Example usage for java.lang NumberFormatException getMessage

List of usage examples for java.lang NumberFormatException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.ephesoft.dcma.gwt.core.server.BatchClassUtil.java

public static void mergeDocumentTypeFieldFromDTO(TableInfo tableInfo, TableInfoDTO tableInfoDTO) {
    // merge the field types edited by user.
    if (tableInfoDTO.getRuleOperator() != null) {
        tableInfo.setRuleOperator(tableInfoDTO.getRuleOperator());
    }/*from   ww w .ja  v a2s  .co  m*/
    tableInfo.setRemoveInvalidRows(tableInfoDTO.isRemoveInvalidRows());
    tableInfo.setName(tableInfoDTO.getName());
    tableInfo.setDisplayImage(tableInfoDTO.getDisplayImage());
    tableInfo.setCurrencyCode(
            CurrencyCode.getCurrencyCodeForRepresentationValue(tableInfoDTO.getCurrencyCode()));

    if (tableInfoDTO.getNumberOfRows() != null && !tableInfoDTO.getNumberOfRows().isEmpty()) {
        tableInfo.setNumberOfRows(Integer.parseInt(tableInfoDTO.getNumberOfRows()));
    } else {
        tableInfo.setNumberOfRows(CoreCommonConstants.DEFAULT_NO_OF_ROWS);
    }

    if (tableInfoDTO.getTableColumnInfoList(true) != null) {
        for (TableColumnInfoDTO tableColumnInfoDTO : tableInfoDTO.getTableColumnInfoList(true)) {
            if (tableColumnInfoDTO.isDeleted()) {

                try {
                    long tableColumnInfoId = Long.parseLong(tableColumnInfoDTO.getIdentifier());
                    tableInfo.removeTableColumnsInfoById(tableColumnInfoId);
                } catch (NumberFormatException e) {
                    LOGGER.error(BatchConstants.ERROR_CONVERT_NUMBER + e.getMessage());
                }
            } else if (tableColumnInfoDTO.isNew()) {
                TableColumnsInfo tabColumnsInfo = new TableColumnsInfo();
                tableColumnInfoDTO.setNew(false);
                mergeTableColumnInfoFromDTO(tabColumnsInfo, tableColumnInfoDTO);
                tableInfo.addTableColumnInfo(tabColumnsInfo);
            } else {
                TableColumnsInfo tabColumnsInfo = tableInfo
                        .getTableColumnInfobyIdentifier(tableColumnInfoDTO.getIdentifier());
                mergeTableColumnInfoFromDTO(tabColumnsInfo, tableColumnInfoDTO);
            }
        }
    }
    if (tableInfoDTO.getRuleInfoDTOs(true) != null) {
        for (RuleInfoDTO ruleInfoDTO : tableInfoDTO.getRuleInfoDTOs(true)) {
            if (ruleInfoDTO.isDeleted()) {

                try {
                    long ruleInfoId = Long.parseLong(ruleInfoDTO.getIdentifier());
                    tableInfo.removeTableRulesInfoById(ruleInfoId);
                } catch (NumberFormatException e) {
                    LOGGER.error(BatchConstants.ERROR_CONVERT_NUMBER + e.getMessage());
                }
            } else if (ruleInfoDTO.isNew()) {
                TableRuleInfo tabRuleInfo = new TableRuleInfo();
                ruleInfoDTO.setNew(false);
                mergeRuleInfoFromDTO(tabRuleInfo, ruleInfoDTO);
                tableInfo.addTableRuleInfo(tabRuleInfo);
            } else {
                TableRuleInfo tabRuleInfo = tableInfo.getTableRuleInfobyIdentifier(ruleInfoDTO.getIdentifier());
                mergeRuleInfoFromDTO(tabRuleInfo, ruleInfoDTO);
            }
        }
    }

    // Merging table extraction rules and table column extraction rules from table info DTO to table info object.
    final List<TableExtractionRuleDTO> tableExtractionRuleDTOs = tableInfoDTO.getTableExtractionRuleDTOs(true);
    if (!CollectionUtil.isEmpty(tableExtractionRuleDTOs)) {
        for (TableExtractionRuleDTO tableExtractionRuleDTO : tableExtractionRuleDTOs) {
            if (null != tableExtractionRuleDTO) {
                if (tableExtractionRuleDTO.isDeleted()) {
                    try {
                        long tableExtractionRuleId = Long.parseLong(tableExtractionRuleDTO.getIdentifier());
                        tableInfo.removeTableExtractionRuleById(tableExtractionRuleId);
                    } catch (final NumberFormatException numberFormatException) {
                        LOGGER.error(EphesoftStringUtil.concatenate(BatchConstants.ERROR_CONVERT_NUMBER,
                                numberFormatException.getMessage()));
                    }
                } else if (tableExtractionRuleDTO.isNew()) {
                    final TableExtractionRule tableExtractionRule = new TableExtractionRule();
                    tableExtractionRuleDTO.setNew(false);
                    tableExtractionRule.setTableInfo(tableInfo);
                    mergeTableExtractionRuleFromDTO(tableExtractionRule, tableExtractionRuleDTO);
                    tableInfo.addTableExtractionRule(tableExtractionRule);
                } else {
                    final TableExtractionRule tableExtractionRule = tableInfo
                            .getTableExtractionRuleByIdentifier(tableExtractionRuleDTO.getIdentifier());
                    mergeTableExtractionRuleFromDTO(tableExtractionRule, tableExtractionRuleDTO);
                }
            }
        }
    }

}

