Example usage for java.lang Integer equals

List of usage examples for java.lang Integer equals

Introduction

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

Prototype

public boolean equals(Object obj) 

Source Link

Document

Compares this object to the specified object.

Usage

From source file:uk.org.rbc1b.roms.controller.volunteer.VolunteersController.java

/**
 * Produce the Volunteer Badge PDF./*  w  ww .j a v  a2  s  . c o m*/
 *
 * @param volunteerId volunteer id of for his/her badge
 * @param volunteerBadgeId volunteer badge id
 *
 * @throws IOException if image file not found
 * @return modelAndView of the VolunteerBadgePdfView
 */
@RequestMapping(value = "{volunteerId}/rbc-{volunteerBadgeId}-badge.pdf", method = RequestMethod.GET)
@PreAuthorize("hasPermission('VOLUNTEER', 'READ')")
public ModelAndView produceVolunteerBadgePdf(@PathVariable Integer volunteerId,
        @PathVariable Integer volunteerBadgeId) throws IOException {

    Volunteer volunteer = volunteerDao.findVolunteer(volunteerId, VOLUNTEER_DATA);
    if (volunteerId.equals(volunteerBadgeId)) {
        VolunteerBadgeColour badgeColour = volunteerBadgePdfModelFactory.determineBadgeColour(volunteer);
        ModelAndView modelAndView = null;

        switch (badgeColour) {
        case GREEN:
            modelAndView = new ModelAndView("greenVolunteerBadgePdfView");
            break;
        case RED:
            modelAndView = new ModelAndView("redVolunteerBadgePdfView");
            break;
        case ORANGE:
            modelAndView = new ModelAndView("orangeVolunteerBadgePdfView");
            break;
        default:
            modelAndView = new ModelAndView("greyVolunteerBadgePdfView");
            break;
        }

        String assignment = volunteerBadgePdfModelFactory.generatePrimaryAssignment(volunteer);

        modelAndView.getModelMap().addAttribute("volunteer", volunteer);
        modelAndView.getModelMap().addAttribute("assignment", assignment);

        String imageName = volunteerId + ".jpg";
        File imageFile = new File(imageDirectories.getProperty(VOLUNTEER_IMAGE_DIRECTORY_KEY) + imageName);
        byte[] bytes = FileUtils.readFileToByteArray(imageFile);
        InputStream inputStream = new ByteArrayInputStream(bytes);
        BufferedImage bufferedImage = ImageIO.read(inputStream);
        modelAndView.getModelMap().addAttribute("bufferedImage", bufferedImage);

        return modelAndView;
    } else {
        return new ModelAndView("redirect:" + VolunteerBadgePdfModelFactory.generateUri(volunteerId));
    }
}

From source file:business.services.LabRequestService.java

@SuppressWarnings("unchecked")
@Transactional// www  . ja v a 2 s.co  m
public void generateLabRequests(String processInstanceId) {
    HistoricProcessInstance instance = requestService.getProcessInstance(processInstanceId);
    Object var = instance.getProcessVariables().get("lab_request_labs");
    log.info("instance: " + instance.getId());
    if (var != null && var instanceof Collection<?>) {
        List<LabRequest> labRequests = new ArrayList<LabRequest>();
        SortedSet<Integer> labNumbers = new TreeSet<>((Collection<Integer>) var);
        Set<User> hubUsers = new HashSet<>();
        for (Integer labNumber : labNumbers) {
            Lab lab = labService.findByNumber(labNumber);
            HistoricTaskInstance task = findLabRequestTaskForLab(labNumber, instance.getId());

            // create lab requests
            LabRequest labRequest = new LabRequest();
            labRequest.setTimeCreated(new Date());
            labRequest.setLab(lab);
            labRequest.setProcessInstanceId(processInstanceId);
            labRequest.setTaskId(task.getId());
            labRequest = labRequestRepository.save(labRequest);
            // set initial status
            labRequest = updateStatus(labRequest, Status.WAITING_FOR_LAB_APPROVAL);
            labRequest.setHubAssistanceRequested(lab.isHubAssistanceEnabled());
            if (lab.isHubAssistanceEnabled()) {
                hubUsers.addAll(userService.findHubUsersForLab(lab));
            }

            ExcerptList excerptList = excerptListService.findByProcessInstanceId(processInstanceId);
            List<PathologyItem> pathologyList = new ArrayList<PathologyItem>();
            for (ExcerptEntry entry : excerptList.getEntries()) {
                if (entry.isSelected() && labNumber.equals(entry.getLabNumber())) {
                    pathologyList.add(new PathologyItem(labRequest.getId(), entry));
                }
            }
            labRequest.setPathologyList(pathologyList);
            labRequest = labRequestRepository.save(labRequest);
            log.info("Saved lab request " + labRequest.getId() + " for lab " + labNumber + " with "
                    + pathologyList.size() + " pathology items.");
            labRequests.add(labRequest);
        }
        Map<Integer, LabRequestRepresentation> representationMap = new TreeMap<>();
        // notify labs by mail
        for (LabRequest labRequest : labRequests) {
            LabRequestRepresentation representation = new LabRequestRepresentation(labRequest);
            transferLabRequestData(representation, false);
            if (representation.getLab() == null) {
                log.warn("No lab for lab request " + representation.getLabRequestCode()
                        + " while gerating lab requests.");
            } else {
                representationMap.put(representation.getLab().getNumber(), representation);
                try {
                    mailService.notifyLab(representation);
                } catch (EmailError e) {
                    log.warn("No mail sent to lab " + representation.getLab().getNumber() + " for lab request "
                            + representation.getLabRequestCode() + ". Email addresses: '"
                            + representation.getLab().getEmailAddresses() == null ? ""
                                    : String.join(", ", representation.getLab().getEmailAddresses()) + "'.");
                    // FIXME: return error messages.
                }
            }
        }
        // notify hub users by mail
        for (User u : hubUsers) {
            // build list of lab request representations for the lab requests for labs
            // associated with the hub user.
            List<LabRequestRepresentation> representations = new ArrayList<>();
            List<String> labRequestCodes = new ArrayList<>();
            for (Lab l : u.getHubLabs()) {
                if (l.isHubAssistanceEnabled()) {
                    LabRequestRepresentation representation = representationMap.get(l.getNumber());
                    if (representation != null) {
                        representations.add(representation);
                        labRequestCodes.add(representation.getLabRequestCode());
                    }
                }
            }
            String labRequestCodesString = String.join(", ", labRequestCodes);
            // send mail to hub user
            try {
                mailService.notifyHubuser(u, representations);
            } catch (EmailError e) {
                log.warn("No mail sent to hub user " + u.getUsername() + " for lab requests "
                        + labRequestCodesString + ". Email address: '" + u.getContactData() == null ? ""
                                : u.getContactData().getEmail() + "'.");
                // FIXME: return error messages.
            }
        }
    }
}

From source file:com.doculibre.constellio.wicket.panels.search.SearchFormPanel.java

