org.wso2.carbon.governance.api.generic

## Class GenericArtifactManager

- java.lang.Object
- - org.wso2.carbon.governance.api.generic.GenericArtifactManager

-     public class GenericArtifactManager
      extends Object

  Manager class for a generic governance artifact.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `GenericArtifactManager(org.wso2.carbon.registry.core.Registry registry, String key)` Constructor accepting an instance of the registry, and key identifying the type of manager.
    `GenericArtifactManager(org.wso2.carbon.registry.core.Registry registry, String mediaType, String artifactNameAttribute, String artifactNamespaceAttribute, String artifactElementRoot, String artifactElementNamespace, String pathExpression, org.wso2.carbon.registry.core.Association[] relationshipDefinitions)` Constructor accepting an instance of the registry, and also details on the type of manager.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addGenericArtifact(GenericArtifact artifact)` Adds the given artifact to the registry.
    `GenericArtifact[]` | `findGenericArtifacts(GenericArtifactFilter criteria)` Finds all artifacts matching the given filter criteria.
    `GenericArtifact[]` | `findGenericArtifacts(Map<String,List<String>> criteria)` Finds all artifacts matching the given filter criteria.
    `GenericArtifact[]` | `findGovernanceArtifacts(String query)` Finds and returns GenericArtifact instances matching the search query
    `String[]` | `getAllGenericArtifactIds()` Finds all identifiers of the artifacts on the registry.
    `GenericArtifact[]` | `getAllGenericArtifacts()` Finds all artifacts on the registry.
    `GenericArtifact[]` | `getAllGenericArtifactsByLifecycle(String lcName)` Retrieve all the generic artifacts which associated with the given lifecycle
    `GenericArtifact[]` | `getAllGenericArtifactsByLifecycleStatus(String lcName, String lcState)` Retrieve all the generic artifacts which associated with the given lifecycle in the given lifecycle state
    `GenericArtifact` | `getGenericArtifact(String artifactId)` Fetches the given artifact on the registry.
    `org.wso2.carbon.registry.common.TermData[]` | `getTermData(Map<String,List<String>> criteria, String facetField, boolean authRequired)` Find all possible terms and its count for the given facet field and query criteria
    `boolean` | `isExists(GovernanceArtifact artifact)` Check whether GovernanceArtifact is exists in the Registry without loading whole artifact into memory.
    `static GenericArtifact` | `newDetachedGovernanceArtifact(QName artifactName, String mediaType)`
    `GenericArtifact` | `newGovernanceArtifact(org.apache.axiom.om.OMElement content)` Creates a new artifact from the given content.
    `GenericArtifact` | `newGovernanceArtifact(QName qName)` Creates a new artifact from the given qualified name.
    `GenericArtifact` | `newGovernanceArtifact(QName qName, byte[] content)` Creates a new artifact from the given qualified name.
    `GenericArtifact` | `newGovernanceArtifact(String omContent)` Creates a new artifact from the given string content.
    `void` | `removeGenericArtifact(GenericArtifact artifact)`
    `void` | `removeGenericArtifact(String artifactId)` Removes the given artifact from the registry.
    `void` | `setContent(org.wso2.carbon.registry.core.Resource resource, GovernanceArtifact artifact)`
    `void` | `updateGenericArtifact(GenericArtifact artifact)` Updates the given artifact on the registry.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### GenericArtifactManager

          public GenericArtifactManager(org.wso2.carbon.registry.core.Registry registry,
                                        String mediaType,
                                        String artifactNameAttribute,
                                        String artifactNamespaceAttribute,
                                        String artifactElementRoot,
                                        String artifactElementNamespace,
                                        String pathExpression,
                                        org.wso2.carbon.registry.core.Association[] relationshipDefinitions)

      Constructor accepting an instance of the registry, and also details on the type of manager.
      Parameters:
        `registry` - the instance of the registry.
        `mediaType` - the media type of resources being saved or fetched.
        `artifactNameAttribute` - the attribute that specifies the name of the artifact.
        `artifactNamespaceAttribute` - the attribute that specifies the namespace of the artifact.
        `artifactElementRoot` - the attribute that specifies the root artifact element.
        `artifactElementNamespace` - the attribute that specifies the artifact element's namespace.
        `pathExpression` - the expression that can be used to compute where to store the artifact.
        `relationshipDefinitions` - the relationship definitions for the types of associations that will be created when the artifact gets updated.

    - #### GenericArtifactManager

          public GenericArtifactManager(org.wso2.carbon.registry.core.Registry registry,
                                        String key)
                                 throws org.wso2.carbon.registry.core.exceptions.RegistryException

      Constructor accepting an instance of the registry, and key identifying the type of manager.
      Parameters:
        `registry` - the instance of the registry.
        `key` - the key short name of the artifact type.
      Throws:
        `org.wso2.carbon.registry.core.exceptions.RegistryException` - Thrown when rxt configuration is not in registry.

  - ### Method Detail

    - #### newGovernanceArtifact

          public GenericArtifact newGovernanceArtifact(QName qName)
                                                throws GovernanceException

      Creates a new artifact from the given qualified name.
      Parameters:
        `qName` - the qualified name of this artifact.
      Returns:
        the artifact added.
      Throws:
        `GovernanceException` - if the operation failed.

    - #### newGovernanceArtifact

          public GenericArtifact newGovernanceArtifact(QName qName,
                                                       byte[] content)
                                                throws GovernanceException

      Creates a new artifact from the given qualified name.
      Parameters:
        `qName` - the qualified name of this artifact.
      Returns:
        the artifact added.
      Throws:
        `GovernanceException` - if the operation failed.

    - #### newGovernanceArtifact

          public GenericArtifact newGovernanceArtifact(org.apache.axiom.om.OMElement content)
                                                throws GovernanceException

      Creates a new artifact from the given content.
      Parameters:
        `content` - the artifact content.
      Returns:
        the artifact added.
      Throws:
        `GovernanceException` - if the operation failed.

    - #### newGovernanceArtifact

          public GenericArtifact newGovernanceArtifact(String omContent)
                                                throws GovernanceException

      Creates a new artifact from the given string content.
      Parameters:
        `omContent` - the artifact content in string
      Returns:
        the artifact added.
      Throws:
        `GovernanceException` - if the operation failed.

    - #### addGenericArtifact

          public void addGenericArtifact(GenericArtifact artifact)
                                  throws GovernanceException

      Adds the given artifact to the registry. Please do not use this method to update an existing artifact use the update method instead. If this method is used to update an existing artifact, all existing properties (such as lifecycle details) will be removed from the existing artifact.
      Parameters:
        `artifact` - the artifact.
      Throws:
        `GovernanceException` - if the operation failed.

    - #### updateGenericArtifact

          public void updateGenericArtifact(GenericArtifact artifact)
                                     throws GovernanceException

      Updates the given artifact on the registry.
      Parameters:
        `artifact` - the artifact.
      Throws:
        `GovernanceException` - if the operation failed.

    - #### getGenericArtifact

          public GenericArtifact getGenericArtifact(String artifactId)
                                             throws GovernanceException

      Fetches the given artifact on the registry.
      Parameters:
        `artifactId` - the identifier of the artifact.
      Returns:
        the artifact.
      Throws:
        `GovernanceException` - if the operation failed.

    - #### removeGenericArtifact

          public void removeGenericArtifact(String artifactId)
                                     throws GovernanceException

      Removes the given artifact from the registry.
      Parameters:
        `artifactId` - the identifier of the artifact.
      Throws:
        `GovernanceException` - if the operation failed.

    - #### findGenericArtifacts

          public GenericArtifact[] findGenericArtifacts(Map<String,List<String>> criteria)
                                                 throws GovernanceException

      Finds all artifacts matching the given filter criteria.
      Parameters:
        `criteria` - the filter criteria to be matched.
      Returns:
        the artifacts that match.
      Throws:
        `GovernanceException` - if the operation failed.

    - #### getTermData

          public org.wso2.carbon.registry.common.TermData[] getTermData(Map<String,List<String>> criteria,
                                                                        String facetField,
                                                                        boolean authRequired)
                                                                 throws GovernanceException

      Find all possible terms and its count for the given facet field and query criteria
      Parameters:
        `criteria` - the filter criteria to be matched
        `facetField` - field used for faceting
        `authRequired` - authorization required flag
      Returns:
        term results
      Throws:
        `GovernanceException`

    - #### findGovernanceArtifacts

          public GenericArtifact[] findGovernanceArtifacts(String query)
                                                    throws GovernanceException

      Finds and returns GenericArtifact instances matching the search query
      Parameters:
        `query` - The query string that needs to be searched for
      Returns:
        The GenericArtifact list that matching the query
      Throws:
        `GovernanceException` - if the operation failed

    - #### findGenericArtifacts

          public GenericArtifact[] findGenericArtifacts(GenericArtifactFilter criteria)
                                                 throws GovernanceException

      Finds all artifacts matching the given filter criteria.
      Parameters:
        `criteria` - the filter criteria to be matched.
      Returns:
        the artifacts that match.
      Throws:
        `GovernanceException` - if the operation failed.

    - #### getAllGenericArtifacts

          public GenericArtifact[] getAllGenericArtifacts()
                                                   throws GovernanceException

      Finds all artifacts on the registry.
      Returns:
        all artifacts on the registry.
      Throws:
        `GovernanceException` - if the operation failed.

    - #### getAllGenericArtifactsByLifecycle

          public GenericArtifact[] getAllGenericArtifactsByLifecycle(String lcName)
                                                              throws GovernanceException

      Retrieve all the generic artifacts which associated with the given lifecycle
      Parameters:
        `lcName` - Name of the lifecycle
      Returns:
        GenericArtifact array
      Throws:
        `GovernanceException`

    - #### getAllGenericArtifactsByLifecycleStatus

          public GenericArtifact[] getAllGenericArtifactsByLifecycleStatus(String lcName,
                                                                           String lcState)
                                                                    throws GovernanceException

      Retrieve all the generic artifacts which associated with the given lifecycle in the given lifecycle state
      Parameters:
        `lcName` - Name of the lifecycle
        `lcState` - Name of the current lifecycle state
      Returns:
        GenericArtifact array
      Throws:
        `GovernanceException`

    - #### getAllGenericArtifactIds

          public String[] getAllGenericArtifactIds()
                                            throws GovernanceException

      Finds all identifiers of the artifacts on the registry.
      Returns:
        an array of identifiers of the artifacts.
      Throws:
        `GovernanceException` - if the operation failed.

    - #### newDetachedGovernanceArtifact

          public static GenericArtifact newDetachedGovernanceArtifact(QName artifactName,
                                                                      String mediaType)

    - #### isExists

          public boolean isExists(GovernanceArtifact artifact)
                           throws GovernanceException

      Check whether GovernanceArtifact is exists in the Registry without loading whole artifact into memory. This method only work for Configurable Governance Artifacts and doe not work for Content Artifacts such as WSDL, WADL, Swagger, XMLSchema etc.
      Parameters:
        `artifact` - GovernanceArtifact to check it's existence.
      Returns:
        true or false
      Throws:
        `GovernanceException` - if the operation failed.

    - #### removeGenericArtifact

          public void removeGenericArtifact(GenericArtifact artifact)
                                     throws GovernanceException

      Throws:
        `GovernanceException`

    - #### setContent

          public void setContent(org.wso2.carbon.registry.core.Resource resource,
                                 GovernanceArtifact artifact)
                          throws GovernanceException

      Throws:
        `GovernanceException`

Copyright © 2017 WSO2. All Rights Reserved.