From source file:de.sub.goobi.forms.ProzessverwaltungForm.java

/**
 * Anzeige der Sammelbnde filtern./*from w  ww  .  j  a va 2 s  . com*/
 */
public String FilterAlleStart() {
    this.statisticsManager = null;
    this.myAnzahlList = null;
    /*
     * Filter fr die Auflistung anwenden
     */
    try {

        // ... Criteria will persist, because it gets passed on to the
        // PageObject
        // but in order to use the extended functions of the
        // UserDefinedFilter
        // for statistics, we will have to hold a reference to the instance
        // of UserDefinedFilter
        this.myFilteredDataSource = new UserDefinedFilter(this.filter);

        // set observable to replace helper.setMessage
        this.myFilteredDataSource.getObservable().addObserver(new Helper().createObserver());

        // // calling the criteria as the result of the filter
        Criteria crit = this.myFilteredDataSource.getCriteria();

        // first manipulation of the created criteria

        /* nur die Vorlagen oder alles */
        if (this.modusAnzeige.equals("vorlagen")) {
            crit.add(Restrictions.eq("template", Boolean.TRUE));
        } else {
            crit.add(Restrictions.eq("template", Boolean.FALSE));
        }
        /* alle Suchparameter miteinander kombinieren */
        if (!this.showClosedProcesses && !this.modusAnzeige.equals("vorlagen")) {
            crit.add(Restrictions.not(Restrictions.eq("sortHelperStatus", "100000000")));
        }

        if (!this.showArchivedProjects) {
            crit.createCriteria("project", "proj");
            crit.add(Restrictions.not(Restrictions.eq("proj.projectIsArchived", true)));
            sortList(crit, false);
        } else {
            /* noch sortieren */
            sortList(crit, true);
        }

        this.page = new Page(crit, 0);
    } catch (HibernateException he) {
        Helper.setFehlerMeldung("fehlerBeimEinlesen", he.getMessage());
        return "";
    } catch (NumberFormatException ne) {
        Helper.setFehlerMeldung("Falsche Suchparameter angegeben", ne.getMessage());
        return "";
    } catch (UnsupportedOperationException e) {
        logger.error(e);
    }

    return "ProzessverwaltungAlle";
}

From source file:com.ephesoft.dcma.gwt.core.server.BatchClassUtil.java

public static void mergeBatchClassModuleFromDTO(BatchClassModule batchClassModule,
        BatchClassModuleDTO batchClassModuleDTO, BatchClassPluginConfigService batchClassPluginConfigService,
        BatchClassPluginService batchClassPluginService, PluginConfigService pluginConfigService) {

    batchClassModule.setRemoteURL(batchClassModuleDTO.getRemoteURL());
    batchClassModule.setRemoteBatchClassIdentifier(batchClassModuleDTO.getRemoteBatchClassIdentifier());
    batchClassModule.setOrderNumber(batchClassModuleDTO.getOrderNumber());

    // New BCMDTO
    if (batchClassModuleDTO.isNew()) {
        batchClassModule.setId(0);/*from  www  .ja v a  2 s  . c o m*/
        batchClassModule.setWorkflowName(batchClassModuleDTO.getWorkflowName());
        Module module = new Module();

        try {
            Long moduleID = Long.valueOf(batchClassModuleDTO.getModule().getIdentifier());
            module.setId(moduleID);
        } catch (NumberFormatException e) {
            LOGGER.error(BatchConstants.ERROR_CONVERT_NUMBER + e.getMessage());
        }
        module.setName(batchClassModuleDTO.getModule().getName());
        module.setDescription(batchClassModuleDTO.getModule().getDescription());
        module.setVersion(batchClassModuleDTO.getModule().getVersion());
        batchClassModule.setModule(module);
        // if (!batchClassModuleDTO.getWorkflowName().contains(batchClassModuleDTO.getBatchClass().getIdentifier())) {
        // batchClassModule.setWorkflowName(batchClassModuleDTO.getWorkflowName() + UNDERSCORE
        // + batchClassModuleDTO.getBatchClass().getIdentifier());
        // }
    } else {

        try {
            long batchClassModuleId = Long.valueOf(batchClassModuleDTO.getIdentifier());
            batchClassModule.setId(batchClassModuleId);
        } catch (NumberFormatException e) {
            LOGGER.error(BatchConstants.ERROR_CONVERT_NUMBER + e.getMessage());
        }
        batchClassModule.setWorkflowName(batchClassModuleDTO.getWorkflowName());
    }

    List<BatchClassPluginDTO> allPluginDTOs = new ArrayList<BatchClassPluginDTO>(
            batchClassModuleDTO.getBatchClassPlugins(true));
    List<BatchClassPluginDTO> removedPluginDTOs = new ArrayList<BatchClassPluginDTO>();

    for (BatchClassPluginDTO pluginDTO : allPluginDTOs) {

        if (batchClassModuleDTO.isNew()) {
            pluginDTO.setNew(true);
        }

        if (pluginDTO.isDeleted() && !pluginDTO.isNew()) {
            try {
                long batchClassPluginId = Long.valueOf(pluginDTO.getIdentifier());
                batchClassModule.removeBatchClassPluginById(batchClassPluginId);
            } catch (NumberFormatException e) {
                LOGGER.error(BatchConstants.ERROR_CONVERT_NUMBER + e.getMessage());
            }
        } else if (pluginDTO.isNew() && !pluginDTO.isDeleted()) {
            BatchClassPlugin batchClassPlugin = new BatchClassPlugin();
            batchClassPlugin.setBatchClassModule(batchClassModule);
            batchClassPlugin.setId(0);
            batchClassPlugin.setOrderNumber(pluginDTO.getOrderNumber());

            Plugin plugin = new Plugin();

            try {

                Long pluginId = Long.valueOf(pluginDTO.getPlugin().getIdentifier());
                plugin.setId(pluginId);
            } catch (NumberFormatException e) {
                LOGGER.error(BatchConstants.ERROR_CONVERT_NUMBER + e.getMessage());
            }
            plugin.setPluginName(pluginDTO.getPlugin().getPluginName());

            batchClassPlugin.setPlugin(plugin);

            mergeBatchClassPluginFromDTO(batchClassPlugin, pluginDTO, batchClassPluginConfigService,
                    batchClassPluginService, pluginConfigService);
            if (batchClassModule.getBatchClassPlugins() == null) {
                batchClassModule.setBatchClassPlugins(new ArrayList<BatchClassPlugin>(0));
                batchClassModule.getBatchClassPlugins().add(batchClassPlugin);
            } else {
                batchClassModule.getBatchClassPlugins().add(batchClassPlugin);
            }
        } else if (!pluginDTO.isDeleted() && !pluginDTO.isNew()) {

            try {
                long batchClassPluginId = Long.valueOf(pluginDTO.getIdentifier());

                BatchClassPlugin batchClassPlugin = batchClassModule
                        .getBatchClassPluginById(batchClassPluginId);
                mergeBatchClassPluginFromDTO(batchClassPlugin, pluginDTO, batchClassPluginConfigService,
                        batchClassPluginService, pluginConfigService);
            } catch (NumberFormatException e) {
                LOGGER.error(BatchConstants.ERROR_CONVERT_NUMBER + e.getMessage());
            }
        } else {
            removedPluginDTOs.add(pluginDTO);
        }

    }

    allPluginDTOs.removeAll(removedPluginDTOs);

}

