Source Code Cross Referenced for Repository.java in  » ERP-CRM-Financial » sakai » org » sakaiproject » component » osid » repository » srw » 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 » ERP CRM Financial » sakai » org.sakaiproject.component.osid.repository.srw 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**********************************************************************************
002:         * $URL: $
003:         * $Id:  $
004:         ***********************************************************************************
005:         *
006:         * Copyright (c) 2003, 2004, 2005, 2006 The Sakai Foundation.
007:         * 
008:         * Licensed under the Educational Community License, Version 1.0 (the "License"); 
009:         * you may not use this file except in compliance with the License. 
010:         * You may obtain a copy of the License at
011:         * 
012:         *      http://www.opensource.org/licenses/ecl1.php
013:         * 
014:         * Unless required by applicable law or agreed to in writing, software 
015:         * distributed under the License is distributed on an "AS IS" BASIS, 
016:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
017:         * See the License for the specific language governing permissions and 
018:         * limitations under the License.
019:         *
020:         **********************************************************************************/package org.sakaiproject.component.osid.repository.srw;
021:
022:        /**
023:         * @author Massachusetts Institute of Techbology, Sakai Software Development Team
024:         * @version
025:         */
026:        public class Repository implements  org.osid.repository.Repository {
027:            private java.util.Vector assetVector = new java.util.Vector();
028:            private org.osid.id.IdManager idManager = null;
029:            private org.osid.logging.WritableLog log = null;
030:            private org.osid.shared.Id id = null;
031:            private String idString = null;
032:            private String displayName = null;
033:            private String description = null;
034:            private String url = null;
035:            private org.osid.shared.Type repositoryType = new Type("mit.edu",
036:                    "repository", "library_content");
037:            private org.osid.shared.Type assetType = new Type("mit.edu",
038:                    "asset", "library_content");
039:            private java.util.Vector searchTypeVector = new java.util.Vector();
040:            private java.util.Vector searchQueryVector = new java.util.Vector();
041:
042:            private void log(String entry)
043:                    throws org.osid.repository.RepositoryException {
044:                if (log != null) {
045:                    try {
046:                        log.appendLog(entry);
047:                    } catch (org.osid.logging.LoggingException lex) {
048:                        // swallow exception since logging is a best attempt to log an exception anyway
049:                    }
050:                }
051:            }
052:
053:            protected Repository(String displayName, String description,
054:                    String idString, java.util.Vector searchTypeVector,
055:                    java.util.Vector searchQueryVector,
056:                    org.osid.id.IdManager idManager,
057:                    org.osid.logging.WritableLog log)
058:                    throws org.osid.repository.RepositoryException {
059:                this .displayName = displayName;
060:                this .description = description;
061:                this .repositoryType = new Type("mit.edu", "repository",
062:                        "library_content");
063:                this .idString = idString;
064:                this .searchTypeVector = searchTypeVector;
065:                this .searchQueryVector = searchQueryVector;
066:                this .idManager = idManager;
067:                this .log = log;
068:                try {
069:                    this .id = idManager.getId(this .idString);
070:                } catch (Throwable t) {
071:                    log(t.getMessage());
072:                }
073:            }
074:
075:            public String getDisplayName()
076:                    throws org.osid.repository.RepositoryException {
077:                return this .displayName;
078:            }
079:
080:            public void updateDisplayName(String displayName)
081:                    throws org.osid.repository.RepositoryException {
082:                throw new org.osid.repository.RepositoryException(
083:                        org.osid.OsidException.UNIMPLEMENTED);
084:            }
085:
086:            public String getDescription()
087:                    throws org.osid.repository.RepositoryException {
088:                return this .description;
089:            }
090:
091:            public void updateDescription(String description)
092:                    throws org.osid.repository.RepositoryException {
093:                throw new org.osid.repository.RepositoryException(
094:                        org.osid.OsidException.UNIMPLEMENTED);
095:            }
096:
097:            public org.osid.shared.Id getId()
098:                    throws org.osid.repository.RepositoryException {
099:                return this .id;
100:            }
101:
102:            public org.osid.shared.Type getType()
103:                    throws org.osid.repository.RepositoryException {
104:                return this .repositoryType;
105:            }
106:
107:            public org.osid.repository.Asset createAsset(String displayName,
108:                    String description, org.osid.shared.Type assetType)
109:                    throws org.osid.repository.RepositoryException {
110:                if ((displayName == null) || (description == null)
111:                        || (assetType == null)) {
112:                    throw new org.osid.repository.RepositoryException(
113:                            org.osid.shared.SharedException.NULL_ARGUMENT);
114:                }
115:                if (!assetType.isEqual(this .assetType)) {
116:                    throw new org.osid.repository.RepositoryException(
117:                            org.osid.shared.SharedException.UNKNOWN_TYPE);
118:                }
119:                throw new org.osid.repository.RepositoryException(
120:                        org.osid.OsidException.UNIMPLEMENTED);
121:            }
122:
123:            public void deleteAsset(org.osid.shared.Id assetId)
124:                    throws org.osid.repository.RepositoryException {
125:                if (assetId == null) {
126:                    throw new org.osid.repository.RepositoryException(
127:                            org.osid.shared.SharedException.NULL_ARGUMENT);
128:                }
129:                throw new org.osid.repository.RepositoryException(
130:                        org.osid.OsidException.UNIMPLEMENTED);
131:            }
132:
133:            public org.osid.repository.AssetIterator getAssets()
134:                    throws org.osid.repository.RepositoryException {
135:                throw new org.osid.repository.RepositoryException(
136:                        org.osid.OsidException.UNIMPLEMENTED);
137:            }
138:
139:            public org.osid.repository.AssetIterator getAssetsByType(
140:                    org.osid.shared.Type assetType)
141:                    throws org.osid.repository.RepositoryException {
142:                if (assetType == null) {
143:                    throw new org.osid.repository.RepositoryException(
144:                            org.osid.shared.SharedException.NULL_ARGUMENT);
145:                }
146:                throw new org.osid.repository.RepositoryException(
147:                        org.osid.OsidException.UNIMPLEMENTED);
148:            }
149:
150:            public org.osid.shared.TypeIterator getAssetTypes()
151:                    throws org.osid.repository.RepositoryException {
152:                java.util.Vector results = new java.util.Vector();
153:                try {
154:                    results.addElement(this .assetType);
155:                    return new TypeIterator(results);
156:                } catch (Throwable t) {
157:                    log(t.getMessage());
158:                    throw new org.osid.repository.RepositoryException(
159:                            org.osid.OsidException.OPERATION_FAILED);
160:                }
161:            }
162:
163:            public org.osid.repository.RecordStructureIterator getRecordStructures()
164:                    throws org.osid.repository.RepositoryException {
165:                java.util.Vector results = new java.util.Vector();
166:                results.addElement(RecordStructure.getInstance());
167:                return new RecordStructureIterator(results);
168:            }
169:
170:            public org.osid.repository.RecordStructureIterator getMandatoryRecordStructures(
171:                    org.osid.shared.Type assetType)
172:                    throws org.osid.repository.RepositoryException {
173:                if (assetType == null) {
174:                    throw new org.osid.repository.RepositoryException(
175:                            org.osid.shared.SharedException.NULL_ARGUMENT);
176:                }
177:                if (assetType.isEqual(this .assetType)) {
178:                    java.util.Vector results = new java.util.Vector();
179:                    results.addElement(RecordStructure.getInstance());
180:                    return new RecordStructureIterator(results);
181:                }
182:                throw new org.osid.repository.RepositoryException(
183:                        org.osid.shared.SharedException.UNKNOWN_TYPE);
184:            }
185:
186:            public org.osid.shared.TypeIterator getSearchTypes()
187:                    throws org.osid.repository.RepositoryException {
188:                java.util.Vector results = new java.util.Vector();
189:                try {
190:                    return new TypeIterator(this .searchTypeVector);
191:                } catch (Throwable t) {
192:                    log(t.getMessage());
193:                    throw new org.osid.repository.RepositoryException(
194:                            org.osid.OsidException.OPERATION_FAILED);
195:                }
196:            }
197:
198:            public org.osid.shared.TypeIterator getStatusTypes()
199:                    throws org.osid.repository.RepositoryException {
200:                java.util.Vector results = new java.util.Vector();
201:                try {
202:                    results.addElement(new Type("mit.edu", "asset", "valid"));
203:                    return new TypeIterator(results);
204:                } catch (Throwable t) {
205:                    log(t.getMessage());
206:                    throw new org.osid.repository.RepositoryException(
207:                            org.osid.OsidException.OPERATION_FAILED);
208:                }
209:            }
210:
211:            public org.osid.shared.Type getStatus(org.osid.shared.Id assetId)
212:                    throws org.osid.repository.RepositoryException {
213:                return new Type("mit.edu", "asset", "valid");
214:            }
215:
216:            public boolean validateAsset(org.osid.shared.Id assetId)
217:                    throws org.osid.repository.RepositoryException {
218:                return true;
219:            }
220:
221:            public void invalidateAsset(org.osid.shared.Id assetId)
222:                    throws org.osid.repository.RepositoryException {
223:                throw new org.osid.repository.RepositoryException(
224:                        org.osid.OsidException.UNIMPLEMENTED);
225:            }
226:
227:            public org.osid.repository.Asset getAsset(org.osid.shared.Id assetId)
228:                    throws org.osid.repository.RepositoryException {
229:                if (assetId == null) {
230:                    throw new org.osid.repository.RepositoryException(
231:                            org.osid.shared.SharedException.NULL_ARGUMENT);
232:                }
233:                throw new org.osid.repository.RepositoryException(
234:                        org.osid.OsidException.UNIMPLEMENTED);
235:            }
236:
237:            public org.osid.repository.Asset getAssetByDate(
238:                    org.osid.shared.Id assetId, long date)
239:                    throws org.osid.repository.RepositoryException {
240:                throw new org.osid.repository.RepositoryException(
241:                        org.osid.OsidException.UNIMPLEMENTED);
242:            }
243:
244:            public org.osid.shared.LongValueIterator getAssetDates(
245:                    org.osid.shared.Id assetId)
246:                    throws org.osid.repository.RepositoryException {
247:                throw new org.osid.repository.RepositoryException(
248:                        org.osid.OsidException.UNIMPLEMENTED);
249:            }
250:
251:            public org.osid.repository.AssetIterator getAssetsBySearch(
252:                    java.io.Serializable searchCriteria,
253:                    org.osid.shared.Type searchType,
254:                    org.osid.shared.Properties searchProperties)
255:                    throws org.osid.repository.RepositoryException {
256:                if (searchCriteria == null) {
257:                    throw new org.osid.repository.RepositoryException(
258:                            org.osid.shared.SharedException.NULL_ARGUMENT);
259:                }
260:                if (searchType == null) {
261:                    throw new org.osid.repository.RepositoryException(
262:                            org.osid.shared.SharedException.NULL_ARGUMENT);
263:                }
264:                if (!(searchCriteria instanceof  String)) {
265:                    // maybe change this to a new exception message
266:                    log("invalid criteria");
267:                    throw new org.osid.repository.RepositoryException(
268:                            org.osid.OsidException.OPERATION_FAILED);
269:                }
270:
271:                java.util.Vector results = new java.util.Vector();
272:                boolean knownType = false;
273:                try {
274:                    String criteria = (String) searchCriteria;
275:                    for (int searchTypeNum = 0, size = this .searchTypeVector
276:                            .size(); searchTypeNum < size; searchTypeNum++) {
277:                        org.osid.shared.Type type = (org.osid.shared.Type) (this .searchTypeVector
278:                                .elementAt(searchTypeNum));
279:
280:                        //System.out.println("searchTypeNum " + searchTypeNum);
281:                        //System.out.println("search type " + searchType.getAuthority() + " / " + searchType.getDomain() + " / " + searchType.getKeyword());
282:                        //System.out.println("type " + type.getAuthority() + " / " + type.getDomain() + " / " + type.getKeyword());
283:
284:                        if (type.isEqual(searchType)) {
285:                            knownType = true;
286:                            String query = (String) this .searchQueryVector
287:                                    .elementAt(searchTypeNum);
288:                            query = query.replaceAll("CRITERIA", criteria);
289:                            System.out.println("SRW Query: " + query);
290:
291:                            java.net.URL url = new java.net.URL(query);
292:                            java.net.URLConnection connection = url
293:                                    .openConnection();
294:                            java.net.HttpURLConnection http = (java.net.HttpURLConnection) connection;
295:                            java.io.InputStreamReader in = new java.io.InputStreamReader(
296:                                    http.getInputStream());
297:
298:                            StringBuffer xml = new StringBuffer();
299:                            try {
300:                                int i = 0;
301:                                while ((i = in.read()) != -1) {
302:                                    xml.append(Character.toString((char) i));
303:                                }
304:                            } catch (Throwable t) {
305:                            }
306:                            //System.out.println("xml " + xml);
307:
308:                            try {
309:                                return new AssetIterator(xml, this .log, this .id);
310:                            } catch (Throwable t) {
311:                                // just ignore
312:                            }
313:                        }
314:                    }
315:                } catch (Throwable t) {
316:                    t.printStackTrace();
317:                    log(t.getMessage());
318:                    throw new org.osid.repository.RepositoryException(
319:                            org.osid.OsidException.OPERATION_FAILED);
320:                }
321:                if (!knownType) {
322:                    throw new org.osid.repository.RepositoryException(
323:                            org.osid.shared.SharedException.UNKNOWN_TYPE);
324:                }
325:                return new AssetIterator(results);
326:            }
327:
328:            public org.osid.shared.Id copyAsset(org.osid.repository.Asset asset)
329:                    throws org.osid.repository.RepositoryException {
330:                throw new org.osid.repository.RepositoryException(
331:                        org.osid.OsidException.UNIMPLEMENTED);
332:            }
333:
334:            public org.osid.repository.RecordStructureIterator getRecordStructuresByType(
335:                    org.osid.shared.Type recordStructureType)
336:                    throws org.osid.repository.RepositoryException {
337:                if (recordStructureType == null) {
338:                    throw new org.osid.repository.RepositoryException(
339:                            org.osid.shared.SharedException.NULL_ARGUMENT);
340:                }
341:                if (recordStructureType.isEqual(new Type("mit.edu",
342:                        "recordStructure", "wellFormed"))) {
343:                    java.util.Vector results = new java.util.Vector();
344:                    // don't return the content's sturcutre even if it matches, since this that is a separate and special case
345:                    results.addElement(RecordStructure.getInstance());
346:                    return new RecordStructureIterator(results);
347:                }
348:                throw new org.osid.repository.RepositoryException(
349:                        org.osid.shared.SharedException.UNKNOWN_TYPE);
350:            }
351:
352:            public org.osid.shared.PropertiesIterator getProperties()
353:                    throws org.osid.repository.RepositoryException {
354:                try {
355:                    return new PropertiesIterator(new java.util.Vector());
356:                } catch (Throwable t) {
357:                    log(t.getMessage());
358:                    throw new org.osid.repository.RepositoryException(
359:                            org.osid.OsidException.OPERATION_FAILED);
360:                }
361:            }
362:
363:            public org.osid.shared.Properties getPropertiesByType(
364:                    org.osid.shared.Type propertiesType)
365:                    throws org.osid.repository.RepositoryException {
366:                if (propertiesType == null) {
367:                    throw new org.osid.repository.RepositoryException(
368:                            org.osid.shared.SharedException.NULL_ARGUMENT);
369:                }
370:                return new Properties();
371:            }
372:
373:            public org.osid.shared.TypeIterator getPropertyTypes()
374:                    throws org.osid.repository.RepositoryException {
375:                try {
376:                    return new TypeIterator(new java.util.Vector());
377:                } catch (Throwable t) {
378:                    log(t.getMessage());
379:                    throw new org.osid.repository.RepositoryException(
380:                            org.osid.OsidException.OPERATION_FAILED);
381:                }
382:            }
383:
384:            protected void addAsset(org.osid.repository.Asset asset)
385:                    throws org.osid.repository.RepositoryException {
386:                this .assetVector.addElement(asset);
387:            }
388:
389:            public boolean supportsUpdate()
390:                    throws org.osid.repository.RepositoryException {
391:                return false;
392:            }
393:
394:            public boolean supportsVersioning()
395:                    throws org.osid.repository.RepositoryException {
396:                return false;
397:            }
398:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.