Skip to content

Instantly share code, notes, and snippets.

View aakash14goplani's full-sized avatar
🎯
Focusing

Aakash Goplani aakash14goplani

🎯
Focusing
View GitHub Profile
@aakash14goplani
aakash14goplani / shareAsset.md
Last active August 8, 2018 15:06
Share Assets from one site to other - OWCS

General steps to follow:

  1. Enable the asset type at target website.
  2. Pass c, cid and run=true from site entry (if run=false, or missing from site entry, assets won't be shared).
  3. Fetch the list of asset_id to be shared for the given asset_type
  4. From that list remove all the asset_id's that have been alredy shared (we don't want our element to load assets that are alredy been shared)
  5. Invoke asset:share tag fo all the asset_id's
  6. Prints the output in asset_id : asset_name format, also displays error's occured, if any and total number of successfully shared assets.
@aakash14goplani
aakash14goplani / shareAsset_API.jsp
Last active May 7, 2017 07:27
Share Assets from one site to other using API - OWCS
<%@page import="java.util.Arrays"%>
<%@page import="com.fatwire.services.AssetService"%>
<%@page import="com.fatwire.services.ServicesManager"%>
<%@page import="java.util.List"%>
<%@page import="java.util.ArrayList"%>
<%@page import="com.openmarket.xcelerate.asset.AssetIdImpl"%>
<%@page import="com.fatwire.system.SessionFactory"%>
<%@page import="com.fatwire.system.Session"%>
<%@ taglib prefix="cs" uri="futuretense_cs/ftcs1_0.tld"
%><%@ taglib prefix="asset" uri="futuretense_cs/asset.tld"
@aakash14goplani
aakash14goplani / Associations.md
Last active June 26, 2017 17:06
Associations

GENERAL STEPS TO FOLLOW:

  1. Load the asset (using asset:load tag)
  2. Get the association (using asset:children tag)
  3. Fetch attributes (by looping through list using ics:listloop tag)

Retrieving NAMED ASSOCIATIONS

<asset:load name="HomePage" type="Page" objectid='<%=ics.GetVar("cid")%>' site='<%=ics.GetVar("site")%>'/>
@aakash14goplani
aakash14goplani / List.md
Last active June 26, 2017 09:07
List Loop

To loop a list we make use of listloop tag

JAVA

IList list = ics.GetList("list_name");
int rows = list.numRows();
int cols = list.numColumns();
String columnName = "", columnValue = "";
out.println("Rows : " + rows + ", " + "Columns : " + cols + " for list " + list.getName() + " : " + list.hasData() + "<br/>");
@aakash14goplani
aakash14goplani / GetAssetInfoEJ.md
Last active June 10, 2018 09:42
Store asset information in JSON and load it using key value pair

What does this code do?

  1. Fetch all the details of asset using Asset API's read() method.
  2. Create JSON tree using JSON simple library and populate it with asset details from #1
  3. Print an JSON tree having all the asset details
<%@ taglib prefix="cs" uri="futuretense_cs/ftcs1_0.tld"
%><%@ taglib prefix="asset" uri="futuretense_cs/asset.tld"
%><%@ taglib prefix="ics" uri="futuretense_cs/ics.tld"
@aakash14goplani
aakash14goplani / Recommendation.md
Last active July 1, 2017 20:34
Engage Personalisation

Recommendation is the part of Engage Framework of OWCS. To work with recommendation we need to use commercecontext and vdm tags.

GENERAL STEPS TO FOLLOW

  1. Create Visitor Attributes and group them into segments
  2. Create a satellite:form to collect these visitor attributes
  3. Write an element to fetch visitor attributes from form and use them to load recommendations

fetch form values:

@aakash14goplani
aakash14goplani / flushVisitor.md
Last active June 26, 2017 14:27
Flush visitor data after 30 days

If you are using Engage, then is one caveat which needs to be taken care of:

"Data in visitor's tables can increase exponentially (obviously depends on how many times your site is visited) which can affect performance"

OWCS has no way to know which data is to be deleted and on what basis so basically you have to flush data from tables either manually or by programming.

Following sample code snippet can help to flush data after every 30 days:

<%@page import="java.util.Calendar"%>
@aakash14goplani
aakash14goplani / email.md
Last active June 26, 2017 15:51
Send Email Notifications

Purpose of this topic is to send email notfications to the users tat have created the assets but haven't modified them since last 30 days.

We can use javax mail service or send:mail tag to achieve this purpose.

Before we begin we need to make following changes to futuretense.ini file

futuretense.ini:cs.emailauthenticator=com.openmarket.framework.mail.ICSAuthenticator
futuretense.ini:cs.emailcontenttype=
futuretense.ini:cs.emailhost=smtp.gmail.com\:587
futuretense.ini:cs.emailaccount=
@aakash14goplani
aakash14goplani / AssetSearch.md
Last active September 30, 2017 21:04
Search Assets using Asset tags and API

In Oracle Webcenter Sites you get a situation where you need to write code to search for a specific assets based on their attribute’s values. There are two major ways to look for assets in oracle webcenter sites. One is to get list of assets based on the asset type and may be also based on some field values. If you want to look for some assets which has searched keyword in their attribute values. This topic is to demonstrate working of asset search using searchstate tag in case of flex assets and asset:search in case of basic assets.

General Steps to follow:

  1. Get the searched keyword from parameter key has been passed in request. Sometimes the parameter name could be very short which is not easily understandable for developer in the code level. So if this is the case you can go for a new variable to store searched keyword. Otherwise you can skip this step

  2. Create an empty search state with a constraint and it is taken by the assetset:setsearchedassets tag which does the search operation.

@aakash14goplani
aakash14goplani / AssetAPI_Delete.md
Last active June 26, 2017 15:29
DELETE operation using Asset API

General steps to follow

  1. Get handle for AssetDataManager which will act as a gateway to interact with Assets.
  2. Create unique AssetIdInstance using AssetIdImpl and AssetId from c and cid parameters, basis on which read operation would be performed.
  3. Call delete() method of AssetDataManager which actually performs delete operation.
<%@page import="com.openmarket.xcelerate.asset.AssetIdImpl"%>
<%@page import="java.util.Arrays"%>
<%@page import="com.fatwire.system.SessionFactory"%>