Package com.dotmarketing.exception

Examples of com.dotmarketing.exception.DotDataException


    }
  }

  public User loadUserById(String userId) throws DotDataException, DotSecurityException,com.dotmarketing.business.NoSuchUserException {
    if(!UtilMethods.isSet(userId)){
      throw new DotDataException("You must specifiy an userId to search for");
    }
    User u = uf.loadUserById(userId);
    if(!UtilMethods.isSet(u)){
      throw new com.dotmarketing.business.NoSuchUserException("No user found with passed in email");
    }
View Full Code Here


    return u;
  }

  public User loadByUserByEmail(String email, User user, boolean respectFrontEndRoles) throws DotDataException, DotSecurityException, com.dotmarketing.business.NoSuchUserException {
    if(!UtilMethods.isSet(email)){
      throw new DotDataException("You must specifiy an email to search for");
    }
    User u = uf.loadByUserByEmail(email);
    if(!UtilMethods.isSet(u)){
      throw new com.dotmarketing.business.NoSuchUserException("No user found with passed in email");
    }
View Full Code Here

  public User getDefaultUser() throws DotDataException {
    try {
      return uf.loadDefaultUser();
    } catch (Exception e) {
      throw new DotDataException("getting default user user failed", e);
    }
  }
View Full Code Here

    return uf.getUsersAnRolesByName(filter, start, limit);
  }

  public void save(User userToSave, User user, boolean respectFrontEndRoles) throws DotDataException, DotSecurityException,DuplicateUserException {
    if (userToSave.getUserId() == null) {
      throw new DotDataException("Can't save a user without a userId");
    }
    if(!perAPI.doesUserHavePermission(upAPI.getUserProxy(userToSave,APILocator.getUserAPI().getSystemUser(), false), PermissionAPI.PERMISSION_EDIT, user, respectFrontEndRoles)){
      throw new DotSecurityException("User doesn't have permission to save the user which is trying to be saved");
    }
    uf.saveUser(userToSave);
View Full Code Here

    APILocator.getRoleAPI().getUserRole(userToSave);
  }

  public void delete(User userToDelete, User user, boolean respectFrontEndRoles) throws DotDataException,  DotSecurityException {
    if (userToDelete.getUserId() == null) {
      throw new DotDataException("Can't delete a user without a userId");
    }
    if(!perAPI.doesUserHavePermission(upAPI.getUserProxy(userToDelete,APILocator.getUserAPI().getSystemUser(), false), PermissionAPI.PERMISSION_EDIT, user, respectFrontEndRoles)){
      throw new DotSecurityException("User doesn't have permission to userToDelete the user which is trying to be saved");
    }
    RoleAPI roleAPI = APILocator.getRoleAPI();
View Full Code Here

      perAPI.removePermissions(destinationFolder);

      // Copy the new permissions
      perAPI.copyPermissions(sourceFolder, destinationFolder);
    }catch (Exception e) {
      throw new DotDataException(e.getMessage(), e);
    }
    return;
  }
