當前位置: 首頁>>代碼示例>>Java>>正文


Java InvalidIdException類代碼示例

本文整理匯總了Java中org.waveprotocol.wave.model.id.InvalidIdException的典型用法代碼示例。如果您正苦於以下問題:Java InvalidIdException類的具體用法?Java InvalidIdException怎麽用?Java InvalidIdException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


InvalidIdException類屬於org.waveprotocol.wave.model.id包,在下文中一共展示了InvalidIdException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: elementStart

import org.waveprotocol.wave.model.id.InvalidIdException; //導入依賴的package包/類
@Override
public void elementStart(String type, Attributes attrs) {
  if ("conversation".equals(documentId) && "conversation".equals(type)) {
    StringMap<String> newAttrs = CollectionUtils.newStringMap();
    for (Map.Entry<String, String> entry : attrs.entrySet()) {
      if (!"anchorWavelet".equals(entry.getKey())) {
        newAttrs.put(entry.getKey(), entry.getValue());
      } else {
        String newValue;
        try {
          newValue = ModernIdSerialiser.INSTANCE.serialiseWaveletId(
              LegacyIdSerialiser.INSTANCE.deserialiseWaveletId(entry.getValue()));
        } catch (InvalidIdException e) {
          throw new InvalidInputException("Failed to convert anchorWavelet: " + attrs);
        }
        log.info("Replacing " + entry + " with value " + newValue);
        newAttrs.put(entry.getKey(), newValue);
      }
    }
    attrs = AttributesImpl.fromStringMap(newAttrs);
  }
  super.elementStart(type, attrs);
}
 
開發者ID:ArloJamesBarnes,項目名稱:walkaround,代碼行數:24,代碼來源:PrivateReplyAnchorLegacyIdConverter.java

示例2: getIdsFromRequest

import org.waveprotocol.wave.model.id.InvalidIdException; //導入依賴的package包/類
/**
 * Get the attachment Ids from the URL in the request.
 *
 * @param request
 * @return the list of Ids.
 */