From source file:de.thorstenberger.taskmodel.view.CommitAction.java

@Override
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    ActionMessages msgs = new ActionMessages();
    ActionMessages errors = new ActionMessages();

    int page;//from  w w  w.  ja v a2s .c o  m
    long id;
    try {
        id = Long.parseLong(request.getParameter("id"));
        page = Integer.parseInt(request.getParameter("page") == null ? "1" : request.getParameter("page"));
    } catch (NumberFormatException e) {
        errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("invalid.parameter"));
        saveErrors(request, errors);
        return mapping.findForward("error");
    }

    TaskModelViewDelegateObject delegateObject = (TaskModelViewDelegateObject) TaskModelViewDelegate
            .getDelegateObject(request.getSession().getId(), id);
    if (delegateObject == null) {
        errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("no.session"));
        saveErrors(request, errors);
        return mapping.findForward("error");
    }
    request.setAttribute("ReturnURL", delegateObject.getReturnURL());

    ComplexTasklet ct;

    try {
        ct = (ComplexTasklet) delegateObject.getTasklet();
    } catch (ClassCastException e1) {
        errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("only.complexTasks.supported"));
        saveErrors(request, errors);
        return mapping.findForward("error");
    } catch (TaskApiException e3) {
        errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("misc.error", e3.getMessage()));
        saveErrors(request, errors);
        log.error(e3);
        return mapping.findForward("error");
    }

    SavePageAction.logPostData(request, ct);

    TaskDef_Complex taskDef;
    try {
        taskDef = (TaskDef_Complex) delegateObject.getTaskDef();
    } catch (ClassCastException e2) {
        errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("only.complexTasks.supported"));
        saveErrors(request, errors);
        return mapping.findForward("error");
    } catch (TaskApiException e3) {
        errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("misc.error", e3.getMessage()));
        saveErrors(request, errors);
        log.error(e3);
        return mapping.findForward("error");
    }

    if (!taskDef.isActive()) {
        errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("task.inactive"));
        saveErrors(request, errors);
        return mapping.findForward("error");
    }

    // finally, commit the whole Task
    try {

        ct.submit();

    } catch (IllegalStateException e) {
        errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(e.getMessage()));
        saveErrors(request, errors);
        log.info(e);
        return mapping.findForward("error");
    }

    return mapping.findForward("success");
}

From source file:com.ephesoft.dcma.gwt.core.server.BatchClassUtil.java

