Search in sources :

Example 6 with ContextKey

use of org.jaffa.loader.ContextKey in project jaffa-framework by jaffa-projects.

the class ApplicationResourcesManager method unregisterResource.

/**
 * unregisterResource - Provides a method which removes the contents of the resource file to the application resource
 * repository.
 *
 * @param resource   the object that contains the xml config file.
 * @param precedence associated with the module based on its definition in manifest
 * @param variation  associated with the module based on its definition in manifest
 * @throws JAXBException
 * @throws SAXException
 * @throws IOException
 */
@Override
public void unregisterResource(Resource resource, String precedence, String variation) throws JAXBException, SAXException, IOException {
    if (resource != null && resource.getInputStream() != null) {
        Properties properties = new Properties();
        properties.load(resource.getInputStream());
        boolean isLocaleResource = Boolean.FALSE;
        String locale = null;
        if (log.isDebugEnabled()) {
            log.debug("Filename :" + resource.getFilename());
        }
        if ((resource.getFilename().indexOf("_") > 0)) {
            locale = resource.getFilename().substring(resource.getFilename().indexOf("_") + 1, resource.getFilename().lastIndexOf("."));
            isLocaleResource = Boolean.TRUE;
        }
        if (!properties.isEmpty()) {
            if (isLocaleResource) {
                // locale resources
                ContextKey key = new ContextKey(locale + "_" + variation, resource.getURI().toString(), variation, precedence);
                unregisterLocaleProperties(key);
            } else {
                // default resource
                for (Object property : properties.keySet()) {
                    ContextKey key = new ContextKey((String) property, resource.getURI().toString(), variation, precedence);
                    unregisterProperties(key);
                }
            }
        }
    }
}
Also used : ContextKey(org.jaffa.loader.ContextKey) Properties(java.util.Properties)

Example 7 with ContextKey

use of org.jaffa.loader.ContextKey in project jaffa-framework by jaffa-projects.

the class ApplicationRulesManager method registerProperties.

/**
 * registerProperties() - Registers each property from a provided ContextKey for repository access
 * @param mapRepository The repository to register the properties to
 * @param key   The ContextKey corresponding to the property values
 * @param properties    The Properties object containing property key/value pairs
 */
private void registerProperties(MapRepository<String> mapRepository, ContextKey key, Properties properties) {
    Iterator<String> contextKeyPropertiesIterator = properties.stringPropertyNames().iterator();
    while (contextKeyPropertiesIterator.hasNext()) {
        String propertyKey = contextKeyPropertiesIterator.next();
        String propertyValue = properties.getProperty(propertyKey);
        mapRepository.register(new ContextKey(propertyKey, key.getFileName(), key.getVariation(), key.getPrecedence()), propertyValue);
    }
}
Also used : ContextKey(org.jaffa.loader.ContextKey)

Example 8 with ContextKey

use of org.jaffa.loader.ContextKey in project jaffa-framework by jaffa-projects.

the class NavigationManager method unregisterResource.

/**
 * unregisterXML - Unregisters the navigation global menu from the IRepository
 * @param resource the object that contains the xml config file.
 * @param precedence associated with the module based on its definition in manifest
 * @param variation associated with the module based on its definition in manifest
 * @throws JAXBException
 * @throws SAXException
 * @throws IOException
 */
@Override
public void unregisterResource(Resource resource, String precedence, String variation) throws JAXBException, SAXException, IOException {
    GlobalMenu globalMenu = JAXBHelper.unmarshalConfigFile(GlobalMenu.class, resource, CONFIGURATION_SCHEMA_FILE);
    if (globalMenu != null) {
        ContextKey key = new ContextKey(GLOBAL_MENU_ID, resource.getURI().toString(), variation, precedence);
        unregisterGlobalMenu(key);
    }
}
Also used : ContextKey(org.jaffa.loader.ContextKey) GlobalMenu(org.jaffa.components.navigation.domain.GlobalMenu)

