Tuesday, 5 July 2016

Copy content from one location to another location via WCM API

Agenda :- How to copy the content from location to other location via custom workflow using WCM API.


Step1 :- Create a custom workflow action where you have to move contents from one location to another location

Document document1 = ws.copy(document.getId(), docid);

Parameter1 :- 'document.getId()' this is the document which need to be copied to some other location.
Parameter2 :- docid this is document id of sitearea when the document need to be copied. You can utilize workspace methods like getByName or findByPath to retrieve the site area documentId.


ws - workspace object


Step2 :- You can verify the newly created content by printing the title of new content(document1.getTitle()).


Note :- There is one more optional overloaded parameter CopyOptions using which properties of copied contents can be modified for example changing author of the copied content.

Understanding JMS in websphere application server and integrate with WCM

JMS :- In a laymen terms we can send messages asking it to store. Later concern person will consume it. By which we can create a intermediate layer where messages can be stored asynchronously and consumed later for further use.

WCM :- Messages or events that can be captured from WCM. We will apply above JMS concepts to catch below events

Item events:
Item created
Item updated
Item moved
Item deleted

Syndication events:
Starting
Stopping

Pre-render events:
Starting
Stopping

Command to enable it :-
./ConfigEngine.sh create-wcm-jms-resources -DPortalAdminId=username -DPortalAdminPwd=password -DuseRemoteEndPoints=true/false


Suggested links :-
http://www-01.ibm.com/support/docview.wss?uid=swg27036467&aid=1

Rendering plugin adding parameters to plugin WCM

Rendering Plugin :- By implementing RenderingPlugin new plugin can be created in WCM. But to include parameters into the plugin implementing RenderingPlugin alone is not sufficient. Need to
implement RenderingPluginDefinition also which internally implements RenderingPlugin.


New methods need to be implemented:-
@Override
public List<RenderingPluginParameter> getParameters() {
ArrayList arrayList = new ArrayList();
    //add all parameters required in the list
arrayList .add(new EmbededURLFormatterPlugin.URLRenderingPluginParameter("parameterName").required(Required.REQUIRED));
return arrayList ;
}


New class that need to be created :- For sever versions lower than 8.5
public class RenderingPluginTypes
implements RenderingPluginType
{
public static final RenderingPluginTypes URL_RENDERING_PLUGIN_TYPE = new RenderingPluginTypes();

public String getDescription(Locale paramLocale)
{
  return "URL_PLUGIN_TYPE_DESCRIPTION";
}

public ListModel<Locale> getLocales()
{
  return null;
}

public String getTitle(Locale paramLocale)
{
  return "URL_PLUGIN_TYPE_TITLE";
}

public String getName()
{
  return "URL";
}
}


Final output:- Try opening any editor in wcm then insert the plugin which provides below output depending on your plugin name.

[Plugin:pluginName parameterName=""] [/Plugin:pluginName]

Custom single threaded java server

 package com.diffengine.csv; import java.io.*; import java.net.*; import java.util.Date; public class Server { public static void main(Str...