Uploading static file (image) in webcenter portal for template

Requirement – I have seen many people asking in OTN forum regarding, how to upload with page template or with skin in webcenter. Today sharing with you all.

In wcp 11.1.1.8 normally you don’t have check box to upload content directory with images, javascript or some static file in portal. If you export some asset in WCP from jdeveloper,
Normally template is uploaded but not image.I will take an example of images in this. I created an custom template with some image for mobile.I want to upload back in WCP using round trip
development.

Normally in old wcp version in shared folder , we have all static files or images.Oracle says about this

Legacy directory in MDS for images and content used by assets, such as, icons, images, and so on.Oracle recommends that you relocate all such artifacts to
your content server and that you use a folder structure on your content server specifically for asset artifacts so that content is easy to identify and move, if required.
If you choose not to move artifacts stored in MDS, your administrator can use the MDS WLST commands exportMetadata/importMetadata to migrate content to and from MDS.

So there are two option

1) – Upload in WCC (Webcenter content) – You can upload these document in wcc with some marking and use in webcenter portal. You can use images in WCP as by my previous article.
Display UCM files in ADF/Webcenter application as images or link

– I uploaded techartifact logo in wcc

WCCCheckIn

– I created custom template and added image in that. Source of image is like below

#{WCAppContext.applicationURL}/content/conn/ucmserver/uuid/dDocName%3aAPPLOGO1

imgeSource

APPLOGO1 – content id of document. Read my previous article

That’s it. In this way you can use images in template or skin.

2) – Upload manually in MDS using exportMetadata/importMetadata command – These command is very helpful in working metadata in weblogic. Read my previous article

While creating assest for WCP in jdeveloper, if you put images in shared folder and in below structure

jdeveloperStructure

Then you can use importMetadata command to import image in MDS. for exmaple

