List of usage examples for java.util Vector get
public synchronized E get(int index)
From source file:eionet.meta.exports.ods.Ods.java
/** * Prepares for table.// w ww .j av a 2 s. c o m * * @param tbl * table * @throws java.lang.Exception * when operation fails */ protected void prepareTbl(DsTable tbl) throws Exception { Table tableTag = new Table(); tableTag.setTableName(tbl.getIdentifier()); tableTag.setSchemaURLTrailer("TBL" + tbl.getID()); Vector elms = searchEngine.getDataElements(null, null, null, null, tbl.getID()); for (int i = 0; elms != null && i < elms.size(); i++) { DataElement elm = (DataElement) elms.get(i); String defaultCellStyleName = getDefaultCellStyleName(elm); tableTag.addTableColumn(defaultCellStyleName); tableTag.addColumnHeader(elm.getIdentifier()); } addTable(tableTag); }
From source file:com.globalsight.util.file.XliffFileUtil.java
/** * Process the files if the source file is with XLZ file format * // w w w .j a v a 2 s. co m * @param p_workflow * * @author Vincent Yan, 2011/01/27 * @version 1.1 * @since 8.1 */ public static void processXLZFiles(Workflow p_workflow) { if (p_workflow == null || p_workflow.getAllTargetPages().size() == 0) return; TargetPage tp = null; String externalId = ""; String tmp = "", exportDir = ""; String sourceFilename = ""; String sourceDir = "", targetDir = ""; File sourceFile = null; File sourcePath = null, targetPath = null; ArrayList<String> xlzFiles = new ArrayList<String>(); try { Vector<TargetPage> targetPages = p_workflow.getAllTargetPages(); String baseCxeDocDir = AmbFileStoragePathUtils.getCxeDocDirPath().concat(File.separator); Job job = p_workflow.getJob(); String companyId = String.valueOf(job.getCompanyId()); String companyName = CompanyWrapper.getCompanyNameById(companyId); if (CompanyWrapper.SUPER_COMPANY_ID.equals(CompanyWrapper.getCurrentCompanyId()) && !CompanyWrapper.SUPER_COMPANY_ID.equals(companyId)) { baseCxeDocDir += companyName + File.separator; } int index = -1; ArrayList<String> processed = new ArrayList<String>(); for (int i = 0; i < targetPages.size(); i++) { tp = (TargetPage) targetPages.get(i); externalId = FileUtil.commonSeparator(tp.getSourcePage().getExternalPageId()); index = externalId.lastIndexOf(SEPARATE_FLAG + File.separator); if (index != -1) { tmp = externalId.substring(0, index); sourceFilename = baseCxeDocDir + tmp; sourceFile = new File(sourceFilename); if (sourceFile.exists() && sourceFile.isFile()) { // Current file is a separated file from big Xliff file // with // multiple <File> tags externalId = tmp; } } if (processed.contains(externalId)) continue; else processed.add(externalId); if (isXliffFile(externalId)) { tmp = externalId.substring(0, externalId.lastIndexOf(File.separator)); sourceFilename = baseCxeDocDir + tmp + XliffFileUtil.XLZ_EXTENSION; sourceFile = new File(sourceFilename); if (sourceFile.exists() && sourceFile.isFile()) { // source file is with xlz file format exportDir = tp.getExportSubDir(); if (exportDir.startsWith("\\") || exportDir.startsWith("/")) exportDir = exportDir.substring(1); targetDir = baseCxeDocDir + exportDir + tmp.substring(tmp.indexOf(File.separator)); if (!xlzFiles.contains(targetDir)) xlzFiles.add(targetDir); // Get exported target path targetPath = new File(targetDir); // Get source path sourceDir = baseCxeDocDir + tmp; sourcePath = new File(sourceDir); // Copy all files extracted from XLZ file from source // path to exported target path // Because Xliff files can be exported by GS // automatically, then ignore them and // just copy the others file to target path File[] files = sourcePath.listFiles(); for (File f : files) { if (f.isDirectory()) continue; if (isXliffFile(f.getAbsolutePath())) continue; org.apache.commons.io.FileUtils.copyFileToDirectory(f, targetPath); } } } } // Generate exported XLZ file and remove temporary folders for (int i = 0; i < xlzFiles.size(); i++) { targetDir = xlzFiles.get(i); targetPath = new File(targetDir); File xlzFile = new File(targetDir + XLZ_EXTENSION); if (!targetPath.exists() || xlzFile.exists()) { continue; } ZipIt.addEntriesToZipFile(xlzFile, targetPath.listFiles(), true, ""); } } catch (Exception e) { logger.error("Error in WorkflowManagerLocal.processXLZFiles. "); logger.error(e.getMessage(), e); } }
From source file:kenh.xscript.impl.BaseElement.java
private int invokeChildren(int i) throws UnsupportedScriptException { Vector<Element> children = this.getChildren(); int r = NONE; for (; i < children.size(); i++) { Element child = children.get(i); r = child.invoke();//www .j av a 2 s. c om if (r != NONE) break; } // If EXCEPTION is return, find Catch element to handle. if (r == EXCEPTION) { for (; i < children.size(); i++) { Element child = children.get(i); if (child instanceof kenh.xscript.elements.Catch) { r = ((kenh.xscript.elements.Catch) child).processException(); break; } } if (r != NONE) return r; else { // If Catch element return NONE, go on with children after Catch element. invokeChildren(i); } } return r; }
From source file:info.guardianproject.gpg.KeyListFragment.java
public void handleIntent(String action, Bundle extras) { // Why doesn't java have default parameters :( if (extras == null) extras = new Bundle(); mCurrentAction = action;//www . j a v a2s. com mCurrentExtras = extras; String searchString = null; if (Intent.ACTION_SEARCH.equals(action)) { searchString = extras.getString(SearchManager.QUERY); if (searchString != null && searchString.trim().length() == 0) { searchString = null; } } long selectedKeyIds[] = null; selectedKeyIds = extras.getLongArray(Apg.EXTRA_SELECTION); if (selectedKeyIds == null) { Vector<Long> vector = new Vector<Long>(); for (int i = 0; i < mListView.getCount(); ++i) { if (mListView.isItemChecked(i)) { vector.add(mListView.getItemIdAtPosition(i)); } } selectedKeyIds = new long[vector.size()]; for (int i = 0; i < vector.size(); ++i) { selectedKeyIds[i] = vector.get(i); } } if (action.equals(Action.FIND_KEYS)) { if (mKeyserverAdapter == null) mKeyserverAdapter = new KeyListKeyserverAdapter(mListView, searchString); setListAdapter(mKeyserverAdapter); } else { mShowKeysAdapter = new KeyListContactsAdapter(mListView, action, searchString, selectedKeyIds); setListAdapter(mShowKeysAdapter); if (selectedKeyIds != null) { for (int i = 0; i < mShowKeysAdapter.getCount(); ++i) { long keyId = mShowKeysAdapter.getItemId(i); for (int j = 0; j < selectedKeyIds.length; ++j) { if (keyId == selectedKeyIds[j]) { mListView.setItemChecked(i, true); break; } } } } } }
From source file:imapi.IMAPIClass.java
void printSourceInfo(SourceDataHolder sourceInfo) { int counter = 0; Vector<String> fileInstances = new Vector<String>(sourceInfo.keySet()); Collections.sort(fileInstances); //System.out.println("Found " + fileInstances.size() + " instances in all \"\"SOURCE\"\" input files."); for (int i = 0; i < fileInstances.size(); i++) { String filename = fileInstances.get(i); Vector<String> uris = new Vector<String>(sourceInfo.get(filename).keySet()); Collections.sort(uris);/* w w w. j a va2 s . com*/ for (int j = 0; j < uris.size(); j++) { counter++; String uri = uris.get(j); SequencesVector allSeqData = sourceInfo.get(filename).get(uri); System.out.println("\r\n" + counter + ". " + uri + "\t\tin source: " + filename); for (int k = 0; k < allSeqData.size(); k++) { SequenceData currentSeq = allSeqData.get(k); System.out .println("\tData found on sequence: " + (currentSeq.getSchemaInfo().getPositionID() + 1) + " mnemonic: " + currentSeq.getSchemaInfo().getMnemonic() + " with weight: " + currentSeq.getSchemaInfo().getWeight()); Hashtable<String, String> parameterTypes = currentSeq.getSchemaInfo() .getAllQueryStepParameters(); String[] parameterNames = currentSeq.getSchemaInfo().getSortedParameterNamesCopy(); for (int paramStep = 0; paramStep < parameterNames.length; paramStep++) { String paramName = parameterNames[paramStep]; String paramType = parameterTypes.get(paramName); //System.out.println(paramName); //String type //String stepName = currentSeq.getSchemaInfo().getQuerySteps().get(step).getParameterName(); //String type = currentSeq.getSchemaInfo().getQuerySteps().get(step).getParameterType(); Vector<DataRecord> vals = currentSeq.getValuesOfKey(paramName); for (int valIndex = 0; valIndex < vals.size(); valIndex++) { DataRecord rec = vals.get(valIndex); String printStr = "\t\t" + paramName + ": " + paramType + " -->\t" + rec.toString(); System.out.println(printStr); } } } } } }
From source file:net.rim.ejde.internal.packaging.PackagingManager.java
static private boolean existingJar(Vector<ImportedJar> vec, ImportedJar jar) { if (jar == null) { return false; }// www . j a v a2 s . c o m for (int i = 0; i < vec.size(); i++) { if (vec.get(i).getPath().equalsIgnoreCase(jar.getPath())) { return true; } } return false; }
From source file:amulet.appbuilder.AppBuilder.java
@SuppressWarnings("unchecked") private boolean callPipeLine(String filename) { QMReader qm = new QMReader(filename); try {// ww w.j av a 2 s .co m manifestReader = new ManifestReader(filename); } catch (Exception exp) { System.out.println("Exception when creating manifest reader for " + filename); exp.printStackTrace(); return false; } // This will be written to a file for parsing by the Resource Profile UI finalJSONGraphStructure = new JSONObject(); if (passToolchain) { Vector<QMClass> classes = qm.getClasses(); authModule = new AuthorizationModule(manifestReader); for (int j = 0; j < classes.size(); j++) { QMClass qmclass = classes.get(j); Vector<State> states = qmclass.getStates(); Vector<Node> action_nodes = qmclass.getActionNodes(); Vector<Node> guard_nodes = qmclass.getGuardNodes(); Vector<Node> operation_nodes = qmclass.getOperationNodes(); // Get all the attributes (global variables) that are put in FRAM HashMap<String, String[]> attdetails = qmclass.getAttributesWithDetails(); resourceProfiler.setGlobalContext(qmclass.getName()); for (String key : attdetails.keySet()) { String[] attinfo = attdetails.get(key); resourceProfiler.addMemoryResource(qmclass.getName(), attinfo[0], key, attinfo[1], ResourceType.GLOBAL_MEMORY); } resourceProfiler.clearProfilerContext(); // This outputs a JSON format of the QMClass finalJSONGraphStructure.put("appname", qmclass.getName()); finalJSONGraphStructure.put("app_human_readable_name", manifestReader.getAppName()); finalJSONGraphStructure.put("app_human_readable_description", manifestReader.getAppDescription()); /* * States. */ // DEBUG:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //NodeList initNodes = qmclass.getInitialTransition(); //for(int n = 0; n < initNodes.getLength(); n++) { // String target = initNodes.item(n).getAttributes().getNamedItem("target").getNodeValue(); // System.out.println("##DEBUG## init->" + qmclass.getQmSateId2NameMapEntry("NONE", target)); //} // DEBUG:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: for (int i = 0; i < states.size(); i++) { State state = states.get(i); if (state != null) { // Set state attributes. String stateName = state.getName(); // DEBUG:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //for(Transition t : state.getTransitions()) { // QMTransition qmt = (QMTransition) t; // System.out.println("##DEBUG## " + qmt.getSource().getName() + "->" + qmt.getTrigger() + "->" + qmt.getTarget().getName()); //} // DEBUG:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: // [ENTER] State i. resourceProfiler.setStateContext(stateName); // AFT analyzer/translator/profiler (entry) if (state.getEntryCode() != null && state.getEntryCode().length() > 0) { compatchecker = new CompatChecker(state.getEntryCode(), qmclass.getName()); if (!compatchecker.getSuccess()) return false; if (!authModule.checkApiAuthorization(state.getEntryCode())) return false; runtimecheck = new RuntimeCheck(qmclass, state.getEntryCode(), togglePins, qmclass.getArrayAttributes(), resourceProfiler); state.setEntryCode(runtimecheck.getCheckedCode()); attributeMapper = new AttributeMapper(state.getEntryCode(), qmclass.getAttributes()); state.setEntryCode(attributeMapper.getMappedCode()); } // AFT analyzer/translator/profiler (exit) if (state.getExitCode() != null && state.getExitCode().length() > 0) { compatchecker = new CompatChecker(state.getExitCode(), qmclass.getName()); if (!compatchecker.getSuccess()) return false; if (!authModule.checkApiAuthorization(state.getExitCode())) return false; runtimecheck = new RuntimeCheck(qmclass, state.getExitCode(), togglePins, qmclass.getArrayAttributes(), resourceProfiler); state.setExitCode(runtimecheck.getCheckedCode()); attributeMapper = new AttributeMapper(state.getExitCode(), qmclass.getAttributes()); state.setExitCode(attributeMapper.getMappedCode()); } // Add "basic blocks" record to state. Resource record = new Resource(ComputationType.BASIC_BLOCKS.text(), qmclass.getName(), ResourceType.COMPUTATION, 0.0); resourceProfiler.add(record); // [EXIT] State i. resourceProfiler.clearProfilerContext(); } } /* * Action Nodes (i.e., Transitions). */ JSONArray statesJsonArray = new JSONArray(); String prevState = null, prevTrigger = null, prevTarget = null; for (int i = 0; i < action_nodes.size(); i++) { if (action_nodes.get(i) != null && action_nodes.get(i).getTextContent() != null) { /* * Set transition attributes. */ String currentState = "", triggerName = "", targetNameID = ""; Node action_node = action_nodes.get(i); Node parent1 = action_node.getParentNode(); Node parent2 = parent1.getParentNode(); // Set the "source" (i.e., the state which this action node is contained within---the "parent state"). currentState = QMClass.getCurrentQMStateFromActionNode(action_node); // Set the "trigger". if (parent1.getAttributes().getNamedItem("trig") != null) { triggerName = parent1.getAttributes().getNamedItem("trig").getNodeValue(); } else if (parent2.getAttributes().getNamedItem("trig") != null) { triggerName = parent2.getAttributes().getNamedItem("trig").getNodeValue(); } else { triggerName = "init"; } // Set the "target". if (parent1.getAttributes().getNamedItem("target") != null) { targetNameID = parent1.getAttributes().getNamedItem("target").getNodeValue(); } else if (parent2.getAttributes().getNamedItem("target") != null) { targetNameID = parent2.getAttributes().getNamedItem("target").getNodeValue(); } else { targetNameID = "init-target-unset?"; } // Fetch the (human-readable) name of the state referenced by the ID specified in the action node. String targetName = qmclass.getQmSateId2NameMapEntry(currentState, targetNameID); /* * Guard against recording duplicate records (it can happen!). * * NOTE: This is a little sloppy, since it assumes that the duplicate records happen in * sequence; this seems to always be true with the QM files we've worked with, but this * issue may need to be re-addressed later... */ if (!currentState.equals(prevState) || !triggerName.equals(prevTrigger) || !targetName.equals(prevTarget)) { //System.out.println(" + TRIGGER:: currentState=" + currentState + "->triggerName="+triggerName + "->targetName="+targetName + " (targetNameID="+targetNameID+")"); // Maintain a JSON representation of the FSM (i.e., states and transitions). JSONObject actionJsonObj = new JSONObject(); actionJsonObj.put("source", currentState); actionJsonObj.put("trigger", triggerName); actionJsonObj.put("target", targetName); statesJsonArray.add(actionJsonObj); // [ENTER] Action Node i. resourceProfiler.setActionContext(currentState, triggerName, targetName); // AFT analyzer/translator/profiler compatchecker = new CompatChecker(action_nodes.get(i).getTextContent(), qmclass.getName()); if (!compatchecker.getSuccess()) return false; if (!authModule.checkApiAuthorization(action_nodes.get(i).getTextContent())) return false; runtimecheck = new RuntimeCheck(qmclass, action_nodes.get(i).getTextContent(), togglePins, qmclass.getArrayAttributes(), resourceProfiler); action_nodes.get(i).setTextContent(runtimecheck.getCheckedCode()); attributeMapper = new AttributeMapper(action_nodes.get(i).getTextContent(), qmclass.getAttributes()); action_nodes.get(i).setTextContent(attributeMapper.getMappedCode()); // Add "basic blocks" record to action. Resource record = new Resource(ComputationType.BASIC_BLOCKS.text(), qmclass.getName(), ResourceType.COMPUTATION, 0.0); resourceProfiler.add(record); // [EXIT] Action Node i. resourceProfiler.clearProfilerContext(); } // Keep track of the previous trigger information... prevState = currentState; prevTrigger = triggerName; prevTarget = targetName; } } finalJSONGraphStructure.put("states", statesJsonArray); /* * Guard Nodes. */ for (int i = 0; i < guard_nodes.size(); i++) { if (guard_nodes.get(i) != null && guard_nodes.get(i).getTextContent() != null && guard_nodes.get(i).getTextContent().length() > 0) { // [ENTER] Guard Node i. resourceProfiler.setGuardContext(); // AFT analyzer/translator/profiler compatchecker = new CompatChecker(guard_nodes.get(i).getTextContent(), qmclass.getName()); if (!compatchecker.getSuccess()) return false; if (!authModule.checkApiAuthorization(guard_nodes.get(i).getTextContent())) return false; runtimecheck = new RuntimeCheck(qmclass, guard_nodes.get(i).getTextContent(), togglePins, qmclass.getArrayAttributes(), resourceProfiler); guard_nodes.get(i).setTextContent(runtimecheck.getCheckedCode()); attributeMapper = new AttributeMapper(guard_nodes.get(i).getTextContent(), qmclass.getAttributes()); guard_nodes.get(i).setTextContent(attributeMapper.getMappedCode()); // Add "basic blocks" record to guard. Resource record = new Resource(ComputationType.BASIC_BLOCKS.text(), qmclass.getName(), ResourceType.COMPUTATION, 0.0); resourceProfiler.add(record); // [EXIT] Guard Node i. resourceProfiler.clearProfilerContext(); } } /* * Operation Nodes. */ for (int i = 0; i < operation_nodes.size(); i++) { if (operation_nodes.get(i) != null && operation_nodes.get(i).getTextContent() != null && operation_nodes.get(i).getTextContent().length() > 0) { // Set operations attributes. String name = operation_nodes.get(i).getParentNode().getAttributes().getNamedItem("name") .getNodeValue(); String type = operation_nodes.get(i).getParentNode().getAttributes().getNamedItem("type") .getNodeValue(); String visibility = operation_nodes.get(i).getParentNode().getAttributes() .getNamedItem("visibility").getNodeValue(); String properties = operation_nodes.get(i).getParentNode().getAttributes() .getNamedItem("properties").getNodeValue(); // [ENTER] Operation Node i. resourceProfiler.setOperationContext(name, type, visibility, properties); // AFT analyzer/translator/profiler compatchecker = new CompatChecker(operation_nodes.get(i).getTextContent(), qmclass.getName()); if (!compatchecker.getSuccess()) return false; if (!authModule.checkApiAuthorization(operation_nodes.get(i).getTextContent())) return false; runtimecheck = new RuntimeCheck(qmclass, operation_nodes.get(i).getTextContent(), togglePins, qmclass.getArrayAttributes(), resourceProfiler); operation_nodes.get(i).setTextContent(runtimecheck.getCheckedCode()); attributeMapper = new AttributeMapper(operation_nodes.get(i).getTextContent(), qmclass.getAttributes()); operation_nodes.get(i).setTextContent(attributeMapper.getMappedCode()); // Add "basic blocks" record to operation. Resource record = new Resource(ComputationType.BASIC_BLOCKS.text(), qmclass.getName(), ResourceType.COMPUTATION, 0.0); resourceProfiler.add(record); // [EXIT] Operation Node i. resourceProfiler.clearProfilerContext(); // For now, add a place-holder entry to the operation map -- it will be updated later // when a request is made to the Resource Profiler to calculate the cost of some application. resourceProfiler.getCurrentQMAppObj().addOperationRecord(name, 0.0, 0.0); } } // Verify checks against function white-list pass... funcWhiteList = new FunctionWhitelist(qmclass.getName(), states, action_nodes, guard_nodes, qmclass.getOperations()); if (!funcWhiteList.getSuccess()) return false; } } else { System.out.println("AFT WARNING: skipping AFT processing -- code has not been properly validated!"); } qm.saveAs(filename + ".temp"); return true; }
From source file:cm.aptoide.pt.RemoteInSearch.java
private String downloadFile(int position) { Vector<DownloadNode> tmp_serv = new Vector<DownloadNode>(); String getserv = new String(); String md5hash = null;/*from ww w . jav a 2s . c o m*/ String repo = null; try { tmp_serv = db.getPathHash(apk_lst.get(position).apkid); if (tmp_serv.size() > 0) { DownloadNode node = tmp_serv.get(0); getserv = node.repo + "/" + node.path; md5hash = node.md5h; repo = node.repo; } if (getserv.length() == 0) throw new TimeoutException(); Message msg = new Message(); msg.arg1 = 0; msg.obj = new String(getserv); download_handler.sendMessage(msg); /*BufferedInputStream getit = new BufferedInputStream(new URL(getserv).openStream()); String path = new String(APK_PATH+apk_lst.get(position).name+".apk"); FileOutputStream saveit = new FileOutputStream(path); BufferedOutputStream bout = new BufferedOutputStream(saveit,1024); byte data[] = new byte[1024]; int readed = getit.read(data,0,1024); while(readed != -1) { bout.write(data,0,readed); readed = getit.read(data,0,1024); } bout.close(); getit.close(); saveit.close();*/ String path = new String(APK_PATH + apk_lst.get(position).name + ".apk"); FileOutputStream saveit = new FileOutputStream(path); DefaultHttpClient mHttpClient = new DefaultHttpClient(); HttpGet mHttpGet = new HttpGet(getserv); String[] logins = null; logins = db.getLogin(repo); if (logins != null) { URL mUrl = new URL(getserv); mHttpClient.getCredentialsProvider().setCredentials(new AuthScope(mUrl.getHost(), mUrl.getPort()), new UsernamePasswordCredentials(logins[0], logins[1])); } HttpResponse mHttpResponse = mHttpClient.execute(mHttpGet); if (mHttpResponse.getStatusLine().getStatusCode() == 401) { return null; } else { byte[] buffer = EntityUtils.toByteArray(mHttpResponse.getEntity()); saveit.write(buffer); } File f = new File(path); Md5Handler hash = new Md5Handler(); if (md5hash == null || md5hash.equalsIgnoreCase(hash.md5Calc(f))) { return path; } else { return null; } } catch (Exception e) { return null; } }
From source file:com.duroty.controller.actions.GoogieSpellAction.java
protected ActionForward doExecute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ActionMessages errors = new ActionMessages(); PostMethod post = null;//from w w w . j a v a 2 s. c o m try { Enumeration enumeration = request.getParameterNames(); while (enumeration.hasMoreElements()) { String name = (String) enumeration.nextElement(); String value = (String) request.getParameter(name); DLog.log(DLog.WARN, this.getClass(), name + " >> " + value); } String text = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><spellrequest textalreadyclipped=\"0\" ignoredups=\"0\" ignoredigits=\"1\" ignoreallcaps=\"1\"><text>" + request.getParameter("check") + "</text></spellrequest>"; String lang = request.getParameter("lang"); String id = request.getParameter("id"); String cmd = request.getParameter("cmd"); String url = "https://" + googleUrl + "/tbproxy/spell?lang=" + lang + "&hl=" + lang; post = new PostMethod(url); post.setRequestBody(text); post.setRequestHeader("Content-type", "text/xml; charset=ISO-8859-1"); HttpClient client = new HttpClient(); int result = client.executeMethod(post); // Display status code System.out.println("Response status code: " + result); // Display response System.out.println("Response body: "); String resp = post.getResponseBodyAsString(); System.out.println(resp); String goodieSpell = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"; Vector matches = getMatches(resp); if (matches.size() <= 0) { goodieSpell = goodieSpell + "<res id=\"" + id + "\" cmd=\"" + cmd + "\" />"; } else { goodieSpell = goodieSpell + "<res id=\"" + id + "\" cmd=\"" + cmd + "\">"; StringBuffer buffer = new StringBuffer(); for (int i = 0; i < matches.size(); i++) { if (buffer.length() > 0) { buffer.append("+"); } String aux = (String) matches.get(i); aux = aux.substring(aux.indexOf(">") + 1, aux.length()); aux = aux.substring(0, aux.indexOf("<")); aux = aux.trim().replaceAll("\\s+", "\\+"); buffer.append(aux); } goodieSpell = goodieSpell + buffer.toString() + "</res>"; } request.setAttribute("googieSpell", goodieSpell); } catch (Exception ex) { String errorMessage = ExceptionUtilities.parseMessage(ex); if (errorMessage == null) { errorMessage = "NullPointerException"; } errors.add("general", new ActionMessage(ExceptionCode.ERROR_MESSAGES_PREFIX + "general", errorMessage)); request.setAttribute("exception", errorMessage); doTrace(request, DLog.ERROR, getClass(), errorMessage); } finally { try { post.releaseConnection(); } catch (Exception e) { } } if (errors.isEmpty()) { doTrace(request, DLog.INFO, getClass(), "OK"); return mapping.findForward(Constants.ACTION_SUCCESS_FORWARD); } else { saveErrors(request, errors); return mapping.findForward(Constants.ACTION_FAIL_FORWARD); } }
From source file:edu.caltechUcla.sselCassel.projects.jMarkets.server.control.MonitorServ.java
/** Log the given message onto the MonitorTransmitters of all sessions */ public void logMessage(String logStr, int level, String className) { Enumeration sessionIds = sessionMonitors.keys(); while (sessionIds.hasMoreElements()) { Integer key = (Integer) sessionIds.nextElement(); Vector monitors = (Vector) sessionMonitors.get(key); for (int i = 0; i < monitors.size(); i++) { MonitorTransmitter ui = (MonitorTransmitter) monitors.get(i); try { ui.addLogMessage(logStr, level, className); } catch (MonitorDisconnectedException e) { disconnectMonitor(key.intValue(), ui); log.error(/*from w ww .jav a2 s .c o m*/ "Failed to establish connection with MonitorTransmitter -- disconnecting from failed monitor"); } } } }