org.apache.commons.collections.ExtendedProperties Java Examples

The following examples show how to use org.apache.commons.collections.ExtendedProperties. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ServletContextLoader.java    From ApprovalTests.Java with Apache License 2.0 6 votes vote down vote up
/**
 *  This is abstract in the base class, so we need it.
 *  <br>
 *  NOTE: this expects that the ServletContext has already
 *        been placed in the runtime's application attributes
 *        under its full class name (i.e. "javax.servlet.ServletContext").
 *
 * @param configuration the {@link ExtendedProperties} associated with 
 *        this resource loader.
 */
public void init(ExtendedProperties configuration)
{
  paths = configuration.getStringArray("path");
  if (paths == null || paths.length == 0)
  {
    paths = new String[1];
    paths[0] = "/";
  }
  else
  {
    /* make sure the paths end with a '/' */
    for (int i = 0; i < paths.length; i++)
    {
      if (!paths[i].endsWith("/"))
      {
        paths[i] += '/';
      }
    }
  }
  //My_System.variable("paths", paths);
}
 
Example #2
Source File: SpringResourceLoader.java    From MaxKey with Apache License 2.0 6 votes vote down vote up
@Override
public void init(ExtendedProperties configuration) {
	this.resourceLoader = (org.springframework.core.io.ResourceLoader)
			this.rsvc.getApplicationAttribute(SPRING_RESOURCE_LOADER);
	String resourceLoaderPath = (String) this.rsvc.getApplicationAttribute(SPRING_RESOURCE_LOADER_PATH);
	if (this.resourceLoader == null) {
		throw new IllegalArgumentException(
				"'resourceLoader' application attribute must be present for SpringResourceLoader");
	}
	if (resourceLoaderPath == null) {
		throw new IllegalArgumentException(
				"'resourceLoaderPath' application attribute must be present for SpringResourceLoader");
	}
	this.resourceLoaderPaths = StringUtils.commaDelimitedListToStringArray(resourceLoaderPath);
	for (int i = 0; i < this.resourceLoaderPaths.length; i++) {
		String path = this.resourceLoaderPaths[i];
		if (!path.endsWith("/")) {
			this.resourceLoaderPaths[i] = path + "/";
		}
	}
	if (logger.isInfoEnabled()) {
		logger.info("SpringResourceLoader for Velocity: using resource loader [" + this.resourceLoader +
				"] and resource loader paths " + Arrays.asList(this.resourceLoaderPaths));
	}
}
 
Example #3
Source File: SpringResourceLoader.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void init(ExtendedProperties configuration) {
	this.resourceLoader = (org.springframework.core.io.ResourceLoader)
			this.rsvc.getApplicationAttribute(SPRING_RESOURCE_LOADER);
	String resourceLoaderPath = (String) this.rsvc.getApplicationAttribute(SPRING_RESOURCE_LOADER_PATH);
	if (this.resourceLoader == null) {
		throw new IllegalArgumentException(
				"'resourceLoader' application attribute must be present for SpringResourceLoader");
	}
	if (resourceLoaderPath == null) {
		throw new IllegalArgumentException(
				"'resourceLoaderPath' application attribute must be present for SpringResourceLoader");
	}
	this.resourceLoaderPaths = StringUtils.commaDelimitedListToStringArray(resourceLoaderPath);
	for (int i = 0; i < this.resourceLoaderPaths.length; i++) {
		String path = this.resourceLoaderPaths[i];
		if (!path.endsWith("/")) {
			this.resourceLoaderPaths[i] = path + "/";
		}
	}
	if (logger.isInfoEnabled()) {
		logger.info("SpringResourceLoader for Velocity: using resource loader [" + this.resourceLoader +
				"] and resource loader paths " + Arrays.asList(this.resourceLoaderPaths));
	}
}
 
Example #4
Source File: SpringResourceLoader.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Override
public void init(ExtendedProperties configuration) {
	this.resourceLoader = (org.springframework.core.io.ResourceLoader)
			this.rsvc.getApplicationAttribute(SPRING_RESOURCE_LOADER);
	String resourceLoaderPath = (String) this.rsvc.getApplicationAttribute(SPRING_RESOURCE_LOADER_PATH);
	if (this.resourceLoader == null) {
		throw new IllegalArgumentException(
				"'resourceLoader' application attribute must be present for SpringResourceLoader");
	}
	if (resourceLoaderPath == null) {
		throw new IllegalArgumentException(
				"'resourceLoaderPath' application attribute must be present for SpringResourceLoader");
	}
	this.resourceLoaderPaths = StringUtils.commaDelimitedListToStringArray(resourceLoaderPath);
	for (int i = 0; i < this.resourceLoaderPaths.length; i++) {
		String path = this.resourceLoaderPaths[i];
		if (!path.endsWith("/")) {
			this.resourceLoaderPaths[i] = path + "/";
		}
	}
	if (logger.isInfoEnabled()) {
		logger.info("SpringResourceLoader for Velocity: using resource loader [" + this.resourceLoader +
				"] and resource loader paths " + Arrays.asList(this.resourceLoaderPaths));
	}
}
 
