001: package org.sakaibrary.osid.repository.xserver;
002:
003: /**********************************************************************************
004: * $URL: https://source.sakaiproject.org/svn/citations/tags/sakai_2-4-1/citations-osid/xserver/src/java/org/sakaibrary/osid/repository/xserver/Record.java $
005: * $Id: Record.java 22640 2007-03-14 21:04:07Z jimeng@umich.edu $
006: **********************************************************************************
007: *
008: * Copyright (c) 2003, 2004, 2005 The Regents of the University of Michigan, Trustees of Indiana University,
009: * Board of Trustees of the Leland Stanford, Jr., University, and The MIT Corporation
010: *
011: * Licensed under the Educational Community License Version 1.0 (the "License");
012: * By obtaining, using and/or copying this Original Work, you agree that you have read,
013: * understand, and will comply with the terms and conditions of the Educational Community License.
014: * You may obtain a copy of the License at:
015: *
016: * http://cvs.sakaiproject.org/licenses/license_1_0.html
017: *
018: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
019: * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
020: * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
021: * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
022: * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
023: *
024: **********************************************************************************/
025: /**
026: * @author Massachusetts Institute of Techbology, Sakai Software Development Team
027: * @version
028: */
029: public class Record implements org.osid.repository.Record {
030: private static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory
031: .getLog("org.sakaibrary.osid.repository.xserver.Record");
032:
033: private java.util.Vector partVector = new java.util.Vector();
034: private org.osid.id.IdManager idManager = null;
035: private org.osid.shared.Id recordStructureId = null;
036: private String displayName = null;
037: private org.osid.shared.Id id = null;
038:
039: public String getDisplayName()
040: throws org.osid.repository.RepositoryException {
041: return this .displayName;
042: }
043:
044: public org.osid.shared.Id getId()
045: throws org.osid.repository.RepositoryException {
046: return this .id;
047: }
048:
049: protected Record(org.osid.shared.Id recordStructureId,
050: org.osid.id.IdManager idManager)
051: throws org.osid.repository.RepositoryException {
052: try {
053: this .idManager = idManager;
054: this .recordStructureId = recordStructureId;
055: this .id = idManager.createId();
056: } catch (Throwable t) {
057: LOG.warn(t.getMessage());
058: throw new org.osid.repository.RepositoryException(
059: org.osid.OsidException.OPERATION_FAILED);
060: }
061: }
062:
063: public org.osid.repository.Part createPart(
064: org.osid.shared.Id partStructureId,
065: java.io.Serializable value)
066: throws org.osid.repository.RepositoryException {
067: try {
068: org.osid.repository.Part part = new Part(partStructureId,
069: value, this .idManager);
070: this .partVector.addElement(part);
071: return part;
072: } catch (Throwable t) {
073: LOG.warn(t.getMessage());
074: throw new org.osid.repository.RepositoryException(
075: org.osid.OsidException.OPERATION_FAILED);
076: }
077: }
078:
079: public void deletePart(org.osid.shared.Id partId)
080: throws org.osid.repository.RepositoryException {
081: try {
082: for (int i = 0, size = this .partVector.size(); i < size; i++) {
083: org.osid.repository.Part part = (org.osid.repository.Part) this .partVector
084: .elementAt(i);
085: if (part.getId().isEqual(partId)) {
086: this .partVector.removeElementAt(i);
087: return;
088: }
089: }
090: throw new org.osid.repository.RepositoryException(
091: org.osid.shared.SharedException.UNKNOWN_ID);
092: } catch (Throwable t) {
093: LOG.warn(t.getMessage());
094: throw new org.osid.repository.RepositoryException(
095: org.osid.OsidException.OPERATION_FAILED);
096: }
097: }
098:
099: public void updateDisplayName(String displayName)
100: throws org.osid.repository.RepositoryException {
101: throw new org.osid.repository.RepositoryException(
102: org.osid.OsidException.UNIMPLEMENTED);
103: }
104:
105: public org.osid.repository.PartIterator getParts()
106: throws org.osid.repository.RepositoryException {
107: return new PartIterator(this .partVector);
108: }
109:
110: public org.osid.repository.RecordStructure getRecordStructure()
111: throws org.osid.repository.RepositoryException {
112: try {
113: if (this .recordStructureId.isEqual(RecordStructure
114: .getInstance().getId())) {
115: return new RecordStructure();
116: } else {
117: return null;
118: }
119: } catch (Throwable t) {
120: LOG.warn(t.getMessage());
121: throw new org.osid.repository.RepositoryException(
122: org.osid.OsidException.OPERATION_FAILED);
123: }
124: }
125:
126: public boolean isMultivalued()
127: throws org.osid.repository.RepositoryException {
128: return false;
129: }
130: }
|