Example usage for java.lang Module Module

List of usage examples for java.lang Module Module

Introduction

In this page you can find the example usage for java.lang Module Module.

Prototype

Module

Source Link

Usage

From source file:architecture.common.license.License.java

public static License fromXML(String xml) {
    try {// w w w  .ja  v  a  2  s  .c o  m
        Document d = DocumentHelper.parseText(xml);
        Element root = d.getRootElement();
        License l = new License();
        String id = root.attributeValue("id");
        if (id == null)
            throw new LicenseException(L10NUtils.format("002105"));
        l.setID(Long.parseLong(id));
        String name0 = root.attributeValue("name");
        if (name0 == null)
            throw new LicenseException(L10NUtils.format("002106"));
        l.setName(name0);
        String edition = root.attributeValue("edition");
        if (edition != null)
            l.setEdition(edition);
        String dateString = root.attributeValue("creationDate");
        if (dateString == null)
            throw new LicenseException(L10NUtils.format("002107"));
        try {
            Date date = parseDate(dateString);
            l.setCreationDate(date);
        } catch (Exception e) {
            throw new LicenseException(L10NUtils.format("002108"));
        }
        String license = root.attributeValue("version");
        if (license == null)
            throw new LicenseException(L10NUtils.format("002109"));
        l.setVersion(Version.parseVersion(license));
        try {
            l.setType(Type.valueOf(root.attributeValue("type")));
        } catch (IllegalArgumentException e) {
            throw new LicenseException(L10NUtils.format("002110"));
        }
        Element clientElement = root.element("client");
        Client client = new Client();
        client.setName(clientElement.attributeValue("name"));
        client.setCompany(clientElement.attributeValue("company"));
        l.setClient(client);

        for (Element e : (List<Element>) root.elements("module")) {
            Module m = new Module();
            m.setName(e.attributeValue("name"));
            l.getModules().add(m);
        }

        Map<String, String> properties = new HashMap<String, String>();
        for (Element e : (List<Element>) root.elements("property")) {
            String name = e.attributeValue("name");
            String value = e.getTextTrim();
            properties.put(name, value);
        }

        l.setProperties(properties);
        Element sig = root.element("signature");
        l.setSignature(sig.getTextTrim());
        return l;
    } catch (DocumentException e) {
        log.fatal(e.getMessage(), e);
        throw new LicenseException(L10NUtils.format("002111"), e);
    }
}

From source file:org.etudes.component.app.melete.MeleteImportServiceImpl.java

/**
 * Builds the module for each Item element under organization
 *
 * @param eleItem item element//from www .jav  a2 s.  c om
 * @exception throws exception
 * revised by rashmi - change the whole structure of accessing elements
 */
private void buildModule(Element eleItem, Document document, String unZippedDirPath, String courseId)
        throws Exception {

    if (logger.isDebugEnabled())
        logger.debug("Entering buildModule...");

    //      create module object
    Module module = new Module();
    boolean moduleTitleFlag = false;
    if (eleItem.attribute("isvisible") != null) {
        if (((Attribute) eleItem.attribute("isvisible")).getValue().equals("false")) {
            CourseModule cmod = new CourseModule(courseId, -1, true, null, false, module);
            module.setCoursemodule(cmod);
        }
    }
    if (eleItem.elements("title") != null && eleItem.elements("title").size() != 0) {
        Element titleEle = (Element) eleItem.elements("title").get(0);
        if (titleEle != null) {
            String title = titleEle.getTextTrim();
            if (title != null && title.length() != 0) {
                module.setTitle(title);
                moduleTitleFlag = true;
            }
        }
    }
    if (!moduleTitleFlag)
        module.setTitle("Untitled Module");

    boolean keywords = false;
    boolean descr = false;
    if (eleItem.selectNodes("./imsmd:lom/imsmd:general") != null
            && eleItem.selectNodes("./imsmd:lom/imsmd:general").size() != 0) {
        Element generalElement = (Element) eleItem.selectNodes("./imsmd:lom/imsmd:general").get(0);
        List moduleMetadataList = generalElement.elements();
        for (Iterator iter = moduleMetadataList.iterator(); iter.hasNext();) {
            Element metaElement = (Element) iter.next();

            if (metaElement.getName().equals("description")) {
                String desc = metaElement.selectSingleNode(".//imsmd:langstring").getText();
                module.setDescription(desc.trim());
                descr = true;
            }

            if (metaElement.getName().equals("keyword")) {
                String modkeyword = metaElement.selectSingleNode(".//imsmd:langstring").getText();
                if (modkeyword != null) {
                    module.setKeywords(modkeyword.trim());
                    keywords = true;
                }
            }
        }
    }
    if (!keywords)
        module.setKeywords(module.getTitle());
    if (!descr)
        module.setDescription("    ");
    createModule(module, courseId);

    //       build sections
    try {
        sectionUtil = new SubSectionUtilImpl();
        Document seqDocument = sectionUtil.createSubSection4jDOM();

        for (Iterator iter = eleItem.elementIterator("item"); iter.hasNext();) {
            Element element = (Element) iter.next();

            if (element.attributeValue("identifier").startsWith("NEXTSTEPS"))
                buildWhatsNext(element, document, module, unZippedDirPath);
            else
                buildSection(element, document, module, addBlankSection(null, seqDocument), unZippedDirPath,
                        seqDocument, courseId);
        }

        // update module seqXml
        //   logger.debug("checking seqXML now at the end of buildModule process" + seqDocument.asXML());
        module.setSeqXml(seqDocument.asXML());
        moduleDB.updateModule(module);
    } catch (Exception e) {
        //   e.printStackTrace();
        throw e;
    }
    if (logger.isDebugEnabled())
        logger.debug("Exiting buildModule...");
}

