Package com.dotmarketing.business

Examples of com.dotmarketing.business.DotStateException


    return new java.util.ArrayList();
  }

  public static java.util.List getChildrenClassByRelationType(Inode p, Class c,String relationType) {
    if( c.equals(Identifier.class)){
      throw new DotStateException("Identifiers are no longer Inodes!");
    }
    try {
      String tableName = ((Inode) c.newInstance()).getType();
      HibernateUtil dh = new HibernateUtil(c);
View Full Code Here


    //return new java.util.ArrayList();
  }

  public static java.util.List getParentsOfClassByRelationType(Inode p, Class c, String relationType) {
    if( c.equals(Identifier.class)){
      throw new DotStateException("Identifiers are no longer Inodes!");
    }
    try {
      String tableName = ((Inode) c.newInstance()).getType();
      HibernateUtil dh = new HibernateUtil(c);
View Full Code Here

  }

  public static java.util.List getChildrenClassByConditionAndOrderBy(String[] inodes, Class c, String condition,
      String orderBy,int quantity) {
    if( c.equals(Identifier.class)){
      throw new DotStateException("Identifiers are no longer Inodes!");
    }
    if (inodes == null || inodes.length == 0)
    {         
      return InodeFactory.getInodesOfClassByConditionAndOrderBy(c, condition, orderBy,quantity);
    }
View Full Code Here

   * @param config
   * @return
   */
  public static boolean bundleExists(PublisherConfig config){
    if(config.getId() ==null){
      throw new DotStateException("publishing config.id is null.  Please set an id before publishing (it will be the folder name under which the bundle will be created)");
    }
    String bundlePath = ConfigUtils.getBundlePath()+ File.separator + config.getId()+ File.separator + "bundle.xml";


    return new File(bundlePath).exists();
View Full Code Here

            if(!"trial".equals(licenseType) && !  
                "dev".equals(licenseType) && !  
                "prod".equals(licenseType)
               
                ){
              throw new DotStateException("invalid License Type");
            }

            LicenseUtil.processForm( request );
          return Response.ok(request.getAttribute("requestCode"), MediaType.APPLICATION_JSON_TYPE).build();
        }
View Full Code Here

                  APILocator.getContentletAPI()
                  .search("+identifier:"+id.getId(), 0, 0, "moddate", user, false));
            }
          } catch (Exception ex) {
            Logger.debug(this, ex.toString());
            throw new DotStateException("Problem occured while publishing file");
          }
        }

      }
    }
View Full Code Here

private boolean isContent(String id, boolean byInode, long langId, boolean respectFrontendRoles) throws DotStateException, DotDataException, DotSecurityException{



    if(cacheMisses.containsKey(id+byInode)){
      throw new DotStateException("404 - Unable to find id:" + id);
    }


    if(byInode){
      try {
        Contentlet c =APILocator.getContentletAPI().find(id, userAPI.getSystemUser(), true);
        if(c != null && c.getInode() != null)
          return true;
      } catch (Exception e) {
        Logger.debug(this.getClass(), "Unable to find contentlet " + id);
      }
      try {
        if(fileAPI.find(id,userAPI.getSystemUser(),false) != null){
          return false;
        }
      } catch (DotHibernateException e) {
        Logger.debug(this.getClass(), "cant find file with inode " + id);
      }
    }

    else{
      try {

        Identifier identifier = APILocator.getIdentifierAPI().loadFromCache(id);
        if(identifier != null){
          return "contentlet".equals(identifier.getAssetType());
        }

        //second check content check from lucene
        String luceneQuery = "+identifier:" + id;
        Contentlet c = APILocator.getContentletAPI().findContentletByIdentifier(id, false,langId, userAPI.getSystemUser(), false);
        if(c != null && UtilMethods.isSet(c.getInode())){
          return true;
        }

      } catch (Exception e) {
        Logger.debug(this.getClass(), "cant find identifier " + id);
      }
    }
    cacheMisses.put(id+byInode, true);
    throw new DotStateException("404 - Unable to find id:" + id);

  }
