List of usage examples for java.util Vector iterator
public synchronized Iterator<E> iterator()
From source file:sos.util.SOSHttpPost.java
/** * Sendet eine Datei an den Server, rekursiv fr Verzeichnisse * @param file Datei oder Verzeichnis/*from www.j a v a 2 s .c o m*/ * @return liefert die Anzahl der gesendeten Dateien zurck * @throws Exception */ private int recursiveSend(File inputFile, String inputFileSpec, String outputFile) throws Exception { int sendcounter = 0; // Verzeichnis if (inputFile.isDirectory()) { Vector filelist = SOSFile.getFilelist(inputFile.getAbsolutePath(), inputFileSpec, 0); Iterator iterator = filelist.iterator(); File nextFile; while (iterator.hasNext()) { nextFile = (File) iterator.next(); sendcounter += this.recursiveSend(nextFile, inputFileSpec, ((outputFile == null) ? null : outputFile + "/" + nextFile.getName())); } // Datei } else if (inputFile.isFile()) { this.sendFile(inputFile, outputFile); sendcounter++; } else { throw new Exception(inputFile.getCanonicalPath() + " is no normal file"); } return sendcounter; }
From source file:com.adaptris.sftp.SftpClient.java
/** * /*from w ww . j a v a2 s.c o m*/ * @see FileTransferClient#dir(java.lang.String, boolean) */ @Override public String[] dir(String dirname, boolean full) throws IOException, FileTransferException { checkConnected(); List<String> names = new ArrayList<String>(); try { acquireLock(); String path = defaultIfBlank(dirname, CURRENT_DIR); log("DIR {}", path); Vector v = sftpChannel.ls(path); if (v != null) { for (Iterator i = v.iterator(); i.hasNext();) { ChannelSftp.LsEntry entry = (ChannelSftp.LsEntry) i.next(); if (!(entry.getFilename().equals(CURRENT_DIR) || entry.getFilename().equals(PARENT_DIR))) { names.add(full ? entry.getLongname() : entry.getFilename()); } } } Collections.sort(names); } catch (com.jcraft.jsch.SftpException e) { throw new SftpException("Could not list files in " + dirname, e); } finally { releaseLock(); } return names.toArray(new String[0]); }
From source file:com.mirth.connect.connectors.file.filesystems.SftpConnection.java
@Override public List<FileInfo> listFiles(String fromDir, String filenamePattern, boolean isRegex, boolean ignoreDot) throws Exception { lastDir = fromDir;/* w w w .ja v a 2 s . c om*/ FilenameFilter filenameFilter; if (isRegex) { filenameFilter = new RegexFilenameFilter(filenamePattern); } else { filenameFilter = new WildcardFileFilter(filenamePattern.trim().split("\\s*,\\s*")); } cwd(fromDir); @SuppressWarnings("unchecked") Vector<ChannelSftp.LsEntry> entries = client.ls("."); List<FileInfo> files = new ArrayList<FileInfo>(entries.size()); for (Iterator<ChannelSftp.LsEntry> iter = entries.iterator(); iter.hasNext();) { ChannelSftp.LsEntry entry = iter.next(); if (!entry.getAttrs().isDir() && !entry.getAttrs().isLink()) { if (((filenameFilter == null) || filenameFilter.accept(null, entry.getFilename())) && !(ignoreDot && entry.getFilename().startsWith("."))) { files.add(new SftpFileInfo(fromDir, entry)); } } } return files; }
From source file:com.adito.util.ProxiedHttpMethod.java
public HttpResponse execute(HttpRequest request, HttpConnection connection) throws IOException { String encodedContent = ""; /**//from ww w . jav a2 s. c o m * Encode parameters into content if application/x-www-form-urlencoded */ if (wwwURLEncodedParameters) { String key; String value; Vector v; for (Enumeration e = getParameterNames(); e.hasMoreElements();) { key = (String) e.nextElement(); v = getParameterValueList(key); for (Iterator it2 = v.iterator(); it2.hasNext();) { value = (String) it2.next(); encodedContent += (encodedContent.length() > 0 ? "&" : "") + Util.urlEncode(key, (charsetEncoding == null ? SystemProperties.get("adito.urlencoding", "UTF-8") : charsetEncoding)) + "=" + Util.urlEncode(value, (charsetEncoding == null ? SystemProperties.get("adito.urlencoding", "UTF-8") : charsetEncoding)); } } if (encodedContent.length() > 0) { if (charsetEncoding == null) { ByteArrayInputStream in = new ByteArrayInputStream(encodedContent.getBytes()); setContent(in, in.available(), "application/x-www-form-urlencoded"); } else { ByteArrayInputStream in = new ByteArrayInputStream(encodedContent.getBytes(charsetEncoding)); setContent(in, in.available(), "application/x-www-form-urlencoded"); } } } // Setup all the proxied headers for (Enumeration e = proxiedHeaders.getHeaderFieldNames(); e.hasMoreElements();) { String header = (String) e.nextElement(); if (header.equalsIgnoreCase("Authorization")) if (request.getHeaderField("Authorization") != null) continue; String[] values = proxiedHeaders.getHeaderFields(header); for (int i = 0; i < values.length; i++) { request.addHeaderField(header, values[i]); } } request.performRequest(this, connection); // If the request is multipart/form-data then copy the streams now if (content != null) { if (log.isDebugEnabled()) log.debug("Sending " + contentLength + " bytes of content"); content.mark(bufferSize); try { int read; byte[] buf = new byte[4096]; long total = 0; do { read = content.read(buf, 0, (int) Math.min(buf.length, contentLength - total)); if (log.isDebugEnabled()) log.debug("Sent " + read + " bytes of content"); if (read > -1) { total += read; connection.getOutputStream().write(buf, 0, read); connection.getOutputStream().flush(); } } while (read > -1 && (contentLength - total) > 0); } finally { content.reset(); } if (log.isDebugEnabled()) log.debug("Completed sending request content"); } return new HttpResponse(connection); }
From source file:com.sslexplorer.util.ProxiedHttpMethod.java
public HttpResponse execute(HttpRequest request, HttpConnection connection) throws IOException { String encodedContent = ""; /**//from w ww. ja v a 2 s .co m * Encode parameters into content if application/x-www-form-urlencoded */ if (wwwURLEncodedParameters) { String key; String value; Vector v; for (Enumeration e = getParameterNames(); e.hasMoreElements();) { key = (String) e.nextElement(); v = getParameterValueList(key); for (Iterator it2 = v.iterator(); it2.hasNext();) { value = (String) it2.next(); encodedContent += (encodedContent.length() > 0 ? "&" : "") + Util.urlEncode(key, (charsetEncoding == null ? SystemProperties.get("sslexplorer.urlencoding", "UTF-8") : charsetEncoding)) + "=" + Util.urlEncode(value, (charsetEncoding == null ? SystemProperties.get("sslexplorer.urlencoding", "UTF-8") : charsetEncoding)); } } if (encodedContent.length() > 0) { if (charsetEncoding == null) { ByteArrayInputStream in = new ByteArrayInputStream(encodedContent.getBytes()); setContent(in, in.available(), "application/x-www-form-urlencoded"); } else { ByteArrayInputStream in = new ByteArrayInputStream(encodedContent.getBytes(charsetEncoding)); setContent(in, in.available(), "application/x-www-form-urlencoded"); } } } // Setup all the proxied headers for (Enumeration e = proxiedHeaders.getHeaderFieldNames(); e.hasMoreElements();) { String header = (String) e.nextElement(); if (header.equalsIgnoreCase("Authorization")) if (request.getHeaderField("Authorization") != null) continue; String[] values = proxiedHeaders.getHeaderFields(header); for (int i = 0; i < values.length; i++) { request.addHeaderField(header, values[i]); } } request.performRequest(this, connection); // If the request is multipart/form-data then copy the streams now if (content != null) { if (log.isDebugEnabled()) log.debug("Sending " + contentLength + " bytes of content"); content.mark(bufferSize); try { int read; byte[] buf = new byte[4096]; long total = 0; do { read = content.read(buf, 0, (int) Math.min(buf.length, contentLength - total)); if (log.isDebugEnabled()) log.debug("Sent " + read + " bytes of content"); if (read > -1) { total += read; connection.getOutputStream().write(buf, 0, read); connection.getOutputStream().flush(); } } while (read > -1 && (contentLength - total) > 0); } finally { content.reset(); } if (log.isDebugEnabled()) log.debug("Completed sending request content"); } return new HttpResponse(connection); }
From source file:com.github.ekumen.rosjava_actionlib.ClientStateMachine.java
/** * Update the state of the client upon the received status of the goal. * @param goalStatus Status of the goal. *///from w ww. ja v a2 s.com public synchronized void transition(int goalStatus) { Vector<Integer> nextStates; Iterator<Integer> iterStates; // transition to next states nextStates = getTransition(goalStatus); iterStates = nextStates.iterator(); log.info("ClientStateMachine - State transition invoked."); while (iterStates.hasNext()) { this.state = iterStates.next(); } }
From source file:org.apache.axis.message.SOAPHeader.java
public Iterator extractAllHeaderElements() { Vector result = new Vector(); List headers = getChildren(); if (headers != null) { for (int i = 0; i < headers.size(); i++) { result.add(headers.get(i));// ww w. ja v a 2 s . co m } headers.clear(); } return result.iterator(); }
From source file:org.openntf.xpt.core.dss.AbstractStorageService.java
private List<String> getStringListFromDocument(Document docCurrent, String strField) { List<String> lstRC = new ArrayList<String>(); try {//from w w w .j a va 2s .co m Vector<?> vecRes = docCurrent.getItemValue(strField); for (Iterator<?> itValue = vecRes.iterator(); itValue.hasNext();) { lstRC.add("" + itValue.next()); } } catch (Exception e) { LoggerFactory.logError(getClass(), "General Error", e); throw new XPTRuntimeException("General Error", e); } return lstRC; }
From source file:org.jengine.mbean.FTPHL7Client.java
private void goGetThem() { if (running != true) return;//from w w w . j a va 2 s. c o m try { //TODO attempt FTP connection to get files if (connectAndLogin(getHostname(), getUsername(), getPassword()) == true) { log.info("Connected... process files... "); connectionStatus = true; if (changeWorkingDirectory(getWorkingDirectory()) != true) { log.error("Could not change to directory [" + getWorkingDirectory() + "]"); } else { log.info("OK, changed directory to [" + getWorkingDirectory() + "]"); } Vector files = listFileNames(); log.info("OK, got file list, size: " + files.size()); int count = 1; for (Iterator it = files.iterator(); it.hasNext(); count++) { String file = (String) it.next(); log.info(count + "> file: " + file); String localFileName = workingDirectoryLocal + "/" + file; if (fileMatchesPattern(file) == true) { downloadFile(file, localFileName); if (processFile(localFileName) == true) { deleteFile(file); } } else { System.out.println("Bypass & Delete file: " + file); //deleteFile(file); } } } else { connectionStatus = false; } } catch (IOException ie) { log.error("IOException", ie); try { disconnect(); connectionStatus = false; } catch (Exception e) { log.error("Exception", e); } } try { log.debug("Disconnect"); disconnect(); connectionStatus = false; } catch (Exception e) { log.error("Exception", e); } }
From source file:org.kuali.rice.krad.service.impl.PersistenceServiceOjbImpl.java
/** * * @see org.kuali.rice.krad.service.PersistenceService#refreshAllNonUpdatingReferences(org.kuali.rice.krad.bo.BusinessObject) *///from w w w.j av a 2 s . c om @Override public void refreshAllNonUpdatingReferences(PersistableBusinessObject bo) { // get the OJB class-descriptor for the bo class ClassDescriptor classDescriptor = getClassDescriptor(bo.getClass()); // get a list of all reference-descriptors for that class Vector references = classDescriptor.getObjectReferenceDescriptors(); // walk through all of the reference-descriptors for (Iterator iter = references.iterator(); iter.hasNext();) { ObjectReferenceDescriptor reference = (ObjectReferenceDescriptor) iter.next(); // if its NOT an updateable reference, then lets refresh it if (reference.getCascadingStore() == ObjectReferenceDescriptor.CASCADE_NONE) { PersistentField persistentField = reference.getPersistentField(); String referenceName = persistentField.getName(); retrieveReferenceObject(bo, referenceName); } } }