use of org.finra.herd.model.annotation.NamespacePermission in project herd by FINRAOS.
the class JobDefinitionServiceImpl method updateJobDefinition.
@NamespacePermission(fields = "#namespace", permissions = NamespacePermissionEnum.WRITE)
@Override
public JobDefinition updateJobDefinition(String namespace, String jobName, JobDefinitionUpdateRequest request, boolean enforceAsync) throws Exception {
// Validate the job definition alternate key.
String namespaceLocal = alternateKeyHelper.validateStringParameter("namespace", namespace);
String jobNameLocal = alternateKeyHelper.validateStringParameter("job name", jobName);
// Validate and trim the Activiti job XML.
Assert.hasText(request.getActivitiJobXml(), "An Activiti job XML must be specified.");
request.setActivitiJobXml(request.getActivitiJobXml().trim());
// Perform the job definition validation.
validateJobDefinition(namespaceLocal, jobNameLocal, request.getActivitiJobXml(), request.getParameters(), request.getS3PropertiesLocation());
if (enforceAsync) {
assertFirstTaskIsAsync(activitiHelper.constructBpmnModelFromXmlAndValidate(request.getActivitiJobXml()));
}
// Get the namespace and ensure it exists.
NamespaceEntity namespaceEntity = namespaceDaoHelper.getNamespaceEntity(namespaceLocal);
// Retrieve and ensure that a job definition exists.
JobDefinitionEntity jobDefinitionEntity = jobDefinitionDaoHelper.getJobDefinitionEntity(namespaceLocal, jobNameLocal);
// Create the new process definition.
ProcessDefinition processDefinition = createProcessDefinition(namespaceLocal, jobNameLocal, request.getActivitiJobXml());
// Create a job definition entity from the request information.
jobDefinitionEntity = createOrUpdateJobDefinitionEntity(jobDefinitionEntity, namespaceEntity, jobNameLocal, request.getDescription(), processDefinition.getId(), request.getParameters(), request.getS3PropertiesLocation());
// Persist the entity.
jobDefinitionEntity = jobDefinitionDao.saveAndRefresh(jobDefinitionEntity);
// Create and return the job definition object from the persisted entity.
return createJobDefinitionFromEntity(jobDefinitionEntity);
}
use of org.finra.herd.model.annotation.NamespacePermission in project herd by FINRAOS.
the class JobDefinitionServiceImpl method getJobDefinition.
@NamespacePermission(fields = "#namespace", permissions = NamespacePermissionEnum.READ)
@Override
public JobDefinition getJobDefinition(String namespace, String jobName) throws Exception {
// Validate the job definition alternate key.
String namespaceLocal = alternateKeyHelper.validateStringParameter("namespace", namespace);
String jobNameLocal = alternateKeyHelper.validateStringParameter("job name", jobName);
// Retrieve and ensure that a job definition exists.
JobDefinitionEntity jobDefinitionEntity = jobDefinitionDaoHelper.getJobDefinitionEntity(namespaceLocal, jobNameLocal);
// Create and return the job definition object from the persisted entity.
return createJobDefinitionFromEntity(jobDefinitionEntity);
}
use of org.finra.herd.model.annotation.NamespacePermission in project herd by FINRAOS.
the class JobDefinitionServiceImpl method createJobDefinition.
/**
* Creates a new business object definition.
*
* @param request the business object definition create request.
* @param enforceAsync True to enforce first task is async, false to ignore
*
* @return the created business object definition.
*/
@NamespacePermission(fields = "#request.namespace", permissions = NamespacePermissionEnum.WRITE)
@Override
public JobDefinition createJobDefinition(JobDefinitionCreateRequest request, boolean enforceAsync) throws Exception {
// Perform the validation.
validateJobDefinitionCreateRequest(request);
if (enforceAsync) {
assertFirstTaskIsAsync(activitiHelper.constructBpmnModelFromXmlAndValidate(request.getActivitiJobXml()));
}
// Get the namespace and ensure it exists.
NamespaceEntity namespaceEntity = namespaceDaoHelper.getNamespaceEntity(request.getNamespace());
// Ensure a job definition with the specified name doesn't already exist.
JobDefinitionEntity jobDefinitionEntity = jobDefinitionDao.getJobDefinitionByAltKey(request.getNamespace(), request.getJobName());
if (jobDefinitionEntity != null) {
throw new AlreadyExistsException("Unable to create job definition with name \"" + request.getJobName() + "\" because it already exists for namespace \"" + request.getNamespace() + "\".");
}
// Create the new process definition.
ProcessDefinition processDefinition = createProcessDefinition(request.getNamespace(), request.getJobName(), request.getActivitiJobXml());
// Create a job definition entity from the request information.
jobDefinitionEntity = createOrUpdateJobDefinitionEntity(null, namespaceEntity, request.getJobName(), request.getDescription(), processDefinition.getId(), request.getParameters(), request.getS3PropertiesLocation());
// Persist the new entity.
jobDefinitionEntity = jobDefinitionDao.saveAndRefresh(jobDefinitionEntity);
// Create and return the job definition from the persisted entity.
return createJobDefinitionFromEntity(jobDefinitionEntity);
}
use of org.finra.herd.model.annotation.NamespacePermission in project herd by FINRAOS.
the class StorageUnitServiceImpl method getStorageUnitUploadCredential.
@NamespacePermission(fields = "#businessObjectDataKey?.namespace", permissions = NamespacePermissionEnum.WRITE)
@Override
public StorageUnitUploadCredential getStorageUnitUploadCredential(BusinessObjectDataKey businessObjectDataKey, Boolean createNewVersion, String storageName) {
StorageUnitUploadCredential businessObjectDataUploadCredential = new StorageUnitUploadCredential();
businessObjectDataUploadCredential.setAwsCredential(getBusinessObjectDataS3Credential(businessObjectDataKey, createNewVersion, storageName, true));
businessObjectDataUploadCredential.setAwsKmsKeyId(getStorageKmsKeyId(storageDaoHelper.getStorageEntity(storageName.trim())));
return businessObjectDataUploadCredential;
}
use of org.finra.herd.model.annotation.NamespacePermission in project herd by FINRAOS.
the class UserNamespaceAuthorizationServiceImpl method getUserNamespaceAuthorizationsByNamespace.
@NamespacePermission(fields = "#namespace", permissions = NamespacePermissionEnum.READ)
@Override
public UserNamespaceAuthorizations getUserNamespaceAuthorizationsByNamespace(String namespace) {
// Validate and trim the namespace code.
Assert.hasText(namespace, "A namespace must be specified.");
String namespaceLocal = namespace.trim();
// Validate that specified namespace exists.
namespaceDaoHelper.getNamespaceEntity(namespaceLocal);
// Retrieve and return a list of user namespace authorization entities for the specified namespace.
List<UserNamespaceAuthorizationEntity> userNamespaceAuthorizationEntities = userNamespaceAuthorizationDao.getUserNamespaceAuthorizationsByNamespace(namespaceLocal);
// Create and populate the user namespace authorizations object from the returned entities.
UserNamespaceAuthorizations userNamespaceAuthorizations = new UserNamespaceAuthorizations();
userNamespaceAuthorizations.getUserNamespaceAuthorizations().addAll(createUserNamespaceAuthorizationsFromEntities(userNamespaceAuthorizationEntities));
return userNamespaceAuthorizations;
}
Aggregations