on 05-02-2006 9:56 AM
Hi All
Does anyone have an example or some help regarding creating a repository service to copy files from one folder to another and if those files exist overwrite them?
I am currentely learning Java however am not quite advanced enough to tackle this from scratch.
Thanks in advance, it is most appreciated!
Hi,
I am sure the standard API's are available, check if this helps.
refer:
https://media.sdn.sap.com/javadocs/NW04/SPS15/km/com/sapportals/wcm/repository/IResource.html
https://media.sdn.sap.com/javadocs/NW04/SPS15/km/com/sapportals/wcm/rfadapter/CopyUtility.html
Hope that helps.
Regards,
S.Divakar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for that
However, I have created my service but I am getting errors all over the portal. e.g.
ITEM NOT FOUND /alias/userhome/<user.id>/favorites
My code is below: any ideas why?
package newsCopy;
import com.sapportals.wcm.repository.service.AbstractRepositoryService;
import com.sapportals.wcm.repository.service.ServiceNotAvailableException;
import com.sapportals.wcm.repository.manager.IResourceEventReceiver;
import com.sapportals.wcm.repository.manager.IRepositoryManager;
import com.sapportals.wcm.util.events.IEvent;
import com.sapportals.wcm.crt.component.*;
import com.sapportals.wcm.crt.configuration.*;
import com.sapportals.wcm.WcmException;
import java.util.Collection;
// New Imports
import com.sapportals.wcm.repository.*;
import com.sapportals.wcm.util.uri.RID;
import com.sap.tc.logging.Location;
// implements IMyNewRepositoryService interface
/*
Note: IReconfigurable and IResourceEventReceiver interfaces are optional
*/
public class newsCopy extends AbstractRepositoryService implements IReconfigurable, IResourceEventReceiver {
private static final String TYPE = "newsCopy";
public newsCopy() {
super();
// Do not add code here. Add it to startUpImpl() instead
}
public String getServiceType() {
return newsCopy.TYPE;
}
protected void startUpImpl(Collection repositoryManagers) throws ConfigurationException, StartupException {
// implement this method as follows:
// - Verify configuration data
// - Get references to other needed (global) services
// - Check whether other repository services (this service depends on) are also assigned to the repository managers
// - Usually the service registers itself for certain events at all repository managers
//
/*
try {
}
catch (Exception e) {
throw new StartupException(e.getMessage(), e);
}
*/
}
protected void shutDownImpl() { }
protected void addRepositoryAssignment(IRepositoryManager mgr) throws ServiceNotAvailableException {
// Implement this method: Usually the service registers itself for certain events at the repository manager.
}
protected void removeRepositoryAssignment(IRepositoryManager mgr) throws WcmException {
// Implement this method: Usually the service must unregister itself as an event handler.
}
public void reconfigure(IConfiguration config) throws ConfigurationException {
this.stateHandler.preReconfigure();
// check the new configuration data
/*
try {
}
catch (ConfigurationException ex) {
this.stateHandler.postReconfigure(ex);
throw ex;
}*/
this.config = config;
this.stateHandler.postReconfigure();
}
private static final Location log = Location.getLocation(newsCopy.class);
public void received(IEvent event) {
IResource resource = (IResource)event.getParameter();
IResource sourceResource = resource;
RID destinationRid = null;
try {
destinationRid = RID.getRID("/news/LatestNews/" + resource.getName());
} catch (ResourceException e1) {
log.errorT("********** No. 1 Resource Exception!");
}
ICopyParameter cp = new CopyParameter();
cp.setIgnorePropertyFailures(true);
cp.setOverwrite(true);
if (sourceResource != null && destinationRid != null){
try {
sourceResource.copy(destinationRid,cp);
} catch (NotSupportedException e) {
log.errorT("********** No. 2 Not Supported Exception!");
} catch (ResourceException e) {
log.errorT("********** No. 3 Resource Exception!");
}
}
}
}
Ny help would be great!
User | Count |
---|---|
81 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.