Experimental services
git-svn-id: https://brutex.net/svn/xservices/trunk@92 e7e49efb-446e-492e-b9ec-fcafc1997a86tag-20130205r
parent
307753f767
commit
1b4345c5e9
|
@ -3789,6 +3789,72 @@
|
|||
<title>FileServices</title>
|
||||
<para>The FileServces bundles various file operations. Its WSDL is located at
|
||||
http://server:port/XServices/FileService?wsdl</para>
|
||||
|
||||
<section version="5.0" xml:base="FileServices/downloadFile.xml" xmlns="http://docbook.org/ns/docbook" xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
<title>downloadFile</title>
|
||||
<para>Downloads a file as base64 encoded.
|
||||
Sample request:
|
||||
<screen><![CDATA[
|
||||
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.xservices.brutex.net">
|
||||
<soapenv:Header/>
|
||||
<soapenv:Body>
|
||||
<!-- downloads a file from the XServices server as base64 encoded -->
|
||||
<ws:downloadFile>
|
||||
<file>
|
||||
<type>FILE</type>
|
||||
<uri>c:\temp\test.docx</uri>
|
||||
</file>
|
||||
</ws:downloadFile>
|
||||
</soapenv:Body>
|
||||
</soapenv:Envelope>
|
||||
]]></screen>
|
||||
Sample response:
|
||||
<programlisting language="xml"><![CDATA[
|
||||
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
||||
<soap:Body>
|
||||
<ns2:downloadFileResponse xmlns:ns2="http://ws.xservices.brutex.net">
|
||||
<return>
|
||||
<content>ADQBNA[... snipp ...]wAApzcAAAAA</content>
|
||||
<filename>test.docx</filename>
|
||||
</return>
|
||||
</ns2:downloadFileResponse>
|
||||
</soap:Body>
|
||||
</soap:Envelope>]]></programlisting>
|
||||
</para>
|
||||
<para>Encoding files as base64 is very memory consuming!</para>
|
||||
</section>
|
||||
<section version="5.0" xml:base="FileServices/encodeFile.xml" xmlns="http://docbook.org/ns/docbook" xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
<title>encodeFile</title>
|
||||
<para>Encodes a file as base64.
|
||||
Sample request:
|
||||
<screen><![CDATA[
|
||||
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.xservices.brutex.net">
|
||||
<soapenv:Header/>
|
||||
<soapenv:Body>
|
||||
<ws:encodeFile>
|
||||
<file>
|
||||
<type>FILE</type>
|
||||
<uri>c:\temp\test.docx</uri>
|
||||
</file>
|
||||
</ws:encodeFile>
|
||||
</soapenv:Body>
|
||||
</soapenv:Envelope>
|
||||
]]></screen>
|
||||
Sample response:
|
||||
<programlisting language="xml"><![CDATA[
|
||||
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
||||
<soap:Body>
|
||||
<ns2:encodeFileResponse xmlns:ns2="http://ws.xservices.brutex.net">
|
||||
<return>
|
||||
<content>ADQBNA[... snipp ...]wAApzcAAAAA</content>
|
||||
<filename>test.docx</filename>
|
||||
</return>
|
||||
</ns2:encodeFileResponse>
|
||||
</soap:Body>
|
||||
</soap:Envelope>]]></programlisting>
|
||||
</para>
|
||||
<para>DEPRECATED: Encoding files as base64 is very memory consuming!</para>
|
||||
</section>
|
||||
</section>
|
||||
<section id="mailservices" version="5.0" xml:base="MailServices.xml" xmlns="http://docbook.org/ns/docbook" xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
<title>MailServices</title>
|
||||
|
@ -3878,6 +3944,45 @@
|
|||
correctly.
|
||||
</para>
|
||||
</section>
|
||||
</section>
|
||||
<section id="stringservices" version="5.0" xml:base="StringServices.xml" xmlns="http://docbook.org/ns/docbook" xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
<title>StringServices</title>
|
||||
<para>The StringService bundles various operations. Its WSDL is located at
|
||||
http://server:port/XServices/StringService?wsdl</para>
|
||||
|
||||
<section version="5.0" xml:base="StringServices/replaceRegEx.xml" xmlns="http://docbook.org/ns/docbook" xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
<title>replaceRegEx</title>
|
||||
<para>Search and Replace using regular expression.
|
||||
Sample request:
|
||||
<screen><![CDATA[
|
||||
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
|
||||
xmlns:ws="http://ws.xservices.brutex.net">
|
||||
<soapenv:Header/>
|
||||
<soapenv:Body>
|
||||
<ws:replaceRegEx>
|
||||
<string>Hallo Welt</string>
|
||||
<search>W.*</search>
|
||||
<replace>Brian</replace>
|
||||
<regexflags>ig</regexflags>
|
||||
</ws:replaceRegEx>
|
||||
</soapenv:Body>
|
||||
</soapenv:Envelope>
|
||||
]]></screen>
|
||||
Sample response:
|
||||
<programlisting language="xml"><![CDATA[
|
||||
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
||||
<soap:Body>
|
||||
<ns2:replaceRegExResponse xmlns:ns2="http://ws.xservices.brutex.net">
|
||||
<return>
|
||||
<string>Hallo Brian</string>
|
||||
<count>1</count>
|
||||
</return>
|
||||
</ns2:replaceRegExResponse>
|
||||
</soap:Body>
|
||||
</soap:Envelope>]]></programlisting>
|
||||
</para>
|
||||
<para>Allowed regexflags are case-insensitive (i) and global search (g).</para>
|
||||
</section>
|
||||
</section>
|
||||
</chapter>
|
||||
|
||||
|
|
|
@ -5,4 +5,7 @@
|
|||
<title>FileServices</title>
|
||||
<para>The FileServces bundles various file operations. Its WSDL is located at
|
||||
http://server:port/XServices/FileService?wsdl</para>
|
||||
|
||||
<xi:include href="FileServices/downloadFile.xml" />
|
||||
<xi:include href="FileServices/encodeFile.xml" />
|
||||
</section>
|
|
@ -0,0 +1,39 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<!DOCTYPE section [
|
||||
<!ENTITY % myent SYSTEM "../entities.ent">
|
||||
%myent;
|
||||
]>
|
||||
<section xmlns="http://docbook.org/ns/docbook" version="5.0"
|
||||
xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
<title>downloadFile</title>
|
||||
<para>Downloads a file as base64 encoded.
|
||||
Sample request:
|
||||
<screen><![CDATA[
|
||||
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.xservices.brutex.net">
|
||||
<soapenv:Header/>
|
||||
<soapenv:Body>
|
||||
<!-- downloads a file from the XServices server as base64 encoded -->
|
||||
<ws:downloadFile>
|
||||
<file>
|
||||
<type>FILE</type>
|
||||
<uri>c:\temp\test.docx</uri>
|
||||
</file>
|
||||
</ws:downloadFile>
|
||||
</soapenv:Body>
|
||||
</soapenv:Envelope>
|
||||
]]></screen>
|
||||
Sample response:
|
||||
<programlisting language="xml"><![CDATA[
|
||||
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
||||
<soap:Body>
|
||||
<ns2:downloadFileResponse xmlns:ns2="http://ws.xservices.brutex.net">
|
||||
<return>
|
||||
<content>ADQBNA[... snipp ...]wAApzcAAAAA</content>
|
||||
<filename>test.docx</filename>
|
||||
</return>
|
||||
</ns2:downloadFileResponse>
|
||||
</soap:Body>
|
||||
</soap:Envelope>]]></programlisting>
|
||||
</para>
|
||||
<para>Encoding files as base64 is very memory consuming!</para>
|
||||
</section>
|
|
@ -0,0 +1,38 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<!DOCTYPE section [
|
||||
<!ENTITY % myent SYSTEM "../entities.ent">
|
||||
%myent;
|
||||
]>
|
||||
<section xmlns="http://docbook.org/ns/docbook" version="5.0"
|
||||
xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
<title>encodeFile</title>
|
||||
<para>Encodes a file as base64.
|
||||
Sample request:
|
||||
<screen><![CDATA[
|
||||
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.xservices.brutex.net">
|
||||
<soapenv:Header/>
|
||||
<soapenv:Body>
|
||||
<ws:encodeFile>
|
||||
<file>
|
||||
<type>FILE</type>
|
||||
<uri>c:\temp\test.docx</uri>
|
||||
</file>
|
||||
</ws:encodeFile>
|
||||
</soapenv:Body>
|
||||
</soapenv:Envelope>
|
||||
]]></screen>
|
||||
Sample response:
|
||||
<programlisting language="xml"><![CDATA[
|
||||
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
||||
<soap:Body>
|
||||
<ns2:encodeFileResponse xmlns:ns2="http://ws.xservices.brutex.net">
|
||||
<return>
|
||||
<content>ADQBNA[... snipp ...]wAApzcAAAAA</content>
|
||||
<filename>test.docx</filename>
|
||||
</return>
|
||||
</ns2:encodeFileResponse>
|
||||
</soap:Body>
|
||||
</soap:Envelope>]]></programlisting>
|
||||
</para>
|
||||
<para>DEPRECATED: Encoding files as base64 is very memory consuming!</para>
|
||||
</section>
|
|
@ -0,0 +1,38 @@
|
|||
# DEFAULT CACHE REGION
|
||||
jcs.default=DC
|
||||
jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
|
||||
jcs.default.cacheattributes.MaxObjects=1000
|
||||
jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
|
||||
jcs.default.cacheattributes.UseMemoryShrinker=false
|
||||
jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
|
||||
jcs.default.cacheattributes.ShrinkerIntervalSeconds=60
|
||||
jcs.default.elementattributes=org.apache.jcs.engine.ElementAttributes
|
||||
jcs.default.elementattributes.IsEternal=false
|
||||
jcs.default.elementattributes.MaxLifeSeconds=21600
|
||||
jcs.default.elementattributes.IdleTime=1800
|
||||
jcs.default.elementattributes.IsSpool=true
|
||||
jcs.default.elementattributes.IsRemote=true
|
||||
jcs.default.elementattributes.IsLateral=true
|
||||
|
||||
# PRE-DEFINED CACHE REGIONS
|
||||
jcs.region.FileCache=DC
|
||||
jcs.region.FileCache.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
|
||||
jcs.region.FileCache.cacheattributes.MaxObjects=1000
|
||||
jcs.region.FileCache.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
|
||||
jcs.region.FileCache.cacheattributes.UseMemoryShrinker=false
|
||||
jcs.region.FileCache.cacheattributes.MaxMemoryIdleTimeSeconds=3600
|
||||
jcs.region.FileCache.cacheattributes.ShrinkerIntervalSeconds=60
|
||||
jcs.region.FileCache.cacheattributes.MaxSpoolPerRun=500
|
||||
jcs.region.FileCache.elementattributes=org.apache.jcs.engine.ElementAttributes
|
||||
jcs.region.FileCache.elementattributes.IsEternal=false
|
||||
|
||||
|
||||
# AVAILABLE AUXILIARY CACHES
|
||||
jcs.auxiliary.DC=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheFactory
|
||||
jcs.auxiliary.DC.attributes=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheAttributes
|
||||
jcs.auxiliary.DC.attributes.DiskPath=${user.dir}/jcs_swap
|
||||
jcs.auxiliary.DC.attributes.MaxPurgatorySize=10000000
|
||||
jcs.auxiliary.DC.attributes.MaxKeySize=1000000
|
||||
jcs.auxiliary.DC.attributes.MaxRecycleBinSize=5000
|
||||
jcs.auxiliary.DC.attributes.OptimizeAtRemoveCount=300000
|
||||
jcs.auxiliary.DC.attributes.ShutdownSpoolTimeLimit=60
|
|
@ -1,39 +0,0 @@
|
|||
package net.brutex.xservices.agent;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.servlet.GenericServlet;
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
|
||||
/**
|
||||
* Servlet implementation class AgentServlet
|
||||
*/
|
||||
public class AgentServlet extends GenericServlet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @see GenericServlet#GenericServlet()
|
||||
*/
|
||||
public AgentServlet() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Servlet#init(ServletConfig)
|
||||
*/
|
||||
public void init(ServletConfig config) throws ServletException {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Servlet#service(ServletRequest request, ServletResponse response)
|
||||
*/
|
||||
public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
System.out.println("Yep. I am here.");
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package net.brutex.xservices.types;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement
|
||||
public class FileInfoListType {
|
||||
|
||||
private List<FileInfoType> list = new ArrayList<FileInfoType>();
|
||||
|
||||
public void setDirectory(File dir, final boolean withDirectories, final boolean withFiles, int depth) {
|
||||
if(depth <=0) return;
|
||||
|
||||
File[] files = dir.listFiles(new FileFilter() {
|
||||
|
||||
public boolean accept(File pathname) {
|
||||
if(!withFiles && !pathname.isFile()) return false;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
if(files==null) return;
|
||||
for( File e : files) {
|
||||
if(e.isDirectory()) setDirectory(e, withDirectories, withFiles, depth-1);
|
||||
if( (withDirectories && e.isDirectory())
|
||||
|| withFiles && e.isFile()) {
|
||||
this.list.add(new FileInfoType(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setDirectory(String dir, final boolean withDirectories, final boolean withFiles, int depth) {
|
||||
setDirectory( (new File(dir)), withDirectories, withFiles, depth);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@XmlElement(name="FileInfoList")
|
||||
public List<FileInfoType> getFiles() {
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
package net.brutex.xservices.types;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
@XmlRootElement
|
||||
public class FileInfoType {
|
||||
|
||||
private String name;
|
||||
private String path;
|
||||
private long filesize;
|
||||
private boolean canWrite;
|
||||
private boolean isDirectory;
|
||||
|
||||
public FileInfoType() {
|
||||
}
|
||||
|
||||
public FileInfoType(File file) {
|
||||
this.name = file.getName();
|
||||
this.path = file.getAbsolutePath().replace('\\', '/');
|
||||
this.canWrite = file.canWrite();
|
||||
this.filesize = file.length();
|
||||
this.isDirectory = file.isDirectory(); }
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
@XmlElement(name="name")
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name the name to set
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the path
|
||||
*/
|
||||
@XmlElement(name="path")
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param path the path to set
|
||||
*/
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the filesize
|
||||
*/
|
||||
@XmlElement(name="size")
|
||||
public long getFilesize() {
|
||||
return filesize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param filesize the filesize to set
|
||||
*/
|
||||
public void setFilesize(long filesize) {
|
||||
this.filesize = filesize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the canWrite
|
||||
*/
|
||||
@XmlElement(name="isWritable")
|
||||
public boolean isCanWrite() {
|
||||
return canWrite;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the isDirectory
|
||||
*/
|
||||
@XmlElement(name="isDirectory")
|
||||
public boolean isDirectory() {
|
||||
return isDirectory;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -48,6 +48,8 @@ public class XServicesDocumentation {
|
|||
"as inline base64 encoded block. Keep in mind that unless you are using MTOM, a lot of " +
|
||||
"java heap memory is used.";
|
||||
|
||||
public static final String SERVICE_OPERATION_ENCODEFILE = "Encodes a file.";
|
||||
|
||||
public static final String SERVICE_OPERATION_UPLOADFILE = "Send a file from client to web service server using either " +
|
||||
"MTOM attachment or base64 inline attachment.";
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@ public interface FileService {
|
|||
|
||||
final String OPERATION_BASENAME ="basename";
|
||||
final String OPERATION_DOWNLOADFILE ="downloadFile";
|
||||
final String OPERATION_ENCODEFILE= "encodeFile";
|
||||
final String OPERATION_UPLOADFILE ="uploadFile";
|
||||
final String OPERATION_COPY ="copy";
|
||||
final String OPERATION_COPYFILE ="copyFile";
|
||||
|
@ -89,6 +90,16 @@ public interface FileService {
|
|||
public abstract AttachmentType downloadFile(
|
||||
@WebParam(name = FileResource.XML_NAME) FileResource res) throws XServicesFault;
|
||||
|
||||
/**
|
||||
* @param res
|
||||
* @return Encodes a file
|
||||
* @throws XServicesFault
|
||||
*/
|
||||
@WSDLDocumentation(XServicesDocumentation.SERVICE_OPERATION_ENCODEFILE)
|
||||
@WebMethod(operationName = OPERATION_ENCODEFILE)
|
||||
public abstract byte[] encodeFile(
|
||||
@WebParam(name = FileResource.XML_NAME) FileResource res) throws XServicesFault;
|
||||
|
||||
/**
|
||||
* @param file
|
||||
* @return The file name of the file that has been uploaded.
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
package net.brutex.xservices.ws.impl;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
|
@ -156,6 +157,26 @@ public class FileServiceImpl implements FileService {
|
|||
}
|
||||
}
|
||||
|
||||
public byte[] encodeFile(FileResource res) throws XServicesFault {
|
||||
InputStream is = null;
|
||||
try {
|
||||
is = res.getAntResource(null).getInputStream();
|
||||
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
int nRead;
|
||||
byte[] data = new byte[4096];
|
||||
while ((nRead = is.read(data, 0, data.length)) != -1) {
|
||||
buffer.write(data, 0, nRead);
|
||||
}
|
||||
buffer.flush();
|
||||
return buffer.toByteArray();
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new XServicesFault(e);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* Copyright 2012 Brian Rosenberger (Brutex Network)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.brutex.xservices.ws.rs;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.HttpHeaders;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import net.brutex.xservices.types.FileInfoType;
|
||||
|
||||
|
||||
|
||||
@Path("/FileService/")
|
||||
@Produces ("application/xml")
|
||||
public interface FileInfo {
|
||||
|
||||
/**
|
||||
* @param dir
|
||||
* @param withDir
|
||||
* @param withFiles
|
||||
* @param depth
|
||||
* @param search
|
||||
* @param count
|
||||
* @param page
|
||||
* @return List of File
|
||||
*/
|
||||
@GET
|
||||
@Path("getFiles/")
|
||||
public Response getFiles(@Context HttpHeaders h,
|
||||
@QueryParam("directory") String dir,
|
||||
@QueryParam("includeDirectories") @DefaultValue("0") boolean withDir,
|
||||
@QueryParam("includeFiles") @DefaultValue("1") boolean withFiles,
|
||||
@QueryParam("depth") @DefaultValue("1") int depth,
|
||||
@QueryParam("search") String search,
|
||||
@QueryParam("itemsPerPage") @DefaultValue("50") int count,
|
||||
@QueryParam("page") @DefaultValue("1") int page);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
package net.brutex.xservices.ws.rs;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.ws.rs.core.GenericEntity;
|
||||
import javax.ws.rs.core.HttpHeaders;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import org.apache.jcs.JCS;
|
||||
import org.apache.jcs.access.exception.CacheException;
|
||||
|
||||
import net.brutex.xservices.types.FileInfoType;
|
||||
|
||||
/**
|
||||
* @author Brian Rosenberger
|
||||
*
|
||||
*/
|
||||
public class FileInfoImpl implements FileInfo {
|
||||
|
||||
public Response getFiles(HttpHeaders h, String dir, boolean withDir,
|
||||
boolean withFiles, int level, String search, int count, int page) {
|
||||
|
||||
System.out.println("Listing directory: " + dir);
|
||||
if(level <= 0) level = 1;
|
||||
if(level > 3) level = 3;
|
||||
if(!withDir && !withFiles) withFiles = true;
|
||||
String cachekey = level +"||"+ withFiles +"||"+ withDir +"||" + search + "||" + dir;
|
||||
try {
|
||||
JCS jcs = JCS.getInstance("FileCache");
|
||||
|
||||
List<FileInfoType> list = (List<FileInfoType>) jcs.get(cachekey);
|
||||
if(list == null) {
|
||||
list = setDirectory(dir, withDir, withFiles, level, search);
|
||||
jcs.put(cachekey, list);
|
||||
System.out.println("Stored in Cache: " + list.toString());
|
||||
} else {
|
||||
System.out.println("Got from Cache: " + list.toString());
|
||||
}
|
||||
|
||||
|
||||
int fromIndex = 0;
|
||||
int toIndex = 0;
|
||||
fromIndex = (page-1) * count;
|
||||
toIndex = (page*count);
|
||||
if(toIndex>list.size()) toIndex = list.size();
|
||||
if(fromIndex>toIndex) fromIndex=toIndex;
|
||||
GenericEntity<List<FileInfoType>> sublist = new GenericEntity<List<FileInfoType>>(list.subList(fromIndex, toIndex) ){};
|
||||
return Response.ok( sublist ).build();
|
||||
} catch (CacheException e) {
|
||||
Response.serverError().build();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void setDirectory(List<FileInfoType> list, File dir, final boolean withDirectories, final boolean withFiles, final int depth, final String search) {
|
||||
if(depth <=0) return;
|
||||
|
||||
File[] files = dir.listFiles(new FileFilter() {
|
||||
|
||||
public boolean accept(File pathname) {
|
||||
if(pathname.isDirectory() && depth > 1) return true;
|
||||
if(search == null || search.equals("")) return true;
|
||||
if(!pathname.getAbsolutePath().contains(search)) return false;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
if(dir.getParentFile() != null && withDirectories==true) list.add(new FileInfoType(dir.getParentFile()));
|
||||
if(files==null) return;
|
||||
|
||||
for( File e : files) {
|
||||
if(e.isDirectory()) setDirectory(list, e, withDirectories, withFiles, depth-1, search);
|
||||
if( (withDirectories && e.isDirectory())
|
||||
|| (withFiles && e.isFile()) ) {
|
||||
list.add(new FileInfoType(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<FileInfoType> setDirectory(String dir, final boolean withDirectories, final boolean withFiles, int depth, String search) {
|
||||
List<FileInfoType> list = new ArrayList<FileInfoType>();
|
||||
setDirectory( list, (new File(dir)), withDirectories, withFiles, depth, search);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package net.brutex.xservices.ws.rs;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
@XmlRootElement(name="FileList")
|
||||
public class FileListType {
|
||||
|
||||
@XmlElement
|
||||
public String name;
|
||||
|
||||
public FileListType(){};
|
||||
public FileListType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<con:soapui-project name="FileRest" soapui-version="4.0.1" abortOnError="false" runType="SEQUENTIAL" xmlns:con="http://eviware.com/soapui/config"><con:settings/><con:properties/><con:wssContainer/></con:soapui-project>
|
|
@ -34,6 +34,8 @@
|
|||
<xs:element name="downloadFileResponse" type="tns:downloadFileResponse"/>
|
||||
<xs:element name="echoToFile" type="tns:echoToFile"/>
|
||||
<xs:element name="echoToFileResponse" type="tns:echoToFileResponse"/>
|
||||
<xs:element name="encodeFile" type="tns:encodeFile"/>
|
||||
<xs:element name="encodeFileResponse" type="tns:encodeFileResponse"/>
|
||||
<xs:element name="loadResource" type="tns:loadResource"/>
|
||||
<xs:element name="loadResourceFromArchive" type="tns:loadResourceFromArchive"/>
|
||||
<xs:element name="loadResourceFromArchiveResponse" type="tns:loadResourceFromArchiveResponse"/>
|
||||
|
@ -69,6 +71,16 @@
|
|||
<xs:element minOccurs="0" name="filename" type="xs:string"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="encodeFile">
|
||||
<xs:sequence>
|
||||
<xs:element minOccurs="0" name="file" type="tns:FileResourceType"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="encodeFileResponse">
|
||||
<xs:sequence>
|
||||
<xs:element minOccurs="0" name="return" type="xs:base64Binary"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="replaceInFileRegEx">
|
||||
<xs:sequence>
|
||||
<xs:element minOccurs="0" name="file" type="tns:FileResourceType"/>
|
||||
|
@ -361,6 +373,9 @@
|
|||
<wsdl:message name="basename">
|
||||
<wsdl:part element="tns:basename" name="parameters"></wsdl:part>
|
||||
</wsdl:message>
|
||||
<wsdl:message name="encodeFile">
|
||||
<wsdl:part element="tns:encodeFile" name="parameters"></wsdl:part>
|
||||
</wsdl:message>
|
||||
<wsdl:message name="uploadFile">
|
||||
<wsdl:part element="tns:uploadFile" name="parameters"></wsdl:part>
|
||||
</wsdl:message>
|
||||
|
@ -385,18 +400,21 @@
|
|||
<wsdl:message name="replaceInFileRegExResponse">
|
||||
<wsdl:part element="tns:replaceInFileRegExResponse" name="parameters"></wsdl:part>
|
||||
</wsdl:message>
|
||||
<wsdl:message name="encodeFileResponse">
|
||||
<wsdl:part element="tns:encodeFileResponse" name="parameters"></wsdl:part>
|
||||
</wsdl:message>
|
||||
<wsdl:message name="replaceInFileResponse">
|
||||
<wsdl:part element="tns:replaceInFileResponse" name="parameters"></wsdl:part>
|
||||
</wsdl:message>
|
||||
<wsdl:message name="copyFileResponse">
|
||||
<wsdl:part element="tns:copyFileResponse" name="parameters"></wsdl:part>
|
||||
</wsdl:message>
|
||||
<wsdl:message name="echoToFile">
|
||||
<wsdl:part element="tns:echoToFile" name="parameters"></wsdl:part>
|
||||
</wsdl:message>
|
||||
<wsdl:message name="basenameResponse">
|
||||
<wsdl:part element="tns:basenameResponse" name="parameters"></wsdl:part>
|
||||
</wsdl:message>
|
||||
<wsdl:message name="echoToFile">
|
||||
<wsdl:part element="tns:echoToFile" name="parameters"></wsdl:part>
|
||||
</wsdl:message>
|
||||
<wsdl:message name="copyFile">
|
||||
<wsdl:part element="tns:copyFile" name="parameters"></wsdl:part>
|
||||
</wsdl:message>
|
||||
|
@ -407,6 +425,12 @@
|
|||
<wsdl:output message="tns:downloadFileResponse" name="downloadFileResponse"></wsdl:output>
|
||||
<wsdl:fault message="tns:XServicesFault" name="XServicesFault"></wsdl:fault>
|
||||
</wsdl:operation>
|
||||
<wsdl:operation name="encodeFile">
|
||||
<wsdl:documentation>Encodes a file.</wsdl:documentation>
|
||||
<wsdl:input message="tns:encodeFile" name="encodeFile"></wsdl:input>
|
||||
<wsdl:output message="tns:encodeFileResponse" name="encodeFileResponse"></wsdl:output>
|
||||
<wsdl:fault message="tns:XServicesFault" name="XServicesFault"></wsdl:fault>
|
||||
</wsdl:operation>
|
||||
<wsdl:operation name="replaceInFileRegEx">
|
||||
<wsdl:documentation>Replaces every <regex pattern> with a string in an ascii file</wsdl:documentation>
|
||||
<wsdl:input message="tns:replaceInFileRegEx" name="replaceInFileRegEx"></wsdl:input>
|
||||
|
@ -493,6 +517,18 @@
|
|||
<soap:fault name="XServicesFault" use="literal"/>
|
||||
</wsdl:fault>
|
||||
</wsdl:operation>
|
||||
<wsdl:operation name="encodeFile">
|
||||
<soap:operation soapAction="" style="document"/>
|
||||
<wsdl:input name="encodeFile">
|
||||
<soap:body use="literal"/>
|
||||
</wsdl:input>
|
||||
<wsdl:output name="encodeFileResponse">
|
||||
<soap:body use="literal"/>
|
||||
</wsdl:output>
|
||||
<wsdl:fault name="XServicesFault">
|
||||
<soap:fault name="XServicesFault" use="literal"/>
|
||||
</wsdl:fault>
|
||||
</wsdl:operation>
|
||||
<wsdl:operation name="changeMode">
|
||||
<soap:operation soapAction="" style="document"/>
|
||||
<wsdl:input name="changeMode">
|
||||
|
@ -791,7 +827,7 @@
|
|||
<ws:downloadFile>
|
||||
<file>
|
||||
<type>FILE</type>
|
||||
<uri>c:\temp\test.docx</uri>
|
||||
<uri>c:/temp/test.docx</uri>
|
||||
</file>
|
||||
</ws:downloadFile>
|
||||
</soapenv:Body>
|
||||
|
@ -800,10 +836,10 @@
|
|||
<soapenv:Body>
|
||||
<ws:echoToFile>
|
||||
<message>Here is some text with german umlauts (äöü).</message>
|
||||
<!-- File _must_ exist in advance -->
|
||||
<file>c:/temp/somefile.txt</file>
|
||||
<!--Optional:-->
|
||||
<encoding>utf-8</encoding>
|
||||
<append>false</append>
|
||||
<append>hallo</append>
|
||||
</ws:echoToFile>
|
||||
</soapenv:Body>
|
||||
</soapenv:Envelope>]]></con:request><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:wsaConfig mustUnderstand="NONE" version="200508" action="http://ws.xservices.brutex.net/FileService/echoToFile"/><con:wsrmConfig version="1.2"/></con:call></con:operation><con:operation isOneWay="false" action="" name="loadResource" bindingOperationName="loadResource" type="Request-Response" outputName="loadResourceResponse" inputName="loadResource" receivesAttachments="false" sendsAttachments="false" anonymous="optional"><con:settings/><con:call name="Request 1"><con:settings/><con:encoding>UTF-8</con:encoding><con:endpoint>http://localhost:8080/XServices/FileService</con:endpoint><con:request><![CDATA[<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.xservices.brutex.net">
|
||||
|
@ -887,4 +923,15 @@
|
|||
</file>
|
||||
</ws:uploadFile>
|
||||
</soapenv:Body>
|
||||
</soapenv:Envelope>]]></con:request><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:wsaConfig mustUnderstand="NONE" version="200508" action="http://ws.xservices.brutex.net/FileService/uploadFile"/><con:wsrmConfig version="1.2"/></con:call></con:operation></con:interface><con:properties/><con:wssContainer/><con:sensitiveInformation/></con:soapui-project>
|
||||
</soapenv:Envelope>]]></con:request><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:wsaConfig mustUnderstand="NONE" version="200508" action="http://ws.xservices.brutex.net/FileService/uploadFile"/><con:wsrmConfig version="1.2"/></con:call></con:operation><con:operation isOneWay="false" action="" name="encodeFile" bindingOperationName="encodeFile" type="Request-Response" outputName="encodeFileResponse" inputName="encodeFile" receivesAttachments="false" sendsAttachments="false" anonymous="optional"><con:settings/><con:call name="Request 1"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:encoding>UTF-8</con:encoding><con:endpoint>http://localhost:8080/XServices/FileService</con:endpoint><con:request><![CDATA[<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.xservices.brutex.net">
|
||||
<soapenv:Header/>
|
||||
<soapenv:Body>
|
||||
<ws:encodeFile>
|
||||
<!--Optional:-->
|
||||
<file>
|
||||
<type>FILE</type>
|
||||
<uri>c:\temp\test.docx</uri>
|
||||
</file>
|
||||
</ws:encodeFile>
|
||||
</soapenv:Body>
|
||||
</soapenv:Envelope>]]></con:request><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:wsaConfig mustUnderstand="NONE" version="200508" action="http://ws.xservices.brutex.net/FileService/encodeFile"/><con:wsrmConfig version="1.2"/></con:call></con:operation></con:interface><con:properties/><con:wssContainer/><con:sensitiveInformation/></con:soapui-project>
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<con:soapui-project name="FileServiceMTOM" resourceRoot="" soapui-version="3.6.1" abortOnError="false" runType="SEQUENTIAL" xmlns:con="http://eviware.com/soapui/config"><con:settings/><con:interface xsi:type="con:WsdlInterface" wsaVersion="NONE" name="FileServiceSoapBinding" type="wsdl" bindingName="{http://ws.xservices.brutex.net}FileServiceSoapBinding" soapVersion="1_1" anonymous="optional" definition="http://localhost:8080/XServices/FileServiceMTOM?wsdl" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:settings/><con:definitionCache type="TEXT" rootPart="http://localhost:8080/XServices/FileServiceMTOM?wsdl"><con:part><con:url>http://localhost:8080/XServices/FileServiceMTOM?wsdl</con:url><con:content><![CDATA[<wsdl:definitions name="FileService" targetNamespace="http://ws.xservices.brutex.net" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://ws.xservices.brutex.net" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
||||
<con:soapui-project name="FileServiceMTOM" resourceRoot="" soapui-version="4.0.1" abortOnError="false" runType="SEQUENTIAL" xmlns:con="http://eviware.com/soapui/config"><con:settings/><con:interface xsi:type="con:WsdlInterface" wsaVersion="NONE" name="FileServiceSoapBinding" type="wsdl" bindingName="{http://ws.xservices.brutex.net}FileServiceSoapBinding" soapVersion="1_1" anonymous="optional" definition="http://localhost:8080/XServices/FileServiceMTOM?wsdl" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:settings/><con:definitionCache type="TEXT" rootPart="http://localhost:8080/XServices/FileServiceMTOM?wsdl"><con:part><con:url>http://localhost:8080/XServices/FileServiceMTOM?wsdl</con:url><con:content><![CDATA[<wsdl:definitions name="FileService" targetNamespace="http://ws.xservices.brutex.net" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://ws.xservices.brutex.net" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
||||
<wsdl:types>
|
||||
<xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://ws.xservices.brutex.net" xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||
<xs:element name="antProperty" type="tns:antProperty"/>
|
||||
|
|
|
@ -71,4 +71,12 @@
|
|||
<entry key="attachment-memory-threshold" value="2000" />
|
||||
</jaxws:properties>
|
||||
</jaxws:endpoint>
|
||||
|
||||
<jaxrs:server id="FileInfo" address="/fileinfo">
|
||||
<jaxrs:serviceBeans>
|
||||
<ref bean="FileInfoBean" />
|
||||
</jaxrs:serviceBeans>
|
||||
</jaxrs:server>
|
||||
|
||||
<bean id="FileInfoBean" class="net.brutex.xservices.ws.rs.FileInfoImpl" />
|
||||
</beans>
|
||||
|
|
|
@ -52,19 +52,4 @@
|
|||
<welcome-file-list>
|
||||
<welcome-file>index.html</welcome-file>
|
||||
</welcome-file-list>
|
||||
<servlet>
|
||||
<description></description>
|
||||
<display-name>AgentServlet</display-name>
|
||||
<servlet-name>AgentServlet</servlet-name>
|
||||
<servlet-class>net.brutex.xservices.agent.AgentServlet</servlet-class>
|
||||
<init-param>
|
||||
<description>Port to listen on</description>
|
||||
<param-name>port</param-name>
|
||||
<param-value>1313</param-value>
|
||||
</init-param>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>AgentServlet</servlet-name>
|
||||
<url-pattern>/AgentServlet</url-pattern>
|
||||
</servlet-mapping>
|
||||
</web-app>
|
Loading…
Reference in New Issue