Ejemplo n.º 1
0
 @Override
 public FileEntity saveFile(String filename, byte[] data) {
   try {
     String path = FolderUtil.getFilePath(filename);
     String name = FolderUtil.getFileName(filename);
     FolderEntity folder = getFolderBusiness().createFolder(path);
     FileEntity file = getDao().getFileDao().getByName(folder.getId(), name);
     if (file == null) {
       file =
           new FileEntity(
               name,
               name,
               folder.getId(),
               MimeType.getContentTypeByExt(FolderUtil.getFileExt(filename)),
               new Date(),
               data.length);
     }
     getDao().getFileDao().save(file, data);
     getSystemService().getFileCache().remove(filename);
     return file;
   } catch (Exception e) {
     e.printStackTrace();
     return null;
   }
 }
Ejemplo n.º 2
0
 public boolean isSiteContent(final ZipEntry entry) throws UnsupportedEncodingException {
   String[] chain = FolderUtil.getPathChain(entry);
   if (chain.length != 1 || !chain[0].equals("content.xml")) {
     return false;
   }
   return true;
 }
Ejemplo n.º 3
0
 @Override
 public FileEntity findFile(String filename) {
   try {
     String path = FolderUtil.getFilePath(filename);
     String name = FolderUtil.getFileName(filename);
     TreeItemDecorator<FolderEntity> folder =
         getFolderBusiness().findFolderByPath(getFolderBusiness().getTree(), path);
     if (folder == null) {
       return null;
     }
     return getDao().getFileDao().getByName(folder.getEntity().getId(), name);
   } catch (Exception e) {
     e.printStackTrace();
     return null;
   }
 }
Ejemplo n.º 4
0
 @Override
 public byte[] readFile(String filename) {
   try {
     String path = FolderUtil.getFilePath(filename);
     String name = FolderUtil.getFileName(filename);
     FolderEntity folder =
         getFolderBusiness().findFolderByPath(getFolderBusiness().getTree(), path).getEntity();
     if (folder == null) {
       return null;
     }
     FileEntity file = getDao().getFileDao().getByName(folder.getId(), name);
     if (file != null) {
       return getDao().getFileDao().getFileContent(file);
     }
     return null;
   } catch (Exception e) {
     e.printStackTrace();
     return null;
   }
 }
Ejemplo n.º 5
0
 @Override
 public void remove(String filename) {
   String path = FolderUtil.getFilePath(filename);
   String name = FolderUtil.getFileName(filename);
   TreeItemDecorator<FolderEntity> folder =
       getFolderBusiness().findFolderByPath(getFolderBusiness().getTree(), path);
   if (folder == null) {
     logger.error("Folder not found. " + path);
     return;
   }
   FileEntity file = getDao().getFileDao().getByName(folder.getEntity().getId(), name);
   if (file == null) {
     logger.error("File not found. " + filename);
     return;
   }
   FolderPermissionEntity perm =
       getFolderPermissionBusiness()
           .getPermission(folder.getEntity(), VosaoContext.getInstance().getUser());
   if (perm.isChangeGranted()) {
     getDao().getFileDao().remove(file.getId());
     getSystemService().getFileCache().remove(filename);
   }
 }
Ejemplo n.º 6
0
  public boolean importSystemFile(String name, String xml)
      throws DocumentException, DaoTaskException, UnsupportedEncodingException {
    if (name.equals("_users.xml")) {
      getUserExporter().readUsersFile(xml);
      return true;
    }
    if (name.equals("_groups.xml")) {
      getGroupExporter().readGroupsFile(xml);
      return true;
    }
    if (name.equals("_config.xml")) {
      getConfigExporter().readConfigFile(xml);
      return true;
    }
    if (name.equals("_structures.xml")) {
      getStructureExporter().readStructuresFile(xml);
      return true;
    }
    if (name.equals("_forms.xml")) {
      getFormExporter().readFormsFile(xml);
      return true;
    }
    if (name.equals("_messages.xml")) {
      getMessagesExporter().readMessagesFile(xml);
      return true;
    }
    if (name.equals("_plugins.xml")) {
      getPluginExporter().readPluginsFile(xml);
      return true;
    }
    if (name.equals("_tags.xml")) {
      getTagExporter().read(xml);
      return true;
    }
    if (name.equals("_seourls.xml")) {
      getSeoUrlExporter().read(xml);
      return true;
    }
    if (name.equals("_dependencies.xml")) {
      getPageDependencyExporter().readFile(xml);
      return true;
    }

    if (name.endsWith("_folder.xml")) {
      String folderPath = FolderUtil.getFilePath("/" + name);
      getResourceExporter().readFolderFile(folderPath, xml);
      return true;
    }
    if (name.endsWith("_template.xml")) {
      return getThemeExporter().readTemplateFile("/" + name, xml);
    }
    if (name.endsWith("_content.xml")) {
      String folderPath = FolderUtil.getFilePath("/" + name);
      return getPageExporter().readContentFile(folderPath, xml);
    }
    if (name.endsWith("_comments.xml")) {
      String folderPath = FolderUtil.getFilePath("/" + name);
      return getPageExporter().readCommentsFile(folderPath, xml);
    }
    if (name.endsWith("_permissions.xml")) {
      String folderPath = FolderUtil.getFilePath("/" + name);
      return getPageExporter().readPermissionsFile(folderPath, xml);
    }
    if (name.endsWith("_tag.xml")) {
      String folderPath = FolderUtil.getFilePath("/" + name);
      return getPageExporter().readPageTagFile(folderPath, xml);
    }
    return false;
  }