2 * Copyright (c) 2015 Huawei, Inc. and others. All rights reserved.
\r
4 * This program and the accompanying materials are made available under the
\r
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
\r
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
\r
8 package org.opendaylight.nemo.user.vnspacemanager.structurestyle.updateintent;
\r
10 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
\r
11 import org.opendaylight.nemo.user.tenantmanager.AAA;
\r
12 import org.opendaylight.nemo.user.tenantmanager.TenantManage;
\r
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.StructureStyleNemoUpdateInput;
\r
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.Results;
\r
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.objects.Connection;
\r
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.objects.Flow;
\r
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.objects.Node;
\r
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.operations.Operation;
\r
20 import java.util.List;
\r
23 * Created by z00293636 on 2015/8/31.
\r
25 public class UpdateIntent {
\r
27 private DataBroker dataBroker;
\r
28 private TenantManage tenantManage;
\r
29 private UpdateNode updateNode;
\r
30 private UpdateConnection updateConnection;
\r
31 private UpdateFlow updateFlow;
\r
32 private UpdateOperation updateOperation;
\r
33 private UpdateResult updateResult;
\r
35 public UpdateIntent(DataBroker dataBroker, TenantManage tenantManage)
\r
37 this.dataBroker = dataBroker;
\r
38 this.tenantManage = tenantManage;
\r
39 updateNode = new UpdateNode(dataBroker,tenantManage);
\r
40 updateConnection = new UpdateConnection(dataBroker,tenantManage);
\r
41 updateFlow = new UpdateFlow(dataBroker,tenantManage);
\r
42 updateOperation = new UpdateOperation(dataBroker,tenantManage);
\r
43 updateResult = new UpdateResult(dataBroker,tenantManage);
\r
46 public String updateIntent(AAA aaa,StructureStyleNemoUpdateInput structureStyleNemoUpdateInput){
\r
48 String erroInfo = null;
\r
50 erroInfo = aaa.CheckUser(structureStyleNemoUpdateInput.getUserId(),structureStyleNemoUpdateInput.getUserName(),structureStyleNemoUpdateInput.getUserPassword(),structureStyleNemoUpdateInput.getUserRole());
\r
52 if (erroInfo != null)
\r
58 if(structureStyleNemoUpdateInput.getObjects() != null)
\r
60 if (structureStyleNemoUpdateInput.getObjects().getNode() != null && erroInfo == null)
\r
62 List<Node> nodeList= structureStyleNemoUpdateInput.getObjects().getNode();
\r
63 for (Node node : nodeList )
\r
65 erroInfo = updateNode.NodeHandling(structureStyleNemoUpdateInput.getUserId(), node);
\r
66 if (erroInfo != null)
\r
72 if (structureStyleNemoUpdateInput.getObjects().getConnection() != null && erroInfo == null)
\r
74 List<Connection> connectionList = structureStyleNemoUpdateInput.getObjects().getConnection();
\r
75 for (Connection connection : connectionList)
\r
77 erroInfo = updateConnection.ConnectionHandling(structureStyleNemoUpdateInput.getUserId(), connection);
\r
78 if (erroInfo != null)
\r
85 if (structureStyleNemoUpdateInput.getObjects().getFlow() != null && erroInfo == null)
\r
87 List<Flow> flowList = structureStyleNemoUpdateInput.getObjects().getFlow();
\r
88 for (Flow flow : flowList)
\r
90 erroInfo = updateFlow.FlowHandling(structureStyleNemoUpdateInput.getUserId(),flow);
\r
91 if (erroInfo != null)
\r
99 if (structureStyleNemoUpdateInput.getOperations() != null)
\r
101 if (structureStyleNemoUpdateInput.getOperations().getOperation() != null && erroInfo == null)
\r
103 List<Operation> operationList =structureStyleNemoUpdateInput.getOperations().getOperation();
\r
104 for (Operation operation : operationList)
\r
106 erroInfo = updateOperation.OperationHandling(structureStyleNemoUpdateInput.getUserId(), operation);
\r
107 if (erroInfo !=null)
\r
115 else if (structureStyleNemoUpdateInput.getResults() != null)
\r
117 if ( structureStyleNemoUpdateInput.getResults() != null && erroInfo == null)
\r
119 Results results = structureStyleNemoUpdateInput.getResults();
\r
120 erroInfo = updateResult.ResultHandling(structureStyleNemoUpdateInput.getUserId(), results);
\r
121 if (erroInfo != null)
\r