Search in sources :

Example 56 with NamespacePermission

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);
}
Also used : JobDefinitionEntity(org.finra.herd.model.jpa.JobDefinitionEntity) NamespaceEntity(org.finra.herd.model.jpa.NamespaceEntity) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) NamespacePermission(org.finra.herd.model.annotation.NamespacePermission)

Example 57 with NamespacePermission

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);
}
Also used : JobDefinitionEntity(org.finra.herd.model.jpa.JobDefinitionEntity) NamespacePermission(org.finra.herd.model.annotation.NamespacePermission)

Example 58 with NamespacePermission

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);
}
Also used : JobDefinitionEntity(org.finra.herd.model.jpa.JobDefinitionEntity) NamespaceEntity(org.finra.herd.model.jpa.NamespaceEntity) AlreadyExistsException(org.finra.herd.model.AlreadyExistsException) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) NamespacePermission(org.finra.herd.model.annotation.NamespacePermission)

Example 59 with NamespacePermission

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;
}
Also used : StorageUnitUploadCredential(org.finra.herd.model.api.xml.StorageUnitUploadCredential) NamespacePermission(org.finra.herd.model.annotation.NamespacePermission)

Example 60 with NamespacePermission

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;
}
Also used : UserNamespaceAuthorizations(org.finra.herd.model.api.xml.UserNamespaceAuthorizations) UserNamespaceAuthorizationEntity(org.finra.herd.model.jpa.UserNamespaceAuthorizationEntity) NamespacePermission(org.finra.herd.model.annotation.NamespacePermission)

Aggregations

NamespacePermission (org.finra.herd.model.annotation.NamespacePermission)63 BusinessObjectDefinitionEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionEntity)10 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)10 NamespaceEntity (org.finra.herd.model.jpa.NamespaceEntity)10 AlreadyExistsException (org.finra.herd.model.AlreadyExistsException)9 AttributeValueListEntity (org.finra.herd.model.jpa.AttributeValueListEntity)6 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)5 BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)5 CustomDdlEntity (org.finra.herd.model.jpa.CustomDdlEntity)5 Credentials (com.amazonaws.services.securitytoken.model.Credentials)4 ArrayList (java.util.ArrayList)4 PublishNotificationMessages (org.finra.herd.model.annotation.PublishNotificationMessages)4 BusinessObjectFormatKey (org.finra.herd.model.api.xml.BusinessObjectFormatKey)4 IamRole (org.finra.herd.model.api.xml.IamRole)4 NamespaceIamRoleAuthorization (org.finra.herd.model.api.xml.NamespaceIamRoleAuthorization)4 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)4 NamespaceIamRoleAuthorizationEntity (org.finra.herd.model.jpa.NamespaceIamRoleAuthorizationEntity)4 UserNamespaceAuthorizationEntity (org.finra.herd.model.jpa.UserNamespaceAuthorizationEntity)4 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)3 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)3