private static List<AttachmentId> getIdsFromRequest(HttpServletRequest request) {
  String par = request.getParameter("attachmentIds");
  if (par != null) {
    List<AttachmentId> ids = new ArrayList<AttachmentId>();
    for (String id : par.split(",", -1)) {
      try {
        ids.add(AttachmentId.deserialise(id));
      } catch (InvalidIdException ex) {
        LOG.log(Level.SEVERE, "Deserialize attachment Id " + id, ex);
      }
    }
    return ids;
  }
  return null;
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:22,代碼來源:AttachmentInfoServlet.java

示例3: execute

import org.waveprotocol.wave.model.id.InvalidIdException; //導入依賴的package包/類
@Override
public void execute(OperationRequest operation, OperationContext context, ParticipantId participant)
    throws InvalidRequestException {
  WaveId waveId;
  WaveletId waveletId;
  try {
    waveId = ApiIdSerializer.instance().deserialiseWaveId(
      OperationUtil.<String>getRequiredParameter(operation, ParamsProperty.WAVE_ID));
    waveletId = ApiIdSerializer.instance().deserialiseWaveletId(
      OperationUtil.<String>getRequiredParameter(operation, ParamsProperty.WAVELET_ID));
  } catch (InvalidIdException ex) {
    throw new InvalidRequestException("Invalid id", operation, ex);
  }
  WaveletName waveletName = WaveletName.of(waveId, waveletId);
  ReadableWaveletData snapshot = context.getWaveletSnapshot(waveletName, participant);
  if (snapshot == null) {
    context.constructErrorResponse(operation, "Can't get snapshot");
    return;
  }
  WaveletSnapshot protoSnapshot = SnapshotSerializer.serializeWavelet(snapshot);
  WaveletSnapshotProtoImpl protoSnapshotImpl = new WaveletSnapshotProtoImpl(protoSnapshot);
  String jsonSnapshot = gson.toJson(protoSnapshotImpl.toGson(null, gson));
  Map<ParamsProperty, Object> data =
    ImmutableMap.<ParamsProperty, Object> of(ParamsProperty.RAW_SNAPSHOT, jsonSnapshot);
  context.constructResponse(operation, data);
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:27,代碼來源:ExportSnapshotService.java

示例4: getVisibleWaveletIds

import org.waveprotocol.wave.model.id.InvalidIdException; //導入依賴的package包/類
@Override
public ImmutableSet<WaveletId> getVisibleWaveletIds(OperationRequest operation, ParticipantId participant)
    throws InvalidRequestException {
  Set<WaveletId> waveletIds = new HashSet<WaveletId>();
  try {
    WaveId waveId = ApiIdSerializer.instance().deserialiseWaveId(
        OperationUtil.<String>getRequiredParameter(operation, ParamsProperty.WAVE_ID));
    ImmutableSet<WaveletId> ids = waveletProvider.getWaveletIds(waveId);
    for (WaveletId waveletId: ids) {
      WaveletName waveletName = WaveletName.of(waveId, waveletId);
      if (waveletProvider.checkAccessPermission(waveletName, participant)) {
        waveletIds.add(waveletId);
      }
    }
  } catch (InvalidIdException ex) {
    throw new InvalidRequestException("Invalid id", operation, ex);
  } catch (WaveServerException e) {
    LOG.severe("Error of access to wave", e);
  }
  return ImmutableSet.copyOf(waveletIds);
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:22,代碼來源:OperationContextImpl.java

示例5: buildSupplement

import org.waveprotocol.wave.model.id.InvalidIdException; //導入依賴的package包/類
/**
 * Builds the supplement model for a wave.
 *
 * @param operation the operation.
 * @param context the operation context.
 * @param participant the viewer.
 * @return the wave supplement.
 * @throws InvalidRequestException if the wave id provided in the operation is
 *         invalid.
 */
public static SupplementedWave buildSupplement(OperationRequest operation,
    OperationContext context, ParticipantId participant) throws InvalidRequestException, OperationException {
  OpBasedWavelet wavelet = context.openWavelet(operation, participant);
  ConversationView conversationView = context.getConversationUtil().buildConversation(wavelet);

  // TODO (Yuri Z.) Find a way to obtain an instance of IdGenerator and use it
  // to create udwId.
  String waveIdStr = OperationUtil.getRequiredParameter(operation, ParamsProperty.WAVE_ID);
  WaveId waveId = null;
  try {
    waveId = ApiIdSerializer.instance().deserialiseWaveId(waveIdStr);
  } catch (InvalidIdException e) {
    throw new InvalidRequestException("Invalid WAVE_ID parameter: " + waveIdStr, operation, e);
  }
  WaveletId udwId = buildUserDataWaveletId(participant, waveId.getDomain());
  OpBasedWavelet udw = context.openWavelet(waveId, udwId, participant);

  PrimitiveSupplement udwState = WaveletBasedSupplement.create(udw);

  SupplementedWave supplement =
    SupplementedWaveImpl.create(udwState, conversationView, participant, DefaultFollow.ALWAYS);
  return supplement;
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:34,代碼來源:OperationUtil.java

示例6: getAttachment

import org.waveprotocol.wave.model.id.InvalidIdException; //導入依賴的package包/類
@Override
public ApiAttachment getAttachment(String attachmentId) throws IOException, InvalidIdException {
  final AttachmentMetadata metadata = attachmentService.getMetadata(AttachmentId.deserialise(attachmentId));
  if (metadata == null) {
    return null;
  }
  return new ApiAttachment() {
    @Override
    public String getMimeType() {
      return metadata.getMimeType();
    }

    @Override
    public String getFileName() {
      return metadata.getFileName();
    }
  };
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:19,代碼來源:RobotAttachmentProvider.java

示例7: deserialise

import org.waveprotocol.wave.model.id.InvalidIdException; //導入依賴的package包/類
/**
 * Creates an AttachmentId from a serialized attachment id.
 *
 * @param attachmentIdString a serialized attachment id
 * @return an AttachmentId
 * @throws InvalidIdException if the id cannot be parsed.
 */
public static AttachmentId deserialise(String attachmentIdString)
    throws InvalidIdException {
  Preconditions.checkNotNull(attachmentIdString, "Null attachmentIdString");
  String[] parts = attachmentIdString.split(ATTACHMENT_PART_SEPARATOR);

  // Two part ids are the expected case (eg. domain/id).
  if (parts.length == 2) {
    return new AttachmentId(parts[0], parts[1]);
  }

  // One part ids are for legacy ids (pre-migration).
  // TODO(user): Remove support for legacy ids after the migration.
  if (parts.length == 1) {
    return new AttachmentId("", parts[0]);
  }

  // Not a valid id, throw an exception.
  throw new InvalidIdException(attachmentIdString,
      "Unable to deserialise the attachment id: " + attachmentIdString +
      ". The attachment id needs to look like <domain>/<id> or <id>");
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:29,代碼來源:AttachmentId.java

示例8: deserialize

import org.waveprotocol.wave.model.id.InvalidIdException; //導入依賴的package包/類
private ObservableWaveletData deserialize(WaveId waveId, WaveletSnapshot snapshot) {
  WaveletId id;
  try {
    id = ModernIdSerialiser.INSTANCE.deserialiseWaveletId(snapshot.getWaveletId());
  } catch (InvalidIdException e) {
    throw new IllegalArgumentException(e);
  }
  ParticipantId creator = ParticipantId.ofUnsafe(snapshot.getParticipantId(0));
  HashedVersion version = deserialize(snapshot.getVersion());
  long lmt = snapshot.getLastModifiedTime();
  long ctime = snapshot.getCreationTime();
  long lmv = version.getVersion();

  WaveletDataImpl waveletData =
      new WaveletDataImpl(id, creator, ctime, lmv, version, lmt, waveId, docFactory);
  for (String participant : snapshot.getParticipantId()) {
    waveletData.addParticipant(new ParticipantId(participant));
  }
  for (DocumentSnapshot docSnapshot : snapshot.getDocument()) {
    deserialize(waveletData, docSnapshot);
  }
  return waveletData;
}
 
開發者ID:apache,項目名稱:incubator-wave,代碼行數:24,代碼來源:RemoteWaveViewService.java

示例9: execute

import org.waveprotocol.wave.model.id.InvalidIdException; //導入依賴的package包/類
@Override
public void execute(OperationRequest operation, OperationContext context, ParticipantId participant)
    throws InvalidRequestException {
  WaveId waveId;
  WaveletId waveletId;
  try {
    waveId = ApiIdSerializer.instance().deserialiseWaveId(
      OperationUtil.<String>getRequiredParameter(operation, ParamsProperty.WAVE_ID));
    waveletId = ApiIdSerializer.instance().deserialiseWaveletId(
      OperationUtil.<String>getRequiredParameter(operation, ParamsProperty.WAVELET_ID));
  } catch (InvalidIdException ex) {
    throw new InvalidRequestException("Invalid id", operation, ex);
  }
  WaveletName waveletName = WaveletName.of(waveId, waveletId);
  CommittedWaveletSnapshot snapshot = context.getWaveletSnapshot(waveletName, participant);
  WaveletSnapshot protoSnapshot = SnapshotSerializer.serializeWavelet(snapshot.snapshot, snapshot.snapshot.getHashedVersion());
  WaveletSnapshotProtoImpl protoSnapshotImpl = new WaveletSnapshotProtoImpl(protoSnapshot);
  String jsonSnapshot = gson.toJson(protoSnapshotImpl.toGson(null, gson));
  Map<ParamsProperty, Object> data =
    ImmutableMap.<ParamsProperty, Object> of(ParamsProperty.RAW_SNAPSHOT, jsonSnapshot);
  context.constructResponse(operation, data);
}
 
開發者ID:apache,項目名稱:incubator-wave,代碼行數:23,代碼來源:ExportSnapshotService.java

示例10: buildSupplement

import org.waveprotocol.wave.model.id.InvalidIdException; //導入依賴的package包/類
/**
 * Builds the supplement model for a wave.
 *
 * @param operation the operation.
 * @param context the operation context.
 * @param participant the viewer.
 * @return the wave supplement.
 * @throws InvalidRequestException if the wave id provided in the operation is
 *         invalid.
 */
public static SupplementedWave buildSupplement(OperationRequest operation,
    OperationContext context, ParticipantId participant) throws InvalidRequestException {
  OpBasedWavelet wavelet = context.openWavelet(operation, participant);
  ConversationView conversationView = context.getConversationUtil().buildConversation(wavelet);

  // TODO (Yuri Z.) Find a way to obtain an instance of IdGenerator and use it
  // to create udwId.
  WaveletId udwId = IdUtil.buildUserDataWaveletId(participant);
  String waveIdStr = OperationUtil.getRequiredParameter(operation, ParamsProperty.WAVE_ID);
  WaveId waveId = null;
  try {
    waveId = ApiIdSerializer.instance().deserialiseWaveId(waveIdStr);
  } catch (InvalidIdException e) {
    throw new InvalidRequestException("Invalid WAVE_ID parameter: " + waveIdStr, operation, e);
  }
  OpBasedWavelet udw = context.openWavelet(waveId, udwId, participant);

  PrimitiveSupplement udwState = WaveletBasedSupplement.create(udw);

  SupplementedWave supplement =
      SupplementedWaveImpl.create(udwState, conversationView, participant, DefaultFollow.ALWAYS);
  return supplement;
}
 
開發者ID:apache,項目名稱:incubator-wave,代碼行數:34,代碼來源:OperationUtil.java

示例11: popupLink

import org.waveprotocol.wave.model.id.InvalidIdException; //導入依賴的package包/類
@Override
public void popupLink(BlipView blipUi) {
  ConversationBlip blip = views.getBlip(blipUi);
  // TODO(Yuri Z.) Change to use the conversation model when the Conversation
  // exposes a reference to its ConversationView.
  WaveId waveId = blip.hackGetRaw().getWavelet().getWaveId();
  WaveletId waveletId;
  try {
    waveletId = DualIdSerialiser.MODERN.deserialiseWaveletId(blip.getConversation().getId());
  } catch (InvalidIdException e) {
    Window.alert(messages.invalidWaveletId(blip.getConversation().getId()));
    return;
  }
  WaveRef waveRef = WaveRef.of(waveId, waveletId, blip.getId());
  final String waveRefStringValue =
      WaveRefConstants.WAVE_URI_PREFIX + GwtWaverefEncoder.encodeToUriPathSegment(waveRef);
  BlipLinkPopupView blipLinkPopupView = blipUi.createLinkPopup();
  blipLinkPopupView.setLinkInfo(waveRefStringValue);
  blipLinkPopupView.show();
}
 
開發者ID:apache,項目名稱:incubator-wave,代碼行數:21,代碼來源:ActionsImpl.java

示例12: getAttachemntIds

import org.waveprotocol.wave.model.id.InvalidIdException; //導入依賴的package包/類
/**
 * Extract attachment ids from operations.
 */
public static Set<AttachmentId> getAttachemntIds(ProtocolWaveletDelta delta) {
  Set<AttachmentId> ids = new HashSet<AttachmentId>();
  for (int i=0; i < delta.getOperationCount(); i++) {
    ProtocolWaveletOperation op = delta.getOperation(i);
    if (op.hasMutateDocument()) {
      MutateDocument doc = op.getMutateDocument();
      for (int c = 0; c < doc.getDocumentOperation().getComponentCount(); c++) {
        Component comp = doc.getDocumentOperation().getComponent(c);
        ElementStart start = comp.getElementStart();
        if (ImageConstants.TAGNAME.equals(start.getType())) {
          for (int a=0; a < start.getAttributeCount(); a++) {
            Component.KeyValuePair attr = start.getAttribute(a);
            if (ImageConstants.ATTACHMENT_ATTRIBUTE.equals(attr.getKey())) {
              try {
                ids.add(AttachmentId.deserialise(attr.getValue()));
              } catch (InvalidIdException ex) {
                Console.error("Invalid attachment Id " + attr.getValue(), ex);
              }
            }
          }
        }
      }
    }
  }
  return ids;
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:30,代碼來源:DeltaParser.java

示例13: deserializeWaveletId

import org.waveprotocol.wave.model.id.InvalidIdException; //導入依賴的package包/類
private static WaveletId deserializeWaveletId(String waveId) {
  try {
    return ModernIdSerialiser.INSTANCE.deserialiseWaveletId(waveId);
  } catch (InvalidIdException ex) {
    throw new IllegalArgumentException(ex);
  }
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:8,代碼來源:RemoteWaveViewService.java

示例14: getAttachmentIdFromRequest

import org.waveprotocol.wave.model.id.InvalidIdException; //導入依賴的package包/類
private static AttachmentId getAttachmentIdFromRequest(HttpServletRequest request) {
  if (request.getPathInfo().length() == 0) {
    return null;
  }
  String id = getAttachmentIdStringFromRequest(request);
  try {
    return AttachmentId.deserialise(id);
  } catch (InvalidIdException ex) {
    LOG.log(Level.SEVERE, "Deserialize attachment Id " + id, ex);
    return null;
  }
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:13,代碼來源:AttachmentServlet.java

示例15: execute

import org.waveprotocol.wave.model.id.InvalidIdException; //導入依賴的package包/類
@Override
public void execute(final OperationRequest operation, final OperationContext context, ParticipantId participant)
    throws InvalidRequestException {
  WaveId waveId;
  WaveletId waveletId;
  HashedVersion startVersion;
  HashedVersion endVersion;
  try {
    waveId = ApiIdSerializer.instance().deserialiseWaveId(
      OperationUtil.<String>getRequiredParameter(operation, ParamsProperty.WAVE_ID));
    waveletId = ApiIdSerializer.instance().deserialiseWaveletId(
      OperationUtil.<String>getRequiredParameter(operation, ParamsProperty.WAVELET_ID));
  } catch (InvalidIdException ex) {
    throw new InvalidRequestException("Invalid id", operation, ex);
  }
  startVersion = getVersionParameter(operation, ParamsProperty.FROM_VERSION);
  endVersion = getVersionParameter(operation, ParamsProperty.TO_VERSION);
  WaveletName waveletName = WaveletName.of(waveId, waveletId);
  getDeltas(context, waveletName, participant, startVersion, endVersion, new RawDeltasListener() {

        @Override
        public void onSuccess(List<byte[]> rawDeltas, byte[] rawTargetVersion) {
          Map<ParamsProperty, Object> data = ImmutableMap.<ParamsProperty, Object> of(
            ParamsProperty.RAW_DELTAS,  rawDeltas,
            ParamsProperty.TARGET_VERSION, rawTargetVersion);
          context.constructResponse(operation, data);
        }

        @Override
        public void onFailure(String message) {
          context.constructErrorResponse(operation, message);
        }
      });
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:35,代碼來源:ExportDeltasService.java


注:本文中的org.waveprotocol.wave.model.id.InvalidIdException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。