/xservices/trunk/src/java/net/brutex/xservices/ws/FileService.java |
---|
1,12 → 1,33 |
/* |
* Copyright 2010 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; |
import java.util.List; |
import javax.activation.DataHandler; |
import javax.jws.WebMethod; |
import javax.jws.WebParam; |
import javax.jws.WebService; |
import javax.xml.bind.annotation.XmlElement; |
import org.apache.cxf.annotations.WSDLDocumentation; |
import org.apache.cxf.annotations.WSDLDocumentationCollection; |
import com.sun.xml.internal.ws.api.model.wsdl.WSDLDescriptorKind; |
import net.brutex.xservices.types.ArchiveResource; |
import net.brutex.xservices.types.AttachmentType; |
import net.brutex.xservices.types.FileResource; |
14,44 → 35,114 |
import net.brutex.xservices.types.ReplacePattern; |
import net.brutex.xservices.types.ReturnCode; |
import net.brutex.xservices.util.BrutexNamespaces; |
import net.brutex.xservices.util.XServicesDocumentation; |
/** |
* @author Brian Rosenberger |
* |
*/ |
@WebService(targetNamespace = BrutexNamespaces.WS_XSERVICES) |
@WSDLDocumentationCollection( |
{ |
@WSDLDocumentation(value = BrutexNamespaces.BRUTEX_COPYRIGHT, placement = WSDLDocumentation.Placement.TOP) |
} |
) |
public interface FileService { |
/** |
* @param filename |
* @param suffix |
* @return The base name of the given file excluding the suffix. |
*/ |
@WSDLDocumentation(value = "The base name of the given file excluding the suffix.") |
@WebMethod(operationName = "basename") |
public abstract ReturnCode basename( |
@WebParam(name = "file") String filename, |
public abstract String basename( |
@WebParam(name = "file") @XmlElement(required=true) String filename, |
@WebParam(name = "suffix") String suffix); |
/** |
* @param res |
* @return The file itself (MTOM attachment or inline base64) including some file metadata. |
*/ |
@WSDLDocumentation(XServicesDocumentation.SERVICE_OPERATION_DOWNLOADFILE) |
@WebMethod(operationName = "downloadFile") |
public abstract AttachmentType downloadFile( |
@WebParam(name = "file") FileResource res); |
/** |
* @param file |
* @return The file name of the file that has been uploaded. |
*/ |
@WSDLDocumentation(XServicesDocumentation.SERVICE_OPERATION_UPLOADFILE) |
@WebMethod(operationName = "uploadFile") |
public abstract String uploadFile( |
@WebParam(name = "file") AttachmentType file); |
/** |
* @param src |
* @param todir |
* @param plm |
* @param overwrite |
* @param encoding |
* @return |
* @throws XServicesFault |
*/ |
@WSDLDocumentation(value = XServicesDocumentation.SERVICE_OPERATION_COPY) |
@WebMethod(operationName = "copy") |
public abstract ReturnCode copy( |
@WebParam(name = "fileset") FileSetResource src, |
@WebParam(name = "todir") String todir, |
@WebParam(name = "fileset") @XmlElement(required=true) FileSetResource src, |
@WebParam(name = "todir") @XmlElement(required=true) String todir, |
@WebParam(name = "preservelastmodified") boolean plm, |
@WebParam(name = "overwrite") boolean overwrite, |
@WebParam(name = "encoding") String encoding) throws XServicesFault; |
/** |
* @param fromFile |
* @param tofile |
* @param overwrite |
* @return |
* @throws XServicesFault |
*/ |
@WSDLDocumentation(value = XServicesDocumentation.SERVICE_OPERATION_COPYFILE) |
@WebMethod(operationName = "copyFile") |
public abstract ReturnCode copyFile( |
@WebParam(name = "fromFile") @XmlElement(required=true) String fromFile, |
@WebParam(name = "toFile") @XmlElement(required=true) String tofile, |
@WebParam(name = "overwrite") boolean overwrite) throws XServicesFault; |
/** |
* @param res |
* @param encoding |
* @return content of the resource |
*/ |
@WSDLDocumentation(value = XServicesDocumentation.SERVICE_OPERATION_LOADRESOURCE) |
@WebMethod(operationName = "loadResource") |
public abstract ReturnCode loadRes( |
public abstract String loadRes( |
@WebParam(name = "resource") FileResource res, |
@WebParam(name = "encoding") String encoding); |
/** |
* @param res |
* @param encoding |
* @return content of the resource |
*/ |
@WSDLDocumentation(value = XServicesDocumentation.SERVICE_OPERATION_LOADRESOURCEFROMARCHIVE) |
@WebMethod(operationName = "loadResourceFromArchive") |
public abstract ReturnCode loadResFromArchive( |
public abstract String loadResFromArchive( |
@WebParam(name = "archiveresource") ArchiveResource res, |
@WebParam(name = "encoding") String encoding); |
/** |
* @param message |
* @param file |
* @param encoding |
* @param append |
* @return |
*/ |
@WSDLDocumentation(value = XServicesDocumentation.SERVICE_OPERATION_ECHOTOFILE) |
@WebMethod(operationName = "echoToFile") |
public abstract ReturnCode echo2file( |
@WebParam(name = "message") String message, |
@WebParam(name = "file") String file, |
@WebParam(name = "message") @XmlElement(required=true) String message, |
@WebParam(name = "file") @XmlElement(required=true) String file, |
@WebParam(name = "encoding") String encoding, |
@WebParam(name = "append") boolean append); |
58,23 → 149,23 |
@WebMethod(operationName = "changeOwner") |
public abstract ReturnCode changeOwner( |
@WebParam(name = "fileset") FileSetResource res, |
@WebParam(name = "owner") String owner); |
@WebParam(name = "owner") @XmlElement(required=true) String owner); |
@WebMethod(operationName = "changeGroup") |
public abstract ReturnCode changeGroup( |
@WebParam(name = "fileset") FileSetResource res, |
@WebParam(name = "group") String group); |
@WebParam(name = "group") @XmlElement(required=true) String group); |
@WebMethod(operationName = "changeMode") |
public abstract ReturnCode changeMode( |
@WebParam(name = "fileset") FileSetResource res, |
@WebParam(name = "permissions") String perm); |
@WebParam(name = "permissions") @XmlElement(required=true) String perm); |
@WebMethod(operationName = "replaceInFile") |
public abstract ReturnCode replaceInFile( |
@WebParam(name = "file") FileResource res, |
@WebParam(name = "search") String search, |
@WebParam(name = "replace") String replace); |
@WebParam(name = "file") @XmlElement(required=true) FileResource res, |
@WebParam(name = "search") @XmlElement(required=true) String search, |
@WebParam(name = "replace") @XmlElement(required=true) String replace); |
@WebMethod(operationName = "replaceInFile2") |
public abstract ReturnCode replaceInFile2( |
/xservices/trunk/src/java/net/brutex/xservices/ws/impl/FileServiceImpl.java |
---|
23,6 → 23,7 |
import java.io.IOException; |
import java.io.InputStream; |
import java.io.UnsupportedEncodingException; |
import java.util.Iterator; |
import java.util.List; |
import javax.activation.DataHandler; |
57,6 → 58,8 |
import org.apache.tools.ant.taskdefs.optional.unix.Chgrp; |
import org.apache.tools.ant.taskdefs.optional.unix.Chown; |
import org.apache.tools.ant.types.FileSet; |
import org.apache.tools.ant.types.Resource; |
import org.apache.tools.ant.types.ResourceCollection; |
/** |
* |
73,10 → 76,19 |
*/ |
@Override |
@WebMethod(operationName = "basename") |
public ReturnCode basename(@WebParam(name = "file") String filename, |
public String basename(@WebParam(name = "file") String filename, |
@WebParam(name = "suffix") String suffix) { |
return basename(new File(filename), suffix); |
final String BASENAME_VALUE = "basename.value"; |
Basename basename = new Basename(); |
RunTask runner = new RunTask(basename); |
basename.setFile(new File(filename)); |
if (suffix != null && !suffix.equals("")) { |
basename.setSuffix(suffix); |
} |
basename.setProperty("BASENAME_VALUE"); |
ReturnCode r = runner.postTask(); |
return r.getProperty("BASENAME_VALUE"); |
} |
@WebMethod(operationName = "replaceInFile") |
public ReturnCode replaceInFile( |
206,6 → 218,21 |
return copy(src, new File(todir), plm, overwrite, encoding); |
} |
@Override |
public ReturnCode copyFile(String fromFile, |
String tofile, |
boolean overwrite) throws XServicesFault { |
Copy copy = new Copy(); |
copy.setTaskName("Copy"); |
RunTask runner = new RunTask(copy); |
File f = new File(fromFile); |
if( ! f.isFile() ) throw new XServicesFault("File '"+fromFile+"' not found."); |
copy.setFile( new File( fromFile )); |
copy.setTofile(new File(tofile)); |
copy.setOverwrite(overwrite); |
return runner.postTask(); |
} |
/* |
* (non-Javadoc) |
* |
215,12 → 242,20 |
*/ |
@Override |
@WebMethod(operationName = "loadResource") |
public ReturnCode loadRes(@WebParam(name = "resource") FileResource res, |
public String loadRes(@WebParam(name = "resource") FileResource res, |
@WebParam(name = "encoding") String encoding) { |
if (encoding == null || encoding.equals("")) { |
encoding = System.getProperty("file.encoding"); |
} |
return loadResource(res, encoding); |
LoadResource lr = new LoadResource(); |
lr.setTaskName("LoadResource"); |
RunTask runner = new RunTask(lr); |
lr.addConfigured(res.getAntResource(lr.getProject())); |
lr.setEncoding(encoding); |
System.out.println("Using encoding: " + encoding); |
lr.setProperty("LoadResource.out"); |
ReturnCode r = runner.postTask(); |
return r.getProperty("LoadResource.out"); |
} |
/* |
232,13 → 267,22 |
*/ |
@Override |
@WebMethod(operationName = "loadResourceFromArchive") |
public ReturnCode loadResFromArchive( |
public String loadResFromArchive( |
@WebParam(name = "archiveresource") ArchiveResource res, |
@WebParam(name = "encoding") String encoding) { |
if (encoding == null || encoding.equals("")) { |
encoding = System.getProperty("file.encoding"); |
} |
return loadResource(res, encoding); |
LoadResource lr = new LoadResource(); |
lr.setTaskName("LoadResource"); |
RunTask runner = new RunTask(lr); |
lr.addConfigured(res.getAntResource(lr.getProject())); |
lr.setEncoding(encoding); |
System.out.println("Using encoding: " + encoding); |
lr.setProperty("LoadResource.out"); |
ReturnCode r = runner.postTask(); |
return r.getProperty("LoadResource.out"); |
} |
/* |
302,30 → 346,6 |
} |
@WebMethod(exclude = true) |
private ReturnCode basename(File file, String suffix) { |
Basename basename = new Basename(); |
RunTask runner = new RunTask(basename); |
basename.setFile(file); |
if (suffix != null && !suffix.equals("")) { |
basename.setSuffix(suffix); |
} |
basename.setProperty("basename.value"); |
return runner.postTask(); |
} |
@WebMethod(exclude = true) |
private ReturnCode loadResource(ResourceInterface src, String encoding) { |
LoadResource lr = new LoadResource(); |
lr.setTaskName("LoadResource"); |
RunTask runner = new RunTask(lr); |
lr.addConfigured(src.getAntResource(lr.getProject())); |
lr.setEncoding(encoding); |
System.out.println("Using encoding: " + encoding); |
lr.setProperty("LoadResource.out"); |
return runner.postTask(); |
} |
@WebMethod(exclude = true) |
private ReturnCode echo(String msg, File file, String encoding, |
boolean append) { |
Echo echo = new Echo(); |
/xservices/trunk/src/java/net/brutex/xservices/util/XServicesDocumentation.java |
---|
0,0 → 1,65 |
/* |
* Copyright 2011 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.util; |
/** |
* Holds static documentation. |
* |
* |
* @author Brian Rosenberger, bru@brutex.de |
*/ |
public class XServicesDocumentation { |
public static final String BRUTEX_COPYRIGHT = "" + |
"/*\n" + |
"* Copyright 2010 Brian Rosenberger (Brutex Network)\n" + |
"*\n" + |
"* Licensed under the Apache License, Version 2.0 (the \"License\")\n" + |
"* you may not use this file except in compliance with the License.\n" + |
"* You may obtain a copy of the License at\n" + |
"*\n" + |
"* http://www.apache.org/licenses/LICENSE-2.0\n" + |
"*\n" + |
"* Unless required by applicable law or agreed to in writing, software\n" + |
"* distributed under the License is distributed on an \"AS IS\" BASIS,\n" + |
"* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" + |
"* See the License for the specific language governing permissions and\n" + |
"* limitations under the License.\n" + |
"*/"; |
public static final String SERVICE_OPERATION_DOWNLOADFILE = "Download a file from the maschine where the service is running in order " + |
"to process it with the client. The file is either downloaded as a MTOM attachment or " + |
"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_UPLOADFILE = "Send a file from client to web service server using either " + |
"MTOM attachment or base64 inline attachment."; |
public static final String SERVICE_OPERATION_COPY = "Copies a fileset locally on the server."; |
public static final String SERVICE_OPERATION_COPYFILE = "Copies a single file locally on the server"; |
public static final String SERVICE_OPERATION_LOADRESOURCE = "Load the content of a resource"; |
public static final String SERVICE_OPERATION_LOADRESOURCEFROMARCHIVE = "Load the content of a resource"; |
public static final String SERVICE_OPERATION_ECHOTOFILE = "Write or append a string to a file"; |
private XServicesDocumentation() {}; |
} |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/xservices/trunk/src/java/net/brutex/xservices/util/BrutexNamespaces.java |
---|
29,6 → 29,25 |
* Brutex Network XServices web service namespace declaration |
*/ |
public static final String WS_XSERVICES = "http://ws.xservices.brutex.net"; |
/** |
* Copyright and license agreement statement. |
*/ |
public static final String BRUTEX_COPYRIGHT = "" + |
"/*\n" + |
"* Copyright 2010 Brian Rosenberger (Brutex Network)\n" + |
"*\n" + |
"* Licensed under the Apache License, Version 2.0 (the \"License\")\n" + |
"* you may not use this file except in compliance with the License.\n" + |
"* You may obtain a copy of the License at\n" + |
"*\n" + |
"* http://www.apache.org/licenses/LICENSE-2.0\n" + |
"*\n" + |
"* Unless required by applicable law or agreed to in writing, software\n" + |
"* distributed under the License is distributed on an \"AS IS\" BASIS,\n" + |
"* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" + |
"* See the License for the specific language governing permissions and\n" + |
"* limitations under the License.\n" + |
"*/"; |
private BrutexNamespaces() {}; |