ComponentResourceProviderUtils.java :  » MVC » simpleframework » net » simpleframework » web » page » component » Java Open Source

Java Open Source » MVC » simpleframework 
simpleframework » net » simpleframework » web » page » component » ComponentResourceProviderUtils.java
package net.simpleframework.web.page.component;

import java.io.IOException;
import java.util.zip.ZipInputStream;

import net.simpleframework.util.IoUtils;
import net.simpleframework.web.page.PageUtils;
import net.simpleframework.web.page.component.ui.htmleditor.HtmlEditorRegistry;

/**
 * LGPLv3
 * 
 * @author (cknet@126.com, 13910090885)
 *         http://code.google.com/p/simpleframework/
 *         http://www.simpleframework.net
 */
public abstract class ComponentResourceProviderUtils {

  public static void extract(final IComponentRegistry componentRegistry) throws IOException {
    final IComponentResourceProvider provider = componentRegistry.getComponentResourceProvider();
    if (provider == null) {
      return;
    }

    final ZipInputStream inputStream = provider.getRequiredResource();
    if (inputStream != null) {
      final String target = componentRegistry.getServletContext().getRealPath(
          provider.getResourceHomePath());
      if (componentRegistry instanceof HtmlEditorRegistry) {
        IoUtils.unzip(inputStream, target);
      } else {
        IoUtils.unzip(inputStream, target, true, PageUtils.defaultUnZipResource);
      }
    }
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.