new RequestContext(this, repository, versionRepository);
try {
// start the transaction
beginTransaction();
ResourcePath resourcePath = new ResourcePath(suggestedPath);
importChildContext.setResourcePath(resourcePath);
context.setResourcePath(resourcePath);
context.setSourceURL(sourceURL);
context.setResource(metaResource);
if (repository.resourceExists(suggestedPath)) {
Resource resource = repository.get(suggestedPath);
importChildContext.setOldResource(resource);
context.setOldResource(resource);
}
registryContext.getHandlerManager().importChild(importChildContext);
registryContext.getHandlerManager().importResource(context);
if (!context.isSimulation()) {
String savedPath = context.getActualPath();
if (!context.isProcessingComplete()) {
savedPath = suggestedPath;
// if some handlers have updated the meta data *without completing the request* we should
// capture the updated meta data here.
if (context.getResource() != null) {
metaResource = context.getResource();
}
try {
CurrentSession.setAttribute(Repository.IS_LOGGING_ACTIVITY,
context.isLoggingActivity());
repository.importResource(resourcePath.getPath(), sourceURL, metaResource);
} finally {
CurrentSession.removeAttribute(Repository.IS_LOGGING_ACTIVITY);
}
}