@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);
      }
    }
  }
Example #2
0
  public CloneWorkspace(Workspace r) {
    this.id = r.getId().toString();
    this.name = r.getName();

    this.parentId = null;
    if (r.getParentItem() != null && r.getParentItem().getId() != null) {
      this.parentId = r.getParentItem().getId();
    }

    this.defaultWorkspace = !r.isShared();
    this.localLastUpdate = r.getLatestRevision();
    this.remoteLastUpdate = r.getLatestRevision();
    this.swiftContainer = r.getSwiftContainer();
    this.swiftStorageURL = r.getSwiftUrl();
    this.owner = r.getOwner().getId().toString();
    this.pathWorkspace = generatePath();
    this.encrypted = true;

    if (!defaultWorkspace) this.encrypted = r.isEncrypted();
  }