com.sap.sl.sdk.authoring.cms
Interface CmsResourceService


public interface CmsResourceService

Provides methods to create and manage repository resources.

This service needs a session that should be provided using CmsSessionService. Semantic layer security is managed by CmsSecurityService.

A repository path represents an InfoObject in the CMS repository. It begins with a root, either UNIVERSES_ROOT, CONNECTIONS_ROOT, or SETS_ROOT. The root is followed by a subfolder and the resource name. The separator is /. For example /Connections/myCmsFolder/MyConnection.


Field Summary
static java.lang.String CONNECTIONS_ROOT
          CMS root path for connections.
static java.lang.String SETS_ROOT
          CMS root path for sets.
static java.lang.String UNIVERSES_ROOT
          CMS root path for universes.
 
Method Summary
 void changeUniverseConnection(java.lang.String repositoryUniversePath, java.lang.String repositoryConnectionPath)
          Replaces a connection from a published universe by another connection stored in the repository.
 void changeUniverseConnections(java.lang.String repositoryUniversePath, java.util.Map<java.lang.String,java.lang.String> repositoryConnectionPathMap)
          Replaces a list of connections from a published multisource-enabled universe by another list of connections stored in the repository.
 void close(SlResource resource)
          Releases the resource to avoid memory leak.
 void convertUniverse(java.lang.String sourceUnvFilePath, java.lang.String destinationFolder, java.lang.String newResourceName, boolean isPromptConverted)
          Converts a .unv universe stored in the repository into a .unx universe.
 void convertUniverse(java.lang.String sourceUnvFilePath, java.lang.String destinationFolder, java.lang.String newResourceName, boolean isPromptConverted, boolean isCoreUniversesIncluded, boolean isOverwritten)
          Converts a .unv universe stored in the repository into a .unx universe.
 java.lang.String createShortcut(java.lang.String repositoryPath, java.lang.String targetFolder)
          Creates a connection shortcut (.cns) in the local workspace from a published connection ( .cnx).
 java.lang.String getResourceCuid(java.lang.String path)
          Gets the CUID of the resource from its path in the CMS repository.
 java.lang.String getResourcePath(java.lang.String cuid)
          Gets the path of the resource in the CMS repository from its CUID.
 java.util.List<java.lang.String> getUniverseConnections(java.lang.String repositoryUniversePath)
          Returns the secured connections attached to a published universe.
 int getUniverseRevisionNumber(java.lang.String unxIdentifier)
          Gets the revision number of a .unx universe published in the CMS repository.
 DatabaseConnection loadConnection(java.lang.String connectionPath)
          Returns a connection from its path in the repository.
 java.lang.String publish(java.lang.String filePath, java.lang.String repositoryPath, boolean overwrite)
          Creates or overwrites a resource (universe or connection) in the CMS.
 java.lang.String retrieveUniverse(java.lang.String repositoryPath, java.lang.String targetFolder, boolean saveForAllUsers)
          Creates resources (.blx, .cns and .dfx if applicable) in the local workspace from a published universe (.unx).
 void saveConnection(DatabaseConnection connection)
          Updates a connection in the repository.
 

Field Detail

UNIVERSES_ROOT

static final java.lang.String UNIVERSES_ROOT
CMS root path for universes.

Since:
14.0.5
See Also:
Constant Field Values

CONNECTIONS_ROOT

static final java.lang.String CONNECTIONS_ROOT
CMS root path for connections.

Since:
14.0.5
See Also:
Constant Field Values

SETS_ROOT

static final java.lang.String SETS_ROOT
CMS root path for sets.

Since:
4.2 SP2
See Also:
Constant Field Values
Method Detail

retrieveUniverse

java.lang.String retrieveUniverse(java.lang.String repositoryPath,
                                  java.lang.String targetFolder,
                                  boolean saveForAllUsers)
                                  throws SlException
Creates resources (.blx, .cns and .dfx if applicable) in the local workspace from a published universe (.unx).

