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, Policy, Schema, Service, Wsdl

public abstract class GovernanceArtifact
extends Object

Governance Artifact abstract class, This is overwritten by Endpoint, Policy, Schema, Service, WSDL 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.
GovernanceArtifact(String path, String id)
          Construct a governance artifact object from the path and the id.
 
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.
protected  void checkRegistryResourceAssociation()
          Validate the resource is associated with a registry
 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 getPath()
          Returns 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 setPath(String path)
          Set the paths
 
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 path,
                          String id)
Construct a governance artifact object from the path and the id.

Parameters:
path - the path
id - the id

GovernanceArtifact

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

Method Detail

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()
Returns the path.

Returns:
the path.

setPath

public void setPath(String path)
Set the paths

Parameters:
path - the path

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.

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.

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:
the array of depending artifacts.
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:
the array of dependents.
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 © 2010 WSO2 Inc. All Rights Reserved.