Package com.liferay.portal.struts

Examples of com.liferay.portal.struts.ActionException


            isCMSOwner = true;
            break;
          }
        }
        if(!isCMSOwner){
          throw new ActionException(WebKeys.USER_PERMISSIONS_EXCEPTION);
        }
      }else{
        throw new ActionException(WebKeys.USER_PERMISSIONS_EXCEPTION);
     
         
    }

    // calls the Contentlet API delete the container version
View Full Code Here


          SessionMessages.add(httpReq, "custommessage", message);
        } catch (Exception e) {
          SessionMessages.add(httpReq, "message", "message." + webAsset.getType() + ".edit.locked");
        }

        throw (new ActionException(WebKeys.EDIT_ASSET_EXCEPTION));
      }
    }

    Folder parentFolder = new Folder();
        String parent = req.getParameter("parent");
View Full Code Here

      Role cmsOwner;
      try {
        cmsOwner = APILocator.getRoleAPI().loadCMSOwnerRole();
      } catch (DotDataException e) {
        Logger.error(DotPortletAction.class,e.getMessage(),e);
        throw new ActionException(e);
      }
      boolean isCMSOwner = false;
      if(rolesPublish.size() > 0 || rolesWrite.size() > 0){
        for (Role role : rolesPublish) {
          if(role.getId().equals(cmsOwner.getId())){
            isCMSOwner = true;
            break;
          }
        }
        if(!isCMSOwner){
          for (Role role : rolesWrite) {
            if(role.getId().equals(cmsOwner.getId())){
              isCMSOwner = true;
              break;
            }
          }
        }
        if(!isCMSOwner){
          throw new ActionException(WebKeys.USER_PERMISSIONS_EXCEPTION);
        }
      }else{
        throw new ActionException(WebKeys.USER_PERMISSIONS_EXCEPTION);
     
         
    }
  }
