Source Code Cross Referenced for RegisterStylesheet.java in  » Portal » uPortal_rel-2-6-1-GA » org » jasig » portal » tools » 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 » Portal » uPortal_rel 2 6 1 GA » org.jasig.portal.tools 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Copyright 2001, 2002 The JA-SIG Collaborative.  All rights reserved.
002:         *  See license distributed with this file and
003:         *  available online at http://www.uportal.org/license.html
004:         */
005:
006:        package org.jasig.portal.tools;
007:
008:        import org.jasig.portal.RDBMServices;
009:        import org.jasig.portal.StructureStylesheetDescription;
010:        import org.jasig.portal.ThemeStylesheetDescription;
011:        import org.jasig.portal.layout.IUserLayoutStore;
012:        import org.jasig.portal.layout.UserLayoutStoreFactory;
013:
014:        /**
015:         * A utility to manage core uPortal stylesheets.
016:         *
017:         * @author Peter Kharchenko  {@link <a href="mailto:pkharchenko@interactivebusiness.com"">pkharchenko@interactivebusiness.com"</a>}
018:         * @version 1.0
019:         */
020:        public class RegisterStylesheet {
021:
022:            public RegisterStylesheet() {
023:            }
024:
025:            public static void main(String[] args) {
026:                RDBMServices.setGetDatasourceFromJndi(false); /*don't try jndi when not in web app */
027:
028:                String stylesheetURI = null;
029:                String stylesheetDescriptionURI = null;
030:                int stylesheetId = -1;
031:                boolean isTheme = true;
032:                boolean update = false;
033:                boolean delete = false;
034:                if (args.length < 3)
035:                    printHelp();
036:                for (int i = 0; i < args.length; i++) {
037:                    if (!args[i].startsWith("-")) {
038:                        if (update) {
039:                            if (i <= 1 || args.length < i + 3) {
040:                                printHelp();
041:                            }
042:
043:                            stylesheetURI = args[i];
044:                            stylesheetDescriptionURI = args[++i];
045:                            stylesheetId = Integer.parseInt(args[++i]);
046:                        } else if (delete) {
047:                            stylesheetId = Integer.parseInt(args[i]);
048:                        } else {
049:                            if (i < 1 || args.length < i + 2) {
050:                                printHelp();
051:                            }
052:
053:                            stylesheetURI = args[i];
054:                            stylesheetDescriptionURI = args[++i];
055:                        }
056:                    } else if (args[i].equals("-s")) {
057:                        isTheme = false;
058:                    } else if (args[i].equals("-t")) {
059:                        isTheme = true;
060:                    } else if (args[i].equals("-u")) {
061:                        update = true;
062:                    } else if (args[i].equals("-d")) {
063:                        delete = true;
064:                    } else {
065:                        printHelp();
066:                        return;
067:                    }
068:                }
069:                if (delete) {
070:                    if (stylesheetId == -1) {
071:                        printHelp();
072:                        return;
073:                    }
074:                } else if (stylesheetURI == null
075:                        || stylesheetDescriptionURI == null) {
076:                    printHelp();
077:                    return;
078:                }
079:                IUserLayoutStore ulsdb = UserLayoutStoreFactory
080:                        .getUserLayoutStoreImpl();
081:                try {
082:                    if (update) {
083:                        if (isTheme) {
084:                            ulsdb.updateThemeStylesheetDescription(
085:                                    stylesheetDescriptionURI, stylesheetURI,
086:                                    stylesheetId);
087:                        } else {
088:                            ulsdb.updateStructureStylesheetDescription(
089:                                    stylesheetDescriptionURI, stylesheetURI,
090:                                    stylesheetId);
091:                        }
092:                        // verify
093:                        if (isTheme) {
094:                            ThemeStylesheetDescription tsd = UserLayoutStoreFactory
095:                                    .getUserLayoutStoreImpl()
096:                                    .getThemeStylesheetDescription(stylesheetId);
097:                        } else {
098:                            StructureStylesheetDescription ssd = UserLayoutStoreFactory
099:                                    .getUserLayoutStoreImpl()
100:                                    .getStructureStylesheetDescription(
101:                                            stylesheetId);
102:                        }
103:                    } else if (delete) {
104:                        if (isTheme) {
105:                            ulsdb
106:                                    .removeThemeStylesheetDescription(stylesheetId);
107:                        } else {
108:                            ulsdb
109:                                    .removeStructureStylesheetDescription(stylesheetId);
110:                        }
111:                    } else {
112:                        Integer id = null;
113:                        if (isTheme) {
114:                            id = ulsdb.addThemeStylesheetDescription(
115:                                    stylesheetDescriptionURI, stylesheetURI);
116:                        } else {
117:                            id = ulsdb.addStructureStylesheetDescription(
118:                                    stylesheetDescriptionURI, stylesheetURI);
119:                        }
120:
121:                        if (id == null) {
122:                            System.out.println("Save failed!");
123:                            return;
124:                        } else {
125:                            stylesheetId = id.intValue();
126:                            System.out
127:                                    .println("Save successfull! The new stylehseet was assigned Id="
128:                                            + id);
129:                        }
130:
131:                        // verify
132:                        if (isTheme) {
133:                            ThemeStylesheetDescription tsd = UserLayoutStoreFactory
134:                                    .getUserLayoutStoreImpl()
135:                                    .getThemeStylesheetDescription(stylesheetId);
136:                        } else {
137:                            StructureStylesheetDescription ssd = UserLayoutStoreFactory
138:                                    .getUserLayoutStoreImpl()
139:                                    .getStructureStylesheetDescription(
140:                                            stylesheetId);
141:                        }
142:                    }
143:
144:                } catch (Exception e) {
145:                    System.out.println("An error has been encountered:");
146:                    e.printStackTrace();
147:                }
148:            }
149:
150:            private static void printHelp() {
151:                System.out
152:                        .println("Usage: RegisterStylesheet -(s|t) [-(u|d)] [stylesheetURI] [stylesheetDescriptionURI] [stylesheetId]");
153:                System.out
154:                        .println("The stylesheetId must be specified for update and delete operations.");
155:                System.out
156:                        .println("The URIs must be specified for add and update operations.");
157:                System.out
158:                        .println("The CLASSPATH environment variable should be set up to include\n"
159:                                + "both \"uPortal/build\" and \"uPortal/build/WEB-INF/classes\" dirs.\n\n"
160:                                + "For deployment all stylesheets are moved under the \"/stylesheet/\" directory,\n"
161:                                + "so the URI for a stylesheet will always begin with \"/stylesheet/\", unless\n"
162:                                + "you're specifying a global URL (which is not recommended).\n"
163:                                + "Stylesheet description files (.sdf) are moved to the same location, so\n"
164:                                + "their URI should be specified in the same manner.\n\n"
165:                                + "For example to specify a URI for a tab-column.xsl (part of the distribution),\n"
166:                                + "use \"/stylesheets/org/jasig/portal/layout/tab-column/tab-column.xsl\".\n");
167:                System.out.println("Flag specification:");
168:                System.out
169:                        .println("\t-s : process structure stylesheet (either \"-t\" or \"-s\" are required on the command line)");
170:                System.out
171:                        .println("\t-t : process theme stylesheet (either \"-t\" or \"-s\" are required on the command line)");
172:                System.out.println("\t-u : update stylesheet definition");
173:                System.out.println("\t-d : delete stylesheet definition");
174:                System.exit(0);
175:            }
176:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.