View Full Code Here

            if(!UtilMethods.isSet(actualFile.getInode())){
              actualFile = (File)APILocator.getVersionableAPI().findWorkingVersion(identifier, user, false);
              WebAssetFactory.unArchiveAsset(actualFile);
            }
            if(!UtilMethods.isSet(actualFile.getInode())){
              throw new DotDataException("unable to locate file");
            }
            //            identifier = idapi.find(actualFile);
            WebAssetFactory.createAsset(file, user.getUserId(),  folder, identifier, false, false);
            if(publish && perAPI.doesUserHavePermission(file, PermissionAPI.PERMISSION_PUBLISH, user)){
              WebAssetFactory.publishAsset(file);
            }

            // ##### Copy the file data if we are creating a new
            // version #####
            String assetsPath = fileAPI.getRealAssetsRootPath();
            new java.io.File(assetsPath).mkdir();

            // creates the new file as
            // inode{1}/inode{2}/inode.file_extension
            java.io.File workingIOFile = fileAPI.getAssetIOFile(actualFile);

            //http://jira.dotmarketing.net/browse/DOTCMS-1873
            //To clear velocity cache
            DotResourceCache vc = CacheLocator.getVeloctyResourceCache();
            vc.remove(ResourceManager.RESOURCE_TEMPLATE + workingIOFile.getPath());

            // If a new version was created, we move the current
            // data to the new version
            if (file != null && InodeUtils.isSet(file.getInode())) {
              byte[] currentData = new byte[0];
              FileInputStream is = new FileInputStream(workingIOFile);
              int size = is.available();
              currentData = new byte[size];
              is.read(currentData);
              java.io.File newVersionFile = fileAPI.getAssetIOFile(file);

              //http://jira.dotmarketing.net/browse/DOTCMS-1873
              //To clear velocity cache
              vc.remove(ResourceManager.RESOURCE_TEMPLATE + newVersionFile.getPath());

              FileChannel channelTo = new FileOutputStream(newVersionFile).getChannel();
              ByteBuffer currentDataBuffer = ByteBuffer.allocate(currentData.length);
              currentDataBuffer.put(currentData);
              currentDataBuffer.position(0);
              channelTo.write(currentDataBuffer);
              channelTo.force(false);
              channelTo.close();
              file.setSize(currentData.length);
              if (UtilMethods.isImage(fileName) && workingIOFile != null) {
                try {
                  // gets image height
                  BufferedImage img = javax.imageio.ImageIO.read(workingIOFile);
                  if(img != null){
                    int height = img.getHeight();
                    file.setHeight(height);
                    // gets image width
                    int width = img.getWidth();
                    file.setWidth(width);
                  }
                } catch (Exception ioe) {
                  Logger.error(this.getClass(), ioe.getMessage(), ioe);
                }
              }
              HibernateUtil.saveOrUpdate(file);
            }
            // ##### END Copy the file data if we are creating a new
            // version #####

            // Get parents of the old version so you can update the
            // working
            // information to this new version.
            java.util.List<Tree> parentTrees = TreeFactory.getTreesByChild(file);

            // update parents to new version delete old versions
            // parents if
            // not live.
            for (Tree tree : parentTrees) {
              // to keep relation types from parent only if it
              // exists
              Tree newTree = TreeFactory.getTree(tree.getParent(), file.getInode());
              if (!InodeUtils.isSet(newTree.getChild())) {
                newTree.setParent(tree.getParent());
                newTree.setChild(file.getInode());
                newTree.setRelationType(tree.getRelationType());
                newTree.setTreeOrder(0);
                TreeFactory.saveTree(newTree);
              }
            }
            APILocator.getVersionableAPI().setWorking(file);
            if(publish && perAPI.doesUserHavePermission(file, PermissionAPI.PERMISSION_PUBLISH, user))
              APILocator.getVersionableAPI().setLive(file);
            WorkingCache.removeAssetFromCache(file);
            LiveCache.removeAssetFromCache(file);
          }

        }
      } else {
        throw new IOException("You don't have access to add that folder/host");
      }
    }catch (Exception e) {
      throw new DotDataException(e.getMessage(), e);
    }

  }
View Full Code Here

      if (InodeUtils.isSet(host.getInode())) {
        path = deleteSpecialCharacter(path);
        try {
          folder = folderAPI.createFolders(path, host,user,false);
        } catch (Exception e) {
          throw new DotDataException(e.getMessage(), e);
        }
      }
    }
    return folder;
  }
