Search in sources :

Example 31 with ContextKey

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

the class ApplicationRulesManager method unregisterResource.

/**
 * unregisterResource - Provides a method which unregisters a given properties resource.
 *
 * @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 {
    Properties properties = new Properties();
    InputStream resourceInputStream = resource.getInputStream();
    if (resource != null && resourceInputStream != null) {
        loadPropertiesResource(resourceInputStream, properties);
        if (!properties.isEmpty()) {
            for (Object property : properties.keySet()) {
                ContextKey key = new ContextKey((String) property, resource.getURI().toString(), variation, precedence);
                unregisterProperties(key);
            }
        }
        resourceInputStream.close();
    }
}
Also used : ContextKey(org.jaffa.loader.ContextKey) InputStream(java.io.InputStream) Properties(java.util.Properties)

Example 32 with ContextKey

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

the class RoleManager method unregisterResource.

/**
 * unregisterResource - Unregisters the roles from the role repository using the roles.xml files found in META-INF/roles.xml
 * that exist in the classpath. This is used to return the repository to its original state before a custom
 * configuration was added.
 * @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 {
    Roles roles = JAXBHelper.unmarshalConfigFile(Roles.class, resource, CONFIGURATION_SCHEMA_FILE);
    if (roles.getRole() != null) {
        for (final Role role : roles.getRole()) {
            ContextKey key = new ContextKey(role.getName(), resource.getURI().toString(), variation, context);
            unregisterRole(key);
        }
    }
}
Also used : Role(org.jaffa.security.securityrolesdomain.Role) ContextKey(org.jaffa.loader.ContextKey) Roles(org.jaffa.security.securityrolesdomain.Roles)

Example 33 with ContextKey

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

the class ComponentManagerTest method testGetName.

/**
 * Test the repository name retrieval function
 */
@Test
public void testGetName() throws Exception {
    // A componentDefinition must be registered first
    Component component = new Component();
    String name = "q1";
    component.setId(name);
    ComponentDefinition definition = new ComponentDefinition(component);
    ContextKey key = new ContextKey(name, "components.xml", "DEF", "0-PLATFORM");
    manager.registerComponentDefinition(key, definition);
    assertEquals("ComponentDefinition", manager.getComponentRepository().getName());
}
Also used : ContextKey(org.jaffa.loader.ContextKey) Component(org.jaffa.presentation.portlet.component.componentdomain.Component) ComponentDefinition(org.jaffa.presentation.portlet.component.ComponentDefinition) Test(org.junit.Test)

Example 34 with ContextKey

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

the class ComponentManagerTest method testRegisterComponentDefinition.

/**
 * Tests registration of ComponentDefinition objects
 * @throws Exception
 */
@Test
public void testRegisterComponentDefinition() throws Exception {
    Component component = new Component();
    String name = "q1";
    component.setId(name);
    ComponentDefinition definition = new ComponentDefinition(component);
    ContextKey key = new ContextKey(name, "components.xml", VariationContext.NULL_VARIATION, "0-PLATFORM");
    manager.registerComponentDefinition(key, definition);
    ComponentDefinition retrievedDefinition = manager.getComponentDefinition(name);
    assertEquals(definition, retrievedDefinition);
}
Also used : ContextKey(org.jaffa.loader.ContextKey) Component(org.jaffa.presentation.portlet.component.componentdomain.Component) ComponentDefinition(org.jaffa.presentation.portlet.component.ComponentDefinition) Test(org.junit.Test)

Example 35 with ContextKey

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

the class ApplicationRulesXmlLoadTest method testApplicationRulesRegistration.

/**
 * testApplicationRulesRegistration - Verifies that the ApplicationRules_*.properties has been loaded correctly
 * into the NavigationManager.
 */
@Test
public void testApplicationRulesRegistration() {
    ApplicationRulesManager applicationRulesManager = xmlLoaderConfig.getBean(ApplicationRulesManager.class);
    ContextKey key = new ContextKey("test", "Application_Rules", "DEF", "100-Highest");
    assertNull(applicationRulesManager.getApplicationRulesRepository().query(key));
    applicationRulesManager.registerProperties(key, "test1");
    assertNotNull(applicationRulesManager.getApplicationRulesRepository().query(key));
    applicationRulesManager.unregisterProperties(key);
    assertNull(applicationRulesManager.getApplicationRulesRepository().query(key));
}
Also used : ContextKey(org.jaffa.loader.ContextKey) Test(org.junit.Test)

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