Parameters:
repositoryPath - A String that represents the path of the repository universe you want to retrieve within the Universes root folder. See UNIVERSES_ROOT.

Example: /Universes/myCmsFolder/MyUniverse.unx

targetFolder - A String that represents the targeted folder path within which the resources are created, for example: C:\Workspace

Do not indicate the resource names, which are set from the business names of the retrieved resources.

saveForAllUsers - If set to false, this creates a secured version of the resources. A CMS session is required to access them. If set to true, this creates a non-encrypted version of the resources. Anyone can access them.
Returns:
A String that represents the created resource path with the following format: [targetFolder]/[temporary folder name]/[business layer name].blx.
Throws:
SlException
Since:
14.0.5
See Also:
UNIVERSES_ROOT

createShortcut

java.lang.String createShortcut(java.lang.String repositoryPath,
                                java.lang.String targetFolder)
                                throws SlException
Creates a connection shortcut (.cns) in the local workspace from a published connection ( .cnx).

Parameters:
repositoryPath - A String that represents the path of the repository connection you want to retrieve within the Connections root folder. See CONNECTIONS_ROOT

Example: /Connections/myCmsFolder/MyConnection

targetFolder - A String that represents the targeted folder path within which the connection shortcut is created, for example: C:\Workspace

Do not indicate the resource name, which is set from the business name of the local resource.

Returns:
A String that represents the created resource path with the following format: [targetFolder]/[temporary folder name]/[connection name].cns
Throws:
SlException
Since:
14.0.5
See Also:
CONNECTIONS_ROOT

publish

java.lang.String publish(java.lang.String filePath,
                         java.lang.String repositoryPath,
                         boolean overwrite)
                         throws SlException
Creates or overwrites a resource (universe or connection) in the CMS.

The resource is created from a local file and all dependent resources must be available. If you want to publish a universe to the repository, the file path must be a business layer path and its dependencies must be available locally (data foundation and connection shortcut).

The SDK throws an exception:

Parameters:
filePath - A String that represents the path of the local resource to publish, for example: C:\myUniverse.blx
repositoryPath - A String that represents the repository folder where the resource is published.

Do not indicate the resource name, which is set from the business name of the local resource. For CMS-specific implementation, specify the Universes or Connections root folder, for example:

  • For connections: /Connections/myCmsFolder
  • For universes: /Universes/myCmsFolder

overwrite - An exception is thrown if false and the resource already exists in the CMS
Returns:
A String that represents the path of the created resource with its root folder, for example: /Universes/myCmsFolder/MyUniverse.unx

If the resource to publish is a connection, the method returns the path of the connection without extension, for example: /Connections/myCmsFolder/MyConnection.

Throws:
SlException
Since:
14.0.5

changeUniverseConnection

void changeUniverseConnection(java.lang.String repositoryUniversePath,
                              java.lang.String repositoryConnectionPath)
                              throws SlException
Replaces a connection from a published universe by another connection stored in the repository.

This method is used for universes with a single-source connection definition (an OLAP connection, an RDBMS connection, or a DataFederator connection). It does not check the structure of the universe after the connection replacement. It does not replace the connections of the "Connections" setting of a Data Security Profile.

Before committing the secured connection replacement, a check is run first to validate if the prerequisites are respected, otherwise a SecuredConnectionException is raised with an error message. Possible exceptions are the following:

Parameters:
repositoryUniversePath - The path of the published universe in the repository

For CMS-specific implementation, specify the Universes root folder, for example: /Universes/myCmsFolder/MyUniverse.unx or /MyUniverse.unx if the file has been stored directly under the root folder.

repositoryConnectionPath - The path of the replacement secured connection stored in the CMS

For CMS-specific implementation, specify the Connections root folder, for example: /Connections/myCmsFolder/Connection or /Connection if the file has been stored directly under the root folder.

Throws:
SlException
Since:
14.0.5

changeUniverseConnections

void changeUniverseConnections(java.lang.String repositoryUniversePath,
                               java.util.Map<java.lang.String,java.lang.String> repositoryConnectionPathMap)
                               throws SlException