public static void mergeBatchClassPluginFromDTO(BatchClassPlugin batchClassPlugin,
        BatchClassPluginDTO pluginDTO, BatchClassPluginConfigService batchClassPluginConfigService,
        BatchClassPluginService batchClassPluginService, PluginConfigService pluginConfigService) {
    Map<String, BatchClassPluginConfig> batchClassPluginConfigMap = new HashMap<String, BatchClassPluginConfig>();
    Map<String, BatchClassDynamicPluginConfig> batchClassDynamicPluginConfigMap = new HashMap<String, BatchClassDynamicPluginConfig>();

    Collection<BatchClassPluginConfigDTO> pluginConfigDTOs = pluginDTO.getBatchClassPluginConfigs();

    Collection<BatchClassDynamicPluginConfigDTO> dynamicPluginConfigDTOs = pluginDTO
            .getBatchClassDynamicPluginConfigs();

    batchClassPlugin.setOrderNumber(pluginDTO.getOrderNumber());
    // New module is added
    if (batchClassPlugin.getBatchClassPluginConfigs() == null) {
        batchClassPlugin.setBatchClassPluginConfigs(new ArrayList<BatchClassPluginConfig>(0));
        batchClassPlugin.setBatchClassDynamicPluginConfigs(new ArrayList<BatchClassDynamicPluginConfig>());

    }/*ww  w. j  a  v a2 s . c  o m*/
    if (batchClassPlugin.getBatchClassDynamicPluginConfigs() == null) {
        batchClassPlugin.setBatchClassDynamicPluginConfigs(new ArrayList<BatchClassDynamicPluginConfig>());
    }

    if (pluginDTO.isNew()) {
        setBatchClassModuleDTOPluginConfigList(batchClassPlugin, pluginDTO, batchClassPluginConfigService,
                batchClassPluginService, pluginConfigService);
        for (BatchClassPluginConfigDTO batchClassPluginConfigDTO : pluginDTO.getBatchClassPluginConfigs()) {
            BatchClassPluginConfig batchClassPluginConfig = new BatchClassPluginConfig();
            PluginConfig pluginConfig = new PluginConfig();
            pluginConfig = mergePluginConfiguration(batchClassPluginConfigDTO);
            batchClassPluginConfig.setPluginConfig(pluginConfig);
            refreshBatchClassPluginConfigFromDTO(batchClassPluginConfig, batchClassPluginConfigDTO);
            batchClassPlugin.addBatchClassPluginConfig(batchClassPluginConfig);
        }

    }
    if (!pluginDTO.isNew()) {
        for (BatchClassPluginConfigDTO batchClassPluginConfigDTO : pluginConfigDTOs) {

            BatchClassPluginConfig batchClassPluginConfig = null;

            try {
                long batchClassPluginConfigId = Long.valueOf(batchClassPluginConfigDTO.getIdentifier());
                batchClassPluginConfig = batchClassPlugin
                        .getBatchClassPluginConfigById(batchClassPluginConfigId);
            } catch (NumberFormatException e) {
                LOGGER.error(BatchConstants.ERROR_CONVERT_NUMBER + e.getMessage());
            }
            if (batchClassPluginConfig == null) {
                batchClassPluginConfig = new BatchClassPluginConfig();
                PluginConfig pluginConfig = new PluginConfig();
                try {
                    long pluginConfigId = Long
                            .valueOf(batchClassPluginConfigDTO.getPluginConfig().getIdentifier());
                    pluginConfig.setId(pluginConfigId);
                } catch (NumberFormatException e) {
                    LOGGER.error(BatchConstants.ERROR_CONVERT_NUMBER + e.getMessage());
                }
                pluginConfig.setMultiValue(batchClassPluginConfigDTO.isMultivalue());
                pluginConfig.setMandatory(batchClassPluginConfigDTO.isMandatory());
                // pluginConfig.setDataType(batchClassPluginConfigDTO.getDataType());

                batchClassPluginConfig.setBatchClassPlugin(batchClassPlugin);
                batchClassPluginConfig.setPluginConfig(pluginConfig);
            }
            refreshBatchClassPluginConfigFromDTO(batchClassPluginConfig, batchClassPluginConfigDTO);
            batchClassPlugin.addBatchClassPluginConfig(batchClassPluginConfig);

            if (batchClassPluginConfigDTO.getKvPageProcessDTOs(true) != null) {
                for (KVPageProcessDTO kvPageProcessDTO : batchClassPluginConfigDTO.getKvPageProcessDTOs(true)) {
                    if (kvPageProcessDTO.getIsDeleted()) {
                        batchClassPluginConfig.removeKvPageProcessById(kvPageProcessDTO.getIdentifier());
                    } else if (kvPageProcessDTO.getIsNew()) {
                        KVPageProcess kvPageProcess = new KVPageProcess();
                        kvPageProcessDTO.setIsNew(false);
                        kvPageProcessDTO.setIdentifier(0L);
                        kvPageProcess.setBatchClassPluginConfig(batchClassPluginConfig);
                        mergeKvPageProcessFromDTO(kvPageProcess, kvPageProcessDTO);
                        batchClassPluginConfig.addKVPageProcess(kvPageProcess);
                    } else {
                        KVPageProcess kvPageProcess = batchClassPluginConfig
                                .getKVPageProcessbyIdentifier(String.valueOf(kvPageProcessDTO.getIdentifier()));
                        mergeKvPageProcessFromDTO(kvPageProcess, kvPageProcessDTO);
                    }
                }
            }

            batchClassPluginConfigMap.put(batchClassPluginConfigDTO.getIdentifier(), batchClassPluginConfig);
        }

        for (BatchClassDynamicPluginConfigDTO batchClassDynamicPluginConfigDTO : dynamicPluginConfigDTOs) {

            BatchClassDynamicPluginConfig batchClassDynamicPluginConfig = null;
            try {
                long batchClassDynamicPluginConfigId = Long
                        .valueOf(batchClassDynamicPluginConfigDTO.getIdentifier());
                batchClassDynamicPluginConfig = batchClassPlugin
                        .getBatchClassDynamicPluginConfigById(batchClassDynamicPluginConfigId);
            } catch (NumberFormatException e) {
                LOGGER.error(BatchConstants.ERROR_CONVERT_NUMBER + e.getMessage());
            }
            if (batchClassDynamicPluginConfig == null) {
                batchClassDynamicPluginConfig = new BatchClassDynamicPluginConfig();
                batchClassDynamicPluginConfig.setId(0);
            }
            refreshBatchClassDynamicPluginConfigFromDTO(batchClassDynamicPluginConfig,
                    batchClassDynamicPluginConfigDTO);
            batchClassPlugin.addBatchClassDynamicPluginConfig(batchClassDynamicPluginConfig);
            batchClassDynamicPluginConfigMap.put(batchClassDynamicPluginConfigDTO.getIdentifier(),
                    batchClassDynamicPluginConfig);

        }

        if (batchClassPlugin.getBatchClassDynamicPluginConfigs() == null) {
            batchClassPlugin.setBatchClassDynamicPluginConfigs(new ArrayList<BatchClassDynamicPluginConfig>(0));
        }
        for (BatchClassDynamicPluginConfigDTO batchClassDynamicPluginConfigDTO : dynamicPluginConfigDTOs) {
            BatchClassDynamicPluginConfig config = batchClassDynamicPluginConfigMap
                    .get(batchClassDynamicPluginConfigDTO.getIdentifier());
            if (batchClassDynamicPluginConfigDTO.getChildren() != null
                    && !batchClassDynamicPluginConfigDTO.getChildren().isEmpty()) {
                Collection<BatchClassDynamicPluginConfigDTO> children = batchClassDynamicPluginConfigDTO
                        .getChildren();
                for (BatchClassDynamicPluginConfigDTO child : children) {
                    BatchClassDynamicPluginConfig childConfig = batchClassDynamicPluginConfigMap
                            .get(child.getIdentifier());
                    if (childConfig != null) {
                        config.addChild(childConfig);
                    }
                }
            }
        }

        for (BatchClassDynamicPluginConfigDTO parent : dynamicPluginConfigDTOs) {

            if (parent != null && parent.getChildren() != null) {
                BatchClassDynamicPluginConfig dynamicParentConfig = batchClassDynamicPluginConfigMap
                        .get(parent.getIdentifier());
                mergeDeletedDynamicConfigs(dynamicParentConfig, pluginDTO);
            }
        }
        mergeDeletedDynamicConfigs(batchClassPlugin, pluginDTO);
    } else {
        batchClassPlugin.setBatchClassDynamicPluginConfigs(new ArrayList<BatchClassDynamicPluginConfig>(0));

    }
}