From source file:org.etudes.component.app.melete.ModuleDB.java

private void populateModuleBean(Module mod, ModuleDateBean mdBean) {
    String modSeq;// ww w  .  ja va  2s  . c o  m
    SubSectionUtilImpl ssuImpl;
    StringBuffer rowClassesBuf;
    List sectionBeanList = null;
    Map sectionMap = null;
    java.sql.Timestamp currentTimestamp = new java.sql.Timestamp(Calendar.getInstance().getTimeInMillis());

    if (mod == null)
        mod = new Module();
    mdBean.setVisibleFlag(mod.getModuleshdate().isVisibleFlag());
    mdBean.setModuleId(mod.getModuleId().intValue());
    mdBean.setModule((Module) mod);
    mdBean.setModuleShdate(mod.getModuleshdate());
    mdBean.setCmod(mod.getCoursemodule());
    mdBean.setTruncTitle(createTruncstr(mod.getTitle()));

    sectionMap = mod.getSections();

    if (sectionMap != null) {
        if (sectionMap.size() > 0) {
            modSeq = Integer.toString(mod.getCoursemodule().getSeqNo());
            ssuImpl = new SubSectionUtilImpl();
            ssuImpl.traverseDom(mod.getSeqXml(), modSeq);
            xmlSecList = ssuImpl.getXmlSecList();
            sectionBeanList = new ArrayList();
            rowClassesBuf = new StringBuffer();

            xmlSecList = correctSections(sectionMap, mod, xmlSecList);
            processSections(sectionMap, sectionBeanList, xmlSecList, rowClassesBuf);
            mdBean.setSectionBeans(sectionBeanList);
            mdBean.setRowClasses(rowClassesBuf.toString());
        }
    }

}

From source file:com.ephesoft.dcma.webservice.EphesoftWebServiceAPI.java

/**
 * To get all Modules Workflow Name by Batch Class.
 * @param identifier {@link String}/*w ww  .  j a  v a  2  s .c o  m*/
 * @param resp {@link HttpServletResponse}
 * @param req {@link HttpServletRequest}
 */
