Main Content

Magnolia Community Forums: Get help with Magnolia: manual files extraction on 5.4.x


  • matteo.pelucco
    matteo.pelucco
    Full name: Matteo Pelucco
    Posts: 264
    Last post: Mar 20, 2017 9:27:06 AM
    manual files extraction on 5.4.x
    #1 by matteo.pelucco on Jan 25, 2017 9:48:32 AM

    Hello everybody,
    we have the need (sometimes) to manually extract JAR files from /docroot /template fodler. This was possible using the "DEV" app on AdminCentral, on the bottom part.

    This feature seems to be removed or not available by default on demo.magnolia-cms.com, isn't it? Am I wrong?

    Thanks,
    matteo

  • had
    had
    Full name: Jan Haderka
    Posts: 1,405
    Last post: Feb 6, 2017 1:59:05 PM
    Re: manual files extraction on 5.4.x
    #2 by had on Jan 27, 2017 11:32:42 AM

    Hi Matteo,

    you are right. This functionality have been removed as part of removing legacy admin central. Originally this function was for re-extracting files in the file system, namely JSPs and other related static resources. This didn't seem to be model used by anyone anymore (with light development and related things), hence the removal.
    All the extraction tasks however still exits and you can easily create action or groovy script to do the same:

    import import info.magnolia.module.files.*;
    new BasicFileExtractor().extractFiles(new ModuleFileExtractorTransformer("my-module"));


    HTH,
    Jan

  • matteo.pelucco
    matteo.pelucco
    Full name: Matteo Pelucco
    Posts: 264
    Last post: Mar 20, 2017 9:27:06 AM
    Re: manual files extraction on 5.4.x
    #3 by matteo.pelucco on Jan 27, 2017 11:47:47 AM

    Hi Jan, tnx..
    Good to know, as we have some legacy tools / projects that can rely on this feature / devops operational activity.
    I created a quick class / command for that, here the "core" code (put here because it contains also MD5 checks..:




    package mypackage;

    import javax.jcr.Session;

    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;

    import info.magnolia.context.MgnlContext;
    import info.magnolia.module.files.FileExtractionLogger;
    import info.magnolia.module.files.MD5CheckingFileExtractor;
    import info.magnolia.module.files.ModuleFileExtractorTransformer;
    import info.magnolia.repository.RepositoryConstants;

    public class MyMD5CheckingFileExtractor {

    private static final Logger log = LoggerFactory.getLogger(MyMD5CheckingFileExtractor.class);

    private String moduleName = null;

    public MyMD5CheckingFileExtractor(String moduleName) {
    this.moduleName = moduleName;
    }

    private static class SimpleFileExtractionLogger implements FileExtractionLogger {

    private Logger innerLog = null;

    public SimpleFileExtractionLogger(Object c) {
    this.innerLog = LoggerFactory.getLogger(c.getClass().getName());
    }

    @Override
    public void error(String message) {
    innerLog.error(message);
    }
    }

    public void extractFiles() {
    try {
    final Session configSession = MgnlContext.getJCRSession(RepositoryConstants.CONFIG);
    final MD5CheckingFileExtractor extractor = new MD5CheckingFileExtractor(new SimpleFileExtractionLogger(this), configSession);
    extractor.extractFiles(new ModuleFileExtractorTransformer(moduleName));
    } catch (Exception e) {
    log.error("Could not extract files for module {}: {}", this.moduleName, e.getMessage());
    e.printStackTrace();
    }

    }
    }




    Usage:



    MyMD5CheckingFileExtractor md5extractor = new MyMD5CheckingFileExtractor("my-module");
    md5extractor.extractFiles();



    HTH,
    Matteo

You don't have the permission to post on this thread

Sign in

To login on this forum, you can use your Magnolia Forge, Support or Partner account, or, below, your Google, Yahoo! or OpenID account. If you have trouble logging in, or any other sort of issue, please let us know in the Meta forum, on the user-list, or simply by email at forum-admin at magnolia-cms dot com.

* Required

... or sign in with:

  • icon http://{your-openid-url}
  • icon
  • icon https://me.yahoo.com/