org.wso2.carbon.governance.api.common.dataobjects
Class GovernanceArtifactImpl

java.lang.Object
  extended by org.wso2.carbon.governance.api.common.dataobjects.GovernanceArtifactImpl
All Implemented Interfaces:
GovernanceArtifact
Direct Known Subclasses:
EndpointImpl, GenericArtifactImpl, PolicyImpl, SchemaImpl, ServiceImpl, WsdlImpl

public abstract class GovernanceArtifactImpl
extends Object
implements GovernanceArtifact

Governance Artifact abstract class, This is overwritten by Endpoint, Policy, Schema, Service, WSDL, People classes. This keeps common methods shared by all the governance artifacts


Field Summary
 String artifactPath
           
protected  Map<String,List<String>> attributes
          Map of attributes associated with this governance artifact.
 String lcName
           
 String lcState
           
 
Constructor Summary
  GovernanceArtifactImpl()
          Construct a governance artifact.
protected GovernanceArtifactImpl(GovernanceArtifactImpl artifact)
          Copy constructor used for cloning.
  GovernanceArtifactImpl(String id)
          Construct a governance artifact object from the path and the id.
  GovernanceArtifactImpl(String id, org.apache.axiom.om.OMElement contentElement)
          Constructor accepting resource identifier and the XML content.
 
Method Summary
 void addAttribute(String key, String value)
          Adding an attribute to the artifact.
 void associateRegistry(org.wso2.carbon.registry.core.Registry registry)
          Associate a registry, this is mostly used by the artifact manager when creating the artifact.
protected  void attach(GovernanceArtifact attachedToArtifact)
          Attach the current artifact to an another artifact.
 void attachLifecycle(String name)
          Associates the named lifecycle with the artifact
protected  void checkRegistryResourceAssociation()
          Validate the resource is associated with a registry
static GovernanceArtifactImpl create(org.wso2.carbon.registry.core.Registry registry, String artifactId)
           
static GovernanceArtifactImpl create(org.wso2.carbon.registry.core.Registry registry, String artifactId, org.apache.axiom.om.OMElement content)
           
 void createVersion()
          Create a version of the artifact.
protected  void detach(String artifactId)
          Detach the current artifact from the provided artifact.
 String getArtifactPath()
           
protected  org.wso2.carbon.registry.core.Registry getAssociatedRegistry()
          Returns the associated registry to the artifact.
 String getAttribute(String key)
          Returns the attribute of a given key.
 String[] getAttributeKeys()
          Returns the available attribute keys
 String[] getAttributes(String key)
          Returns the attribute values for a key.
 GovernanceArtifact[] getDependencies()
          Get dependencies of an artifacts.
 GovernanceArtifact[] getDependents()
          Get dependents of an artifact.
 String getId()
          Returns the id of the artifact
 String getLcName()
           
 String getLcState()
           
 String getLifecycleName()
          Returns the name of the lifecycle associated with this artifact.
 String getLifecycleState()
          Returns the state of the lifecycle associated with this artifact.
 String getPath()
          Returns the path of the artifact, need to save the artifact before getting the path.
 void removeAttribute(String key)
          Remove attribute with the given key.
 void setArtifactPath(String artifactPath)
           
 void setAttribute(String key, String newValue)
          Set/Update an attribute with a single value.
 void setAttributes(String key, String[] newValues)
          Set/Update an attribute with multiple values.
 void setId(String id)
          Set the id
 void setLcName(String lcName)
           
 void setLcState(String lcState)
           
 void updatePath()
          update the path after moving the resource.
 void updatePath(String artifactId)
          update the path after moving the resource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.wso2.carbon.governance.api.common.dataobjects.GovernanceArtifact
getQName
 

Field Detail

lcName

public String lcName

lcState

public String lcState

artifactPath

public String artifactPath

attributes

protected Map<String,List<String>> attributes
Map of attributes associated with this governance artifact.

Constructor Detail

GovernanceArtifactImpl

