cancel
Showing results for 
Search instead for 
Did you mean: 

Generate surrogate ID

Former Member
0 Kudos
55

Hi, all!

Does anybody suggests how to generate surrogate value for property ID when uploading file in folder?

By default the property is set by filename and I need to change this behavior.

bestRegards

Michael

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

hi michael,

do you mean that after the upload you would like to change some certain property? in this case you might want to write a small aplication - km repository service which would "react" on this event and substitute the km property in question. if you want i can send you a sample par file (dsurkov/at/btexx.de).

regards,

dimitry

Former Member
0 Kudos

Thank you, Dimitry

Please send the example to

<banned>

Message was edited by: Michail Evreyson

Former Member
0 Kudos

The implementation class example:


package com.btexx.repservice.example;

import com.sapportals.wcm.WcmException;
import com.sapportals.wcm.crt.component.*;
import com.sapportals.wcm.crt.configuration.ConfigurationException;
import com.sapportals.wcm.crt.configuration.IConfiguration;
import com.sapportals.wcm.repository.*;
import com.sapportals.wcm.repository.manager.*;
import com.sapportals.wcm.repository.service.AbstractRepositoryService;
import com.sapportals.wcm.repository.service.ServiceNotAvailableException;
import com.sapportals.wcm.util.events.IEvent;
import com.sapportals.wcm.util.uri.RID;
import java.util.Collection;
import java.util.Iterator;

public class ServiceExample extends AbstractRepositoryService
	implements IReconfigurable, IResourceEventReceiver
{

	public ServiceExample()
	{
	}

	public String getServiceType()
	{
		return TYPE;
	}

	protected void startUpImpl(Collection repositoryManagers)
		throws ConfigurationException, StartupException
	{
		this.repositoryManagers = repositoryManagers;
		for(Iterator it = repositoryManagers.iterator(); it.hasNext();)
			try
			{
				addRepositoryAssignment((IRepositoryManager)it.next());
			}
			catch(ServiceNotAvailableException e)
			{
				e.printStackTrace();
			}

	}

	protected void shutDownImpl()
	{
		for(Iterator it = repositoryManagers.iterator(); it.hasNext();)
			try
			{
				removeRepositoryAssignment((IRepositoryManager)it.next());
			}
			catch(WcmException e)
			{
				e.printStackTrace();
			}

	}

	protected void addRepositoryAssignment(IRepositoryManager mgr)
		throws ServiceNotAvailableException
	{
		try
		{
			mgr.getEventBroker().register(this, new ResourceEvent(311, null));
		}
		catch(WcmException e)
		{
			e.printStackTrace();
		}
	}

	protected void removeRepositoryAssignment(IRepositoryManager irepositorymanager)
		throws WcmException
	{
	}

	public void reconfigure(IConfiguration config)
		throws ConfigurationException
	{
		super.stateHandler.preReconfigure();
		super.config = config;
		super.stateHandler.postReconfigure();
	}

	public void received(IEvent event)
	{
		IResource resource = (IResource)event.getParameter();
		// check for event.getType() ->
		// changes on the resource... e.g. change of the display name
	}

	private static final String TYPE = "ServiceExample";
	private Collection repositoryManagers;
}

+ repository framework wrapper service


package com.btexx.repservice.example;
 
import com.sapportals.portal.prt.service.IServiceContext;
import com.sapportals.wcm.crt.CrtClassLoaderRegistry;

  public class RFWS implements IRFWS{

  private IServiceContext mm_serviceContext;

  public void init(IServiceContext serviceContext)
  {
	CrtClassLoaderRegistry.addClassLoader(getKey(), getClass().getClassLoader());
    mm_serviceContext = serviceContext;
  }

  public void afterInit()
  {
  }

  public void configure(com.sapportals.portal.prt.service.IServiceConfiguration configuration)
  {
  }

  public void destroy()
  {
  }

  public void release()
  {
  }

  public IServiceContext getContext()
  {
    return mm_serviceContext;
  }

  public String getKey()
  {
    return KEY;
  }

}

+ configuration xml under install\data\cm\repository_services\com.btexx.repservice.example


 <?xml version="1.0" encoding="UTF-8" ?> 
- <Configurable configclass="com.btexx.repservice.example.ServiceExample">
  <property name="name" value="com.btexx.repservice.example.ServiceExample" /> 
  <property name="active" value="true" /> 
  <property name="description" /> 
  </Configurable>

regards,

ds