[GitHub] [brooklyn-server] algairim commented on a change in pull request #1300: Gracefully handle invalid sensor types in REST requests
algairim commented on a change in pull request #1300: URL: https://github.com/apache/brooklyn-server/pull/1300#discussion_r806874578 ## File path: rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/EntityAttributesUtils.java ## @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.brooklyn.rest.util; + +import org.apache.brooklyn.api.entity.Entity; +import org.apache.brooklyn.api.sensor.AttributeSensor; +import org.apache.brooklyn.util.exceptions.Exceptions; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class EntityAttributesUtils { Review comment: This is consistent with existing standalone utils and has nothing to do with `BrooklynRestResourceUtils`, which is used in in transformers to pull items from the management context. ## File path: rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/ScriptResource.java ## @@ -26,6 +26,7 @@ import org.apache.brooklyn.core.mgmt.entitlement.Entitlements; import org.apache.brooklyn.rest.api.ScriptApi; import org.apache.brooklyn.rest.domain.ScriptExecutionSummary; +import org.apache.brooklyn.rest.util.EntityAttributesUtils; Review comment: e6305e9a8df01b2ae5252609d849f3ededc020ff ## File path: rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/SensorResource.java ## @@ -26,14 +26,17 @@ import org.apache.brooklyn.api.entity.Entity; import org.apache.brooklyn.api.sensor.AttributeSensor; import org.apache.brooklyn.api.sensor.Sensor; +import org.apache.brooklyn.core.entity.Attributes; import org.apache.brooklyn.core.entity.EntityInternal; +import org.apache.brooklyn.core.entity.lifecycle.Lifecycle; Review comment: removed - e6305e9a8df01b2ae5252609d849f3ededc020ff -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@brooklyn.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [brooklyn-server] algairim commented on a change in pull request #1300: Gracefully handle invalid sensor types in REST requests
algairim commented on a change in pull request #1300: URL: https://github.com/apache/brooklyn-server/pull/1300#discussion_r806875310 ## File path: rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/SensorResource.java ## @@ -26,14 +26,17 @@ import org.apache.brooklyn.api.entity.Entity; import org.apache.brooklyn.api.sensor.AttributeSensor; import org.apache.brooklyn.api.sensor.Sensor; +import org.apache.brooklyn.core.entity.Attributes; import org.apache.brooklyn.core.entity.EntityInternal; +import org.apache.brooklyn.core.entity.lifecycle.Lifecycle; Review comment: removed - e6305e9a8df01b2ae5252609d849f3ededc020ff -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@brooklyn.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [brooklyn-server] algairim commented on a change in pull request #1300: Gracefully handle invalid sensor types in REST requests
algairim commented on a change in pull request #1300: URL: https://github.com/apache/brooklyn-server/pull/1300#discussion_r806875006 ## File path: rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/ScriptResource.java ## @@ -26,6 +26,7 @@ import org.apache.brooklyn.core.mgmt.entitlement.Entitlements; import org.apache.brooklyn.rest.api.ScriptApi; import org.apache.brooklyn.rest.domain.ScriptExecutionSummary; +import org.apache.brooklyn.rest.util.EntityAttributesUtils; Review comment: e6305e9a8df01b2ae5252609d849f3ededc020ff -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@brooklyn.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [brooklyn-server] algairim commented on a change in pull request #1300: Gracefully handle invalid sensor types in REST requests
algairim commented on a change in pull request #1300: URL: https://github.com/apache/brooklyn-server/pull/1300#discussion_r806874578 ## File path: rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/EntityAttributesUtils.java ## @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.brooklyn.rest.util; + +import org.apache.brooklyn.api.entity.Entity; +import org.apache.brooklyn.api.sensor.AttributeSensor; +import org.apache.brooklyn.util.exceptions.Exceptions; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class EntityAttributesUtils { Review comment: This is consistent with existing standalone utils and has nothing to do with `BrooklynRestResourceUtils`, which is used in in transformers to pull items from the management context. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@brooklyn.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [brooklyn-server] algairim commented on a change in pull request #1300: Gracefully handle invalid sensor types in REST requests
algairim commented on a change in pull request #1300: URL: https://github.com/apache/brooklyn-server/pull/1300#discussion_r805725049 ## File path: rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/ApplicationResource.java ## @@ -710,13 +711,7 @@ private void checkLocationsAreValid(ApplicationSpec applicationSpec) { return result; } for (Entity e: descs) { -Object v = null; -try { -v = e.getAttribute((AttributeSensor)s); -} catch (Exception exc) { -Exceptions.propagateIfFatal(exc); -log.warn("Error retrieving sensor "+s+" for "+e+" (ignoring): "+exc); -} Review comment: This code has been moved into `EntityAttributesUtils` and re-used in all explicit attempts to retrieve a sensor in `rest-resources` project, see next line. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@brooklyn.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org