001: package org.sakaiproject.metaobj.shared.mgt.home;
002:
003: import org.sakaiproject.metaobj.shared.mgt.WritableObjectHome;
004: import org.sakaiproject.metaobj.shared.model.*;
005: import org.sakaiproject.metaobj.utils.xml.SchemaNode;
006: import org.sakaiproject.content.api.ResourceToolActionPipe;
007: import org.sakaiproject.content.api.ContentResource;
008: import org.sakaiproject.content.cover.ContentHostingService;
009: import org.sakaiproject.entity.api.ResourceProperties;
010: import org.jdom.Element;
011:
012: import java.io.InputStream;
013: import java.util.Collection;
014: import java.util.Date;
015:
016: /**
017: * Created by IntelliJ IDEA.
018: * User: johnellis
019: * Date: Jan 30, 2007
020: * Time: 9:31:00 AM
021: * To change this template use File | Settings | File Templates.
022: */
023: public class ResourceHelperArtifactHome implements
024: StructuredArtifactHomeInterface {
025:
026: private StructuredArtifactHomeInterface parentHome;
027: private ResourceToolActionPipe pipe;
028:
029: public ResourceHelperArtifactHome(
030: StructuredArtifactHomeInterface parentHome,
031: ResourceToolActionPipe pipe) {
032: this .parentHome = parentHome;
033: this .pipe = pipe;
034: // assume the user is gonna cancel unless they store
035: pipe.setActionCanceled(true);
036: pipe.setActionCompleted(false);
037: }
038:
039: public Artifact store(Artifact object) throws PersistenceException {
040: pipe.setRevisedContent(getParentHome().getBytes(
041: (StructuredArtifact) object));
042: pipe.setRevisedResourceProperty(
043: ResourceProperties.PROP_STRUCTOBJ_TYPE, getParentHome()
044: .getTypeId());
045: pipe
046: .setRevisedResourceProperty(
047: ContentHostingService.PROP_ALTERNATE_REFERENCE,
048: org.sakaiproject.metaobj.shared.mgt.MetaobjEntityManager.METAOBJ_ENTITY_PREFIX);
049: pipe.setActionCompleted(true);
050: pipe.setActionCanceled(false);
051: return object;
052: }
053:
054: public Artifact load(Id id) throws PersistenceException {
055: return load((ContentResource) pipe.getContentEntity());
056: }
057:
058: public void remove(Artifact object) throws PersistenceException {
059: getParentHome().remove(object);
060: }
061:
062: public Artifact store(String displayName, String contentType,
063: Type type, InputStream in) throws PersistenceException {
064: return getParentHome()
065: .store(displayName, contentType, type, in);
066: }
067:
068: public Artifact update(Artifact object, InputStream in)
069: throws PersistenceException {
070: return getParentHome().update(object, in);
071: }
072:
073: public Type getType() {
074: return getParentHome().getType();
075: }
076:
077: public String getExternalType() {
078: return getParentHome().getExternalType();
079: }
080:
081: public Artifact createInstance() {
082: return getParentHome().createInstance();
083: }
084:
085: public void prepareInstance(Artifact object) {
086: getParentHome().prepareInstance(object);
087: }
088:
089: public Artifact createSample() {
090: return getParentHome().createSample();
091: }
092:
093: public Collection findByOwner(Agent owner) throws FinderException {
094: return getParentHome().findByOwner(owner);
095: }
096:
097: public boolean isInstance(Artifact testObject) {
098: return getParentHome().isInstance(testObject);
099: }
100:
101: public void refresh() {
102: getParentHome().refresh();
103: }
104:
105: public String getExternalUri(Id artifactId, String name) {
106: return getParentHome().getExternalUri(artifactId, name);
107: }
108:
109: public InputStream getStream(Id artifactId) {
110: return getParentHome().getStream(artifactId);
111: }
112:
113: public boolean isSystemOnly() {
114: return getParentHome().isSystemOnly();
115: }
116:
117: public Class getInterface() {
118: return getParentHome().getInterface();
119: }
120:
121: public String getSiteId() {
122: return getParentHome().getSiteId();
123: }
124:
125: public SchemaNode getRootSchema() {
126: return getParentHome().getRootSchema();
127: }
128:
129: public String getInstruction() {
130: return getParentHome().getInstruction();
131: }
132:
133: public Date getModified() {
134: return getParentHome().getModified();
135: }
136:
137: public String getRootNode() {
138: return getParentHome().getRootNode();
139: }
140:
141: public SchemaNode getSchema() {
142: return getParentHome().getSchema();
143: }
144:
145: public StructuredArtifact load(ContentResource resource) {
146: return getParentHome().load(resource);
147: }
148:
149: public String getTypeId() {
150: return getParentHome().getTypeId();
151: }
152:
153: public byte[] getBytes(StructuredArtifact artifact) {
154: return getParentHome().getBytes(artifact);
155: }
156:
157: public Artifact cloneArtifact(Artifact copy, String newName)
158: throws PersistenceException {
159: return getParentHome().cloneArtifact(copy, newName);
160: }
161:
162: public Element getArtifactAsXml(Artifact art) {
163: return getParentHome().getArtifactAsXml(art);
164: }
165:
166: public StructuredArtifactHomeInterface getParentHome() {
167: return parentHome;
168: }
169:
170: public void setParentHome(StructuredArtifactHomeInterface parentHome) {
171: this.parentHome = parentHome;
172: }
173: }
|