importMetadata(application=’webcenter’, server=’WC_Spaces’,fromLocation=’/home/oracle/temp’,docs=’/**’)

– /home/oracle/temp= On this location there is same folder structure like ‘oracle\webcenter\siteresources\scopedMD\shared\images’ . inside image folder , you can put your all images.
and run it

Steps

– run wlst.sh or wlst.cmd under webcenter installtion location
– connect(‘weblogic’,’pwd’,’t3://:7001′)
– importMetadata(application=’webcenter’, server=’WC_Spaces’,fromLocation=’/home/oracle/temp’,docs=’/**’)

Note:In this case, image source in jdeveloper will point to oracle\webcenter\siteresources\scopedMD\shared\images folder and so on..

Final output of template is as below

phone template

That’s it.. By this way you can upload your images.

Happy Learning with Vinay in techartifact…..

How to create custom component in Webcenter Content (UCM)

Requirement – How to Create a UCM custom component

Solutions- Please follow the below steps –

Starting the componentWizard – CD to the path where the component wizard is.
[[email protected] ~]$ cd /oracle/Middleware/user_projects/domains/ucm_domain/ucm/cs/bin // this path will of your weblogic domain
[[email protected] bin]$ ./ComponentWizard

1. Goto Options -> Add
You get the below window.
Fill in the component Name. Click OK.

111

You get below screen.
Custom component gets created here (path may be different for you)
/oracle/ecm/ucm_domain/ucm/cs/custom
The component is created and you can add resources by clicking Add.

222

1. Select service. Click next.

333

Fill in the Name of the Service, Service class, Template. Fill in access levels.
Add actions by clicking on Add.

444

5555

Click OK. Click Finish.

Similarly Add a Resource.

666

image

Resources created
demo_component_resource.htm
demo_component_service.htm
demo_component.hda

Modify the resource.htm as below. Give the Service name, handler name and search order.
The handler name is the fully qualified name of the java file where the service method (printTheName()) is created.

Place the compiled java class file in the classes folder inside the custom component.
cs/custom/demo_component/classes/de/xyz/ucm/service

7777

8888

9999

Build the component to create the manifest.hda file. Demo_component.zip is created that can now be installed on other UCM and used.
Build by clicking on Build.

10000

1212212121212

Enable the component.

1313131313

Hit the browser with the service Name and required parameters
http://192.168.0.118:16200/cs/idcplg?IdcService=PRINT_THE_NAME&IsJava=1&dDocName=HO051621920
My java code is as below. (Calls a standard UCM service from my custom service)

package de.xyz.ucm.service;

import java.io.File;
import java.io.IOException;
import intradoc.common.ExecutionContext;
import intradoc.common.LocaleUtils;
import intradoc.common.Log;
import intradoc.common.ServiceException;
import intradoc.common.SystemUtils;
import intradoc.data.DataBinder;
import intradoc.data.DataException;
import intradoc.data.DataResultSet;
import intradoc.data.ResultSet;
import intradoc.data.Workspace;
import intradoc.provider.Provider;
import intradoc.provider.Providers;
import intradoc.server.Service;
import intradoc.server.ServiceData;
import intradoc.server.ServiceHandler;
import intradoc.server.ServiceManager;
import intradoc.server.UserStorage;
import intradoc.shared.SharedObjects;
import intradoc.shared.UserData;

public class PrintingNames extends ServiceHandler{
	public void printTheName() throws DataException, ServiceException
	{
		
	Log.info("Start printing name"+ true);
	String Docname = m_binder.getLocal("dDocName");
	String serviceName = "DOC_INFO_BY_NAME";
    String userName = m_binder.getLocal("dUser");
    Log.info("environment "+m_binder.getEnvironment());
    Log.info("shared obj val"+SharedObjects.getEnvironmentValue("IntradocServerPort"));
	DataBinder requestBinder = new DataBinder();
	requestBinder.putLocal("dDocName", Docname);
	requestBinder.putLocal("IdcService", serviceName);
	
	
	executeService(requestBinder,"sysadmin",false);	
    final ResultSet docinforesultset = requestBinder.getResultSet("DOC_INFO");
    DataResultSet docinfodataresultset = (DataResultSet)requestBinder.getResultSet("DOC_INFO");

 
	DataResultSet result = new DataResultSet();
	result.copy(docinforesultset);
	
	m_binder.putLocal("Message", "Name printed");
	m_binder.addResultSet("demo_resultset1", docinforesultset);
	m_binder.addResultSet("demo_resultset2", docinfodataresultset);
	Log.info("Finished printing name");

	}
	
	public void executeService(DataBinder binder, String userName, boolean suppressServiceError)
	        throws DataException, ServiceException
	    {       
	        ServiceException error;
	        Workspace workspace = getSystemWorkspace();
	        String cmd = binder.getLocal("IdcService");
	        if(cmd == null)
	            throw new DataException("!csIdcServiceMissing");
	        ServiceData serviceData = ServiceManager.getFullService(cmd);
	        if(serviceData == null)
	            throw new DataException(LocaleUtils.encodeMessage("!csNoServiceDefined", null, cmd));
	        Service service = ServiceManager.createService(serviceData.m_classID, workspace, null, binder, serviceData);
	        UserData fullUserData = getFullUserData(userName, service, workspace);
	        service.setUserData(fullUserData);
	        binder.m_environment.put("REMOTE_USER", userName);
	        error = null;
	        try
	        {
	            service.setSendFlags(true, true);
	            service.initDelegatedObjects();
	            service.globalSecurityCheck();
	            service.preActions();
	            service.doActions();
	            service.postActions();
	            service.updateSubjectInformation(true);
	            service.updateTopicInformation(binder);
	      
	        }
	        catch(ServiceException e)
	        {
	            error = e;
	        }
	        finally{
	        service.cleanUp(true);
	        workspace.releaseConnection();
	        }
	        if(error != null)
	            if(suppressServiceError)
	            {
	                error.printStackTrace();
	                if(binder.getLocal("StatusCode") == null)
	                {
	                    binder.putLocal("StatusCode", String.valueOf(error.m_errorCode));
	                    binder.putLocal("StatusMessage", error.getMessage());
	                }
	            } else
	            {
	                throw new ServiceException(error.m_errorCode, error.getMessage());
	            }
	        return;
	    }
	
	public UserData getFullUserData(String userName, ExecutionContext cxt, Workspace ws)
	        throws DataException, ServiceException
	    {
	        if(ws == null)
	            ws = getSystemWorkspace();
	        UserData userData = UserStorage.retrieveUserDatabaseProfileDataFull(userName, ws, null, cxt, true, true);
	        ws.releaseConnection();
	        return userData;
	    }
	
	public static Workspace getSystemWorkspace()
    {
        Workspace workspace = null;
        Provider wsProvider = Providers.getProvider("SystemDatabase");
        if (wsProvider != null)
        {
            workspace = (Workspace) wsProvider.getProvider();
        }
        return workspace;
    }
}

Happy coding with Vinay Kumar in Techartifact…..