Hi,
How to publish a Static file in an application using Java Code (Without making use of the DPM/DSM).
I am using WEM 8.1.
Any help on this will be highly appreaciated.
Thanks in advance!!!
Hi Andy,
Try this reference code for publish SFs to a particular stage of site. Modify as per your requirements
///////////////////////
/**
* Publish List of static files to given stage of siteName
* @param list - Static File object list
* @param siteName - Name of site on which the content tobe published
* @param stage - stage Name for deployment
*/
public void pubishStaticFile(List list, String siteName,String stage) {
try {
int size = list.size();
int count = 0;
int items = 0;
ManagedObjectVCMRef[] sfarray = new ManagedObjectVCMRef[100];
if (size < 100)
sfarray = new ManagedObjectVCMRef[size];
else {
sfarray = new ManagedObjectVCMRef[100];
}
for (int i = 0; i < size; i++) {
StaticFile sf = (StaticFile) list.get(i);
sfarray[(count++)] = sf.getContentManagementId();
System.out.println(i + ". " + sf.getProjectPath());
if ((count % 100 == 0) || (i + 1 == size)) {
publishToStage(sfarray, siteName, stage);
items = size - i > 100 ? 100 : size - i - 1;
sfarray = new ManagedObjectVCMRef[items];
count = 0;
} catch (Exception e) {
e.printStackTrace();
public void publishToStage(ManagedObjectVCMRef[] sfarray, String siteName,
String stage) {
System.out.println("-------------------- publishToStage ");
DeploymentJobDefinition deploymentjobdefinition = null;
Site site = Site.findByName(siteName);
SiteRef siteref = new SiteRef(site);
DeploymentClient deploymentclient = new DeploymentClient(siteref);
ContentInstancePattern contentinstancepattern = new ContentInstancePattern(
sfarray);
System.out.println("contents for publish ----- " + sfarray.length);
deploymentjobdefinition = new DeploymentJobDefinition(siteName
+ "_StandAloneDeployment", JobType.PUBLISH);
deploymentjobdefinition.setRequestor("cmsadmin2");
deploymentjobdefinition.setContentPattern(contentinstancepattern,
false);
JobReport jr = deploymentclient.createJob2(deploymentjobdefinition);
if (jr != null) {
JobData jd = jr.getJobData();
ObjectId objID = jd.getId();
if (jr.isJobValid()) {
System.out.println("job is valid ...");
System.out.println("run job ...");
deploymentclient.runJob(objID, stage, true);
} else {
String sInvalidReason = "Job is invalid as following items are unapproved:\n";
Iterator<?> iter = jr.getExcludedItems(true, null, true)
.asList().iterator();
while (iter.hasNext()) {
ExcludedJobItem element = (ExcludedJobItem) iter.next();
sInvalidReason = sInvalidReason
+ element.getItemName()
+ " is "
+ ("approved".equals(element
.getItemApprovalStatus()) ? "approved"
: "unapproved") + "\n";
boolean released = deploymentclient.releaseJob(objID);
System.out.println("Job " + (released ? "" : "un")
+ "sucessfully released.");
System.out.println(sInvalidReason);
Thanks & Regards,
Trilochan Singh
From: eLink Entry: Discussion Group - Web Experience Management [mailto:v7webcontentmanagement@elinkkc.opentext.com] Sent: Tuesday, October 22, 2013 10:24 AMTo: eLink RecipientSubject: Static File using Java Code
Static File using Java Code
Posted by ali@smg.sanmiguel.com.ph (Li, Andy) On 10-22-2013 00:49
[To post a comment, use the normal reply function]
Forum:
Discussion Group - Web Experience Management
Content Server:
Knowledge Center
Hello,
The document that your referred to ("OpenText Web Experience Management 8.1 Content Delivery SDK Development Guide”) seems to be outdated. I would recommend that you open a support ticket to report this.
In WEM 8.1, all the delivery war files were removed from the distribution. Instead you need to use “vgncdawar” command tool (in “<vinstalldir>/Content/8_1/bin”) to create a base delivery application depending on your environment (app server, DPM/DSM enabled, HPD enabled/disabled, etc).
Your case is a bit special but I understand that you can use “vgncdawar” to build a base war, take the tld from it, and install in your environment.
Regards,
Tomás
Hi Trilochan,
Thanks for your reply.
Actually I wanted to render images in my application using JSF(Primefaces) but without using DPM/DSM.
Can you please help for the same?
Thanks!!
I am not able to understand what exactly you are looking for; What is the src path you are getting in your JSF page for images/Static files?
To render images in an application you need a docroot for your static files.
Publish static files to a stage(You can create a separate stage for dynamic content) and setup the docroot for the your application server to get the files from dynamic stage docroot.
As per my understanding you are not using DSM/DPM , and rendering content to an application through JSF. In that case if you are using ELJ to include images in your content then you have to change the “Link Transformer Class” under “Advanced Inline Links Settings” for ELJ widget, to render your images you can change your image path as per your requirements.
Trilochan
From: eLink Entry: Discussion Group - Web Experience Management [mailto:v7webcontentmanagement@elinkkc.opentext.com] Sent: Wednesday, October 23, 2013 3:39 PMTo: eLink RecipientSubject: RE Static File using Java Code
RE Static File using Java Code
Posted by ali@smg.sanmiguel.com.ph (Li, Andy) On 10-23-2013 06:03
Topic:
Thanks for the reply Tomas!
I have already raised a ticket for the "vgn-appsvcs-cda.war" . The support team is already working to provide a solution for it. Till then I was trying to find a workaround for it.
The images in my application are getting rendered on the CMA environment and not on the CDS environment. We have not used the OpenText DPM/DSM but have used JSF(Primefaces).
I tried building “vgncdawar” but the already existing jar files were generated. Please correct me if I am wrong. Am I missing any step?
Please Help!!
Thanks!
There is not any issue in using Media CCE widget. Everything is good in your configuration as well.
For immediate fix you can check in your application server or webserver for docroot settings, it should point to delivery docroot. This you can solve from your application level.
If you are able to access this image from your webserver then there should not be any issue.
Thanks,
From: eLink Entry: Discussion Group - Web Experience Management [mailto:v7webcontentmanagement@elinkkc.opentext.com] Sent: Wednesday, October 23, 2013 5:18 PMTo: eLink RecipientSubject: RE RE Static File using Java Code
RE RE Static File using Java Code
Posted by ali@smg.sanmiguel.com.ph (Li, Andy) On 10-23-2013 07:42
The Full Image tag generated using the jsf code is :
<img width="960" height="350" vgn_ext_params="type=image/jpeg" alt="" name="vgn_ext_templ_rewrite?vgnextoid=5e285b5071211410VgnVCM1000000e01140aSTFL&vgnextmgmtpath=/file_source/vgn_ext_templ_rewrite" src="/file_source/BellTelWeb_Project/Slideshow/Slideshow_Images/samsung72.jpg"></img>
I have created a docroot while configuring the delivery stage and published the static files.
On publishing, the images get stored in the path specified during configuration of delivery stage.
The issue is that the images are being displayed on the management stage but not on the Delivery stage. May be there is some issue getting files fr om the delivery stage docroot.
Please correct me if i have missed any step.
I have used Media CCE widget for rendering the images and not ELJ.
Will it help if I use ELJ ? If yes, can you please help me in using ELJ as I have not done it before.
Andy