View Full Code Here

    Host host=APILocator.getHostAPI().find(hostId, user, false);

    //check permissions
    if(isRootHost) {
        if(!APILocator.getPermissionAPI().doesUserHavePermission(host, PERMISSION_CAN_ADD_CHILDREN, user))
            throw new ActionException(WebKeys.USER_PERMISSIONS_EXCEPTION);
    }
    else {
        _checkUserPermissions(folder, user, PERMISSION_CAN_ADD_CHILDREN);
    }

    String fileNamesStr = ParamUtil.getString(req, "fileNames");
    if(!UtilMethods.isSet(fileNamesStr))
      throw new ActionException(LanguageUtil.get(user, "message.file_asset.alert.please.upload"));

    String selectedStructureInode = ParamUtil.getString(req, "selectedStructure");
    if(!UtilMethods.isSet(selectedStructureInode))
      selectedStructureInode = StructureCache.getStructureByVelocityVarName(FileAssetAPI.DEFAULT_FILE_ASSET_STRUCTURE_VELOCITY_VAR_NAME).getInode();

    String[] fileNamesArray = fileNamesStr.split(WebKeys.CONTENTLET_FORM_NAME_VALUE_SEPARATOR);
    String customMessage = LanguageUtil.get(user, "message.file_asset.error.filename.filters") + ": ";
    if(fileNamesArray.length > 2)
      SessionMessages.add(req, "custommessage", LanguageUtil.get(user, "message.contentlets.batch.reindexing.background"));
    boolean filterError = false;

    List<String> existingFileNames = new ArrayList<String>();
    for (int k=0;k<fileNamesArray.length;k++) {
      try{
        HibernateUtil.startTransaction();
        Contentlet contentlet = new Contentlet();
        contentlet.setStructureInode(selectedStructureInode);
        contentlet.setHost(hostId);
        contentlet.setFolder(folder.getInode());
        String fileName = fileNamesArray[k];
        String title = getFriendlyName(fileName);

        fileName = checkMACFileName(fileName);

        if(!APILocator.getFolderAPI().matchFilter(folder,fileName))
              {
           customMessage += fileName + ", ";
                 filterError = true;
                 continue;
              }

        if (fileName.length()>0) {

                    //sets filename for this new file
                    contentlet.setStringProperty("title", title);
                    contentlet.setStringProperty("fileName", fileName);

                    java.io.File uploadedFile = uploadReq.getFile(fileName);
                    contentlet.setBinary("fileAsset", uploadedFile);

                    if ( uploadedFile != null ) {

                        //checks if another identifier with the same name exists in the same folder
                        if (APILocator.getFileAssetAPI().fileNameExists(host, folder, fileName, "")) {
                            throw new DuplicateFileException(fileName);
                        }

                        contentlet = APILocator.getContentletAPI().checkin( contentlet, user, false );
                        if ( (subcmd != null) && subcmd.equals( com.dotmarketing.util.Constants.PUBLISH ) ) {
                            if ( isRootHost
                                    && !APILocator.getPermissionAPI().doesUserHaveInheriablePermissions( host, File.class.getCanonicalName(), PermissionAPI.PERMISSION_PUBLISH, user )
                                    && !isAdmin ) {
                                throw new ActionException( WebKeys.USER_PERMISSIONS_EXCEPTION );
                            }

                            APILocator.getVersionableAPI().setLive( contentlet );
                        }
View Full Code Here

      if(APILocator.getFileAPI().moveFile(webAsset, parent, user, false)) {
        SessionMessages.add(req, "message", "message.file_asset.move");
      } else {
        SessionMessages.add(req, "error", "message.file_asset.error.filename.exists");
        throw new ActionException("message.file_asset.error.filename.exists");
      }
      APILocator.getFileAPI().invalidateCache(webAsset);
    }
   
  }
View Full Code Here

     
      if(haveUpload) {
        if ((uploadFileMaxSize > 0) && (uploadedFile.length() > uploadFileMaxSize)) {
          // when there is an error saving should unlock working asset
          WebAssetFactory.unLockAsset(currentFile);
          throw new ActionException();
        }
      }
     
     
      // CHECK THE FOLDER PATTERN
      if (UtilMethods.isSet(file.getFileName()) && !APILocator.getFolderAPI().matchFilter(folder, file.getFileName())) {
        SessionMessages.add(req, "error", "message.file_asset.error.filename.filters");
        // when there is an error saving should unlock working asset
        WebAssetFactory.unLockAsset(currentFile);
        throw new ActionException("message.file_asset.error.filename.filters");
      }
     
     
      // Checking permissions
      _checkPermissions(currentFile, folder, user, httpReq);
     
     
      //Setting some flags
      boolean editing = (InodeUtils.isSet(currentFile.getInode()));

     

      if(!haveUpload){
        uploadedFile = APILocator.getFileAPI().getAssetIOFile(currentFile);
        tmpFile = false;
      }
     
     
      // if we don't have a file anywhere, die
      if(!(uploadedFile.exists() && uploadedFile.length()>0)){
        SessionMessages.add(req, "error", "message.file_asset.error.nofile");
        // when there is an error saving should unlock working asset
        WebAssetFactory.unLockAsset(currentFile);
        throw new ActionException("message.file_asset.error.nofile")
      }

      String fileName = (editing) ? currentFile.getFileName() : fileForm.getFileName();
     
      //getting mime type
      String mimeType = APILocator.getFileAPI().getMimeType(fileName);

      file.setMimeType(mimeType);

      if (editing && haveUpload && !
          APILocator.getFileAPI().getMimeType(fileName).equals(APILocator.getFileAPI().getMimeType(uploadedFile.getName()))) {
        SessionMessages.add(req, "error", "message.file_asset.error.mimetype");
        // when there is an error saving should unlock working asset
        Logger.error(this.getClass(), "MimeType Mismatch:" + fileName + " : " + uploadedFile.getName());
        WebAssetFactory.unLockAsset(currentFile);
        HibernateUtil.rollbackTransaction();
        throw new ActionException("message.file_asset.error.mimetype");
      }
 
      // checks if another identifier with the same name exists in the same
      // folder
      if ((!editing) && (APILocator.getFileAPI().fileNameExists(folder, fileName))) {
        SessionMessages.add(req, "error", "message.file_asset.error.filename.exists");
        throw new ActionException("message.file_asset.error.filename.exists");
      }

      //sets new file properties
      file.setFileName(fileName);
      file.setModUser(userId);
     
      if (haveUpload) {
        file.setSize((int)uploadedFile.length());
      }
      else {
        file.setSize(currentFile.getSize());
        file.setWidth(currentFile.getWidth());
        file.setHeight(currentFile.getHeight());
      }
      //Saving the file, this creates the new version and save the new data
      File workingFile = null;
      workingFile = APILocator.getFileAPI().saveFile(file, uploadedFile, folder, user, false);
      APILocator.getVersionableAPI().setWorking(file);
      APILocator.getVersionableAPI().setLocked(file, false, user);
      if(uploadedFile != null && uploadedFile.exists() &&tmpFile){
        uploadedFile.delete();
      }
      SessionMessages.add(req, "message", "message.file_asset.save");
         // for file in a popup
      if (req.getParameter("popup") != null) {
        req.setAttribute("fileInode", file.getInode() + "");
        req.setAttribute("fileName", file.getFileName() + "");
      }     
      req.setAttribute(WebKeys.FILE_FORM_EDIT, workingFile);
      // copies the information back into the form bean
      BeanUtils.copyProperties(form, req.getAttribute(WebKeys.FILE_FORM_EDIT));
     
      //Refreshing the menues
      if (previousShowMenu != file.isShowOnMenu()) {
        //existing folder with different show on menu ... need to regenerate menu
        RefreshMenus.deleteMenu(file);
        CacheLocator.getNavToolCache().removeNav(folder.getHostId(), folder.getInode());
      }
     
    } catch (Exception e) {
      Logger.error(this, "\n\n\nEXCEPTION IN FILE SAVING!!! " + e.getMessage(), e);
      throw new ActionException(e.getMessage());
    }
  }
View Full Code Here

     
      SessionMessages.add(req, "message", "message.file_asset.copy");
     
    } catch (IOException e) {
      Logger.error(this, e.toString(), e);
      throw new ActionException(e.getMessage());
    }
  }
View Full Code Here

    if (!InodeUtils.isSet(webAsset.getInode()))
      return;

    if (!permissionAPI.doesUserHavePermission(webAsset, permission,
        user)) {
      throw new ActionException(WebKeys.USER_PERMISSIONS_EXCEPTION);
    }
  }
View Full Code Here

    if (!InodeUtils.isSet(webAsset.getInode()))
      return;

    if (!permissionAPI.doesUserHavePermission(webAsset, permission,
        user)) {
      throw new ActionException(WebKeys.USER_PERMISSIONS_EXCEPTION);
    }
  }
View Full Code Here

  public static void changeAssetMenuOrder(Inode asset, int newValue, User user) throws ActionException, DotDataException {

    // Checking permissions
    if (!permissionAPI.doesUserHavePermission(asset, PERMISSION_WRITE, user))
      throw new ActionException(WebKeys.USER_PERMISSIONS_EXCEPTION);

    if (asset instanceof Folder) {
      if (newValue == -1) {
        ((Folder)asset).setShowOnMenu(false);
      } else {
View Full Code Here

TOP

Related Classes of com.liferay.portal.struts.ActionException

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.