Friday, December 25, 2015

Adding unbookmark context menu

Authors are always trained to use bookmark function while creating or updating assets for associating assets to other asset in an attribute or association. Usually authors keep on bookmarking assets in Contributor UI for a site as they tend to bookmark asset frequently while creating or updating assets but often forget to unbookmark when work is completed.

If you double-click bookmarks node from left pane under "My Work" tab in Contributor UI, bookmarks list gets populated in center pane showing bookmarked assets for the current site. And if an author right-click's any asset or group of assets, he/she still sees bookmark option in context-menu but assets are already bookmarked and don't know how to unbookmark them! Should he/she unbookmark each asset one by one by opening them from Top Navigation - Content menu? Sounds boring and time consuming task.

Bookmarks Dashboard Widget

But wait, there is already OOTB dashboard in WebCenter Sites which also shows bookmarked assets and thus an author can unbookmark multiple assets at a time by either CTRL + CLICK for selective asset or Shift + Click for selecting all assets. That's it, multiple assets can be unbookmarked easily.

But in one of my recent project, there was a scenario wherein these dashboards were deleted so that Contributor UI loads faster as authors used to bookmark many assets, also many assets were assigned due to workflow and many assets were checked out. And thus, Contributor UI load time was really slow as many authors worked at same time on the Authoring Instance.

So now problem again was how can an author unbookmark multiple assets?
Well, with simple customization, one can provide unbookmark option in context menu which can help authors/contributors to unbookmark multiple assets again when assets are opened on double-clicking Bookmarks node under My Work tab. This customization is mentioned in guide here.

So basically, you just need to create either global or for a single site; a config element under CustomElements folder and write the following logic which will provide unbookmark option:

config.contextMenus = {
  "default":["bookmark", "unbookmark", "tagasset", "delete"],
  "asset":["edit", "copy", "preview", "share", "delete", "bookmark", "unbookmark", "tagasset"],
  "asset/Page":["edit", "copy", "preview", "delete", "bookmark", "unbookmark", "tagasset"],
  "proxy":["preview", "bookmark", "unbookmark", "tagasset", "delete"]
};

I tested it for avisports site by updating CustomElements/avisports/UI/Config/SiteConfigHtml element and it works well. That's it, problem solved. Now authors/contributors can bookmark and unbookmark as many assets as they desire.  

Unbookmark multiple assets

Note: After unbookmarking asset in list pane, one has to reload list pane so that only bookmarked assets are visible by either double-clicking again on Bookmarks node or by clicking on refresh buttom from right side.

Disclaimer: Any sample code on this blog is not officially recommended, use at your own risk.

Tuesday, December 22, 2015

Resolving missing dimension relationship

In one of my previous project on Oracle WCS 11g 8, I faced several times the problem of missing translation among master and translated assets for many assets after using Realtime Publishing. No matter how tedious or careful I was to publish first only master assets and then publish other translated assets, either due to dependency not all master assets were published or somehow did not published the translation link between master and translated asset. In such scenario, there is no other option than to write a simple utility to create a dimension relationship link between them again.

Steps to resolve this issue is:
  1. Find the assets which are missing this translation link among assets. In order to do that, compare the <AssetType>_DimP tables between source and destination instances after running the following query using Support Tools or using some utility element:
    Select CS_OWNERID, CS_DIMENSIONPARENTID from <AssetType>_DimP where CS_OWNERID!=CS_DIMENSIONPARENTID
  2. Important columns are CS_OWNERID (translated assetid) and CS_DIMENSIONPARENTID (master assetid)
  3. List down the assets which are not present on your destination instance by comparing. I prefer the following final format to update dimension relationship for multiple assets of a particular assettype: <TranslatedId1>,<MasterId1>;<TranslatedId2>,<MasterId2>... 
Once you have the above string, create one template (applies to various assettypes, can be called externally from browser or as layout) and add the following code:

Hit the url: [hostname]:[port]/[sites context]/ContentServer?pagename=[Sitename where template was created]/[YourTemplateName]&assetType=[AssetType] 
for e.g. http://localhost:9080/cs/ContentServer?pagename=FirstSiteII/ResolveMissingTranslations&assetType=Product_C
and wait for the output.

Sometimes, even after running the above code may not update all assets because there can be 2 translated assets supposed to be associated to same master asset and <asset:save> tag will not able to save the asset for both in same request. So, just run the utility again for the failed ones and that should resolve the issue. Compare again by running the same above query and the result should be same. Check in contributor UI to cross-check if dimension relationship was generated or not.

NOTE: You have to run this utility for all the affected assets of different assets types separately.
 
Disclaimer: Any sample code on this blog is not officially recommended, use at your own risk.

A simple code compare functionality

One of the most important aspect of any development cycle is deployment and while deployment, it is very important to note the changes don...