@RequestMapping(value = "/getAllModulesWorkflowNameByBatchClass/{batchClassIdentifier}", method = RequestMethod.GET)
@ResponseBody
public void getAllModulesWorkflowNameByBatchClass(@PathVariable("batchClassIdentifier") final String identifier,
        final HttpServletResponse resp, final HttpServletRequest req) {
    LOGGER.info("Start processing web service for get all modules workflowName by batchClassId");
    String respStr = "";
    Set<String> loggedInUserRole = getUserRoles(req);
    if (loggedInUserRole == null || loggedInUserRole.isEmpty()) {
        respStr = "User is not authorized to view this API.";
    } else {
        if (identifier != null && !identifier.isEmpty()) {
            final BatchClass batchClass = bcService.getBatchClassByIdentifier(identifier);
            if (batchClass != null) {
                boolean isBatchClassViewableToUser = isBatchClassViewableToUser(identifier, loggedInUserRole,
                        isSuperAdmin(req));
                if (isBatchClassViewableToUser) {
                    List<BatchClassModule> modules = batchClass.getBatchClassModules();
                    Modules modulesSchema = new Modules();
                    for (BatchClassModule bcm : modules) {
                        Module module = new Module();
                        module.setModuleName(bcm.getModule().getName());
                        module.setWorkflowName(bcm.getWorkflowName());
                        modulesSchema.getModule().add(module);
                    }
                    StreamResult result;
                    try {
                        result = new StreamResult(resp.getOutputStream());
                        resp.setStatus(HttpServletResponse.SC_OK);
                        batchSchemaDao.getJAXB2Template().getJaxb2Marshaller().marshal(modulesSchema, result);
                    } catch (final IOException e) {
                        try {
                            resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                                    INTERNAL_SERVER_ERROR + e.getMessage());
                        } catch (final IOException ioe) {
                            LOGGER.info(ERROR_WHILE_SENDING_ERROR_RESPONSE_TO_CLIENT + ioe, ioe);
                        }
                    }
                } else {
                    respStr = "User not authorized to view this batch class id:" + identifier;
                    LOGGER.error(SERVER_ERROR_MSG + respStr);
                }
            } else {
                respStr = "Batch Class does not exist with batch class id:" + identifier;
                LOGGER.error(SERVER_ERROR_MSG + respStr);
            }
        } else {
            respStr = "Invalid input parameters.";
            LOGGER.error(SERVER_ERROR_MSG + respStr);

        }
    }

    if (!respStr.isEmpty()) {
        try {
            resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, respStr);
            LOGGER.error(SERVER_ERROR_MSG + respStr);
        } catch (IOException ioe) {
            LOGGER.info(ERROR_WHILE_SENDING_ERROR_RESPONSE_TO_CLIENT + ioe, ioe);
        }
    }
}

From source file:com.ephesoft.dcma.webservice.util.WebServiceHelper.java

/**
 * Gets the all WorkFlow name and the module name of the Batch Class Identifier as requested by the Client in the Request
 * // w  w w. j a v a 2s .  c om
 * @param loggedInUserRole {@link Set} Roles specifed for the user
 * @param identifier {@link String} Batch Class identifier which is the Name of the Batch Class Identifier
 * @param isBatchClassViewable boolean It is t5he flag which determines that the Batch Class is Visible to the user or not
 * @return {@link Modules} All the modules and the work Flow names
 * @throws ValidationException The validation exception - in case some parameter is not valid.
 * @throws UnAuthorisedAccessException the un authorised access exception - in case user does not have access to the passed batch
 *             class.
 */
public Modules getAllModulesWorkflowNameByBatchClass(final Set<String> loggedInUserRole,
        final String identifier, final boolean isBatchClassViewable)
        throws ValidationException, UnAuthorisedAccessException {
    final Modules modulesSchema = new Modules();
    if (CollectionUtils.isEmpty(loggedInUserRole)) {
        throw new UnAuthorisedAccessException();
    } else {
        final BatchClass batchClass = batchClassService.getBatchClassByIdentifier(identifier);
        if (batchClass != null) {
            if (isBatchClassViewable) {
                final List<BatchClassModule> modules = batchClass.getBatchClassModules();
                for (final BatchClassModule bcm : modules) {
                    final Module module = new Module();
                    module.setModuleName(bcm.getModule().getName());
                    module.setWorkflowName(bcm.getWorkflowName());
                    modulesSchema.getModule().add(module);
                }
            } else {
                throw new UnAuthorisedAccessException();
            }
        } else {
            throw new ValidationException(WebServiceConstants.INVALID_BATCH_CLASS_ID_MESSAGE + identifier,
                    createUnprocessableEntityRestError(WebServiceConstants.INVALID_BATCH_CLASS_ID_MESSAGE,
                            WebServiceConstants.INVALID_BATCH_CLASS_ID_CODE));
        }
    }
    return modulesSchema;
}