public void execute(OperationRequest operation, OperationContext context, ParticipantId participant)
throws InvalidRequestException {
WaveId waveId;
WaveletId waveletId;
AttachmentId attachmentId;
RawAttachmentData attachmentData;
try {
waveId = ApiIdSerializer.instance().deserialiseWaveId(
OperationUtil.<String>getRequiredParameter(operation, ParamsProperty.WAVE_ID));
waveletId = ApiIdSerializer.instance().deserialiseWaveletId(
OperationUtil.<String>getRequiredParameter(operation, ParamsProperty.WAVELET_ID));
attachmentId = AttachmentId.deserialise(OperationUtil.<String>getRequiredParameter(operation,
ParamsProperty.ATTACHMENT_ID));
attachmentData = OperationUtil.<RawAttachmentData>getRequiredParameter(operation,
ParamsProperty.ATTACHMENT_DATA);
} catch (InvalidIdException ex) {
throw new InvalidRequestException("Invalid id", operation, ex);
}
try {
attachmentService.storeAttachment(attachmentId, new ByteArrayInputStream(attachmentData.getData()),
WaveletName.of(waveId, waveletId), attachmentData.getFileName(), ParticipantId.of(attachmentData.getCreator()));
} catch (InvalidParticipantAddress ex) {
throw new InvalidRequestException("Invalid participant " + attachmentData.getCreator(), operation, ex);
} catch (IOException ex) {
LOG.severe("Store attachment", ex);
context.constructErrorResponse(operation, ex.toString());
return;
}