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.instancecheck;
\r
10 import org.opendaylight.nemo.user.tenantmanager.TenantManage;
\r
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.common.rev151010.UserId;
\r
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.Objects;
\r
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.objects.Connection;
\r
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.objects.Flow;
\r
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.objects.Node;
\r
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.operations.Operation;
\r
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.users.User;
\r
19 import java.util.List;
\r
22 * Created by z00293636 on 2015/9/10.
\r
24 public class OperationInstanceCheck {
\r
25 private TenantManage tenantManage;
\r
27 public OperationInstanceCheck(TenantManage tenantManage)
\r
29 this.tenantManage = tenantManage;
\r
32 public String checkOperationInstance(UserId userId, Operation operation)
\r
34 String errorInfo = null;
\r
36 tenantManage.fetchVNSpace(userId);
\r
38 User user = tenantManage.getUser();
\r
41 if (operation.getTargetObject() != null && user.getObjects() == null)
\r
43 errorInfo = "There are no objects in data store.";
\r
45 if (operation.getTargetObject() != null && user.getObjects() != null)
\r
47 Objects objects = user.getObjects();
\r
48 Boolean targetExist = false;
\r
50 if (objects.getNode() != null )
\r
52 List<Node> nodeList = objects.getNode();
\r
53 for (Node node:nodeList)
\r
55 if (node.getNodeId().getValue().equals(operation.getTargetObject().getValue()))
\r
62 if (objects.getConnection() != null)
\r
64 List<Connection> connectionList = objects.getConnection();
\r
65 for (Connection connection : connectionList)
\r
67 if (connection.getConnectionId().getValue().equals(operation.getTargetObject().getValue()))
\r
74 if (objects.getFlow() != null)
\r
76 List<Flow> flowList = objects.getFlow();
\r
77 for (Flow flow : flowList)
\r
79 if (flow.getFlowId().getValue().equals(operation.getTargetObject().getValue()))
\r
88 errorInfo ="The target object is not included in vn space.";
\r
93 if (user.getOperations() != null)
\r
95 if (user.getOperations().getOperation() != null)
\r
97 List<Operation> operationList = tenantManage.getUser().getOperations().getOperation();
\r
98 for (Operation operation1 : operationList)
\r
100 if (operation1.getOperationId().equals(operation.getOperationId()))
\r
102 if (!operation1.getOperationName().equals(operation.getOperationName()))
\r
104 errorInfo = "The operation name should not be changed.";
\r
115 if (operation.getTargetObject() != null)
\r
117 errorInfo = "There are no objects in data store.";
\r