Search in sources :

Example 1 with DefaultResourceImportHandler

use of org.cristalise.kernel.process.resource.DefaultResourceImportHandler in project kernel by cristal-ise.

the class Gateway method getResourceImportHandler.

/**
 * Retrieves the ResourceImportHandler available for the resource type. It creates a new if configured
 * or falls back to the default one provided in the kernel
 *
 * @param resType the type o the Resource
 * @return the initialised ResourceImportHandler
 */
public static ResourceImportHandler getResourceImportHandler(BuiltInResources resType) throws Exception {
    if (resourceImportHandlerCache.containsKey(resType))
        return resourceImportHandlerCache.get(resType);
    ResourceImportHandler handler = null;
    if (Gateway.getProperties().containsKey("ResourceImportHandler." + resType)) {
        try {
            handler = (ResourceImportHandler) Gateway.getProperties().getInstance("ResourceImportHandler." + resType);
        } catch (Exception ex) {
            Logger.error(ex);
            Logger.error("Exception loading ResourceHandler for " + resType + ". Using default.");
        }
    }
    if (handler == null)
        handler = new DefaultResourceImportHandler(resType);
    resourceImportHandlerCache.put(resType, handler);
    return handler;
}
Also used : DefaultResourceImportHandler(org.cristalise.kernel.process.resource.DefaultResourceImportHandler) DefaultResourceImportHandler(org.cristalise.kernel.process.resource.DefaultResourceImportHandler) ResourceImportHandler(org.cristalise.kernel.process.resource.ResourceImportHandler) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) MalformedURLException(java.net.MalformedURLException) PersistencyException(org.cristalise.kernel.common.PersistencyException) CannotManageException(org.cristalise.kernel.common.CannotManageException)

Aggregations

MalformedURLException (java.net.MalformedURLException)1 CannotManageException (org.cristalise.kernel.common.CannotManageException)1 InvalidDataException (org.cristalise.kernel.common.InvalidDataException)1 ObjectNotFoundException (org.cristalise.kernel.common.ObjectNotFoundException)1 PersistencyException (org.cristalise.kernel.common.PersistencyException)1 DefaultResourceImportHandler (org.cristalise.kernel.process.resource.DefaultResourceImportHandler)1 ResourceImportHandler (org.cristalise.kernel.process.resource.ResourceImportHandler)1