1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 package com.sun.star.wizards.web.data;
24 
25 import com.sun.star.wizards.common.ConfigGroup;
26 import com.sun.star.wizards.common.PropertyNames;
27 
28 /**
29  *
30  * A Class which describes the publishing arguments
31  * in a session.
32  * Each session can contain different publishers, which are configured
33  * through such a CGPublish object.
34  */
35 public class CGPublish extends ConfigGroup
36 {
37 
38     public boolean cp_Publish;
39     public String cp_URL;
40     public String cp_Username;
41     public String password;
42     /**
43      * cp_URL is the url given by the user
44      * for this publisher. (in UCB URL form)
45      * This one will be edited to result the "url"
46      * field, which is the true url, ucb uses to publish.
47      * It is used for example to add ftp username and password, or zip url
48      */
49     public String url;
50     /**
51      * if the user approved overwriting files in this publisher target
52      */
53     public boolean overwriteApproved;
54 
55     /**
56      * here I get an URL from user input, and parse it to
57      * a UCB url...
58      * @param url
59      */
setURL(String path)60     public void setURL(String path)
61     {
62         try
63         {
64             this.cp_URL = ((CGSettings) this.root).getFileAccess().getURL(path);
65             overwriteApproved = false;
66         }
67         catch (Exception ex)
68         {
69             ex.printStackTrace();
70         }
71     }
72 
getURL()73     public String getURL()
74     {
75         try
76         {
77             return ((CGSettings) this.root).getFileAccess().getPath(cp_URL, null);
78         }
79         catch (Exception e)
80         {
81             e.printStackTrace();
82             return PropertyNames.EMPTY_STRING;
83         }
84     }
85 
ftpURL()86     private String ftpURL()
87     {
88         return "ftp://" + cp_Username +
89                 ((password != null && password.length() > 0) ? ":" + password : PropertyNames.EMPTY_STRING) + "@" + cp_URL.substring(7);
90     }
91 }
92