Search in sources :

Example 1 with BusinessFunction

use of org.jaffa.security.businessfunctionsdomain.BusinessFunction in project jaffa-framework by jaffa-projects.

the class BusinessFunctionXmlLoadTest method testGetBusinessFunctionRegistration.

/**
 * Verifies that we can register and unregister specific business functions provided by the client.
 */
@Test
public void testGetBusinessFunctionRegistration() {
    BusinessFunctionManager businessFunctionManager = xmlLoaderConfig.getBean(BusinessFunctionManager.class);
    assertNull(businessFunctionManager.getBusinessFunction("Jaffa.WebServices.Test"));
    BusinessFunction businessFunction = new BusinessFunction();
    ContextKey key = new ContextKey("Jaffa.WebServices.Test", "business-functions.xml", VariationContext.NULL_VARIATION, "100-Highest");
    businessFunctionManager.registerBusinessFunction(key, businessFunction);
    assertNotNull(businessFunctionManager.getBusinessFunction("Jaffa.WebServices.Test"));
    businessFunctionManager.unregisterBusinessFunction(key);
    assertNull(businessFunctionManager.getBusinessFunction("Jaffa.WebServices.Test"));
}
Also used : ContextKey(org.jaffa.loader.ContextKey) BusinessFunction(org.jaffa.security.businessfunctionsdomain.BusinessFunction) Test(org.junit.Test)

Example 2 with BusinessFunction

use of org.jaffa.security.businessfunctionsdomain.BusinessFunction 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)

Example 3 with BusinessFunction

use of org.jaffa.security.businessfunctionsdomain.BusinessFunction in project jaffa-framework by jaffa-projects.

the class BusinessFunctionManager method registerResource.

/**
 * registerResource - Registers the roles into the business function repository from 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 registerResource(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);
            registerBusinessFunction(contextKey, businessFunction);
        }
    }
}
Also used : ContextKey(org.jaffa.loader.ContextKey) BusinessFunctions(org.jaffa.security.businessfunctionsdomain.BusinessFunctions) BusinessFunction(org.jaffa.security.businessfunctionsdomain.BusinessFunction)

Example 4 with BusinessFunction

use of org.jaffa.security.businessfunctionsdomain.BusinessFunction in project jaffa-framework by jaffa-projects.

the class BusinessFunctionManager method getAllBusinessFunctionsStrings.

/**
 * getAllBusinessFunctionsStrings - Returns a list of all business functions as a list of strings.
 * @return all business functions as Strings
 */
public List<String> getAllBusinessFunctionsStrings() {
    List<BusinessFunction> businessFunctions = getAllBusinessFunctions();
    List<String> businessFunctionStrings = new ArrayList<>();
    for (BusinessFunction businessFunction : businessFunctions) {
        businessFunctionStrings.add(businessFunction.getName());
    }
    return businessFunctionStrings;
}
Also used : ArrayList(java.util.ArrayList) BusinessFunction(org.jaffa.security.businessfunctionsdomain.BusinessFunction)

Aggregations

BusinessFunction (org.jaffa.security.businessfunctionsdomain.BusinessFunction)4 ContextKey (org.jaffa.loader.ContextKey)3 BusinessFunctions (org.jaffa.security.businessfunctionsdomain.BusinessFunctions)2 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1