本文整理汇总了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);
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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();
}
};
}
示例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>");
}
示例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;
}
示例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);
}
示例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;
}
示例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();
}
示例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;
}
示例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);
}
}
示例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;
}
}
示例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);
}
});
}