Translate

Showing posts with label fatwire. Show all posts
Showing posts with label fatwire. Show all posts

Tuesday, December 15, 2015

Using PreUpdate or PostUpdate element for flex asset

In WebCenter Sites, whenever an asset is added/read/edited/deleted, many elements are called internally before an asset's CRUD operations are performed. These elements are stored under OpenMarket/Xcelerate/AssetType/[Your custom AssetType] folder.

Among the elements, PreUpdate and PostUpdate are called many times whenever any CRUD operations are performed on an asset. Hence, if any custom update is required either before or after an asset is saved in database, you can write your logic in PreUpdate element (before saving) or in PostUpdate element (after save).

Details related to which method should be updated is clearly mentioned in Developer's Guide. As not much detail is present in guide for any implementation or usage, I am discussing one very simple use case which is very common ask by any Client.

USE CASE:
If an asset is created in one site, it should be shared automatically with other sites. This is very practical and generic requirement for e.g. client may want to show News (all English ones) from all sites in other site's English version of News page or global site's News page.

Let us consider that there are 2 sites - FirstSite and FirstSite II, and both sites have product family and corresponding other child flex families. If a product asset of type - FSII Audio is created in FirstSite, it should be automatically shared with FirstSite II and vice-versa.

At first glance, this use case seems very easy and one can think of implementing a custom asset listener by updating the assetAdded method. But there is a catch; it seems that there is one bug that one cannot fetch asset subtype value using any method in asset listener while an asset is created and thus, cannot share only that asset whose type (definition) is FSII Audio. As asset is not saved in database at the time of call of asset listener, it does not have any way to retrieve asset's subtype value (or other custom attribute values) and hence, fails to meet the purpose. In such scenario, either you have to write flex filter or update that element which will be called just before an asset is shown in contributor UI after its created. How to develop flex filter is mentioned in detail in Developer's Guide, I have provided steps for updating core element method.

Elements while are called while CRUD operations for Product_C are located under "OpenMarket/Xcelerate/AssetType/Product_C/" folder. Create/Update element calls the PreUpdate and PostUpdate elements just before saving and after saving asset respectively. Hence, you can update one of the element to perform the task of sharing the asset. As we want to update asset based on subtype, PostUpdate element is most suitable option for this task as database entry has the subtype value present for the asset before PostUpdate element is called.

STEPS:
  1. Internally, PostUpdate element for each AssetType folder calls the element: OpenMarket/Gator/FlexibleAsset/Common/PostUpdate. PostUpdate is xml file containing various checks on operations like create, delete, update, remotepost, etc. These operations are briefly defined in developer's guide.
  2. If you are using Windows and have access to Sites Explorer, then navigate to the element and edit using desired text editor.
  3. If you are using Mac or Linux, one cannot use Sites Explorer, so just create new CSElement with same name and the element code will be visible in the element tab.
  4. In our case, need to add your code under "create" condition.
  5. As writing code in XML can be difficult and cannot use any JAVA within XML, call your JSP element using <CALLELEMENT> tag under Variable.updatetype=create condition and write your logic in JSP element to share the asset.
  6. You have the following ics variables available: AssetType as asset type and id as asset id, which can be used to find the subtype using <asset:getsubtype> tag and then this current asset can be shared using <asset:share> tag. You don't need to use <asset:save> tag.
  7. Save your element and test by creating new asset. As soon as product asset of type FSIIAudio is saved, it will be shared to the sites according to your code.
CAVEATS:
  1. As this is a type of customization, one has to keep track of such elements in event of upgrades in future and update accordingly after upgrade.
  2. Always keep backup of original element before updating any core element as it may or may not behave as intended.
  3. If an user has access to only one site say FirstSite and creates FSIIAudio product asset, it will be shared to FirstSite II also, according to our implementation. But if the same user wants to unshare/delete this asset, then he/she will not be able to do so as share function will not be accessible to unshare and/or then delete the asset. In such scenario, either you have to develop  custom unshare/delete button or user has to request the admin editor, who has access to all sites, to unshare/delete the asset. For creating custom button, you can check my post.
----------------------------------------------------
SUGGESTIONS/COMMENTS ARE INVITED
----------------------------------------------------

Sunday, June 21, 2015

Creating a simple custom WEM application

