Ejemplo n.º 1
0
  public Folder getFileFolder(File file, String hostId) throws DotDataException {
    HibernateUtil hu = new HibernateUtil(Folder.class);
    hu.setSQLQuery(
        "select {folder.*} from folder,identifier,inode folder_1_ where folder.identifier = identifier.id and "
            + "folder_1_.inode = folder.inode and host_inode = ? and path =(select parent_path from identifier where id=?)");

    hu.setParam(hostId);
    hu.setParam(file.getIdentifier());
    return (Folder) hu.load();
  }
Ejemplo n.º 2
0
 public Map<String, Object> fetchTemplateImage(String id)
     throws DotDataException, DotSecurityException {
   Map<String, Object> toReturn = new HashMap<String, Object>();
   Template template = null;
   try {
     template =
         templateAPI.findWorkingTemplate(id, APILocator.getUserAPI().getSystemUser(), false);
   } catch (DotSecurityException e) {
     Logger.error(this, e.getMessage());
   }
   if (template != null) {
     Identifier imageIdentifier = APILocator.getIdentifierAPI().find(template.getImage());
     if (UtilMethods.isSet(imageIdentifier.getAssetType())
         && imageIdentifier.getAssetType().equals("contentlet")) {
       Contentlet imageContentlet = TemplateFactory.getImageContentlet(template);
       if (imageContentlet != null) {
         toReturn.put("inode", imageContentlet.getInode());
         toReturn.put("name", imageContentlet.getTitle());
         toReturn.put("identifier", imageContentlet.getIdentifier());
         toReturn.put(
             "extension",
             com.dotmarketing.util.UtilMethods.getFileExtension(imageContentlet.getTitle()));
       }
     } else {
       File imgFile = TemplateFactory.getImageFile(template);
       if (imgFile != null) {
         toReturn.put("inode", imgFile.getInode());
         toReturn.put("name", imgFile.getFileName());
         toReturn.put("identifier", imgFile.getIdentifier());
         toReturn.put(
             "extension",
             com.dotmarketing.util.UtilMethods.getFileExtension(imgFile.getFileName()));
       }
     }
   }
   return toReturn;
 }