lunes, 22 de febrero de 2016

WCC: Check if Framework Folders is enabled using RIDC

Useful snippet of code for check if your WebCenter Content is using Folders_g or Framework Folders as the Foldering Service in your RIDC Code.

The clue is the use of CONFIG_INFO IDC Service.

private synchronized void checkFrameworkFoldersEnabled() throws IdcClientException {
    final String METHOD_NAME = "checkFrameworkFoldersEnabled";
    logger.entering(CLASS_NAME, METHOD_NAME);
    // Get IdcClient and IdcContext if necessary
 if (!configChecked) {
        DataBinder binder = idcClient.createBinder();
        binder.putLocal("IdcService", "CONFIG_INFO");
        DataBinder rb = idcClient.sendRequest(defaultIdcContext, binder).getResponseAsBinder();
        DataResultSet resultSet = rb.getResultSet("EnabledComponents");
        List<DataObject> components = resultSet.getRows();
        for (DataObject component : components) {
            if (("FrameworkFolders".equals(component.get("name"))) && ("Enabled".equals(component.get("status")))) {
                folderingService = "FrameworkFolders";
                break;
            }
            if (("Folders_g".equals(component.get("name"))) && ("Enabled".equals(component.get("status")))) {
                folderingService = "Folders_g";
                break;
            }
        }
        if (folderingService == null) {
            if (logger.isWarning()) {
                logger.warning(CLASS_NAME, METHOD_NAME, "Not able to determine Foldering Service on Content Server, defaulting to Folders_g");
            }
            folderingService =  "Folders_g";
        }
        configChecked = true;
    }
    if (logger.isInfo()) {
        logger.info(CLASS_NAME, METHOD_NAME, "Current RIDC Foldering Service: " + folderingService);
    }
    logger.exiting(CLASS_NAME, METHOD_NAME);
}

domingo, 21 de febrero de 2016

WCC: The power of GET_FS_DOC_INFO service

GET_FS_DOC_INFO service is an IDC Service that I used in some of my solutions.
It provides very useful information regarding to the URLs and Paths of the Documents in WebCenter Content.
IsSoap=1 Output of GET_FS_DOC_INFO

This service requires the following Input Paramters:
  • dID: Specific Revision ID of the document
Why is it too nice this service? :). It retrieves the following useful information:
  • relativeURL: Relative URL to Web Layout File
  • containerLocation: File System Path to the File (without the file name)
  • renditionFiles: In case of having attachments!
  • absoluteURL: Absolute URL to the Web Layout File
  • webViewableFile: File System Path location of the Web Viewable Format
  • primaryFile: File System Path location of the Native Format
References (Thanks Jonathan and Sonal):
http://contentmgmtsys.blogspot.com/2015/04/ucm-retrieve-vault-and-weblayout-path.html 

WCP: Get the Page Variants of a Page

I decided to create this blog post based on a quesiton I found on OTN WebCenter Portal Forum.

How to retrieve the Page Variants from a given Page Path programatically?

Page Variants are created in the same folder of the Page and it uses the following naming convenion:

[Source Page Name] +  "_" + [Device Group Name] + "jspx" 

Using the following code snippet you can get the Page Variants for the Current Page and then modify it as desired :)
public void changeVariantsOfCurrentPage() {
  // Get Page Service for editing Page Attributes
  PageService pageService = getEditModePageService(); 
  // Get Current Page Path
  final String pagePath = (String)ADFContext.getCurrent().getExpressionEvaluator().evaluate("#{pageDocBean.pagePath}");
  if ((pagePath != null) && (pagePath.length() > 0)) {
  // For each possible Device Agent detect if it has a pageVariant
  List<DeviceGroup> allDeviceGroups = getAllDeviceGroups();
  for (DeviceGroup dg : allDevicesGroups) {
   int iLastSlash = pagePath.lastIndexOf('/');
   int iLastDot = pagePath.lastIndexOf('.');
   String srcFolderPath = pagePath.substring(0, iLastSlash + 1);
   String srcPageName = pagePath.substring(iLastSlash + 1, iLastDot);
   String newPageTitle = pageService.getPage(pagePath).getTitle();
   String pageNameFormat = srcPageName + "_" + dg.getName() + ".jspx";
   String variantPagePath = srcFolderPath + pageNameFormat;
   PageDef variantPage = getEditModePageService().getPageDefAttributes(variantPagePath);
   // TODO: Check if it is not null and apply changes
   pageService.updatePageDefAttributes(variantPage);
   pageService.saveChanges();
  }
 }
}

