List of usage examples for java.util StringTokenizer hasMoreElements
public boolean hasMoreElements()
From source file:com.webcohesion.enunciate.modules.csharp_client.CSharpXMLClientModule.java
private File compileSources(File srcDir) { File compileDir = getCompileDir(); compileDir.mkdirs();/*from w ww .ja va 2 s . c o m*/ if (!isDisableCompile()) { if (!isUpToDateWithSources(compileDir)) { String compileExectuable = getCompileExecutable(); if (compileExectuable == null) { String osName = System.getProperty("os.name"); if (osName != null && osName.toUpperCase().contains("WINDOWS")) { //try the "csc" command on Windows environments. debug("Attempting to execute command \"csc /help\" for the current environment (%s).", osName); try { Process process = new ProcessBuilder("csc", "/help").redirectErrorStream(true).start(); InputStream in = process.getInputStream(); byte[] buffer = new byte[1024]; int len = in.read(buffer); while (len > -0) { len = in.read(buffer); } int exitCode = process.waitFor(); if (exitCode != 0) { debug("Command \"csc /help\" failed with exit code " + exitCode + "."); } else { compileExectuable = "csc"; debug("C# compile executable to be used: csc"); } } catch (Throwable e) { debug("Command \"csc /help\" failed (" + e.getMessage() + ")."); } } if (compileExectuable == null) { //try the "gmcs" command (Mono) debug("Attempting to execute command \"gmcs /help\" for the current environment (%s).", osName); try { Process process = new ProcessBuilder("gmcs", "/help").redirectErrorStream(true).start(); InputStream in = process.getInputStream(); byte[] buffer = new byte[1024]; int len = in.read(buffer); while (len > -0) { len = in.read(buffer); } int exitCode = process.waitFor(); if (exitCode != 0) { debug("Command \"gmcs /help\" failed with exit code " + exitCode + "."); } else { compileExectuable = "gmcs"; debug("C# compile executable to be used: %s", compileExectuable); } } catch (Throwable e) { debug("Command \"gmcs /help\" failed (" + e.getMessage() + ")."); } } if (compileExectuable == null && isRequire()) { throw new EnunciateException( "C# client code generation is required, but there was no valid compile executable found. " + "Please supply one in the configuration file, or set it up on your system path."); } } String compileCommand = getCompileCommand(); if (compileCommand == null) { throw new IllegalStateException( "Somehow the \"compile\" step was invoked on the C# module without a valid compile command."); } compileCommand = compileCommand.replace(' ', '\0'); //replace all spaces with the null character, so the command can be tokenized later. File dll = new File(compileDir, getDLLFileName()); File docXml = new File(compileDir, getDocXmlFileName()); File sourceFile = new File(srcDir, getSourceFileName()); compileCommand = String.format(compileCommand, compileExectuable, dll.getAbsolutePath(), docXml.getAbsolutePath(), sourceFile.getAbsolutePath()); StringTokenizer tokenizer = new StringTokenizer(compileCommand, "\0"); //tokenize on the null character to preserve the spaces in the command. List<String> command = new ArrayList<String>(); while (tokenizer.hasMoreElements()) { command.add((String) tokenizer.nextElement()); } try { Process process = new ProcessBuilder(command).redirectErrorStream(true).directory(compileDir) .start(); BufferedReader procReader = new BufferedReader(new InputStreamReader(process.getInputStream())); String line = procReader.readLine(); while (line != null) { info(line); line = procReader.readLine(); } int procCode; try { procCode = process.waitFor(); } catch (InterruptedException e1) { throw new EnunciateException("Unexpected inturruption of the C# compile process."); } if (procCode != 0) { throw new EnunciateException("C# compile failed."); } } catch (IOException e) { throw new EnunciateException(e); } FileArtifact assembly = new FileArtifact(getName(), "csharp.assembly", dll); assembly.setPublic(false); enunciate.addArtifact(assembly); if (docXml.exists()) { FileArtifact docs = new FileArtifact(getName(), "csharp.docs.xml", docXml); docs.setPublic(false); enunciate.addArtifact(docs); } } else { info("Skipping C# compile because everything appears up-to-date."); } } else { debug("Skipping C# compile because a compile executable was neither found nor provided. The C# bundle will only include the sources."); } return compileDir; }
From source file:org.forgerock.openam.forgerockrest.RestDispatcher.java
/** * Parse Realm Path, Resource Name, and Resource ID * * @return Map containing realmPath, resourceName, and resourceID * @throws NotFoundException when configuration manager cannot retrieve a realm *//*from w w w . j a v a 2s .co m*/ public Map<String, String> getRequestDetails(String resourceName) throws NotFoundException { Map<String, String> details = new HashMap<String, String>(3); if (StringUtils.isBlank(resourceName)) { return null; } StringTokenizer tokenizer = new StringTokenizer(resourceName.trim(), "/", false); boolean topLevel = true; String lastNonBlank = null; String lastNonBlankID = null; String tmp = null; StringBuilder realmPath = new StringBuilder("/"); // fqdn path to resource StringBuilder resourceID = null; // resource id StringBuilder endpoint = null; // defined endpoint OrganizationConfigManager ocm = null; try { ocm = new OrganizationConfigManager(getSSOToken(), realmPath.toString()); } catch (SMSException smse) { throw new NotFoundException(smse.getMessage(), smse); } while (tokenizer.hasMoreElements()) { String next = tokenizer.nextToken(); if (StringUtils.isNotBlank(next)) { if (null != lastNonBlank) { try { // test to see if its a realm if (realmPath.toString().equalsIgnoreCase("/") && topLevel) { ocm = new OrganizationConfigManager(getSSOToken(), realmPath.toString() + lastNonBlank); realmPath.append(lastNonBlank); topLevel = false; } else { ocm = new OrganizationConfigManager(getSSOToken(), realmPath.toString() + "/" + lastNonBlank); realmPath.append("/").append(lastNonBlank); } ocm = new OrganizationConfigManager(getSSOToken(), realmPath.toString()); } catch (SMSException smse) { // cannot retrieve realm, must be endpoint debug.warning(next + "is the endpoint because it is not a realm"); endpoint = new StringBuilder("/"); endpoint.append(lastNonBlank); if (!checkValidEndpoint(endpoint.toString())) { debug.warning(endpoint.toString() + "is the endpoint because it is not a realm"); throw new NotFoundException( "Endpoint " + endpoint.toString() + " is not a defined endpoint."); } // add the rest of tokens as resource name lastNonBlankID = next; while (tokenizer.hasMoreElements()) { next = tokenizer.nextToken(); if (StringUtils.isNotBlank(next)) { if (null != lastNonBlankID) { if (null == resourceID) { resourceID = new StringBuilder(lastNonBlankID); } else { resourceID.append("/").append(lastNonBlankID); } } lastNonBlankID = next; } } } } lastNonBlank = next; } } details.put("realmPath", realmPath.toString()); if (null != endpoint && !endpoint.toString().isEmpty()) { details.put("resourceName", endpoint.toString()); } else { endpoint = new StringBuilder("/"); details.put("resourceName", endpoint.append(lastNonBlank).toString()); } if (null != resourceID) { details.put("resourceId", resourceID.append("/").append(lastNonBlankID).toString()); } else if (null != lastNonBlank) { details.put("resourceId", lastNonBlankID); } else { throw new NotFoundException("Resource ID has not been provided."); } return details; }
From source file:org.apache.cloudstack.storage.datastore.util.SolidFireUtil.java
public static String getValue(String keyToMatch, String url, boolean throwExceptionIfNotFound) { String delimiter1 = ";"; String delimiter2 = "="; StringTokenizer st = new StringTokenizer(url, delimiter1); while (st.hasMoreElements()) { String token = st.nextElement().toString(); int index = token.indexOf(delimiter2); if (index == -1) { throw new RuntimeException("Invalid URL format"); }/*from w w w . jav a 2s .c o m*/ String key = token.substring(0, index); if (key.equalsIgnoreCase(keyToMatch)) { String valueToReturn = token.substring(index + delimiter2.length()); return valueToReturn; } } if (throwExceptionIfNotFound) { throw new RuntimeException("Key not found in URL"); } return null; }
From source file:org.apache.cloudstack.storage.datastore.util.SolidFireUtil.java
public static String getModifiedUrl(String originalUrl) { StringBuilder sb = new StringBuilder(); String delimiter = ";"; StringTokenizer st = new StringTokenizer(originalUrl, delimiter); while (st.hasMoreElements()) { String token = st.nextElement().toString().toUpperCase(); if (token.startsWith(SolidFireUtil.MANAGEMENT_VIP.toUpperCase()) || token.startsWith(SolidFireUtil.STORAGE_VIP.toUpperCase())) { sb.append(token).append(delimiter); }/*from w w w . j ava 2 s . co m*/ } String modifiedUrl = sb.toString(); int lastIndexOf = modifiedUrl.lastIndexOf(delimiter); if (lastIndexOf == (modifiedUrl.length() - delimiter.length())) { return modifiedUrl.substring(0, lastIndexOf); } return modifiedUrl; }
From source file:org.mifos.customers.client.struts.actionforms.ClientCustActionForm.java
public String removeSpaces(String s) { StringTokenizer st = new StringTokenizer(s, " ", false); String t = ""; while (st.hasMoreElements()) { t += st.nextElement();/* w w w . j av a2 s. co m*/ } return t; }
From source file:eu.aniketos.scpm.impl.CompositionPlanner.java
private ICompositionPlan orderAtRuntime(List<ICompositionPlan> securedCompositions, IConsumerPolicy consumerPolicy) { try {// w ww. j a v a2 s . co m System.out.println("Connecting to SPDM"); URL spdmurl = new URL(URL_SPDM); } catch (MalformedURLException e) { //System.out.println(e.getMessage()); e.printStackTrace(); } String commentCriteria = consumerPolicy.getXML(); //System.out.println(commentCriteria); int j = commentCriteria.indexOf("<!--orderCriteria"); int k = commentCriteria.indexOf("-->"); if (k > j)//if the order criteria indeed saved in the consumer policy { commentCriteria = commentCriteria.substring(j, k - 1); } else commentCriteria = "<!--orderCriteria Trustworthiness 1 Credibility 1 Validness 1 -->"; OrderCriteria criteria = new OrderCriteria(); ICompositionPlan bestComposition = new CompositionPlan(""); StringTokenizer st = new StringTokenizer(commentCriteria); while (st.hasMoreElements()) { String temp = st.nextToken(); if (temp.equals("Trustworthiness")) criteria.addCriterion("Trustworthiness", st.nextToken()); else if (temp.equals("Credibility")) criteria.addCriterion("Credibility", st.nextToken()); else if (temp.equals("Validness")) criteria.addCriterion("Validness", st.nextToken()); } try { String value = criteria.getCriteria().get("Trustworthiness"); System.out.println("trustworthiness:" + value); value = criteria.getCriteria().get("Credibility"); System.out.println("Credibility:" + value); value = criteria.getCriteria().get("Validness"); System.out.println("validness:" + value); double maxValue = 0; for (int index = 0; index < securedCompositions.size(); index++) { double overallValue = getOrderValue(securedCompositions.get(index), criteria); String compositionID = securedCompositions.get(index).getCompositionPlanID(); System.out.println("Overall value of " + compositionID + ": " + overallValue); if (overallValue >= maxValue) { maxValue = overallValue; bestComposition = securedCompositions.get(index); } } } catch (Exception e) { System.out.println(e.getMessage()); //e.printStackTrace(); } return bestComposition; }
From source file:org.netbeans.nbbuild.MakeJnlp2.java
private void processExtensions(File f, Manifest mf, Writer fileWriter, String dashcnb, String codebase, String permissions) throws IOException, BuildException { File nblibJar = new File(new File(new File(f.getParentFile().getParentFile(), "ant"), "nblib"), dashcnb + ".jar"); if (nblibJar.isFile()) { File ext = new File(new File(targetFile, dashcnb), "ant-nblib-" + nblibJar.getName()); fileWriter.write(constructJarHref(ext, dashcnb)); signOrCopy(nblibJar, ext);//from w w w . j a v a2s . c o m } String path = mf.getMainAttributes().getValue("Class-Path"); if (path == null) { return; } StringTokenizer tok = new StringTokenizer(path, ", "); while (tok.hasMoreElements()) { String s = tok.nextToken(); if (s.contains("${java.home}")) { continue; } File e = new File(f.getParentFile(), s); if (!e.canRead()) { throw new BuildException("Cannot read extension " + e + " referenced from " + f); } // if (optimize && checkDuplicate(e).isPresent()) { continue; } // String n = e.getName(); if (n.endsWith(".jar")) { n = n.substring(0, n.length() - 4); } File ext = new File(new File(targetFile, dashcnb), s.replace("../", "").replace('/', '-')); if (isSigned(e) != null) { signOrCopy(e, ext); // Copy copy = (Copy)getProject().createTask("copy"); // copy.setFile(e); // copy.setTofile(ext); // copy.execute(); String extJnlpName = dashcnb + '-' + ext.getName().replaceFirst("\\.jar$", "") + ".jnlp"; File jnlp = new File(targetFile, extJnlpName); FileWriter writeJNLP = new FileWriter(jnlp); writeJNLP.write("<?xml version='1.0' encoding='UTF-8'?>\n"); writeJNLP.write( "<!DOCTYPE jnlp PUBLIC \"-//Sun Microsystems, Inc//DTD JNLP Descriptor 6.0//EN\" \"http://java.sun.com/dtd/JNLP-6.0.dtd\">\n"); writeJNLP.write("<jnlp spec='1.0+' codebase='" + codebase + "'>\n"); writeJNLP.write(" <information>\n"); writeJNLP.write(" <title>" + n + "</title>\n"); writeJNLP.write(" <vendor>NetBeans</vendor>\n"); writeJNLP.write(" </information>\n"); writeJNLP.write(permissions + "\n"); writeJNLP.write(" <resources>\n"); writeJNLP .write("<property name=\"jnlp.packEnabled\" value=\"" + String.valueOf(pack200) + "\"/>\n"); writeJNLP.write(constructJarHref(ext, dashcnb)); writeJNLP.write(" </resources>\n"); writeJNLP.write(" <component-desc/>\n"); writeJNLP.write("</jnlp>\n"); writeJNLP.close(); fileWriter.write(" <extension name='" + e.getName().replaceFirst("\\.jar$", "") + "' href='" + extJnlpName + "'/>\n"); } else { signOrCopy(e, ext); fileWriter.write(constructJarHref(ext, dashcnb)); } } }
From source file:com.moviejukebox.scanner.MovieFilenameScanner.java
private MovieFilenameScanner(File file) { // CHECK FOR USE_PARENT_PATTERN matches if (useParentRegex && USE_PARENT_PATTERN.matcher(file.getName()).find()) { // Check the container to see if it's a RAR file and go up a further directory String rarExtensionCheck; try {//from w ww. j a v a 2 s . com rarExtensionCheck = file.getParentFile().getName().toLowerCase(); } catch (Exception error) { rarExtensionCheck = Movie.UNKNOWN; } if (ARCHIVE_SCAN_RAR && RAR_EXT_PATTERN.matcher(rarExtensionCheck).find()) { // We need to go up two parent directories this.file = file.getParentFile().getParentFile(); } else { // Just go up one parent directory. this.file = file.getParentFile(); } LOG.debug("UseParentPattern matched for {} - Using parent folder name: {}", file.getName(), this.file.getName()); } else { this.file = file; } this.filename = this.file.getName(); rest = filename; LOG.trace("Processing filename: '{}'", rest); // EXTENSION AND CONTAINER if (this.file.isFile()) { // Extract and strip extension String ext = FilenameUtils.getExtension(rest); if (ext.length() > 0) { rest = FilenameUtils.removeExtension(rest); } dto.setExtension(ext); dto.setContainer(dto.getExtension().toUpperCase()); } else { // For DVD images // no extension dto.setExtension(""); dto.setContainer("DVD"); dto.setVideoSource("DVD"); } rest = cleanUp(rest); LOG.trace("After Extension: '{}'", rest); // Detect incomplete filenames and add parent folder name to parser for (Pattern pattern : PARENT_FOLDER_PART_PATTERNS) { final Matcher matcher = pattern.matcher(rest); if (matcher.find()) { final File folder = this.file.getParentFile(); if (folder == null) { break; } rest = cleanUp(folder.getName()) + "./." + rest; break; } } LOG.trace("After incomplete filename: '{}'", rest); // Remove version info for (Pattern pattern : MOVIE_VERSION_PATTERNS) { rest = pattern.matcher(rest).replaceAll("./."); } LOG.trace("After version info: '{}'", rest); // EXTRAS (Including Trailers) { for (Pattern pattern : EXTRAS_PATTERNS) { Matcher matcher = pattern.matcher(rest); if (matcher.find()) { dto.setExtra(Boolean.TRUE); dto.setPartTitle(matcher.group(1)); rest = cutMatch(rest, matcher, "./EXTRA/."); break; } } } LOG.trace("After Extras: '{}'", rest); dto.setFps(seekPatternAndUpdateRest(FPS_MAP, dto.getFps())); dto.setAudioCodec(seekPatternAndUpdateRest(AUDIO_CODEC_MAP, dto.getAudioCodec())); dto.setVideoCodec(seekPatternAndUpdateRest(VIDEO_CODEC_MAP, dto.getVideoCodec())); dto.setHdResolution(seekPatternAndUpdateRest(HD_RESOLUTION_MAP, dto.getHdResolution())); dto.setVideoSource(seekPatternAndUpdateRest(VIDEO_SOURCE_MAP, dto.getVideoSource(), PART_PATTERNS)); // SEASON + EPISODES { final Matcher matcher = TV_PATTERN.matcher(rest); if (matcher.find()) { if ("720".equals(matcher.group(1)) || "1080".equals(matcher.group(1)) || "2160".equals(matcher.group(1))) { LOG.trace("Skipping pattern detection of '{}' because it looks like a resolution", matcher.group(0)); } else { // logger.finest("It's a TV Show: " + group0); rest = cutMatch(rest, matcher, "./TVSHOW/."); final Matcher smatcher = SEASON_PATTERN.matcher(matcher.group(0)); smatcher.find(); int season = Integer.parseInt(smatcher.group(1)); dto.setSeason(season); final Matcher ematcher = EPISODE_PATTERN.matcher(matcher.group(0)); while (ematcher.find()) { dto.getEpisodes().add(Integer.parseInt(ematcher.group(1))); } } } } LOG.trace("After season & episode: '{}'", rest); // PART { for (Pattern pattern : PART_PATTERNS) { Matcher matcher = pattern.matcher(rest); if (matcher.find()) { rest = cutMatch(rest, matcher, " /PART/ "); dto.setPart(Integer.parseInt(matcher.group(1))); break; } } } LOG.trace("After Part: '{}'", rest); // SETS { for (;;) { final Matcher matcher = SET_PATTERN.matcher(rest); if (!matcher.find()) { break; } rest = cutMatch(rest, matcher, Movie.SPACE_SLASH_SPACE); MovieFileNameDTO.SetDTO set = new MovieFileNameDTO.SetDTO(); dto.getSets().add(set); String n = matcher.group(1); Matcher nmatcher = SET_INDEX_PATTERN.matcher(n); if (nmatcher.find()) { set.setIndex(Integer.parseInt(nmatcher.group(1))); n = cutMatch(n, nmatcher); } set.setTitle(n.trim()); } } LOG.trace("After Sets: '{}'", rest); // Movie ID detection { Matcher matcher = ID_PATTERN.matcher(rest); if (matcher.find()) { rest = cutMatch(rest, matcher, " /ID/ "); String[] idString = matcher.group(1).split("[-\\s+]"); if (idString.length == 2) { dto.setId(idString[0].toLowerCase(), idString[1]); } else { LOG.debug("Error decoding ID from filename: {}", matcher.group(1)); } } else { matcher = IMDB_PATTERN.matcher(rest); if (matcher.find()) { rest = cutMatch(rest, matcher, " /ID/ "); dto.setId(ImdbPlugin.IMDB_PLUGIN_ID, matcher.group(1)); } } } LOG.trace("After Movie ID: '{}'", rest); // LANGUAGES if (languageDetection) { for (;;) { String language = seekPatternAndUpdateRest(STRICT_LANGUAGE_MAP, null); if (language == null) { break; } dto.getLanguages().add(language); } } LOG.trace("After languages: '{}'", rest); // TITLE { int iextra = dto.isExtra() ? rest.indexOf("/EXTRA/") : rest.length(); int itvshow = dto.getSeason() >= 0 ? rest.indexOf("/TVSHOW/") : rest.length(); int ipart = dto.getPart() >= 0 ? rest.indexOf("/PART/") : rest.length(); { int min = iextra < itvshow ? iextra : itvshow; min = min < ipart ? min : ipart; // Find first token before trailer, TV show and part // Name should not start with '-' (exclude wrongly marked part/episode titles) String title = ""; StringTokenizer t = new StringTokenizer(rest.substring(0, min), "/[]"); while (t.hasMoreElements()) { String token = t.nextToken(); token = cleanUpTitle(token); if (token.length() >= 1 && token.charAt(0) != '-') { title = token; break; } } boolean first = Boolean.TRUE; while (t.hasMoreElements()) { String token = t.nextToken(); token = cleanUpTitle(token); // Search year (must be next to a non-empty token) if (first) { if (token.length() > 0) { try { int year = Integer.parseInt(token); if (year >= 1800 && year <= 3000) { dto.setYear(year); } } catch (NumberFormatException error) { /* ignore */ } } first = Boolean.FALSE; } if (!languageDetection) { break; } // Loose language search if (token.length() >= 2 && token.indexOf('-') < 0) { for (Map.Entry<String, Pattern> e : LOOSE_LANGUAGE_MAP.entrySet()) { Matcher matcher = e.getValue().matcher(token); if (matcher.find()) { dto.getLanguages().add(e.getKey()); } } } } // Search year within title (last 4 digits or 4 digits in parenthesis) if (dto.getYear() < 0) { Matcher ymatcher = MOVIE_YEAR_PATTERN.matcher(title); if (ymatcher.find()) { int year = Integer.parseInt(ymatcher.group(1)); if (year >= 1919 && year <= 2099) { dto.setYear(year); title = cutMatch(title, ymatcher); } } } dto.setTitle(title); } // EPISODE TITLE if (dto.getSeason() >= 0) { itvshow += 8; Matcher matcher = SECOND_TITLE_PATTERN.matcher(rest.substring(itvshow)); while (matcher.find()) { String title = cleanUpTitle(matcher.group(1)); if (title.length() > 0) { if (SKIP_EP_TITLE) { dto.setEpisodeTitle(Movie.UNKNOWN); } else { dto.setEpisodeTitle(title); } break; } } } // PART TITLE if (dto.getPart() >= 0) { // Just do this for no extra, already named. if (!dto.isExtra()) { ipart += 6; Matcher matcher = SECOND_TITLE_PATTERN.matcher(rest.substring(ipart)); while (matcher.find()) { String title = cleanUpTitle(matcher.group(1)); if (title.length() > 0) { dto.setPartTitle(title); break; } } } } } LOG.trace("Final: {}", dto.toString()); }
From source file:us.mn.state.health.lims.qaevent.action.QaEventsEntryUpdateAction.java
protected ActionForward performAction(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String forward = FWD_SUCCESS; request.setAttribute(ALLOW_EDITS_KEY, "true"); request.setAttribute(PREVIOUS_DISABLED, "true"); request.setAttribute(NEXT_DISABLED, "true"); BaseActionForm dynaForm = (BaseActionForm) form; String accessionNumber = (String) dynaForm.get("accessionNumber"); String[] selectedAnalysisQaEventIdsForCompletion = (String[]) dynaForm .get("selectedAnalysisQaEventIdsForCompletion"); List testQaEvents = (List) dynaForm.get("testQaEvents"); //bugzilla 2500 String[] selectedSampleQaEventIdsForCompletion = (String[]) dynaForm .get("selectedSampleQaEventIdsForCompletion"); List sampleQaEvents = (List) dynaForm.get("sampleQaEvents"); //bugzilla 2566 for now qa events is for both humand and newborn //bugzilla 2501 String multipleSampleMode = (String) dynaForm.get("multipleSampleMode"); String qaEventCategoryId = (String) dynaForm.get("selectedQaEventsCategoryId"); //bugzilla 2500 String addQaEventPopupSelectedQaEventIdsForSample = (String) dynaForm .get("addQaEventPopupSelectedQaEventIdsForSample"); StringTokenizer qaEventIdTokenizerForSample = new StringTokenizer( addQaEventPopupSelectedQaEventIdsForSample, SystemConfiguration.getInstance().getDefaultIdSeparator()); List listOfAddedQaEventIdsForSample = new ArrayList(); while (qaEventIdTokenizerForSample.hasMoreElements()) { String qaEventIdForSample = (String) qaEventIdTokenizerForSample.nextElement(); listOfAddedQaEventIdsForSample.add(qaEventIdForSample); }//from w w w .j ava 2 s . c o m String addActionSelectedActionIdsForSample = (String) dynaForm .get("addActionPopupSelectedActionIdsForSample"); String addActionSelectedSampleQaEventIds = (String) dynaForm.get("addActionPopupSelectedSampleQaEventIds"); StringTokenizer actionIdTokenizerForSample = new StringTokenizer(addActionSelectedActionIdsForSample, SystemConfiguration.getInstance().getDefaultIdSeparator()); List listOfAddedActionIdsForSample = new ArrayList(); while (actionIdTokenizerForSample.hasMoreElements()) { String actionIdForSample = (String) actionIdTokenizerForSample.nextElement(); listOfAddedActionIdsForSample.add(actionIdForSample); } StringTokenizer sampleQaEventIdTokenizer = new StringTokenizer(addActionSelectedSampleQaEventIds, SystemConfiguration.getInstance().getDefaultIdSeparator()); List listOfSampleQaEventIds = new ArrayList(); while (sampleQaEventIdTokenizer.hasMoreElements()) { String sampleQaEventId = (String) sampleQaEventIdTokenizer.nextElement(); listOfSampleQaEventIds.add(sampleQaEventId); } //end bugzilla 2500 String addQaEventSelectedTestIds = (String) dynaForm.get("addQaEventPopupSelectedTestIds"); String addQaEventSelectedQaEventIds = (String) dynaForm.get("addQaEventPopupSelectedQaEventIds"); StringTokenizer testIdTokenizer = new StringTokenizer(addQaEventSelectedTestIds, SystemConfiguration.getInstance().getDefaultIdSeparator()); List listOfTestIds = new ArrayList(); while (testIdTokenizer.hasMoreElements()) { String testId = (String) testIdTokenizer.nextElement(); listOfTestIds.add(testId); } StringTokenizer qaEventIdTokenizer = new StringTokenizer(addQaEventSelectedQaEventIds, SystemConfiguration.getInstance().getDefaultIdSeparator()); List listOfAddedQaEventIds = new ArrayList(); while (qaEventIdTokenizer.hasMoreElements()) { String qaEventId = (String) qaEventIdTokenizer.nextElement(); listOfAddedQaEventIds.add(qaEventId); } String addActionSelectedActionIds = (String) dynaForm.get("addActionPopupSelectedActionIds"); String addActionSelectedAnalysisQaEventIds = (String) dynaForm .get("addActionPopupSelectedAnalysisQaEventIds"); StringTokenizer actionIdTokenizer = new StringTokenizer(addActionSelectedActionIds, SystemConfiguration.getInstance().getDefaultIdSeparator()); List listOfActionIds = new ArrayList(); while (actionIdTokenizer.hasMoreElements()) { String actionId = (String) actionIdTokenizer.nextElement(); listOfActionIds.add(actionId); } StringTokenizer analysisQaEventIdTokenizer = new StringTokenizer(addActionSelectedAnalysisQaEventIds, SystemConfiguration.getInstance().getDefaultIdSeparator()); List listOfAnalysisQaEventIds = new ArrayList(); while (analysisQaEventIdTokenizer.hasMoreElements()) { String analysisQaEventId = (String) analysisQaEventIdTokenizer.nextElement(); listOfAnalysisQaEventIds.add(analysisQaEventId); } // server side validation of accessionNumber // validate on server-side sample accession number ActionMessages errors = null; try { errors = new ActionMessages(); errors = validateAccessionNumber(request, errors, dynaForm); } catch (Exception e) { //bugzilla 2154 LogEvent.logError("QaEventsEntryUpdateAction", "performAction()", e.toString()); ActionError error = new ActionError("errors.ValidationException", null, null); errors.add(ActionMessages.GLOBAL_MESSAGE, error); } if (errors != null && errors.size() > 0) { saveErrors(request, errors); return mapping.findForward(FWD_FAIL); } // initialize the form dynaForm.initialize(mapping); // 1926 get sysUserId from login module UserSessionData usd = (UserSessionData) request.getSession().getAttribute(USER_SESSION_DATA); String sysUserId = String.valueOf(usd.getSystemUserId()); //bugzilla 2481 Action Owner SystemUser systemUser = new SystemUser(); systemUser.setId(sysUserId); SystemUserDAO systemUserDAO = new SystemUserDAOImpl(); systemUserDAO.getData(systemUser); Date today = Calendar.getInstance().getTime(); Locale locale = (Locale) request.getSession().getAttribute("org.apache.struts.action.LOCALE"); String dateAsText = DateUtil.formatDateAsText(today, locale); org.hibernate.Transaction tx = HibernateUtil.getSession().beginTransaction(); AnalysisQaEventDAO analysisQaEventDAO = new AnalysisQaEventDAOImpl(); SampleDAO sampleDAO = new SampleDAOImpl(); SampleItemDAO sampleItemDAO = new SampleItemDAOImpl(); AnalysisDAO analysisDAO = new AnalysisDAOImpl(); QaEventDAO qaEventDAO = new QaEventDAOImpl(); ActionDAO actionDAO = new ActionDAOImpl(); AnalysisQaEventActionDAO analysisQaEventActionDAO = new AnalysisQaEventActionDAOImpl(); //bugzilla 2501 SampleQaEventDAO sampleQaEventDAO = new SampleQaEventDAOImpl(); SampleQaEventActionDAO sampleQaEventActionDAO = new SampleQaEventActionDAOImpl(); if (!StringUtil.isNullorNill(accessionNumber)) { try { //bugzilla 2500 first update completed dates for sample if (selectedSampleQaEventIdsForCompletion != null && selectedSampleQaEventIdsForCompletion.length > 0) { for (int i = 0; i < selectedSampleQaEventIdsForCompletion.length; i++) { String sampleQaEventId = selectedSampleQaEventIdsForCompletion[i]; SampleQaEvent sampleQaEvent = new SampleQaEvent(); sampleQaEvent.setId(sampleQaEventId); sampleQaEventDAO.getData(sampleQaEvent); if (sampleQaEvent.getCompletedDate() == null) { sampleQaEvent.setCompletedDateForDisplay(dateAsText); sampleQaEvent.setSysUserId(sysUserId); sampleQaEventDAO.updateData(sampleQaEvent); } } } //first update completed dates if (selectedAnalysisQaEventIdsForCompletion != null && selectedAnalysisQaEventIdsForCompletion.length > 0) { for (int i = 0; i < selectedAnalysisQaEventIdsForCompletion.length; i++) { String analysisQaEventId = selectedAnalysisQaEventIdsForCompletion[i]; AnalysisQaEvent analysisQaEvent = new AnalysisQaEvent(); analysisQaEvent.setId(analysisQaEventId); analysisQaEventDAO.getData(analysisQaEvent); if (analysisQaEvent.getCompletedDate() == null) { analysisQaEvent.setCompletedDateForDisplay(dateAsText); analysisQaEvent.setSysUserId(sysUserId); analysisQaEventDAO.updateData(analysisQaEvent); } } } //bug 2500 now check if we added new Qa Events for sample if (listOfAddedQaEventIdsForSample != null && listOfAddedQaEventIdsForSample.size() > 0) { Sample sample = new Sample(); sample.setAccessionNumber(accessionNumber); sampleDAO.getSampleByAccessionNumber(sample); if (!StringUtil.isNullorNill(sample.getId())) { //insert all qaEvents selected for this sample if doesn't exist already for (int j = 0; j < listOfAddedQaEventIdsForSample.size(); j++) { //if this doesn't exist in in SAMPLE_QAEVENT already then insert it QaEvent qaEvent = new QaEvent(); qaEvent.setId((String) listOfAddedQaEventIdsForSample.get(j)); qaEventDAO.getData(qaEvent); if (qaEvent != null) { SampleQaEvent sampleQaEvent = new SampleQaEvent(); sampleQaEvent.setSample(sample); sampleQaEvent.setQaEvent(qaEvent); sampleQaEvent = sampleQaEventDAO.getSampleQaEventBySampleAndQaEvent(sampleQaEvent); if (sampleQaEvent != null) { //do nothing } else { //insert this new analysis qa event sampleQaEvent = new SampleQaEvent(); sampleQaEvent.setSample(sample); sampleQaEvent.setQaEvent(qaEvent); sampleQaEvent.setSysUserId(sysUserId); sampleQaEventDAO.insertData(sampleQaEvent); } } } } } //now check if we added new Actions if (listOfSampleQaEventIds != null && listOfSampleQaEventIds.size() > 0 && listOfAddedActionIdsForSample != null && listOfAddedActionIdsForSample.size() > 0) { Sample sample = new Sample(); sample.setAccessionNumber(accessionNumber); sampleDAO.getSampleByAccessionNumber(sample); if (!StringUtil.isNullorNill(sample.getId())) { SampleQaEvent sampleQaEvent = new SampleQaEvent(); sampleQaEvent.setSample(sample); sampleQaEvents = sampleQaEventDAO.getSampleQaEventsBySample(sampleQaEvent); for (int j = 0; j < sampleQaEvents.size(); j++) { SampleQaEvent sampQaEvent = (SampleQaEvent) sampleQaEvents.get(j); if (listOfSampleQaEventIds.contains(sampQaEvent.getId())) { for (int k = 0; k < listOfAddedActionIdsForSample.size(); k++) { Action action = new Action(); action.setId((String) listOfAddedActionIdsForSample.get(k)); actionDAO.getData(action); //if this analysis qa event action doesn't already exist in ANALYSIS_QA_EVENT_ACTION then insert it if (action != null) { SampleQaEventAction sampQaEventAction = new SampleQaEventAction(); sampQaEventAction.setAction(action); sampQaEventAction.setSampleQaEvent(sampQaEvent); sampQaEventAction = sampleQaEventActionDAO .getSampleQaEventActionBySampleQaEventAndAction(sampQaEventAction); if (sampQaEventAction != null) { //do nothing if already exists } else { //insert this new analysis qa event action sampQaEventAction = new SampleQaEventAction(); sampQaEventAction.setSampleQaEvent(sampQaEvent); sampQaEventAction.setAction(action); sampQaEventAction.setCreatedDateForDisplay(dateAsText); sampQaEventAction.setSysUserId(sysUserId); //bugzilla 2481 sampQaEventAction.setSystemUser(systemUser); sampleQaEventActionDAO.insertData(sampQaEventAction); } } } } } } } //end 2500 //now check if we added new Qa Events if (listOfAddedQaEventIds != null && listOfAddedQaEventIds.size() > 0 && listOfTestIds != null && listOfTestIds.size() > 0) { Sample sample = new Sample(); sample.setAccessionNumber(accessionNumber); sampleDAO.getSampleByAccessionNumber(sample); List analyses = new ArrayList(); if (!StringUtil.isNullorNill(sample.getId())) { SampleItem sampleItem = new SampleItem(); sampleItem.setSample(sample); sampleItemDAO.getDataBySample(sampleItem); if (sampleItem.getId() != null) { //bugzilla 2227 analyses = analysisDAO.getMaxRevisionAnalysesBySample(sampleItem); } } if (analyses != null) { for (int i = 0; i < analyses.size(); i++) { Analysis analysis = (Analysis) analyses.get(i); if (listOfTestIds.contains(analysis.getTest().getId())) { //insert all qaEvents selected for this test if doesn't exist already for (int j = 0; j < listOfAddedQaEventIds.size(); j++) { //if this doesn't exist in in ANALYSIS_QAEVENT already then insert it QaEvent qaEvent = new QaEvent(); qaEvent.setId((String) listOfAddedQaEventIds.get(j)); qaEventDAO.getData(qaEvent); if (qaEvent != null) { AnalysisQaEvent analysisQaEvent = new AnalysisQaEvent(); analysisQaEvent.setAnalysis(analysis); analysisQaEvent.setQaEvent(qaEvent); analysisQaEvent = analysisQaEventDAO .getAnalysisQaEventByAnalysisAndQaEvent(analysisQaEvent); if (analysisQaEvent != null) { //do nothing } else { //insert this new analysis qa event analysisQaEvent = new AnalysisQaEvent(); analysisQaEvent.setAnalysis(analysis); analysisQaEvent.setQaEvent(qaEvent); analysisQaEvent.setSysUserId(sysUserId); analysisQaEventDAO.insertData(analysisQaEvent); } } } } } } } //now check if we added new Actions if (listOfAnalysisQaEventIds != null && listOfAnalysisQaEventIds.size() > 0 && listOfActionIds != null && listOfActionIds.size() > 0) { Sample sample = new Sample(); sample.setAccessionNumber(accessionNumber); sampleDAO.getSampleByAccessionNumber(sample); List analyses = new ArrayList(); if (!StringUtil.isNullorNill(sample.getId())) { SampleItem sampleItem = new SampleItem(); sampleItem.setSample(sample); sampleItemDAO.getDataBySample(sampleItem); if (sampleItem.getId() != null) { //bugzilla 2227 analyses = analysisDAO.getMaxRevisionAnalysesBySample(sampleItem); } } if (analyses != null) { for (int i = 0; i < analyses.size(); i++) { Analysis analysis = (Analysis) analyses.get(i); AnalysisQaEvent analysisQaEvent = new AnalysisQaEvent(); analysisQaEvent.setAnalysis(analysis); List analysisQaEvents = analysisQaEventDAO .getAnalysisQaEventsByAnalysis(analysisQaEvent); for (int j = 0; j < analysisQaEvents.size(); j++) { AnalysisQaEvent analQaEvent = (AnalysisQaEvent) analysisQaEvents.get(j); if (listOfAnalysisQaEventIds.contains(analQaEvent.getId())) { for (int k = 0; k < listOfActionIds.size(); k++) { Action action = new Action(); action.setId((String) listOfActionIds.get(k)); actionDAO.getData(action); //if this analysis qa event action doesn't already exist in ANALYSIS_QA_EVENT_ACTION then insert it if (action != null) { AnalysisQaEventAction analQaEventAction = new AnalysisQaEventAction(); analQaEventAction.setAction(action); analQaEventAction.setAnalysisQaEvent(analQaEvent); analQaEventAction = analysisQaEventActionDAO .getAnalysisQaEventActionByAnalysisQaEventAndAction( analQaEventAction); if (analQaEventAction != null) { //do nothing if already exists } else { //insert this new analysis qa event action analQaEventAction = new AnalysisQaEventAction(); analQaEventAction.setAnalysisQaEvent(analQaEvent); analQaEventAction.setAction(action); analQaEventAction.setCreatedDateForDisplay(dateAsText); analQaEventAction.setSysUserId(sysUserId); //bugzilla 2481 analQaEventAction.setSystemUser(systemUser); analysisQaEventActionDAO.insertData(analQaEventAction); } } } } } } } } tx.commit(); } catch (LIMSRuntimeException lre) { //bugzilla 2154 LogEvent.logError("QaEventsEntryUpdateAction", "performAction()", lre.toString()); tx.rollback(); errors = new ActionMessages(); ActionError error = null; if (lre.getException() instanceof org.hibernate.StaleObjectStateException) { error = new ActionError("errors.OptimisticLockException", null, null); } else { error = new ActionError("errors.UpdateException", null, null); } errors.add(ActionMessages.GLOBAL_MESSAGE, error); saveErrors(request, errors); request.setAttribute(Globals.ERROR_KEY, errors); forward = FWD_FAIL; } finally { HibernateUtil.closeSession(); } } PropertyUtils.setProperty(dynaForm, "accessionNumber", accessionNumber); PropertyUtils.setProperty(dynaForm, "selectedAnalysisQaEventIdsForCompletion", selectedAnalysisQaEventIdsForCompletion); //bugzilla 2500 PropertyUtils.setProperty(dynaForm, "selectedSampleQaEventIdsForCompletion", selectedSampleQaEventIdsForCompletion); //bugzilla 2566 for now qa events is for human and newborn //PropertyUtils.setProperty(dynaForm, "domain", domain); PropertyUtils.setProperty(dynaForm, "testQaEvents", testQaEvents); //bugzilla 2501 PropertyUtils.setProperty(dynaForm, "multipleSampleMode", multipleSampleMode); PropertyUtils.setProperty(dynaForm, "selectedQaEventsCategoryId", qaEventCategoryId); return mapping.findForward(forward); }
From source file:org.netbeans.nbbuild.MakeJnlp2.java
private Map<String, List<File>> verifyExtensions(File f, Manifest mf, String dashcnb, String codebasename, boolean verify, Set<String> indirectFilePaths) throws IOException, BuildException { Map<String, List<File>> localizedFiles = new HashMap<String, List<File>>(); File clusterRoot = f.getParentFile(); String moduleDirPrefix = ""; File updateTracking;// w w w . j av a 2 s. c o m log("Verifying extensions for: " + codebasename + ", cluster root: " + clusterRoot + ", verify: " + verify, Project.MSG_DEBUG); for (;;) { updateTracking = new File(clusterRoot, "update_tracking"); if (updateTracking.isDirectory()) { break; } moduleDirPrefix = clusterRoot.getName() + "/" + moduleDirPrefix; clusterRoot = clusterRoot.getParentFile(); if (clusterRoot == null || !clusterRoot.exists()) { if (!verify) { return localizedFiles; } throw new BuildException("Cannot find update_tracking directory for module " + f); } } File ut = new File(updateTracking, dashcnb + ".xml"); if (!ut.exists()) { throw new BuildException("The file " + ut + " for module " + codebasename + " cannot be found"); } Map<String, String> fileToOwningModule = new HashMap<String, String>(); try { ModuleSelector.readUpdateTracking(getProject(), ut.toString(), fileToOwningModule); } catch (IOException ex) { throw new BuildException(ex); } catch (ParserConfigurationException ex) { throw new BuildException(ex); } catch (SAXException ex) { throw new BuildException(ex); } log("project files: " + fileToOwningModule, Project.MSG_DEBUG); String name = relative(f, clusterRoot); log(" removing: " + name, Project.MSG_DEBUG); removeWithLocales(fileToOwningModule, name, clusterRoot, localizedFiles); name = "config/Modules/" + dashcnb + ".xml"; log(" removing: " + name, Project.MSG_DEBUG); removeWithLocales(fileToOwningModule, name, clusterRoot, localizedFiles); name = "config/ModuleAutoDeps/" + dashcnb + ".xml"; log(" removing: " + name, Project.MSG_DEBUG); removeWithLocales(fileToOwningModule, name, clusterRoot, localizedFiles); name = "update_tracking/" + dashcnb + ".xml"; log(" removing: " + name, Project.MSG_DEBUG); removeWithLocales(fileToOwningModule, name, clusterRoot, localizedFiles); String path = mf.getMainAttributes().getValue("Class-Path"); if (path != null) { StringTokenizer tok = new StringTokenizer(path, ", "); while (tok.hasMoreElements()) { String s = tok.nextToken(); File e = new File(f.getParentFile(), s); String r = relative(e, clusterRoot); removeWithLocales(fileToOwningModule, r, clusterRoot, localizedFiles); } } fileToOwningModule.remove("ant/nblib/" + dashcnb + ".jar"); fileToOwningModule.remove("VERSION.txt"); // cluster release information fileToOwningModule.keySet().removeAll(indirectFilePaths); if (verifyExcludes != null) { StringTokenizer tok = new StringTokenizer(verifyExcludes, ", "); while (tok.hasMoreElements()) { removeWithLocales(fileToOwningModule, tok.nextToken(), clusterRoot, localizedFiles); } } if (verify) { if (!fileToOwningModule.isEmpty()) { throw new BuildException("Cannot build JNLP for module " + f + " as these files are in " + "module's NBM, but are not referenced from any path (see harness/README for properties you can define to fix):\n" + fileToOwningModule.keySet()); } } return localizedFiles; }