org.ogf.graap.wsag.wsrf.persistence
Class WsDatabaseAgreementFactory

java.lang.Object
  extended by org.ogf.graap.wsag.wsrf.persistence.WsDatabaseAgreementFactory
All Implemented Interfaces:
AgreementFactory, IAgreementHome, PersistentAgreementFactory, WsPersistentAgreementFactory

public class WsDatabaseAgreementFactory
extends Object
implements WsPersistentAgreementFactory

The WsDatabaseAgreementFactory encapsulates a PersistentAgreementFactory and additionally stores the endpoint reference of the persistent factory. Calls to this factory are delegated to the PersistentAgreementFactory.

Author:
thomasw, owaeld

Field Summary
static String FACTORY_EPR
           
 
Constructor Summary
WsDatabaseAgreementFactory(PersistentAgreementFactory factory, EndpointReferenceType epr)
          Creates a persistent WS agreement factory for a given EPR and implementation.
 
Method Summary
 void addAgreement(Agreement agreement, EndpointReferenceType epr)
          Deprecated.  
 Agreement createAgreement(AgreementOffer offer, Map<String,Object> context)
          Creates a new agreement based on an offer.
 Agreement createPendingAgreement(AgreementOffer offer, PendingAgreementListener listener, Map<String,Object> context)
          Creates a new pending agreement based on an offer.
 WsDatabasePersistentAgreement find(String epr)
          Tries to find an agreement for a specified EPR.
 WsDatabasePersistentAgreement findByAgreementId(String agreementId)
          Tries to find a agreement for a specified agreement ID.
 WsDatabasePersistentAgreement findByEprAddress(String eprAddress)
          Tries to find a agreement for a specified EPR address of an agreement.
 AgreementFactory getAgreementFactory()
          Deprecated.  
 EndpointReferenceType getAgreementFactoryEPR()
          use the resource id at the WSRF layer to construct the EPR
 AgreementFactoryContext getFactoryContext()
          Returns the factory context.
 String getResourceId()
          
 AgreementTemplateType[] getTemplates()
          
 Negotiation initiateNegotiation(NegotiationContextType context, org.apache.xmlbeans.XmlObject[] criticalExtensions, org.apache.xmlbeans.XmlObject[] nonCriticalExtensions, Map<String,Object> environment)
          Initializes a new negotiation instance.
 WsDatabasePersistentAgreement[] list()
          Creates a list of all webservice-based versions of agreements for one specific agreement factory.
 PersistentAgreement[] list(String agreementFactoryId)
          Lists all agreements for one specific agreement factory.
 void load()
          loads the factory instance
 void remove(String epr)
          Removes the factory identified by the given EPR.
 void save()
          saves the factory instance
 void setFactoryContext(AgreementFactoryContext context)
          Sets the factory context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FACTORY_EPR

public static final String FACTORY_EPR
See Also:
Constant Field Values
Constructor Detail

WsDatabaseAgreementFactory

public WsDatabaseAgreementFactory(PersistentAgreementFactory factory,
                                  EndpointReferenceType epr)
Creates a persistent WS agreement factory for a given EPR and implementation.

Parameters:
factory - the persistent factory where calls are delegated to
epr - the endpoint reference of the persistent factory
Method Detail

getResourceId

public String getResourceId()

Specified by:
getResourceId in interface PersistentAgreementFactory
Returns:
unique factory id
See Also:
PersistentAgreementFactory.getResourceId()

getAgreementFactory

@Deprecated
public AgreementFactory getAgreementFactory()
Deprecated. 

Specified by:
getAgreementFactory in interface PersistentAgreementFactory
Returns:
the concrete implementation of the persisted factory
See Also:
PersistentAgreementFactory.getAgreementFactory()

load

public void load()
          throws Exception
loads the factory instance

Specified by:
load in interface PersistentAgreementFactory
Throws:
Exception - indicates an exception while loading the agreement factory from the database
See Also:
PersistentAgreementFactory.load()

save

public void save()
          throws Exception
saves the factory instance

Specified by:
save in interface PersistentAgreementFactory
Throws:
Exception - indicates an exception while saving the agreement to the database
See Also:
PersistentAgreementFactory.save()

addAgreement

@Deprecated
public void addAgreement(Agreement agreement,
                                    EndpointReferenceType epr)
Deprecated. 

Persists a new created agreement instance

Specified by:
addAgreement in interface PersistentAgreementFactory
Parameters:
agreement - the agreement instance to add
epr - the external reference for this agreement
See Also:
PersistentAgreementFactory.addAgreement(org.ogf.graap.wsag.api.Agreement, org.w3.x2005.x08.addressing.EndpointReferenceType)

getTemplates

public AgreementTemplateType[] getTemplates()

Specified by:
getTemplates in interface AgreementFactory
Returns:
the agreement templates exposed by this factory
See Also:
AgreementFactory.getTemplates()

createAgreement

public Agreement createAgreement(AgreementOffer offer,
                                 Map<String,Object> context)
                          throws AgreementFactoryException
Creates a new agreement based on an offer.

Specified by:
createAgreement in interface AgreementFactory
Parameters:
offer - agreement offer
context - invocation context
Returns:
the created agreement instance
Throws:
AgreementFactoryException - Indicates that the agreement offer was rejected or another fault occurred.
See Also:
org.ogf.graap.wsag.api.AgreementFactory#createAgreement(org.ogf.graap.wsag.api.AgreementOffer)

createPendingAgreement