@SuppressWarnings({ "rawtypes", "unchecked" })
public SearchFormPanel(String id, final IModel simpleSearchModel) {
    super(id);//  ww  w.  j av  a2s . c o m

    searchForm = new WebMarkupContainer("searchForm", new CompoundPropertyModel(simpleSearchModel));

    simpleSearchFormDiv = new WebMarkupContainer("simpleSearchFormDiv") {
        @Override
        public boolean isVisible() {
            SimpleSearch search = (SimpleSearch) simpleSearchModel.getObject();
            return search.getAdvancedSearchRule() == null;
        }
    };
    advancedSearchFormDiv = new WebMarkupContainer("advancedSearchFormDiv") {
        @Override
        public boolean isVisible() {
            SimpleSearch search = (SimpleSearch) simpleSearchModel.getObject();
            return search.getAdvancedSearchRule() != null;
        }
    };

    advancedSearchPanel = new AdvancedSearchPanel("advanceForm", simpleSearchModel);

    searchForm.add(new AttributeModifier("action", new LoadableDetachableModel() {
        @Override
        protected Object load() {
            PageFactoryPlugin pageFactoryPlugin = PluginFactory.getPlugin(PageFactoryPlugin.class);
            return urlFor(pageFactoryPlugin.getSearchResultsPage(), new PageParameters());
        }
    }));

    hiddenFields = new ListView("hiddenFields", new LoadableDetachableModel() {
        @Override
        protected Object load() {
            List<SimpleParam> hiddenParams = new ArrayList<SimpleParam>();
            HiddenSearchFormParamsPlugin hiddenSearchFormParamsPlugin = PluginFactory
                    .getPlugin(HiddenSearchFormParamsPlugin.class);

            if (hiddenSearchFormParamsPlugin != null) {
                WebRequestCycle webRequestCycle = (WebRequestCycle) RequestCycle.get();
                HttpServletRequest request = webRequestCycle.getWebRequest().getHttpServletRequest();
                SimpleParams hiddenSimpleParams = hiddenSearchFormParamsPlugin.getHiddenParams(request);
                for (String paramName : hiddenSimpleParams.keySet()) {
                    for (String paramValue : hiddenSimpleParams.getList(paramName)) {
                        hiddenParams.add(new SimpleParam(paramName, paramValue));
                    }
                }
            }

            SimpleSearch simpleSearch = (SimpleSearch) simpleSearchModel.getObject();
            SimpleSearch clone = simpleSearch.clone();

            SearchInterfaceConfigServices searchInterfaceConfigServices = ConstellioSpringUtils
                    .getSearchInterfaceConfigServices();
            SearchInterfaceConfig config = searchInterfaceConfigServices.get();
            if (!config.isKeepFacetsNewSearch()) {
                // Will be true if we just clicked on a delete link
                // on the CurrentSearchPanel
                if (!clone.isRefinedSearch()) {
                    clone.getSearchedFacets().clear();
                    clone.setCloudKeyword(null);
                }
                // We must click on a delete link on
                // CurrentSearchPanel so that it is considered
                // again as refined
                clone.setRefinedSearch(false);
            }

            clone.initFacetPages();

            List<String> ignoredParamNames = Arrays.asList("query", "searchType", "page", "singleSearchLocale");
            SimpleParams searchParams = clone.toSimpleParams();
            for (String paramName : searchParams.keySet()) {
                if (!ignoredParamNames.contains(paramName) && !paramName.contains(SearchRule.ROOT_PREFIX)) {
                    List<String> paramValues = searchParams.getList(paramName);
                    for (String paramValue : paramValues) {
                        SimpleParam hiddenParam = new SimpleParam(paramName, paramValue);
                        hiddenParams.add(hiddenParam);
                    }
                }
            }
            return hiddenParams;
        }
    }) {
        @Override
        protected void populateItem(ListItem item) {
            SimpleParam hiddenParam = (SimpleParam) item.getModelObject();
            if (hiddenParam.value != null) {
                item.add(new SimpleAttributeModifier("name", hiddenParam.name));
                item.add(new SimpleAttributeModifier("value", hiddenParam.value));
            } else {
                item.setVisible(false);
            }
        }
    };

    SearchInterfaceConfigServices searchInterfaceConfigServices = ConstellioSpringUtils
            .getSearchInterfaceConfigServices();
    SearchInterfaceConfig config = searchInterfaceConfigServices.get();

    if (config.isSimpleSearchAutocompletion()
            && ((SimpleSearch) simpleSearchModel.getObject()).getAdvancedSearchRule() == null) {
        AutoCompleteSettings settings = new AutoCompleteSettings();
        settings.setCssClassName("simpleSearchAutoCompleteChoices");
        IModel model = new Model(((SimpleSearch) simpleSearchModel.getObject()).getQuery());

        WordsAndValueAutoCompleteRenderer render = new WordsAndValueAutoCompleteRenderer() {
            @Override
            protected String getTextValue(String word, Object value) {
                return word;
            }
        };

        queryField = new TextAndValueAutoCompleteTextField("query", model, String.class, settings, render) {
            @Override
            public String getInputName() {
                return super.getId();
            }

            @Override
            protected Iterator getChoicesForWord(String word) {
                SimpleSearch simpleSearch = (SimpleSearch) simpleSearchModel.getObject();
                String collectionName = simpleSearch.getCollectionName();
                AutocompleteServices autocompleteServices = ConstellioSpringUtils.getAutocompleteServices();
                RecordCollectionServices collectionServices = ConstellioSpringUtils
                        .getRecordCollectionServices();
                RecordCollection collection = collectionServices.get(collectionName);
                List<String> suggestions = autocompleteServices.suggestSimpleSearch(word, collection,
                        getLocale());
                return suggestions.iterator();
            }

            @Override
            protected boolean supportMultipleWords() {
                return false;
            }
        };
    } else {
        queryField = new TextField("query") {
            @Override
            public String getInputName() {
                return super.getId();
            }
        };
    }

    searchTypeField = new RadioGroup("searchType") {
        @Override
        public String getInputName() {
            return super.getId();
        }
    };

    IModel languages = new LoadableDetachableModel() {
        protected Object load() {
            Set<String> localeCodes = new HashSet<String>();
            SimpleSearch simpleSearch = (SimpleSearch) simpleSearchModel.getObject();
            RecordCollectionServices recordCollectionServices = ConstellioSpringUtils
                    .getRecordCollectionServices();
            RecordCollection collection = recordCollectionServices.get(simpleSearch.getCollectionName());
            List<Locale> searchableLocales = ConstellioSpringUtils.getSearchableLocales();
            if (!collection.isOpenSearch()) {
                localeCodes.add("");
                if (!searchableLocales.isEmpty()) {
                    for (Locale searchableLocale : searchableLocales) {
                        localeCodes.add(searchableLocale.getLanguage());
                    }
                } else {
                    IndexFieldServices indexFieldServices = ConstellioSpringUtils.getIndexFieldServices();
                    IndexField languageField = indexFieldServices.get(IndexField.LANGUAGE_FIELD, collection);
                    for (String localeCode : indexFieldServices.suggestValues(languageField)) {
                        localeCodes.add(localeCode);
                    }
                }
            } else {
                localeCodes.add("");
                if (!searchableLocales.isEmpty()) {
                    for (Locale searchableLocale : searchableLocales) {
                        localeCodes.add(searchableLocale.getLanguage());
                    }
                } else {
                    for (Locale availableLocale : Locale.getAvailableLocales()) {
                        localeCodes.add(availableLocale.getLanguage());
                    }
                }
            }
            List<Locale> locales = new ArrayList<Locale>();
            for (String localeCode : localeCodes) {
                locales.add(new Locale(localeCode));
            }
            Collections.sort(locales, new Comparator<Locale>() {
                @Override
                public int compare(Locale locale1, Locale locale2) {
                    Locale locale1Display;
                    Locale locale2Display;
                    SearchInterfaceConfig config = ConstellioSpringUtils.getSearchInterfaceConfigServices()
                            .get();
                    if (config.isTranslateLanguageNames()) {
                        locale1Display = locale2Display = getLocale();
                    } else {
                        locale1Display = locale1;
                        locale2Display = locale2;
                    }

                    List<Locale> searchableLocales = ConstellioSpringUtils.getSearchableLocales();
                    if (searchableLocales.isEmpty()) {
                        searchableLocales = ConstellioSpringUtils.getSupportedLocales();
                    }

                    Integer indexOfLocale1;
                    Integer indexOfLocale2;
                    if (locale1.getLanguage().equals(getLocale().getLanguage())) {
                        indexOfLocale1 = Integer.MIN_VALUE;
                    } else {
                        indexOfLocale1 = searchableLocales.indexOf(locale1);
                    }
                    if (locale2.getLanguage().equals(getLocale().getLanguage())) {
                        indexOfLocale2 = Integer.MIN_VALUE;
                    } else {
                        indexOfLocale2 = searchableLocales.indexOf(locale2);
                    }

                    if (indexOfLocale1 == -1) {
                        indexOfLocale1 = Integer.MAX_VALUE;
                    }
                    if (indexOfLocale2 == -1) {
                        indexOfLocale2 = Integer.MAX_VALUE;
                    }
                    if (!indexOfLocale1.equals(Integer.MAX_VALUE)
                            || !indexOfLocale2.equals(Integer.MAX_VALUE)) {
                        return indexOfLocale1.compareTo(indexOfLocale2);
                    } else if (StringUtils.isBlank(locale1.getLanguage())) {
                        return Integer.MIN_VALUE;
                    } else {
                        return locale1.getDisplayLanguage(locale1Display)
                                .compareTo(locale2.getDisplayLanguage(locale2Display));
                    }
                }
            });
            return locales;
        }
    };

    IChoiceRenderer languageRenderer = new ChoiceRenderer() {
        @Override
        public Object getDisplayValue(Object object) {
            Locale locale = (Locale) object;
            String text;
            if (locale.getLanguage().isEmpty()) {
                text = (String) new StringResourceModel("all", SearchFormPanel.this, null).getObject();
            } else {
                Locale localeDisplay;
                SearchInterfaceConfig config = ConstellioSpringUtils.getSearchInterfaceConfigServices().get();
                if (config.isTranslateLanguageNames()) {
                    localeDisplay = getLocale();
                } else {
                    localeDisplay = locale;
                }
                text = StringUtils.capitalize(locale.getDisplayLanguage(localeDisplay));
            }
            return text;
        }

        @Override
        public String getIdValue(Object object, int index) {
            return ((Locale) object).getLanguage();
        }
    };

    IModel languageModel = new Model() {
        @Override
        public Object getObject() {
            SimpleSearch simpleSearch = (SimpleSearch) simpleSearchModel.getObject();
            Locale singleSearchLocale = simpleSearch.getSingleSearchLocale();
            if (singleSearchLocale == null) {
                SearchedFacet facet = simpleSearch.getSearchedFacet(IndexField.LANGUAGE_FIELD);
                List<String> values = facet == null ? new ArrayList<String>() : facet.getIncludedValues();
                singleSearchLocale = values.isEmpty() ? null : new Locale(values.get(0));
            }
            if (singleSearchLocale == null) {
                singleSearchLocale = getLocale();
            }
            return singleSearchLocale;
        }

        @Override
        public void setObject(Object object) {
            Locale singleSearchLocale = (Locale) object;
            SimpleSearch simpleSearch = (SimpleSearch) simpleSearchModel.getObject();
            simpleSearch.setSingleSearchLocale(singleSearchLocale);
        }
    };

    languageDropDown = new DropDownChoice("singleSearchLocale", languageModel, languages, languageRenderer) {
        @Override
        public String getInputName() {
            return "singleSearchLocale";
        }

        @Override
        public boolean isVisible() {
            SearchInterfaceConfigServices searchInterfaceConfigServices = ConstellioSpringUtils
                    .getSearchInterfaceConfigServices();
            SearchInterfaceConfig config = searchInterfaceConfigServices.get();
            return config.isLanguageInSearchForm();
        }

        @Override
        protected CharSequence getDefaultChoice(Object selected) {
            return "";
        };
    };

    searchButton = new Button("searchButton") {
        @Override
        public String getMarkupId() {
            return super.getId();
        }

        @Override
        public String getInputName() {
            return super.getId();
        }
    };

    String submitImgUrl = "" + urlFor(new ResourceReference(BaseConstellioPage.class, "images/ico_loupe.png"));

    add(searchForm);
    searchForm.add(simpleSearchFormDiv);
    searchForm.add(advancedSearchFormDiv);
    searchForm.add(hiddenFields);

    queryField.add(new SetFocusBehavior(queryField));

    addChoice(SimpleSearch.ALL_WORDS);
    addChoice(SimpleSearch.AT_LEAST_ONE_WORD);
    addChoice(SimpleSearch.EXACT_EXPRESSION);
    simpleSearchFormDiv.add(queryField);
    simpleSearchFormDiv.add(searchTypeField);
    simpleSearchFormDiv.add(languageDropDown);
    simpleSearchFormDiv.add(searchButton);
    advancedSearchFormDiv.add(advancedSearchPanel);
    searchButton.add(new SimpleAttributeModifier("src", submitImgUrl));
}

From source file:cz.cesnet.shongo.connector.device.CiscoMCUConnector.java

@Override
public void modifyRoomParticipant(RoomParticipant roomParticipant) throws CommandException {
    String roomId = roomParticipant.getRoomId();
    if (roomId == null) {
        throw new IllegalArgumentException("RoomId must be not null.");
    }/*from  www.  j  a v a2s.c  om*/
    String roomParticipantId = roomParticipant.getId();
    if (roomParticipantId == null) {
        throw new IllegalArgumentException("RoomParticipantId must be not null.");
    }

    Command cmd = new Command("participant.modify");
    identifyParticipant(cmd, roomId, roomParticipantId);

    // NOTE: oh yes, Cisco MCU wants "activeState" for modify while for status, it gets "currentState"...
    cmd.setParameter("operationScope", "activeState");

    // @see extractRoomParticipant for more info we we don't return participant layout
    //if (roomParticipant.getLayout() != null) {
    //    Integer layoutIndex = getLayoutIndexByRoomLayout(roomParticipant.getLayout());
    //    if (layoutIndex != null) {
    //        cmd.setParameter("cpLayout", "layout" + layoutIndex);
    //    }
    //}

    // Set parameters
    if (roomParticipant.getDisplayName() != null) {
        cmd.setParameter("displayNameOverrideValue", truncateString(roomParticipant.getDisplayName()));
        cmd.setParameter("displayNameOverrideStatus", Boolean.TRUE); // for the value to take effect
    }
    if (roomParticipant.getMicrophoneEnabled() != null) {
        cmd.setParameter("audioRxMuted", !roomParticipant.getMicrophoneEnabled());
    }
    if (roomParticipant.getVideoEnabled() != null) {
        cmd.setParameter("videoRxMuted", !roomParticipant.getVideoEnabled());
    }
    Integer microphoneLevel = roomParticipant.getMicrophoneLevel();
    if (microphoneLevel != null && !microphoneLevel.equals(RoomParticipant.DEFAULT_MICROPHONE_LEVEL)) {
        double gainDb = MathHelper.getDbFromPercent(((double) roomParticipant.getMicrophoneLevel() - 5.0) / 5.0,
                MAX_ABS_GAIN_DB);
        cmd.setParameter("audioRxGainMillidB", (int) (gainDb * 1000.0));
        cmd.setParameter("audioRxGainMode", "fixed");
    } else {
        cmd.setParameter("audioRxGainMode", "default");
    }

    // Content
    // NOTE: it seems it is not possible to enable content using current API (2.9)
    //throw new CommandUnsupportedException();

    execApi(cmd);
}

