com.versionone.apiclient

## Class Services

- java.lang.Object
- - com.versionone.apiclient.Services

- All Implemented Interfaces:
    IServices

      public class Services
      extends Object
      implements IServices

  Wraps the services available in the VersionOne API

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Services(IMetaModel metaModel, IAPIConnector connector)`
    `Services(V1Connector v1Connector)`
    `Services(V1Connector connector, boolean preLoadMeta)`
    `Services(V1Connector connector, IMetaModel metaModel)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Asset` | `createNew(IAssetType assetType, Oid context)` Create new Asset
    `Oid` | `executeOperation(IOperation op, Oid oid)` Execute an operation on the server
    `String` | `executePassThroughQuery(String query)` Executes a Query API query using in JSON or YAML format.
    `IAPIConnector` | `get_connector()`
    `Oid` | `get_loggedin()`
    `IAssetType` | `getAssetType(String token)` Get the asset type from an token
    `InputStream` | `getAttachment(Oid attachmentOid)` Returns the attachment data for the specified attachment Oid.
    `IAttributeDefinition` | `getAttributeDefinition(String token)` Get the attribute definition
    `Reader` | `getEmbeddedImage(Oid embeddedImageOid)` Returns the embedded image data for the specified attachment Oid.
    `Map<String,String>` | `getLocalization(ArrayList<IAttributeDefinition> attributes)` Returns a Map of localized values.
    `String` | `getLocalization(IAttributeDefinition attribute)` Returns a localization value based on an attribute definition.
    `String` | `getLocalization(String key)` Returns a localization value based on key.
    `Oid` | `getLoggedIn()` Get the Oid of the current logged in user
    `IMetaModel` | `getMeta()` Returns the MetaModel.
    `Oid` | `getOid(String token)` Get the Object Identifier from a token
    `IOperation` | `getOperation(String token)` Get an operation from a token
    `V1Connector` | `getV1Connector()` Returns the V1Connector.
    `QueryResult` | `retrieve(Query query)` Query VersionOne
    `void` | `save(Asset asset)` Save an asset with no comment
    `void` | `save(Asset[] assets)` Save an array of assets without comment
    `void` | `save(Asset asset, String comment)` Save an asset with comment
    `Oid` | `saveAttachment(String filePath, Asset asset, String attachmentName)` Saves an attachment to the specified asset.
    `Oid` | `saveEmbeddedImage(String filePath, Asset asset)` Saves an embedded image to the specified asset.

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

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

- - ### Constructor Detail

    - #### Services

          public Services(IMetaModel metaModel,
                          IAPIConnector connector)

      Parameters:
        `metaModel` - - VersionOne MetaModel
        `connector` - - Connection to the server

    - #### Services

          public Services(V1Connector v1Connector)
                   throws org.apache.commons.lang.NullArgumentException

      Throws:
        `org.apache.commons.lang.NullArgumentException`

    - #### Services

          public Services(V1Connector connector,
                          IMetaModel metaModel)
                   throws org.apache.commons.lang.NullArgumentException

      Throws:
        `org.apache.commons.lang.NullArgumentException`

    - #### Services

          public Services(V1Connector connector,
                          boolean preLoadMeta)
                   throws org.apache.commons.lang.NullArgumentException

      Throws:
        `org.apache.commons.lang.NullArgumentException`

  - ### Method Detail

    - #### getMeta

          public IMetaModel getMeta()

      Description copied from interface: `IServices`
      Returns the MetaModel.
      Specified by:
        `getMeta` in interface `IServices`
      Returns:
        IMetaModel

    - #### get_connector

          public IAPIConnector get_connector()

    - #### get_loggedin

          public Oid get_loggedin()

    - #### getV1Connector

          public V1Connector getV1Connector()

      Description copied from interface: `IServices`
      Returns the V1Connector.
      Specified by:
        `getV1Connector` in interface `IServices`
      Returns:
        V1Connector

    - #### retrieve

          public QueryResult retrieve(Query query)
                               throws ConnectionException,
                                      APIException,
                                      OidException

      Query VersionOne
      Specified by:
        `retrieve` in interface `IServices`
      Parameters:
        `query` - The query to execute.
      Returns:
        QueryResult of the query
      Throws:
        `ConnectionException` - - if connection to VersionOne down
        `APIException` - if there is a problem executing the query
        `OidException` - - if there is problem related to Object Identifiers
      See Also:
        `IServices.retrieve(Query)`

    - #### createNew

          public Asset createNew(IAssetType assetType,
                                 Oid context)
                          throws V1Exception

      Create new Asset
      Specified by:
        `createNew` in interface `IServices`
      Parameters:
        `assetType` - The type of asset to create
        `context` - - context under which to create the asset
      Returns:
        New Asset
      Throws:
        `V1Exception` - - when the create fails
      See Also:
        `IServices.createNew(IAssetType, Oid)`

    - #### executeOperation

          public Oid executeOperation(IOperation op,
                                      Oid oid)
                               throws APIException

      Execute an operation on the server
      Specified by:
        `executeOperation` in interface `IServices`
      Parameters:
        `op` - The operation to execute
        `oid` - - OID of object on which method is executed
      Returns:
        Oid result of operation
      Throws:
        `APIException` - - when the operation fails
      See Also:
        `IServices.executeOperation(IOperation, Oid)`

    - #### getAssetType

          public IAssetType getAssetType(String token)
                                  throws MetaException

      Get the asset type from an token
      Specified by:
        `getAssetType` in interface `IServices`
      Parameters:
        `token` - The token to process
      Returns:
        IAssetType Based on the token
      Throws:
        `MetaException` - if the token is invalid
      See Also:
        `IServices.getAssetType(String)`

    - #### getAttributeDefinition

          public IAttributeDefinition getAttributeDefinition(String token)
                                                      throws MetaException

      Get the attribute definition
      Specified by:
        `getAttributeDefinition` in interface `IServices`
      Parameters:
        `token` - The token to process
      Returns:
        IAttributeDefinition Based on the token
      Throws:
        `MetaException` - if the token is invalid
      See Also:
        `IServices.getAttributeDefinition(String)`

    - #### getOid

          public Oid getOid(String token)
                     throws OidException

      Get the Object Identifier from a token
      Specified by:
        `getOid` in interface `IServices`
      Parameters:
        `token` - The token to process
      Returns:
        Object Identifier
      Throws:
        `OidException` - if the token is invalid
      See Also:
        `IServices.getOid(String)`

    - #### getOperation

          public IOperation getOperation(String token)
                                  throws MetaException

      Get an operation from a token
      Specified by:
        `getOperation` in interface `IServices`
      Parameters:
        `token` - The token to process
      Returns:
        IOperation Based on the token
      Throws:
        `MetaException` - if the token is invalid
      See Also:
        `IServices.getOperation(String)`

    - #### getLoggedIn

          public Oid getLoggedIn()
                          throws APIException,
                                 ConnectionException,
                                 OidException

      Get the Oid of the current logged in user
      Specified by:
        `getLoggedIn` in interface `IServices`
      Returns:
        Object Identifier for current user
      Throws:
        `APIException` - - if there is any other error
        `ConnectionException` - - if connection to VersionOne down
        `OidException` - - if there is problem related to Object Identifiers
      See Also:
        `IServices.getLoggedIn()`

    - #### save

          public void save(Asset asset)
                    throws APIException,
                           ConnectionException

      Save an asset with no comment
      Specified by:
        `save` in interface `IServices`
      Parameters:
        `asset` - The asset that changed
      Throws:
        `APIException` - - if the save fails
        `ConnectionException` - - if connection to VersionOne down
      See Also:
        `IServices.save(Asset)`

    - #### save

          public void save(Asset asset,
                           String comment)
                    throws APIException,
                           ConnectionException

      Save an asset with comment
      Specified by:
        `save` in interface `IServices`
      Parameters:
        `asset` - The asset that changed
        `comment` - - comment
      Throws:
        `APIException` - - if the save fails
        `ConnectionException` - - if connection to VersionOne down
      See Also:
        `IServices.save(Asset, String)`

    - #### save

          public void save(Asset[] assets)
                    throws V1Exception

      Save an array of assets without comment
      Specified by:
        `save` in interface `IServices`
      Parameters:
        `assets` - An array of assets to save
      Throws:
        `V1Exception` - - if the save fails
      See Also:
        `IServices.save(Asset[])`

    - #### executePassThroughQuery

          public String executePassThroughQuery(String query)

      Description copied from interface: `IServices`
      Executes a Query API query using in JSON or YAML format.
      Specified by:
        `executePassThroughQuery` in interface `IServices`
      Parameters:
        `query` - The query JSON or YAML query string
      Returns:
        String

    - #### getLocalization

          public String getLocalization(IAttributeDefinition attribute)
                                 throws V1Exception

      Description copied from interface: `IServices`
      Returns a localization value based on an attribute definition.
      Specified by:
        `getLocalization` in interface `IServices`
      Parameters:
        `attribute` - An attribute definition
      Returns:
        String String
      Throws:
        `V1Exception` - V1Exception

    - #### getLocalization

          public String getLocalization(String key)
                                 throws V1Exception

      Description copied from interface: `IServices`
      Returns a localization value based on key.
      Specified by:
        `getLocalization` in interface `IServices`
      Parameters:
        `key` - String A string value of the key
      Returns:
        String String
      Throws:
        `V1Exception` - V1Exception

    - #### getLocalization

          public Map<String,String> getLocalization(ArrayList<IAttributeDefinition> attributes)
                                             throws ConnectionException

      Description copied from interface: `IServices`
      Returns a Map of localized values.
      Specified by:
        `getLocalization` in interface `IServices`
      Parameters:
        `attributes` - attributes
      Returns:
        Map Map of strings
      Throws:
        `ConnectionException` - ConnectionException

    - #### saveAttachment

          public Oid saveAttachment(String filePath,
                                    Asset asset,
                                    String attachmentName)
                             throws V1Exception,
                                    IOException

      Description copied from interface: `IServices`
      Saves an attachment to the specified asset.
      Specified by:
        `saveAttachment` in interface `IServices`
      Parameters:
        `filePath` - Path and name of the attachment file.
        `asset` - Asset to save the attachment to.
        `attachmentName` - The name of the attachment.
      Returns:
        Oid
      Throws:
        `V1Exception` - V1Exception
        `IOException` - IOException

    - #### getAttachment

          public InputStream getAttachment(Oid attachmentOid)
                                    throws V1Exception

      Description copied from interface: `IServices`
      Returns the attachment data for the specified attachment Oid.
      Specified by:
        `getAttachment` in interface `IServices`
      Parameters:
        `attachmentOid` - The Oid of the attachment to return.
      Returns:
        Reader
      Throws:
        `V1Exception` - V1Exception

    - #### saveEmbeddedImage

          public Oid saveEmbeddedImage(String filePath,
                                       Asset asset)
                                throws V1Exception,
                                       IOException

      Description copied from interface: `IServices`
      Saves an embedded image to the specified asset.
      Specified by:
        `saveEmbeddedImage` in interface `IServices`
      Parameters:
        `filePath` - Path and name of the embedded image file.
        `asset` - Asset to save the embedded image to.
      Returns:
        Oid
      Throws:
        `V1Exception` - V1Exception
        `IOException` - IOException

    - #### getEmbeddedImage

          public Reader getEmbeddedImage(Oid embeddedImageOid)
                                  throws V1Exception

      Description copied from interface: `IServices`
      Returns the embedded image data for the specified attachment Oid.
      Specified by:
        `getEmbeddedImage` in interface `IServices`
      Parameters:
        `embeddedImageOid` - The Oid of the embedded image to return.
      Returns:
        Reader
      Throws:
        `V1Exception` - V1Exception

Copyright © 2021 VersionOne, Inc.. All rights reserved.