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

java.lang.Object
  extended by org.wso2.carbon.governance.api.common.dataobjects.GovernanceArtifact
Direct Known Subclasses:
Endpoint, GenericArtifact, Policy, Schema, Service, Wsdl

public abstract class GovernanceArtifact
extends Object

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
protected  Map<String,List<String>> attributes
          Map of attributes associated with this governance artifact.
 
Constructor Summary
  GovernanceArtifact()
          Construct a governance artifact.
protected GovernanceArtifact(GovernanceArtifact artifact)
          Copy constructor used for cloning.
  GovernanceArtifact(String id)
          Construct a governance artifact object from the path and the id.
  GovernanceArtifact(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 GovernanceArtifact create(org.wso2.carbon.registry.core.Registry registry, String artifactId)
           
static GovernanceArtifact 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.
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 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.
abstract  QName getQName()
          Returns the QName of the artifact.
 void removeAttribute(String key)
          Remove attribute with the given key.
 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 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
 

Field Detail

attributes

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

Constructor Detail

GovernanceArtifact

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

Parameters:
id - the id

GovernanceArtifact

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


GovernanceArtifact

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

Parameters:
artifact - the object to be copied.

GovernanceArtifact

public GovernanceArtifact(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

create

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

create

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

getQName

public abstract QName getQName()
Returns the QName of the artifact.

Returns:
the QName of the artifact

getId

public String getId()
Returns the id of the artifact

Returns:
the id

setId

public void setId(String id)
Set the id

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.

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.

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

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.

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.

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.

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.

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.

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

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.

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.

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.

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.

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.