From source file:org.dspace.app.webui.cris.controller.ResearcherPageDetailsController.java

@Override
public ModelAndView handleDetails(HttpServletRequest request, HttpServletResponse response) throws Exception {
    log.debug("Start handleRequest");
    Map<String, Object> model = new HashMap<String, Object>();

    Integer objectId = extractEntityId(request);
    if (objectId == -1) {
        response.sendError(HttpServletResponse.SC_NOT_FOUND, "Researcher page not found");
        return null;
    }//from  w ww  .  j  ava 2 s. c  o  m

    ResearcherPage researcher = null;
    try {

        researcher = ((ApplicationService) applicationService).get(ResearcherPage.class, objectId);

    } catch (NumberFormatException e) {
    }

    if (researcher == null) {
        response.sendError(HttpServletResponse.SC_NOT_FOUND, "Researcher page not found");
        return null;
    }

    Context context = UIUtil.obtainContext(request);
    EPerson currUser = context.getCurrentUser();

    boolean isAdmin = AuthorizeManager.isAdmin(context);

    if (isAdmin || (currUser != null
            && (researcher.getEpersonID() != null && currUser.getID() == researcher.getEpersonID()))) {
        model.put("researcher_page_menu", new Boolean(true));
        model.put("authority_key", ResearcherPageUtils.getPersistentIdentifier(researcher));

        if (isAdmin) {
            AuthorityDAO dao = AuthorityDAOFactory.getInstance(context);
            long pendingItems = dao.countIssuedItemsByAuthorityValueInAuthority(RPAuthority.RP_AUTHORITY_NAME,
                    ResearcherPageUtils.getPersistentIdentifier(researcher));
            model.put("pendingItems", new Long(pendingItems));
        }
    }

    else if ((researcher.getStatus() == null || researcher.getStatus().booleanValue() == false)) {
        if (context.getCurrentUser() != null || Authenticate.startAuthentication(context, request, response)) {
            // Log the error
            log.info(LogManager.getHeader(context, "authorize_error",
                    "Only system administrator can access to disabled researcher page"));

            JSPManager.showAuthorizeError(request, response,
                    new AuthorizeException("Only system administrator can access to disabled researcher page"));
        }
        return null;
    }

    if (subscribeService != null) {
        boolean subscribed = subscribeService.isSubscribed(currUser, researcher);
        model.put("subscribed", subscribed);
        EPerson eperson = EPerson.findByNetid(context, researcher.getSourceID());
        if (eperson != null) {
            model.put("subscriptions", subscribeService.getSubscriptions(eperson));
        }
    }

    ModelAndView mvc = null;

    try {
        mvc = super.handleDetails(request, response);
    } catch (RuntimeException e) {
        log.error(e.getMessage(), e);
        return null;
    }

    mvc.getModel().putAll(model);
    mvc.getModel().put("researcher", researcher);
    mvc.getModel().put("exportscitations", ConfigurationManager.getProperty("exportcitation.options"));
    mvc.getModel().put("showStatsOnlyAdmin",
            ConfigurationManager.getBooleanProperty(SolrLogger.CFG_STAT_MODULE, "authorization.admin"));

    // Fire usage event.
    request.setAttribute("sectionid", StatsConfig.DETAILS_SECTION);
    new DSpace().getEventService()
            .fireEvent(new UsageEvent(UsageEvent.Action.VIEW, request, context, researcher));

    log.debug("end servlet handleRequest");

    return mvc;
}

