<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-aop</artifactId>
+ </dependency>
+
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
--- /dev/null
+/**
+ * Copyright (c) 2018 Orange
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.nbi.apis.hub;
+
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.annotation.AfterReturning;
+import org.aspectj.lang.annotation.Aspect;
+import org.onap.nbi.apis.serviceorder.model.ServiceOrder;
+import org.onap.nbi.apis.serviceorder.model.StateType;
+import org.springframework.beans.factory.annotation.Configurable;
+import org.springframework.stereotype.Component;
+
+@Aspect
+@Component
+@Configurable
+public class MyAspect {
+
+ @AfterReturning(value = "execution(* org.onap.nbi.apis.serviceorder.service.ServiceOrderService" +
+ ".createServiceOrder(..))", returning = "serviceOrderCreated")
+ public void whenCreateServiceOrder(ServiceOrder serviceOrderCreated) {
+ if(StateType.ACKNOWLEDGED.equals(serviceOrderCreated.getState())) {
+ // Notif createServiceOrder
+ }
+ }
+
+ @AfterReturning(value = "execution(* org.onap.nbi.apis.serviceorder.service.ServiceOrderService" +
+ ".updateOrderState(..))", returning = "serviceOrderUpdated")
+ public void whenUpdateServiceOrderState(ServiceOrder serviceOrderUpdated) {
+ if(StateType.COMPLETED.equals(serviceOrderUpdated.getState())||
+ StateType.FAILED.equals(serviceOrderUpdated.getState())) {
+ // Notif updateServiceOrder
+ }
+ }
+
+ @AfterReturning(value = "execution(* org.onap.nbi.apis.serviceorder.service.ServiceOrderService" +
+ ".updateOrderItemState(..))")
+ public void whenUpdateServiceOrderItemState(JoinPoint joinPoint) {
+ Object[] signatureArgs = joinPoint.getArgs();
+
+ if(signatureArgs != null && signatureArgs.length == 3) {
+ StateType serviceOrderItemState = (StateType) signatureArgs[2];
+ // Notif updateServiceOrderItem
+
+ }
+ }
+}
*/
package org.onap.nbi.apis.serviceorder;
-import java.util.List;
-import javax.validation.Valid;
import org.onap.nbi.apis.serviceorder.model.ServiceOrder;
import org.onap.nbi.apis.serviceorder.model.StateType;
import org.onap.nbi.apis.serviceorder.model.orchestrator.ServiceOrderInfo;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.util.MultiValueMap;
import org.springframework.validation.Errors;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+import java.util.List;
@RestController
@RequestMapping("/serviceOrder")
throw new ValidationException(errors.getAllErrors());
}
- ServiceOrder serviceOrderSaved =serviceOrderService.updateOrderAndItemStateToAcknowledged(serviceOrder);
+ ServiceOrder serviceOrderSaved =serviceOrderService.createServiceOrder(serviceOrder);
serviceOrderService.updateOrderHref(serviceOrderSaved);
JsonRepresentation filter = new JsonRepresentation(params);
return this.createResponse(serviceOrderSaved, filter);
for (ServiceOrder serviceOrder : acknowledgedOrders) {
ServiceOrderInfo serviceOrderInfo = checkOrderConsistenceManager.checkServiceOrder(serviceOrder);
if (serviceOrderInfo.isServiceOrderRejected()) {
- serviceOrderService.updateOrderFinalState(serviceOrder, StateType.REJECTED);
+ serviceOrderService.updateOrderState(serviceOrder, StateType.REJECTED);
} else if (serviceOrderInfo.isAllItemsCompleted()) {
- serviceOrderService.updateOrderFinalState(serviceOrder, StateType.COMPLETED);
+ serviceOrderService.updateOrderState(serviceOrder, StateType.COMPLETED);
} else {
createAAICustomer.createAAICustomer(serviceOrder,serviceOrderInfo);
if(StateType.ACKNOWLEDGED==serviceOrder.getState()) {
*/
package org.onap.nbi.apis.serviceorder.service;
-import java.util.Date;
-import java.util.List;
import org.onap.nbi.apis.serviceorder.model.ServiceOrder;
import org.onap.nbi.apis.serviceorder.model.ServiceOrderItem;
import org.onap.nbi.apis.serviceorder.model.StateType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import java.util.Date;
+import java.util.List;
+
@Service
public class ServiceOrderService {
return serviceOrderRepository.findByState(state);
}
- public void updateOrderState(ServiceOrder serviceOrder,StateType state){
- serviceOrder.setState(state);
- serviceOrderRepository.save(serviceOrder);
- }
-
- public void updateOrderFinalState(ServiceOrder serviceOrder,StateType state){
+ public ServiceOrder updateOrderState(ServiceOrder serviceOrder,StateType state){
+ if(StateType.COMPLETED.equals(state) || StateType.REJECTED.equals(state)) {
+ serviceOrder.setCompletionDateTime(new Date());
+ }
serviceOrder.setState(state);
- serviceOrder.setCompletionDateTime(new Date());
- serviceOrderRepository.save(serviceOrder);
+ return serviceOrderRepository.save(serviceOrder);
}
public void updateOrderItemState(ServiceOrder serviceOrder,ServiceOrderItem serviceOrderItem, StateType state){
serviceOrderRepository.save(serviceOrder);
}
- public ServiceOrder updateOrderAndItemStateToAcknowledged(ServiceOrder serviceOrder){
+ public ServiceOrder createServiceOrder(ServiceOrder serviceOrder){
serviceOrder.setState(StateType.ACKNOWLEDGED);
serviceOrder.setOrderDate(new Date());
for (ServiceOrderItem serviceOrderItem : serviceOrder.getOrderItem()) {
boolean customerCreated = serviceOrderConsumerService.putCustomer(serviceOrderInfo.getSubscriberInfo());
if (!customerCreated) {
- serviceOrderService.updateOrderFinalState(serviceOrder,StateType.REJECTED);
+ serviceOrderService.updateOrderState(serviceOrder,StateType.REJECTED);
LOGGER.warn("serviceOrder {} rejected : cannot create customer", serviceOrder.getId());
}
}
*/
package org.onap.nbi.apis.serviceorder.workflow;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
import org.onap.nbi.apis.serviceorder.MultiClient;
import org.onap.nbi.apis.serviceorder.model.ActionType;
import org.onap.nbi.apis.serviceorder.model.ServiceOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
@Service
public class CreateAAIServiceTypeManager {
boolean serviceCreated = serviceOrderConsumerService.putServiceType(
serviceOrderInfo.getSubscriberInfo().getGlobalSubscriberId(), sdcServiceName);
if (!serviceCreated) {
- serviceOrderService.updateOrderFinalState(serviceOrder,StateType.REJECTED);
+ serviceOrderService.updateOrderState(serviceOrder,StateType.REJECTED);
LOGGER.warn("serviceOrder {} rejected : cannot create service type {} for customer {}",
serviceOrder.getId(), sdcServiceName,
serviceOrderInfo.getSubscriberInfo().getGlobalSubscriberId());
*/
package org.onap.nbi.apis.serviceorder.workflow;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
import org.onap.nbi.apis.serviceorder.SoClient;
import org.onap.nbi.apis.serviceorder.model.ServiceCharacteristic;
import org.onap.nbi.apis.serviceorder.model.ServiceOrder;
import org.onap.nbi.apis.serviceorder.model.ServiceOrderItem;
import org.onap.nbi.apis.serviceorder.model.StateType;
-import org.onap.nbi.apis.serviceorder.model.consumer.CloudConfiguration;
-import org.onap.nbi.apis.serviceorder.model.consumer.CreateServiceInstanceResponse;
-import org.onap.nbi.apis.serviceorder.model.consumer.GetRequestStatusResponse;
-import org.onap.nbi.apis.serviceorder.model.consumer.MSOPayload;
-import org.onap.nbi.apis.serviceorder.model.consumer.ModelInfo;
-import org.onap.nbi.apis.serviceorder.model.consumer.OwningEntity;
-import org.onap.nbi.apis.serviceorder.model.consumer.Project;
-import org.onap.nbi.apis.serviceorder.model.consumer.RequestDetails;
-import org.onap.nbi.apis.serviceorder.model.consumer.RequestInfo;
-import org.onap.nbi.apis.serviceorder.model.consumer.RequestParameters;
-import org.onap.nbi.apis.serviceorder.model.consumer.RequestState;
-import org.onap.nbi.apis.serviceorder.model.consumer.SubscriberInfo;
-import org.onap.nbi.apis.serviceorder.model.consumer.UserParams;
+import org.onap.nbi.apis.serviceorder.model.consumer.*;
import org.onap.nbi.apis.serviceorder.model.orchestrator.ExecutionTask;
import org.onap.nbi.apis.serviceorder.model.orchestrator.ServiceOrderInfo;
import org.onap.nbi.apis.serviceorder.repositories.ExecutionTaskRepository;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
+import java.io.IOException;
+import java.util.*;
+
@Service
public class SOTaskProcessor {
} else {
finalState=StateType.COMPLETED;
}
- serviceOrderService.updateOrderFinalState(serviceOrder,finalState);
+ serviceOrderService.updateOrderState(serviceOrder,finalState);
}
}