Fix for ONOS-4836
Change-Id: Ic2f0d36a8238221a1093fda259156485674f6d44
Showing
4 changed files
with
20 additions
and
26 deletions
... | @@ -53,10 +53,6 @@ public class FilteringObjectiveCodec extends JsonCodec<FilteringObjective> { | ... | @@ -53,10 +53,6 @@ public class FilteringObjectiveCodec extends JsonCodec<FilteringObjective> { |
53 | " member is required in FilteringObjective"; | 53 | " member is required in FilteringObjective"; |
54 | private static final String NOT_NULL_MESSAGE = | 54 | private static final String NOT_NULL_MESSAGE = |
55 | "FilteringObjective cannot be null"; | 55 | "FilteringObjective cannot be null"; |
56 | - private static final String INVALID_TYPE_MESSAGE = | ||
57 | - "The requested type {} is not defined in FilteringObjective."; | ||
58 | - private static final String INVALID_OP_MESSAGE = | ||
59 | - "The requested operation {} is not defined for FilteringObjective."; | ||
60 | 56 | ||
61 | public static final String REST_APP_ID = "org.onosproject.rest"; | 57 | public static final String REST_APP_ID = "org.onosproject.rest"; |
62 | 58 | ||
... | @@ -133,8 +129,8 @@ public class FilteringObjectiveCodec extends JsonCodec<FilteringObjective> { | ... | @@ -133,8 +129,8 @@ public class FilteringObjectiveCodec extends JsonCodec<FilteringObjective> { |
133 | builder.deny(); | 129 | builder.deny(); |
134 | break; | 130 | break; |
135 | default: | 131 | default: |
136 | - log.warn(INVALID_TYPE_MESSAGE, typeStr); | 132 | + throw new IllegalArgumentException("The requested type " + typeStr + |
137 | - return null; | 133 | + " is not defined for FilteringObjective."); |
138 | } | 134 | } |
139 | 135 | ||
140 | // decode key | 136 | // decode key |
... | @@ -173,8 +169,8 @@ public class FilteringObjectiveCodec extends JsonCodec<FilteringObjective> { | ... | @@ -173,8 +169,8 @@ public class FilteringObjectiveCodec extends JsonCodec<FilteringObjective> { |
173 | filteringObjective = builder.remove(); | 169 | filteringObjective = builder.remove(); |
174 | break; | 170 | break; |
175 | default: | 171 | default: |
176 | - log.warn(INVALID_OP_MESSAGE, opStr); | 172 | + throw new IllegalArgumentException("The requested operation " + opStr + |
177 | - return null; | 173 | + " is not defined for FilteringObjective."); |
178 | } | 174 | } |
179 | 175 | ||
180 | return filteringObjective; | 176 | return filteringObjective; | ... | ... |
... | @@ -50,10 +50,6 @@ public class ForwardingObjectiveCodec extends JsonCodec<ForwardingObjective> { | ... | @@ -50,10 +50,6 @@ public class ForwardingObjectiveCodec extends JsonCodec<ForwardingObjective> { |
50 | " member is required in ForwardingObjective"; | 50 | " member is required in ForwardingObjective"; |
51 | private static final String NOT_NULL_MESSAGE = | 51 | private static final String NOT_NULL_MESSAGE = |
52 | "ForwardingObjective cannot be null"; | 52 | "ForwardingObjective cannot be null"; |
53 | - private static final String INVALID_FLAG_MESSAGE = | ||
54 | - "The requested flag {} is not defined in ForwardingObjective."; | ||
55 | - private static final String INVALID_OP_MESSAGE = | ||
56 | - "The requested operation {} is not defined for FilteringObjective."; | ||
57 | 53 | ||
58 | public static final String REST_APP_ID = "org.onosproject.rest"; | 54 | public static final String REST_APP_ID = "org.onosproject.rest"; |
59 | 55 | ||
... | @@ -129,8 +125,8 @@ public class ForwardingObjectiveCodec extends JsonCodec<ForwardingObjective> { | ... | @@ -129,8 +125,8 @@ public class ForwardingObjectiveCodec extends JsonCodec<ForwardingObjective> { |
129 | builder.withFlag(ForwardingObjective.Flag.VERSATILE); | 125 | builder.withFlag(ForwardingObjective.Flag.VERSATILE); |
130 | break; | 126 | break; |
131 | default: | 127 | default: |
132 | - log.warn(INVALID_FLAG_MESSAGE, flagStr); | 128 | + throw new IllegalArgumentException("The requested flag " + flagStr + |
133 | - return null; | 129 | + " is not defined for FilteringObjective."); |
134 | } | 130 | } |
135 | 131 | ||
136 | // decode selector | 132 | // decode selector |
... | @@ -155,7 +151,7 @@ public class ForwardingObjectiveCodec extends JsonCodec<ForwardingObjective> { | ... | @@ -155,7 +151,7 @@ public class ForwardingObjectiveCodec extends JsonCodec<ForwardingObjective> { |
155 | 151 | ||
156 | // decode operation | 152 | // decode operation |
157 | String opStr = nullIsIllegal(json.get(OPERATION), OPERATION + MISSING_MEMBER_MESSAGE).asText(); | 153 | String opStr = nullIsIllegal(json.get(OPERATION), OPERATION + MISSING_MEMBER_MESSAGE).asText(); |
158 | - ForwardingObjective forwardingObjective; | 154 | + ForwardingObjective forwardingObjective = null; |
159 | 155 | ||
160 | switch (opStr) { | 156 | switch (opStr) { |
161 | case "ADD": | 157 | case "ADD": |
... | @@ -165,8 +161,8 @@ public class ForwardingObjectiveCodec extends JsonCodec<ForwardingObjective> { | ... | @@ -165,8 +161,8 @@ public class ForwardingObjectiveCodec extends JsonCodec<ForwardingObjective> { |
165 | forwardingObjective = builder.remove(); | 161 | forwardingObjective = builder.remove(); |
166 | break; | 162 | break; |
167 | default: | 163 | default: |
168 | - log.warn(INVALID_OP_MESSAGE, opStr); | 164 | + throw new IllegalArgumentException("The requested operation " + opStr + |
169 | - return null; | 165 | + " is not defined for FilteringObjective."); |
170 | } | 166 | } |
171 | 167 | ||
172 | return forwardingObjective; | 168 | return forwardingObjective; | ... | ... |
... | @@ -53,10 +53,6 @@ public class NextObjectiveCodec extends JsonCodec<NextObjective> { | ... | @@ -53,10 +53,6 @@ public class NextObjectiveCodec extends JsonCodec<NextObjective> { |
53 | " member is required in NextObjective"; | 53 | " member is required in NextObjective"; |
54 | private static final String NOT_NULL_MESSAGE = | 54 | private static final String NOT_NULL_MESSAGE = |
55 | "NextObjective cannot be null"; | 55 | "NextObjective cannot be null"; |
56 | - private static final String INVALID_TYPE_MESSAGE = | ||
57 | - "The requested flag {} is not defined in NextObjective."; | ||
58 | - private static final String INVALID_OP_MESSAGE = | ||
59 | - "The requested operation {} is not defined for NextObjective."; | ||
60 | 56 | ||
61 | public static final String REST_APP_ID = "org.onosproject.rest"; | 57 | public static final String REST_APP_ID = "org.onosproject.rest"; |
62 | 58 | ||
... | @@ -141,8 +137,8 @@ public class NextObjectiveCodec extends JsonCodec<NextObjective> { | ... | @@ -141,8 +137,8 @@ public class NextObjectiveCodec extends JsonCodec<NextObjective> { |
141 | builder.withType(NextObjective.Type.SIMPLE); | 137 | builder.withType(NextObjective.Type.SIMPLE); |
142 | break; | 138 | break; |
143 | default: | 139 | default: |
144 | - log.warn(INVALID_TYPE_MESSAGE, typeStr); | 140 | + throw new IllegalArgumentException("The requested type " + typeStr + |
145 | - return null; | 141 | + " is not defined for FilteringObjective."); |
146 | } | 142 | } |
147 | 143 | ||
148 | // decode treatments | 144 | // decode treatments |
... | @@ -174,8 +170,8 @@ public class NextObjectiveCodec extends JsonCodec<NextObjective> { | ... | @@ -174,8 +170,8 @@ public class NextObjectiveCodec extends JsonCodec<NextObjective> { |
174 | nextObjective = builder.remove(); | 170 | nextObjective = builder.remove(); |
175 | break; | 171 | break; |
176 | default: | 172 | default: |
177 | - log.warn(INVALID_OP_MESSAGE, opStr); | 173 | + throw new IllegalArgumentException("The requested operation " + opStr + |
178 | - return null; | 174 | + " is not defined for FilteringObjective."); |
179 | } | 175 | } |
180 | 176 | ||
181 | return nextObjective; | 177 | return nextObjective; | ... | ... |
... | @@ -3,6 +3,7 @@ | ... | @@ -3,6 +3,7 @@ |
3 | "title": "nextObjective", | 3 | "title": "nextObjective", |
4 | "required": [ | 4 | "required": [ |
5 | "type", | 5 | "type", |
6 | + "id", | ||
6 | "priority", | 7 | "priority", |
7 | "timeout", | 8 | "timeout", |
8 | "isPermanent", | 9 | "isPermanent", |
... | @@ -16,6 +17,11 @@ | ... | @@ -16,6 +17,11 @@ |
16 | "type": "string", | 17 | "type": "string", |
17 | "example": "HASHED" | 18 | "example": "HASHED" |
18 | }, | 19 | }, |
20 | + "id": { | ||
21 | + "type": "integer", | ||
22 | + "format": "int64", | ||
23 | + "example": 1 | ||
24 | + }, | ||
19 | "priority": { | 25 | "priority": { |
20 | "type": "integer", | 26 | "type": "integer", |
21 | "format": "int64", | 27 | "format": "int64", |
... | @@ -308,4 +314,4 @@ | ... | @@ -308,4 +314,4 @@ |
308 | } | 314 | } |
309 | } | 315 | } |
310 | } | 316 | } |
311 | -} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
317 | +} | ... | ... |
-
Please register or login to post a comment