Package com.dotmarketing.portlets.files.model

Examples of com.dotmarketing.portlets.files.model.File


    if(!isLegacyFilesSupported()){
      //throw new DotStateException("File Assets have been disabled.");
    }

    String fileName = UtilMethods.getFileName(file.getFileName());
    File currentFile = getWorkingFileByFileName(file.getFileName(), folder, user, respectFrontendRoles);

    boolean fileExists = (currentFile != null) && InodeUtils.isSet(currentFile.getInode());

    if (fileExists) {
      if (!permissionAPI.doesUserHavePermission(currentFile, PermissionAPI.PERMISSION_READ, user, respectFrontendRoles)) {
        throw new DotSecurityException("You don't have permission to read the source file.");
      }
    }

    if (!permissionAPI.doesUserHavePermission(folder, PermissionAPI.PERMISSION_WRITE, user, respectFrontendRoles)) {
      throw new DotSecurityException("You don't have permission to write in the destination folder.");
    }

    File workingFile = null;

    try {
      long uploadFileMaxSize = Long.parseLong(Config.getStringProperty("UPLOAD_FILE_MAX_SIZE"));

      // Checking the max file size
View Full Code Here


    return QueryUtil.DBSearch(query, dbColToObjectAttribute, null, user, true, respectFrontendRoles);
  }

  public File getWorkingFileById(String fileId, User user, boolean respectFrontendRoles) throws DotDataException, DotSecurityException {

    File file = (File) vapi.findWorkingVersion(fileId, user, respectFrontendRoles);
    if (file == null)
      return file;
    if (!permissionAPI.doesUserHavePermission(file, PermissionAPI.PERMISSION_READ, user, respectFrontendRoles))
      throw new DotSecurityException("User " + user.getUserId() + "has no permissions to read file id " + fileId);
View Full Code Here

    return file;
  }

  public File get(String inode, User user, boolean respectFrontendRoles) throws DotHibernateException, DotSecurityException,
      DotDataException {
    File file = ffac.get(inode);

    if (!permissionAPI.doesUserHavePermission(file, PermissionAPI.PERMISSION_READ, user, respectFrontendRoles)) {
      throw new DotSecurityException(WebKeys.USER_PERMISSIONS_EXCEPTION);
    }
View Full Code Here

  }

  public File getFileByURI(String uri, Host host, boolean live, User user, boolean respectFrontendRoles) throws DotDataException,
      DotSecurityException {
    File file = ffac.getFileByURI(uri, host, live);
    if (file!=null && !permissionAPI.doesUserHavePermission(file, PermissionAPI.PERMISSION_READ, user, respectFrontendRoles)) {
      throw new DotSecurityException(WebKeys.USER_PERMISSIONS_EXCEPTION);
    }
    return file;
  }
View Full Code Here

    return file;
  }

  public File getFileByURI(String uri, String hostId, boolean live, User user, boolean respectFrontendRoles) throws DotDataException,
      DotSecurityException {
    File file = ffac.getFileByURI(uri, hostId, live);
    if (!permissionAPI.doesUserHavePermission(file, PermissionAPI.PERMISSION_READ, user, respectFrontendRoles)) {
      throw new DotSecurityException(WebKeys.USER_PERMISSIONS_EXCEPTION);
    }
    return file;
  }
