Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014-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 | package org.onosproject.xosintegration; |
| 17 | |
Jonathan Hart | 5e9a63d | 2015-05-19 16:21:46 -0700 | [diff] [blame] | 18 | import com.eclipsesource.json.JsonArray; |
| 19 | import com.eclipsesource.json.JsonObject; |
| 20 | import com.sun.jersey.api.client.Client; |
Jonathan Hart | b455803 | 2015-05-20 16:32:04 -0700 | [diff] [blame] | 21 | import com.sun.jersey.api.client.ClientHandlerException; |
Jonathan Hart | 5e9a63d | 2015-05-19 16:21:46 -0700 | [diff] [blame] | 22 | import com.sun.jersey.api.client.ClientResponse; |
| 23 | import com.sun.jersey.api.client.WebResource; |
| 24 | import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter; |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 25 | import org.apache.felix.scr.annotations.Activate; |
| 26 | import org.apache.felix.scr.annotations.Component; |
| 27 | import org.apache.felix.scr.annotations.Deactivate; |
| 28 | import org.apache.felix.scr.annotations.Modified; |
| 29 | import org.apache.felix.scr.annotations.Property; |
| 30 | import org.apache.felix.scr.annotations.Reference; |
| 31 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
| 32 | import org.apache.felix.scr.annotations.Service; |
Jonathan Hart | 5e9a63d | 2015-05-19 16:21:46 -0700 | [diff] [blame] | 33 | import org.onlab.packet.VlanId; |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 34 | import org.onlab.util.Tools; |
| 35 | import org.onosproject.cfg.ComponentConfigService; |
| 36 | import org.onosproject.core.ApplicationId; |
| 37 | import org.onosproject.core.CoreService; |
Jonathan Hart | 5e9a63d | 2015-05-19 16:21:46 -0700 | [diff] [blame] | 38 | import org.onosproject.net.ConnectPoint; |
| 39 | import org.onosproject.net.DeviceId; |
| 40 | import org.onosproject.net.PortNumber; |
| 41 | import org.onosproject.net.flow.DefaultTrafficSelector; |
| 42 | import org.onosproject.net.flow.DefaultTrafficTreatment; |
| 43 | import org.onosproject.net.flow.TrafficSelector; |
| 44 | import org.onosproject.net.flow.TrafficTreatment; |
| 45 | import org.onosproject.net.flowobjective.DefaultForwardingObjective; |
| 46 | import org.onosproject.net.flowobjective.FlowObjectiveService; |
| 47 | import org.onosproject.net.flowobjective.ForwardingObjective; |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 48 | import org.osgi.service.component.ComponentContext; |
| 49 | import org.slf4j.Logger; |
| 50 | |
Jonathan Hart | 5e9a63d | 2015-05-19 16:21:46 -0700 | [diff] [blame] | 51 | import java.util.Dictionary; |
| 52 | import java.util.Set; |
| 53 | import java.util.stream.Collectors; |
| 54 | import java.util.stream.IntStream; |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 55 | |
| 56 | import static com.google.common.base.Strings.isNullOrEmpty; |
| 57 | import static com.google.common.net.MediaType.JSON_UTF_8; |
| 58 | import static java.net.HttpURLConnection.HTTP_CREATED; |
| 59 | import static java.net.HttpURLConnection.HTTP_NO_CONTENT; |
| 60 | import static java.net.HttpURLConnection.HTTP_OK; |
| 61 | import static org.slf4j.LoggerFactory.getLogger; |
| 62 | |
| 63 | |
| 64 | /** |
| 65 | * XOS interface application. |
| 66 | */ |
| 67 | @Component(immediate = true) |
| 68 | @Service |
| 69 | public class OnosXOSIntegrationManager implements VoltTenantService { |
Ray Milkey | dea9817 | 2015-05-18 10:39:39 -0700 | [diff] [blame] | 70 | private static final String XOS_SERVER_ADDRESS_PROPERTY_NAME = |
| 71 | "xosServerAddress"; |
| 72 | private static final String XOS_SERVER_PORT_PROPERTY_NAME = |
| 73 | "xosServerPort"; |
| 74 | private static final String XOS_PROVIDER_SERVICE_PROPERTY_NAME = |
| 75 | "xosProviderService"; |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 76 | |
| 77 | private static final String TEST_XOS_SERVER_ADDRESS = "10.254.1.22"; |
| 78 | private static final int TEST_XOS_SERVER_PORT = 8000; |
| 79 | private static final String XOS_TENANT_BASE_URI = "/xoslib/volttenant/"; |
Ray Milkey | dea9817 | 2015-05-18 10:39:39 -0700 | [diff] [blame] | 80 | private static final int TEST_XOS_PROVIDER_SERVICE = 1; |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 81 | |
Jonathan Hart | b455803 | 2015-05-20 16:32:04 -0700 | [diff] [blame] | 82 | private static final int PRIORITY = 50000; |
Jonathan Hart | 5e9a63d | 2015-05-19 16:21:46 -0700 | [diff] [blame] | 83 | private static final DeviceId FABRIC_DEVICE_ID = DeviceId.deviceId("of:5e3e486e73000187"); |
| 84 | private static final PortNumber FABRIC_OLT_CONNECT_POINT = PortNumber.portNumber(2); |
| 85 | private static final PortNumber FABRIC_VCPE_CONNECT_POINT = PortNumber.portNumber(3); |
| 86 | private static final String FABRIC_CONTROLLER_ADDRESS = "10.0.3.136"; |
| 87 | private static final int FABRIC_SERVER_PORT = 8181; |
| 88 | private static final String FABRIC_BASE_URI = "/onos/cordfabric/vlans/add"; |
| 89 | |
| 90 | private static final ConnectPoint FABRIC_PORT = new ConnectPoint( |
| 91 | DeviceId.deviceId("of:000090e2ba82f974"), |
| 92 | PortNumber.portNumber(2)); |
| 93 | |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 94 | private final Logger log = getLogger(getClass()); |
| 95 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 96 | protected CoreService coreService; |
| 97 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 98 | protected ComponentConfigService cfgService; |
Ray Milkey | dea9817 | 2015-05-18 10:39:39 -0700 | [diff] [blame] | 99 | |
Jonathan Hart | 5e9a63d | 2015-05-19 16:21:46 -0700 | [diff] [blame] | 100 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 101 | protected FlowObjectiveService flowObjectiveService; |
| 102 | |
Ray Milkey | dea9817 | 2015-05-18 10:39:39 -0700 | [diff] [blame] | 103 | @Property(name = XOS_SERVER_ADDRESS_PROPERTY_NAME, |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 104 | value = TEST_XOS_SERVER_ADDRESS, |
| 105 | label = "XOS Server address") |
| 106 | protected String xosServerAddress = TEST_XOS_SERVER_ADDRESS; |
Ray Milkey | dea9817 | 2015-05-18 10:39:39 -0700 | [diff] [blame] | 107 | |
| 108 | @Property(name = XOS_SERVER_PORT_PROPERTY_NAME, |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 109 | intValue = TEST_XOS_SERVER_PORT, |
| 110 | label = "XOS Server port") |
| 111 | protected int xosServerPort = TEST_XOS_SERVER_PORT; |
Ray Milkey | dea9817 | 2015-05-18 10:39:39 -0700 | [diff] [blame] | 112 | |
| 113 | @Property(name = XOS_PROVIDER_SERVICE_PROPERTY_NAME, |
| 114 | intValue = TEST_XOS_PROVIDER_SERVICE, |
| 115 | label = "XOS Provider Service") |
| 116 | protected int xosProviderService = TEST_XOS_PROVIDER_SERVICE; |
| 117 | |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 118 | private ApplicationId appId; |
| 119 | |
| 120 | @Activate |
| 121 | public void activate(ComponentContext context) { |
| 122 | log.info("XOS app is starting"); |
| 123 | cfgService.registerProperties(getClass()); |
| 124 | appId = coreService.registerApplication("org.onosproject.xosintegration"); |
| 125 | readComponentConfiguration(context); |
| 126 | |
| 127 | log.info("XOS({}) started", appId.id()); |
| 128 | } |
| 129 | |
| 130 | @Deactivate |
| 131 | public void deactivate() { |
| 132 | cfgService.unregisterProperties(getClass(), false); |
| 133 | log.info("XOS({}) stopped", appId.id()); |
| 134 | } |
| 135 | |
| 136 | @Modified |
| 137 | public void modified(ComponentContext context) { |
| 138 | readComponentConfiguration(context); |
| 139 | } |
| 140 | |
| 141 | /** |
| 142 | * Converts a JSON representation of a tenant into a tenant object. |
| 143 | * |
| 144 | * @param jsonTenant JSON object representing the tenant |
| 145 | * @return volt tenant object |
| 146 | */ |
| 147 | private VoltTenant jsonToTenant(JsonObject jsonTenant) { |
| 148 | return VoltTenant.builder() |
| 149 | .withHumanReadableName(jsonTenant.get("humanReadableName").asString()) |
| 150 | .withId(jsonTenant.get("id").asInt()) |
| 151 | .withProviderService(jsonTenant.get("provider_service").asInt()) |
| 152 | .withServiceSpecificId(jsonTenant.get("service_specific_id").asString()) |
| 153 | .withVlanId(jsonTenant.get("vlan_id").asString()) |
| 154 | .build(); |
| 155 | } |
| 156 | |
| 157 | /** |
| 158 | * Converts a tenant object into a JSON string. |
| 159 | * |
| 160 | * @param tenant volt tenant object to convert |
| 161 | * @return JSON string for the tenant |
| 162 | */ |
| 163 | private String tenantToJson(VoltTenant tenant) { |
| 164 | return "{" |
| 165 | + "\"humanReadableName\": \"" + tenant.humanReadableName() + "\"," |
| 166 | + "\"id\": \"" + tenant.id() + "\"," |
| 167 | + "\"provider_service\": \"" + tenant.providerService() + "\"," |
| 168 | + "\"service_specific_id\": \"" + tenant.serviceSpecificId() + "\"," |
| 169 | + "\"vlan_id\": \"" + tenant.vlanId() + "\"" |
| 170 | + "}"; |
| 171 | } |
| 172 | |
| 173 | /** |
| 174 | * Gets a client web resource builder for the base XOS REST API |
| 175 | * with no additional URI. |
| 176 | * |
| 177 | * @return web resource builder |
| 178 | */ |
Simon Hunt | 8483e9d | 2015-05-26 18:22:07 -0700 | [diff] [blame] | 179 | @Deprecated |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 180 | private WebResource.Builder getClientBuilder() { |
| 181 | return getClientBuilder(""); |
| 182 | } |
| 183 | |
| 184 | /** |
| 185 | * Gets a client web resource builder for the base XOS REST API |
| 186 | * with an optional additional URI. |
| 187 | * |
| 188 | * @return web resource builder |
| 189 | */ |
Simon Hunt | 8483e9d | 2015-05-26 18:22:07 -0700 | [diff] [blame] | 190 | @Deprecated |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 191 | private WebResource.Builder getClientBuilder(String uri) { |
| 192 | String baseUrl = "http://" + xosServerAddress + ":" |
| 193 | + Integer.toString(xosServerPort); |
| 194 | Client client = Client.create(); |
| 195 | client.addFilter(new HTTPBasicAuthFilter("padmin@vicci.org", "letmein")); |
| 196 | WebResource resource = client.resource(baseUrl |
| 197 | + XOS_TENANT_BASE_URI + uri); |
| 198 | return resource.accept(JSON_UTF_8.toString()) |
| 199 | .type(JSON_UTF_8.toString()); |
| 200 | } |
| 201 | |
| 202 | /** |
| 203 | * Performs a REST GET operation on the base XOS REST URI. |
| 204 | * |
| 205 | * @return JSON string fetched by the GET operation |
| 206 | */ |
Simon Hunt | 8483e9d | 2015-05-26 18:22:07 -0700 | [diff] [blame] | 207 | @Deprecated |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 208 | private String getRest() { |
| 209 | return getRest(""); |
| 210 | } |
| 211 | |
| 212 | /** |
| 213 | * Performs a REST GET operation on the base XOS REST URI with |
| 214 | * an optional additional URI. |
| 215 | * |
| 216 | * @return JSON string fetched by the GET operation |
| 217 | */ |
Simon Hunt | 8483e9d | 2015-05-26 18:22:07 -0700 | [diff] [blame] | 218 | @Deprecated |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 219 | private String getRest(String uri) { |
| 220 | WebResource.Builder builder = getClientBuilder(uri); |
| 221 | ClientResponse response = builder.get(ClientResponse.class); |
| 222 | |
| 223 | if (response.getStatus() != HTTP_OK) { |
| 224 | log.info("REST GET request returned error code {}", |
| 225 | response.getStatus()); |
| 226 | } |
| 227 | String jsonString = response.getEntity(String.class); |
| 228 | log.info("JSON read:\n{}", jsonString); |
| 229 | |
| 230 | return jsonString; |
| 231 | } |
| 232 | |
| 233 | /** |
| 234 | * Performs a REST POST operation of a json string on the base |
| 235 | * XOS REST URI with an optional additional URI. |
| 236 | * |
| 237 | * @param json JSON string to post |
| 238 | */ |
Simon Hunt | 8483e9d | 2015-05-26 18:22:07 -0700 | [diff] [blame] | 239 | @Deprecated |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 240 | private void postRest(String json) { |
| 241 | WebResource.Builder builder = getClientBuilder(); |
Jonathan Hart | b455803 | 2015-05-20 16:32:04 -0700 | [diff] [blame] | 242 | ClientResponse response; |
| 243 | |
| 244 | try { |
| 245 | response = builder.post(ClientResponse.class, json); |
| 246 | } catch (ClientHandlerException e) { |
| 247 | log.warn("Unable to contact REST server: {}", e.getMessage()); |
| 248 | return; |
| 249 | } |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 250 | |
| 251 | if (response.getStatus() != HTTP_CREATED) { |
| 252 | log.info("REST POST request returned error code {}", |
| 253 | response.getStatus()); |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | /** |
| 258 | * Performs a REST DELETE operation on the base |
| 259 | * XOS REST URI with an optional additional URI. |
| 260 | * |
| 261 | * @param uri optional additional URI |
| 262 | */ |
Simon Hunt | 8483e9d | 2015-05-26 18:22:07 -0700 | [diff] [blame] | 263 | @Deprecated |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 264 | private void deleteRest(String uri) { |
| 265 | WebResource.Builder builder = getClientBuilder(uri); |
| 266 | ClientResponse response = builder.delete(ClientResponse.class); |
| 267 | |
| 268 | if (response.getStatus() != HTTP_NO_CONTENT) { |
| 269 | log.info("REST DELETE request returned error code {}", |
| 270 | response.getStatus()); |
| 271 | } |
| 272 | } |
| 273 | |
| 274 | /** |
| 275 | * Deletes the tenant with the given ID. |
| 276 | * |
| 277 | * @param tenantId ID of tenant to delete |
| 278 | */ |
| 279 | private void deleteTenant(long tenantId) { |
| 280 | deleteRest(Long.toString(tenantId)); |
| 281 | } |
| 282 | |
| 283 | @Override |
| 284 | public Set<VoltTenant> getAllTenants() { |
| 285 | String jsonString = getRest(); |
| 286 | |
| 287 | JsonArray voltTenantItems = JsonArray.readFrom(jsonString); |
| 288 | |
| 289 | return IntStream.range(0, voltTenantItems.size()) |
| 290 | .mapToObj(index -> jsonToTenant(voltTenantItems.get(index).asObject())) |
| 291 | .collect(Collectors.toSet()); |
| 292 | } |
| 293 | |
| 294 | @Override |
| 295 | public void removeTenant(long id) { |
| 296 | deleteTenant(id); |
| 297 | } |
| 298 | |
| 299 | @Override |
| 300 | public VoltTenant addTenant(VoltTenant newTenant) { |
Ray Milkey | dea9817 | 2015-05-18 10:39:39 -0700 | [diff] [blame] | 301 | long providerServiceId = newTenant.providerService(); |
| 302 | if (providerServiceId == -1) { |
| 303 | providerServiceId = xosProviderService; |
| 304 | } |
| 305 | VoltTenant tenantToCreate = VoltTenant.builder() |
| 306 | .withProviderService(providerServiceId) |
| 307 | .withServiceSpecificId(newTenant.serviceSpecificId()) |
| 308 | .withVlanId(newTenant.vlanId()) |
Jonathan Hart | 5e9a63d | 2015-05-19 16:21:46 -0700 | [diff] [blame] | 309 | .withPort(newTenant.port()) |
Ray Milkey | dea9817 | 2015-05-18 10:39:39 -0700 | [diff] [blame] | 310 | .build(); |
| 311 | String json = tenantToJson(tenantToCreate); |
Jonathan Hart | 5e9a63d | 2015-05-19 16:21:46 -0700 | [diff] [blame] | 312 | |
| 313 | provisionDataPlane(tenantToCreate); |
| 314 | |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 315 | postRest(json); |
Jonathan Hart | 5e9a63d | 2015-05-19 16:21:46 -0700 | [diff] [blame] | 316 | |
| 317 | provisionFabric(VlanId.vlanId(Short.parseShort(newTenant.vlanId()))); |
| 318 | |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 319 | return newTenant; |
| 320 | } |
| 321 | |
| 322 | @Override |
| 323 | public VoltTenant getTenant(long id) { |
| 324 | String jsonString = getRest(Long.toString(id)); |
| 325 | JsonObject jsonTenant = JsonObject.readFrom(jsonString); |
| 326 | if (jsonTenant.get("id") != null) { |
| 327 | return jsonToTenant(jsonTenant); |
| 328 | } else { |
| 329 | return null; |
| 330 | } |
| 331 | } |
| 332 | |
Jonathan Hart | 5e9a63d | 2015-05-19 16:21:46 -0700 | [diff] [blame] | 333 | private void provisionDataPlane(VoltTenant tenant) { |
| 334 | VlanId vlan = VlanId.vlanId(Short.parseShort(tenant.vlanId())); |
| 335 | |
| 336 | TrafficSelector fromGateway = DefaultTrafficSelector.builder() |
| 337 | .matchInPhyPort(tenant.port().port()) |
| 338 | .build(); |
| 339 | |
| 340 | TrafficSelector fromFabric = DefaultTrafficSelector.builder() |
| 341 | .matchInPhyPort(FABRIC_PORT.port()) |
| 342 | .matchVlanId(vlan) |
| 343 | .build(); |
| 344 | |
| 345 | TrafficTreatment toFabric = DefaultTrafficTreatment.builder() |
| 346 | .pushVlan() |
| 347 | .setVlanId(vlan) |
| 348 | .setOutput(FABRIC_PORT.port()) |
| 349 | .build(); |
| 350 | |
| 351 | TrafficTreatment toGateway = DefaultTrafficTreatment.builder() |
| 352 | .popVlan() |
| 353 | .setOutput(tenant.port().port()) |
| 354 | .build(); |
| 355 | |
| 356 | ForwardingObjective forwardToFabric = DefaultForwardingObjective.builder() |
| 357 | .withFlag(ForwardingObjective.Flag.VERSATILE) |
Jonathan Hart | b455803 | 2015-05-20 16:32:04 -0700 | [diff] [blame] | 358 | .withPriority(PRIORITY) |
Jonathan Hart | 5e9a63d | 2015-05-19 16:21:46 -0700 | [diff] [blame] | 359 | .makePermanent() |
| 360 | .fromApp(appId) |
| 361 | .withSelector(fromGateway) |
| 362 | .withTreatment(toFabric) |
| 363 | .add(); |
| 364 | |
| 365 | ForwardingObjective forwardToGateway = DefaultForwardingObjective.builder() |
| 366 | .withFlag(ForwardingObjective.Flag.VERSATILE) |
Jonathan Hart | b455803 | 2015-05-20 16:32:04 -0700 | [diff] [blame] | 367 | .withPriority(PRIORITY) |
Jonathan Hart | 5e9a63d | 2015-05-19 16:21:46 -0700 | [diff] [blame] | 368 | .makePermanent() |
| 369 | .fromApp(appId) |
| 370 | .withSelector(fromFabric) |
| 371 | .withTreatment(toGateway) |
| 372 | .add(); |
| 373 | |
| 374 | flowObjectiveService.forward(FABRIC_PORT.deviceId(), forwardToFabric); |
| 375 | flowObjectiveService.forward(FABRIC_PORT.deviceId(), forwardToGateway); |
| 376 | } |
| 377 | |
| 378 | private void provisionFabric(VlanId vlanId) { |
| 379 | String json = "{\"vlan\":" + vlanId + ",\"ports\":["; |
| 380 | json += "{\"device\":\"" + FABRIC_DEVICE_ID.toString() + "\",\"port\":\"" |
| 381 | + FABRIC_OLT_CONNECT_POINT.toString() + "\"},"; |
| 382 | json += "{\"device\":\"" + FABRIC_DEVICE_ID.toString() + "\",\"port\":\"" |
| 383 | + FABRIC_VCPE_CONNECT_POINT.toString() + "\"}"; |
| 384 | json += "]}"; |
| 385 | |
| 386 | String baseUrl = "http://" + FABRIC_CONTROLLER_ADDRESS + ":" |
| 387 | + Integer.toString(FABRIC_SERVER_PORT); |
| 388 | Client client = Client.create(); |
Jonathan Hart | b455803 | 2015-05-20 16:32:04 -0700 | [diff] [blame] | 389 | WebResource resource = client.resource(baseUrl + FABRIC_BASE_URI); |
Jonathan Hart | 5e9a63d | 2015-05-19 16:21:46 -0700 | [diff] [blame] | 390 | WebResource.Builder builder = resource.accept(JSON_UTF_8.toString()) |
| 391 | .type(JSON_UTF_8.toString()); |
| 392 | |
Jonathan Hart | b455803 | 2015-05-20 16:32:04 -0700 | [diff] [blame] | 393 | try { |
| 394 | builder.post(ClientResponse.class, json); |
| 395 | } catch (ClientHandlerException e) { |
| 396 | log.warn("Unable to contact fabric REST server:", e.getMessage()); |
| 397 | return; |
| 398 | } |
Jonathan Hart | 5e9a63d | 2015-05-19 16:21:46 -0700 | [diff] [blame] | 399 | } |
| 400 | |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 401 | /** |
| 402 | * Extracts properties from the component configuration context. |
| 403 | * |
| 404 | * @param context the component context |
| 405 | */ |
| 406 | private void readComponentConfiguration(ComponentContext context) { |
| 407 | Dictionary<?, ?> properties = context.getProperties(); |
| 408 | |
Ray Milkey | dea9817 | 2015-05-18 10:39:39 -0700 | [diff] [blame] | 409 | String newXosServerAddress = |
| 410 | Tools.get(properties, XOS_SERVER_ADDRESS_PROPERTY_NAME); |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 411 | if (!isNullOrEmpty(newXosServerAddress)) { |
| 412 | xosServerAddress = newXosServerAddress; |
| 413 | } |
| 414 | |
Ray Milkey | dea9817 | 2015-05-18 10:39:39 -0700 | [diff] [blame] | 415 | String newXosServerPortString = |
| 416 | Tools.get(properties, XOS_SERVER_PORT_PROPERTY_NAME); |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 417 | if (!isNullOrEmpty(newXosServerPortString)) { |
| 418 | xosServerPort = Integer.parseInt(newXosServerPortString); |
| 419 | } |
Ray Milkey | dea9817 | 2015-05-18 10:39:39 -0700 | [diff] [blame] | 420 | |
| 421 | String newXosProviderServiceString = |
| 422 | Tools.get(properties, XOS_PROVIDER_SERVICE_PROPERTY_NAME); |
| 423 | if (!isNullOrEmpty(newXosProviderServiceString)) { |
| 424 | xosProviderService = Integer.parseInt(newXosProviderServiceString); |
| 425 | } |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 426 | } |
| 427 | } |
| 428 | |
| 429 | |