List of usage examples for org.apache.commons.vfs2.provider UriParser extractQueryString
public static String extractQueryString(final StringBuilder name)
From source file:com.yenlo.synapse.transport.vfs.VFSOutTransportInfo.java
/** * Constructs the VFSOutTransportInfo containing the information about the file to which the * response has to be submitted to.//from www . j a v a 2 s . c om * * @param outFileURI URI of the file to which the message is delivered */ VFSOutTransportInfo(String outFileURI, boolean fileLocking) { if (outFileURI.startsWith(VFSConstants.VFS_PREFIX)) { String vfsURI = outFileURI.substring(VFSConstants.VFS_PREFIX.length()); String queryParams = UriParser.extractQueryString(new StringBuilder(vfsURI)); //Lets get rid of unwanted query params and clean the URI if (null != queryParams && !"".equals(queryParams) && vfsURI.contains(VFSConstants.APPEND)) { this.outFileURI = cleanURI(vfsURI, queryParams, outFileURI); } else { this.outFileURI = vfsURI; } } else { this.outFileURI = outFileURI; } Map<String, String> properties = BaseUtils.getEPRProperties(outFileURI); if (properties.containsKey(VFSConstants.MAX_RETRY_COUNT)) { String strMaxRetryCount = properties.get(VFSConstants.MAX_RETRY_COUNT); maxRetryCount = Integer.parseInt(strMaxRetryCount); } else { maxRetryCount = VFSConstants.DEFAULT_MAX_RETRY_COUNT; } if (properties.containsKey(VFSConstants.RECONNECT_TIMEOUT)) { String strReconnectTimeout = properties.get(VFSConstants.RECONNECT_TIMEOUT); reconnectTimeout = Long.parseLong(strReconnectTimeout) * 1000; } else { reconnectTimeout = VFSConstants.DEFAULT_RECONNECT_TIMEOUT; } if (properties.containsKey(VFSConstants.TRANSPORT_FILE_LOCKING)) { String strFileLocking = properties.get(VFSConstants.TRANSPORT_FILE_LOCKING); if (VFSConstants.TRANSPORT_FILE_LOCKING_ENABLED.equals(strFileLocking)) { fileLocking = true; } else if (VFSConstants.TRANSPORT_FILE_LOCKING_DISABLED.equals(strFileLocking)) { fileLocking = false; } } else { this.fileLocking = fileLocking; } if (properties.containsKey(VFSConstants.APPEND)) { String strAppend = properties.get(VFSConstants.APPEND); append = Boolean.parseBoolean(strAppend); } if (log.isDebugEnabled()) { log.debug("Using the fileURI : " + this.outFileURI); log.debug("Using the maxRetryCount : " + maxRetryCount); log.debug("Using the reconnectionTimeout : " + reconnectTimeout); log.debug("Using the append : " + append); log.debug("File locking : " + (this.fileLocking ? "ON" : "OFF")); } }
From source file:org.apache.synapse.commons.vfs.VFSOutTransportInfo.java
/** * Constructs the VFSOutTransportInfo containing the information about the file to which the * response has to be submitted to./* w ww. j a v a 2 s .c o m*/ * * @param outFileURI URI of the file to which the message is delivered */ public VFSOutTransportInfo(String outFileURI, boolean fileLocking) { if (outFileURI.startsWith(VFSConstants.VFS_PREFIX)) { String vfsURI = outFileURI.substring(VFSConstants.VFS_PREFIX.length()); String queryParams = UriParser.extractQueryString(new StringBuilder(vfsURI)); //Lets get rid of unwanted query params and clean the URI if (null != queryParams && !"".equals(queryParams) && vfsURI.contains(VFSConstants.APPEND)) { this.outFileURI = cleanURI(vfsURI, queryParams, outFileURI); } else { this.outFileURI = vfsURI; } } else { this.outFileURI = outFileURI; } Map<String, String> properties = BaseUtils.getEPRProperties(outFileURI); String scheme = UriParser.extractScheme(this.outFileURI); properties.put(VFSConstants.SCHEME, scheme); setOutFileSystemOptionsMap(properties); if (properties.containsKey(VFSConstants.SUBFOLDER_TIMESTAMP)) { String strSubfolderFormat = properties.get(VFSConstants.SUBFOLDER_TIMESTAMP); try { SimpleDateFormat sdf = new SimpleDateFormat(strSubfolderFormat); String strDateformat = sdf.format(new Date()); int iIndex = this.outFileURI.indexOf("?"); if (iIndex > -1) { this.outFileURI = this.outFileURI.substring(0, iIndex) + strDateformat + this.outFileURI.substring(iIndex, this.outFileURI.length()); } else { this.outFileURI += strDateformat; } } catch (Exception e) { log.warn("Error generating subfolder name with date", e); } } if (properties.containsKey(VFSConstants.MAX_RETRY_COUNT)) { String strMaxRetryCount = properties.get(VFSConstants.MAX_RETRY_COUNT); maxRetryCount = Integer.parseInt(strMaxRetryCount); } else { maxRetryCount = VFSConstants.DEFAULT_MAX_RETRY_COUNT; } forceCreateFolder = false; if (properties.containsKey(VFSConstants.FORCE_CREATE_FOLDER)) { String strForceCreateFolder = properties.get(VFSConstants.FORCE_CREATE_FOLDER); if (strForceCreateFolder != null && strForceCreateFolder.toLowerCase().equals("true")) { forceCreateFolder = true; } } if (properties.containsKey(VFSConstants.RECONNECT_TIMEOUT)) { String strReconnectTimeout = properties.get(VFSConstants.RECONNECT_TIMEOUT); reconnectTimeout = Long.parseLong(strReconnectTimeout) * 1000; } else { reconnectTimeout = VFSConstants.DEFAULT_RECONNECT_TIMEOUT; } if (properties.containsKey(VFSConstants.TRANSPORT_FILE_LOCKING)) { String strFileLocking = properties.get(VFSConstants.TRANSPORT_FILE_LOCKING); if (VFSConstants.TRANSPORT_FILE_LOCKING_ENABLED.equals(strFileLocking)) { fileLocking = true; } else if (VFSConstants.TRANSPORT_FILE_LOCKING_DISABLED.equals(strFileLocking)) { fileLocking = false; } } else { this.fileLocking = fileLocking; } if (properties.containsKey(VFSConstants.TRANSPORT_FILE_SEND_FILE_LOCKING)) { String strSendLocking = properties.get(VFSConstants.TRANSPORT_FILE_SEND_FILE_LOCKING); sendFileSynchronously = Boolean.parseBoolean(strSendLocking); } else { sendFileSynchronously = false; } if (properties.containsKey(VFSConstants.APPEND)) { String strAppend = properties.get(VFSConstants.APPEND); append = Boolean.parseBoolean(strAppend); } if (log.isDebugEnabled()) { log.debug("Using the fileURI : " + this.outFileURI); log.debug("Using the maxRetryCount : " + maxRetryCount); log.debug("Using the reconnectionTimeout : " + reconnectTimeout); log.debug("Using the append : " + append); log.debug("File locking : " + (this.fileLocking ? "ON" : "OFF")); } }