View Full Code Here

  }
 

  public File find(String inode, User user, boolean respectFrontendRoles) throws DotStateException, DotDataException, DotSecurityException{

    File file = fcache.get(inode);
   
    if(file ==null){
      file = ffac.get(inode);
      if(file != null && UtilMethods.isSet(file.getInode())){
        fcache.add(file);
      }
      else{
        file = new File();
        file.setInode(inode);
        file.setIdentifier(Constants.FOUR_OH_FOUR_RESPONSE);
        fcache.add(file);
      }
    }
    if(Constants.FOUR_OH_FOUR_RESPONSE.equals(file.getIdentifier())){
      return null;
    }
    if (!permissionAPI.doesUserHavePermission(file, PermissionAPI.PERMISSION_READ, user, respectFrontendRoles)) {
      throw new DotSecurityException(WebKeys.USER_PERMISSIONS_EXCEPTION);
    }
View Full Code Here

      localTransation =  DbConnectionFactory.getConnection().getAutoCommit();
      if (localTransation) {
        HibernateUtil.startTransaction();
      }
      // old working file
      File oldFile = null;
      // if new identifier
      if (identifier == null || !InodeUtils.isSet(identifier.getInode())) {
        identifier = APILocator.getIdentifierAPI().createNew(newFile, parentFolder);
        newFile.setIdentifier(identifier.getInode());
        HibernateUtil.save(newFile);
        APILocator.getVersionableAPI().setWorking(newFile);
        saveFileData(newFile, null, dataFile);
      }else{
        APILocator.getVersionableAPI().removeLive(identifier.getId());
      }
      if (UtilMethods.isSet(dataFile)) {
        HibernateUtil.save(newFile);
        saveFileData(newFile, null, dataFile);
      }
      if (oldFile != null && InodeUtils.isSet(oldFile.getInode())) {
        APILocator.getFileAPI().invalidateCache(oldFile);
        fileCache.remove(oldFile);
        WorkingCache.removeAssetFromCache(oldFile);
      }
      LiveCache.removeAssetFromCache(newFile);
View Full Code Here

      return null;
    return files.get(0);
  }

  public File get(String inode) throws DotStateException, DotDataException, DotSecurityException {
    File file = fileCache.get(inode);

    if ((file == null) || !InodeUtils.isSet(file.getInode())) {
      file = (File) HibernateUtil.load(File.class, inode);

      fileCache.add(file);
      WorkingCache.removeAssetFromCache(file);
      WorkingCache.addToWorkingAssetToCache(file);
      LiveCache.removeAssetFromCache(file);
      if (file.isLive()) {
        LiveCache.addToLiveAssetToCache(file);
      }
    }

    return file;
View Full Code Here

     * @throws IOException
     * @throws DotHibernateException
     */
    private File copyFile ( File file, Folder parent, Host host ) throws DotDataException, IOException {

        File newFile = new File();

        newFile.copy( file );
        newFile.setParent(parent.getInode());

        // gets filename before extension
        String fileName = com.dotmarketing.util.UtilMethods.getFileName( file.getFileName() );
        // gets file extension
        String fileExtension = com.dotmarketing.util.UtilMethods.getFileExtension( file.getFileName() );

        Boolean fileNameExists;
        if (parent != null) {
            fileNameExists = fileNameExists( parent, file.getFileName() );
        } else {
            fileNameExists = fileNameExists( APILocator.getFolderAPI().findSystemFolder(), file.getFileName() );
        }

        // Setting file name
        if ( fileNameExists ) {
            // adds "copy" word to the filename
            newFile.setFileName( fileName + "_copy." + fileExtension );
            newFile.setFriendlyName( file.getFriendlyName() + " (COPY) " );
        } else {
            newFile.setFileName( fileName + "." + fileExtension );
        }

        Identifier identifier;
        if ( parent != null ) {
            identifier = APILocator.getIdentifierAPI().createNew( newFile, parent );
        } else {
            identifier = APILocator.getIdentifierAPI().createNew( newFile, host );
        }
        newFile.setIdentifier( identifier.getInode() );

        // persists the webasset
        HibernateUtil.saveOrUpdate( newFile );

        saveFileData( file, newFile, null );
View Full Code Here

      boolean islive = false;


    for (Versionable version : versions) {
      File f = (File)version;


        // sets filename for this new file
        f.setFileName(newFileName);

        HibernateUtil.saveOrUpdate(f);

        if (f.isLive())
          islive = true;
      }

    LiveCache.removeAssetFromCache(file);
    WorkingCache.removeAssetFromCache(file);
View Full Code Here

TOP

Related Classes of com.dotmarketing.portlets.files.model.File

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.