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