Search in sources :

Example 1 with BusinessFunctions

use of org.jaffa.security.businessfunctionsdomain.BusinessFunctions 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 2 with BusinessFunctions

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

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

the class CheckPolicyComponent method readFunctions.

/**
 * This reads the bussiness-functions from the bussiness-functions.xml file
 * @throws ApplicationExceptions if any error occurs.
 */
private List readFunctions() throws ApplicationExceptions {
    ApplicationExceptions appExps = new ApplicationExceptions();
    ArrayList bflist = new ArrayList();
    InputStream stream = null;
    try {
        stream = URLHelper.newExtendedURL("resources/business-functions.xml").openStream();
        // create a JAXBContext capable of handling classes generated into the package
        JAXBContext jc = JAXBContext.newInstance("org.jaffa.security.businessfunctionsdomain");
        // create an Unmarshaller
        Unmarshaller u = jc.createUnmarshaller();
        // enable validation
        u.setSchema(JAXBHelper.createSchema(SCHEMA));
        // unmarshal a document into a tree of Java content objects composed of classes from the package.
        BusinessFunctions businessFunctions = (BusinessFunctions) u.unmarshal(XmlHelper.stripDoctypeDeclaration(stream));
        for (Iterator i = businessFunctions.getBusinessFunction().iterator(); i.hasNext(); ) {
            bflist.add(((BusinessFunction) i.next()).getName());
        }
    } catch (Exception e) {
        appExps.add(new CheckPolicyException(CheckPolicyException.PROP_FILEREAD_ERROR, StringHelper.convertToHTML(e.getMessage())));
        throw appExps;
    } finally {
        try {
            if (stream != null) {
                stream.close();
            }
        } catch (IOException e) {
        // do nothing
        }
    }
    return bflist;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) InputStream(java.io.InputStream) BusinessFunctions(org.jaffa.security.businessfunctionsdomain.BusinessFunctions) CheckPolicyException(org.jaffa.applications.jaffa.modules.admin.components.checkpolicy.ui.exceptions.CheckPolicyException) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) JAXBContext(javax.xml.bind.JAXBContext) IOException(java.io.IOException) Unmarshaller(javax.xml.bind.Unmarshaller) FrameworkException(org.jaffa.exceptions.FrameworkException) CheckPolicyException(org.jaffa.applications.jaffa.modules.admin.components.checkpolicy.ui.exceptions.CheckPolicyException) IOException(java.io.IOException)

Aggregations

BusinessFunctions (org.jaffa.security.businessfunctionsdomain.BusinessFunctions)3 ContextKey (org.jaffa.loader.ContextKey)2 BusinessFunction (org.jaffa.security.businessfunctionsdomain.BusinessFunction)2 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 JAXBContext (javax.xml.bind.JAXBContext)1 Unmarshaller (javax.xml.bind.Unmarshaller)1 CheckPolicyException (org.jaffa.applications.jaffa.modules.admin.components.checkpolicy.ui.exceptions.CheckPolicyException)1 ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)1 FrameworkException (org.jaffa.exceptions.FrameworkException)1