Search in sources :

Example 1 with OwningEntity

use of org.onap.so.serviceinstancebeans.OwningEntity in project so by onap.

the class ProjectOwningEntityValidation method validate.

@Override
public ValidationInformation validate(ValidationInformation info) throws ValidationException {
    int reqVersion = info.getReqVersion();
    Project project;
    OwningEntity owningEntity;
    String requestScope = info.getRequestScope();
    Actions action = info.getAction();
    project = info.getSir().getRequestDetails().getProject();
    owningEntity = info.getSir().getRequestDetails().getOwningEntity();
    if (reqVersion >= 5 && requestScope.equalsIgnoreCase(ModelType.service.name()) && action == Action.createInstance || action == Action.assignInstance) {
        if (reqVersion > 5 && owningEntity == null) {
            throw new ValidationException("owningEntity");
        }
        if (owningEntity != null && empty(owningEntity.getOwningEntityId())) {
            throw new ValidationException("owningEntityId");
        }
        if (project != null && empty(project.getProjectName())) {
            throw new ValidationException("projectName");
        }
    }
    info.setProject(project);
    info.setOE(owningEntity);
    return info;
}
Also used : Project(org.onap.so.serviceinstancebeans.Project) ValidationException(org.onap.so.exceptions.ValidationException) Actions(org.onap.so.apihandlerinfra.Actions) OwningEntity(org.onap.so.serviceinstancebeans.OwningEntity)

Aggregations

Actions (org.onap.so.apihandlerinfra.Actions)1 ValidationException (org.onap.so.exceptions.ValidationException)1 OwningEntity (org.onap.so.serviceinstancebeans.OwningEntity)1 Project (org.onap.so.serviceinstancebeans.Project)1