From source file:com.ephesoft.dcma.gwt.core.server.BatchClassUtil.java

/**
 * /*from   ww w . ja  v a2  s  .  com*/
 * @param batchClass the batch class that is to be merged
 * @param batchClassDTO the batchClassDTO which has to be replicated on the batch class
 * @param batchClassPluginConfigService
 * @param batchClassPluginService
 * @param superAdminGroupsSet
 * @return a list of document type names that have been deleted.
 */

public static List<String> mergeBatchClassFromDTO(BatchClass batchClass, BatchClassDTO batchClassDTO,
        Set<String> groupNameSet, BatchClassPluginConfigService batchClassPluginConfigService,
        BatchClassPluginService batchClassPluginService, PluginConfigService pluginConfigService,
        List<ScannerMasterConfiguration> scannerMasterConfigs, Set<String> superAdminGroupsSet) {
    List<String> docTypeNameList = null;
    int priority = Integer.parseInt(batchClassDTO.getPriority());
    batchClass.setPriority(priority);
    batchClass.setDescription(batchClassDTO.getDescription());
    batchClass.setName(batchClassDTO.getName());
    batchClass.setLastModifiedBy(batchClass.getCurrentUser());
    updateRevisionNumber(batchClass);

    batchClassDTO.setVersion(batchClass.getVersion());
    batchClass.setDeleted(batchClassDTO.isDeleted());

    List<BatchClassModuleDTO> allBatchClassModuleDTOs = new ArrayList<BatchClassModuleDTO>(
            batchClassDTO.getModules(true));
    List<BatchClassModuleDTO> removedBatchClassModuleDTOs = new ArrayList<BatchClassModuleDTO>();

    for (BatchClassModuleDTO moduleDTO : allBatchClassModuleDTOs) {

        if (moduleDTO.isDeleted() && !moduleDTO.isNew()) {
            batchClass.removeModuleByIdentifier(moduleDTO.getIdentifier());
        } else if (moduleDTO.isNew() && !moduleDTO.isDeleted()) {
            BatchClassModule batchClassModule = new BatchClassModule();
            batchClassModule.setBatchClass(batchClass);
            mergeBatchClassModuleFromDTO(batchClassModule, moduleDTO, batchClassPluginConfigService,
                    batchClassPluginService, pluginConfigService);
            moduleDTO.setNew(false);
            batchClass.addModule(batchClassModule);

        } else if (!moduleDTO.isNew() && !moduleDTO.isDeleted()) {
            BatchClassModule batchClassModule = null;
            try {
                long moduleIdentifier = Long.valueOf(moduleDTO.getIdentifier());
                batchClassModule = batchClass.getBatchClassModuleById(moduleIdentifier);
                mergeBatchClassModuleFromDTO(batchClassModule, moduleDTO, batchClassPluginConfigService,
                        batchClassPluginService, pluginConfigService);
            } catch (NumberFormatException e) {
                LOGGER.error(BatchConstants.ERROR_CONVERT_NUMBER + e.getMessage());
            }

        } else {
            removedBatchClassModuleDTOs.add(moduleDTO);
        }

    }
    allBatchClassModuleDTOs.removeAll(removedBatchClassModuleDTOs);
    for (DocumentTypeDTO documentTypeDTO : batchClassDTO.getDocuments(true)) {
        if (documentTypeDTO.isDeleted()) {
            batchClass.removeDocumentTypeByIdentifier(documentTypeDTO.getIdentifier());
            if (null == docTypeNameList) {
                docTypeNameList = new ArrayList<String>();
                docTypeNameList.add(documentTypeDTO.getName());
            } else {
                docTypeNameList.add(documentTypeDTO.getName());
            }
            removeFuzzyDynamicConfigs(documentTypeDTO.getDescription(), batchClass,
                    CoreCommonConstants.DOCUMENT_TYPE);
        } else if (documentTypeDTO.isNew()) {
            DocumentType documentType = new DocumentType();
            documentTypeDTO.setNew(false);
            mergeBatchClassDocumentFromDTO(documentType, documentTypeDTO);
            addAutoGeneratedPageType(documentType);
            batchClass.addDocumentType(documentType);
            documentType.setBatchClass(batchClass);
        } else {
            DocumentType documentType = batchClass.getDocumentTypeByIdentifier(documentTypeDTO.getIdentifier());
            mergeBatchClassDocumentFromDTO(documentType, documentTypeDTO);
        }
    }
    for (EmailConfigurationDTO emailConfigurationDTO : batchClassDTO.getEmailConfiguration(true)) {
        if (emailConfigurationDTO.isDeleted()) {
            batchClass.removeEmailConfigurationByIdentifier(emailConfigurationDTO.getIdentifier());
        } else if (emailConfigurationDTO.isNew()) {
            BatchClassEmailConfiguration emailConfiguration = new BatchClassEmailConfiguration();
            emailConfigurationDTO.setNew(false);
            mergeBatchClassEmailFromDTO(emailConfiguration, emailConfigurationDTO);
            batchClass.addEmailConfiguration(emailConfiguration);
        } else {
            BatchClassEmailConfiguration batchClassEmailConfiguration = batchClass
                    .getEmailConfigurationByIdentifier(emailConfigurationDTO.getIdentifier());
            mergeBatchClassEmailFromDTO(batchClassEmailConfiguration, emailConfigurationDTO);
        }
    }

    for (CmisConfigurationDTO cmisConfigurationDTO : batchClassDTO.getCmisConfiguration(true)) {
        if (cmisConfigurationDTO.isDeleted()) {
            batchClass.removeCmisConfigurationByIdentifier(cmisConfigurationDTO.getIdentifier());
        } else if (cmisConfigurationDTO.isNew()) {
            BatchClassCmisConfiguration cmisConfiguration = new BatchClassCmisConfiguration();
            cmisConfigurationDTO.setNew(false);
            mergeBatchClassCmisFromDTO(cmisConfiguration, cmisConfigurationDTO);
        } else {
            BatchClassCmisConfiguration batchClassCmisConfiguration = batchClass
                    .getCmisConfigurationByIdentifier(cmisConfigurationDTO.getIdentifier());
            mergeBatchClassCmisFromDTO(batchClassCmisConfiguration, cmisConfigurationDTO);
        }
    }

    for (WebScannerConfigurationDTO configurationDTO : batchClassDTO.getScannerConfiguration(true)) {
        if (configurationDTO.getParent() == null) {
            // update only the parent configs here
            if (configurationDTO.isDeleted()) {
                batchClass.removeScannerConfigIdentifier(configurationDTO.getIdentifier());
            } else if (configurationDTO.isNew()) {
                BatchClassScannerConfiguration config = new BatchClassScannerConfiguration();
                config.setBatchClass(batchClass);
                config.setParent(null);

                configurationDTO.setNew(false);
                mergeBatchClassScannerFromDTO(config, configurationDTO, batchClass, scannerMasterConfigs);
            } else {
                BatchClassScannerConfiguration config = batchClass
                        .getScannerConfigByIdentifier(configurationDTO.getIdentifier());
                mergeBatchClassScannerFromDTO(config, configurationDTO, batchClass, scannerMasterConfigs);
            }
        }
    }

    for (BatchClassFieldDTO batchClassFieldDTO : batchClassDTO.getBatchClassField(true)) {
        if (batchClassFieldDTO.isDeleted()) {
            batchClass.removeBatchClassFieldByIdentifier(batchClassFieldDTO.getIdentifier());
        } else if (batchClassFieldDTO.isNew()) {
            BatchClassField batchClassField = new BatchClassField();
            batchClassFieldDTO.setNew(false);
            mergeBatchClassFieldFromDTO(batchClassField, batchClassFieldDTO);
            batchClass.addBatchClassField(batchClassField);
        } else {
            BatchClassField batchClassField = batchClass
                    .getBatchClassFieldByIdentifier(batchClassFieldDTO.getIdentifier());
            mergeBatchClassFieldFromDTO(batchClassField, batchClassFieldDTO);
        }
    }

    List<BatchClassGroups> assignedRoles = batchClass.getAssignedGroups();
    if (assignedRoles == null) {
        assignedRoles = new ArrayList<BatchClassGroups>();
    }
    assignedRoles.clear();
    if (null != groupNameSet && !groupNameSet.isEmpty()) {
        List<String> addedRoles = new ArrayList<String>();
        for (RoleDTO roleDTO : batchClassDTO.getAssignedRole()) {
            for (String group : groupNameSet) {
                if (!addedRoles.contains(group)
                        && (superAdminGroupsSet.contains(group) || roleDTO.getName().equals(group))) {
                    BatchClassGroups batchClassGroups = new BatchClassGroups();
                    batchClassGroups.setGroupName(group);
                    addedRoles.add(group);
                    batchClassGroups.setBatchClass(batchClass);
                    assignedRoles.add(batchClassGroups);
                }
            }
        }
    }

    // This is when super-admin has unmapped all roles from batch class but super-admin role needs to persist
    if (assignedRoles.isEmpty() && batchClassDTO.getAssignedRole().isEmpty()) {
        for (String group : groupNameSet) {
            if (superAdminGroupsSet.contains(group)) {
                BatchClassGroups batchClassGroups = new BatchClassGroups();
                batchClassGroups.setGroupName(group);
                batchClassGroups.setBatchClass(batchClass);
                assignedRoles.add(batchClassGroups);
            }
        }
    }
    batchClass.setAssignedGroups(assignedRoles);

    return docTypeNameList;
}

