Search in sources :

Example 1 with DescriptorType

use of com.evolveum.midpoint.xml.ns._public.gui.admin_1.DescriptorType in project midpoint by Evolveum.

the class DescriptorLoader method loadData.

public void loadData(MidPointApplication application) {
    LOGGER.debug("Loading data from descriptor files.");
    try (InputStream baseInput = application.getServletContext().getResourceAsStream(baseFileName);
        InputStream customInput = application.getServletContext().getResourceAsStream(customFileName)) {
        if (baseInput == null) {
            LOGGER.error("Couldn't find " + baseFileName + " file, can't load application menu and other stuff.");
        }
        JAXBContext context = JAXBContext.newInstance(ObjectFactory.class);
        Unmarshaller unmarshaller = context.createUnmarshaller();
        JAXBElement<DescriptorType> element = (JAXBElement) unmarshaller.unmarshal(baseInput);
        DescriptorType descriptor = element.getValue();
        LOGGER.debug("Loading menu bar from " + baseFileName + " .");
        DescriptorType customDescriptor = null;
        if (customInput != null) {
            element = (JAXBElement) unmarshaller.unmarshal(customInput);
            customDescriptor = element.getValue();
        }
        scanPackagesForPages(descriptor.getPackagesToScan(), application);
        if (customDescriptor != null) {
            scanPackagesForPages(customDescriptor.getPackagesToScan(), application);
        }
        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace("loaded:\n{}", debugDump(1));
        }
    } catch (Exception ex) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't process application descriptor", ex);
    }
}
Also used : InputStream(java.io.InputStream) DescriptorType(com.evolveum.midpoint.xml.ns._public.gui.admin_1.DescriptorType) JAXBContext(javax.xml.bind.JAXBContext) JAXBElement(javax.xml.bind.JAXBElement) Unmarshaller(javax.xml.bind.Unmarshaller)

Aggregations

DescriptorType (com.evolveum.midpoint.xml.ns._public.gui.admin_1.DescriptorType)1 InputStream (java.io.InputStream)1 JAXBContext (javax.xml.bind.JAXBContext)1 JAXBElement (javax.xml.bind.JAXBElement)1 Unmarshaller (javax.xml.bind.Unmarshaller)1