コード例 #1
0
  @Override
  public void updateWorkspace(UpdateWorkspaceRequest request)
      throws UserNotFoundException, WorkspaceNotUpdatedException {
    logger.debug(request);

    User user = new User();
    user.setId(request.getUserId());
    Item item = new Item(request.getParentItemId());

    Workspace workspace = new Workspace(request.getWorkspaceId());
    workspace.setName(request.getWorkspaceName());
    workspace.setParentItem(item);

    getHandler().doUpdateWorkspace(user, workspace);

    // Create notification
    UpdateWorkspaceNotification notification =
        new UpdateWorkspaceNotification(
            workspace.getId(), workspace.getName(), workspace.getParentItem().getId());
    notification.setRequestId(request.getRequestId());

    // Send notification to owner
    RemoteClient client;
    try {
      client = broker.lookupMulti(user.getId().toString(), RemoteClient.class);
      client.notifyUpdateWorkspace(notification);
    } catch (RemoteException e1) {
      logger.error(String.format("Could not notify user: '******'", user.getId()), e1);
    }
  }
コード例 #2
0
  @Override
  public void createShareProposal(ShareProposalRequest request)
      throws ShareProposalNotCreatedException, UserNotFoundException {

    logger.debug(request);

    User user = new User();
    user.setId(request.getUserId());

    Item item = new Item(request.getItemId());

    // Create share proposal
    Workspace workspace =
        getHandler().doShareFolder(user, request.getEmails(), item, request.isEncrypted());

    // Create notification
    ShareProposalNotification notification =
        new ShareProposalNotification(
            workspace.getId(),
            workspace.getName(),
            item.getId(),
            workspace.getOwner().getId(),
            workspace.getOwner().getName(),
            workspace.getSwiftContainer(),
            workspace.getSwiftUrl(),
            workspace.isEncrypted());

    notification.setRequestId(request.getRequestId());

    // Send notification to owner
    RemoteClient client;
    try {
      client = broker.lookupMulti(user.getId().toString(), RemoteClient.class);
      client.notifyShareProposal(notification);
    } catch (RemoteException e1) {
      logger.error(String.format("Could not notify user: '******'", user.getId()), e1);
    }

    // Send notifications to users
    for (User addressee : workspace.getUsers()) {
      try {
        client = broker.lookupMulti(addressee.getId().toString(), RemoteClient.class);
        client.notifyShareProposal(notification);
      } catch (RemoteException e) {
        logger.error(String.format("Could not notify user: '******'", addressee.getId()), e);
      }
    }
  }