From source file:com.microsoft.tfs.core.httpclient.HttpMethodBase.java

/**
 * Return the length (in bytes) of the response body, as specified in a
 * <tt>Content-Length</tt> header.
 *
 * <p>/*from  w  w w. jav  a2s.c  o m*/
 * Return <tt>-1</tt> when the content-length is unknown.
 * </p>
 *
 * @return content length, if <tt>Content-Length</tt> header is available.
 *         <tt>0</tt> indicates that the request has no body. If
 *         <tt>Content-Length</tt> header is not present, the method returns
 *         <tt>-1</tt>.
 */
public long getResponseContentLength() {
    final Header[] headers = getResponseHeaderGroup().getHeaders("Content-Length");
    if (headers.length == 0) {
        return -1;
    }
    if (headers.length > 1) {
        LOG.warn("Multiple content-length headers detected");
    }
    for (int i = headers.length - 1; i >= 0; i--) {
        final Header header = headers[i];
        try {
            return Long.parseLong(header.getValue());
        } catch (final NumberFormatException e) {
            if (LOG.isWarnEnabled()) {
                LOG.warn("Invalid content-length value: " + e.getMessage());
            }
        }
        // See if we can have better luck with another header, if present
    }
    return -1;
}

From source file:com.virtusa.isq.rft.runtime.RFTCommandBase.java