Example #5
Source File: LibraryWebappLoader.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
   * @param configuration the {@link ExtendedProperties} associated with this resource
   *                      loader.
   */
  @Override
  public void init(ExtendedProperties configuration) {
      log.debug("WebappLoader : initialization starting.");

      getLibraryWebappResourceManager();

/* init the template paths map */
      templatePaths = new HashMap<>();

      log.debug("WebappLoader : initialization complete.");
  }
 
Example #6
Source File: LibraryWebappLoader.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
   * @param configuration the {@link ExtendedProperties} associated with this resource
   *                      loader.
   */
  @Override
  public void init(ExtendedProperties configuration) {
      log.debug("WebappLoader : initialization starting.");

      getLibraryWebappResourceManager();

/* init the template paths map */
      templatePaths = new HashMap<>();

      log.debug("WebappLoader : initialization complete.");
  }
 
Example #7
Source File: left_Attachment_1.24.java    From gumtree-spoon-ast-diff with Apache License 2.0 5 votes vote down vote up
/**
 * Get the repository path info
 * @return String
 */
public String getRepositoryDirectory(String moduleCode)
    throws Exception
{
    ExtendedProperties extProp = TurbineServices.getInstance()
        .getService(UploadService.SERVICE_NAME).getConfiguration();
    String uploadFileRepo = (String)extProp.getProperty(UploadService.REPOSITORY_KEY);
    String repoModuleDir = uploadFileRepo + File.separator + moduleCode;
    File repoDir = new File(repoModuleDir);
    
    if (!repoDir.exists())
    {
        try
        {
            repoDir.mkdir();
        }
        catch (SecurityException e)
        {
            String errorMessage = 
                "Unable to create directory for repository: " + 
                repoModuleDir;
            Log.error(errorMessage + ", " + e.getMessage());
            throw new Exception(errorMessage);
        }
    }
    
    return repoModuleDir;
}
 
Example #8
Source File: ViewVelocity.java    From baratine with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void init(ExtendedProperties configuration)
{
  String path = (String) configuration.getProperty("path");

  if (path != null) {
    _root = path;
  }
}
 
Example #9
Source File: VelocityHelper.java    From PackageTemplates with Apache License 2.0 5 votes vote down vote up
private static VelocityEngine newVelocityEngine() {
    ExtendedProperties prop = new ExtendedProperties();
    prop.addProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, SimpleLog4JLogSystem.class.getName());
    prop.addProperty("runtime.log.logsystem.log4j.category", "GenerateToString");

    VelocityEngine velocity = new VelocityEngine();
    velocity.setExtendedProperties(prop);
    velocity.init();

    return velocity;
}
 
Example #10
Source File: WebappResourceLoader.java    From Albianj2 with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * This is abstract in the base class, so we need it.
 * <br>
 * NOTE: this expects that the ServletContext has already
 * been placed in the runtime's application attributes
 * under its full class name (i.e. "javax.servlet.ServletContext").
 *
 * @param configuration the {@link ExtendedProperties} associated with
 *                      this resource loader.
 */
public void init(ExtendedProperties configuration) {
    log.trace("WebappResourceLoader: initialization starting.");

    /* get configured paths */
    paths = configuration.getStringArray("path");
    if (paths == null || paths.length == 0) {
        paths = new String[1];
        paths[0] = "/";
    } else {
        /* make sure the paths end with a '/' */
        for (int i = 0; i < paths.length; i++) {
            if (!paths[i].endsWith("/")) {
                paths[i] += '/';
            }
            log.info("WebappResourceLoader: added template path - '" + paths[i] + "'");
        }
    }

    /* get the ServletContext */
    Object obj = rsvc.getApplicationAttribute(ServletContext.class.getName());
    if (obj instanceof ServletContext) {
        servletContext = (ServletContext) obj;
    } else {
        log.error("WebappResourceLoader: unable to retrieve ServletContext");
    }

    /* init the template paths map */
    templatePaths = new HashMap();

    log.trace("WebappResourceLoader: initialization complete.");
}
 
Example #11
Source File: right_Attachment_1.25.java    From gumtree-spoon-ast-diff with Apache License 2.0 5 votes vote down vote up
/**
 * Get the repository path info
 * @return String
 */
