1:
30:
31: package ;
32:
33: import ;
34: import ;
35: import ;
36: import ;
37: import ;
38: import ;
39:
40:
45: public class StreamContentLocation implements ContentLocation
46: {
47: private ContentItem contentItem;
48: private StreamRepository repository;
49: private static final ContentEntity[] EMPTY_CONTENT_ENTITY = new ContentEntity[0];
50:
51: public StreamContentLocation(final StreamRepository repository)
52: {
53: this.repository = repository;
54: }
55:
56: public ContentEntity[] listContents() throws ContentIOException
57: {
58: if (contentItem == null)
59: {
60: return EMPTY_CONTENT_ENTITY;
61: }
62: else
63: {
64: return new ContentEntity[]{contentItem};
65: }
66: }
67:
68: public ContentEntity getEntry(final String name) throws ContentIOException
69: {
70: if (contentItem == null)
71: {
72: throw new ContentIOException("No such item");
73: }
74: if (contentItem.getName().equals(name))
75: {
76: return contentItem;
77: }
78: throw new ContentIOException("No such item");
79: }
80:
81: public ContentItem createItem(final String name) throws ContentCreationException
82: {
83: if (contentItem == null)
84: {
85: contentItem = new StreamContentItem(name, this,
86: repository.getInputStream(), repository.getOutputStream());
87: return contentItem;
88: }
89: throw new ContentCreationException
90: ("Failed to create the item. Item already there");
91: }
92:
93: public ContentLocation createLocation(final String name)
94: throws ContentCreationException
95: {
96: throw new ContentCreationException
97: ("Failed to create the item. Item already there");
98: }
99:
100: public boolean exists(final String name)
101: {
102: if (contentItem == null)
103: {
104: return false;
105: }
106: return contentItem.getName().equals(name);
107: }
108:
109: public String getName()
110: {
111: return "root";
112: }
113:
114: public Object getContentId()
115: {
116: return getName();
117: }
118:
119: public Object getAttribute(final String domain, final String key)
120: {
121: return null;
122: }
123:
124: public boolean setAttribute(final String domain, final String key, final Object value)
125: {
126: return false;
127: }
128:
129: public ContentLocation getParent()
130: {
131: return null;
132: }
133:
134: public Repository getRepository()
135: {
136: return repository;
137: }
138:
139: public boolean delete()
140: {
141: return false;
142: }
143: }