From fc5a88101c6dc2c5399e7a72a550c49524126d1d Mon Sep 17 00:00:00 2001 From: RĂ¼diger Timm Date: Mon, 31 Jan 2005 15:59:01 +0000 Subject: INTEGRATION: CWS sdksample (1.4.40); FILE MERGED 2005/01/18 15:52:24 jsc 1.4.40.4: #i29308# generate output in the output directory 2005/01/17 14:30:28 jsc 1.4.40.3: RESYNC: (1.4-1.5); FILE MERGED 2004/06/16 09:43:24 jsc 1.4.40.2: #i29308# explicit imports 2004/06/14 08:33:42 jsc 1.4.40.1: #i29308# use of new UNO bootstrap feature --- .../DevelopersGuide/UCB/ResourceCreator.java | 65 +++++++++------------- 1 file changed, 27 insertions(+), 38 deletions(-) diff --git a/odk/examples/DevelopersGuide/UCB/ResourceCreator.java b/odk/examples/DevelopersGuide/UCB/ResourceCreator.java index 7e338942c616..202941e1772a 100644 --- a/odk/examples/DevelopersGuide/UCB/ResourceCreator.java +++ b/odk/examples/DevelopersGuide/UCB/ResourceCreator.java @@ -2,9 +2,9 @@ * * $RCSfile: ResourceCreator.java,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: vg $ $Date: 2004-12-23 09:48:48 $ + * last change: $Author: rt $ $Date: 2005-01-31 16:59:01 $ * * The Contents of this file are made available subject to the terms of * the BSD license. @@ -37,11 +37,14 @@ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * *************************************************************************/ -// base classes -import com.sun.star.uno.UnoRuntime; -import com.sun.star.ucb.*; + import com.sun.star.beans.PropertyValue; -import com.sun.star.io.*; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.ucb.ContentInfo; +import com.sun.star.ucb.InsertCommandArgument; +import com.sun.star.ucb.XContent; +import com.sun.star.ucb.XContentCreator; +import com.sun.star.io.XInputStream; /** @@ -54,7 +57,6 @@ public class ResourceCreator { */ private Helper m_helper; private XContent m_content; - private String m_connectString = ""; private String m_contenturl = ""; private String m_name = ""; private String m_srcURL = ""; @@ -63,10 +65,10 @@ public class ResourceCreator { * Constructor. * *@param String[] This construtor requires the arguments: - * -connect=socket,host=..., port=... - * -url=.. - * -srcURL=... (optional). - * -name=... (optional). + * -url=... (optional) + * -name=... (optional) + * -srcURL=... (optional) + * -workdir=... (optional) * See Help (method printCmdLineUsage()). * Without the arguments a new connection to a * running office cannot created. @@ -76,11 +78,10 @@ public class ResourceCreator { // Parse arguments parseArguments( args ); - String connect = getConnect(); String url = getContentURL(); // Init - m_helper = new Helper( connect, url ); + m_helper = new Helper( url ); if ( url.startsWith( "file:///" )) { // Create UCB content @@ -88,8 +89,8 @@ public class ResourceCreator { } else { throw new Exception( "Create new resource : parameter 'url' must contain a File URL " + - "pointing to the file system folder in that the new resource " + - "shall be created. (Example: file:///)" ); + "pointing to the file system folder in which the new resource " + + "shall be created. (Example: file:///tmp/)" ); } } @@ -130,9 +131,8 @@ public class ResourceCreator { if ( sourceURL == null || sourceURL.equals( "" )) { stream = new MyInputStream(); } else { - String[] args = new String[ 2 ]; - args[ 0 ] = "-connect=" + getConnect(); - args[ 1 ] = "-url=" + sourceURL; + String[] args = new String[ 1 ]; + args[ 0 ] = "-url=" + sourceURL; DataStreamRetriever access = new DataStreamRetriever( args ); stream = access.getDataStream(); } @@ -230,15 +230,6 @@ public class ResourceCreator { return m_contenturl; } - /** - * Get source data connection. - * - *@return String That contains the source data connection - */ - public String getConnect() { - return m_connectString; - } - /** * Parse arguments * @@ -247,15 +238,17 @@ public class ResourceCreator { */ public void parseArguments( String[] args ) throws java.lang.Exception { + String workdir = ""; + for ( int i = 0; i < args.length; i++ ) { - if ( args[i].startsWith( "-connect=" )) { - m_connectString = args[i].substring( 9 ); - } else if ( args[i].startsWith( "-url=" )) { + if ( args[i].startsWith( "-url=" )) { m_contenturl = args[i].substring( 5 ); } else if ( args[i].startsWith( "-name=" )) { m_name = args[i].substring( 6 ); } else if ( args[i].startsWith( "-srcURL=" )) { m_srcURL = args[i].substring( 8 ); + } else if ( args[i].startsWith( "-workdir=" )) { + workdir = args[i].substring( 9 ); } else if ( args[i].startsWith( "-help" ) || args[i].startsWith( "-?" )) { printCmdLineUsage(); @@ -263,12 +256,8 @@ public class ResourceCreator { } } - if ( m_connectString == null || m_connectString.equals( "" )) { - m_connectString = "socket,host=localhost,port=2083"; - } - if ( m_contenturl == null || m_contenturl.equals( "" )) { - m_contenturl = Helper.getCurrentDirAsAbsoluteFileURL(); + m_contenturl = Helper.getAbsoluteFileURLFromSystemPath( workdir ); } if ( m_name == null || m_name.equals( "" )) { @@ -276,7 +265,7 @@ public class ResourceCreator { } if ( m_srcURL == null || m_srcURL.equals( "" )) { - m_srcURL = Helper.getAbsoluteFileURL( "data/data.txt" ); + m_srcURL = Helper.prependCurrentDirAsAbsoluteFileURL( "data/data.txt" ); } } @@ -285,9 +274,9 @@ public class ResourceCreator { */ public void printCmdLineUsage() { System.out.println( - "Usage : ResourceCreator -connect=socket,host=...,port=... -url=... -name=... -srcURL=..." ); + "Usage : ResourceCreator -url=... -name=... -srcURL=... -workdir=..." ); System.out.println( - "Defaults: -connect=socket,host=localhost,port=2083 -url= -name=created-resource- -srcURL=/data/data.txt>" ); + "Defaults: -url= -name=created-resource- -srcURL=/data/data.txt> -workdir=" ); System.out.println( "\nExample : -url=file:///home/kai/ -name=newfile.txt -srcURL=file:///home/kai/sourcefile.txt" ); } -- cgit v1.2.3