public Agreement createPendingAgreement(AgreementOffer offer,
                                        PendingAgreementListener listener,
                                        Map<String,Object> context)
                                 throws AgreementFactoryException
Creates a new pending agreement based on an offer.

Specified by:
createPendingAgreement in interface AgreementFactory
Parameters:
offer - agreement offer
listener - the listener, when provided, receives the agreement acceptance events once the creation process is finished
context - invocation context
Returns:
the created agreement instance
Throws:
AgreementFactoryException - Indicates that the agreement offer was rejected or another fault occurred.
See Also:
org.ogf.graap.wsag.api.AgreementFactory#createPendingAgreement(org.ogf.graap.wsag.api.AgreementOffer)

initiateNegotiation

public Negotiation initiateNegotiation(NegotiationContextType context,
                                       org.apache.xmlbeans.XmlObject[] criticalExtensions,
                                       org.apache.xmlbeans.XmlObject[] nonCriticalExtensions,
                                       Map<String,Object> environment)
                                throws NegotiationFactoryException
Initializes a new negotiation instance. This method creates a new negotiation instance based on the provided negotiation context, taking into account the critical and non-critical extensions.

Specified by:
initiateNegotiation in interface AgreementFactory
Parameters:
context - The negotiation context defines the roles and obligations of the negotiating parties. Furthermore, it defines the nature of the negotiation process (e.g. negotiation or re-negotiation).
criticalExtensions - Critical extensions must be supported during the negotiation process. If a critical extension is not understood or supported by the negotiation factory, it must throw an @see NegotiationFactoryException.
nonCriticalExtensions - Non-critical extensions should be supported during the negotiation process. If a non-critical extension is not understood or supported by the negotiation factory, it can be ignored. Alternatively, an @see NegotiationFactoryException could be thrown.
environment - Provides access to additional variables provided by the calling instance. These environment variables are domain specific.
Returns:
the new initiated negotiation instance
Throws:
NegotiationFactoryException - indicates that an error occurred while instantiating the negotiation process
See Also:
AgreementFactory.initiateNegotiation(NegotiationContextType, XmlObject[], XmlObject[], Map)

find

public WsDatabasePersistentAgreement find(String epr)
                                   throws PersistedResourceException
Tries to find an agreement for a specified EPR. An agreement can be found, if a corresponding AgreementEprContainer instance exists.

Specified by:
find in interface IAgreementHome
Parameters:
epr - EPR of the agreement.
Returns:
Webservice-version of the persisted agreement.
Throws:
PersistedResourceException - indicates an exception while loading the agreement from the database

findByEprAddress

public WsDatabasePersistentAgreement findByEprAddress(String eprAddress)
                                               throws Exception
Tries to find a agreement for a specified EPR address of an agreement. An agreement can be found, if a corresponding AgreementEprContainer instance exists.

Parameters:
eprAddress - Address of the EPR of the agreement.
Returns:
Webservice-version of the persisted agreement.
Throws:
Exception - failed to lookup the EPR

list

public WsDatabasePersistentAgreement[] list()
Creates a list of all webservice-based versions of agreements for one specific agreement factory.

Specified by:
list in interface IAgreementHome
Specified by:
list in interface WsPersistentAgreementFactory
Returns:
a list of webservice-based versions of the agreements for the requested agreement factory.

findByAgreementId

public WsDatabasePersistentAgreement findByAgreementId(String agreementId)
                                                throws Exception
Tries to find a agreement for a specified agreement ID. An agreement can be found, if a corresponding AgreementEprContainer instance exists.

Parameters:
agreementId - ID of the requested agreement.
Returns:
a webservice-version of the persisted agreement.
Throws:
Exception - failed to look up the specified agreement, i.e. a database error occurred

list

public PersistentAgreement[] list(String agreementFactoryId)
                           throws Exception
Lists all agreements for one specific agreement factory.

Specified by:
list in interface IAgreementHome
Parameters:
agreementFactoryId - the id of the factory for which the agreements should be listed
Returns:
a list of all agreements for a specified agreement factory
Throws:
Exception - indicates an exception while loading the agreements from the database
See Also:
IAgreementHome.list(java.lang.String)

remove

public void remove(String epr)
            throws PersistedResourceException
Removes the factory identified by the given EPR.

Specified by:
remove in interface IAgreementHome
Parameters:
epr - the EPR that identifies the factory resource
Throws:
PersistedResourceException - the specified resource was not removed, i.e. it was not found

getAgreementFactoryEPR

public EndpointReferenceType getAgreementFactoryEPR()
use the resource id at the WSRF layer to construct the EPR

Specified by:
getAgreementFactoryEPR in interface WsPersistentAgreementFactory
Returns:
the factory EPR
See Also:
WsPersistentAgreementFactory.getAgreementFactoryEPR()

getFactoryContext

public AgreementFactoryContext getFactoryContext()
Description copied from interface: AgreementFactory
Returns the factory context.

Specified by:
getFactoryContext in interface AgreementFactory
Returns:
See Also:
AgreementFactory.getFactoryContext()

setFactoryContext

public void setFactoryContext(AgreementFactoryContext context)
Description copied from interface: AgreementFactory
Sets the factory context.

Specified by:
setFactoryContext in interface AgreementFactory
Parameters:
context -
See Also:
AgreementFactory.setFactoryContext(org.ogf.graap.wsag.api.AgreementFactoryContext)


Copyright © 2008-2012. All Rights Reserved.