Replaces a list of connections from a published multisource-enabled universe by another list of connections stored in the repository.

This method is used for universes with a multisource-enabled connection definition (RDBMS and/or DataFederator connections). You can replace a connection with one that is already used by the universe. If the replacement connection has not been deployed on the Data Federation Query Server, this is done automatically when the replacement is performed. This method does not check the structure of the universe after the connection replacement. It does not replace the connections of the "Connections" setting of a Data Security Profile.

Before committing the secured connection replacement, a check is run first to validate if the prerequisites are respected in the repository connection path mapping, otherwise a SecuredConnectionException is raised with an error message. Possible exceptions are the following:

Parameters:
repositoryUniversePath - The path of the published universe in the repository

For CMS-specific implementation, specify the Universes root folder, for example: /Universes/myCmsFolder/MyUniverse.unx or /MyUniverse.unx if the file has been stored directly under the root folder.

repositoryConnectionPathMap - A map that ensures the connection replacement between the universe connections and a list of connections stored in the repository:
  • The key entry of the map is the connection path defined in the multisource-enabled universe. It can be helpful to use the CmsResourceService.getUniverseConnections(String repositoryUniversePath) method to know the path of the connections attached to the published universe and then to enter the right connection path in the map as key entry.
  • The value entry of the map is the replacement connection path stored in the repository.

For CMS-specific implementation, specify the Connections root folder, for example: /Connections/myCmsFolder/Connection.cnx or /Connections/Connection.cnx if the file has been stored directly under the root folder.

Throws:
SlException
Since:
14.0.5
See Also:
getUniverseConnections(String)

getUniverseConnections

java.util.List<java.lang.String> getUniverseConnections(java.lang.String repositoryUniversePath)
                                                        throws SlException
Returns the secured connections attached to a published universe.

Every loaded resource must be released with the method close(SlResource) to avoid memory leak.

Parameters:
repositoryUniversePath - The path of the published universe in the repository

For CMS-specific implementation, specify the Universes root folder in the path, for example: /Universes/myCmsFolder/MyUniverse.unx or /Universes/MyUniverse.unx if the file has been stored directly under the root folder.

Returns:
A list of strings that represents the list of the secured connection paths attached to the published universe

The retrieved connection path is formatted as /Connections/subFolder/connection. The root folder is Connections.

Throws:
SlException
Since:
14.0.5
See Also:
changeUniverseConnections(String, Map)

loadConnection

DatabaseConnection loadConnection(java.lang.String connectionPath)
                                  throws SlException
Returns a connection from its path in the repository.

If allowed, the connection parameter values are also returned.

Parameters:
connectionPath - The path of the connection, formatted as /Connections/subFolder/connection. The root folder is Connections.
Returns:
A Connection object
Throws:
SlException
Since:
14.0.5
See Also:
DatabaseConnection, saveConnection(DatabaseConnection), close(SlResource)

saveConnection

void saveConnection(DatabaseConnection connection)
                    throws SlException
Updates a connection in the repository.

The connection can only be provided by the loadConnection(String) method of the same SlContext.

Parameters:
connection - The connection returned by loadConnection(String)
Throws:
SlException
Since:
14.0.5
See Also:
DatabaseConnection, loadConnection(String)

convertUniverse

void convertUniverse(java.lang.String sourceUnvFilePath,
                     java.lang.String destinationFolder,
                     java.lang.String newResourceName,
                     boolean isPromptConverted)
                     throws SlException
Converts a .unv universe stored in the repository into a .unx universe.

Parameters:
sourceUnvFilePath - The path of the .unv universe

For CMS-specific implementation, it is formatted as /Universes/subFolder/myUniverse. The root folder is Universes.

destinationFolder - The path of the converted universe stored in the repository

Do not indicate the resource name, which is set from the business name of the local resource. In the repository, it is a string that represents the repository folder where the resource is to be published. It is formatted as /Universes/myFolder.

