bharat saraswal | f7364db | 2015-08-11 13:39:31 +0530 | [diff] [blame] | 1 | /*
|
| 2 | * Copyright 2015 Open Networking Laboratory
|
| 3 | *
|
| 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 | * you may not use this file except in compliance with the License.
|
| 6 | * You may obtain a copy of the License at
|
| 7 | *
|
| 8 | * http://www.apache.org/licenses/LICENSE-2.0
|
| 9 | *
|
| 10 | * Unless required by applicable law or agreed to in writing, software
|
| 11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 | * See the License for the specific language governing permissions and
|
| 14 | * limitations under the License.
|
| 15 | */
|
| 16 |
|
| 17 | package org.onosproject.pcepio.protocol.ver1;
|
| 18 |
|
| 19 | import org.onosproject.pcepio.exceptions.PcepParseException;
|
| 20 | import org.onosproject.pcepio.protocol.PcepLspObject;
|
| 21 | import org.onosproject.pcepio.protocol.PcepMsgPath;
|
| 22 | import org.onosproject.pcepio.protocol.PcepSrpObject;
|
| 23 | import org.onosproject.pcepio.protocol.PcepUpdateRequest;
|
| 24 | import org.slf4j.Logger;
|
| 25 | import org.slf4j.LoggerFactory;
|
| 26 |
|
| 27 | import com.google.common.base.MoreObjects;
|
| 28 |
|
| 29 | /*
|
| 30 | * PCEP Update Request List.
|
| 31 | */
|
| 32 | public class PcepUpdateRequestVer1 implements PcepUpdateRequest {
|
| 33 |
|
| 34 | /* <update-request-list>
|
| 35 | * Where:
|
| 36 | * <update-request-list> ::= <update-request>[<update-request-list>]
|
| 37 | * <update-request> ::= <SRP>
|
| 38 | * <LSP>
|
| 39 | * <path>
|
| 40 | * Where:
|
| 41 | * <path> ::= <ERO><attribute-list>
|
| 42 | * Where:
|
| 43 | * <attribute-list> is defined in [RFC5440] and extended by PCEP extensions.
|
| 44 | */
|
| 45 |
|
| 46 | protected static final Logger log = LoggerFactory.getLogger(PcepUpdateRequestVer1.class);
|
| 47 |
|
| 48 | //PCEP SRP Object
|
| 49 | private PcepSrpObject srpObject;
|
| 50 | //PCEP LSP Object
|
| 51 | private PcepLspObject lspObject;
|
| 52 | //PCEP Message path
|
| 53 | private PcepMsgPath msgPath;
|
| 54 |
|
| 55 | /**
|
| 56 | * Default constructor.
|
| 57 | */
|
| 58 | public PcepUpdateRequestVer1() {
|
| 59 | srpObject = null;
|
| 60 | lspObject = null;
|
| 61 | msgPath = null;
|
| 62 | }
|
| 63 |
|
| 64 | /**
|
| 65 | * Constructor to initialize all member variables.
|
| 66 | *
|
| 67 | * @param srpObject srp object
|
| 68 | * @param lspObject lsp object
|
| 69 | * @param msgPath message path object
|
| 70 | */
|
| 71 | public PcepUpdateRequestVer1(PcepSrpObject srpObject, PcepLspObject lspObject, PcepMsgPath msgPath) {
|
| 72 | this.srpObject = srpObject;
|
| 73 | this.lspObject = lspObject;
|
| 74 | this.msgPath = msgPath;
|
| 75 | }
|
| 76 |
|
| 77 | @Override
|
| 78 | public PcepSrpObject getSrpObject() {
|
| 79 | return srpObject;
|
| 80 | }
|
| 81 |
|
| 82 | @Override
|
| 83 | public PcepLspObject getLspObject() {
|
| 84 | return lspObject;
|
| 85 | }
|
| 86 |
|
| 87 | @Override
|
| 88 | public PcepMsgPath getMsgPath() {
|
| 89 | return msgPath;
|
| 90 | }
|
| 91 |
|
| 92 | @Override
|
| 93 | public void setSrpObject(PcepSrpObject srpObject) {
|
| 94 | this.srpObject = srpObject;
|
| 95 |
|
| 96 | }
|
| 97 |
|
| 98 | @Override
|
| 99 | public void setLspObject(PcepLspObject lspObject) {
|
| 100 | this.lspObject = lspObject;
|
| 101 | }
|
| 102 |
|
| 103 | @Override
|
| 104 | public void setMsgPath(PcepMsgPath msgPath) {
|
| 105 | this.msgPath = msgPath;
|
| 106 | }
|
| 107 |
|
| 108 | /**
|
| 109 | * Builder class for PCEP update request.
|
| 110 | */
|
| 111 | public static class Builder implements PcepUpdateRequest.Builder {
|
| 112 |
|
| 113 | private boolean bIsSRPObjectSet = false;
|
| 114 | private boolean bIsLSPObjectSet = false;
|
| 115 | private boolean bIsPcepMsgPathSet = false;
|
| 116 |
|
| 117 | //PCEP SRP Object
|
| 118 | private PcepSrpObject srpObject;
|
| 119 | //PCEP LSP Object
|
| 120 | private PcepLspObject lspObject;
|
| 121 | //PCEP Attribute list
|
| 122 | private PcepMsgPath msgPath;
|
| 123 |
|
| 124 | @Override
|
| 125 | public PcepUpdateRequest build() throws PcepParseException {
|
| 126 |
|
| 127 | //PCEP SRP Object
|
| 128 | PcepSrpObject srpObject = null;
|
| 129 | //PCEP LSP Object
|
| 130 | PcepLspObject lspObject = null;
|
| 131 | //PCEP Attribute list
|
| 132 | PcepMsgPath msgPath = null;
|
| 133 |
|
| 134 | if (!this.bIsSRPObjectSet) {
|
| 135 | throw new PcepParseException(" SRP Object NOT Set while building PcepUpdateRequest.");
|
| 136 | } else {
|
| 137 | srpObject = this.srpObject;
|
| 138 | }
|
| 139 | if (!this.bIsLSPObjectSet) {
|
| 140 | throw new PcepParseException(" LSP Object NOT Set while building PcepUpdateRequest.");
|
| 141 | } else {
|
| 142 | lspObject = this.lspObject;
|
| 143 | }
|
| 144 | if (!this.bIsPcepMsgPathSet) {
|
| 145 | throw new PcepParseException(" Msg Path NOT Set while building PcepUpdateRequest.");
|
| 146 | } else {
|
| 147 | msgPath = this.msgPath;
|
| 148 | }
|
| 149 |
|
| 150 | return new PcepUpdateRequestVer1(srpObject, lspObject, msgPath);
|
| 151 | }
|
| 152 |
|
| 153 | @Override
|
| 154 | public PcepSrpObject getSrpObject() {
|
| 155 | return this.srpObject;
|
| 156 | }
|
| 157 |
|
| 158 | @Override
|
| 159 | public PcepLspObject getLspObject() {
|
| 160 | return this.lspObject;
|
| 161 | }
|
| 162 |
|
| 163 | @Override
|
| 164 | public PcepMsgPath getMsgPath() {
|
| 165 | return this.msgPath;
|
| 166 | }
|
| 167 |
|
| 168 | @Override
|
| 169 | public Builder setSrpObject(PcepSrpObject srpobj) {
|
| 170 | this.srpObject = srpobj;
|
| 171 | this.bIsSRPObjectSet = true;
|
| 172 | return this;
|
| 173 |
|
| 174 | }
|
| 175 |
|
| 176 | @Override
|
| 177 | public Builder setLspObject(PcepLspObject lspObject) {
|
| 178 | this.lspObject = lspObject;
|
| 179 | this.bIsLSPObjectSet = true;
|
| 180 | return this;
|
| 181 | }
|
| 182 |
|
| 183 | @Override
|
| 184 | public Builder setMsgPath(PcepMsgPath msgPath) {
|
| 185 | this.msgPath = msgPath;
|
| 186 | this.bIsPcepMsgPathSet = true;
|
| 187 | return this;
|
| 188 | }
|
| 189 | }
|
| 190 |
|
| 191 | @Override
|
bharat saraswal | f7364db | 2015-08-11 13:39:31 +0530 | [diff] [blame] | 192 | public String toString() {
|
bharat saraswal | e180630 | 2015-08-21 12:16:46 +0530 | [diff] [blame] | 193 | return MoreObjects.toStringHelper(getClass()).add("SrpObject", srpObject).add("LspObject", lspObject)
|
| 194 | .add("MsgPath", msgPath).toString();
|
bharat saraswal | f7364db | 2015-08-11 13:39:31 +0530 | [diff] [blame] | 195 | }
|
| 196 | } |