/**
 * Check store value type.//from   ww  w  .  j a  v  a  2s. c  o  m
 * 
 * @param type
 *            the type
 * @param value
 *            the value
 */
private void checkStoreValueType(final String type, final String value) {
    try {
        if ("Int".equalsIgnoreCase(type)) {
            Integer.parseInt(value);
        } else if ("Boolean".equalsIgnoreCase(type)) {
            if ("true".equalsIgnoreCase(value) || "false".equalsIgnoreCase(value)) {
                Boolean.parseBoolean(value);
            } else {
                throw new IllegalArgumentException("Cannot convert to boolean value " + value);
            }
        } else if ("Float".equalsIgnoreCase(type)) {
            Float.parseFloat(value);
        }
    } catch (NumberFormatException e) {
        throw new IllegalArgumentException(e.getMessage(), e);
    }
}

From source file:femr.business.services.system.SearchService.java

/**
 * {@inheritDoc}//from   w ww  .  j  a  v  a 2  s  .c o  m
 */
@Override
public ServiceResponse<List<PatientItem>> retrievePatientsFromQueryString(String patientSearchQuery) {
    ServiceResponse<List<PatientItem>> response = new ServiceResponse<>();
    if (StringUtils.isNullOrWhiteSpace(patientSearchQuery)) {
        response.addError("", "bad parameters");
        return response;
    }

    String[] words = patientSearchQuery.trim().split(" ");
    Integer id = null;
    String firstName = null;
    String lastName = null;
    String phoneNumber = null;
    if (words.length == 0) {
        //nothing was in the query
        response.addError("", "query string empty");
        return response;
    } else if (words.length == 1) {
        //could be an ID, name, or phone number
        try {
            //see if it is a number
            if (isNumeric(words[0]) && words[0].length() > 5)
                phoneNumber = words[0];
            else
                id = Integer.parseInt(words[0]);
        } catch (NumberFormatException ex) {
            //see if it it a string
            firstName = words[0];
        }
    } else if (words.length == 2) {
        firstName = words[0];
        lastName = words[1];
    } else {
        response.addError("", "too many words in query string");
        return response;
    }

    List<? extends IPatient> patients;

    try {
        //Build the Query
        //TODO: filter these by the current country of the team
        if (id != null) {
            //if we have an id, that is all we need.
            //this is the most ideal scenario
            IPatient patient = patientRepository.retrievePatientById(id);
            List<IPatient> iPatients = new ArrayList<>();
            iPatients.add(patient);
            patients = iPatients;
        } else if (phoneNumber != null) {
            patients = patientRepository.retrievePatientsByPhoneNumber(phoneNumber);
        } else {
            patients = patientRepository.retrievePatientsByName(firstName, lastName);
        }

        //Execute the query

        List<PatientItem> patientItems = new ArrayList<>();
        for (IPatient patient : patients) {
            //patientItems.add(DomainMapper.createPatientItem(p, null, null, null, null));
            String pathToPhoto = null;
            Integer photoId = null;
            if (patient.getPhoto() != null) {
                pathToPhoto = patient.getPhoto().getFilePath();
                photoId = patient.getPhoto().getId();
            }
            patientItems.add(itemModelMapper.createPatientItem(patient.getId(), patient.getFirstName(),
                    patient.getLastName(), patient.getPhoneNumber(), patient.getCity(), patient.getAddress(),
                    patient.getUserId(), patient.getAge(), patient.getSex(), null, null, null, null,
                    pathToPhoto, photoId, null));
        }
        response.setResponseObject(patientItems);
    } catch (Exception ex) {
        response.addError("", ex.getMessage());
    }

    return response;
}