return null;
}
public void createLink(String path, String target) throws RegistryException {
boolean transactionSucceeded = false;
RequestContext context = new RequestContext(this, repository, versionRepository);
try {
// start the transaction
beginTransaction();
if (path.equals(target)) {
String msg = "Path and target are same, path = target = " + path +
". You can't create a symbolic link to itself.";
log.error(msg);
throw new RegistryException(msg);
}
// first put the data..
Resource oldResource = repository.getMetaData(target);
Resource resource;
if (repository.resourceExists(path)) {
resource = repository.get(path);
resource.addProperty(RegistryConstants.REGISTRY_EXISTING_RESOURCE, "true");
} else if (oldResource != null) {
if (oldResource instanceof Collection) {
resource = new CollectionImpl();
} else {
resource = new ResourceImpl();
}
} else {
resource = new CollectionImpl();
}
resource.addProperty(RegistryConstants.REGISTRY_NON_RECURSIVE, "true");
resource.addProperty(RegistryConstants.REGISTRY_LINK_RESTORATION,
path + RegistryConstants.URL_SEPARATOR + target +
RegistryConstants.URL_SEPARATOR + CurrentSession.getUser());
try {
CurrentSession.setAttribute(Repository.IS_LOGGING_ACTIVITY, false);
repository.put(path, resource);
} finally {
CurrentSession.removeAttribute(Repository.IS_LOGGING_ACTIVITY);
}
resource.discard();
HandlerManager hm = registryContext.getHandlerManager();
ResourcePath resourcePath = new ResourcePath(path);
context.setResourcePath(resourcePath);
context.setTargetPath(target);
hm.createLink(context);
if (!context.isSimulation()) {
if (!context.isProcessingComplete()) {
RegistryUtils.registerHandlerForSymbolicLinks(registryContext, path, target,
CurrentSession.getUser());
String author = CurrentSession.getUser();
RegistryUtils.addMountEntry(this, registryContext, path, target,
false, author);
if (context.isLoggingActivity()) {
registryContext.getLogWriter().addLog(path, CurrentSession.getUser(),
LogEntry.CREATE_SYMBOLIC_LINK,
target);
}
}