public GovernanceArtifactImpl(String id)
Construct a governance artifact object from the path and the id.

Parameters:
id - the id

GovernanceArtifactImpl

public GovernanceArtifactImpl()
Construct a governance artifact. The default constructor.


GovernanceArtifactImpl

protected GovernanceArtifactImpl(GovernanceArtifactImpl artifact)
Copy constructor used for cloning.

Parameters:
artifact - the object to be copied.

GovernanceArtifactImpl

public GovernanceArtifactImpl(String id,
                              org.apache.axiom.om.OMElement contentElement)
                       throws GovernanceException
Constructor accepting resource identifier and the XML content.

Parameters:
id - the resource identifier.
contentElement - an XML element containing the content.
Throws:
GovernanceException - if the construction fails.
Method Detail

getLcName

public String getLcName()

setLcName

public void setLcName(String lcName)

getLcState

public String getLcState()

setLcState

public void setLcState(String lcState)

getArtifactPath

public String getArtifactPath()

setArtifactPath

public void setArtifactPath(String artifactPath)

create

public static GovernanceArtifactImpl create(org.wso2.carbon.registry.core.Registry registry,
                                            String artifactId)
                                     throws GovernanceException
Throws:
GovernanceException

create

public static GovernanceArtifactImpl create(org.wso2.carbon.registry.core.Registry registry,
                                            String artifactId,
                                            org.apache.axiom.om.OMElement content)
                                     throws GovernanceException
Throws:
GovernanceException

getId

public String getId()
Returns the id of the artifact

Specified by:
getId in interface GovernanceArtifact
Returns:
the id

setId

public void setId(String id)
Set the id

Specified by:
setId in interface GovernanceArtifact
Parameters:
id - the id

getPath

public String getPath()
               throws GovernanceException
Returns the path of the artifact, need to save the artifact before getting the path.

Specified by:
getPath in interface GovernanceArtifact
Returns:
here we return the path of the artifact.
Throws:
GovernanceException - if an error occurred.

getLifecycleName

public String getLifecycleName()
                        throws GovernanceException
Returns the name of the lifecycle associated with this artifact.

Specified by:
getLifecycleName in interface GovernanceArtifact
Returns:
the name of the lifecycle associated with this artifact.
Throws:
GovernanceException - if an error occurred.

attachLifecycle

public void attachLifecycle(String name)
                     throws GovernanceException
Associates the named lifecycle with the artifact

Specified by:
attachLifecycle in interface GovernanceArtifact
Parameters:
name - the name of the lifecycle to be associated with this artifact.
Throws:
GovernanceException - if an error occurred.

getLifecycleState

public String getLifecycleState()
                         throws GovernanceException
Returns the state of the lifecycle associated with this artifact.

Specified by:
getLifecycleState in interface GovernanceArtifact
Returns:
the state of the lifecycle associated with this artifact.
Throws:
GovernanceException - if an error occurred.

updatePath

public void updatePath()
                throws GovernanceException
update the path after moving the resource.

Throws:
GovernanceException - if an error occurred.

updatePath

public void updatePath(String artifactId)
                throws GovernanceException
update the path after moving the resource.

Parameters:
artifactId -
Throws:
GovernanceException - if an error occurred.

createVersion

public void createVersion()
                   throws GovernanceException
Create a version of the artifact.

Throws:
GovernanceException - throws if the operation failed.

associateRegistry

public void associateRegistry(org.wso2.carbon.registry.core.Registry registry)
                       throws GovernanceException
Associate a registry, this is mostly used by the artifact manager when creating the artifact.

Parameters:
registry - the registry.
Throws:
GovernanceException - throws if the operation failed.

addAttribute

public void addAttribute(String key,
                         String value)
                  throws GovernanceException
Adding an attribute to the artifact. The artifact should be saved to get effect the change. In the case of a single-valued attribute, this method will set or replace the existing attribute with the provided value. In the case of a multi-valued attribute, this method will append the provided value to the existing list.