Example 9 with ContextKey

use of org.jaffa.loader.ContextKey in project jaffa-framework by jaffa-projects.

the class NavigationManager method registerResource.

/**
 * registerXML - Registers the navigation global menu into the IRepository
 * @param resource the object that contains the xml config file.
 * @param precedence associated with the module based on its definition in manifest
 * @param variation associated with the module based on its definition in manifest
 * @throws JAXBException
 * @throws SAXException
 * @throws IOException
 */
@Override
public void registerResource(Resource resource, String precedence, String variation) throws JAXBException, SAXException, IOException {
    GlobalMenu globalMenu = JAXBHelper.unmarshalConfigFile(GlobalMenu.class, resource, CONFIGURATION_SCHEMA_FILE);
    if (globalMenu != null) {
        ContextKey key = new ContextKey(GLOBAL_MENU_ID, resource.getURI().toString(), variation, precedence);
        registerGlobalMenu(key, globalMenu);
    }
}
Also used : ContextKey(org.jaffa.loader.ContextKey) GlobalMenu(org.jaffa.components.navigation.domain.GlobalMenu)

Example 10 with ContextKey

use of org.jaffa.loader.ContextKey in project jaffa-framework by jaffa-projects.

the class BusinessFunctionManager method unregisterResource.

/**
 * unregisterResource - Unregisters the roles from the business function repository using a business-functions.xml file.
 * @param resource the object that contains the xml config file.
 * @param context  key with which config file to be registered.
 * @throws JAXBException
 * @throws SAXException
 * @throws IOException
 */
@Override
public void unregisterResource(Resource resource, String context, String variation) throws JAXBException, SAXException, IOException {
    BusinessFunctions businessFunctions = JAXBHelper.unmarshalConfigFile(BusinessFunctions.class, resource, CONFIGURATION_SCHEMA_FILE);
    if (businessFunctions.getBusinessFunction() != null) {
        for (final BusinessFunction businessFunction : businessFunctions.getBusinessFunction()) {
            ContextKey contextKey = new ContextKey(businessFunction.getName(), resource.getURI().toString(), variation, context);
            unregisterBusinessFunction(contextKey);
        }
    }
}
Also used : ContextKey(org.jaffa.loader.ContextKey) BusinessFunctions(org.jaffa.security.businessfunctionsdomain.BusinessFunctions) BusinessFunction(org.jaffa.security.businessfunctionsdomain.BusinessFunction)

Aggregations

ContextKey (org.jaffa.loader.ContextKey)49 Test (org.junit.Test)21 ComponentDefinition (org.jaffa.presentation.portlet.component.ComponentDefinition)6 Component (org.jaffa.presentation.portlet.component.componentdomain.Component)5 TransactionInfo (org.jaffa.transaction.services.configdomain.TransactionInfo)5 TypeInfo (org.jaffa.transaction.services.configdomain.TypeInfo)5 Properties (java.util.Properties)4 Task (org.jaffa.modules.scheduler.services.configdomain.Task)4 GlobalMenu (org.jaffa.components.navigation.domain.GlobalMenu)3 BusinessFunction (org.jaffa.security.businessfunctionsdomain.BusinessFunction)3 Role (org.jaffa.security.securityrolesdomain.Role)3 Config (org.jaffa.transaction.services.configdomain.Config)3 InputStream (java.io.InputStream)2 Config (org.jaffa.modules.messaging.services.configdomain.Config)2 JmsConfig (org.jaffa.modules.messaging.services.configdomain.JmsConfig)2 JndiConfig (org.jaffa.modules.messaging.services.configdomain.JndiConfig)2 Config (org.jaffa.modules.scheduler.services.configdomain.Config)2 Components (org.jaffa.presentation.portlet.component.componentdomain.Components)2 BusinessFunctions (org.jaffa.security.businessfunctionsdomain.BusinessFunctions)2 Roles (org.jaffa.security.securityrolesdomain.Roles)2