Resource createResource(Endpoint endpoint, DataSet dataSet, String desiredPath) throws ApplicationExecutionException {
ResourceId resourceId=endpoint.resourceId();
Container resource = this.resourceRepository.containerOfId(resourceId);
if(resource==null) {
String errorMessage = applicationFailureMessage(COULD_NOT_FIND_CONTAINER_FOR_ENDPOINT,endpoint);
LOGGER.error(errorMessage);
throw new ApplicationExecutionException(errorMessage);
}
try {
WriteSessionConfiguration config=
DefaultApplicationContextHelper.
create(this.engine().templateManagementService()).
createConfiguration(resource,dataSet,desiredPath,lastModified());
return this.engine().resourceControllerService().createResource(resource,dataSet,config);
} catch (FeatureExecutionException e) {
processConstraintValidationFailure(resource, e);
String errorMessage = applicationFailureMessage(RESOURCE_CREATION_FAILED,endpoint);
throw createException(errorMessage,e);
} catch (InvalidIndirectIdentifierException e) {
throw e;
} catch (Exception e) {
String errorMessage = applicationFailureMessage(RESOURCE_CREATION_FAILED,endpoint);
throw createException(errorMessage,e);
}
}