Hi,
Is there APIs availalble to allow us writing a standalone code to publish content instances given a list of GUID. Thanks.
/**This is SAMPLE CODE*** This method publishes the ContentInstance whose id is passed as an argument.* The context channel is assumed to be the first channel to which the content instance is associated** @param ciId the String representation of the content management id of a content instance* @throws ApplicationException* @throws ValidationException* @throws AuthorizationException* @throws RemoteException* */public static void testPublish(String ciId) throws ApplicationException, ValidationException, AuthorizationException, RemoteException {if(ciId != null && ciId.length() == 40){ManagedObjectVCMRef moVCMRef=new ManagedObjectVCMRef(ciId);ManagedObject mo=ManagedObject.findByContentManagementId(moVCMRef);if(mo != null && mo instanceof ContentInstance) {ContentInstance ci=(ContentInstance)mo;//approve all referred objectsManagedObjectVCMRef[] moRefArray= ContentManagementOps.getReferredManagedObjects(moVCMRef);if(moRefArray != null){for(int i=0; i<moRefArray.length; i++){ManagedObject referredMo=ManagedObject.findByContentManagementId(moRefArray[i]);if(!referredMo.isStatusApproved()){referredMo.setStatus("approved");referredMo.commit();}}}if(ci.getChannelRefs() != null && ci.getChannelRefs().length > 0){ChannelRef channelRef=ci.getChannelRefs()[0];Channel mainChannel=null;while(channelRef != null){Channel channel=channelRef.getChannel(new RequestParameters(false));if(mainChannel == null){mainChannel=channel;}if(!channel.isStatusApproved()){channel.setStatus("approved");channel.commit();}channelRef=channel.getData().getParentChannelRef();}if(mainChannel != null){SiteRef siteRef=mainChannel.getData().getSiteRef();Site site=siteRef.getSite();if(!site.isStatusApproved()){site.setStatus("approved");}JobType type = JobType.PUBLISH;DeploymentJobDefinition jobDef = new DeploymentJobDefinition(PublishUtils.autogenerateJobName(site.getName()), type );jobDef.setRequestor("testPublish");jobDef.setDescription("Job created by TestPublish on " + new Date());ContentInstancePattern pattern = new ContentInstancePattern(new ManagedObjectVCMRef[] {ci.getContentManagementId()}, mainChannel.getContentManagementId());ApprovalPolicy policy = new ApprovalPolicy();policy.setUnapprovedDescendentAction(JobConst.getPolicyFromName("MODERATE"));pattern.setApprovalPolicy(policy);jobDef.setContentPattern( pattern, false);DeploymentClient dc=new DeploymentClient(siteRef);JobReport jr=dc.createJob2(jobDef);ObjectId jobId=jr.getJobData().getId();if(jr.isJobValid()){dc.launchJob(jobId);System.out.println("Job launched successfully");} else {dc.releaseJob(jobId);System.out.println("Invalid job: released");}}} else {System.out.println("The specified content instance has no channel association");}} else {System.out.println("A managed object with the specified id does not exist or it is not a ContentInstance.");}} else {System.out.println("Invalid content management id '" + ciId + "'");}}
From: eLink Entry: Discussion Group - Web Experience Management [mailto:v7webcontentmanagement@elinkkc.opentext.com] Sent: Tuesday, September 16, 2014 3:27 PMTo: eLink RecipientSubject: programatically publish content instance
programatically publish content instance
Posted byvwang@toronto.ca (****, Victor) On 09/16/2014 04:20 PM
[To post a comment, use the normal reply function]
Forum:
Discussion Group - Web Experience Management
Content Server:
Knowledge Center
programatically publish content instance Posted byvwang@toronto.ca (****, Victor)On 09/16/2014 04:20 PM Hi, Is there APIs availalble to allow us writing a standalone code to publish content instances given a list of GUID. Thanks.[To post a comment, use the normal reply function]Forum:Discussion Group - Web Experience ManagementContent Server:Knowledge Center
Hello,
In WEM 8.5 Content Management SDK Development Guide , section 8.3 is called specifically “Programatically Creating and Launching Jobs”. You can find there detail about different ways of defining jobs and sample code to create and launch publishing jobs.
In other versions the section number or name may not be the same, but the information is there.
Cheers,
Tomás
Thanks for the response guys. One follow up question, when the job contains invalid items, is there a way to skip the invalid items with code? Similar to the UI interface where the user could check the Skip checkbox and proceed with publishing? Thanks.
You can only “skip” what we call “non-fatal exclusions”, in which case the job is valid, and it can be published without modification, and the non-fatal exclusions will be omitted. But you cannot skip a “fatal” exclusion, in which case the job is invalid, and it cannot be published. Rather, another job must be recreated with a change to the pattern or policy such that the fatal exclusions are removed.
For instance, if you create a job using ContentInstancePattern with several items and with moderate (default) policy, and some of those items are not eligible, they will be non-fatal exclusions by design. The job is valid, and it can be published (DeploymentClient#launchJob/runJob) excluding those items. But if the same pattern was built using strict policy, those ineligible items would be fatal exclusions. The job is invalid, and it cannot be published. The job would need to be re-created with a different pattern or policy removing those fatal exclusions.
The console “Publishing Assistant” wizard is doing two things. First, it’s advising the user of non-fatal exclusions, allowing them to be fixed or “omitted”, where omitted is just an acknowledgement – there is no modification to the job, which will exclude them upon publish anyhow. Second, it’s requiring the user to fix any fatal exclusions which cannot be omitted. If the user elects to fix any non-fatal or fatal exclusions, the job is implicitly recreated behind the scenes using the same pattern and policy, and the wizard iterates. Once no fatal exclusions exist, the job can be published. But if the user does not fix some fatal exclusions within the wizard, the job cannot be published. Note that the user could decline fixing them within the wizard, cancel the publish operation, and start another with a different selection of content (or policy) that did not involve the fatal exclusions. Likewise, this is what you would need to do “with code” in order to “skip” fatal exclusions.
From: eLink Entry: Discussion Group - Web Experience Management [mailto:v7webcontentmanagement@elinkkc.opentext.com]Sent: Wednesday, September 17, 2014 10:00 AMTo: eLink RecipientSubject: programatically publish content instance
Posted byvwang@toronto.ca (****, Victor) On 09/17/2014 10:58 AM
Topic:
I am interetsed in skipping the non-fatal exclusions. Will those be automatically skipped when launching the job with code, or some additional coding is required to handle the exception? Thanks.
Non-fatal exclusions should be automatically skipped when launching the job.
Are you seeing some exception?
From: eLink Entry: Discussion Group - Web Experience Management [mailto:v7webcontentmanagement@elinkkc.opentext.com]Sent: Wednesday, September 17, 2014 12:06 PMTo: eLink RecipientSubject: RE programatically publish content instance
RE programatically publish content instance
Posted byvwang@toronto.ca (****, Victor) On 09/17/2014 01:04 PM
Policy may affect whether a particular ineligibility is fatal or non-fatal upon jobcreation, but it plays no factor in a valid job omitting non-fatal exclusions upon publish.
From: eLink Entry: Discussion Group - Web Experience Management [mailto:v7webcontentmanagement@elinkkc.opentext.com]Sent: Wednesday, September 17, 2014 10:10 PMTo: eLink RecipientSubject: RE RE RE programatically publish content instance
RE RE RE programatically publish content instance
Posted byqsaifudd@opentext.com (Saifuddin, Qutubuddin) On 09/17/2014 11:09 PM
Behavior will depend on publishing policy used for the job.QutubSent from my Android phone using TouchDown (www.nitrodesk.com)-----Original Message----- From: eLink Entry: Discussion Group - Web Experience Management [v7webcontentmanagement@elinkkc.opentext.com]Received: Wednesday, 17 Sep 2014, 2:16PMTo: eLink Recipient [devnull@elinkkc.opentext.com]Subject: RE RE programatically publish content instance
RE RE programatically publish content instance
Posted byclayj@opentext.com (Johnson, Clay) On 09/17/2014 02:15 PM
Posted by vwang@toronto.ca (****, Victor) On 09/17/2014 01:04 PM