View Full Code Here

      // gets the current working asset
    livewebasset = (WebAsset) APILocator.getVersionableAPI().findLiveVersion(identifier, APILocator.getUserAPI().getSystemUser(), false);

    if(workingwebasset.isDeleted()){
      throw new DotStateException("You may not publish deleted assets!!!");
    }

    /*if ((livewebasset != null) && (InodeUtils.isSet(livewebasset.getInode()))
        && (livewebasset.getInode() != workingwebasset.getInode())) {

View Full Code Here

    }
   
    private void doSaveAs(HttpServletRequest request, HttpServletResponse response, String inode, String fileName){
     
    if(!UtilMethods.isSet(inode)){
      throw new DotStateException("Cannot find underlying file to 'save as' ");
    }
      User user;
    try {
     
        Map<String, String> imgToolFile = (Map<String, String>) request.getSession().getAttribute(WebKeys.IMAGE_TOOL_SAVE_FILES);
      if(imgToolFile  ==null){
        throw new DotStateException("Cannot find underlying file to 'save as' ");
      }
      java.io.File saveAsIOFile = null;
      if(imgToolFile != null){
       
        for (Map.Entry<String, String> entry : imgToolFile.entrySet()){
          if(WebKeys.EDITED_IMAGE_FILE_ASSET.equals(entry.getKey())){
            saveAsIOFile = new java.io.File(entry.getValue());
            request.getSession().removeAttribute(WebKeys.IMAGE_TOOL_SAVE_FILES);
            break;
          }
        }
      }
      if(saveAsIOFile ==null || ! saveAsIOFile.exists() || saveAsIOFile.length() <60){
        response.getWriter().println("failure.  No Save as file found");
        return;
      }
      java.io.File temp = java.io.File.createTempFile(saveAsIOFile.getName(),UtilMethods.getFileExtension(saveAsIOFile.getName()));
      temp.deleteOnExit();
      FileUtil.copyFile(saveAsIOFile, temp);
     
     
      FileAPI fAPI = APILocator.getFileAPI();
      user = WebAPILocator.getUserWebAPI().getLoggedInUser(request);
      Identifier ident = APILocator.getIdentifierAPI().findFromInode(inode);
        if(ident!=null && InodeUtils.isSet(ident.getId()) && ident.getAssetType().equals("contentlet")){
          Contentlet cont = APILocator.getContentletAPI().findContentletByIdentifier(ident.getId(), true, APILocator.getLanguageAPI().getDefaultLanguage().getId(), user, false);
          if(cont!=null && InodeUtils.isSet(cont.getInode())){
            Host h = APILocator.getHostAPI().find(cont.getHost(), user, false);
          Folder folder = APILocator.getFolderAPI().findFolderByPath(ident.getParentPath(), h, user, false);
          if(APILocator.getFileAssetAPI().fileNameExists(h, folder, fileName, cont.getIdentifier())){
            response.getWriter().println("failure.  fileAlreadyExists");
            return;
          }
          Contentlet fileAsset = new Contentlet();
          fileAsset.setStructureInode(folder.getDefaultFileType());
          fileAsset.setStringProperty(FileAssetAPI.TITLE_FIELD, UtilMethods.getFileName(fileName));
          fileAsset.setFolder(folder.getInode());
          fileAsset.setHost(h.getIdentifier());
          fileAsset.setBinary(FileAssetAPI.BINARY_FIELD, temp);
          APILocator.getContentletAPI().checkin(fileAsset, user,false);
          }
         
        }else{
          File src = fAPI.get(inode,user, false );
          Identifier fileId = APILocator.getIdentifierAPI().find(src.getIdentifier());
        Host h = APILocator.getHostAPI().find(fileId.getHostId(), user, false);
        Folder folder = APILocator.getFileAPI().getFileFolder(src, h, user, false);
        File copiedFile = new File();
        copiedFile.setFileName(fileName);
        copiedFile.setAuthor(user.getFullName());
        copiedFile.setModUser(user.getUserId());
        copiedFile.setFriendlyName(src.getFriendlyName());
        copiedFile.setMimeType(APILocator.getFileAPI().getMimeType(fileName));
        String x = WorkingCache.getPathFromCache(APILocator.getIdentifierAPI().find(folder).getPath() + fileName, h);

       
       
        if(UtilMethods.isSet(x)){
          response.getWriter().println("failure.  fileAlreadyExists");
         
          return;
        }
       


        fAPI.saveFile(copiedFile, temp, folder, user, false);

        }
   
 
      response.getWriter().println("success.  File Saved");
     
      return;
    } catch (Exception e) {
      Logger.error(this.getClass(), e.getMessage());
      Logger.debug(this.getClass(), e.getMessage(), e);
      throw new DotStateException("Error in 'save as' " +e.getMessage() );
    }
    finally{
      request.getSession().removeAttribute(WebKeys.IMAGE_TOOL_SAVE_FILES);
    }
   
View Full Code Here

      /************ Structures *****************/
      StructureFactory.updateFolderReferences(folder);
    } catch (Exception e) {
      Logger.error(FolderAPI.class, e.getMessage(), e);
      throw new DotStateException(e.getMessage());

    }

  }
View Full Code Here

TOP

Related Classes of com.dotmarketing.business.DotStateException

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.