Package com.dotmarketing.portlets.files.model

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


        }
        if(cont!=null && InodeUtils.isSet(cont.getInode())){
          return cont.getInode();
        }
      }else{
        File f = APILocator.getFileAPI().getFileByURI(path, host, false,backEndUser!=null?backEndUser:user, false);
        return f.getInode();
      }
      return null;
    }catch (Exception e) {
      Logger.error(this, e.getMessage(),e);
      return null;
View Full Code Here


          Contentlet cont = APILocator.getContentletAPI().findContentletByIdentifier(xslId.getId(), true, APILocator.getLanguageAPI().getDefaultLanguage().getId(), userAPI.getSystemUser(),false);
          if(cont!=null && InodeUtils.isSet(cont.getInode())){
            binFile = cont.getBinary(FileAssetAPI.BINARY_FIELD);
          }
        }else{
          File xslFile = fileAPI.getFileByURI(XSLPath, host, true, userAPI.getSystemUser(),false);
          binFile = fileAPI.getAssetIOFile (xslFile);
        }
       
       
        /*Get the XML Source from file or from URL*/
        if(!XMLPath.startsWith("http")){
          Identifier xmlId = APILocator.getIdentifierAPI().find(host, XMLPath);
          if(xmlId!=null && InodeUtils.isSet(xmlId.getId()) && xmlId.getAssetType().equals("contentlet")){
            Contentlet cont = APILocator.getContentletAPI().findContentletByIdentifier(xmlId.getId(), true, APILocator.getLanguageAPI().getDefaultLanguage().getId(), userAPI.getSystemUser(),false);
            if(cont!=null && InodeUtils.isSet(cont.getInode())){
              xmlSource = new StreamSource(new InputStreamReader(new FileInputStream(cont.getBinary(FileAssetAPI.BINARY_FIELD)), "UTF8"));
            }
          }else{
            File xmlFile = fileAPI.getFileByURI(XMLPath, host, true,userAPI.getSystemUser(),false);
            xmlSource = new StreamSource(new InputStreamReader(new FileInputStream(fileAPI.getAssetIOFile(xmlFile)), "UTF8"));
          }

        }else{
          xmlSource = new StreamSource(XMLPath);
View Full Code Here

      Source xmlSource = null;
      XSLTranformationDoc doc = null;
      Host host = hostWebAPI.getCurrentHost(request);
     
      /*Get the XSL source*/
      File xslFile = fileAPI.getFileByURI(XSLPath, host, true, userAPI.getSystemUser(), false);
     
      if (doc == null) {
        xmlSource = new StreamSource(new ByteArrayInputStream(xmlString.getBytes("UTF-8")));
       
        Source xsltSource = new StreamSource(new InputStreamReader(new FileInputStream(fileAPI.getAssetIOFile (xslFile)), "UTF8"));
       
        // create an instance of TransformerFactory
        TransformerFactory transFact = TransformerFactory.newInstance();
        StreamResult result = new StreamResult(new ByteArrayOutputStream());
        Transformer trans = transFact.newTransformer(xsltSource);
       
        try {
          trans.transform(xmlSource, result);
        } catch (Exception e1) {
          Logger.error(XsltTool.class, "Error in transformation. " + e1.getMessage());
          e1.printStackTrace();
        }
       
        outputXML = result.getOutputStream().toString();
       
        doc = new XSLTranformationDoc();
        doc.setIdentifier(xslFile.getIdentifier());
        doc.setInode(xslFile.getInode());
        doc.setXslPath(XSLPath);
        doc.setXmlTransformation(outputXML);
      }
     
      return doc;
View Full Code Here

    try {
      identifier = APILocator.getIdentifierAPI().find(imageIdentifierInode);
    } catch (DotHibernateException e) {
      Logger.error(TemplateFactory.class,e.getMessage(),e);
    }
    File imageFile = new File();
    if(InodeUtils.isSet(identifier.getInode())){
      imageFile = (File) APILocator.getVersionableAPI().findWorkingVersion(identifier, APILocator.getUserAPI().getSystemUser(),false);
    }
    return imageFile;
  }
