Source Code Cross Referenced for RepositoryManager.java in  » ERP-CRM-Financial » sakai » edu » indiana » lib » osid » base » repository » http » 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 » edu.indiana.lib.osid.base.repository.http 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package edu.indiana.lib.osid.base.repository.http;
002:
003:        import java.io.*;
004:        import java.util.*;
005:
006:        import edu.indiana.lib.twinpeaks.search.*;
007:        import edu.indiana.lib.twinpeaks.util.*;
008:
009:        /**********************************************************************************
010:         * $URL: https://source.sakaiproject.org/svn/citations/tags/sakai_2-4-1/citations-osid/web2bridge/src/java/edu/indiana/lib/osid/base/repository/http/RepositoryManager.java $
011:         * $Id: RepositoryManager.java 22657 2007-03-15 13:21:23Z jimeng@umich.edu $
012:         **********************************************************************************
013:         *
014:         * Copyright (c) 2003, 2004, 2005 The Regents of the University of Michigan, Trustees of Indiana University,
015:         *                  Board of Trustees of the Leland Stanford, Jr., University, and The MIT Corporation
016:         *
017:         * Licensed under the Educational Community License Version 1.0 (the "License");
018:         * By obtaining, using and/or copying this Original Work, you agree that you have read,
019:         * understand, and will comply with the terms and conditions of the Educational Community License.
020:         * You may obtain a copy of the License at:
021:         *
022:         *      http://cvs.sakaiproject.org/licenses/license_1_0.html
023:         *
024:         * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
025:         * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
026:         * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
027:         * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
028:         * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
029:         *
030:         **********************************************************************************/
031:        /**
032:         * @author Massachusetts Institute of Techbology, Sakai Software Development Team
033:         * @version
034:         */
035:        public class RepositoryManager extends
036:                edu.indiana.lib.osid.base.repository.RepositoryManager {
037:            private static org.apache.commons.logging.Log _log = edu.indiana.lib.twinpeaks.util.LogUtils
038:                    .getLog(RepositoryManager.class);
039:
040:            private org.osid.repository.Repository repository = null;
041:            private org.osid.id.IdManager idManager = null;
042:            private org.osid.OsidContext context = null;
043:            private java.util.Properties configuration = null;
044:            private java.util.Vector repositoryVector = new java.util.Vector();
045:
046:            public RepositoryManager() {
047:            }
048:
049:            public org.osid.OsidContext getOsidContext()
050:                    throws org.osid.repository.RepositoryException {
051:                return context;
052:            }
053:
054:            private java.util.Vector asVector(Object value) {
055:                java.util.Vector vector = new java.util.Vector(1);
056:
057:                vector.addElement(value);
058:                return vector;
059:            }
060:
061:            public void assignOsidContext(org.osid.OsidContext context)
062:                    throws org.osid.repository.RepositoryException {
063:                this .context = context;
064:            }
065:
066:            /*
067:             * Phase two configuration
068:             */
069:            public void assignConfiguration(java.util.Properties configuration)
070:                    throws org.osid.repository.RepositoryException {
071:                java.io.InputStream configStream = null;
072:                org.osid.OsidContext osidContext = this .context;
073:                String contextName;
074:                /*
075:                 * Establish our configuration
076:                 */
077:                try {
078:                    configStream = getConfigStream("/searchsource.xml");
079:                    SearchSource.populate(configStream);
080:                } catch (Throwable t) {
081:                    _log.error(t.getMessage());
082:                    throw new org.osid.repository.RepositoryException(
083:                            org.osid.OsidException.OPERATION_FAILED);
084:                } finally {
085:                    if (configStream != null)
086:                        try {
087:                            configStream.close();
088:                        } catch (Throwable ignore) {
089:                        }
090:                }
091:                /*
092:                 * Verify mandatory configuration values
093:                 */
094:                try {
095:                    String idImplementation = SearchSource
096:                            .getMandatoryGlobalConfigurationValue("osid_20_Id_Implementation");
097:
098:                    /*
099:                     * Get our unique OSID context object
100:                     */
101:                    osidContext = this .context;
102:                    /*
103:                     * Load the ID manager
104:                     */
105:                    this .idManager = (org.osid.id.IdManager) edu.indiana.lib.osid.base.loader.OsidLoader
106:                            .getManager("org.osid.id.IdManager",
107:                                    idImplementation, osidContext,
108:                                    new java.util.Properties());
109:                    Managers.setIdManager(this .idManager);
110:                    /*
111:                     * Set up our Repositories
112:                     */
113:                    if (!SearchSource.isSourceListPopulated()) {
114:                        return;
115:                    }
116:                    /*
117:                     * Add in the enabled choices
118:                     */
119:                    for (Iterator i = SearchSource.getSearchListIterator(); i
120:                            .hasNext();) {
121:                        SearchSource ss = (SearchSource) i.next();
122:                        Type searchType;
123:
124:                        if (!ss.isEnabled()) {
125:                            continue;
126:                        }
127:
128:                        _log.debug("name = " + ss.getName());
129:                        _log.debug("description = " + ss.getDescription());
130:                        _log.debug("id = " + ss.getId());
131:                        _log.debug("authority = " + ss.getAuthority());
132:                        _log.debug("domain = " + ss.getDomain());
133:                        _log.debug("searchType = " + ss.getSearchType());
134:                        _log.debug("query handler = "
135:                                + ss.getQueryHandlerClassName());
136:                        _log.debug("result handler = "
137:                                + ss.getSearchResultHandlerClassName());
138:                        _log.debug("osid context = " + this .context);
139:                        /*
140:                         * Set up the search-type and add the new Repository
141:                         */
142:                        searchType = new Type(ss.getAuthority(),
143:                                ss.getDomain(), ss.getSearchType(), ss
144:                                        .getTypeDescription());
145:
146:                        this .repositoryVector.addElement(new Repository(ss
147:                                .getName(), ss.getDescription(), ss.getId(),
148:                                asVector(searchType), asVector(ss
149:                                        .getQueryHandlerClassName()),
150:                                asVector(ss.getSearchResultHandlerClassName()),
151:                                this .idManager));
152:                    }
153:                } catch (Throwable t) {
154:                    _log.error(t.getMessage());
155:
156:                    if (t instanceof  org.osid.repository.RepositoryException) {
157:                        throw new org.osid.repository.RepositoryException(t
158:                                .getMessage());
159:                    } else {
160:                        throw new org.osid.repository.RepositoryException(
161:                                org.osid.OsidException.OPERATION_FAILED);
162:                    }
163:                }
164:            }
165:
166:            public org.osid.repository.RepositoryIterator getRepositories()
167:                    throws org.osid.repository.RepositoryException {
168:                return new RepositoryIterator(this .repositoryVector);
169:            }
170:
171:            public org.osid.repository.RepositoryIterator getRepositoriesByType(
172:                    org.osid.shared.Type repositoryType)
173:                    throws org.osid.repository.RepositoryException {
174:                if (repositoryType == null) {
175:                    throw new org.osid.repository.RepositoryException(
176:                            org.osid.shared.SharedException.NULL_ARGUMENT);
177:                }
178:
179:                java.util.Vector result = new java.util.Vector();
180:                org.osid.repository.RepositoryIterator repositoryIterator = getRepositories();
181:
182:                while (repositoryIterator.hasNextRepository()) {
183:                    org.osid.repository.Repository nextRepository = repositoryIterator
184:                            .nextRepository();
185:
186:                    if (nextRepository.getType().isEqual(repositoryType)) {
187:                        result.addElement(nextRepository);
188:                    }
189:                }
190:                return new RepositoryIterator(result);
191:            }
192:
193:            public org.osid.repository.Repository getRepository(
194:                    org.osid.shared.Id repositoryId)
195:                    throws org.osid.repository.RepositoryException {
196:                if (repositoryId == null) {
197:                    throw new org.osid.repository.RepositoryException(
198:                            org.osid.shared.SharedException.NULL_ARGUMENT);
199:                }
200:                try {
201:                    org.osid.repository.RepositoryIterator repositoryIterator = getRepositories();
202:                    while (repositoryIterator.hasNextRepository()) {
203:                        org.osid.repository.Repository nextRepository = repositoryIterator
204:                                .nextRepository();
205:                        if (nextRepository.getId().isEqual(repositoryId)) {
206:                            return nextRepository;
207:                        }
208:                    }
209:                    throw new org.osid.repository.RepositoryException(
210:                            org.osid.shared.SharedException.UNKNOWN_ID);
211:                } catch (Throwable t) {
212:                    _log.error(t.getMessage());
213:                    throw new org.osid.repository.RepositoryException(
214:                            org.osid.OsidException.OPERATION_FAILED);
215:                }
216:            }
217:
218:            public org.osid.repository.Asset getAsset(org.osid.shared.Id assetId)
219:                    throws org.osid.repository.RepositoryException {
220:                if (assetId == null) {
221:                    throw new org.osid.repository.RepositoryException(
222:                            org.osid.shared.SharedException.NULL_ARGUMENT);
223:                }
224:                try {
225:                    org.osid.repository.RepositoryIterator repositoryIterator = getRepositories();
226:                    while (repositoryIterator.hasNextRepository()) {
227:                        org.osid.repository.Repository nextRepository = repositoryIterator
228:                                .nextRepository();
229:                        try {
230:                            org.osid.repository.Asset asset = nextRepository
231:                                    .getAsset(assetId);
232:                            return asset;
233:                        } catch (Throwable t) {
234:                        }
235:                    }
236:                } catch (Throwable t) {
237:                    _log.error(t.getMessage());
238:                    throw new org.osid.repository.RepositoryException(
239:                            org.osid.OsidException.OPERATION_FAILED);
240:                }
241:                throw new org.osid.repository.RepositoryException(
242:                        org.osid.shared.SharedException.UNKNOWN_ID);
243:            }
244:
245:            public org.osid.repository.Asset getAssetByDate(
246:                    org.osid.shared.Id assetId, long date)
247:                    throws org.osid.repository.RepositoryException {
248:                if (assetId == null) {
249:                    throw new org.osid.repository.RepositoryException(
250:                            org.osid.shared.SharedException.NULL_ARGUMENT);
251:                }
252:                try {
253:                    org.osid.repository.RepositoryIterator repositoryIterator = getRepositories();
254:                    while (repositoryIterator.hasNextRepository()) {
255:                        org.osid.repository.Repository nextRepository = repositoryIterator
256:                                .nextRepository();
257:                        try {
258:                            org.osid.repository.Asset asset = nextRepository
259:                                    .getAssetByDate(assetId, date);
260:                            return asset;
261:                        } catch (Throwable t) {
262:                        }
263:                    }
264:                } catch (Throwable t) {
265:                    _log.error(t.getMessage());
266:                    throw new org.osid.repository.RepositoryException(
267:                            org.osid.OsidException.OPERATION_FAILED);
268:                }
269:                throw new org.osid.repository.RepositoryException(
270:                        org.osid.shared.SharedException.UNKNOWN_ID);
271:            }
272:
273:            public org.osid.shared.LongValueIterator getAssetDates(
274:                    org.osid.shared.Id assetId)
275:                    throws org.osid.repository.RepositoryException {
276:                if (assetId == null) {
277:                    throw new org.osid.repository.RepositoryException(
278:                            org.osid.shared.SharedException.NULL_ARGUMENT);
279:                }
280:                java.util.Vector result = new java.util.Vector();
281:                try {
282:                    org.osid.repository.RepositoryIterator repositoryIterator = getRepositories();
283:                    while (repositoryIterator.hasNextRepository()) {
284:                        org.osid.repository.Repository nextRepository = repositoryIterator
285:                                .nextRepository();
286:                        org.osid.shared.LongValueIterator longValueIterator = repository
287:                                .getAssetDates(assetId);
288:                        while (longValueIterator.hasNextLongValue()) {
289:                            result.addElement(new Long(longValueIterator
290:                                    .nextLongValue()));
291:                        }
292:                    }
293:                    return new LongValueIterator(result);
294:                } catch (Throwable t) {
295:                    _log.error(t.getMessage());
296:                    throw new org.osid.repository.RepositoryException(
297:                            org.osid.OsidException.OPERATION_FAILED);
298:                }
299:            }
300:
301:            public org.osid.repository.AssetIterator getAssetsBySearch(
302:                    org.osid.repository.Repository[] repositories,
303:                    java.io.Serializable searchCriteria,
304:                    org.osid.shared.Type searchType,
305:                    org.osid.shared.Properties searchProperties)
306:                    throws org.osid.repository.RepositoryException {
307:                if (repositories == null) {
308:                    throw new org.osid.repository.RepositoryException(
309:                            org.osid.shared.SharedException.NULL_ARGUMENT);
310:                }
311:                try {
312:                    java.util.Vector results = new java.util.Vector();
313:                    for (int j = 0; j < repositories.length; j++) {
314:                        org.osid.repository.Repository nextRepository = repositories[j];
315:                        //optionally add a separate thread here
316:                        try {
317:                            org.osid.repository.AssetIterator assetIterator = nextRepository
318:                                    .getAssetsBySearch(searchCriteria,
319:                                            searchType, searchProperties);
320:                            while (assetIterator.hasNextAsset()) {
321:                                results.addElement(assetIterator.nextAsset());
322:                            }
323:                        } catch (Throwable t) {
324:                            _log.warn(t.getMessage());
325:                        }
326:                    }
327:                    return new AssetIterator(results);
328:                } catch (Throwable t) {
329:                    _log.error(t.getMessage());
330:                    throw new org.osid.repository.RepositoryException(
331:                            org.osid.OsidException.OPERATION_FAILED);
332:                }
333:            }
334:
335:            public org.osid.shared.Id copyAsset(
336:                    org.osid.repository.Repository repository,
337:                    org.osid.shared.Id assetId)
338:                    throws org.osid.repository.RepositoryException {
339:                if ((repository == null) || (assetId == null)) {
340:                    throw new org.osid.repository.RepositoryException(
341:                            org.osid.shared.SharedException.NULL_ARGUMENT);
342:                }
343:                throw new org.osid.repository.RepositoryException(
344:                        org.osid.OsidException.UNIMPLEMENTED);
345:            }
346:
347:            public org.osid.shared.TypeIterator getRepositoryTypes()
348:                    throws org.osid.repository.RepositoryException {
349:                java.util.Vector results = new java.util.Vector();
350:                try {
351:                    results.addElement(new Type("sakaibrary", "repository",
352:                            "metasearch"));
353:                    return new TypeIterator(results);
354:                } catch (Throwable t) {
355:                    _log.error(t.getMessage());
356:                    throw new org.osid.repository.RepositoryException(
357:                            org.osid.OsidException.OPERATION_FAILED);
358:                }
359:            }
360:
361:            public void osidVersion_2_0()
362:                    throws org.osid.repository.RepositoryException {
363:            }
364:
365:            public java.io.InputStream getConfigStream(String fileName)
366:                    throws org.osid.repository.RepositoryException {
367:                InputStream fileIn = this .getClass().getResourceAsStream(
368:                        fileName);
369:
370:                if (fileIn == null) {
371:                    /*
372:                     * Not found
373:                     */
374:                    throw new org.osid.repository.RepositoryException(
375:                            org.osid.OsidException.CONFIGURATION_ERROR);
376:                }
377:                return fileIn;
378:            }
379:        }
w__w_w_.__j__a__v___a_2___s_.com___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.