Source Code Cross Referenced for SchemaListModel.java in  » Portal » Open-Portal » com » sun » portal » search » admin » model » 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.search.admin.model 
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:
006:        package com.sun.portal.search.admin.model;
007:
008:        import java.lang.*;
009:        import java.util.*;
010:        import java.util.logging.Logger;
011:        import java.util.logging.Level;
012:        import java.io.*;
013:        import java.net.*;
014:        import javax.servlet.http.HttpServletRequest;
015:
016:        import com.iplanet.jato.model.*;
017:        import com.iplanet.jato.view.html.*;
018:        import com.iplanet.jato.util.Encoder;
019:        import com.sun.portal.search.admin.CSConfig;
020:        import com.sun.portal.search.util.SearchConfig;
021:        import com.sun.portal.search.admin.resources.SearchResource;
022:        import com.sun.portal.search.soif.*;
023:        import com.sun.portal.search.rdm.*;
024:        import com.sun.portal.log.common.PortalLogger;
025:
026:        /**
027:         * This class supports the MenuListView by providing the data in the
028:         * format expected by the view.
029:         */
030:        public class SchemaListModel extends DefaultModel implements 
031:                DatasetModel, RetrievingModel, DeletingModel {
032:            public static final String FIELD_NAME = "Name";
033:            public static final String FIELD_DELNAME = "DelName";
034:            public static final String FIELD_DESC = "Desc";
035:            public static final String FIELD_ALIAS = "Alias";
036:            public static final String FIELD_DATATYPE = "Datatype";
037:            public static final String FIELD_EDITABLE = "Editable";
038:            public static final String FIELD_INDEXABLE = "Indexable";
039:            public static final String FIELD_DELETE = "Delete";
040:            public static final String FIELD_ENCODED_NAME = "EncodedName";
041:            static final String[] FIELDS = { FIELD_NAME, FIELD_DESC,
042:                    FIELD_ALIAS };
043:            public Locale userLocale = Locale.getDefault();
044:            public static final String[] DATA_TYPES = { "date", "int", "string" };
045:            public boolean showInternal = false;
046:
047:            private String schfn = "";
048:
049:            // Create a Logger for this class
050:            private static Logger debugLogger = PortalLogger
051:                    .getLogger(SchemaListModel.class);
052:
053:            /**
054:             * @param req The HttpServletRequest object passed to the super class.
055:             * @param rbName The name of the resource bundle.
056:             */
057:            public SchemaListModel() {
058:                super ();
059:                /*
060:                   try {
061:                   retrieve(null);
062:                   }
063:                   catch (Exception e) {}
064:                 */
065:            }
066:
067:            // Model execution methods
068:            ////////////////////////////////////////////////////////////////////////////////
069:
070:            /**
071:             *
072:             *
073:             */
074:            public Object execute(ModelExecutionContext context)
075:                    throws ModelControlException {
076:                String operationName = null;
077:                if (context != null)
078:                    operationName = context.getOperationName();
079:                else
080:                    operationName = ModelExecutionContext.OPERATION_RETRIEVE;
081:
082:                Object result = null;
083:                if (operationName
084:                        .equals(ModelExecutionContext.OPERATION_RETRIEVE)) {
085:                    result = retrieve(context);
086:                } else if (operationName
087:                        .equals(ModelExecutionContext.OPERATION_DELETE)) {
088:                    result = delete(context);
089:                }
090:
091:                return result;
092:            }
093:
094:            /**
095:             *
096:             *
097:             */
098:            public Object delete(ModelExecutionContext context)
099:                    throws ModelControlException {
100:                RDMSchema schema = null;
101:                try {
102:                    schema = loadSchema();
103:                } catch (Exception e) {
104:                    throw new ModelControlException(e);
105:                }
106:
107:                if (schema == null) {
108:                    throw new ModelControlException("Error on loading Schema");
109:                }
110:
111:                beforeFirst();
112:                while (next()) {
113:                    String isDelete = (String) getValue(FIELD_DELETE);
114:                    if (isDelete != null && isDelete.equalsIgnoreCase("true")) {
115:                        String delName = (String) getValue(FIELD_DELNAME);
116:                        debugLogger
117:                                .log(Level.FINER, "PSSH_CSPSAM0040", delName);
118:                        if (delName != null) {
119:                            String name = null;
120:                            try {
121:                                name = new String(
122:                                        Encoder.decodeBase64(delName), "UTF-8");
123:                                schema.deleteColumn(name);
124:                            } catch (Exception e) {
125:                                throw new ModelControlException(
126:                                        "Schema failed to delete column: "
127:                                                + name + ": " + e);
128:                            }
129:                        }
130:                    }
131:                }
132:                try {
133:                    SOIFOutputStream outss = new SOIFOutputStream(schfn);
134:                    outss.write(schema.getSOIF());
135:                    outss.close();
136:                } catch (Exception e) {
137:                    throw new ModelControlException("Unable to write SOIF to "
138:                            + schfn + ": " + e);
139:                }
140:                return null;
141:            }
142:
143:            private RDMSchema loadSchema() throws Exception {
144:                RDMSchema schema = null;
145:                String csidfn = CSConfig.getServerRoot() + File.separator
146:                        + SearchConfig.CONFDIR + File.separator
147:                        + SearchConfig.SEARCH_CONF;
148:                try {
149:                    SearchConfig.init(csidfn);
150:                } catch (Exception e) {
151:                    throw new Exception("Unable to initialize SearchConfig: "
152:                            + csidfn);
153:                }
154:
155:                if ((schfn = SearchConfig.getValue(SearchConfig.SCHEMA)) == null) {
156:                    throw new Exception("Missing SearchConfig.SCHEMA parameter");
157:                }
158:
159:                // Load the schema
160:                debugLogger.log(Level.FINER, "PSSH_CSPSAM0041", schfn);
161:                SOIFInputStream ss = null;
162:                try {
163:                    ss = new SOIFInputStream(schfn);
164:                    schema = new RDMSchema(ss.readSOIF());
165:                } catch (Exception e) {
166:                    debugLogger.log(Level.INFO, "PSSH_CSPSAM0042", schfn);
167:                }
168:                return schema;
169:            }
170:
171:            public String[] getSchemaList() {
172:                try {
173:                    RDMSchema schema = loadSchema();
174:                    return schema.schema_nonInternal_attrs();
175:                } catch (Exception e) {
176:                }
177:                return null;
178:            }
179:
180:            /**
181:             *
182:             *
183:             */
184:            public Object retrieve(ModelExecutionContext context)
185:                    throws ModelControlException {
186:                clear();
187:                try {
188:                    RDMSchema schema = loadSchema();
189:                    String[] arr = {};
190:                    if (showInternal) {
191:                        int i, j, n, nmv = 0;
192:                        List attrs = new ArrayList();
193:                        String attr;
194:                        String iflg = null;
195:
196:                        n = schema.getMaxIndex();
197:                        for (i = 0; i <= n; i++) {
198:                            if ((attr = schema.getSOIFAttribute(i)) != null) {
199:                                attrs.add(attr);
200:                            }
201:                        }
202:                        arr = (String[]) attrs.toArray(new String[0]);
203:                    } else {
204:                        arr = schema.schema_nonInternal_attrs();
205:                    }
206:
207:                    for (int i = 0; i < arr.length; i++) {
208:                        appendRow();
209:                        String name = arr[i];
210:                        setValue(FIELD_NAME, name);
211:
212:                        try {
213:                            String encodedName = Encoder.encodeBase64(name
214:                                    .getBytes("UTF-8"));
215:                            setValue(FIELD_ENCODED_NAME, encodedName);
216:                            setValue(FIELD_DELNAME, encodedName);
217:                        } catch (Exception e) {
218:                            debugLogger.log(Level.INFO, "PSSH_CSPSAM0012", e
219:                                    .getMessage());
220:                            setValue(FIELD_ENCODED_NAME, name);
221:                            setValue(FIELD_DELNAME, name);
222:                        }
223:
224:                        int col = schema.getColumnNumber(name);
225:                        setValue(FIELD_DESC, schema.getDescription(col));
226:                        String value = schema.getAliases(col);
227:                        if (value != null) {
228:                            setValue(FIELD_ALIAS, value);
229:                        }
230:                        value = schema.getDataType(col);
231:                        if (value != null) {
232:                            setValue(FIELD_DATATYPE, value);
233:                        }
234:                        value = schema.getEditAttribute(col);
235:                        if (value != null && value.equals("1")) {
236:                            setValue(FIELD_EDITABLE, "true");
237:                        } else {
238:                            setValue(FIELD_EDITABLE, "false");
239:                        }
240:                        value = schema.getIndexAttribute(col);
241:                        if (value != null && value.equals("1")) {
242:                            setValue(FIELD_INDEXABLE, "true");
243:                        } else {
244:                            setValue(FIELD_INDEXABLE, "false");
245:                        }
246:                    }
247:
248:                } catch (Exception e) {
249:                    throw new ModelControlException(e);
250:                }
251:                beforeFirst();
252:
253:                // Nothing useful to return
254:                return null;
255:            }
256:
257:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.