Hello all ,
I am trying to create a move command that doesnu2019t need the u201Cdelete leafu201D authorization.
For this Iu2019ve done two things . Iu2019ve downloaded the flexibleUiExample project . and decompiled the UIMoveCommand .
I created a class called(that will be called) UiAltMoveCommand in the FlexibleUIExample par , altered the xmls but I am getting the folloing error on the default trace:
Full Message Text Could not create command with alias SimpleExampleScreenflowCommand and classname br.com.customer.uicommand.SimpleScreenflowCommand:java.lang.ClassNotFoundException: br.com.customer.uicommand.SimpleScreenflowCommand at com.sapportals.wcm.crt.CrtClassLoaderRegistry.findClass(CrtClassLoaderRegistry.java:176) at java.lang.ClassLoader.loadClass(ClassLoader.java:289) at java.lang.ClassLoader.loadClass(ClassLoader.java:235) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:219) at com.sapportals.wcm.crt.CrtClassLoaderRegistry.forName(CrtClassLoaderRegistry.java:349) at com.sapportals.wcm.rendering.uicommand.CommandCreator.createExecCommand(CommandCreator.java:120) at com.sapportals.wcm.rendering.uicommand.CommandCreator.create(CommandCreator.java:108) at com.sapportals.wcm.rendering.uicommand.UICommandFactory.initialize(UICommandFactory.java:1169) at com.sapportals.wcm.rendering.uicommand.UICommandFactory.getInstance(UICommandFactory.java:220) at com.sapportals.wcm.rendering.uicommand.AbstractUIMassCommand.isApplicable(AbstractUIMassCommand.java:539) at com.sapportals.wcm.rendering.uicommand.UIGroupCommand.getResourceCommands(UIGroupCommand.java:64) at com.sapportals.wcm.rendering.uicommand.UIGroupCommand.getResourceGroupCommands(UIGroupCommand.java:131) at com.sapportals.wcm.rendering.uicommand.UIGroupCommand.getResourceCommands(UIGroupCommand.java:101) at com.sapportals.wcm.rendering.uicommand.UIGroupCommand.getResourceGroupCommands(UIGroupCommand.java:131) at com.sapportals.wcm.rendering.uicommand.UIGroupCommand.getResourceCommands(UIGroupCommand.java:101) at com.sapportals.wcm.rendering.uicommand.UIGroupCommand.getResourceGroupCommands(UIGroupCommand.java:131) at com.sapportals.wcm.rendering.uicommand.UIGroupCommand.getResourceCommands(UIGroupCommand.java:101) at com.sapportals.wcm.rendering.uicommand.UIGroupCommand.getListWithReplaceCommands(UIGroupCommand.java:191) at com.sapportals.wcm.rendering.uicommand.UIMenuFactory.getRenderMenu(UIMenuFactory.java:143) at com.sapportals.wcm.rendering.control.cm.MenuBarControl.render(MenuBarControl.java:244) at com.sapportals.wcm.rendering.layout.cm.MenuTreeListLayoutController.render(MenuTreeListLayoutController.java:102) at com.sapportals.wcm.rendering.control.cm.WdfProxy.render(WdfProxy.java:1812)
My code is just a copy of the UIMoveCommand :
package br.com.customer.uicommand;
import com.sap.tc.logging.Location;
import com.sap.tc.logging.LogController;
import com.sapportals.wcm.WcmException;
import com.sapportals.wcm.control.base.*;
import com.sapportals.wcm.control.enum.StatusType;
import com.sapportals.wcm.control.event.CflMoveEvent;
import com.sapportals.wcm.control.event.CflStatusInfoEvent;
import com.sapportals.wcm.rendering.base.*;
import com.sapportals.wcm.rendering.event.cm.MoveEvent;
import com.sapportals.wcm.rendering.screenflow.IScreenflow;
import com.sapportals.wcm.rendering.screenflow.cm.SelectScreenflow;
import com.sapportals.wcm.rendering.uicommand.*;
import com.sapportals.wcm.repository.*;
import com.sapportals.wcm.repository.enum.LinkType;
import com.sapportals.wcm.repository.enum.SupportedOption;
import com.sapportals.wcm.repository.manager.IRepositoryManager;
import com.sapportals.wcm.rfadapter.MoveUtility;
import com.sapportals.wcm.rfadapter.Result;
import com.sapportals.wcm.util.controlstatus.FieldIdentifier;
import com.sapportals.wcm.util.controlstatus.MetaInfo;
import com.sapportals.wcm.util.enum.AbstractEnum;
import com.sapportals.wcm.util.logging.LoggingFormatter;
import com.sapportals.wcm.util.uri.RID;
import com.sapportals.wdf.ControllerDynPage;
import com.sapportals.wdf.WdfException;
import com.sapportals.wdf.event.WdfEvent;
import java.util.*;
public class SimpleScreenflowCommand extends AbstractUICommand
implements ISelector
{
public SimpleScreenflowCommand()
{
values = null;
pushStack = false;
configdefinedHabitat = null;
Properties texts = new Properties();
texts.setProperty("keyLabel", "xbut_Move");
texts.setProperty("keyTooltip", "xtol_Move");
texts.setProperty("keyInputControlText", "xfld_CopyTechnicalName");
texts.setProperty("keyInputControlText2", "xfld_CopyDisplayName");
texts.setProperty("keySingleCommandText", "xbut_MoveHere");
texts.setProperty("keySingleCommandTooltip", "xtol_Move");
setTextProperties(texts);
}
public void setParameters(Hashtable parameters)
{
super.setParameters(parameters);
List starturi = (List)getParameters().get("SelectionStartUri");
List uri = (List)getParameters().get("SelectionUri");
try
{
if(starturi != null && starturi.size() > 0 && uri != null && uri.size() > 0)
configdefinedHabitat = new Habitat(RID.getRID(uri.get(0).toString(), null), RID.getRID(starturi.get(0).toString(), null), true);
else
if(uri != null && uri.size() > 0)
configdefinedHabitat = new Habitat(RID.getRID(uri.get(0).toString(), null));
}
catch(InvalidStartUriException e)
{
log.errorT("Configuration contains invalid uri/starturi combination" + LoggingFormatter.extractCallstack(e));
}
}
public String[] getTargetParameters()
throws WcmException
{
String result[] = new String[1];
result[0] = RIDMapperUtil.getMapper(super.proxy, super.resource.getRID());
return result;
}
public boolean isExecutable()
{
return canExecuteMoveResourceCommand(super.resource);
}
private boolean canExecuteMoveResourceCommand(IResource resource)
{
boolean canExecute = true;
try
{
ResourceCommandAmalgamation amalgamation = getProxy().getAmalgamation().getResourceCommandAmalg();
canExecute = canExecute && (amalgamation.isSupported(resource, SupportedOption.CREATE_RESOURCE) || amalgamation.isSupported(resource, SupportedOption.CREATE_COLLECTION));
canExecute = canExecute && amalgamation.isAccessible(resource, "node_write_properties");
canExecute = canExecute && true;
//canExecute = canExecute && amalgamation.isAccessible(resource, "leaf_delete");
canExecute = canExecute && !amalgamation.isLockedUnbreakable(resource);
}
catch(WcmException e)
{
log.errorT("Error while calling isExecutable " + LoggingFormatter.extractCallstack(e));
return false;
}
return canExecute;
}
public IUICommand getNewInstance()
{
return initNewInstance(new SimpleScreenflowCommand());
}
public void setTargetParameters(List values, IResourceContext context)
{
this.values = values;
super.context = context;
}
public IRenderingEvent execute(IResourceList targets, IProxy currentProxy)
throws WcmException
{
if(targets.size() > 1)
return new RenderingEvent(new CflStatusInfoEvent(StatusType.ERROR, getBundleString("xmsg_SingleTargetOnly")));
MoveUtility muy = new MoveUtility(super.resource, (ICollection)targets.get(0));
Result mr = muy.move(true);
CflStatusInfoEvent infoEvent = new CflStatusInfoEvent(mr.status(), mr.message());
WdfEvent event = new RenderingBackEvent();
event.addNestedEvent(infoEvent);
if(!pushStack && mr.resource() != null)
event.addNestedEvent(new CflMoveEvent(mr.resource().getAccessRID()));
RenderingEvent wrapperEvent = new RenderingEvent(event);
return wrapperEvent;
}
public WdfEvent execute(ControllerDynPage dynpage, boolean pushStack)
throws WdfException
{
try
{
this.pushStack = pushStack;
RID temp = RIDMapperUtil.getRID(super.proxy, (String)values.get(0));
super.resource = createResource(temp.getPath());
return getScreenflow(dynpage).execute(pushStack);
}
catch(WcmException e)
{
throw new WdfException(e);
}
}
private Habitat habitat()
throws ResourceException
{
Habitat result = null;
if(configdefinedHabitat == null)
{
result = getProxy().getHabitat();
if(!(getProxy().getResource() instanceof ICollection))
{
if(log.beDebug())
log.debugT("Using parent of current resource <" + getProxy().getResource() + " as navigation start, because resource is not a collection");
result = Habitat.getHabitat(result.current().parent(), result.ancestor());
}
} else
{
if(log.beDebug())
log.debugT("Using habitat from configuration for selection screen " + configdefinedHabitat);
result = configdefinedHabitat;
try
{
IResource res = ResourceFactory.getInstance().getResource(result.current(), getProxy().getResourceContext());
if(!(res instanceof ICollection))
{
log.warningT("The RID <" + result.current() + "> supplied in the config of command <" + getAlias() + "> does not point to a collection.");
result = getProxy().getHabitat();
}
}
catch(ResourceException e)
{
log.errorT("Cannot create resource with rid <" + result.current() + "> from configuration: " + LoggingFormatter.extractCallstack(e));
result = getProxy().getHabitat();
}
}
if(result.current().equals(RID.getRID("")))
{
RID newCurrent = getResource().getAccessRID();
if(!(getResource() instanceof ICollection))
newCurrent = newCurrent.parent();
result = Habitat.getHabitat(newCurrent, newCurrent);
log.debugT("Had to use current resource as habitat, because no habitat could be retrieved from proxy or configuration");
}
return result;
}
public IMandatoryField[] getUserInputSpecifiers()
{
try
{
IMandatoryField result[] = new MandatoryField[2];
String label = getLabel("keyInputControlText");
String input = getResource().getName();
HashMap metainfo = new HashMap();
metainfo.put(MetaInfo.LABEL, label);
result[0] = new MandatoryField(new FieldIdentifier(getProxy().createUniqueComponentId(ID_ID_FIELD)), input, metainfo, super.context.getLocale(), true);
label = getLabel("keyInputControlText2");
input = getResource().getDisplayName();
metainfo = new HashMap();
metainfo.put(MetaInfo.LABEL, label);
result[1] = new MandatoryField(new FieldIdentifier(getProxy().createUniqueComponentId(ID_NAME_FIELD)), input, metainfo, super.context.getLocale(), false);
return result;
}
catch(ResourceException e)
{
log.errorT("Could not set values for user input control for resource " + getResource() + " " + LoggingFormatter.extractCallstack(e));
}
return super.getUserInputSpecifiers();
}
public boolean allowUserInput()
{
return false;
}
private IScreenflow getScreenflow(ControllerDynPage page)
throws WdfException, WcmException
{
com.sapportals.wdf.element.PaneElement temp = getProxy().getPresentDynamicPane();
String text = getBundleString("ymsg_ExplanationTextMove", super.resource.getDisplayName(true));
Habitat habitat = habitat();
MoveEvent event = new MoveEvent(habitat, text, this);
SelectScreenflow result = new SelectScreenflow(temp, page, this, event, getProxy().getDynamicPane());
return result;
}
public boolean isValidTargetResource(IResource res)
{
try
{
boolean result = true;
result = result && !AbstractUICommand.ROOT_RID.equals(res.getRID());
result = result && (res instanceof ICollection);
if(res.getLinkType().equals(LinkType.INTERNAL))
result = result && ((ICollection)res.getTargetResource()).getRepositoryManager().getSupportedOptions(res.getTargetResource()).isSupported(SupportedOption.CREATE_RESOURCE);
else
result = result && ((ICollection)res).getRepositoryManager().getSupportedOptions(res).isSupported(SupportedOption.CREATE_RESOURCE);
return result;
}
catch(ResourceException e)
{
log.errorT("Could not check if resource " + res + " is valid target. " + LoggingFormatter.extractCallstack(e));
}
return false;
}
static Class _mthclass$(String x0)
{
try
{
return Class.forName(x0);
}
catch(ClassNotFoundException x1)
{
throw new NoClassDefFoundError(x1.getMessage());
}
}
private List values;
private boolean pushStack;
private Habitat configdefinedHabitat;
private static final String HASH;
private static final String ID_ID_FIELD;
private static final String ID_NAME_FIELD;
private static Location log;
static
{
HASH = Integer.toHexString((SimpleScreenflowCommand.class).getName().hashCode());
ID_ID_FIELD = HASH + "ID";
ID_NAME_FIELD = HASH + "NAME";
log = Location.getLocation(SimpleScreenflowCommand.class);
}
}
The servicewrapper :
package com.sap.netweaver.rf.wrapper;
import com.sapportals.portal.prt.service.IService;
public interface IRFServiceWrapper extends IService{
public static final String KEY = "br.com.customer.uicommand";
}
And my xmls files are as following
My portalxml
<?xml version="1.0" encoding="UTF-8"?>
<application>
<application-config>
<property name="SharingReference" value="usermanagement, knowledgemanagement, landscape, htmlb,km.appl.ui.flex.uicommand_core,com.sap.km.cm.main,com.sap.km.cm.ui,com.sap.km.cm.repository.manager,com.sap.km.bs.ui.wdf,com.sap.km.bs.crt,com.sap.km.bs.rf,com.sap.km.bs.rf.manager,com.sap.km.bs.util,com.sap.km.bs.rf.service,com.sap.km.bs.sf.service,com.sap.km.cm.service.base, exportalJCOclient, exportalcom.sap.km.cm.main, com.sap.km.cm.ui, com.sap.km.cm.repository.manager, com.sap.km.bs.ui.wdf, com.sap.km.bs.crt, com.sap.km.bs.rf, com.sap.km.bs.rf.manager, com.sap.km.bs.util, com.sap.km.bs.rf.service, com.sap.km.bs.sf.service, com.sap.km.cm.service.base,com.sapportals.wcm.rendering.event.cm.MoveEvent,com.sap.km.cm.ui.flex"/>
</application-config>
<components/>
<services>
<service name="RFServiceWrapper">
<service-config>
<property name="className" value="com.sap.netweaver.rf.wrapper.RFServiceWrapper"/>
<property name="startup" value="true"/>
</service-config>
</service>
</services>
</application>
<?xml version="1.0" encoding="UTF-8" ?> - <!-- file generated by configuration framework 17.02.2005 14:51:02 --> - <Configurable configclass="UICommandWithSelection"> <property name="classname" value="br.com.customer.uicommand.SimpleScreenflowCommand" /> <property name="parameters" /> <property name="labelBundleKey" /> <property name="rolemapping" /> <property name="description" value="This is an example for a command using the screenflow mechanisme." /> <property name="iconPath" /> <property name="bundleFileName" value="com.sapportals.wcm.rendering.uicommand.UICConsts" /> <property name="masscommand" value="false" /> <property name="tooltipBundleKey" /> <property name="alias" value="SimpleExampleScreenflowCommand" /> </Configurable>
How can I solve this problem ?
I will change the name of the class later on .
Thank you in advance ,
Guy