Ejemplo n.º 1
0
 public static Collection<File> getResourceWithoutMT(ContentContext ctx) throws Exception {
   Collection<File> outFiles = new LinkedList<File>();
   Collection<File> allFiles = getAllResources(ctx);
   for (File file : allFiles) {
     StaticInfo staticInfo = StaticInfo.getInstance(ctx, file);
     if (!staticInfo.isPertinent(ctx)) {
       outFiles.add(file);
     }
   }
   return outFiles;
 }
Ejemplo n.º 2
0
  /**
   * change all the reference to a resource when a resource path or name if changed
   *
   * @param ctx
   * @param oldName
   * @param newName
   * @throws Exception
   */
  public static void renameResource(ContentContext ctx, File file, File newFile) throws Exception {
    GlobalContext globalContext = GlobalContext.getInstance(ctx.getRequest());
    ContentContext lgCtx = new ContentContext(ctx);
    lgCtx.setRenderMode(ContentContext.EDIT_MODE);
    Collection<String> lgs = globalContext.getContentLanguages();
    for (String lg : lgs) {
      lgCtx.setRequestContentLanguage(lg);
      List<IContentVisualComponent> comps = ComponentFactory.getAllComponentsFromContext(lgCtx);
      for (IContentVisualComponent comp : comps) {
        if (comp instanceof IStaticContainer) {
          ((IStaticContainer) comp).renameResource(ctx, file, newFile);
        }
      }
    }
    StaticInfo staticInfo = StaticInfo.getInstance(ctx, file);
    staticInfo.renameFile(ctx, newFile);

    // delete old ref in cache
    String fromDataFolder = file.getAbsolutePath().replace(globalContext.getDataFolder(), "");
    FileCache.getInstance(ctx.getRequest().getSession().getServletContext()).delete(fromDataFolder);
  }