Source Code Cross Referenced for DataServiceHelper.java in  » Portal » Open-Portal » com » sun » portal » rewriter » services » 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 » Open Portal » com.sun.portal.rewriter.services 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2001 Sun Microsystems, Inc.  All rights reserved.
003:         * PROPRIETARY/CONFIDENTIAL.  Use of this product is subject to license terms.
004:         */
005:        package com.sun.portal.rewriter.services;
006:
007:        import com.iplanet.am.util.AdminUtils;
008:        import com.sun.portal.rewriter.RewriterModule;
009:        import com.sun.portal.rewriter.util.ConfigManager;
010:        import com.sun.portal.rewriter.util.Constants;
011:        import com.sun.portal.rewriter.util.StringHelper;
012:
013:        import java.lang.reflect.Constructor;
014:        import java.util.Properties;
015:        import java.util.logging.Handler;
016:        import java.util.logging.Level;
017:        import java.util.logging.Logger;
018:        import java.io.File;
019:
020:        public class DataServiceHelper {
021:            public static Properties getDefaultIDSProps() {
022:                final Properties props = new Properties();
023:                props.setProperty(Constants.PROPERTY_DATA_SOURCE_TYPE,
024:                        DataService.IDS);
025:
026:                return props;
027:            }//getDefaultIDSProps()
028:
029:            public static Properties getDefaultIDSAMEProps() {
030:                final Properties props = new Properties();
031:                props.setProperty(Constants.PROPERTY_DATA_SOURCE_TYPE,
032:                        DataService.IDSAME);
033:
034:                props.setProperty(DataService.PROPERTY_DATA_SERIVCE_USER,
035:                        StringHelper.normalize(AdminUtils.getAdminDN()));
036:                byte[] adminUtilPassword = AdminUtils.getAdminPassword();
037:                adminUtilPassword = (adminUtilPassword == null) ? Constants.EMTPY_BYTE_ARRAY
038:                        : adminUtilPassword;
039:                props.setProperty(
040:                        DataService.PROPERTY_DATA_SERIVCE_USER_PASSWORD,
041:                        new String(adminUtilPassword));
042:                return props;
043:            }//getDefaultIDSAMEProps()
044:
045:            public static Properties getIDSAMEProps(final String aUserName,
046:                    final String aPassword) {
047:                final Properties props = new Properties();
048:                props.setProperty(Constants.PROPERTY_DATA_SOURCE_TYPE,
049:                        DataService.IDSAME);
050:
051:                props.setProperty(DataService.PROPERTY_DATA_SERIVCE_USER,
052:                        StringHelper.normalize(aUserName));
053:                props.setProperty(
054:                        DataService.PROPERTY_DATA_SERIVCE_USER_PASSWORD,
055:                        aPassword);
056:                return props;
057:            }//getIDSAMEProps()
058:
059:            public static Properties getDefaultFileProps() {
060:                final Properties props = new Properties();
061:                props.setProperty(Constants.PROPERTY_DATA_SOURCE_TYPE,
062:                        Constants.FILE);
063:                props.setProperty(DataService.PROPERTY_DATA_SERVICE_BASE, ".");
064:
065:                return props;
066:            }//getDefaultFileProps()
067:
068:            public final static void initLogSystem(final Class aHandlerClass,
069:                    String path, String logLevel) {
070:                try {
071:                    //it is mandatory to see that, by the time first call to debug class is made
072:                    //ConfigManager would have been initialized properly..
073:                    if (path == null || path.length() == 0) {
074:                        throw new LoggingInitializationException(
075:                                "Debug Log Location Not Specified.");
076:                    } else {
077:                        File dir = new File(path);
078:                        if (!dir.exists()) {
079:                            dir.mkdirs();
080:                        }
081:                    }
082:                    String debugFile = ((path != null) ? path
083:                            + (path.endsWith("/") ? "" : "/") : "")
084:                            + ConfigManager.getModulePrefixID();
085:
086:                    String debugFileExt = ConfigManager.getModuleSuffixID();
087:                    if (debugFileExt.length() > 0) {
088:                        debugFileExt = "." + debugFileExt;
089:                    }
090:
091:                    Handler lHandler = createHandler(aHandlerClass, debugFile
092:                            + debugFileExt);
093:
094:                    final Level bLevel;
095:                    if (logLevel != null) {
096:                        bLevel = Level.parse(logLevel);
097:                    } else {
098:                        bLevel = lHandler.getLevel();
099:                    }
100:
101:                    /*Logger.getLogger(RewriterModule.REWRITER_LOG).setLevel(bLevel);
102:
103:                    Logger.getLogger(RewriterModule.REWRITER_LOG_REST).addHandler(lHandler);
104:
105:                    Logger.getLogger(RewriterModule.REWRITER_LOG_RULRESET_INFO).addHandler(createHandler(aHandlerClass,
106:                            debugFile + "_RuleSetInfo" + debugFileExt));
107:
108:                    Logger.getLogger(RewriterModule.REWRITER_LOG_URI_INFO).addHandler(createHandler(aHandlerClass,
109:                            debugFile + "_URIInfo" + debugFileExt));
110:
111:                    Logger.getLogger(RewriterModule.REWRITER_LOG_ORIGINAL_PAGES).addHandler(createHandler(aHandlerClass,
112:                            debugFile + "_OriginalPages" + debugFileExt));
113:
114:                    Logger.getLogger(RewriterModule.REWRITER_LOG_UNAFFECTED_PAGES).addHandler(createHandler(aHandlerClass,
115:                            debugFile + "_UnaffectedPages" + debugFileExt));
116:
117:                    Logger.getLogger(RewriterModule.REWRITER_LOG_REWRITTEN_PAGES).addHandler(createHandler(aHandlerClass,
118:                            debugFile + "_RewrittenPages" + debugFileExt));*/
119:
120:                } catch (LoggingInitializationException lie) {
121:                    lie.printStackTrace();
122:                } catch (Exception e) {
123:                    System.out.println("Unable to create instance of "
124:                            + aHandlerClass.getClass());
125:                    e.printStackTrace();
126:                }
127:            }
128:
129:            public final static void initLogSystem(final Class aHandlerClass) {
130:                /*try {
131:                  //it is mandatory to see that, by the time first call to debug class is made
132:                  //ConfigManager would have been initialized properly..
133:                  String debugFile = ConfigManager.getModulePrefixID();
134:
135:                  String debugFileExt = ConfigManager.getModuleSuffixID();
136:                  if (debugFileExt.length() > 0) {
137:                      debugFileExt = "." + debugFileExt;
138:                  }
139:
140:                  Handler lHandler = createHandler(aHandlerClass,
141:                          debugFile + debugFileExt);
142:
143:                  final Level bLevel = lHandler.getLevel();
144:
145:                  Logger.getLogger(RewriterModule.REWRITER_LOG).setLevel(bLevel);
146:
147:                  Logger.getLogger(RewriterModule.REWRITER_LOG_REST).addHandler(lHandler);
148:
149:                  Logger.getLogger(RewriterModule.REWRITER_LOG_RULRESET_INFO).addHandler(createHandler(aHandlerClass,
150:                          debugFile + "_RuleSetInfo" + debugFileExt));
151:
152:                  Logger.getLogger(RewriterModule.REWRITER_LOG_URI_INFO).addHandler(createHandler(aHandlerClass,
153:                          debugFile + "_URIInfo" + debugFileExt));
154:
155:                  Logger.getLogger(RewriterModule.REWRITER_LOG_ORIGINAL_PAGES).addHandler(createHandler(aHandlerClass,
156:                          debugFile + "_OriginalPages" + debugFileExt));
157:
158:                  Logger.getLogger(RewriterModule.REWRITER_LOG_UNAFFECTED_PAGES).addHandler(createHandler(aHandlerClass,
159:                          debugFile + "_UnaffectedPages" + debugFileExt));
160:
161:                  Logger.getLogger(RewriterModule.REWRITER_LOG_REWRITTEN_PAGES).addHandler(createHandler(aHandlerClass,
162:                          debugFile + "_RewrittenPages" + debugFileExt));
163:                } catch (final Exception e) {
164:                  System.out.println("Unable to create instance of " +
165:                          aHandlerClass.getClass());
166:                  e.printStackTrace();
167:                }*/
168:            }//initLogSystem()
169:
170:            private static final Handler createHandler(
171:                    final Class aHandlerClass, final String aFileName)
172:                    throws Exception {
173:                Constructor constructor = aHandlerClass
174:                        .getConstructor(new Class[] { String.class });
175:                return (Handler) constructor
176:                        .newInstance(new Object[] { aFileName });
177:            }//createHandler()
178:
179:        }//class DataServiceHelper
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.