private PageService getEditModePageService() {
    if (this.pageService == null) {
      MDSSession sess = getEditModeMDSSession();
      this.pageService = PageServiceFactory.createInstance(new PageServiceConfig(sess, ServiceContext().getContext().getScope().getName()));
    }
    return this.pageService;
  }

private MDSSession getEditModeMDSSession() {
    if (this.editSess == null) {
      this.editSess = WCApplicationContext.getCurrentInstance().createEditModeMDSSession();
    }
    return this.editSess;
}


private List<DeviceGroup> getAllDeviceGroups() {
    List<DeviceGroup> deviceGroups = null;
    try {
      DeviceSupport deviceSupport = DeviceSupport.getInstance();
      deviceGroups = deviceSupport.getAllDeviceGroups(ServiceContext.getContext().getScope());
    }
    catch (Exception e) {
  // TODO: Log
    }
    return deviceGroups;
}

sábado, 20 de febrero de 2016

WCC: Folders_g to FrameworkFolders Quick Reference

Planning to migrate from Folders_g to Framework Folders? If so then find here a useful tables about how to migrate you RIDC code to be compatible with Framework Folders.

Parameters Mapping  

Parameter in Folders_g
Parameter in Framework Folders
dCollectionPath
path
dCollectionID
fFolderGUID
dCollectionName
fFolderName
dSecurityGroup
fSecurityGroup
dParentCollectionID
fParentGUID
xCollectionID
parent
dCollectionOwner
fOwner
dCollectionCreator
fCreator
dCollectionModifier
fLastModifier
dDocAccount
fDocAccount
dLinkID
fLinkID
dLinkName
fLinkName
dCreateDate
fCreateDate
dLastModifiedDate
fLastModifiedDate
todCollectionID
destination
todCollectionPath
destination
toContentName
fFileName
xClbraUserList
fClbraUserList
xClbraRoleList
fClbraRoleList
xClbraAliasList
fClbraAliasList
dCollectionType
fFolderType

Note: The metadata not appearing in the above table uses the same name in both (if I did not miss it!).

Services Mapping

IDC Service in Folders_g
IDC Service in Framework Folders
COLLECTION_ADD
FLD_CREATE_FOLDER
COLLECTION_ADD_LINK
FLD_CREATE_FOLDER
COLLECTION_BROWSE
FLD_INFO
COLLECTION_CHECKIN_NEW
FLD_CREATE_FILE
COLLECTION_COPY_COLLECTION
FLD_COPY
COLLECTION_COPY_ITEM
FLD_COPY
COLLECTION_COPY_LOT
FLD_COPY
COLLECTION_DELETE
FLD_DELETE
COLLECTION_DELETE_ITEM
FLD_DELETE
COLLECTION_DELETE_LOT
FLD_DELETE
COLLECTION_DISPLAY
FLD_BROWSE
COLLECTION_GET_COLLECTIONS
FLD_RETRIEVE_CHILD_FOLDERS
COLLECTION_GET_CONTENTS
FLD_RETRIEVE_CHILD_FILES
COLLECTION_GET_LINKS
FLD_INFO
COLLECTION_GET_REFERENCE
FLD_INFO
COLLECTION_INFO
FLD_INFO
COLLECTION_MOVE_ALL
FLD_MOVE
COLLECTION_MOVE_COLLECTION
FLD_MOVE
COLLECTION_MOVE_ITEM
FLD_EDIT_FILE
COLLECTION_MOVE_LOT
FLD_MOVE
COLLECTION_SEARCH_RESULTS
FLD_FOLDER_SEARCH
COLLECTION_UPDATE
FLD_EDIT_FOLDER
COLLECTION_UPDATE_META
FLD_PROPAGATE
COLLECTION_UPDATE_ADMIN_METADATA_DEFAULTS
FLD_EDIT_METADATA_RULES
VCR_FOLDER_INFO
FLD_VCR_FOLDER_INFO
GET_FOLDER_HISTORY_REPORT
FLD_GET_FOLDER_HISTORY

Result Sets 

Result Sets in Folders_g
Result Sets in Framework Folders
COLLECTIONS
ChildFolders
CONTENTS
ChildFiles

References:
Mapping of Folders_g Services with FrameworkFolders Services