1 /*
2 * Copyright (c) 2012, 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.api.rest;
36
37 import javax.ws.rs.Consumes;
38 import javax.ws.rs.DELETE;
39 import javax.ws.rs.GET;
40 import javax.ws.rs.POST;
41 import javax.ws.rs.Path;
42 import javax.ws.rs.Produces;
43 import javax.ws.rs.core.MediaType;
44
45 import org.apache.cxf.annotations.DataBinding;
46 import org.apache.cxf.xmlbeans.XmlBeansDataBinding;
47 import org.ogf.graap.wsag.api.exceptions.NegotiationException;
48 import org.ogf.graap.wsag.api.exceptions.ResourceUnavailableException;
49 import org.ogf.graap.wsag.api.exceptions.ResourceUnknownException;
50 import org.ogf.schemas.graap.wsAgreement.negotiation.AdvertiseInputDocument;
51 import org.ogf.schemas.graap.wsAgreement.negotiation.NegotiateInputDocument;
52 import org.ogf.schemas.graap.wsAgreement.negotiation.NegotiateOutputDocument;
53 import org.ogf.schemas.graap.wsAgreement.negotiation.NegotiationPropertiesDocument;
54 import org.ogf.schemas.graap.wsAgreement.negotiation.TerminateInputDocument;
55
56 /**
57 * Interface definition of the RESTful agreement service.
58 *
59 * @author owaeld
60 */
61 @DataBinding( XmlBeansDataBinding.class )
62 public interface RestNegotiation
63 {
64
65 /**
66 * Returns the context of this negotiation process.
67 *
68 * @return the negotiation context
69 * @throws ResourceUnknownException
70 * the remote resource is unknown
71 * @throws ResourceUnavailableException
72 * the remote resource is unavailable
73 */
74 @GET
75 @Path( "/NegotiationContext" )
76 @Produces( MediaType.APPLICATION_XML )
77 NegotiationPropertiesDocument getNegotiationContext()
78 throws ResourceUnknownException, ResourceUnavailableException;
79
80 /**
81 * A negotiation instance supports zero or more templates that can be used to create negotiation offers.
82 * In case of a negotiation process, these templates are a subset of the templates offered by an agreement
83 * factory. Only these templates are returned for which a proper negotiation strategy is implemented. in
84 * case of agreement re negotiation, a negotiation instance may return one ore more templates to bootstrap
85 * the negotiation process.
86 *
87 * @return the negotiable templates
88 * @throws ResourceUnknownException
89 * the remote resource is unknown
90 * @throws ResourceUnavailableException
91 * the remote resource is unavailable
92 */
93 @GET
94 @Path( "/NegotiableTemplates" )
95 @Produces( MediaType.APPLICATION_XML )
96 NegotiationPropertiesDocument getNegotiableTemplates()
97 throws ResourceUnknownException, ResourceUnavailableException;
98
99 /**
100 * Returns a history of exchanged offers in this negotiation process.
101 *
102 * @return the offers exchanged in this negotiation
103 * @throws ResourceUnknownException
104 * the remote resource is unknown
105 * @throws ResourceUnavailableException
106 * the remote resource is unavailable
107 */
108 @GET
109 @Path( "/NegotiationOffers" )
110 @Produces( MediaType.APPLICATION_XML )
111 NegotiationPropertiesDocument getNegotiationOffers()
112 throws ResourceUnknownException, ResourceUnavailableException;
113
114 /**
115 * Negotiates a set of agreement offers.
116 *
117 * @param offers
118 * the offers to negotiate
119 * @return a set of counter offers
120 * @throws NegotiationException
121 * an error occured processing the negotiation request
122 * @throws ResourceUnknownException
123 * the remote resource is unknown
124 * @throws ResourceUnavailableException
125 * the remote resource is unavailable
126 */
127 @POST
128 @Consumes( MediaType.APPLICATION_XML )
129 @Produces( MediaType.APPLICATION_XML )
130 NegotiateOutputDocument negotiate( NegotiateInputDocument offers )
131 throws NegotiationException, ResourceUnknownException, ResourceUnavailableException;
132
133 /**
134 * Advertises a set of negotiation offers.
135 *
136 * @param offers
137 * the offers to advertise
138 * @throws NegotiationException
139 * an error occured processing the negotiation request
140 * @throws ResourceUnknownException
141 * the remote resource is unknown
142 * @throws ResourceUnavailableException
143 * the remote resource is unavailable
144 */
145 @POST
146 @Consumes( MediaType.APPLICATION_XML )
147 void advertise( AdvertiseInputDocument offers )
148 throws NegotiationException, ResourceUnknownException, ResourceUnavailableException;
149
150 /**
151 * Terminates the agreement if permitted.
152 *
153 * @param reason
154 * the termination reason
155 *
156 * @throws ResourceUnknownException
157 * the referenced resource does not exist
158 * @throws ResourceUnavailableException
159 * the referenced resource is not available
160 */
161 @POST
162 @Path( "/Operations/Terminate" )
163 @Consumes( MediaType.APPLICATION_XML )
164 void terminate( TerminateInputDocument reason )
165 throws ResourceUnknownException, ResourceUnavailableException;
166
167 /**
168 * Destroys the agreement REST resource.
169 *
170 * @throws ResourceUnknownException
171 * the referenced resource does not exist
172 * @throws ResourceUnavailableException
173 * the referenced resource is not available
174 */
175 @DELETE
176 void destroy() throws ResourceUnknownException, ResourceUnavailableException;
177 }