COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => SDK => Topic started by: Yanny on 25 Jan 2017 10:04:50 PM

Title: Copy object between servers
Post by: Yanny on 25 Jan 2017 10:04:50 PM
Hi,
I am working on using java code to deploy objects(report, Jobs) from one server to another.
And I try to use the sample from http://www-01.ibm.com/support/docview.wss?uid=swg21335839 (http://www-01.ibm.com/support/docview.wss?uid=swg21335839) to make the deployment. While I got a error message below:
{http://developer.cognos.com/schemas/bibus/3/}exception:
         <severity>error</severity>
         <errorCode>cmBadSelection</errorCode>
         <ns1:message>
            <messageString>CM-REQ-4023 You cannot create an object at the location &quot;/Public Folders/Transactions/test&quot;.</messageString>
         </ns1:message>
         <ns1:message>
            <nestingLevel>1</nestingLevel>
            <messageString>CM-REQ-4164 The search expression did not select a parent object.</messageString>
         </ns1:message>
could anyone offer some solution or idea about this case?

Many thanks!
Title: Re: Copy object between servers
Post by: Andrew Weiss on 26 Jan 2017 09:07:22 AM
Yanny,

Unfortunately there is no SDK method to perform a deployment.  You can use the SDK to script an export, move a file and script an import but for most this is an undesirable solution to the problem.  Deploying or copying an object to another server in the SDK is a very difficult process with lots of implications if you're going to support it generically.  We've done this in our MetaManager and Integrated Control Suite software and have a fairly robust solution.  We also support the process in our Script Runner API for customers who are looking to wrap some code logic around a deployment process.  If this is something you would be interested in you can try out the deploy module and the script runner by downloading the software from here: http://www.bspsoftware.com/MetaManager.


If however you're committed to developing this with the SDK, you'll need to query all of the properties of the object and craft a corresponding Update call to the target server with those properties. 

A few tips:
  Stay away from the readonly properties except for searchPath which is required
  Only update properties with security references if the CAMID's match in both environments (e.g. owner, credential, policies)
  Only update the policies property if security should match in both environments AND the property is not currently set to inherit. (overwriting inherited properties makes them explicit)
  If you're deploying objects with references to other objects (e.g. shortcut and a report, reportView and a report) then deploy the target before deploying the object with the reference.

As I mentioned there are a lot of gotchas and edge conditions when supporting this generically, but if you're developing a very specific script to copy a report and all you need is the specification to be copied, then it's not nearly as difficult.

Good Luck,
-Andy
Title: Re: Copy object between servers
Post by: Yanny on 04 Feb 2017 01:52:29 AM
Thanks Andy for your reply!

I was used to apply copy object(report, job, report view) - update properties to achieve deployment until I found the sample I posted,
and property updating did cost lots of trouble to us, we still fail to find a proper way to do it.
Title: Re: Copy object between servers
Post by: aussieadam on 12 Feb 2018 03:47:35 PM
With reports it should be pretty easy, just need to pull specification from one enviornment, then set name and search path for the new enviornment. I haven't tried it with a job, but if you pull back the correct properties with the QueryProp i'd imagine it would work correctly.