public String getRepositoryDirectory(String moduleCode)
    throws Exception
{
    ExtendedProperties extProp = TurbineServices.getInstance()
        .getService(UploadService.SERVICE_NAME).getConfiguration();
    String uploadFileRepo = (String)extProp.getProperty(UploadService.REPOSITORY_KEY);
    String repoModuleDir = uploadFileRepo + File.separator + moduleCode;
    File repoDir = new File(repoModuleDir);
    
    if (!repoDir.exists())
    {
        try
        {
            repoDir.mkdir();
        }
        catch (SecurityException e)
        {
            String errorMessage = 
                "Unable to create directory for repository: " + 
                repoModuleDir;
            Log.error(errorMessage + ", " + e.getMessage());
            throw new Exception(errorMessage);
        }
    }
    
    return repoModuleDir;
}
 
Example #12
Source File: VelocimacroUtils.java    From velocity-spring-boot-project with Apache License 2.0 5 votes vote down vote up
/**
 * Convert Singleton element {@link ExtendedProperties} from {@link Velocity} {@link Properties}
 *
 * @param velocityProperties {@link Velocity} {@link Properties}
 * @param propertyName       the name of property
 * @return non-null {@link ExtendedProperties}
 */
protected static ExtendedProperties toSingletonExtendedProperties(Map<String, String> velocityProperties, String propertyName) {
    String library = velocityProperties.get(propertyName);
    ExtendedProperties extendedProperties = new ExtendedProperties();
    if (StringUtils.hasText(library)) {
        extendedProperties.setProperty(propertyName, library);
    }
    return extendedProperties;
}
 
Example #13
Source File: VelocimacroUtils.java    From velocity-spring-boot-project with Apache License 2.0 5 votes vote down vote up
/**
 * Append Velocimacro Library into {@link Velocity} {@link Properties}
 *
 * @param velocityProperties {@link Velocity} {@link Properties}
 * @param libraryPath        the path of Velocimacro Library
 */
public static void appendVelocimacroLibrary(Map<String, String> velocityProperties, String libraryPath) {
    String propertyName = RuntimeConstants.VM_LIBRARY;
    ExtendedProperties extendedProperties = toSingletonExtendedProperties(velocityProperties, propertyName);
    extendedProperties.addProperty(propertyName, libraryPath);
    List<String> listValue = extendedProperties.getList(propertyName);
    String propertyValue = StringUtils.collectionToCommaDelimitedString(listValue);
    velocityProperties.put(propertyName, propertyValue);
}
 
Example #14
Source File: PrefixedClasspathResourceLoader.java    From pippo with Apache License 2.0 4 votes vote down vote up
@Override
public void init(ExtendedProperties configuration) {
    prefix = configuration.getString("prefix", "");
}
 
Example #15
Source File: LocalizedTemplateResourceLoaderImpl.java    From gazpachoquest with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void init(final ExtendedProperties configuration) {
}
 
Example #16
Source File: TemplateEngineUtils.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
public void init(ExtendedProperties configuration) {
}
 
Example #17
Source File: StringResourceLoader.java    From ApprovalTests.Java with Apache License 2.0 4 votes vote down vote up
public void init(ExtendedProperties arg0)
{
}
 
Example #18
Source File: VelocimacroUtilsTest.java    From velocity-spring-boot-project with Apache License 2.0 4 votes vote down vote up
/**
 * {@link VelocimacroUtils#toSingletonExtendedProperties(Map, String)}
 */
@Test
public void testToSingletonExtendedProperties() {

    Map<String, String> velocityProperties = new HashMap<>();

    List<String> pathsList = Arrays.asList("/macros/main.vm", "/macros/index.vm");

    String vmLibrary = StringUtils.collectionToCommaDelimitedString(pathsList);

    String propertyName = RuntimeConstants.VM_LIBRARY;

    velocityProperties.put(propertyName, vmLibrary);

    ExtendedProperties extendedProperties = VelocimacroUtils.toSingletonExtendedProperties(velocityProperties, propertyName);

    Assert.assertEquals(pathsList, extendedProperties.getList(propertyName));


}
 
Example #19
Source File: TemplateEngineUtils.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
public void init(ExtendedProperties configuration) {
}
 
Example #20
Source File: TemplateEngineUtils.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
public void init(ExtendedProperties configuration) {
}
 
Example #21
Source File: TemplateEngineUtils.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
public void init(ExtendedProperties configuration) {
}
 
Example #22
Source File: TemplateEngineUtils.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
public void init(ExtendedProperties configuration) {
}
 
Example #23
Source File: RegistryBasedResourceLoader.java    From carbon-device-mgt with Apache License 2.0 2 votes vote down vote up
@Override
public void init(ExtendedProperties extendedProperties) {

}
 
Example #24
Source File: LocalizedTemplateResourceLoader.java    From gazpachoquest with GNU General Public License v3.0 votes vote down vote up
void init(ExtendedProperties configuration);