View Javadoc

1   /* 
2    * Copyright (c) 2007, Fraunhofer-Gesellschaft
3    * All rights reserved.
4    * 
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions are
7    * met:
8    * 
9    * (1) Redistributions of source code must retain the above copyright
10   *     notice, this list of conditions and the disclaimer at the end.
11   *     Redistributions in binary form must reproduce the above copyright
12   *     notice, this list of conditions and the following disclaimer in
13   *     the documentation and/or other materials provided with the
14   *     distribution.
15   * 
16   * (2) Neither the name of Fraunhofer nor the names of its
17   *     contributors may be used to endorse or promote products derived
18   *     from this software without specific prior written permission.
19   * 
20   * DISCLAIMER
21   * 
22   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23   * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24   * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25   * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26   * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29   * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30   * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31   * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33   *  
34   */
35  package org.ogf.graap.wsag.client.api;
36  
37  import org.ogf.graap.wsag.api.AgreementOffer;
38  import org.ogf.graap.wsag.api.exceptions.AgreementFactoryException;
39  import org.ogf.graap.wsag.api.exceptions.NegotiationFactoryException;
40  import org.ogf.graap.wsag.api.exceptions.ResourceUnavailableException;
41  import org.ogf.graap.wsag.api.exceptions.ResourceUnknownException;
42  import org.ogf.schemas.graap.wsAgreement.AgreementFactoryPropertiesType;
43  import org.ogf.schemas.graap.wsAgreement.AgreementTemplateType;
44  import org.ogf.schemas.graap.wsAgreement.negotiation.NegotiationContextType;
45  import org.w3.x2005.x08.addressing.EndpointReferenceType;
46  
47  /**
48   * Client interface to interact with an agreement factory.
49   * 
50   * @author Oliver Waeldrich
51   */
52  public interface AgreementFactoryClient
53  {
54      /**
55       * Default builder.
56       */
57      ClientLocator<AgreementFactoryClient> FACTORY = new ClientLocator<AgreementFactoryClient>(
58          AgreementFactoryClient.class );
59  
60      /**
61       * Returns the WSDM id of a web-service resource.
62       * 
63       * @return the WSDM resource id
64       * 
65       * @throws ResourceUnknownException
66       *             the remote resource is unknown
67       * @throws ResourceUnavailableException
68       *             the remote resource is unavailable
69       */
70      String getResourceId() throws ResourceUnknownException, ResourceUnavailableException;
71  
72      /**
73       * Retrieves the templates for supported SLAs from the SLA management system.
74       * 
75       * @return all templates exposed by this agreement factory instance
76       * @throws ResourceUnknownException
77       *             the remote resource is unknown
78       * @throws ResourceUnavailableException
79       *             the remote resource is unavailable
80       */
81      AgreementTemplateType[] getTemplates() throws ResourceUnknownException, ResourceUnavailableException;
82  
83      /**
84       * Creates a new agreement instance with the SLA management server.
85       * 
86       * @param offer
87       *            the agreement offer
88       * @return a client for the created agreement
89       * @throws AgreementFactoryException
90       *             indicates that the agreement was rejected by the factory
91       * @throws ResourceUnknownException
92       *             the remote resource is unknown
93       * @throws ResourceUnavailableException
94       *             the remote resource is unavailable
95       */
96      AgreementClient createAgreement( AgreementOffer offer )
97          throws AgreementFactoryException, ResourceUnknownException, ResourceUnavailableException;
98  
99      /**
100      * Creates a pending agreement instance. The decision whether to accept or reject the agreement is
101      * deferred.
102      * 
103      * @param offer
104      *            The agreement offer passed from the agreement initiator.
105      * @return An {@link AgreementClient} for the new created agreement.
106      * @throws AgreementFactoryException
107      *             An error occurred during the the agreement creation. The agreement was rejected.
108      * @throws ResourceUnknownException
109      *             No pending agreement factory exists at the specified endpoint.
110      * @throws ResourceUnavailableException
111      *             The agreement factory at the specified endpoint is not accessible.
112      */
113     AgreementClient createPendingAgreement( AgreementOffer offer )
114         throws AgreementFactoryException, ResourceUnknownException, ResourceUnavailableException;
115 
116     /**
117      * Creates a pending agreement instance. The decision whether to accept or reject the agreement is
118      * deferred. Once the decision has been made the client is notified via the given notification endpoint.
119      * 
120      * @param offer
121      *            The agreement offer passed from the agreement initiator.
122      * @param acceptanceEPR
123      *            An endpoint to an agreement acceptance instance.
124      * @return An {@link AgreementClient} for the new created agreement.
125      * @throws AgreementFactoryException
126      *             An error occurred during the the agreement creation. The agreement was rejected.
127      * @throws ResourceUnknownException
128      *             No pending agreement factory exists at the specified endpoint.
129      * @throws ResourceUnavailableException
130      *             The agreement factory at the specified endpoint is not accessible.
131      */
132     AgreementClient createPendingAgreement( AgreementOffer offer, EndpointReferenceType acceptanceEPR )
133         throws AgreementFactoryException, ResourceUnknownException, ResourceUnavailableException;
134 
135     /**
136      * Initiates a new negotiation process.
137      * 
138      * @param context
139      *            the context for the negotiation to initialize
140      * @return the new initiated negotiation instance
141      * @throws NegotiationFactoryException
142      *             indicates that the creation of a negotiation process was rejected
143      * @throws ResourceUnknownException
144      *             the remote resource is unknown
145      * @throws ResourceUnavailableException
146      *             the remote resource is unavailable
147      */
148     NegotiationClient initiateNegotiation( NegotiationContextType context )
149         throws NegotiationFactoryException, ResourceUnknownException, ResourceUnavailableException;
150 
151     /**
152      * Lists the agreement instances of a particular agreement factory.
153      * 
154      * @return a set of registered agreements
155      * 
156      * @throws ResourceUnknownException
157      *             the remote resource is unknown
158      * @throws ResourceUnavailableException
159      *             the remote resource is unavailable
160      */
161     AgreementClient[] listAgreements() throws ResourceUnknownException, ResourceUnavailableException;
162 
163     /**
164      * Returns a template with a particular name and id from the server, or <code>null</code> if the requested
165      * template does not exist.
166      * 
167      * @param name
168      *            the name of the requested template
169      * @param id
170      *            the id of the requested template
171      * @return a template with the given name and id, or null if no appropriate template was found.
172      * @throws ResourceUnknownException
173      *             the remote resource is unknown
174      * @throws ResourceUnavailableException
175      *             the remote resource is unavailable
176      */
177     AgreementTemplateType getTemplate( String name, String id )
178         throws ResourceUnknownException, ResourceUnavailableException;
179 
180     /**
181      * Returns the resource properties of the agreement factory instance.
182      * 
183      * @return the agreement factory resource properties
184      * 
185      * @throws ResourceUnknownException
186      *             the remote resource is unknown
187      * @throws ResourceUnavailableException
188      *             the remote resource is unavailable
189      */
190     AgreementFactoryPropertiesType getResourceProperties()
191         throws ResourceUnknownException, ResourceUnavailableException;
192 
193     /**
194      * Returns the web service client used for communication with the SLA management system.
195      * 
196      * @return the web service client for this service.
197      */
198     RemoteClient getRemoteClient();
199 
200     /**
201      * Returns a copy of the client.
202      * 
203      * @return the cloned AgreementFactoryClient
204      * 
205      * @throws CloneNotSupportedException
206      *             indicates that the particular client implementation does not support cloning
207      */
208     AgreementFactoryClient clone() throws CloneNotSupportedException;
209 
210 }