View Javadoc

1   /* -*- mode: JDE; c-basic-offset: 2; indent-tabs-mode: nil -*-
2    *
3    * $Id: BasicUsageExample.java,v 1.3 2003/07/12 16:13:23 ljnelson Exp $
4    *
5    * Copyright (c) 2003 Laird Jarrett Nelson.
6    *
7    * Permission is hereby granted, free of charge, to any person obtaining a copy
8    * of this software and associated documentation files (the "Software"), to deal
9    * in the Software without restriction, including without limitation the rights
10   * to use, copy, modify, merge, publish, distribute, sublicense and/or sell
11   * copies of the Software, and to permit persons to whom the Software is
12   * furnished to do so, subject to the following conditions:
13   *
14   * The above copyright notice and this permission notice shall be included in
15   * all copies or substantial portions of the Software.
16   *
17   * THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
20   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23   * SOFTWARE.
24   *
25   * The original copy of this license is available at
26   * http://www.opensource.org/license/mit-license.html.
27   */
28  package examples;
29  
30  import java.io.File;
31  
32  import java.util.Date;
33  
34  import sfutils.Administrator;
35  import sfutils.Project;
36  
37  import sfutils.frs.FileRelease;
38  import sfutils.frs.FileSpecification;
39  import sfutils.frs.Package;
40  
41  import sfutils.frs.web.HttpUnitPublisher;
42  
43  /***
44   * An example of how to use the file release system classes.  This example will
45   * compile, but will not work as all of the parameters (file names, project
46   * names, passwords and the like) are fictitious.
47   *
48   * @author     <a href="mailto:ljnelson94@alumni.amherst.edu">Laird Nelson</a>
49   * @version    $Revision: 1.3 $ $Date: 2003/07/12 16:13:23 $
50   * @since      July 7, 2003
51   */
52  public class BasicUsageExample {
53  
54    /***
55     * Creates a new {@link BasicUsageExample}.  Not used.
56     */
57    private BasicUsageExample() {
58      super();
59    }
60  
61    /***
62     * If this were a fully-functional class, this method would create a {@link
63     * FileRelease} and {@linkplain FileRelease#publish() publish it}.
64     *
65     * @param      args
66     *               the command line arguments; ignored
67     * @exception  Exception
68     *               if an error occurs, which it will if this method is actually
69     *               invoked
70     */
71    public static final void main(final String[] args) throws Exception {
72  
73      final Administrator admin = new Administrator();
74      admin.setName("username");
75      admin.setPassword("password");
76  
77      final Project project = new Project();
78      project.setName("My Project"); // the "normal" project name
79      project.setShortName("myproj"); // must be a valid project shortname
80      project.setAdministrator(admin);
81  
82      final Package packaj = new Package();
83      packaj.setName("myproj"); // name it whatever you like
84      packaj.setHidden(false);
85      packaj.setProject(project);
86  
87      final FileRelease release = new FileRelease();
88      release.setName("myproj-1.0"); // name it whatever you like
89      release.setPackage(packaj);
90      release.setHidden(false);
91      release.setReleaseDate(new Date()); // or whenever you like
92      release.setNotifyOthers(true);
93  
94      final File changeLogFile = new File("/path/to/changelog.txt");
95      release.setChangeLogFile(changeLogFile);
96  
97      release.setReleaseNotes("Behold the release notes");
98  
99      final FileSpecification spec1 = new FileSpecification();
100     spec1.setFile(new File("/path/to/file1.txt"));
101     spec1.setFileType(FileSpecification.TEXT_FILE);
102     spec1.setProcessorType(FileSpecification.PLATFORM_INDEPENDENT_PROCESSOR);
103     spec1.setReleaseDate(new Date());
104 
105     release.setFileSpecifications(new FileSpecification[] { spec1 });
106 
107     release.setPublisher(new HttpUnitPublisher());
108     release.publish();
109 
110   }
111 
112 }