List of usage examples for java.util ArrayList toString
public String toString()
From source file:es.juntadeandalucia.mapea.proxy.ProxyRedirect.java
/*************************************************************************** * Process the HTTP Get request/*w ww. j av a2 s . c om*/ ***************************************************************************/ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException { String serverUrl = request.getParameter("url"); // manages a get request if it's the geoprint or getcapabilities operation boolean isGeoprint = serverUrl.toLowerCase().contains("mapeaop=geoprint"); boolean isGetCapabilities = serverUrl.toLowerCase().contains("getcapabilities"); boolean isGetFeatureInfo = serverUrl.toLowerCase().contains("wmsinfo"); if (isGeoprint || isGetCapabilities || isGetFeatureInfo) { String strErrorMessage = ""; serverUrl = checkTypeRequest(serverUrl); if (!serverUrl.equals("ERROR")) { // removes mapeaop parameter String url = serverUrl.replaceAll("\\&?\\??mapeaop=geoprint", ""); url = serverUrl.replaceAll("\\&?\\??mapeaop=getcapabilities", ""); url = serverUrl.replaceAll("\\&?\\??mapeaop=wmsinfo", ""); HttpClient client = new HttpClient(); GetMethod httpget = null; try { httpget = new GetMethod(url); HttpClientParams params = client.getParams(); params.setIntParameter(HttpClientParams.MAX_REDIRECTS, numMaxRedirects); client.executeMethod(httpget); // REDIRECTS MANAGEMENT if (httpget.getStatusCode() == HttpStatus.SC_OK) { // PATH_SECURITY_PROXY - AG Header[] respHeaders = httpget.getResponseHeaders(); int compSize = httpget.getResponseBody().length; ArrayList<Header> headerList = new ArrayList<Header>(Arrays.asList(respHeaders)); String headersString = headerList.toString(); boolean checkedContent = checkContent(headersString, compSize, serverUrl); // FIN_PATH_SECURITY_PROXY if (checkedContent) { if (request.getProtocol().compareTo("HTTP/1.0") == 0) { response.setHeader("Pragma", "no-cache"); } else if (request.getProtocol().compareTo("HTTP/1.1") == 0) { response.setHeader("Cache-Control", "no-cache"); } response.setDateHeader("Expires", -1); // set content-type headers if (isGeoprint) { response.setContentType("application/json"); } else if (isGetCapabilities) { response.setContentType("text/xml"); } /* * checks if it has requested an getfeatureinfo to modify the response content * type. */ String requesteredUrl = request.getParameter("url"); if (GETINFO_PLAIN_REGEX.matcher(requesteredUrl).matches()) { response.setContentType("text/plain"); } else if (GETINFO_GML_REGEX.matcher(requesteredUrl).matches()) { response.setContentType("application/gml+xml"); } else if (GETINFO_HTML_REGEX.matcher(requesteredUrl).matches()) { response.setContentType("text/html"); } InputStream st = httpget.getResponseBodyAsStream(); ServletOutputStream sos = response.getOutputStream(); IOUtils.copy(st, sos); } else { strErrorMessage += errorType; log.error(strErrorMessage); } } else { strErrorMessage = "Unexpected failure: " + httpget.getStatusLine().toString(); log.error(strErrorMessage); } httpget.releaseConnection(); } catch (Exception e) { log.error("Error al tratar el contenido de la peticion: " + e.getMessage(), e); } finally { if (httpget != null) { httpget.releaseConnection(); } } } else { // String errorXML = strErrorMessage; String errorXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><error><descripcion>Error en el parametro url de entrada</descripcion></error>"; response.setContentType("text/xml"); try { PrintWriter out = response.getWriter(); out.print(errorXML); response.flushBuffer(); } catch (Exception e) { log.error(e); } } } else { doPost(request, response); } }
From source file:org.hfoss.posit.web.Communicator.java
public boolean sendFind(Find find, String action) { boolean success = false; String url;/*w w w. j a v a 2 s. co m*/ HashMap<String, String> sendMap = find.getContentMapGuid(); //Log.i(TAG, "sendFind map = " + sendMap.toString()); cleanupOnSend(sendMap); sendMap.put("imei", imei); String guid = sendMap.get(PositDbHelper.FINDS_GUID); // Create the url if (action.equals("create")) { url = server + "/api/createFind?authKey=" + authKey; } else { url = server + "/api/updateFind?authKey=" + authKey; } if (Utils.debug) { Log.i(TAG, "SendFind=" + sendMap.toString()); } // Send the find try { responseString = doHTTPPost(url, sendMap); } catch (Exception e) { Log.i(TAG, e.getMessage()); Utils.showToast(mContext, e.getMessage()); } if (Utils.debug) Log.i(TAG, "sendFind.ResponseString: " + responseString); // If the update failed return false if (responseString.indexOf("True") == -1) { Log.i(TAG, "sendFind result doesn't contain 'True'"); return false; } else { PositDbHelper dbh = new PositDbHelper(mContext); long id = find.getId(); success = dbh.markFindSynced(id); if (Utils.debug) Log.i(TAG, "sendfind synced " + id + " " + success); } if (!success) return false; // Otherwise send the Find's images long id = Long.parseLong(sendMap.get(PositDbHelper.FINDS_ID)); PositDbHelper dbh = new PositDbHelper(mContext); ArrayList<ContentValues> photosList = dbh.getImagesListSinceUpdate(id); Log.i(TAG, "sendFind, photosList=" + photosList.toString()); Iterator<ContentValues> it = photosList.listIterator(); while (it.hasNext()) { ContentValues imageData = it.next(); Uri uri = Uri.parse(imageData.getAsString(PositDbHelper.PHOTOS_IMAGE_URI)); String base64Data = convertUriToBase64(uri); uri = Uri.parse(imageData.getAsString(PositDbHelper.PHOTOS_THUMBNAIL_URI)); String base64Thumbnail = convertUriToBase64(uri); sendMap = new HashMap<String, String>(); sendMap.put(COLUMN_IMEI, Utils.getIMEI(mContext)); sendMap.put(PositDbHelper.FINDS_GUID, guid); sendMap.put(PositDbHelper.PHOTOS_IDENTIFIER, imageData.getAsString(PositDbHelper.PHOTOS_IDENTIFIER)); sendMap.put(PositDbHelper.FINDS_PROJECT_ID, imageData.getAsString(PositDbHelper.FINDS_PROJECT_ID)); sendMap.put(PositDbHelper.FINDS_TIME, imageData.getAsString(PositDbHelper.FINDS_TIME)); sendMap.put(PositDbHelper.PHOTOS_MIME_TYPE, imageData.getAsString(PositDbHelper.PHOTOS_MIME_TYPE)); sendMap.put("mime_type", "image/jpeg"); sendMap.put(PositDbHelper.PHOTOS_DATA_FULL, base64Data); sendMap.put(PositDbHelper.PHOTOS_DATA_THUMBNAIL, base64Thumbnail); sendMedia(sendMap); //it.next(); } // Update the Synced attribute. return true; }
From source file:org.jumpmind.metl.core.runtime.component.XsltProcessor.java
@Override public void handle(Message inputMessage, ISendMessageCallback callback, boolean unitOfWorkBoundaryReached) { if (inputMessage instanceof EntityDataMessage) { ArrayList<EntityData> inputRows = ((EntityDataMessage) inputMessage).getPayload(); ArrayList<String> outputPayload = new ArrayList<String>(); String batchXml = getBatchXml(getComponent().getInputModel(), inputRows, outputAllAttributes); String stylesheetXml = stylesheet.getValue(); if (useParameterReplacement) { stylesheetXml = resolveParamsAndHeaders(stylesheetXml, inputMessage); }/*from w w w. j ava2s .co m*/ String outputXml = getTransformedXml(batchXml, stylesheetXml, xmlFormat, omitXmlDeclaration); outputPayload.add(outputXml); log(LogLevel.DEBUG, outputPayload.toString()); callback.sendTextMessage(null, outputPayload); } }
From source file:de.uzk.hki.da.format.PublishImageConversionStrategy.java
/** *//*from w ww . j ava 2 s .co m*/ @Override public List<Event> convertFile(ConversionInstruction ci) throws FileNotFoundException { if (cliConnector == null) throw new IllegalStateException("cliConnector not set"); if (ci.getConversion_routine() == null) throw new IllegalStateException("conversionRoutine not set"); if (ci.getConversion_routine().getTarget_suffix() == null || ci.getConversion_routine().getTarget_suffix().isEmpty()) throw new IllegalStateException("target suffix in conversionRoutine not set"); List<Event> results = new ArrayList<Event>(); // connect dafile to package String input = ci.getSource_file().toRegularFile().getAbsolutePath(); // Convert ArrayList<String> commandAsList = null; for (String audience : audiences) { Path.makeFile(object.getDataPath(), pips, audience.toLowerCase(), ci.getTarget_folder()).mkdirs(); commandAsList = new ArrayList<String>(); commandAsList.add("convert"); commandAsList.add(ci.getSource_file().toRegularFile().getAbsolutePath()); logger.debug(commandAsList.toString()); commandAsList = assembleResizeDimensionsCommand(commandAsList, audience); commandAsList = assembleWatermarkCommand(commandAsList, audience); commandAsList = assembleFooterTextCommand(commandAsList, audience, ci.getSource_file().toRegularFile().getAbsolutePath()); DAFile target = new DAFile(pkg, pips + "/" + audience.toLowerCase(), Utilities.slashize(ci.getTarget_folder()) + FilenameUtils.getBaseName(input) + "." + ci.getConversion_routine().getTarget_suffix()); commandAsList.add(target.toRegularFile().getAbsolutePath()); logger.debug(commandAsList.toString()); String[] commandAsArray = new String[commandAsList.size()]; commandAsArray = commandAsList.toArray(commandAsArray); if (!cliConnector.execute(commandAsArray)) throw new RuntimeException("convert did not succeed: " + Arrays.toString(commandAsArray)); // In order to support multipage tiffs, we check for files by wildcard expression String extension = FilenameUtils.getExtension(target.toRegularFile().getAbsolutePath()); List<File> wild = findFilesWithRegex( new File(FilenameUtils.getFullPath(target.toRegularFile().getAbsolutePath())), Pattern.quote(FilenameUtils.getBaseName(target.getRelative_path())) + "-\\d+\\." + extension); if (!target.toRegularFile().exists() && !wild.isEmpty()) { for (File f : wild) { DAFile multipageTarget = new DAFile(pkg, pips + "/" + audience.toLowerCase(), Utilities.slashize(ci.getTarget_folder()) + f.getName()); Event e = new Event(); e.setDetail(Utilities.createString(commandAsList)); e.setSource_file(ci.getSource_file()); e.setTarget_file(multipageTarget); e.setType("CONVERT"); e.setDate(new Date()); results.add(e); } } else { Event e = new Event(); e.setDetail(Utilities.createString(commandAsList)); e.setSource_file(ci.getSource_file()); e.setTarget_file(target); e.setType("CONVERT"); e.setDate(new Date()); results.add(e); } } return results; }
From source file:lectorarchivos.VerCSV.java
public static void llenarTabla(JTable tabla, File fichero) throws FileNotFoundException, IOException { //Almacenamos la direccion donde se encuenta el fichero en un String String rutaFichero = fichero.getAbsolutePath().toString(); BufferedReader br = null;//from w w w . j a va2 s .com String line = ""; //Asignar un separador char csvSplitBy = ';'; char quote = '"'; CSVReader reader = null; //Realizar lectura del fichero para coger los titulos String titulos[] = new String[5]; titulos[0] = "Fecha"; titulos[1] = "Hora"; titulos[2] = "Nmero de serie"; titulos[3] = "Lectura"; titulos[4] = "Consumo"; //Array de filas String col[] = new String[5]; //Creacion del modelo model = new DefaultTableModel(null, titulos); //Recoger fecha del item actual en string String fechaActual = null; //Recoger la fecha anterior en un string String fechaAnterior = null; //Recoger las lecturas String lecturaActual = null; String lecturaAnterior = null; //Consumo double consumo = 0; //Lectura del fichero try { reader = new CSVReader(new FileReader(rutaFichero), csvSplitBy, quote); String[] nextLine = null; while ((nextLine = reader.readNext()) != null) { //System.out.println(Arrays.toString(nextLine)); //Asignar a cada fila el valor col[0] = nextLine[0];//Lnea de la fecha Actual col[1] = nextLine[1]; col[2] = nextLine[2];//Nmero de serire col[3] = nextLine[12];//Lectura col[4] = nextLine[11];//Consumo if (fechaActual == null && lecturaActual == null) { //Aqu se asigna la fecha actual; fechaActual = col[0]; //Aqu se le asigna la lectura actual //lecturaActual = col[3]; } else { //Se le asigna la fecha a fechaAnterior fechaAnterior = col[0]; //Aqu se le asigna la lectura anterior //lecturaAnterior = col[3]; //Comprobar fechActual con anterior if (fechaActual.compareTo(fechaAnterior) == 1) { //La fecha sera menor } else if (fechaActual.compareTo(fechaAnterior) == -1) { //Es que la fecha es mayor } else { //La fecha es menor } //Mostrar fecha actual y menor System.out.println("Fecha actual --> " + fechaActual); System.out.println("Fecha anterior --> " + fechaAnterior); System.out.println("----------------------------------------"); //Antes de vaciar nada sacamos el consumo de cada cosa //consumo = Double.parseDouble(lecturaActual)-Double.parseDouble(lecturaAnterior); //Ahora asignamos el consumo a la col[4]; //col[4] = String.valueOf(consumo); //Vaciamos las acturales fecha y lectura fechaActual = null; } //Aadimos la columna al modelo model.addRow(col); } ArrayList<Double> consumoRecogido = new ArrayList<Double>(); //Recorrer el modelo for (int i = 0; i < model.getRowCount(); i++) { codigoContadores.add(model.getValueAt(i, 2).toString()); if (lecturaActual == null) { lecturaActual = model.getValueAt(i, 3).toString(); System.out.println("Lectura actual --> " + lecturaActual); } else { lecturaAnterior = model.getValueAt(i, 3).toString(); System.out.println("Lectura anterior --> " + lecturaAnterior); //Lectura anterior - actual = consumo consumo = Double.parseDouble(lecturaActual) - Double.parseDouble(lecturaAnterior); System.out.println("Consumo = " + consumo); //Insertamos el consumo dentro de un arraylist consumoRecogido.add(consumo); //model.setValueAt(consumo, i, 4); System.out.println("---------------------------------------------------"); lecturaActual = lecturaAnterior; } } consumoRecogido.add(0.0); System.out.println(consumoRecogido.toString()); System.out.println(model.getRowCount()); //Ahora vamos metiendo el consumo recogido dentro del modelo for (int i = 0; i < consumoRecogido.size(); i++) { model.setValueAt(consumoRecogido.get(i).toString(), i, 4); } //Recorrer array de codigoContadores System.out.println("Tamao de la lista de numContadores: " + codigoContadores.size()); System.out.println("Datos del array: " + codigoContadores.toString()); //Leer el XML para mostrar el nombre del contador leerXML(); //Editar el modelo de la tabla tabla.setModel(model); //Llamamos al mtodo para mostrar la grfica mostrarGrafica(jTableInfoCSV); } catch (Exception e) { } finally { if (null != reader) { reader.close(); } } }
From source file:edu.isi.wings.portal.controllers.RunController.java
private String getTemplateMD5(String templateurl) throws Exception { String tdbdir = this.config.getProperties().getProperty("tdb.repository.dir"); OntFactory fac = new OntFactory(OntFactory.JENA, tdbdir); KBAPI kbapi = fac.getKB(templateurl, OntSpec.PLAIN); ArrayList<String> triples = new ArrayList<String>(); for (KBTriple triple : kbapi.getAllTriples()) { triples.add(triple.fullForm());//w ww . jav a2 s. c o m } Collections.sort(triples); return MD5Util.MD5(triples.toString()); }
From source file:it.isislab.dmason.util.SystemManagement.Worker.Updater.java
public static void restart(String myTopic, Address address, boolean isBatch, String topicPrefix) { logger.debug("Restart command received"); // TODO Auto-generated method stub String path;/* w w w . java 2s .co m*/ try { path = URLDecoder.decode(Updater.class.getProtectionDomain().getCodeSource().getLocation().getFile(), "UTF-8"); } catch (UnsupportedEncodingException e1) { // TODO Auto-generated catch block e1.printStackTrace(); path = ""; } if (path.contains(".jar")) //from jar { File jarfile = new File(path); try { ArrayList<String> command = new ArrayList<String>(); // Luca Vicidomini command.add("java"); command.add("-cp"); command.add(jarfile.getAbsolutePath()); command.add(DMasonWorker.class.getName()); command.add(address.getIPaddress()); command.add(address.getPort()); command.add(myTopic); if (!isBatch) command.add("reset"); else command.add(topicPrefix); // As wrote by Mario // command.add("java"); // command.add("-jar"); // command.add(jarfile.getAbsolutePath()); // command.add(address.getIPaddress()); // command.add(address.getPort()); // command.add(myTopic); // if(!isBatch) // command.add("reset"); // else // command.add(topicPrefix); logger.info("Restarting with command: " + command.toString()); System.out.println("Restarting with command: " + command); ProcessBuilder builder = new ProcessBuilder(command); Process process = builder.start(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
From source file:de.uzk.hki.da.convert.PublishImageConversionStrategy.java
/** */// w w w .j a v a 2 s . c om @Override public List<Event> convertFile(WorkArea wa, ConversionInstruction ci) throws FileNotFoundException { if (cliConnector == null) throw new IllegalStateException("cliConnector not set"); if (ci.getConversion_routine() == null) throw new IllegalStateException("conversionRoutine not set"); if (ci.getConversion_routine().getTarget_suffix() == null || ci.getConversion_routine().getTarget_suffix().isEmpty()) throw new IllegalStateException("target suffix in conversionRoutine not set"); List<Event> results = new ArrayList<Event>(); // connect dafile to package String input = wa.toFile(ci.getSource_file()).getAbsolutePath(); // Convert ArrayList<String> commandAsList = null; for (String audience : audiences) { Path.makeFile(wa.dataPath(), pips, audience.toLowerCase(), ci.getTarget_folder()).mkdirs(); commandAsList = new ArrayList<String>(); commandAsList.add("convert"); String sourceFileName = wa.toFile(ci.getSource_file()).getAbsolutePath() + "[0]"; commandAsList.add(sourceFileName); logger.debug(commandAsList.toString()); commandAsList = assembleResizeDimensionsCommand(commandAsList, audience); commandAsList = assembleWatermarkCommand(commandAsList, audience); commandAsList = assembleFooterTextCommand(commandAsList, audience, wa.toFile(ci.getSource_file()).getAbsolutePath()); DAFile target = new DAFile(pips + "/" + audience.toLowerCase(), StringUtilities.slashize(ci.getTarget_folder()) + FilenameUtils.getBaseName(input) + "." + ci.getConversion_routine().getTarget_suffix()); String targetFileName = wa.toFile(target).getAbsolutePath(); commandAsList.add(targetFileName); logger.debug(commandAsList.toString()); String[] commandAsArray = new String[commandAsList.size()]; commandAsArray = commandAsList.toArray(commandAsArray); FormatCmdLineExecutor cle = new FormatCmdLineExecutor(cliConnector, knownErrors); cle.setPruneExceptions(prune); String prunedError = ""; try { cle.execute(commandAsArray); } catch (UserFileFormatException ufe) { if (!prune) { throw ufe; } prunedError = " " + ufe.getKnownError().getError_name() + " ISSUED WAS PRUNED BY USER!"; } Event e = new Event(); e.setDetail(StringUtilities.createString(commandAsList) + prunedError); e.setSource_file(ci.getSource_file()); e.setTarget_file(target); e.setType("CONVERT"); e.setDate(new Date()); results.add(e); } return results; }
From source file:com.zira.registration.DocumentUploadActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) { String imagePath = ""; if (requestCode == 1) { encodedImage = ""; imagePath = mCurrentPhotoPath; } else if (requestCode == 2) { encodedImage = ""; Uri selectedImageUri = data.getData(); Cursor cursor = getContentResolver().query(selectedImageUri, new String[] { android.provider.MediaStore.Images.ImageColumns.DATA }, null, null, null); cursor.moveToFirst();/*from www. j av a 2 s . co m*/ //Link to the image final String imageFilePath = cursor.getString(0); cursor.close(); imagePath = imageFilePath; } if (trigger.equals("vehicle")) { encodedImage = Util.showImage(imagePath, vehicleImage); } else if (trigger.equals("rc")) { encodedImage = Util.showImage(imagePath, RCImage); } else if (trigger.equals("drivinglicense")) { encodedImage = Util.showImage(imagePath, licenceImage); } else if (trigger.equals("medicalcertificate")) { encodedImage = Util.showImage(imagePath, medicalImage); } try { if (Util.isNetworkAvailable(DocumentUploadActivity.this)) { ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1); nameValuePairs.add(new BasicNameValuePair("RiderId", prefs.getString("riderid", null))); nameValuePairs.add(new BasicNameValuePair("Trigger", trigger)); nameValuePairs.add(new BasicNameValuePair("Image", encodedImage)); Log.e("IMAGEUPLOAD", nameValuePairs.toString()); AsyncTaskForZira mUploadImage = new AsyncTaskForZira(DocumentUploadActivity.this, uploadImageMethod, nameValuePairs, false, ""); mUploadImage.delegate = (AsyncResponseForZira) DocumentUploadActivity.this; mUploadImage.execute(); } else { Util.alertMessage(DocumentUploadActivity.this, "Please check your internet connection"); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
From source file:org.bdval.modelconditions.RestatMode.java
private ArrayList<String> extractSeriesModelIds(final ProcessModelConditionsOptions options, final String seriesID) { if (seriesID == null) { return new ArrayList<String>(); }/*from w w w. jav a 2s . c o m*/ final Set<String> modelIdKeys = options.modelConditions.keySet(); // model-Id's associated with model-conditions file //String[] keys = modelIdKeys.toArray(new String[modelIdKeys.size()]); final ArrayList<String> models = new ArrayList<String>(); // arraylist of models in the same series for (final String modelId : modelIdKeys) { final String otherseriesId = options.modelConditions.get(modelId).get("id-parameter-scan-series"); if (seriesID.equals(otherseriesId)) { models.add(modelId); } } LOG.info("models in same series " + models.toString()); LOG.info("# models in series " + seriesID + " = " + models.size()); return models; }