View Full Code Here

          LiveCache.removeAssetFromCache(f);
          WorkingCache.removeAssetFromCache(f);
        }

      }catch (Exception e) {
        throw new DotDataException(e.getMessage(),e);
      }
    } else {
      if (UtilMethods.isSet(toParentPath) && !toParentPath.equals("/")) {
        try {
          if (!perAPI.doesUserHavePermission(toParentFolder,  PermissionAPI.PERMISSION_READ, user, false)) {
            throw new IOException("User doesn't have permissions to move file to folder");
          }
        } catch (DotDataException e1) {
          Logger.error(DotWebdavHelper.class,e1.getMessage(),e1);
          throw new IOException(e1.getMessage());
        }
        if (getFolderName(fromPath).equals(getFolderName(toPath))) {
          Logger.debug(this, "Calling Folderfactory to rename " + fromPath + " to " + toPath);
          try{
            Folder folder = folderAPI.findFolderByPath(getPath(toPath), host,user,false);
            removeObject(toPath, user);
            fc.removeFolder(folder,idapi.find(folder));
          }catch (Exception e) {
            Logger.debug(this, "Unable to delete toPath " + toPath);
          }
          boolean renamed = false;
          try{
            Folder folder = folderAPI.findFolderByPath(getPath(fromPath), host,user,false);
            renamed = folderAPI.renameFolder(folder, getFileName(toPath),user,false);
            fc.removeFolder(folder,idapi.find(folder));
            //folderAPI.updateMovedFolderAssets(folder);
          }catch (Exception e) {
            throw new DotDataException(e.getMessage(), e);
          }
          if(!renamed){
            Logger.error(this, "Unable to remame folder");
            throw new IOException("Unable to rename folder");
          }
        } else {
          Logger.debug(this, "Calling folder factory to move from " + fromPath + " to " + toParentPath);
          Folder fromFolder;
          try {
            fromFolder = folderAPI.findFolderByPath(getPath(fromPath), host,user,false);
          } catch (Exception e1) {
            Logger.error(DotWebdavHelper.class, e1.getMessage(), e1);
            throw new DotRuntimeException(e1.getMessage(), e1);
          }
          if(fromFolder != null){
            Logger.debug(this, "Calling folder factory to move from " + idapi.find(fromFolder).getPath() + " to " + toParentPath);
            Logger.debug(this, "the from folder inode is " + fromFolder.getInode());
          }else{
            Logger.debug(this, "The from folder is null");
          }
          try {
            folderAPI.move(fromFolder, toParentFolder,user,false);
            fc.removeFolder(fromFolder,idapi.find(fromFolder));
            fc.removeFolder(toParentFolder,idapi.find(toParentFolder));
            //folderAPI.updateMovedFolderAssets(fromFolder);
          } catch (Exception e) {
            Logger.error(DotWebdavHelper.class, e.getMessage(), e);
            throw new DotDataException(e.getMessage(), e);
          }
        }
      } else {
        try {
          if (!perAPI.doesUserHavePermission(host,PermissionAPI.PERMISSION_READ, user, false)) {
            throw new IOException("User doesn't have permissions to move file to host");
          }
        } catch (DotDataException e) {
          Logger.error(DotWebdavHelper.class,e.getMessage(),e);
          throw new IOException(e.getMessage());
        }
        if (getFolderName(fromPath).equals(getFolderName(toPath))) {
          try{
            Folder fromfolder = folderAPI.findFolderByPath(getPath(fromPath), host,user,false);
            folderAPI.renameFolder(fromfolder, getFileName(toPath),user,false);
            fc.removeFolder(fromfolder,idapi.find(fromfolder));
          }catch (Exception e) {
            throw new DotDataException(e.getMessage(), e);
          }
        } else {
          Folder fromFolder;
          try {
            fromFolder = folderAPI.findFolderByPath(getPath(fromPath), host,user,false);
            folderAPI.move(fromFolder, host,user,false);
            fc.removeFolder(fromFolder,idapi.find(fromFolder));
            //folderAPI.updateMovedFolderAssets(fromFolder);
          } catch (Exception e) {
            Logger.error(DotWebdavHelper.class, e.getMessage(), e);
            throw new DotDataException(e.getMessage(), e);
          }
        }
      }
    }
View Full Code Here

           
            try{
                APILocator.getContentletAPI().archive(fileAssetCont, user, false);
            }catch (Exception e) {
                Logger.error(DotWebdavHelper.class, e.getMessage(), e);
                throw new DotDataException(e.getMessage(), e);
            }
           
            WorkingCache.removeAssetFromCache(fileAssetCont);
            LiveCache.removeAssetFromCache(fileAssetCont);
            fileResourceCache.remove(uri + "|" + user.getUserId());
          }
      } else {
          webAsset = fileAPI.getFileByURI(path, host, false, user, false);
          // This line just archive the assets
          // WebAssetFactory.deleteAsset(file, user.getUserId());
          // This line delete the assets (no archive)
          try{
              WebAssetFactory.archiveAsset(webAsset, user);
          }catch (Exception e) {
              Logger.error(DotWebdavHelper.class, e.getMessage(), e);
              throw new DotDataException(e.getMessage(), e);
          }
          WorkingCache.removeAssetFromCache(webAsset);
          LiveCache.removeAssetFromCache(webAsset);
      }
View Full Code Here

TOP

Related Classes of com.dotmarketing.exception.DotDataException

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.