org.ogf.graap.wsag.client.rest.RestNegotiationClient Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of wsag4j-rest-client Show documentation
Show all versions of wsag4j-rest-client Show documentation
Implementation of the RESTFUL WS-Agreement client-side components.
This module includes the required classes of the WSAG framework
to access WSAG services.
The newest version!
/*
* Copyright (c) 2007, Fraunhofer-Gesellschaft
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* (1) Redistributions of source code must retain the above copyright
* notice, this list of conditions and the disclaimer at the end.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* (2) Neither the name of Fraunhofer nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* DISCLAIMER
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package org.ogf.graap.wsag.client.rest;
import java.util.Properties;
import org.ogf.graap.wsag.api.exceptions.NegotiationException;
import org.ogf.graap.wsag.api.exceptions.ResourceUnavailableException;
import org.ogf.graap.wsag.api.exceptions.ResourceUnknownException;
import org.ogf.graap.wsag.api.rest.RestNegotiation;
import org.ogf.graap.wsag.api.security.ISecurityProperties;
import org.ogf.graap.wsag.client.api.NegotiationClient;
import org.ogf.graap.wsag.client.api.impl.NegotiationClientImpl;
import org.ogf.schemas.graap.wsAgreement.AgreementTemplateType;
import org.ogf.schemas.graap.wsAgreement.negotiation.AdvertiseInputDocument;
import org.ogf.schemas.graap.wsAgreement.negotiation.NegotiateInputDocument;
import org.ogf.schemas.graap.wsAgreement.negotiation.NegotiateOutputDocument;
import org.ogf.schemas.graap.wsAgreement.negotiation.NegotiationContextType;
import org.ogf.schemas.graap.wsAgreement.negotiation.NegotiationOfferType;
import org.ogf.schemas.graap.wsAgreement.negotiation.NegotiationPropertiesType;
import org.ogf.schemas.graap.wsAgreement.negotiation.TerminateInputDocument;
import org.w3.x2005.x08.addressing.EndpointReferenceType;
/**
* Default implementation of an agreement negotiation client.
*
* @author hrasheed
*
*/
public class RestNegotiationClient extends NegotiationClientImpl
{
private final RestRemoteClient client;
/**
* Instantiates a negotiation client for the given EPR.
*
* @param epr
* the negotiation endpoint reference
* @param properties
* the client properties
* @param securityProperties
* the security properties to use
*/
public RestNegotiationClient( EndpointReferenceType epr, Properties properties,
ISecurityProperties securityProperties )
{
client = RestRemoteClient.getInstance( epr, properties, securityProperties, RestNegotiation.class );
}
/**
* {@inheritDoc}
*/
@Override
public RestRemoteClient getRemoteClient()
{
return client;
}
/**
* {@inheritDoc}
*/
@Override
public NegotiationClient clone() throws CloneNotSupportedException
{
return new RestNegotiationClient( getRemoteReference(), getProperties(), getSecurityProperties() );
}
/**
* Returns the RESTful negotiation client
*
* @return the negotiation client
*/
public RestNegotiation getNegotiationClient()
{
return client.getApplicationClient();
}
/*
* (non-Javadoc)
*
* @see org.ogf.graap.wsag.client.api.impl.NegotiationClientImpl#getNegotiationContext()
*/
@Override
public NegotiationContextType getNegotiationContext()
throws ResourceUnknownException, ResourceUnavailableException
{
NegotiationPropertiesType properties =
getNegotiationClient().getNegotiationContext().getNegotiationProperties();
return properties.getNegotiationContext();
}
/*
* (non-Javadoc)
*
* @see org.ogf.graap.wsag.client.api.impl.NegotiationClientImpl#getNegotiableTemplates()
*/
@Override
public AgreementTemplateType[] getNegotiableTemplates()
throws ResourceUnknownException, ResourceUnavailableException
{
NegotiationPropertiesType properties =
getNegotiationClient().getNegotiableTemplates().getNegotiationProperties();
return properties.getNegotiableTemplateArray();
}
/*
* (non-Javadoc)
*
* @see org.ogf.graap.wsag.client.api.impl.NegotiationClientImpl#getNegotiationOffers()
*/
@Override
public NegotiationOfferType[] getNegotiationOffers()
throws ResourceUnknownException, ResourceUnavailableException
{
NegotiationPropertiesType properties =
getNegotiationClient().getNegotiationOffers().getNegotiationProperties();
return properties.getNegotiationOfferArray();
}
/*
* (non-Javadoc)
*
* @see
* org.ogf.graap.wsag.client.api.impl.NegotiationClientImpl#negotiate(org.ogf.schemas.graap.wsAgreement
* .negotiation.NegotiationOfferType[])
*/
@Override
public NegotiationOfferType[] negotiate( NegotiationOfferType[] offers )
throws NegotiationException, ResourceUnknownException, ResourceUnavailableException
{
NegotiateInputDocument input = NegotiateInputDocument.Factory.newInstance();
input.addNewNegotiateInput().setNegotiationOfferArray( offers );
NegotiateOutputDocument output = getNegotiationClient().negotiate( input );
return output.getNegotiateOutput().getNegotiationCounterOfferArray();
}
/*
* (non-Javadoc)
*
* @see
* org.ogf.graap.wsag.client.api.impl.NegotiationClientImpl#advertise(org.ogf.schemas.graap.wsAgreement
* .negotiation.NegotiationOfferType[])
*/
@Override
public void advertise( NegotiationOfferType[] quotes )
throws NegotiationException, ResourceUnknownException, ResourceUnavailableException
{
AdvertiseInputDocument input = AdvertiseInputDocument.Factory.newInstance();
input.addNewAdvertiseInput().setNegotiationOfferArray( quotes );
getNegotiationClient().advertise( input );
}
/*
* (non-Javadoc)
*
* @see org.ogf.graap.wsag.client.api.impl.NegotiationClientImpl#terminate()
*/
@Override
public void terminate() throws ResourceUnknownException, ResourceUnavailableException
{
TerminateInputDocument input = TerminateInputDocument.Factory.newInstance();
input.addNewTerminateInput();
getNegotiationClient().terminate( input );
}
/*
* (non-Javadoc)
*
* @see org.ogf.graap.wsag.client.api.impl.NegotiationClientImpl#destroy()
*/
@Override
public void destroy() throws ResourceUnknownException, ResourceUnavailableException
{
getNegotiationClient().destroy();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy