fixed Null pointer exception

revert-70aa11f8
ayyoob 8 years ago
parent d4ec0705e7
commit 5b3a8091ec

@ -74,6 +74,7 @@ public class AnnotationProcessor {
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_VALUE = "value"; private static final String SWAGGER_ANNOTATIONS_PROPERTIES_VALUE = "value";
private static final String ANNOTATIONS_SCOPES = "scopes"; private static final String ANNOTATIONS_SCOPES = "scopes";
private static final String ANNOTATIONS_SCOPE = "scope"; private static final String ANNOTATIONS_SCOPE = "scope";
private static final String DEFAULT_SCOPE_NAME = "default admin scope";
private static final String DEFAULT_SCOPE_KEY = "perm:admin"; private static final String DEFAULT_SCOPE_KEY = "perm:admin";
private static final String DEFAULT_SCOPE_PERMISSION = "/permision/device-mgt"; private static final String DEFAULT_SCOPE_PERMISSION = "/permision/device-mgt";
@ -280,8 +281,11 @@ public class AnnotationProcessor {
if (scope != null) { if (scope != null) {
resource.setScope(scope); resource.setScope(scope);
} else { } else {
log.error("Scope is not defined for '" + makeContextURLReady(resourceRootContext) + log.warn("Scope is not defined for '" + makeContextURLReady(resourceRootContext) +
makeContextURLReady(subCtx) + "' endpoint, hence assigning the default scope"); makeContextURLReady(subCtx) + "' endpoint, hence assigning the default scope");
scope = new Scope();
scope.setName(DEFAULT_SCOPE_NAME);
scope.setDescription(DEFAULT_SCOPE_NAME);
scope.setKey(DEFAULT_SCOPE_KEY); scope.setKey(DEFAULT_SCOPE_KEY);
scope.setRoles(DEFAULT_SCOPE_PERMISSION); scope.setRoles(DEFAULT_SCOPE_PERMISSION);
resource.setScope(scope); resource.setScope(scope);

@ -71,7 +71,8 @@ public class AnnotationProcessor {
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_PERMISSIONS = "permissions"; private static final String SWAGGER_ANNOTATIONS_PROPERTIES_PERMISSIONS = "permissions";
private static final String ANNOTATIONS_SCOPES = "scopes"; private static final String ANNOTATIONS_SCOPES = "scopes";
private static final String ANNOTATIONS_SCOPE = "scope"; private static final String ANNOTATIONS_SCOPE = "scope";
private static final String DEFAULT_PERM_NAME = "default";
private static final String DEFAULT_PERM = "/device-mgt";
private static final String PERMISSION_PREFIX = "/permission/admin"; private static final String PERMISSION_PREFIX = "/permission/admin";
private StandardContext context; private StandardContext context;
@ -392,9 +393,15 @@ public class AnnotationProcessor {
.getMethod(SWAGGER_ANNOTATIONS_PROPERTIES_VALUE, null), null); .getMethod(SWAGGER_ANNOTATIONS_PROPERTIES_VALUE, null), null);
if (!scopeKey.isEmpty()) { if (!scopeKey.isEmpty()) {
scope = apiScopes.get(scopeKey); scope = apiScopes.get(scopeKey);
permission.setName(scope.getName()); if (scope != null) {
//TODO: currently permission tree supports only adding one permission per API point. permission.setName(scope.getName());
permission.setPath(scope.getRoles().split(" ")[0]); //TODO: currently permission tree supports only adding one permission per API point.
permission.setPath(scope.getRoles().split(" ")[0]);
} else {
log.warn("No Scope mapping is done for scope key: " + scopeKey);
permission.setName(DEFAULT_PERM_NAME);
permission.setPath(DEFAULT_PERM);
}
} }
} }
} }

Loading…
Cancel
Save