WEM - Web Experience management is a feature in webcenter sites/fatwire where in separate module can be implemented/deployed to integrate external content/repository via REST API or by deploying applications. All possible use of this feature are listed and discussed in detail here (Developer's Guide).

One feature is available to test and deploy: Articles Sample application (which can be downloaded  from Oracle edelivery site). Although following the steps given in guide should be enough, there are few errors and less info available for known issues. I am listing those so that you can make the changes and make it work:

1. SSO authentication failure (multi cast port not updated). Open the file: cas-cache.xml present at /WEB-INF/classes/cas-cache.xml and search for the term -"multicastGroupPort=@casCacheMultiCastGroupPort@" and change it to "multicastGroupPort=<SOME PORT NUMBER>". Re-deploy articles-1.0.war and run install.app

2. If you are not able to run install.app, then after deploying article-1.0.war file, register your app manually as mentioned here. There are few issues even after registering manually:

  • Not able to find app icon: To resolve this either you keep the icon within /cs/ folder of your application server directory and update your FW_Application or else update your FW_Application icon url to "../articles-1.0/images/articles.png"
  • Other issue is after each login on JSK, you have to run install.app and also there are multiple http redirects made leading to errors. To resolve this, rather than deploying the article-1.0.war file, unzip the folder under <APP_SERVER>/webapps/ folder and update your FW_Application accordingly. More details present here in oracle community. 
Although sample is present, it is little complex to understand it as it requires good knowledge on how controller works and creating app & assets programatically. But there is another simpler way to create and test WEM app. As a FatWire/Oracle Webcenter Sites consultant, often challenges are met with developing custom solutions which are useful for content contributors and administrators. For eg: Mass edit/save/update/delete/sharing assets, managing roles and ACLs, searching assets on attributes, etc. Such tools/solutions are often created as CSElement+SiteEntry where SiteEntry is called via browser to perform the task. If a project has so many custom requirements, I think it is better to have them separately in another WEM app which would be available to only permitted users. By doing so, custom admin tasks are separated from normal users and is secure as the solution is not exposed. I won't be telling you how to create these custom tools but rather about how to create a simple custom WEM app as followed:

Step 1: Create one typeless-template which should have the following code within the default code:
<div id="myapp" style="float:left;height:100%;width:100%" class="wemholder"></div>

This would be your layout element which would be included while creating FW_Application asset. Note: This id - myapp is important as it would be added to field: parent node while creating FW_View asset and should be unique.

Step 2: Create another typeless-template which will include your code to render the content. This content can come from anywhere like REST API, 3rd party api, etc. In our example, I will just include and proceed with Sample site URL present in JSK which shows the number of sites present and two sample sites urls to access sites: http://localhost:8080/cs/ContentServer?pagename=OpenMarket/Demos/index



This url would be added in the element while creating FW_View asset. 

Step 3: Download an icon (.gif or .png) from internet for your app and place it under some folder in <webapps>/cs/ folder

Step 4: Go to AdminSite, create new asset of Type: FW_View, fill in all the details like name, parent node (value would the id present in layout template i.e. myapp), view type: iframe and source url: sample site url. It should look like the following:


Step 5: After creating FW_View asset, add it to active list/bookmark it or it should be available in HISTORY tab if you did not navigate to other site or logged out. Create new FW_Application asset, include your FW_View asset and fill in all the details which should end like the following:


Step 6: Navigate to WEM Admin in AdminSite and register your app for avisports. Click on Apps from top menu and hover over you MyApp app, you will get 2 options: Edit and Manage App. Select Manage App, select site/s & role and then save it. I selected avisports and assigned all roles. Select site - avisports, an icon should be now visible for you to click on to open your WEM app. Overall you should see like below:

Similarly, any webcenter sites content or small functionality can be shown.

----------------------------------------------------
SUGGESTIONS/COMMENTS ARE INVITED
----------------------------------------------------

Thursday, November 21, 2013

WebCenter Sites / FatWire customizations - FULL LIST

Customization is fun. You achieve something which was never done by someone and you feel proud to share that you are the first one to do so. In my past few projects, I was able to do something like that and hence, I would like to share those.

This are all my personal views, findings and suggestions. These are not guidelines to meet you client expectations. Although if there is something you want to ask, I am ready to help.

As I move forward learning new things in Oracle WebCenter Sites and FatWire, I would like to share some brief idea/overview/illustrations about them. This blog contains full list of customization (be it UI and/or Functionality) which I know till date and will keep on sharing as I learn. 

FULL LISTING:
  1. UI Customization: Changing icons in FatWire/Oracle WebCenter Sites 
  2. UI Customization: Creating a simple custom WEM app 
  3. UI Customization: Creating a custom tree tab
  4. UI/Functionality Customization: PreUpdate/PostUpdate element
  5. Functionality Customization: Creating custom Dashboard
  6. Functionality Customization: Customize CKEditor Toolbar
  7. UI Customization: Adding unbookmark context menu
  8. Functionality Customization: Custom event for assets approval
  9. UI Customization: Thumbnail Search View Customization
  10. Functionality Customization: Creating a custom event listener 
  11. Functionality Customization: Customizing workflow
  12. UI/Functionality Customization: Creating custom button
  13. UI Customization: Creating custom alert message
  14. UI Customization: Adding unbookmark context menu
  15. Functionality Customization: Automatic approval of assets 
  16. UI/Functionality Customization: Proxy Assets (Google Map) 
  17. UI/Functionality Customization: Gadgets
Do check my other blogs for more:  Sample Codes & FatWire/Oracle WebCenter Sites development