Commit ad79fb8b authored by Christos Tranoris's avatar Christos Tranoris
Browse files

Merge branch 'develop' into enhance_resources_apiroutes

parents a8e89e2d a0ca826f
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -5,3 +5,4 @@
/.classpath
/.settings
/org.etsi.osl.tmf.api.iml
/.idea/
+8 −2
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import org.etsi.osl.tmf.rcm634.model.ResourceSpecification;
import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationCreate;
import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationRef;
import org.etsi.osl.tmf.rcm634.repo.ResourceCatalogRepository;
import org.etsi.osl.tmf.rcm634.repo.ResourceCategoriesRepository;
import org.etsi.osl.tmf.rcm634.repo.ResourceSpecificationRepository;
import org.etsi.osl.tmf.rcm634.reposervices.ResourceCandidateRepoService;
import org.etsi.osl.tmf.rcm634.reposervices.ResourceCatalogRepoService;
@@ -71,6 +72,9 @@ public class BootstrapResources {
	@Autowired
	ResourceSpecificationRepository resourceSpecificationRepo;

    @Autowired
	ResourceCategoriesRepository resourceCategoriesRepository;
	
	@Autowired
	ObjectMapper objectMapper;

@@ -249,6 +253,7 @@ public class BootstrapResources {
	}
	

    @Transactional
	private void createBootResourceSpec( ResourceCategory scategory, String aname, String afile) {		 
		
		ResourceSpecificationCreate rsc = this.resourceSpecRepoService.readFromLocalLogicalResourceSpec( afile );
@@ -259,6 +264,7 @@ public class BootstrapResources {
		
	}

    @Transactional
	private void addToCategory(ResourceCategory scategory,  ResourceSpecification resourceSpecificationObj) {	
		
		//Turn the ResourceSpecification to a ResourceCanditate to save it to the ResourceCatalogRepo			
+19 −10
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.HttpStatusCode;
import org.springframework.http.ResponseEntity;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
@@ -18,15 +19,23 @@ public class RestExceptionHandler extends ResponseEntityExceptionHandler {
	@Override
	protected ResponseEntity<Object> handleHttpMessageNotReadable(HttpMessageNotReadableException ex,
			HttpHeaders headers, HttpStatusCode status, WebRequest request) {
		String error = "Malformed JSON request";
		ApiError apiError = new ApiError(HttpStatus.BAD_REQUEST, error, ex);
		return new ResponseEntity<Object>(apiError, apiError.getStatus());
		return buildResponseEntity(ex);
	}

	// other exception handlers below

	private ResponseEntity<Object> buildResponseEntity(ApiError apiError) {
		return new ResponseEntity<>(apiError, apiError.getStatus());
	@Override
	protected ResponseEntity<Object> handleMethodArgumentNotValid(
			MethodArgumentNotValidException ex,
			HttpHeaders headers,
			HttpStatusCode status,
			WebRequest request) {
		return buildResponseEntity(ex);
	}
	// other exception handlers below

	private ResponseEntity<Object> buildResponseEntity(Throwable ex) {
		String error = "Malformed JSON request";
		ApiError apiError = new ApiError(HttpStatus.BAD_REQUEST, error, ex);
		return new ResponseEntity<Object>(apiError, apiError.getStatus());
	}
}
+2 −2
Original line number Diff line number Diff line
@@ -716,13 +716,13 @@ public class ProductOfferingRepoService {
          
                    
          // Build the name LIKE clause
          StringJoiner nameJoiner = new StringJoiner(" AND ");
          StringJoiner nameJoiner = new StringJoiner(" OR ");
          for (String term : searchList) {
              nameJoiner.add("p.name LIKE '%" + term + "%'");
          }

          // Build the description LIKE clause
          StringJoiner descriptionJoiner = new StringJoiner(" AND ");
          StringJoiner descriptionJoiner = new StringJoiner(" OR ");
          for (String term : searchList) {
              descriptionJoiner.add("p.description LIKE '%" + term + "%'");
          }
+2 −1
Original line number Diff line number Diff line
@@ -430,9 +430,10 @@ public class ProductSpecificationRepoService {
				// we need the attachment model from resource spec models
				boolean idexists = false;
				for (ProductSpecificationCharacteristic orinalAtt : prodSpec.getProductSpecCharacteristic()) {
					if (orinalAtt.getName().equals(ar.getName())) {
					if (orinalAtt.getName()!=null && ar.getName()!=null &&  orinalAtt.getName().equals(ar.getName())) {
						idexists = true;
						idAddedUpdated.put(orinalAtt.getName(), true);
						orinalAtt.updateWith( ar );
						break;
					}
				}
Loading