Source Code Cross Referenced for ShellRun.java in  » Groupware » hipergate » org » jical » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Groupware » hipergate » org.jical 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.jical;
002:
003:        import java.io.ByteArrayInputStream;
004:        import java.io.File;
005:        import java.io.FileInputStream;
006:        import java.io.InputStream;
007:
008:        import javax.xml.transform.Result;
009:        import javax.xml.transform.Source;
010:        import javax.xml.transform.Transformer;
011:        import javax.xml.transform.TransformerFactory;
012:        import javax.xml.transform.stream.StreamResult;
013:        import javax.xml.transform.stream.StreamSource;
014:
015:        /*
016:         *  Version 1.2
017:         *  Provides extra XSLT capabilities.
018:         *
019:         */
020:        public class ShellRun {
021:            /** Version number. */
022:            public static final String VERSION = "1.4";
023:
024:            public static void main(String args[]) {
025:                /*
026:                 *  The idea here is to provide user who are stuck on the command line and have no access to jboss with
027:                 *  a way to run the JiCal options from CRON. Not really adviseable as it will incur a penalty of starting
028:                 *  java each time but...
029:                 *
030:                 */
031:                if (args.length == 0 || args[0].equalsIgnoreCase("-help")) {
032:                    System.out
033:                            .println("================================================================================\n"
034:                                    + "JICAL v"
035:                                    + VERSION
036:                                    + " SHELL INTERFACE. GDAY - GOOD START! YOU FOUND ME!\n"
037:                                    + "\n"
038:                                    + "Your Options:\n"
039:                                    + " -ical2fburl           <calendarLocation> <fburl> <Organiser> <Email>                <DaysForward>\n"
040:                                    + " -ical2jicalxml        <calendarLocation>         <Organiser> <Email>                <DaysForward>\n"
041:                                    + " -ical2jicaldisplayxml <calendarLocation>         <Organiser> <Email>                <DaysForward> <timerange>\n"
042:                                    + " -xslt                 <calendarLocation>         <Organiser> <Email> <xsl document> <DaysForward>\n"
043:                                    + " -xsltonly                                                            <xsl document> <xml document>\n"
044:                                    + "\n"
045:                                    + "Parameters explained:\n"
046:                                    + "<calendarLocation>  - your iCal location\n"
047:                                    + "                      eg /home/sfg/evolution/local/Calendar/calendar.ics\n"
048:                                    + "<fburl>             - the internet URL for this FBURL before the username.ifb file\n"
049:                                    + "                      eg http://www.eurekait.com/\n"
050:                                    + "<Organiser>         - this is used to name the free busy file. (sfg.ifb)\n"
051:                                    + "                      eg sfg\n"
052:                                    + "<Email>             - the organisers email address\n"
053:                                    + "                      eg sfg@eurekait.com\n"
054:                                    + "<DaysForwardOrDateRange> - how far into the future do we project repeat events\n"
055:                                    + "                         eg1: 180\n"
056:                                    + "                         eg2: 20021215153500-20021215164500 Date formats are reverse ccyyMMddHHMMss\n"
057:                                    + "                              in the form fromdate-todate with the dash showing the start of the new date.\n"
058:                                    + "<timerange>         - If required, will only show events that fall within the time range\n"
059:                                    + "                         eg: 0730-1800 for 7:30am to 6:00pm \n"
060:                                    + "<xsl document>      - The Stylesheet to translate the XML to something else\n"
061:                                    + "                    eg HTML\n"
062:                                    + "<xml document>      - The xml to translate with the Stylesheet.\n"
063:                                    + "\n"
064:                                    + "Learn by example:\n"
065:                                    + "java -jar jical.jar -ical2fburl /home/sfg/evolution/local/Calendar/calendar.ics http://www.eurekait.com/ sfg sfg@eurekait.com 180 > /www/website.live/sfg.ifb\n"
066:                                    + "java -jar jical.jar -ical2jicalxml /home/sfg/evolution/local/Calendar/calendar.ics sfg sfg@eurekait.com 180 > /www/website.live/sfg.xml\n"
067:                                    + "java -jar jical.jar -xslt /home/sfg/evolution/local/Calendar/calendar.ics sfg sfg@eurekait.com xsl/htmllist.xsl 180 > /www/website.live/sfg-yag.html\n"
068:                                    + "java -jar jical.jar -xsltonly fred.xsl jicaldisplayonyl.xml > /www/website.live/sfg.svg\n"
069:                                    + "java -jar jical.jar -ical2jicaldisplayxml /home/sfg/evolution/local/Calendar/calendar.ics sfg sfg@eurekait.com 180 0630-2230 > /www/website.live/jicaldisplay.xml\n"
070:                                    + "================================================================================");
071:                } else if (args[0].equalsIgnoreCase("-ical2fburl")) {
072:                    /* We will be processing as per jboss run but for a single entry. */
073:                    if (args.length != 6) {
074:                        System.err
075:                                .println("Syntax is:  -ical2fburl <calendarLocation> <FBURL> <Organiser> <Email> <DaysForwardOrDateRange>\n"
076:                                        + "Example:\n"
077:                                        + "java -jar jical.jar -ical2FBURL /home/sfg/evolution/local/Calendar/calendar.ics http://www.eurekait.com/ sfg sfg@eurekait.com 180 > /www/website.live/sfg.ifb");
078:                        return;
079:                    }
080:                    ICalendarParser icp = new ICalendarParser();
081:                    ICalendar ical = icp.parse(args[1]);
082:                    ical.setFBUrl(args[2]);
083:                    ical.setOrganizer(args[3]);
084:                    ical.setOrganizerEmail(args[4]);
085:                    //int DaysForwardOrDateRange = java.lang.Integer.parseInt(args[5]);
086:                    //System.out.println(ical.getFBString(DaysForwardOrDateRange));
087:                    try {
088:                        System.out.println(ical.getFBString(args[5]));
089:                    } catch (Exception e) {
090:                        System.err.println(e);
091:                        e.printStackTrace();
092:                    }
093:                } else if (args[0].equalsIgnoreCase("-ical2jicalxml")) {
094:                    /* We will be processing as per jboss run but for a single entry. */
095:                    if (args.length < 5) {
096:                        System.err
097:                                .println("Syntax is:  -ical2jicalxml <calendarLocation> <Organiser> <Email> <DaysForwardOrDateRange>\n"
098:                                        + "Example:\n"
099:                                        + "java -jar jical.jar -ical2jicalxml /home/sfg/evolution/local/Calendar/calendar.ics sfg sfg@eurekait.com 180 0630-2000 > /www/website.live/sfg.xml");
100:                        return;
101:                    }
102:                    ICalendarParser icp = new ICalendarParser();
103:                    ICalendar ical = icp.parse(args[1]);
104:                    ical.setOrganizer(args[2]);
105:                    ical.setOrganizerEmail(args[3]);
106:                    //int DaysForwardOrDateRange = java.lang.Integer.parseInt(args[4]);
107:                    //System.out.println(ical.getJiCalXML(DaysForwardOrDateRange));
108:                    try {
109:                        if (args.length == 5)
110:                            System.out.println(ical.getJiCalXML(args[4], null));
111:                        else
112:                            System.out.println(ical.getJiCalXML(args[4],
113:                                    args[5]));
114:                    } catch (Exception e) {
115:                        System.err.println(e);
116:                        e.printStackTrace();
117:                    }
118:                } else if (args[0].equalsIgnoreCase("-ical2jicaldisplayxml")) {
119:                    /* This option should make it easier to generate calendars of peoples dairies for two reasons..
120:                       Every day is included, so spacing empty days requires no programming in XSLT.
121:                       Ugly events that span days are shown as seperate events per day. ie 7 day event is 7 single daily events.
122:                       Repeat events are broken into their individual events. */
123:                    if (args.length < 5) {
124:                        System.err
125:                                .println("Syntax is:  -ical2jicaldisplayxml <calendarLocation> <Organiser> <Email> <DaysForwardOrDateRange> <timerange>\n"
126:                                        + "Example:\n"
127:                                        + "java -jar jical.jar -ical2jicaldisplayxml /home/sfg/evolution/local/Calendar/calendar.ics sfg sfg@eurekait.com 180 0630-1800 > /www/website.live/sfg-jicaldisplay.xml\n"
128:                                        + "Note - timerange is optional.");
129:                        return;
130:                    }
131:
132:                    ICalendarParser icp = new ICalendarParser();
133:                    ICalendar ical = icp.parse(args[1]);
134:                    ical.setOrganizer(args[2]);
135:                    ical.setOrganizerEmail(args[3]);
136:                    //int DaysForwardOrDateRange = java.lang.Integer.parseInt(args[4]);
137:
138:                    try {
139:                        if (args.length == 5)
140:                            System.out.println(ical.getJiCaldisplayXML(args[4],
141:                                    null));
142:                        else
143:                            System.out.println(ical.getJiCaldisplayXML(args[4],
144:                                    args[5]));
145:
146:                    } catch (Exception e) {
147:                        System.err.println(e);
148:                        e.printStackTrace();
149:                    }
150:                } else if (args[0].equalsIgnoreCase("-xslt")) {
151:                    /* Use XALAN to transform an iCal to XML then via a given Style sheet to a new format. */
152:                    if (args.length != 6) {
153:                        System.err
154:                                .println("Syntax is:  -xslt <calendarLocation> <Organiser> <Email> <DaysForwardOrDateRange> <xsl document>\n"
155:                                        + "Example:\n"
156:                                        + "java -jar jical.jar -xslt /home/sfg/evolution/local/Calendar/calendar.ics sfg sfg@eurekait.com 180 xsl/yag.xsl > /www/website.live/sfg-yag.html");
157:                        return;
158:                    }
159:                    ICalendarParser icp = new ICalendarParser();
160:                    ICalendar ical = icp.parse(args[1]);
161:                    ical.setOrganizer(args[2]);
162:                    ical.setOrganizerEmail(args[3]);
163:                    //int DaysForwardOrDateRange = java.lang.Integer.parseInt(args[5]);
164:                    //String xmlCalString = ical.getJiCalXML(DaysForwardOrDateRange);
165:                    String xmlCalString = null;
166:                    try {
167:                        xmlCalString = ical.getJiCalXML(args[5], null);
168:                    } catch (Exception e) {
169:                        System.err.println(e);
170:                        e.printStackTrace();
171:                    }
172:                    // Now translate..
173:                    try {
174:
175:                        // 1. Instantiate a TransformerFactory.
176:                        javax.xml.transform.TransformerFactory tFactory = javax.xml.transform.TransformerFactory
177:                                .newInstance();
178:
179:                        // 2. Use the TransformerFactory to process the stylesheet Source and
180:                        //    generate a Transformer.
181:
182:                        javax.xml.transform.Transformer transformer = tFactory
183:                                .newTransformer(new javax.xml.transform.stream.StreamSource(
184:                                        args[4])); //XSL File Name
185:
186:                        // 3. Use the Transformer to transform an XML Source and send the
187:                        //    output to a Result object.
188:                        ByteArrayInputStream bais = new ByteArrayInputStream(
189:                                xmlCalString.getBytes());
190:                        transformer.transform(
191:                                new javax.xml.transform.stream.StreamSource(
192:                                        bais), // "foo.xml"
193:                                //new javax.xml.transform.stream.StreamResult ( new java.io.FileOutputStream("foo.out"))
194:                                new javax.xml.transform.stream.StreamResult(
195:                                        System.out));
196:                    } catch (Exception e) {
197:                        System.err.println("JiCal -xsl error in translation: "
198:                                + e);
199:                        e.printStackTrace();
200:                    }
201:                } else if (args[0].equalsIgnoreCase("-xsltonly")) {
202:                    /* Use XALAN to do a XSLT.  This is just so its easy. */
203:                    if (args.length != 3) {
204:                        System.err
205:                                .println("Syntax is:  -xsltonly <xsl document> <xml input document>\n"
206:                                        + "Example:\n"
207:                                        + "java -jar jical.jar -xslt /www/website.live/jicaldisplay.xml xsl/svg.xsl > /www/website.live/sfg-yag.svg");
208:                        return;
209:                    }
210:                    File styleFile = new File(args[1]); // stylesheet
211:                    File dataFile = new File(args[2]); // data
212:                    try {
213:                        InputStream dataStream = new FileInputStream(dataFile);
214:                        InputStream styleStream = new FileInputStream(styleFile);
215:                        // create XSLT Source and Result objects
216:                        Source data = new StreamSource(dataStream);
217:                        Source style = new StreamSource(styleStream);
218:                        Result output = new StreamResult(System.out);
219:                        // create Transformer and perform the tranfomation
220:                        Transformer xslt = TransformerFactory.newInstance()
221:                                .newTransformer(style);
222:                        xslt.transform(data, output);
223:                    } catch (Exception e) {
224:                        System.err
225:                                .println("JiCal -xsltonly error in translation: "
226:                                        + e);
227:                        e.printStackTrace();
228:                    }
229:                } else {
230:                    System.out
231:                            .println("================================================================================\n"
232:                                    + "JICAL v"
233:                                    + VERSION
234:                                    + " SHELL INTERFACE. GDAY - GOOD START! YOU FOUND ME!\n"
235:                                    + "Unfortunately, you got the option wrong. try -help for a list\n"
236:                                    + "================================================================================");
237:                }
238:            }
239:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.