001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.jetspeed.capabilities;
018:
019: import java.util.Collection;
020: import java.util.Iterator;
021:
022: /**
023: * Capabilities Component Interface
024: *
025: * @author <a href="mailto:roger.ruttimann@earthlink.net">Roger Ruttimann</a>
026: * @version $Id: Capabilities.java 516448 2007-03-09 16:25:47Z ate $
027: */
028: public interface Capabilities {
029:
030: /**
031: * Creates a Capability Map with Capabilities, Mimetypes and mediaTypes for the given UserAgentPattern
032: * @param userAgent Agent from the request
033: * @return CapabilityMap populated with Capabilities, Mimetypes and Mediatype
034: * that match the userAgent. Never returns <code>null</code>
035: * @throws UnableToBuildCapabilityMapException If a capability could not be created
036: */
037: CapabilityMap getCapabilityMap(String userAgent)
038: throws UnableToBuildCapabilityMapException;
039:
040: /**
041: * Obtain an iterator of all existing clients.
042: * @return Returns an iterator for all existing Clients
043: */
044: Iterator getClients();
045:
046: /**
047: * Finds a client for a given userAgentPattern
048: * @param userAgent
049: * @return Client that matches agent or null if no match is found
050: *
051: */
052: Client findClient(String userAgent);
053:
054: /**
055: * Returns a collection of MediaTypes that matches the MimeTypes defined in the mimetype parameter
056: * @param Mimetype
057: *
058: * @return Collection of Mediatypes that matches the mimetypes
059: */
060: Collection getMediaTypesForMimeTypes(Iterator mimetypes);
061:
062: /**
063: * Clears CapabilityMap cache
064: * TODO: Roger, why is this on the public interface. It seems to be impl specific
065: */
066: void deleteCapabilityMapCache();
067:
068: /**
069: * Given a media type string, look up the corresponding media type object.
070: *
071: * @param mediaType The string representation of a media type.
072: * @return The found media type object or if not found, null.
073: */
074: MediaType getMediaType(String mediaType);
075:
076: /**
077: * Given a Mimetype string lookup the corresponding media type object
078: * @param mimeTypeName to use for lookup
079: * @return MediaTypeEntry that matches the lookup in the MEDIATYPE_TO_MIMETYPE table
080: */
081: public MediaType getMediaTypeForMimeType(String mimeTypeName);
082:
083: /**
084: * Given a capability string, look up the corresponding capability object.
085: *
086: * @param capability The string representation of a capability.
087: * @return The found capability object or if not found, null.
088: */
089: Capability getCapability(String capability);
090:
091: /**
092: * Given a mime type string, look up the corresponding mime type object.
093: *
094: * @param mimeType The string representation of a mime type.
095: * @return The found mime type object or if not found, null.
096: */
097: MimeType getMimeType(String mimeType);
098:
099: /**
100: * Given a client name, look up the corresponding client object.
101: *
102: * @param clientName The name of the client.
103: * @return The found client object or if not found, null.
104: */
105: Client getClient(String clientName);
106:
107: /**
108: * Obtain an iterator of all existing capabilities.
109: * @return Returns an iterator for all existing Capabilities of type <code>Capability</code>
110: */
111: Iterator getCapabilities();
112:
113: /**
114: * Obtain an iterator of all existing mime types.
115: * @return Returns an iterator for all existing Mime Types of type <code>MimeType</code>
116: */
117: Iterator getMimeTypes();
118:
119: /**
120: * Obtain an iterator of all existing media types.
121: * @return Returns an iterator for all existing media types of type <code>MediaType</code>
122: */
123: Iterator getMediaTypes();
124:
125: /**
126: * Obtain the name of the CapabilityBean reference
127: * @return ref-id of the capability bean
128: */
129: public String getCapabilityBeanName();
130:
131: /**
132: * Set the name of the CapabilityBean reference - used exclusively in IoC
133: * @param capabilityBeanName The ref-id of the capability bean.
134: */
135: public void setCapabilityBeanName(String capabilityBeanName);
136:
137: /**
138: * Obtain the name of the ClientBean reference
139: * @return ref-id of the client bean
140: */
141: public String getClientBeanName();
142:
143: /**
144: * Set the name of the ClientBean reference - used exclusively in IoC
145: * @param clientBeanName The ref-id of the client bean.
146: */
147: public void setClientBeanName(String clientBeanName);
148:
149: /**
150: * Obtain the name of the Media Type reference
151: * @return ref-id of the media type bean
152: */
153: public String getMediaTypeBeanName();
154:
155: /**
156: * Set the name of the MediaType bean reference - used exclusively in IoC
157: * @param mediaTypeBeanName The ref-id of the mediaType bean.
158: */
159: public void setMediaTypeBeanName(String mediaTypeBeanName);
160:
161: /**
162: * Obtain the name of the Mime Type reference
163: * @return ref-id of the mime type bean
164: */
165: public String getMimeTypeBeanName();
166:
167: /**
168: * Set the name of the MimeType bean reference - used exclusively in IoC
169: * @param mimeTypeBeanName The ref-id of the mimeType bean.
170: */
171: public void setMimeTypeBeanName(String mimeTypeBeanName);
172:
173: /**
174: * Create a new capability in the system or return the existing one if already exists
175: * @param capabilityName The string describing the capability
176: * @return A new (or existing) capability
177: */
178: public Capability createCapability(String capabilityName)
179: throws ClassNotFoundException;
180:
181: /**
182: * Create a new mimetype in the system or return the existing one if already exists
183: * @param mimeTypeName The string describing the mimeType
184: * @return A new (or existing) MimeType
185: */
186: public MimeType createMimeType(String mimeTypeName)
187: throws ClassNotFoundException;
188:
189: /**
190: * Create a new mediaType in the system or return the existing one if already exists
191: * @param mediaTypeName The string describing the mediaType
192: * @return A new (or existing) MediaType
193: */
194: public MediaType createMediaType(String mediaTypeName)
195: throws ClassNotFoundException;
196:
197: /**
198: * Create a new client in the system or return the existing one if already exists
199: * @param clientName The string describing the client
200: * @return A new (or existing) client
201: */
202: public Client createClient(String clientName)
203: throws ClassNotFoundException;
204:
205: /**
206: * Save media type to backend storage
207: *
208: * @param mediaType valid mediatype object
209: */
210: public void storeMediaType(MediaType mediaType)
211: throws CapabilitiesException;
212:
213: //TODO: change CapabilitiesException to better indicate cause
214:
215: /**
216: * delete existing media type from backend storage
217: *
218: * @param mediaType valid mediatype object
219: */
220: public void deleteMediaType(MediaType mediaType)
221: throws CapabilitiesException;
222:
223: /**
224: * Save capability to backend storage
225: *
226: * @param capability valid capability object
227: */
228: public void storeCapability(Capability capability)
229: throws CapabilitiesException;
230:
231: /**
232: * delete existing capability from backend storage
233: *
234: * @param capability valid capability object
235: */
236: public void deleteCapability(Capability capability)
237: throws CapabilitiesException;
238:
239: /**
240: * Save mime type to backend storage
241: *
242: * @param mimeType valid mimetype object
243: */
244: public void storeMimeType(MimeType mimeType)
245: throws CapabilitiesException;
246:
247: /**
248: * delete existing mime type from backend storage
249: *
250: * @param mimeType valid mimetype object
251: */
252: public void deleteMimeType(MimeType mimeType)
253: throws CapabilitiesException;
254:
255: /**
256: * Save client to backend storage
257: *
258: * @param client valid Client object
259: */
260: public void storeClient(Client client) throws CapabilitiesException;
261:
262: /**
263: * delete existing client from backend storage
264: *
265: * @param client valid client object
266: */
267: public void deleteClient(Client client)
268: throws CapabilitiesException;
269:
270: }
|