Package com.google.wave.api.impl

Examples of com.google.wave.api.impl.RawAttachmentData


  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;
    }
View Full Code Here


    } catch (IOException ex) {
      LOG.info("Get attachment", ex);
      context.constructErrorResponse(operation, ex.toString());
      return;
    }
    RawAttachmentData attachment = new RawAttachmentData(meta.getFileName(), meta.getCreator(),
        data);
    Map<ParamsProperty, Object> parameters =
      ImmutableMap.<ParamsProperty, Object> of(ParamsProperty.ATTACHMENT_DATA, attachment);
    context.constructResponse(operation, parameters);
  }
View Full Code Here

  private void importAttachments(WaveId sourceWaveId, WaveletId sourceWaveletId,
      WaveId targetWaveId, WaveletId targetWaveletId, Set<AttachmentId> attachmentIds)
      throws FileNotFoundException, IOException {
    for (AttachmentId attachmentId : attachmentIds) {
      String attachmentFile = fileNames.getAttachmentFilePath(sourceWaveId, sourceWaveletId, attachmentId);
      RawAttachmentData attachmentData = gson.fromJson(readFile(new File(attachmentFile)), RawAttachmentData.class);
      Console.print("    importing attachment " + attachmentId.serialise() + " ...");
      api.importAttachment(targetWaveId, targetWaveletId, attachmentId, attachmentData, rpcServerUrl);
      Console.println(" Ok");
    }
  }
View Full Code Here

    }
  }

  private void exportAttachment(WaveId waveId, WaveletId waveletId, AttachmentId attachmentId) throws IOException {
    Console.print("    getting attachment " + attachmentId.getId() + " ...");
    RawAttachmentData attachment = api.exportAttachment(attachmentId, rpcServerUrl);
    writeAttachmentToFile(waveId, waveletId, attachmentId, attachment);
    Console.println(" Ok");
  }
View Full Code Here

TOP

Related Classes of com.google.wave.api.impl.RawAttachmentData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.