View Full Code Here

        if (host != null && InodeUtils.isSet(host.getInode())&& InodeUtils.isSet(folder.getInode())) {

          Identifier identifier = APILocator.getIdentifierAPI().find(host,path);

          File file = new File();
          file.setTitle(fileName);
          file.setFileName(fileName);
          file.setShowOnMenu(false);
          file.setModDate(new Date());
          String mimeType = fileAPI.getMimeType(fileName);
          file.setMimeType(mimeType);
          String author = user.getFullName();
          file.setAuthor(author);
          file.setModUser(author);
          file.setSortOrder(0);
          file.setShowOnMenu(false);


          if (identifier !=null &&  InodeUtils.isSet(identifier.getId()) && !identifier.getAssetType().equals("contentlet")) {
            File actualFile = fileAPI.getFileByURI(path, host, false,user,false);
            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)){
View Full Code Here

        }
      }else{

        if(destinationFile instanceof File){
          // Save the file size
          File file = fileAPI.getFileByURI(path, host, false, user, false);
          file.setSize(currentData.length);
          file.setModDate(modifiedDate);
          file.setModUser(user.getUserId());
          try {
            HibernateUtil.saveOrUpdate(file);
          } catch (DotHibernateException e1) {
            Logger.error(this,e1.getMessage(), e1);
          }
View Full Code Here

              APILocator.getContentletAPI().delete(origin, APILocator.getUserAPI().getSystemUser(), false);
              while(APILocator.getContentletAPI().isInodeIndexed(origin.getInode(),1));
          }
        }else{
          File f = fileAPI.getFileByURI(getPath(fromPath), host, false, user, false);
          if (getFolderName(fromPath).equals(getFolderName(toPath))) {

            String fileName = getFileName(toPath);
            if(fileName.contains(".")){
              fileName = fileName.substring(0, fileName.lastIndexOf("."));
View Full Code Here

      Identifier identifier  = APILocator.getIdentifierAPI().find(host, path);
      if(identifier!=null && identifier.getAssetType().equals("contentlet")){
                Contentlet cont  = APILocator.getContentletAPI().findContentletByIdentifier(identifier.getId(), false, APILocator.getLanguageAPI().getDefaultLanguage().getId(), user, false);
          workingFile = cont.getBinary(FileAssetAPI.BINARY_FIELD);
      }else{
        File file = fileAPI.getFileByURI(path, host, false, user, false);
        // inode{1}/inode{2}/inode.file_extension
        workingFile = fileAPI.getAssetIOFile(file);
      }
      FileInputStream is = new FileInputStream(workingFile);
      returnValue = is;
View Full Code Here

    String fileName = UtilMethods.getFileName(source.getFileName());
    // gets file extension
    String fileExtension = UtilMethods.getFileExtension(source.getFileName());

    boolean isNew = false;
    File newFile;
    if (forceOverwrite) {
      newFile = getWorkingFileByFileName(source.getFileName(), destination, user, respectFrontendRoles);
      if (newFile == null) {
        isNew = true;
      }
    } else {
      isNew = true;
    }

    try {
      newFile = new File();
      newFile.copy(source);

      // Setting file name
      if (!forceOverwrite) {
        newFile.setFileName(getCopyFileName(fileName, fileExtension, destination));

        if (!UtilMethods.getFileName(newFile.getFileName()).equals(fileName))
          newFile.setFriendlyName(source.getFriendlyName() + " (COPY) ");
      }

      if (isNew) {
        // persists the webasset
        java.io.File sourceFile = getAssetIOFile(source);
View Full Code Here

 
 
 
 
  public File getWorkingFileByFileName(String fileName, Folder folder, User user, boolean respectFrontendRoles) throws DotStateException, DotDataException, DotSecurityException {
    File f = ffac.getWorkingFileByFileName(fileName, folder);
    if(!InodeUtils.isSet(f.getInode())){
      return null;
    }
    if (!permissionAPI.doesUserHavePermission(f, PermissionAPI.PERMISSION_READ, user, respectFrontendRoles)) {
      throw new DotSecurityException("You don't have permission to read the  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.