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 org.apache.xmlbeans.XmlObject;
38  import org.ogf.graap.wsag.api.Negotiation;
39  import org.ogf.graap.wsag.api.client.NegotiationService;
40  import org.ogf.graap.wsag.api.exceptions.NegotiationException;
41  import org.ogf.graap.wsag.api.exceptions.ResourceUnavailableException;
42  import org.ogf.graap.wsag.api.exceptions.ResourceUnknownException;
43  import org.ogf.schemas.graap.wsAgreement.AgreementTemplateType;
44  import org.ogf.schemas.graap.wsAgreement.negotiation.NegotiationContextType;
45  import org.ogf.schemas.graap.wsAgreement.negotiation.NegotiationOfferType;
46  
47  /**
48   * Default implementation of a negotiation service client for local access to a negotiation service instance.
49   * Internal use only.
50   * 
51   * @author hrasheed
52   * 
53   */
54  public class LocalNegotiationServiceImpl extends LocalWsClient implements NegotiationService
55  {
56  
57      private Negotiation negotiation;;
58  
59      /**
60       * 
61       * @param negotiation
62       *            the negotiation service
63       */
64      public LocalNegotiationServiceImpl( Negotiation negotiation )
65      {
66          this.negotiation = negotiation;
67      }
68  
69      /**
70       * {@inheritDoc}
71       */
72      public NegotiationContextType getNegotiationContext()
73          throws ResourceUnknownException, ResourceUnavailableException
74      {
75          return negotiation.getNegotiationContext();
76      }
77  
78      /**
79       * {@inheritDoc}
80       */
81      public AgreementTemplateType[] getNegotiableTemplates()
82          throws ResourceUnknownException, ResourceUnavailableException
83      {
84          return negotiation.getNegotiableTemplates();
85      }
86  
87      /**
88       * {@inheritDoc}
89       */
90      public NegotiationOfferType[] getNegotiationOffers()
91          throws ResourceUnknownException, ResourceUnavailableException
92      {
93          return negotiation.getNegotiationOffers();
94      }
95  
96      /**
97       * {@inheritDoc}
98       */
99      public NegotiationOfferType[] negotiate( NegotiationOfferType[] quotes )
100         throws NegotiationException, ResourceUnknownException, ResourceUnavailableException
101     {
102         XmlObject[] nocriticalExtensions = new XmlObject[0];
103         return negotiation.negotiate( quotes, nocriticalExtensions );
104     }
105 
106     /**
107      * {@inheritDoc}
108      */
109     public void advertise( NegotiationOfferType[] quotes )
110         throws NegotiationException, ResourceUnknownException, ResourceUnavailableException
111     {
112         XmlObject[] nocriticalExtensions = new XmlObject[0];
113         negotiation.advertise( quotes, nocriticalExtensions );
114     }
115 
116     /**
117      * {@inheritDoc}
118      */
119     public void terminate() throws ResourceUnavailableException, ResourceUnknownException
120     {
121         negotiation.terminate();
122     }
123 
124     /**
125      * {@inheritDoc}
126      */
127     public void destroy() throws ResourceUnavailableException, ResourceUnknownException
128     {
129         // do nothing
130     }
131 
132 }