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.local;
36
37 import org.ogf.graap.wsag.api.Agreement;
38 import org.ogf.graap.wsag.api.exceptions.ResourceUnavailableException;
39 import org.ogf.graap.wsag.api.exceptions.ResourceUnknownException;
40 import org.ogf.graap.wsag.client.api.AgreementClient;
41 import org.ogf.graap.wsag.client.api.RemoteClient;
42 import org.ogf.graap.wsag.client.api.impl.AgreementClientImpl;
43 import org.ogf.schemas.graap.wsAgreement.AgreementContextType;
44 import org.ogf.schemas.graap.wsAgreement.AgreementPropertiesType;
45 import org.ogf.schemas.graap.wsAgreement.AgreementStateType;
46 import org.ogf.schemas.graap.wsAgreement.GuaranteeTermStateType;
47 import org.ogf.schemas.graap.wsAgreement.ServiceTermStateType;
48 import org.ogf.schemas.graap.wsAgreement.TermTreeType;
49 import org.ogf.schemas.graap.wsAgreement.TerminateInputType;
50
51 /**
52 * LocalAgreementClientImpl
53 *
54 * @author Oliver Waeldrich
55 *
56 */
57 public class LocalAgreementClient extends AgreementClientImpl
58 {
59
60 private final Agreement agreement;
61
62 /**
63 * {@inheritDoc}
64 *
65 * @see org.ogf.graap.wsag.api.Agreement#getName()
66 */
67 @Override
68 public String getName()
69 {
70 return agreement.getName();
71 }
72
73 /**
74 * {@inheritDoc}
75 *
76 * @see org.ogf.graap.wsag.api.Agreement#getAgreementId()
77 */
78 @Override
79 public String getAgreementId()
80 {
81 return agreement.getAgreementId();
82 }
83
84 /**
85 * {@inheritDoc}
86 *
87 * @see org.ogf.graap.wsag.api.Agreement#getContext()
88 */
89 @Override
90 public AgreementContextType getContext()
91 {
92 return agreement.getContext();
93 }
94
95 /**
96 * {@inheritDoc}
97 *
98 * @see org.ogf.graap.wsag.api.Agreement#getTerms()
99 */
100 @Override
101 public TermTreeType getTerms()
102 {
103 return agreement.getTerms();
104 }
105
106 /**
107 * {@inheritDoc}
108 *
109 * @see org.ogf.graap.wsag.api.Agreement#terminate(org.ogf.schemas.graap.wsAgreement.TerminateInputType)
110 */
111 @Override
112 public void terminate( TerminateInputType reason )
113 {
114 agreement.terminate( reason );
115 }
116
117 /**
118 * {@inheritDoc}
119 *
120 * @see org.ogf.graap.wsag.api.Agreement#getState()
121 */
122 @Override
123 public AgreementStateType getState()
124 {
125 return agreement.getState();
126 }
127
128 /**
129 * {@inheritDoc}
130 *
131 * @see org.ogf.graap.wsag.api.Agreement#getGuaranteeTermStates()
132 */
133 @Override
134 public GuaranteeTermStateType[] getGuaranteeTermStates()
135 {
136 return agreement.getGuaranteeTermStates();
137 }
138
139 /**
140 * {@inheritDoc}
141 *
142 * @see org.ogf.graap.wsag.api.Agreement#getServiceTermStates()
143 */
144 @Override
145 public ServiceTermStateType[] getServiceTermStates()
146 {
147 return agreement.getServiceTermStates();
148 }
149
150 private final RemoteClient wsclient;
151
152 /**
153 * Creates a new local agreement instance using the given agreement object.
154 *
155 * @param agreement
156 * the agreement instance
157 */
158 public LocalAgreementClient( Agreement agreement )
159 {
160 this.agreement = agreement;
161 wsclient = new RemoteClient( "http://localhost:8080" );
162 }
163
164 /**
165 * {@inheritDoc}
166 */
167 @Override
168 public AgreementClient clone() throws CloneNotSupportedException
169 {
170 return new LocalAgreementClient( agreement );
171 }
172
173 /**
174 * {@inheritDoc}
175 *
176 * @see org.ogf.graap.wsag.client.api.AgreementService#getRemoteClient()
177 */
178 @Override
179 public RemoteClient getRemoteClient()
180 {
181 return wsclient;
182 }
183
184 /**
185 * {@inheritDoc}
186 *
187 * @see org.ogf.graap.wsag.client.api.impl.AgreementClientImpl#destroy()
188 */
189 @Override
190 public void destroy() throws ResourceUnknownException, ResourceUnavailableException
191 {
192 // dummy method, nothing to do
193 }
194
195 /**
196 * {@inheritDoc}
197 *
198 * @see org.ogf.graap.wsag.client.api.AgreementClient#getResourceProperties()
199 */
200 @Override
201 public AgreementPropertiesType getResourceProperties()
202 throws ResourceUnknownException, ResourceUnavailableException
203 {
204 return agreement.getXMLObject();
205 }
206 }