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.exceptions.NegotiationException;
38  import org.ogf.graap.wsag.api.exceptions.ResourceUnavailableException;
39  import org.ogf.graap.wsag.api.exceptions.ResourceUnknownException;
40  import org.ogf.schemas.graap.wsAgreement.AgreementTemplateType;
41  import org.ogf.schemas.graap.wsAgreement.negotiation.NegotiationContextType;
42  import org.ogf.schemas.graap.wsAgreement.negotiation.NegotiationOfferType;
43  
44  /**
45   * Client interface for perfoming dynamic negotiation processes with a WSAG4J server.
46   * 
47   * @author hrasheed
48   */
49  public interface NegotiationClient
50  {
51      /**
52       * Default builder.
53       */
54      ClientLocator<NegotiationClient> FACTORY = new ClientLocator<NegotiationClient>( NegotiationClient.class );
55  
56      /**
57       * Returns the web-service client used for communication with the SLA management server.
58       * 
59       * @return the web service client for this service.
60       */
61      RemoteClient getRemoteClient();
62  
63      /**
64       * Returns the context of this negotiation process.
65       * 
66       * @return the negotiation context
67       * @throws ResourceUnknownException
68       *             the remote resource is unknown
69       * @throws ResourceUnavailableException
70       *             the remote resource is unavailable
71       */
72      NegotiationContextType getNegotiationContext()
73          throws ResourceUnknownException, ResourceUnavailableException;
74  
75      /**
76       * A negotiation instance supports zero or more templates that can be used to create negotiation offers.
77       * In case of a negotiation process, these templates are a subset of the templates offered by an agreement
78       * factory. Only these templates are returned for which a proper negotiation strategy is implemented. in
79       * case of agreement re negotiation, a negotiation instance may return one ore more templates to bootstrap
80       * the negotiation process.
81       * 
82       * @return the negotiable templates
83       * @throws ResourceUnknownException
84       *             the remote resource is unknown
85       * @throws ResourceUnavailableException
86       *             the remote resource is unavailable
87       */
88      AgreementTemplateType[] getNegotiableTemplates()
89          throws ResourceUnknownException, ResourceUnavailableException;
90  
91      /**
92       * Returns a history of exchanged offers in this negotiation process.
93       * 
94       * @return the offers exchanged in this negotiation
95       * @throws ResourceUnknownException
96       *             the remote resource is unknown
97       * @throws ResourceUnavailableException
98       *             the remote resource is unavailable
99       */
100     NegotiationOfferType[] getNegotiationOffers()
101         throws ResourceUnknownException, ResourceUnavailableException;
102 
103     /**
104      * Negotiates a set of agreement offers.
105      * 
106      * @param offers
107      *            the offers to negotiate
108      * @return a set of counter offers
109      * @throws NegotiationException
110      *             an error occured processing the negotiation request
111      * @throws ResourceUnknownException
112      *             the remote resource is unknown
113      * @throws ResourceUnavailableException
114      *             the remote resource is unavailable
115      */
116     NegotiationOfferType[] negotiate( NegotiationOfferType[] offers )
117         throws NegotiationException, ResourceUnknownException, ResourceUnavailableException;
118 
119     /**
120      * Advertises a set of negotiation offers.
121      * 
122      * @param offers
123      *            the offers to advertise
124      * @throws NegotiationException
125      *             an error occured processing the negotiation request
126      * @throws ResourceUnknownException
127      *             the remote resource is unknown
128      * @throws ResourceUnavailableException
129      *             the remote resource is unavailable
130      */
131     void advertise( NegotiationOfferType[] offers )
132         throws NegotiationException, ResourceUnknownException, ResourceUnavailableException;
133 
134     /**
135      * Destroys this web service object.
136      * 
137      * @throws ResourceUnknownException
138      *             the remote resource is unknown
139      * @throws ResourceUnavailableException
140      *             the remote resource is unavailable
141      */
142     void destroy() throws ResourceUnknownException, ResourceUnavailableException;
143 
144     /**
145      * Returns the Negotiation Offer with the given offer id
146      * 
147      * @param offerID
148      *            the offerID of the negotiation offer to retrieve
149      * @return the negotiation offer with the given offer id
150      * @throws ResourceUnknownException
151      *             the remote resource is unknown
152      * @throws ResourceUnavailableException
153      *             the remote resource is unavailable
154      */
155     NegotiationOfferType getNegotiationOffer( String offerID )
156         throws ResourceUnknownException, ResourceUnavailableException;
157 
158     /**
159      * Terminates a negotiation.
160      * 
161      * @throws ResourceUnknownException
162      *             the remote resource is unknown
163      * @throws ResourceUnavailableException
164      *             the remote resource is unavailable
165      */
166     void terminate() throws ResourceUnknownException, ResourceUnavailableException;
167 
168     /**
169      * Returns a copy of the client.
170      * 
171      * @return the cloned NegotiationClient
172      * @throws CloneNotSupportedException
173      *             indicates that a particular client implementation does not support cloning
174      */
175     NegotiationClient clone() throws CloneNotSupportedException;
176 
177 }