Specified by:
addAttribute in interface GovernanceArtifact
Parameters:
key - the key.
value - the value.
Throws:
GovernanceException - throws if the operation failed.

setAttributes

public void setAttributes(String key,
                          String[] newValues)
                   throws GovernanceException
Set/Update an attribute with multiple values. The artifact should be saved to get effect the change.

Specified by:
setAttributes in interface GovernanceArtifact
Parameters:
key - the key
newValues - the value
Throws:
GovernanceException - throws if the operation failed.

setAttribute

public void setAttribute(String key,
                         String newValue)
                  throws GovernanceException
Set/Update an attribute with a single value. The artifact should be saved to get effect the change. This method will replace the existing attribute with the provided value. In the case of a multi-valued attribute this will remove all existing values. If you want to append the provided value to a list values of a multi-valued attribute, use the addAttribute method instead.

Specified by:
setAttribute in interface GovernanceArtifact
Parameters:
key - the key
newValue - the value
Throws:
GovernanceException - throws if the operation failed.

getAttribute

public String getAttribute(String key)
                    throws GovernanceException
Returns the attribute of a given key.

Specified by:
getAttribute in interface GovernanceArtifact
Parameters:
key - the key
Returns:
the value of the attribute, if there are more than one attribute for the key this returns the first value.
Throws:
GovernanceException - throws if the operation failed.

getAttributeKeys

public String[] getAttributeKeys()
                          throws GovernanceException
Returns the available attribute keys

Specified by:
getAttributeKeys in interface GovernanceArtifact
Returns:
an array of attribute keys.
Throws:
GovernanceException - throws if the operation failed.

getAttributes

public String[] getAttributes(String key)
                       throws GovernanceException
Returns the attribute values for a key.

Specified by:
getAttributes in interface GovernanceArtifact
Parameters:
key - the key.
Returns:
attribute values for the key.
Throws:
GovernanceException - throws if the operation failed.

removeAttribute

public void removeAttribute(String key)
                     throws GovernanceException
Remove attribute with the given key. The artifact should be saved to get effect the change.

Specified by:
removeAttribute in interface GovernanceArtifact
Parameters:
key - the key
Throws:
GovernanceException - throws if the operation failed.

getDependencies

public GovernanceArtifact[] getDependencies()
                                     throws GovernanceException
Get dependencies of an artifacts. The artifacts should be saved, before calling this method.

Specified by:
getDependencies in interface GovernanceArtifact
Returns:
an array of dependencies of this artifact.
Throws:
GovernanceException - throws if the operation failed.

getDependents

public GovernanceArtifact[] getDependents()
                                   throws GovernanceException
Get dependents of an artifact. The artifacts should be saved, before calling this method.

Specified by:
getDependents in interface GovernanceArtifact
Returns:
an array of artifacts that is dependent on this artifact.
Throws:
GovernanceException - throws if the operation failed.

attach

protected void attach(GovernanceArtifact attachedToArtifact)
               throws GovernanceException
Attach the current artifact to an another artifact. Both the artifacts should be saved, before calling this method. This method will two generic artifact types. There are specific methods

Parameters:
attachedToArtifact - the artifact the current artifact is attached to
Throws:
GovernanceException - throws if the operation failed.

detach

protected void detach(String artifactId)
               throws GovernanceException
Detach the current artifact from the provided artifact. Both the artifacts should be saved, before calling this method.

Parameters:
artifactId - the artifact id of the attached artifact
Throws:
GovernanceException - throws if the operation failed.

checkRegistryResourceAssociation

protected void checkRegistryResourceAssociation()
                                         throws GovernanceException
Validate the resource is associated with a registry

Throws:
GovernanceException - if the resource is not associated with a registry.

getAssociatedRegistry

protected org.wso2.carbon.registry.core.Registry getAssociatedRegistry()
Returns the associated registry to the artifact.

Returns:
the associated registry


Copyright © 2012 WSO2 Inc. All Rights Reserved.