The importResource method

Imports an existing *.pes export file from the local file system to the repository.

importResource(source,target,resourceType,resourceConflict,invalidVersionConflict,
resourceDef,labelFrom,lockResolution,exclude)
Table 1. Input parameters for importResource
Field Use Type Description Example Value
source Required String The fully qualified path (on the local file system) of the file to import "C:\Temp\New.pes"
target Required String The fully qualified repository path or object URI of the folder into which to import "/Temp Folder" or "0a58c3670016a7860000 010dcee0eaa28219"
resourceType Optional String Type of content being imported. Specify one of the following values:
  • ContentRepository for content objects such as files and folders
  • ResourceDef for resource definitions
  • Credential for user credentials
  • DataSource for data source definitions
  • MessageDomain for message domains
  • ServerCluster for server cluster definitions
  • Server for server definitions
  • PromotionPolicy for promotion policies
If this parameter is not specified, the default value of ContentRepository is used.
 
resourceConflict Optional String Indicates how to resolve duplicate ID or name conflicts. Specify one of the following values:
  • keepTarget. The target item will be maintained. The source item with the duplicate ID, which is contained in the .pes file, will be ignored.
  • addNewVersion. This option is typically used to resolve ID conflicts or naming conflicts. If a duplicate ID conflict occurs between the source object and the target object, then a new version of the object will be created in the target location. If a naming conflict occurs, the imported object will be renamed in the target location. Typically, renamed objects are appended with _1, _2, and so forth. In the event that two versions of an object have the same label, the system keeps one label and discards the duplicate label because no two versions of the same item can have the same label. The label that is retained depends on the labelFrom parameter.
If this parameter is not specified, the default value of keepTarget is used.
 
labelFrom Optional String Label to use if two versions of an object have the same label. The label for the other version is discarded. Specify either source or target. If this parameter is not specified, the default value of source is used.  
lockResolution Optional String Defines how to proceed if locked resources are encountered. Specify one of the following values:
  • continue. Continues the import, omitting any locked resources.
  • abort. Terminates the import process if any locked resources are encountered.If any conflicts are encountered due to object locks, the import process will be terminated and fail.
If this parameter is not specified, the default value of abort is used.
 
invalidVersionConflict Optional String Defines how to proceed if an invalid version is encountered during the import process. Specify one of the following values:
  • import. The invalid version will be imported.
  • discard. The invalid version will be deleted.
If this parameter is not specified, the default value of import is used.
 
resourceDef Optional String Defines the processing behavior for resource definitions. Specify one of the following values:
  • recommended. A resource definition is imported only if the identifier or name does not conflict with a target definition. Any resource definitions that have a conflict are not imported.
  • include. All resource definitions in the import file are imported. You can select one or more resource definition types to exclude from the import by selecting the corresponding check box.
  • exclude. No resource definitions from the import files are imported. Imported objects may need to be modified to reference available resource definitions.
If this parameter is not specified, the default value of recommended is used.
 
exclude Optional String Defines which resource types are excluded during the import. Multiple values can be combined in any order as a semicolon-delimited list. Specify one or more of the following values:
  • credential excludes user credentials
  • customproperty excludes custom properties for resource objects
  • datasource excludes data source definitions
  • messagedomain excludes message domains
  • notification excludes notification definitions
  • servercluster excludes server cluster definitions
  • server excludes server definitions
  • topic excludes topic definitions
If this parameter is not specified, all types are included in the import.
 
Table 2. Return value for importResource
Type Description
Boolean True or False based on whether the method runs successfully.
Table 3. Exceptions for importResource
Type Description
ResourceNotFoundException The source file or target folder does not exist.
InsufficientParameterException Required parameters are not specified.

Example

The following sample imports the contents of the drafts.pes export file to the /Demo/Drafts folder of the IBM® SPSS® Collaboration and Deployment Services Repository


from pes.api.PESImpl import PESImpl
pesImpl = PESImpl(user = "admin", password = "[{AES}KrY+KLlOYo4O6545tgGsYQ==]", host = "localhost", port = "8080", appserver_type = "websphere")
bSuccess = pesImpl.importResource(source="C:\Demo\drafts.pes",target="/Demo/Drafts")