For CMS-specific implementation, specify the Universes root folder, for example: /Universes/SDK/Conversion.

newResourceName - The name of the new resource, without extension

Is optional. If not provided, the universe name will be used. Can be null, but not empty.

isPromptConverted - true to create the parameter prompt in the business layer during conversion, false to keep the universe prompt definition into the business object
Throws:
SlException
Since:
14.0.5

convertUniverse

void convertUniverse(java.lang.String sourceUnvFilePath,
                     java.lang.String destinationFolder,
                     java.lang.String newResourceName,
                     boolean isPromptConverted,
                     boolean isCoreUniversesIncluded,
                     boolean isOverwritten)
                     throws SlException
Converts a .unv universe stored in the repository into a .unx universe.

Parameters:
sourceUnvFilePath - The path of the .unv universe

  • For CMS-specific implementation, it is formatted as /Universes/subFolder/myUniverse. The root folder is Universes.
destinationFolder - The path of the converted universe stored in the repository

  • Do not indicate the resource name, which is set from the business name of the local resource. In the repository, it is a string that represents the repository folder where the resource is to be published. It is formatted as /Universes/myFolder.
  • For CMS-specific implementation, specify the Universes root folder, for example: /Universes/SDK/Conversion.
newResourceName - The name of the new resource, without extension

  • Is optional. If not provided, the universe name will be used. Can be null, but not empty.
isPromptConverted - true to create the parameter prompt in the business layer during conversion, false to keep the universe prompt definition into the business object.

isCoreUniversesIncluded - true to include the existing core universes into the converted linked universe, false to convert the linked universes and its core universes.

isOverwritten - true to replace the universe that is already in the CMS repository during conversion, false to keep the universe that is in the CMS repository.
Throws:
SlException
Since:
14.2.3

getUniverseRevisionNumber

int getUniverseRevisionNumber(java.lang.String unxIdentifier)
                              throws SlException
Gets the revision number of a .unx universe published in the CMS repository.

Parameters:
unxIdentifier - The identifier of the .unx universe

In the CMS repository, the identifier of a .unx universe can be one of the following:

  • Its path formatted as /Universes/subFolder/myUniverse.unx
  • Its CUID formatted as for example AUkhFsg72ntHpql8Izl9pv0

Returns:
An integer that represents the universe revision number
Throws:
SlException
Since:
14.2.3

getResourceCuid

java.lang.String getResourceCuid(java.lang.String path)
                                 throws SlException
Gets the CUID of the resource from its path in the CMS repository.

The supported resources are the following:

Parameters:
path - The path of the resource

  • For .unx universes, the path is formatted as /Universes/subFolder/myUniverse.unx.
  • For .unv universes, the path is formatted as /Universes/subFolder/myUniverse.
  • For .cnx connections, the path is formatted as /Connections/subFolder/myConnection.

Returns:
A string that represents the CUID of the resource

The CUID is formatted as for example AUkhFsg72ntHpql8Izl9pv0.

Throws:
SlException
Since:
14.2.3

getResourcePath

java.lang.String getResourcePath(java.lang.String cuid)
                                 throws SlException
Gets the path of the resource in the CMS repository from its CUID.

The supported resources are the following:

Parameters:
cuid - The CUID of the resource

For example: AUkhFsg72ntHpql8Izl9pv0

Returns:
A string that represents the path of the resource

  • For .unx universes, the path is formatted as /Universes/subFolder/myUniverse.unx.
  • For .unv universes, the path is formatted as /Universes/subFolder/myUniverse.
  • For .cnx connections, the path is formatted as /Connections/subFolder/myConnection.

Throws:
SlException
Since:
14.2.3

close

void close(SlResource resource)
           throws SlException
Releases the resource to avoid memory leak.

If a method is still using this resource after it has been closed, an SlException is raised.

The following methods also release this resource:

Parameters:
resource - The resource to release
Throws:
SlException
Since:
14.0.5


© Copyright 2016 SAP SE or an SAP affiliate company. All rights reserved.