Package org.hive2hive.core.model

Examples of org.hive2hive.core.model.FolderIndex


  protected void doExecute() throws InvalidProcessStateException, ProcessExecutionException {
    logger.debug("Updating user profile for sharing folder '{}'.", context.getFolder().getName());

    try {
      UserProfile userProfile = profileManager.getUserProfile(getID(), true);
      FolderIndex folderIndex = (FolderIndex) userProfile.getFileByPath(context.getFolder(), root);

      if (!folderIndex.canWrite()) {
        throw new ProcessExecutionException(String.format(
            "Cannot share folder '%s' with read-only access.", folderIndex.getName()));
      } else if (!folderIndex.getSharedFlag() && folderIndex.isSharedOrHasSharedChildren()) {
        // restriction that disallows sharing folders within other shared folders
        throw new ProcessExecutionException(String.format(
            "Folder '%s' is already shared or contains an shared folder.", folderIndex.getName()));
      }

      // check if the folder is already shared with this user
      if (folderIndex.getCalculatedUserList().contains(context.getFriendId())) {
        throw new ProcessExecutionException(String.format(
            "Friend '%s' already has access to folder '%s'.", context.getFriendId(),
            folderIndex.getName()));
      }

      // store for the notification
      context.provideIndex(folderIndex);

      if (folderIndex.getSharedFlag()) {
        // this if-clause allows sharing with multiple users and omits the next if-clause
        logger.debug("Sharing an already shared folder '{}' with friend '{}'.",
            folderIndex.getName(), context.getFriendId());
        folderIndex.addUserPermissions(context.getUserPermission());
      } else {
        // make the node shared with the new protection keys
        folderIndex.share(context.consumeNewProtectionKeys());
        // add read/write user permission of friend
        folderIndex.addUserPermissions(context.getUserPermission());
        // add write user permission of user itself
        folderIndex.addUserPermissions(new UserPermission(userId, PermissionType.WRITE));
      }

      // upload modified profile
      profileManager.readyToPut(userProfile, getID());
View Full Code Here


  protected void doRollback(RollbackReason reason) throws InvalidProcessStateException {
    if (modified) {
      // return to original domain key and put the userProfile
      try {
        UserProfile userProfile = profileManager.getUserProfile(getID(), true);
        FolderIndex folderNode = (FolderIndex) userProfile.getFileById(context.consumeMetaFile()
            .getId());

        // unshare the fileNode
        folderNode.unshare();

        profileManager.readyToPut(userProfile, getID());

        // reset flag
        modified = false;
View Full Code Here

TOP

Related Classes of org.hive2hive.core.model.FolderIndex

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.