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);
}
}
}
}
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
}
Aggregations