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 Part implements org.osid.repository.Part {
027: private org.osid.repository.PartStructure partStructure = null;
028: private org.osid.shared.Id partStructureId = null;
029: private java.io.Serializable value = null;
030: private org.osid.id.IdManager idManager = null;
031: private org.osid.logging.WritableLog log = null;
032: private String displayName = null;
033: private org.osid.shared.Id id = null;
034:
035: public String getDisplayName()
036: throws org.osid.repository.RepositoryException {
037: return this .displayName;
038: }
039:
040: public org.osid.shared.Id getId()
041: throws org.osid.repository.RepositoryException {
042: return this .id;
043: }
044:
045: private void log(String entry)
046: throws org.osid.repository.RepositoryException {
047: if (log != null) {
048: try {
049: log.appendLog(entry);
050: } catch (org.osid.logging.LoggingException lex) {
051: // swallow exception since logging is a best attempt to log an exception anyway
052: }
053: }
054: }
055:
056: protected Part(org.osid.shared.Id partStructureId,
057: java.io.Serializable value,
058: org.osid.id.IdManager idManager,
059: org.osid.logging.WritableLog log)
060: throws org.osid.repository.RepositoryException {
061: this .idManager = idManager;
062: this .log = log;
063: this .partStructureId = partStructureId;
064:
065: this .value = value;
066: try {
067: this .id = this .idManager.createId();
068: if (partStructureId.isEqual(ContributorPartStructure
069: .getInstance().getId())) {
070: this .partStructure = ContributorPartStructure
071: .getInstance();
072: } else if (partStructureId.isEqual(CoveragePartStructure
073: .getInstance().getId())) {
074: this .partStructure = CoveragePartStructure
075: .getInstance();
076: } else if (partStructureId.isEqual(CreatorPartStructure
077: .getInstance().getId())) {
078: this .partStructure = CreatorPartStructure.getInstance();
079: } else if (partStructureId.isEqual(DatePartStructure
080: .getInstance().getId())) {
081: this .partStructure = DatePartStructure.getInstance();
082: } else if (partStructureId.isEqual(FormatPartStructure
083: .getInstance().getId())) {
084: this .partStructure = FormatPartStructure.getInstance();
085: } else if (partStructureId.isEqual(LanguagePartStructure
086: .getInstance().getId())) {
087: this .partStructure = LanguagePartStructure
088: .getInstance();
089: } else if (partStructureId.isEqual(PublisherPartStructure
090: .getInstance().getId())) {
091: this .partStructure = PublisherPartStructure
092: .getInstance();
093: } else if (partStructureId.isEqual(RelationPartStructure
094: .getInstance().getId())) {
095: this .partStructure = RelationPartStructure
096: .getInstance();
097: } else if (partStructureId.isEqual(RightsPartStructure
098: .getInstance().getId())) {
099: this .partStructure = RightsPartStructure.getInstance();
100: } else if (partStructureId.isEqual(SourcePartStructure
101: .getInstance().getId())) {
102: this .partStructure = SourcePartStructure.getInstance();
103: } else if (partStructureId.isEqual(SubjectPartStructure
104: .getInstance().getId())) {
105: this .partStructure = SubjectPartStructure.getInstance();
106: } else if (partStructureId.isEqual(TypePartStructure
107: .getInstance().getId())) {
108: this .partStructure = TypePartStructure.getInstance();
109: } else if (partStructureId.isEqual(VueSpecPartStructure
110: .getInstance().getId())) {
111: this .partStructure = VueSpecPartStructure.getInstance();
112: } else if (partStructureId.isEqual(XmlPartStructure
113: .getInstance().getId())) {
114: this .partStructure = XmlPartStructure.getInstance();
115: } else if (partStructureId.isEqual(URLPartStructure
116: .getInstance().getId())) {
117: this .partStructure = URLPartStructure.getInstance();
118: }
119: } catch (Throwable t) {
120: log(t.getMessage());
121: throw new org.osid.repository.RepositoryException(
122: org.osid.repository.RepositoryException.OPERATION_FAILED);
123: }
124: }
125:
126: public org.osid.repository.Part createPart(
127: org.osid.shared.Id partStructureId,
128: java.io.Serializable value)
129: throws org.osid.repository.RepositoryException {
130: throw new org.osid.repository.RepositoryException(
131: org.osid.OsidException.UNIMPLEMENTED);
132: }
133:
134: public void deletePart(org.osid.shared.Id partStructureId)
135: throws org.osid.repository.RepositoryException {
136: throw new org.osid.repository.RepositoryException(
137: org.osid.OsidException.UNIMPLEMENTED);
138: }
139:
140: public void updateDisplayName(String displayName)
141: throws org.osid.repository.RepositoryException {
142: throw new org.osid.repository.RepositoryException(
143: org.osid.OsidException.UNIMPLEMENTED);
144: }
145:
146: public org.osid.repository.PartIterator getParts()
147: throws org.osid.repository.RepositoryException {
148: return new PartIterator(new java.util.Vector());
149: }
150:
151: public org.osid.repository.PartStructure getPartStructure()
152: throws org.osid.repository.RepositoryException {
153: return this .partStructure;
154: }
155:
156: public java.io.Serializable getValue()
157: throws org.osid.repository.RepositoryException {
158: return this .value;
159: }
160:
161: public void updateValue(java.io.Serializable value)
162: throws org.osid.repository.RepositoryException {
163: this.value = value;
164: }
165: }
|