From source file:de.uniwue.info6.database.jdbc.ConnectionManager.java

/**
 *
 *
 * @param scenario// w  w w  . j a va2 s .  com
 * @param db
 * @throws SQLException
 * @throws IOException
 * @throws FileNotFoundException
 */
public synchronized String addDB(Scenario scenario) throws SQLException, FileNotFoundException, IOException {
    if (scenario == null) {
        LOGGER.error("ADDED SCENARIO IS NULL");
    } else {
        this.createDataSource(scenario);

        // parse import-scripts
        String error = "";
        if (scenario != null) {
            Connection connection = null;
            StringWriter swError = new StringWriter();
            StringWriter swLog = new StringWriter();

            try {

                connection = instance.getConnection(scenario);
                String dbScript = scenario.getCreateScriptPath();
                ScriptRunner sc = new ScriptRunner(connection, false, true);

                PrintWriter pwLog = new PrintWriter(swLog);
                sc.setLogWriter(pwLog);

                PrintWriter pwError = new PrintWriter(swError);
                sc.setErrorLogWriter(pwError);

                File sqlScript = null;
                File tempScenarioFile = null;
                Integer scID = scenario.getId();

                // ------------------------------------------------ //

                if (scID.equals(0)) {
                    final URL scriptFileURL = this.getClass().getResource("/" + dbScript);
                    if (scriptFileURL != null) {
                        sqlScript = new File(scriptFileURL.getFile());
                    }
                } else {
                    sqlScript = new File(resourcePath + File.separator + scID, dbScript);
                    tempScenarioFile = new File(resourcePath + File.separator + "0", dbScript);

                    if (!sqlScript.exists() && tempScenarioFile.exists()) {
                        if (!sqlScript.getParentFile().exists()) {
                            sqlScript.getParentFile().mkdirs();
                        }
                        FileUtils.copyFile(tempScenarioFile, sqlScript);
                    }
                }

                // ------------------------------------------------ //

                if (sqlScript.exists()) {
                    sc.runScript(new FileReader(sqlScript), true);
                    ArrayList<String> commands = sc.getCommands();

                    if (!commands.isEmpty()) {
                        scenarioScripts.put(scenario, commands);
                    }
                    for (String command : commands) {
                        addUserPrefix(command, scenario, null);
                    }
                }

                // ------------------------------------------------ //

            } catch (Exception e) {
                error = swError.toString();
                if (error.isEmpty()) {
                    String er = ExceptionUtils.getStackTrace(e);
                    if (er.length() > 500) {
                        error = Cfg.inst().getProp(DEF_LANGUAGE, "ERROR.UNEXPECTED") + ": \n"
                                + er.substring(0, 500) + " [...]";
                    } else {
                        error = Cfg.inst().getProp(DEF_LANGUAGE, "ERROR.UNEXPECTED") + ": \n" + er;
                    }
                }

                if (!error.toLowerCase().contains("duplicate entry")) {
                    LOGGER.error(error, e);
                }

                if (!errors.containsKey(scenario)) {
                    errors.put(scenario, error);
                }
                return error;
            } finally {
                if (connection != null) {
                    try {
                        connection.close();
                    } catch (SQLException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    }
    return null;
}

From source file:ch.kostceco.tools.kostval.KOSTVal.java

/** Die Eingabe besteht aus 2 oder 3 Parameter: [0] Validierungstyp [1] Pfad zur Val-File [2]
 * option: Verbose// ww  w.  j a v  a 2  s.c  o  m
 * 
 * @param args
 * @throws IOException */

@SuppressWarnings("unused")
public static void main(String[] args) throws IOException {
    ApplicationContext context = new ClassPathXmlApplicationContext("classpath:config/applicationContext.xml");

    // Zeitstempel Start
    java.util.Date nowStart = new java.util.Date();
    java.text.SimpleDateFormat sdfStart = new java.text.SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
    String ausgabeStart = sdfStart.format(nowStart);

    /* TODO: siehe Bemerkung im applicationContext-services.xml bezglich Injection in der
     * Superklasse aller Impl-Klassen ValidationModuleImpl validationModuleImpl =
     * (ValidationModuleImpl) context.getBean("validationmoduleimpl"); */

    KOSTVal kostval = (KOSTVal) context.getBean("kostval");
    File configFile = new File("configuration" + File.separator + "kostval.conf.xml");

    // Ueberprfung des Parameters (Log-Verzeichnis)
    String pathToLogfile = kostval.getConfigurationService().getPathToLogfile();

    File directoryOfLogfile = new File(pathToLogfile);

    if (!directoryOfLogfile.exists()) {
        directoryOfLogfile.mkdir();
    }

    // Im Logverzeichnis besteht kein Schreibrecht
    if (!directoryOfLogfile.canWrite()) {
        System.out.println(
                kostval.getTextResourceService().getText(ERROR_LOGDIRECTORY_NOTWRITABLE, directoryOfLogfile));
        System.exit(1);
    }

    if (!directoryOfLogfile.isDirectory()) {
        System.out.println(kostval.getTextResourceService().getText(ERROR_LOGDIRECTORY_NODIRECTORY));
        System.exit(1);
    }

    // Ist die Anzahl Parameter (mind. 2) korrekt?
    if (args.length < 2) {
        System.out.println(kostval.getTextResourceService().getText(ERROR_PARAMETER_USAGE));
        System.exit(1);
    }

    File valDatei = new File(args[1]);
    File logDatei = null;
    logDatei = valDatei;

    // Informationen zum Arbeitsverzeichnis holen
    String pathToWorkDir = kostval.getConfigurationService().getPathToWorkDir();
    /* Nicht vergessen in "src/main/resources/config/applicationContext-services.xml" beim
     * entsprechenden Modul die property anzugeben: <property name="configurationService"
     * ref="configurationService" /> */

    // Informationen holen, welche Formate validiert werden sollen
    String pdfaValidation = kostval.getConfigurationService().pdfaValidation();
    String siardValidation = kostval.getConfigurationService().siardValidation();
    String tiffValidation = kostval.getConfigurationService().tiffValidation();
    String jp2Validation = kostval.getConfigurationService().jp2Validation();

    // Konfiguration des Loggings, ein File Logger wird zustzlich erstellt
    LogConfigurator logConfigurator = (LogConfigurator) context.getBean("logconfigurator");
    String logFileName = logConfigurator.configure(directoryOfLogfile.getAbsolutePath(), logDatei.getName());
    File logFile = new File(logFileName);
    // Ab hier kann ins log geschrieben werden...

    String formatValOn = "";
    // ermitteln welche Formate validiert werden knnen respektive eingeschaltet sind
    if (pdfaValidation.equals("yes")) {
        formatValOn = "PDF/A";
        if (tiffValidation.equals("yes")) {
            formatValOn = formatValOn + ", TIFF";
        }
        if (jp2Validation.equals("yes")) {
            formatValOn = formatValOn + ", JP2";
        }
        if (siardValidation.equals("yes")) {
            formatValOn = formatValOn + ", SIARD";
        }
    } else if (tiffValidation.equals("yes")) {
        formatValOn = "TIFF";
        if (jp2Validation.equals("yes")) {
            formatValOn = formatValOn + ", JP2";
        }
        if (siardValidation.equals("yes")) {
            formatValOn = formatValOn + ", SIARD";
        }
    } else if (jp2Validation.equals("yes")) {
        formatValOn = "JP2";
        if (siardValidation.equals("yes")) {
            formatValOn = formatValOn + ", SIARD";
        }
    } else if (siardValidation.equals("yes")) {
        formatValOn = "SIARD";
    }

    LOGGER.logError(kostval.getTextResourceService().getText(MESSAGE_XML_HEADER));
    LOGGER.logError(kostval.getTextResourceService().getText(MESSAGE_XML_START, ausgabeStart));
    LOGGER.logError(kostval.getTextResourceService().getText(MESSAGE_XML_END));
    LOGGER.logError(kostval.getTextResourceService().getText(MESSAGE_XML_FORMATON, formatValOn));
    LOGGER.logError(kostval.getTextResourceService().getText(MESSAGE_XML_INFO));
    System.out.println("KOST-Val");
    System.out.println("");

    if (args[0].equals("--format") && formatValOn.equals("")) {
        // Formatvalidierung aber alle Formate ausgeschlossen
        LOGGER.logError(kostval.getTextResourceService().getText(ERROR_IOE,
                kostval.getTextResourceService().getText(ERROR_NOFILEENDINGS)));
        System.out.println(kostval.getTextResourceService().getText(ERROR_NOFILEENDINGS));
        System.exit(1);
    }

    File xslOrig = new File("resources" + File.separator + "kost-val.xsl");
    File xslCopy = new File(directoryOfLogfile.getAbsolutePath() + File.separator + "kost-val.xsl");
    if (!xslCopy.exists()) {
        Util.copyFile(xslOrig, xslCopy);
    }

    File tmpDir = new File(pathToWorkDir);

    /* bestehendes Workverzeichnis Abbruch wenn nicht leer, da am Schluss das Workverzeichnis
     * gelscht wird und entsprechend bestehende Dateien gelscht werden knnen */
    if (tmpDir.exists()) {
        if (tmpDir.isDirectory()) {
            // Get list of file in the directory. When its length is not zero the folder is not empty.
            String[] files = tmpDir.list();
            if (files.length > 0) {
                LOGGER.logError(kostval.getTextResourceService().getText(ERROR_IOE,
                        kostval.getTextResourceService().getText(ERROR_WORKDIRECTORY_EXISTS, pathToWorkDir)));
                System.out.println(
                        kostval.getTextResourceService().getText(ERROR_WORKDIRECTORY_EXISTS, pathToWorkDir));
                System.exit(1);
            }
        }
    }

    // Im Pfad keine Sonderzeichen xml-Validierung SIP 1d und SIARD C strzen ab

    String patternStr = "[^!#\\$%\\(\\)\\+,\\-_\\.=@\\[\\]\\{\\}\\~:\\\\a-zA-Z0-9 ]";
    Pattern pattern = Pattern.compile(patternStr);

    String name = tmpDir.getAbsolutePath();

    String[] pathElements = name.split("/");
    for (int i = 0; i < pathElements.length; i++) {
        String element = pathElements[i];

        Matcher matcher = pattern.matcher(element);

        boolean matchFound = matcher.find();
        if (matchFound) {
            LOGGER.logError(kostval.getTextResourceService().getText(ERROR_IOE,
                    kostval.getTextResourceService().getText(ERROR_SPECIAL_CHARACTER, name)));
            System.out.println(kostval.getTextResourceService().getText(ERROR_SPECIAL_CHARACTER, name));
            System.exit(1);
        }
    }

    // die Anwendung muss mindestens unter Java 6 laufen
    String javaRuntimeVersion = System.getProperty("java.vm.version");
    if (javaRuntimeVersion.compareTo("1.6.0") < 0) {
        LOGGER.logError(kostval.getTextResourceService().getText(ERROR_IOE,
                kostval.getTextResourceService().getText(ERROR_WRONG_JRE)));
        System.out.println(kostval.getTextResourceService().getText(ERROR_WRONG_JRE));
        System.exit(1);
    }

    // bestehendes Workverzeichnis wieder anlegen
    if (!tmpDir.exists()) {
        tmpDir.mkdir();
    }

    // Im workverzeichnis besteht kein Schreibrecht
    if (!tmpDir.canWrite()) {
        LOGGER.logError(kostval.getTextResourceService().getText(ERROR_IOE,
                kostval.getTextResourceService().getText(ERROR_WORKDIRECTORY_NOTWRITABLE, tmpDir)));
        System.out.println(kostval.getTextResourceService().getText(ERROR_WORKDIRECTORY_NOTWRITABLE, tmpDir));
        System.exit(1);
    }

    /* Vorberitung fr eine allfllige Festhaltung bei unterschiedlichen PDFA-Validierungsresultaten
     * in einer PDF_Diagnosedatei sowie Zhler der SIP-Dateiformate */
    String diaPath = kostval.getConfigurationService().getPathToDiagnose();

    // Im diaverzeichnis besteht kein Schreibrecht
    File diaDir = new File(diaPath);

    if (!diaDir.exists()) {
        diaDir.mkdir();
    }

    if (!diaDir.canWrite()) {
        LOGGER.logError(kostval.getTextResourceService().getText(ERROR_IOE,
                kostval.getTextResourceService().getText(ERROR_DIADIRECTORY_NOTWRITABLE, diaDir)));
        System.out.println(kostval.getTextResourceService().getText(ERROR_DIADIRECTORY_NOTWRITABLE, diaDir));
        System.exit(1);
    }

    File xmlDiaOrig = new File("resources" + File.separator + "KaD-Diagnosedaten.kost-val.xml");
    File xmlDiaCopy = new File(diaPath + File.separator + "KaD-Diagnosedaten.kost-val.xml");
    if (!xmlDiaCopy.exists()) {
        Util.copyFile(xmlDiaOrig, xmlDiaCopy);
    }
    File xslDiaOrig = new File("resources" + File.separator + "kost-val_KaDdia.xsl");
    File xslDiaCopy = new File(diaPath + File.separator + "kost-val_KaDdia.xsl");
    if (!xslDiaCopy.exists()) {
        Util.copyFile(xslDiaOrig, xslDiaCopy);
    }

    /* Ueberprfung des optionalen Parameters (2 -v --> im Verbose-mode werden die originalen Logs
     * nicht gelscht (PDFTron, Jhove & Co.) */
    boolean verbose = false;
    if (args.length > 2) {
        if (!(args[2].equals("-v"))) {
            LOGGER.logError(kostval.getTextResourceService().getText(ERROR_IOE,
                    kostval.getTextResourceService().getText(ERROR_PARAMETER_OPTIONAL_1)));
            System.out.println(kostval.getTextResourceService().getText(ERROR_PARAMETER_OPTIONAL_1));
            System.exit(1);
        } else {
            verbose = true;
        }
    }

    /* Initialisierung TIFF-Modul B (JHove-Validierung) berprfen der Konfiguration: existiert die
     * jhove.conf am angebenen Ort? */
    String jhoveConf = kostval.getConfigurationService().getPathToJhoveConfiguration();
    File fJhoveConf = new File(jhoveConf);
    if (!fJhoveConf.exists() || !fJhoveConf.getName().equals("jhove.conf")) {

        LOGGER.logError(kostval.getTextResourceService().getText(ERROR_IOE,
                kostval.getTextResourceService().getText(ERROR_JHOVECONF_MISSING)));
        System.out.println(kostval.getTextResourceService().getText(ERROR_JHOVECONF_MISSING));
        System.exit(1);
    }

    // Im Pfad keine Sonderzeichen xml-Validierung SIP 1d und SIARD C strzen ab

    name = valDatei.getAbsolutePath();

    pathElements = name.split("/");
    for (int i = 0; i < pathElements.length; i++) {
        String element = pathElements[i];

        Matcher matcher = pattern.matcher(element);

        boolean matchFound = matcher.find();
        if (matchFound) {
            LOGGER.logError(kostval.getTextResourceService().getText(ERROR_IOE,
                    kostval.getTextResourceService().getText(ERROR_SPECIAL_CHARACTER, name)));
            System.out.println(kostval.getTextResourceService().getText(ERROR_SPECIAL_CHARACTER, name));
            System.exit(1);
        }
    }

    // Ueberprfung des Parameters (Val-Datei): existiert die Datei?
    if (!valDatei.exists()) {
        LOGGER.logError(kostval.getTextResourceService().getText(ERROR_IOE,
                kostval.getTextResourceService().getText(ERROR_VALFILE_FILENOTEXISTING)));
        System.out.println(kostval.getTextResourceService().getText(ERROR_VALFILE_FILENOTEXISTING));
        System.exit(1);
    }

    if (args[0].equals("--format")) {
        LOGGER.logError(kostval.getTextResourceService().getText(MESSAGE_XML_FORMAT1));
        Integer countNio = 0;
        Integer countSummaryNio = 0;
        Integer count = 0;
        Integer pdfaCountIo = 0;
        Integer pdfaCountNio = 0;
        Integer siardCountIo = 0;
        Integer siardCountNio = 0;
        Integer tiffCountIo = 0;
        Integer tiffCountNio = 0;
        Integer jp2CountIo = 0;
        Integer jp2CountNio = 0;

        // TODO: Formatvalidierung an einer Datei --> erledigt --> nur Marker
        if (!valDatei.isDirectory()) {

            boolean valFile = valFile(valDatei, logFileName, directoryOfLogfile, verbose);

            LOGGER.logError(kostval.getTextResourceService().getText(MESSAGE_XML_FORMAT2));

            // Lschen des Arbeitsverzeichnisses, falls eines angelegt wurde
            if (tmpDir.exists()) {
                Util.deleteDir(tmpDir);
            }

            LOGGER.logError(kostval.getTextResourceService().getText(MESSAGE_XML_LOGEND));
            // Zeitstempel End
            java.util.Date nowEnd = new java.util.Date();
            java.text.SimpleDateFormat sdfEnd = new java.text.SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
            String ausgabeEnd = sdfEnd.format(nowEnd);
            ausgabeEnd = "<End>" + ausgabeEnd + "</End>";
            Util.valEnd(ausgabeEnd, logFile);
            Util.amp(logFile);

            // Die Konfiguration hereinkopieren
            try {
                DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                factory.setValidating(false);

                factory.setExpandEntityReferences(false);

                Document docConfig = factory.newDocumentBuilder().parse(configFile);
                NodeList list = docConfig.getElementsByTagName("configuration");
                Element element = (Element) list.item(0);

                Document docLog = factory.newDocumentBuilder().parse(logFile);

                Node dup = docLog.importNode(element, true);

                docLog.getDocumentElement().appendChild(dup);
                FileWriter writer = new FileWriter(logFile);

                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                ElementToStream(docLog.getDocumentElement(), baos);
                String stringDoc2 = new String(baos.toByteArray());
                writer.write(stringDoc2);
                writer.close();

                // Der Header wird dabei leider verschossen, wieder zurck ndern
                String newstring = kostval.getTextResourceService().getText(MESSAGE_XML_HEADER);
                String oldstring = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><KOSTValLog>";
                Util.oldnewstring(oldstring, newstring, logFile);

            } catch (Exception e) {
                LOGGER.logError("<Error>"
                        + kostval.getTextResourceService().getText(ERROR_XML_UNKNOWN, e.getMessage()));
                System.out.println("Exception: " + e.getMessage());
            }

            if (valFile) {
                // Lschen des Arbeitsverzeichnisses, falls eines angelegt wurde
                if (tmpDir.exists()) {
                    Util.deleteDir(tmpDir);
                }
                // Validierte Datei valide
                System.exit(0);
            } else {
                // Lschen des Arbeitsverzeichnisses, falls eines angelegt wurde
                if (tmpDir.exists()) {
                    Util.deleteDir(tmpDir);
                }
                // Fehler in Validierte Datei --> invalide
                System.exit(2);

            }
        } else {
            // TODO: Formatvalidierung ber ein Ordner --> erledigt --> nur Marker
            Map<String, File> fileMap = Util.getFileMap(valDatei, false);
            Set<String> fileMapKeys = fileMap.keySet();

            for (Iterator<String> iterator = fileMapKeys.iterator(); iterator.hasNext();) {
                String entryName = iterator.next();
                File newFile = fileMap.get(entryName);
                if (!newFile.isDirectory()) {
                    valDatei = newFile;
                    count = count + 1;

                    // Ausgabe Dateizhler Ersichtlich das KOST-Val Dateien durchsucht
                    System.out.print(count + "   ");
                    System.out.print("\r");

                    if (((valDatei.getAbsolutePath().toLowerCase().endsWith(".jp2")))
                            && jp2Validation.equals("yes")) {

                        boolean valFile = valFile(valDatei, logFileName, directoryOfLogfile, verbose);

                        // Lschen des Arbeitsverzeichnisses, falls eines angelegt wurde
                        if (tmpDir.exists()) {
                            Util.deleteDir(tmpDir);
                        }
                        if (valFile) {
                            jp2CountIo = jp2CountIo + 1;
                            // Lschen des Arbeitsverzeichnisses, falls eines angelegt wurde
                            if (tmpDir.exists()) {
                                Util.deleteDir(tmpDir);
                            }
                        } else {
                            jp2CountNio = jp2CountNio + 1;
                            // Lschen des Arbeitsverzeichnisses, falls eines angelegt wurde
                            if (tmpDir.exists()) {
                                Util.deleteDir(tmpDir);
                            }
                        }
                    } else if (((valDatei.getAbsolutePath().toLowerCase().endsWith(".tiff")
                            || valDatei.getAbsolutePath().toLowerCase().endsWith(".tif")))
                            && tiffValidation.equals("yes")) {

                        boolean valFile = valFile(valDatei, logFileName, directoryOfLogfile, verbose);

                        // Lschen des Arbeitsverzeichnisses, falls eines angelegt wurde
                        if (tmpDir.exists()) {
                            Util.deleteDir(tmpDir);
                        }
                        if (valFile) {
                            tiffCountIo = tiffCountIo + 1;
                            // Lschen des Arbeitsverzeichnisses, falls eines angelegt wurde
                            if (tmpDir.exists()) {
                                Util.deleteDir(tmpDir);
                            }
                        } else {
                            tiffCountNio = tiffCountNio + 1;
                            // Lschen des Arbeitsverzeichnisses, falls eines angelegt wurde
                            if (tmpDir.exists()) {
                                Util.deleteDir(tmpDir);
                            }
                        }
                    } else if ((valDatei.getAbsolutePath().toLowerCase().endsWith(".siard"))
                            && siardValidation.equals("yes")) {

                        boolean valFile = valFile(valDatei, logFileName, directoryOfLogfile, verbose);

                        // Lschen des Arbeitsverzeichnisses, falls eines angelegt wurde
                        if (tmpDir.exists()) {
                            Util.deleteDir(tmpDir);
                        }
                        if (valFile) {
                            siardCountIo = siardCountIo + 1;
                            // Lschen des Arbeitsverzeichnisses, falls eines angelegt wurde
                            if (tmpDir.exists()) {
                                Util.deleteDir(tmpDir);
                            }
                        } else {
                            siardCountNio = siardCountNio + 1;
                            // Lschen des Arbeitsverzeichnisses, falls eines angelegt wurde
                            if (tmpDir.exists()) {
                                Util.deleteDir(tmpDir);
                            }
                        }

                    } else if (((valDatei.getAbsolutePath().toLowerCase().endsWith(".pdf")
                            || valDatei.getAbsolutePath().toLowerCase().endsWith(".pdfa")))
                            && pdfaValidation.equals("yes")) {

                        boolean valFile = valFile(valDatei, logFileName, directoryOfLogfile, verbose);

                        // Lschen des Arbeitsverzeichnisses, falls eines angelegt wurde
                        if (tmpDir.exists()) {
                            Util.deleteDir(tmpDir);
                        }
                        if (valFile) {
                            pdfaCountIo = pdfaCountIo + 1;
                            // Lschen des Arbeitsverzeichnisses, falls eines angelegt wurde
                            if (tmpDir.exists()) {
                                Util.deleteDir(tmpDir);
                            }
                        } else {
                            pdfaCountNio = pdfaCountNio + 1;
                            // Lschen des Arbeitsverzeichnisses, falls eines angelegt wurde
                            if (tmpDir.exists()) {
                                Util.deleteDir(tmpDir);
                            }
                        }

                    } else {
                        countNio = countNio + 1;
                    }
                }
            }

            System.out.print("                   ");
            System.out.print("\r");

            if (countNio.equals(count)) {
                // keine Dateien Validiert
                LOGGER.logError(
                        kostval.getTextResourceService().getText(ERROR_INCORRECTFILEENDINGS, formatValOn));
                System.out.println(
                        kostval.getTextResourceService().getText(ERROR_INCORRECTFILEENDINGS, formatValOn));
            }

            LOGGER.logError(kostval.getTextResourceService().getText(MESSAGE_XML_FORMAT2));

            LOGGER.logError(kostval.getTextResourceService().getText(MESSAGE_XML_LOGEND));
            // Zeitstempel End
            java.util.Date nowEnd = new java.util.Date();
            java.text.SimpleDateFormat sdfEnd = new java.text.SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
            String ausgabeEnd = sdfEnd.format(nowEnd);
            ausgabeEnd = "<End>" + ausgabeEnd + "</End>";
            Util.valEnd(ausgabeEnd, logFile);
            Util.amp(logFile);

            // Die Konfiguration hereinkopieren
            try {
                DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                factory.setValidating(false);

                factory.setExpandEntityReferences(false);

                Document docConfig = factory.newDocumentBuilder().parse(configFile);
                NodeList list = docConfig.getElementsByTagName("configuration");
                Element element = (Element) list.item(0);

                Document docLog = factory.newDocumentBuilder().parse(logFile);

                Node dup = docLog.importNode(element, true);

                docLog.getDocumentElement().appendChild(dup);
                FileWriter writer = new FileWriter(logFile);

                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                ElementToStream(docLog.getDocumentElement(), baos);
                String stringDoc2 = new String(baos.toByteArray());
                writer.write(stringDoc2);
                writer.close();

                // Der Header wird dabei leider verschossen, wieder zurck ndern
                String newstring = kostval.getTextResourceService().getText(MESSAGE_XML_HEADER);
                String oldstring = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><KOSTValLog>";
                Util.oldnewstring(oldstring, newstring, logFile);

            } catch (Exception e) {
                LOGGER.logError("<Error>"
                        + kostval.getTextResourceService().getText(ERROR_XML_UNKNOWN, e.getMessage()));
                System.out.println("Exception: " + e.getMessage());
            }

            countSummaryNio = pdfaCountNio + siardCountNio + tiffCountNio + jp2CountNio;

            if (countNio.equals(count)) {
                // keine Dateien Validiert bestehendes Workverzeichnis ggf. lschen
                if (tmpDir.exists()) {
                    Util.deleteDir(tmpDir);
                }
                System.exit(1);
            } else if (countSummaryNio == 0) {
                // bestehendes Workverzeichnis ggf. lschen
                if (tmpDir.exists()) {
                    Util.deleteDir(tmpDir);
                }
                // alle Validierten Dateien valide
                System.exit(0);
            } else {
                // bestehendes Workverzeichnis ggf. lschen
                if (tmpDir.exists()) {
                    Util.deleteDir(tmpDir);
                }
                // Fehler in Validierten Dateien --> invalide
                System.exit(2);
            }
            if (tmpDir.exists()) {
                Util.deleteDir(tmpDir);
                tmpDir.deleteOnExit();
            }
        }
        LOGGER.logError(kostval.getTextResourceService().getText(MESSAGE_XML_FORMAT2));

    } else if (args[0].equals("--sip")) {
        LOGGER.logError(kostval.getTextResourceService().getText(MESSAGE_XML_FORMAT1));

        // TODO: Sipvalidierung --> erledigt --> nur Marker
        boolean validFormat = false;
        File originalSipFile = valDatei;
        File unSipFile = valDatei;
        File outputFile3c = null;
        String fileName3c = null;
        File tmpDirZip = null;

        // zuerst eine Formatvalidierung ber den Content dies ist analog aufgebaut wie --format
        Integer countNio = 0;
        Integer countSummaryNio = 0;
        Integer countSummaryIo = 0;
        Integer count = 0;
        Integer pdfaCountIo = 0;
        Integer pdfaCountNio = 0;
        Integer siardCountIo = 0;
        Integer siardCountNio = 0;
        Integer tiffCountIo = 0;
        Integer tiffCountNio = 0;
        Integer jp2CountIo = 0;
        Integer jp2CountNio = 0;

        if (!valDatei.isDirectory()) {
            Boolean zip = false;
            // Eine ZIP Datei muss mit PK.. beginnen
            if ((valDatei.getAbsolutePath().toLowerCase().endsWith(".zip")
                    || valDatei.getAbsolutePath().toLowerCase().endsWith(".zip64"))) {

                FileReader fr = null;

                try {
                    fr = new FileReader(valDatei);
                    BufferedReader read = new BufferedReader(fr);

                    // Hex 03 in Char umwandeln
                    String str3 = "03";
                    int i3 = Integer.parseInt(str3, 16);
                    char c3 = (char) i3;
                    // Hex 04 in Char umwandeln
                    String str4 = "04";
                    int i4 = Integer.parseInt(str4, 16);
                    char c4 = (char) i4;

                    // auslesen der ersten 4 Zeichen der Datei
                    int length;
                    int i;
                    char[] buffer = new char[4];
                    length = read.read(buffer);
                    for (i = 0; i != length; i++)
                        ;

                    // die beiden charArrays (soll und ist) mit einander vergleichen
                    char[] charArray1 = buffer;
                    char[] charArray2 = new char[] { 'P', 'K', c3, c4 };

                    if (Arrays.equals(charArray1, charArray2)) {
                        // hchstwahrscheinlich ein ZIP da es mit 504B0304 respektive PK.. beginnt
                        zip = true;
                    }
                } catch (Exception e) {
                    LOGGER.logError("<Error>"
                            + kostval.getTextResourceService().getText(ERROR_XML_UNKNOWN, e.getMessage()));
                    System.out.println("Exception: " + e.getMessage());
                }
            }

            // wenn die Datei kein Directory ist, muss sie mit zip oder zip64 enden
            if ((!(valDatei.getAbsolutePath().toLowerCase().endsWith(".zip")
                    || valDatei.getAbsolutePath().toLowerCase().endsWith(".zip64"))) || zip == false) {
                // Abbruch! D.h. Sip message beginnen, Meldung und Beenden ab hier bis System.exit( 1 );
                LOGGER.logError(kostval.getTextResourceService().getText(MESSAGE_XML_FORMAT2));
                LOGGER.logError(kostval.getTextResourceService().getText(MESSAGE_XML_SIP1));
                valDatei = originalSipFile;
                LOGGER.logError(kostval.getTextResourceService().getText(MESSAGE_XML_VALERGEBNIS));
                LOGGER.logError(kostval.getTextResourceService().getText(MESSAGE_XML_VALTYPE,
                        kostval.getTextResourceService().getText(MESSAGE_SIPVALIDATION)));
                LOGGER.logError(kostval.getTextResourceService().getText(MESSAGE_XML_VALFILE,
                        valDatei.getAbsolutePath()));
                System.out.println(kostval.getTextResourceService().getText(MESSAGE_SIPVALIDATION));
                System.out.println(valDatei.getAbsolutePath());

                // die eigentliche Fehlermeldung
                LOGGER.logError(kostval.getTextResourceService().getText(MESSAGE_XML_MODUL_Aa_SIP)
                        + kostval.getTextResourceService().getText(ERROR_XML_AA_INCORRECTFILEENDING));
                System.out.println(kostval.getTextResourceService().getText(ERROR_XML_AA_INCORRECTFILEENDING));

                // Fehler im Validierten SIP --> invalide & Abbruch
                LOGGER.logError(kostval.getTextResourceService().getText(MESSAGE_XML_VALERGEBNIS_INVALID));
                LOGGER.logError(kostval.getTextResourceService().getText(MESSAGE_XML_VALERGEBNIS_CLOSE));
                System.out.println("Invalid");
                System.out.println("");
                LOGGER.logError(kostval.getTextResourceService().getText(MESSAGE_XML_SIP2));
                LOGGER.logError(kostval.getTextResourceService().getText(MESSAGE_XML_LOGEND));

                // Zeitstempel End
                java.util.Date nowEnd = new java.util.Date();
                java.text.SimpleDateFormat sdfEnd = new java.text.SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
                String ausgabeEnd = sdfEnd.format(nowEnd);
                ausgabeEnd = "<End>" + ausgabeEnd + "</End>";
                Util.valEnd(ausgabeEnd, logFile);
                Util.amp(logFile);

                // Die Konfiguration hereinkopieren
                try {
                    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                    factory.setValidating(false);

                    factory.setExpandEntityReferences(false);

                    Document docConfig = factory.newDocumentBuilder().parse(configFile);
                    NodeList list = docConfig.getElementsByTagName("configuration");
                    Element element = (Element) list.item(0);

                    Document docLog = factory.newDocumentBuilder().parse(logFile);

                    Node dup = docLog.importNode(element, true);

                    docLog.getDocumentElement().appendChild(dup);
                    FileWriter writer = new FileWriter(logFile);

                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
                    ElementToStream(docLog.getDocumentElement(), baos);
                    String stringDoc2 = new String(baos.toByteArray());
                    writer.write(stringDoc2);
                    writer.close();

                    // Der Header wird dabei leider verschossen, wieder zurck ndern
                    String newstring = kostval.getTextResourceService().getText(MESSAGE_XML_HEADER);
                    String oldstring = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><KOSTValLog>";
                    Util.oldnewstring(oldstring, newstring, logFile);

                } catch (Exception e) {
                    LOGGER.logError("<Error>"
                            + kostval.getTextResourceService().getText(ERROR_XML_UNKNOWN, e.getMessage()));
                    System.out.println("Exception: " + e.getMessage());
                }

                // bestehendes Workverzeichnis ggf. lschen
                if (tmpDir.exists()) {
                    Util.deleteDir(tmpDir);
                }
                System.exit(1);

            } else {
                // geziptes SIP --> in temp dir entzipen
                String toplevelDir = valDatei.getName();
                int lastDotIdx = toplevelDir.lastIndexOf(".");
                toplevelDir = toplevelDir.substring(0, lastDotIdx);
                tmpDirZip = new File(
                        tmpDir.getAbsolutePath() + File.separator + "ZIP" + File.separator + toplevelDir);
                try {
                    Zip64Archiver.unzip(valDatei.getAbsolutePath(), tmpDirZip.getAbsolutePath());
                } catch (Exception e) {
                    try {
                        Zip64Archiver.unzip64(valDatei, tmpDirZip);
                    } catch (Exception e1) {
                        // Abbruch! D.h. Sip message beginnen, Meldung und Beenden ab hier bis System.exit
                        LOGGER.logError(kostval.getTextResourceService().getText(MESSAGE_XML_FORMAT2));
                        LOGGER.logError(kostval.getTextResourceService().getText(MESSAGE_XML_SIP1));
                        valDatei = originalSipFile;
                        LOGGER.logError(kostval.getTextResourceService().getText(MESSAGE_XML_VALERGEBNIS));
                        LOGGER.logError(kostval.getTextResourceService().getText(MESSAGE_XML_VALTYPE,
                                kostval.getTextResourceService().getText(MESSAGE_SIPVALIDATION)));
                        LOGGER.logError(kostval.getTextResourceService().getText(MESSAGE_XML_VALFILE,
                                valDatei.getAbsolutePath()));
                        System.out.println(kostval.getTextResourceService().getText(MESSAGE_SIPVALIDATION));
                        System.out.println(valDatei.getAbsolutePath());

                        // die eigentliche Fehlermeldung
                        LOGGER.logError(kostval.getTextResourceService().getText(MESSAGE_XML_MODUL_Aa_SIP)
                                + kostval.getTextResourceService().getText(ERROR_XML_AA_CANNOTEXTRACTZIP));
                        System.out.println(
                                kostval.getTextResourceService().getText(ERROR_XML_AA_CANNOTEXTRACTZIP));

                        // Fehler im Validierten SIP --> invalide & Abbruch
                        LOGGER.logError(
                                kostval.getTextResourceService().getText(MESSAGE_XML_VALERGEBNIS_INVALID));
                        LOGGER.logError(
                                kostval.getTextResourceService().getText(MESSAGE_XML_VALERGEBNIS_CLOSE));
                        System.out.println("Invalid");
                        System.out.println("");
                        LOGGER.logError(kostval.getTextResourceService().getText(MESSAGE_XML_SIP2));
                        LOGGER.logError(kostval.getTextResourceService().getText(MESSAGE_XML_LOGEND));

                        // Zeitstempel End
                        java.util.Date nowEnd = new java.util.Date();
                        java.text.SimpleDateFormat sdfEnd = new java.text.SimpleDateFormat(
                                "dd.MM.yyyy HH:mm:ss");
                        String ausgabeEnd = sdfEnd.format(nowEnd);
                        ausgabeEnd = "<End>" + ausgabeEnd + "</End>";
                        Util.valEnd(ausgabeEnd, logFile);
                        Util.amp(logFile);

                        // Die Konfiguration hereinkopieren
                        try {
                            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                            factory.setValidating(false);

                            factory.setExpandEntityReferences(false);

                            Document docConfig = factory.newDocumentBuilder().parse(configFile);
                            NodeList list = docConfig.getElementsByTagName("configuration");
                            Element element = (Element) list.item(0);

                            Document docLog = factory.newDocumentBuilder().parse(logFile);

                            Node dup = docLog.importNode(element, true);

                            docLog.getDocumentElement().appendChild(dup);
                            FileWriter writer = new FileWriter(logFile);

                            ByteArrayOutputStream baos = new ByteArrayOutputStream();
                            ElementToStream(docLog.getDocumentElement(), baos);
                            String stringDoc2 = new String(baos.toByteArray());
                            writer.write(stringDoc2);
                            writer.close();

                            // Der Header wird dabei leider verschossen, wieder zurck ndern
                            String newstring = kostval.getTextResourceService().getText(MESSAGE_XML_HEADER);
                            String oldstring = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><KOSTValLog>";
                            Util.oldnewstring(oldstring, newstring, logFile);

                        } catch (Exception e2) {
                            LOGGER.logError("<Error>" + kostval.getTextResourceService()
                                    .getText(ERROR_XML_UNKNOWN, e2.getMessage()));
                            System.out.println("Exception: " + e2.getMessage());
                        }

                        // bestehendes Workverzeichnis ggf. lschen
                        if (tmpDir.exists()) {
                            Util.deleteDir(tmpDir);
                        }
                        System.exit(1);
                    }
                }
                valDatei = tmpDirZip;

                File toplevelfolder = new File(
                        valDatei.getAbsolutePath() + File.separator + valDatei.getName());
                if (toplevelfolder.exists()) {
                    valDatei = toplevelfolder;
                }
                unSipFile = valDatei;
            }
        } else {
            // SIP ist ein Ordner valDatei bleibt unverndert
        }

        // Vorgngige Formatvalidierung (Schritt 3c)
        Map<String, File> fileMap = Util.getFileMap(valDatei, false);
        Set<String> fileMapKeys = fileMap.keySet();

        int pdf = 0;
        int tiff = 0;
        int siard = 0;
        int txt = 0;
        int csv = 0;
        int xml = 0;
        int xsd = 0;
        int wave = 0;
        int mp3 = 0;
        int jp2 = 0;
        int jpx = 0;
        int jpeg = 0;
        int png = 0;
        int dng = 0;
        int svg = 0;
        int mpeg2 = 0;
        int mp4 = 0;
        int xls = 0;
        int odt = 0;
        int ods = 0;
        int odp = 0;
        int other = 0;

        for (Iterator<String> iterator = fileMapKeys.iterator(); iterator.hasNext();) {
            String entryName = iterator.next();
            File newFile = fileMap.get(entryName);

            if (!newFile.isDirectory()
                    && newFile.getAbsolutePath().contains(File.separator + "content" + File.separator)) {
                valDatei = newFile;
                count = count + 1;

                // Ausgabe Dateizhler Ersichtlich das KOST-Val Dateien durchsucht
                System.out.print(count + "   ");
                System.out.print("\r");

                String extension = valDatei.getName();
                int lastIndexOf = extension.lastIndexOf(".");
                if (lastIndexOf == -1) {
                    // empty extension
                    extension = "other";
                } else {
                    extension = extension.substring(lastIndexOf);
                }

                if (extension.equalsIgnoreCase(".pdf") || extension.equalsIgnoreCase(".pdfa")) {
                    pdf = pdf + 1;
                } else if (extension.equalsIgnoreCase(".tiff") || extension.equalsIgnoreCase(".tif")) {
                    tiff = tiff + 1;
                } else if (extension.equalsIgnoreCase(".siard")) {
                    siard = siard + 1;
                } else if (extension.equalsIgnoreCase(".txt")) {
                    txt = txt + 1;
                } else if (extension.equalsIgnoreCase(".csv")) {
                    csv = csv + 1;
                } else if (extension.equalsIgnoreCase(".xml")) {
                    xml = xml + 1;
                } else if (extension.equalsIgnoreCase(".xsd")) {
                    xsd = xsd + 1;
                } else if (extension.equalsIgnoreCase(".wav")) {
                    wave = wave + 1;
                } else if (extension.equalsIgnoreCase(".mp3")) {
                    mp3 = mp3 + 1;
                } else if (extension.equalsIgnoreCase(".jp2")) {
                    jp2 = jp2 + 1;
                } else if (extension.equalsIgnoreCase(".jpx") || extension.equalsIgnoreCase(".jpf")) {
                    jpx = jpx + 1;
                } else if (extension.equalsIgnoreCase(".jpe") || extension.equalsIgnoreCase(".jpeg")
                        || extension.equalsIgnoreCase(".jpg")) {
                    jpeg = jpeg + 1;
                } else if (extension.equalsIgnoreCase(".png")) {
                    png = png + 1;
                } else if (extension.equalsIgnoreCase(".dng")) {
                    dng = dng + 1;
                } else if (extension.equalsIgnoreCase(".svg")) {
                    svg = svg + 1;
                } else if (extension.equalsIgnoreCase(".mpeg") || extension.equalsIgnoreCase(".mpg")) {
                    mpeg2 = mpeg2 + 1;
                } else if (extension.equalsIgnoreCase(".f4a") || extension.equalsIgnoreCase(".f4v")
                        || extension.equalsIgnoreCase(".m4a") || extension.equalsIgnoreCase(".m4v")
                        || extension.equalsIgnoreCase(".mp4")) {
                    mp4 = mp4 + 1;
                } else if (extension.equalsIgnoreCase(".xls") || extension.equalsIgnoreCase(".xlw")
                        || extension.equalsIgnoreCase(".xlsx")) {
                    xls = xls + 1;
                } else if (extension.equalsIgnoreCase(".odt") || extension.equalsIgnoreCase(".ott")) {
                    odt = odt + 1;
                } else if (extension.equalsIgnoreCase(".ods") || extension.equalsIgnoreCase(".ots")) {
                    ods = ods + 1;
                } else if (extension.equalsIgnoreCase(".odp") || extension.equalsIgnoreCase(".otp")) {
                    odp = odp + 1;
                } else {
                    other = other + 1;
                }

                if (((valDatei.getAbsolutePath().toLowerCase().endsWith(".jp2")))
                        && jp2Validation.equals("yes")) {

                    boolean valFile = valFile(valDatei, logFileName, directoryOfLogfile, verbose);

                    if (valFile) {
                        jp2CountIo = jp2CountIo + 1;
                    } else {
                        jp2CountNio = jp2CountNio + 1;
                    }

                } else if (((valDatei.getAbsolutePath().toLowerCase().endsWith(".tiff")
                        || valDatei.getAbsolutePath().toLowerCase().endsWith(".tif")))
                        && tiffValidation.equals("yes")) {

                    boolean valFile = valFile(valDatei, logFileName, directoryOfLogfile, verbose);

                    if (valFile) {
                        tiffCountIo = tiffCountIo + 1;
                    } else {
                        tiffCountNio = tiffCountNio + 1;
                    }

                } else if ((valDatei.getAbsolutePath().toLowerCase().endsWith(".siard"))
                        && siardValidation.equals("yes")) {

                    // Arbeitsverzeichnis zum Entpacken des Archivs erstellen
                    String pathToWorkDirSiard = kostval.getConfigurationService().getPathToWorkDir();
                    File tmpDirSiard = new File(pathToWorkDirSiard + File.separator + "SIARD");
                    if (tmpDirSiard.exists()) {
                        Util.deleteDir(tmpDirSiard);
                    }
                    if (!tmpDirSiard.exists()) {
                        tmpDirSiard.mkdir();
                    }

                    boolean valFile = valFile(valDatei, logFileName, directoryOfLogfile, verbose);

                    if (valFile) {
                        siardCountIo = siardCountIo + 1;
                    } else {
                        siardCountNio = siardCountNio + 1;
                    }

                } else if (((valDatei.getAbsolutePath().toLowerCase().endsWith(".pdf")
                        || valDatei.getAbsolutePath().toLowerCase().endsWith(".pdfa")))
                        && pdfaValidation.equals("yes")) {

                    boolean valFile = valFile(valDatei, logFileName, directoryOfLogfile, verbose);

                    if (valFile) {
                        pdfaCountIo = pdfaCountIo + 1;
                    } else {
                        pdfaCountNio = pdfaCountNio + 1;
                    }

                } else {
                    countNio = countNio + 1;
                }
            }
        }

        countSummaryNio = pdfaCountNio + siardCountNio + tiffCountNio + jp2CountNio;
        countSummaryIo = pdfaCountIo + siardCountIo + tiffCountIo + jp2CountIo;
        int countSummaryIoP = 100 / count * countSummaryIo;
        int countSummaryNioP = 100 / count * countSummaryNio;
        int countNioP = 100 / count * countNio;
        String summary3c = kostval.getTextResourceService().getText(MESSAGE_XML_SUMMARY_3C, count,
                countSummaryIo, countSummaryNio, countNio, countSummaryIoP, countSummaryNioP, countNioP);

        if (countSummaryNio == 0) {
            // alle Validierten Dateien valide
            validFormat = true;
            fileName3c = "3c_Valide.txt";
        } else {
            // Fehler in Validierten Dateien --> invalide
            validFormat = false;
            fileName3c = "3c_Invalide.txt";
        }
        // outputFile3c = new File( directoryOfLogfile + fileName3c );
        outputFile3c = new File(pathToWorkDir + File.separator + fileName3c);
        try {
            outputFile3c.createNewFile();
        } catch (IOException e) {
            e.printStackTrace();
        }

        if (countNio == count) {
            // keine Dateien Validiert
            LOGGER.logError(kostval.getTextResourceService().getText(ERROR_INCORRECTFILEENDINGS, formatValOn));
            System.out
                    .println(kostval.getTextResourceService().getText(ERROR_INCORRECTFILEENDINGS, formatValOn));
        }

        LOGGER.logError(kostval.getTextResourceService().getText(MESSAGE_XML_FORMAT2));

        // Start Normale SIP-Validierung mit auswertung Format-Val. im 3c

        LOGGER.logError(kostval.getTextResourceService().getText(MESSAGE_XML_SIP1));
        valDatei = unSipFile;
        LOGGER.logError(kostval.getTextResourceService().getText(MESSAGE_XML_VALERGEBNIS));
        LOGGER.logError(kostval.getTextResourceService().getText(MESSAGE_XML_VALTYPE,
                kostval.getTextResourceService().getText(MESSAGE_SIPVALIDATION)));
        LOGGER.logError(kostval.getTextResourceService().getText(MESSAGE_XML_VALFILE,
                originalSipFile.getAbsolutePath()));
        System.out.println(kostval.getTextResourceService().getText(MESSAGE_SIPVALIDATION));
        System.out.println(originalSipFile.getAbsolutePath());

        Controllersip controller = (Controllersip) context.getBean("controllersip");
        boolean okMandatory = false;
        okMandatory = controller.executeMandatory(valDatei, directoryOfLogfile);
        boolean ok = false;

        /* die Validierungen 1a - 1d sind obligatorisch, wenn sie bestanden wurden, knnen die
         * restlichen Validierungen, welche nicht zum Abbruch der Applikation fhren, ausgefhrt
         * werden.
         * 
         * 1a wurde bereits getestet (vor der Formatvalidierung entsprechend fngt der Controller mit
         * 1b an */
        if (okMandatory) {
            ok = controller.executeOptional(valDatei, directoryOfLogfile);
        }
        // Formatvalidierung validFormat
        ok = (ok && okMandatory && validFormat);

        if (ok) {
            // Validiertes SIP valide
            LOGGER.logError(kostval.getTextResourceService().getText(MESSAGE_XML_VALERGEBNIS_VALID));
            LOGGER.logError(kostval.getTextResourceService().getText(MESSAGE_XML_VALERGEBNIS_CLOSE));
            System.out.println("Valid");
            System.out.println("");
        } else {
            // Fehler im Validierten SIP --> invalide
            LOGGER.logError(kostval.getTextResourceService().getText(MESSAGE_XML_VALERGEBNIS_INVALID));
            LOGGER.logError(kostval.getTextResourceService().getText(MESSAGE_XML_VALERGEBNIS_CLOSE));
            System.out.println("Invalid");
            System.out.println("");

        }

        // ggf. Fehlermeldung 3c ergnzen Util.val3c(summary3c, logFile );

        LOGGER.logError(kostval.getTextResourceService().getText(MESSAGE_XML_SIP2));

        LOGGER.logError(kostval.getTextResourceService().getText(MESSAGE_XML_LOGEND));
        // Zeitstempel End
        java.util.Date nowEnd = new java.util.Date();
        java.text.SimpleDateFormat sdfEnd = new java.text.SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
        String ausgabeEnd = sdfEnd.format(nowEnd);
        ausgabeEnd = "<End>" + ausgabeEnd + "</End>";
        Util.valEnd(ausgabeEnd, logFile);
        Util.val3c(summary3c, logFile);
        Util.amp(logFile);

        // Die Konfiguration hereinkopieren
        try {
            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            factory.setValidating(false);

            factory.setExpandEntityReferences(false);

            Document docConfig = factory.newDocumentBuilder().parse(configFile);
            NodeList list = docConfig.getElementsByTagName("configuration");
            Element element = (Element) list.item(0);

            Document docLog = factory.newDocumentBuilder().parse(logFile);

            Node dup = docLog.importNode(element, true);

            docLog.getDocumentElement().appendChild(dup);
            FileWriter writer = new FileWriter(logFile);

            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            ElementToStream(docLog.getDocumentElement(), baos);
            String stringDoc2 = new String(baos.toByteArray());
            writer.write(stringDoc2);
            writer.close();

            // Der Header wird dabei leider verschossen, wieder zurck ndern
            String newstring = kostval.getTextResourceService().getText(MESSAGE_XML_HEADER);
            String oldstring = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><KOSTValLog>";
            Util.oldnewstring(oldstring, newstring, logFile);

        } catch (Exception e) {
            LOGGER.logError(
                    "<Error>" + kostval.getTextResourceService().getText(ERROR_XML_UNKNOWN, e.getMessage()));
            System.out.println("Exception: " + e.getMessage());
        }

        // bestehendes Workverzeichnis ggf. lschen
        if (tmpDir.exists()) {
            Util.deleteDir(tmpDir);
        }
        StringBuffer command = new StringBuffer("rd " + tmpDir.getAbsolutePath() + " /s /q");

        try {
            // KaD-Diagnose-Datei mit den neusten Anzahl Dateien pro KaD-Format Updaten
            DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
            Document doc = dBuilder.parse(xmlDiaCopy);

            doc.getDocumentElement().normalize();

            NodeList nList = doc.getElementsByTagName("KOSTVal_FFCounter");

            for (int temp = 0; temp < nList.getLength(); temp++) {

                Node nNode = nList.item(temp);

                if (nNode.getNodeType() == Node.ELEMENT_NODE) {
                    Element eElement = (Element) nNode;

                    if (pdf > 0) {
                        String pdfNodeString = eElement.getElementsByTagName("pdf").item(0).getTextContent();
                        int pdfNodeValue = Integer.parseInt(pdfNodeString);
                        pdf = pdf + pdfNodeValue;
                        Util.kadDia("<pdf>" + pdfNodeValue + "</pdf>", "<pdf>" + pdf + "</pdf>", xmlDiaCopy);
                    }
                    if (tiff > 0) {
                        String tiffNodeString = eElement.getElementsByTagName("tiff").item(0).getTextContent();
                        int tiffNodeValue = Integer.parseInt(tiffNodeString);
                        tiff = tiff + tiffNodeValue;
                        Util.kadDia("<tiff>" + tiffNodeValue + "</tiff>", "<tiff>" + tiff + "</tiff>",
                                xmlDiaCopy);
                    }
                    if (siard > 0) {
                        String siardNodeString = eElement.getElementsByTagName("siard").item(0)
                                .getTextContent();
                        int siardNodeValue = Integer.parseInt(siardNodeString);
                        siard = siard + siardNodeValue;
                        Util.kadDia("<siard>" + siardNodeValue + "</siard>", "<siard>" + siard + "</siard>",
                                xmlDiaCopy);
                    }
                    if (txt > 0) {
                        String txtNodeString = eElement.getElementsByTagName("txt").item(0).getTextContent();
                        int txtNodeValue = Integer.parseInt(txtNodeString);
                        txt = txt + txtNodeValue;
                        Util.kadDia("<txt>" + txtNodeValue + "</txt>", "<txt>" + txt + "</txt>", xmlDiaCopy);
                    }
                    if (csv > 0) {
                        String csvNodeString = eElement.getElementsByTagName("csv").item(0).getTextContent();
                        int csvNodeValue = Integer.parseInt(csvNodeString);
                        csv = csv + csvNodeValue;
                        Util.kadDia("<csv>" + csvNodeValue + "</csv>", "<csv>" + csv + "</csv>", xmlDiaCopy);
                    }
                    if (xml > 0) {
                        String xmlNodeString = eElement.getElementsByTagName("xml").item(0).getTextContent();
                        int xmlNodeValue = Integer.parseInt(xmlNodeString);
                        xml = xml + xmlNodeValue;
                        Util.kadDia("<xml>" + xmlNodeValue + "</xml>", "<xml>" + xml + "</xml>", xmlDiaCopy);
                    }
                    if (xsd > 0) {
                        String xsdNodeString = eElement.getElementsByTagName("xsd").item(0).getTextContent();
                        int xsdNodeValue = Integer.parseInt(xsdNodeString);
                        xsd = xsd + xsdNodeValue;
                        Util.kadDia("<xsd>" + xsdNodeValue + "</xsd>", "<xsd>" + xsd + "</xsd>", xmlDiaCopy);
                    }
                    if (wave > 0) {
                        String waveNodeString = eElement.getElementsByTagName("wave").item(0).getTextContent();
                        int waveNodeValue = Integer.parseInt(waveNodeString);
                        wave = wave + waveNodeValue;
                        Util.kadDia("<wave>" + waveNodeValue + "</wave>", "<wave>" + wave + "</wave>",
                                xmlDiaCopy);
                    }
                    if (mp3 > 0) {
                        String mp3NodeString = eElement.getElementsByTagName("mp3").item(0).getTextContent();
                        int mp3NodeValue = Integer.parseInt(mp3NodeString);
                        mp3 = mp3 + mp3NodeValue;
                        Util.kadDia("<mp3>" + mp3NodeValue + "</mp3>", "<mp3>" + mp3 + "</mp3>", xmlDiaCopy);
                    }
                    if (jp2 > 0) {
                        String jp2NodeString = eElement.getElementsByTagName("jp2").item(0).getTextContent();
                        int jp2NodeValue = Integer.parseInt(jp2NodeString);
                        jp2 = jp2 + jp2NodeValue;
                        Util.kadDia("<jp2>" + jp2NodeValue + "</jp2>", "<jp2>" + jp2 + "</jp2>", xmlDiaCopy);
                    }
                    if (jpx > 0) {
                        String jpxNodeString = eElement.getElementsByTagName("jpx").item(0).getTextContent();
                        int jpxNodeValue = Integer.parseInt(jpxNodeString);
                        jpx = jpx + jpxNodeValue;
                        Util.kadDia("<jpx>" + jpxNodeValue + "</jpx>", "<jpx>" + jpx + "</jpx>", xmlDiaCopy);
                    }
                    if (jpeg > 0) {
                        String jpegNodeString = eElement.getElementsByTagName("jpeg").item(0).getTextContent();
                        int jpegNodeValue = Integer.parseInt(jpegNodeString);
                        jpeg = jpeg + jpegNodeValue;
                        Util.kadDia("<jpeg>" + jpegNodeValue + "</jpeg>", "<jpeg>" + jpeg + "</jpeg>",
                                xmlDiaCopy);
                    }
                    if (png > 0) {
                        String pngNodeString = eElement.getElementsByTagName("png").item(0).getTextContent();
                        int pngNodeValue = Integer.parseInt(pngNodeString);
                        png = png + pngNodeValue;
                        Util.kadDia("<png>" + pngNodeValue + "</png>", "<png>" + png + "</png>", xmlDiaCopy);
                    }
                    if (dng > 0) {
                        String dngNodeString = eElement.getElementsByTagName("dng").item(0).getTextContent();
                        int dngNodeValue = Integer.parseInt(dngNodeString);
                        dng = dng + dngNodeValue;
                        Util.kadDia("<dng>" + dngNodeValue + "</dng>", "<dng>" + dng + "</dng>", xmlDiaCopy);
                    }
                    if (svg > 0) {
                        String svgNodeString = eElement.getElementsByTagName("svg").item(0).getTextContent();
                        int svgNodeValue = Integer.parseInt(svgNodeString);
                        svg = svg + svgNodeValue;
                        Util.kadDia("<svg>" + svgNodeValue + "</svg>", "<svg>" + svg + "</svg>", xmlDiaCopy);
                    }
                    if (mpeg2 > 0) {
                        String mpeg2NodeString = eElement.getElementsByTagName("mpeg2").item(0)
                                .getTextContent();
                        int mpeg2NodeValue = Integer.parseInt(mpeg2NodeString);
                        mpeg2 = mpeg2 + mpeg2NodeValue;
                        Util.kadDia("<mpeg2>" + mpeg2NodeValue + "</mpeg2>", "<mpeg2>" + mpeg2 + "</mpeg2>",
                                xmlDiaCopy);
                    }
                    if (mp4 > 0) {
                        String mp4NodeString = eElement.getElementsByTagName("mp4").item(0).getTextContent();
                        int mp4NodeValue = Integer.parseInt(mp4NodeString);
                        mp4 = mp4 + mp4NodeValue;
                        Util.kadDia("<mp4>" + mp4NodeValue + "</mp4>", "<mp4>" + mp4 + "</mp4>", xmlDiaCopy);
                    }
                    if (xls > 0) {
                        String xlsNodeString = eElement.getElementsByTagName("xls").item(0).getTextContent();
                        int xlsNodeValue = Integer.parseInt(xlsNodeString);
                        xls = xls + xlsNodeValue;
                        Util.kadDia("<xls>" + xlsNodeValue + "</xls>", "<xls>" + xls + "</xls>", xmlDiaCopy);
                    }
                    if (odt > 0) {
                        String odtNodeString = eElement.getElementsByTagName("odt").item(0).getTextContent();
                        int odtNodeValue = Integer.parseInt(odtNodeString);
                        odt = odt + odtNodeValue;
                        Util.kadDia("<odt>" + odtNodeValue + "</odt>", "<odt>" + odt + "</odt>", xmlDiaCopy);
                    }
                    if (ods > 0) {
                        String odsNodeString = eElement.getElementsByTagName("ods").item(0).getTextContent();
                        int odsNodeValue = Integer.parseInt(odsNodeString);
                        ods = ods + odsNodeValue;
                        Util.kadDia("<ods>" + odsNodeValue + "</ods>", "<ods>" + ods + "</ods>", xmlDiaCopy);
                    }
                    if (odp > 0) {
                        String odpNodeString = eElement.getElementsByTagName("odp").item(0).getTextContent();
                        int odpNodeValue = Integer.parseInt(odpNodeString);
                        odp = odp + odpNodeValue;
                        Util.kadDia("<odp>" + odpNodeValue + "</odp>", "<odp>" + odp + "</odp>", xmlDiaCopy);
                    }
                    if (other > 0) {
                        String otherNodeString = eElement.getElementsByTagName("other").item(0)
                                .getTextContent();
                        int otherNodeValue = Integer.parseInt(otherNodeString);
                        other = other + otherNodeValue;
                        Util.kadDia("<other>" + otherNodeValue + "</other>", "<other>" + other + "</other>",
                                xmlDiaCopy);
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        if (ok) {
            // bestehendes Workverzeichnis ggf. lschen
            if (tmpDir.exists()) {
                Util.deleteDir(tmpDir);
            }
            if (tmpDir.exists()) {
                Runtime rt = Runtime.getRuntime();
                Process proc = rt.exec(command.toString());
            }
            System.exit(0);
        } else {
            // bestehendes Workverzeichnis ggf. lschen
            if (tmpDir.exists()) {
                Util.deleteDir(tmpDir);
            }
            if (tmpDir.exists()) {
                Runtime rt = Runtime.getRuntime();
                Process proc = rt.exec(command.toString());
            }
            System.exit(2);
        }
        LOGGER.logError(kostval.getTextResourceService().getText(MESSAGE_XML_SIP2));

    } else {
        /* Ueberprfung des Parameters (Val-Typ): format / sip args[0] ist nicht "--format" oder
         * "--sip" --> INVALIDE */
        LOGGER.logError(kostval.getTextResourceService().getText(ERROR_IOE,
                kostval.getTextResourceService().getText(ERROR_PARAMETER_USAGE)));
        System.out.println(kostval.getTextResourceService().getText(ERROR_PARAMETER_USAGE));
        if (tmpDir.exists()) {
            Util.deleteDir(tmpDir);
            tmpDir.deleteOnExit();
        }
        System.exit(1);
    }
}

From source file:net.neurowork.cenatic.centraldir.workers.XMLRestWorker.java

private Sector importSector(String xmlString, Integer id)
        throws ParserConfigurationException, SAXException, IOException {
    Document doc = XmlParserUtil.createDocumentFromString(xmlString);
    Sector ret = null;//  ww  w.  j a  va2  s.com
    NodeList nodeLst = doc.getElementsByTagName("sector");

    for (int s = 0; s < nodeLst.getLength(); s++) {
        Node fstNode = nodeLst.item(s);
        if (fstNode.getNodeType() == Node.ELEMENT_NODE) {
            Element elPDU = (Element) fstNode;
            String code = XmlParserUtil.getAttribute(elPDU, "code");
            NodeList fstNm = elPDU.getChildNodes();
            String sectorName = null;

            if (fstNm.getLength() > 0) {
                String tmp = ((Node) fstNm.item(0)).getNodeValue();
                byte[] utf8 = tmp.getBytes("UTF-8");
                sectorName = new String(utf8, "UTF-8");

                Integer capId = getId(code);
                Sector sector = null;
                try {
                    Collection<Sector> sectores = sectorService.findByName(sectorName);

                    if (sectores != null && sectores.size() > 0) {
                        sector = sectores.iterator().next();
                    } else {
                        sector = new Sector();
                        sector.setName(sectorName);
                        sectorService.save(sector);
                    }

                    if (capId != null && capId.equals(id)) {
                        ret = sector;
                    }
                } catch (ServiceException e) {
                    logger.error(e.getMessage());
                }
            }
        }
    }
    return ret;
}

From source file:org.esupportail.bigbluebutton.domain.DomainServiceImpl.java

@Override
public String createMeetingUrl(String meetingID, String meetingName, String welcome, String viewerPassword,
        String moderatorPassword, Integer voiceBridge, Boolean record, String username) {

    String base_url_create = BBBServerUrl + "api/create?";
    String base_url_join = BBBServerUrl + "api/join?";

    String welcome_param = "";
    String checksum = "";

    String attendee_password_param = "&attendeePW=" + viewerPassword;
    String moderator_password_param = "&moderatorPW=" + moderatorPassword;
    String voice_bridge_param = "";
    String logoutURL_param = "";
    String record_param = "";

    WebUtils utils = new WebUtils();

    if ((welcome != null) && !welcome.equals("")) {
        welcome_param = "&welcome=" + utils.urlEncode(welcome);
    }//  w  ww. j  a v a  2 s  .  co m

    if ((moderatorPassword != null) && !moderatorPassword.equals("")) {
        moderator_password_param = "&moderatorPW=" + utils.urlEncode(moderatorPassword);
    }

    if ((viewerPassword != null) && !viewerPassword.equals("")) {
        attendee_password_param = "&attendeePW=" + utils.urlEncode(viewerPassword);
    }

    if ((voiceBridge != null) && !voiceBridge.equals("")) {
        voice_bridge_param = "&voiceBridge=" + voiceBridge;
    }

    if ((BBBLogoutUrl != null) && !BBBLogoutUrl.equals("")) {
        logoutURL_param = "&logoutURL=" + utils.urlEncode(BBBLogoutUrl);
    }

    if ((record != null) && !record.equals("")) {
        record_param = "&record=" + record.toString();
    }

    //
    // Now create the URL
    //

    String create_parameters = "name=" + utils.urlEncode(meetingName) + "&meetingID="
            + utils.urlEncode(meetingID) + welcome_param + attendee_password_param + moderator_password_param
            + voice_bridge_param + record_param + logoutURL_param;

    String url = base_url_create + create_parameters + "&checksum="
            + utils.checksum("create" + create_parameters + BBBSecuritySalt);

    return url;
}

From source file:gov.nih.nci.cabig.caaers.web.ae.CreateAdverseEventAjaxFacade.java

public AjaxOutput editReviewComment(String comment, Integer commentId, String reportIdString) {
    Integer reportId = Integer.parseInt(reportIdString);
    //       ExpeditedAdverseEventInputCommand command = (ExpeditedAdverseEventInputCommand) extractCommand();
    String userId = getUserId();//  ww w  .j a v  a  2s  .c  o m
    Report report = null;
    if (reportId != null || !reportId.equals(""))
        report = reportDao.getById(reportId);
    //       Report report = null;
    //       for(Report r: command.getAeReport().getActiveReports())
    //          if(r.getId().equals(reportId))
    //             report = r;
    adverseEventRoutingAndReviewRepository.editReportReviewComment(report, comment, userId, commentId);
    return fetchPreviousComments(reportId, getUserId());
}