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.local;
36  
37  import java.util.Properties;
38  
39  import org.ogf.graap.wsag.api.Agreement;
40  import org.ogf.graap.wsag.api.AgreementFactory;
41  import org.ogf.graap.wsag.api.AgreementOffer;
42  import org.ogf.graap.wsag.api.client.AgreementClient;
43  import org.ogf.graap.wsag.api.client.AgreementFactoryClient;
44  import org.ogf.graap.wsag.api.client.NegotiationClient;
45  import org.ogf.graap.wsag.api.client.WsClient;
46  import org.ogf.graap.wsag.api.exceptions.AgreementFactoryException;
47  import org.ogf.graap.wsag.api.exceptions.NegotiationFactoryException;
48  import org.ogf.graap.wsag.api.exceptions.ResourceUnavailableException;
49  import org.ogf.graap.wsag.api.exceptions.ResourceUnknownException;
50  import org.ogf.graap.wsag.api.security.ISecurityProperties;
51  import org.ogf.graap.wsag.api.security.SecurityProperties;
52  import org.ogf.graap.wsag.client.impl.AgreementFactoryFacade;
53  import org.ogf.schemas.graap.wsAgreement.AgreementTemplateType;
54  import org.ogf.schemas.graap.wsAgreement.negotiation.NegotiationContextType;
55  import org.w3.x2005.x08.addressing.EndpointReferenceType;
56  
57  /**
58   * An implementation of the Client API for local invocation of an agreement factory.
59   * 
60   * @author Oliver Waeldrich
61   * 
62   */
63  public class LocalAgreementFactoryClientImpl
64      implements AgreementFactoryClient
65  {
66  
67      private final Agreement[] agreements = new Agreement[0];
68  
69      private final AgreementFactory factory;
70  
71      private final AgreementFactoryFacade facade;
72  
73      /**
74       * Creates a client for local invocation of an agreement factory.
75       * 
76       * @param factory
77       *            the factory object
78       */
79      public LocalAgreementFactoryClientImpl( AgreementFactory factory )
80      {
81          this.factory = factory;
82          this.facade =
83              new AgreementFactoryFacade( new LocalAgreementFactoryServiceImpl( factory ),
84                  new LocalAgreementFactoryRegistryImpl( agreements ), new SecurityProperties( null ) );
85      }
86  
87      /**
88       * {@inheritDoc}
89       */
90      @Override
91      public AgreementFactoryClient clone() throws CloneNotSupportedException
92      {
93          return new LocalAgreementFactoryClientImpl( factory );
94      }
95  
96      /**
97       * {@inheritDoc}
98       * 
99       * @see org.ogf.graap.wsag.api.client.AgreementFactoryClient#getWebServiceClient()
100      */
101     public WsClient getWebServiceClient()
102     {
103         return facade.getWebServiceClient();
104     }
105 
106     /**
107      * {@inheritDoc}
108      */
109     public AgreementClient createAgreement( AgreementOffer offer )
110         throws AgreementFactoryException, ResourceUnknownException, ResourceUnavailableException
111     {
112         return facade.createAgreement( offer );
113     }
114 
115     /**
116      * {@inheritDoc}
117      */
118     public AgreementClient createPendingAgreement( AgreementOffer offer )
119         throws AgreementFactoryException, ResourceUnknownException, ResourceUnavailableException
120     {
121         return facade.createPendingAgreement( offer );
122     }
123 
124     /**
125      * {@inheritDoc}
126      */
127     public AgreementClient createPendingAgreement( AgreementOffer offer, EndpointReferenceType acceptanceEPR )
128         throws AgreementFactoryException, ResourceUnknownException, ResourceUnavailableException
129     {
130         return facade.createPendingAgreement( offer, acceptanceEPR );
131     }
132 
133     /**
134      * {@inheritDoc}
135      */
136     public NegotiationClient initiateNegotiation( NegotiationContextType context )
137         throws NegotiationFactoryException, ResourceUnknownException, ResourceUnavailableException
138     {
139         return facade.initiateNegotiation( context );
140     }
141 
142     /**
143      * {@inheritDoc}
144      */
145     public EndpointReferenceType getEndpoint()
146     {
147         return facade.getEndpoint();
148     }
149 
150     /**
151      * {@inheritDoc}
152      */
153     public Properties getProperties()
154     {
155         return facade.getProperties();
156     }
157 
158     /**
159      * {@inheritDoc}
160      */
161     public String getResourceId() throws ResourceUnknownException, ResourceUnavailableException
162     {
163         return facade.getResourceId();
164     }
165 
166     /**
167      * {@inheritDoc}
168      */
169     public ISecurityProperties getSecurityProperties()
170     {
171         return facade.getSecurityProperties();
172     }
173 
174     /**
175      * {@inheritDoc}
176      */
177     public AgreementTemplateType getTemplate( String name, String id )
178         throws ResourceUnknownException, ResourceUnavailableException
179     {
180         return facade.getTemplate( name, id );
181     }
182 
183     /**
184      * {@inheritDoc}
185      */
186     public AgreementTemplateType[] getTemplates()
187         throws ResourceUnknownException, ResourceUnavailableException
188     {
189         return facade.getTemplates();
190     }
191 
192     /**
193      * {@inheritDoc}
194      */
195     public boolean isUsingTrace()
196     {
197         return facade.isUsingTrace();
198     }
199 
200     /**
201      * {@inheritDoc}
202      */
203     public AgreementClient[] listAgreements() throws ResourceUnknownException, ResourceUnavailableException
204     {
205         return facade.listAgreements();
206     }
207 
208     /**
209      * {@inheritDoc}
210      */
211     public void setProperties( Properties properties )
212     {
213         facade.setProperties( properties );
214     }
215 
216     /**
217      * {@inheritDoc}
218      */
219     public void setTrace( boolean trace )
220     {
221         facade.setTrace( trace );
222     }
223 
224 }