@Override public String getCommandName() { return getClass().getAnnotation(APICommand.class).name(); }
@Override public String getCommandName() { return getClass().getAnnotation(APICommand.class).name(); }
private static synchronized void addAuthenticator(Class<?> authenticator, APICommand command) { s_authenticators.put(command.name().toLowerCase(), authenticator); }
/** * Gets the CommandName based on the class annotations: the value from {@link APICommand#name()} * * @return the value from {@link APICommand#name()} */ public String getActualCommandName() { String cmdName = null; if (this.getClass().getAnnotation(APICommand.class) != null) { cmdName = this.getClass().getAnnotation(APICommand.class).name(); } else { cmdName = this.getClass().getName(); } return cmdName; }
@Override public boolean start() { for (PluggableService service : services) { for (Class<?> clz : service.getCommands()) { APICommand command = clz.getAnnotation(APICommand.class); for (RoleType role : command.authorized()) { Set<String> commands = annotationRoleBasedApisMap.get(role); if (!commands.contains(command.name())) commands.add(command.name()); } if (!commandNames.contains(command.name())) { commandNames.add(command.name()); } } } return super.start(); }
private void doAccessChecks(BaseCmd cmd, Map<Object, AccessType> entitiesToAccess) { Account caller = CallContext.current().getCallingAccount(); APICommand commandAnnotation = cmd.getClass().getAnnotation(APICommand.class); String apiName = commandAnnotation != null ? commandAnnotation.name() : null; if (!entitiesToAccess.isEmpty()) { for (Object entity : entitiesToAccess.keySet()) { if (entity instanceof ControlledEntity) { _accountMgr.checkAccess(caller, entitiesToAccess.get(entity), false, apiName, (ControlledEntity) entity); } else if (entity instanceof InfrastructureEntity) { //FIXME: Move this code in adapter, remove code from Account manager } } } }
@Override public boolean start() { initAuthenticator(); for (Class<?> authenticator: getCommands()) { APICommand command = authenticator.getAnnotation(APICommand.class); if (command != null && !command.name().isEmpty() && APIAuthenticator.class.isAssignableFrom(authenticator)) { addAuthenticator(authenticator, command); } } return true; }
@Override public boolean start() { for (PluggableService service : services) { for (Class<?> clz : service.getCommands()) { APICommand command = clz.getAnnotation(APICommand.class); for (RoleType role : command.authorized()) { addApiToRoleBasedAnnotationsMap(role, command.name()); } } } return super.start(); }
continue; String apiName = cmdClass.getAnnotation(APICommand.class).name(); if (s_apiNameCmdClassMap.containsKey(apiName)) {
String apiName = at.name(); List<Class<?>> apiCmdList = s_apiNameCmdClassMap.get(apiName); if (apiCmdList == null) {
apiCmdAnnotation = cmdClass.getSuperclass().getAnnotation(APICommand.class); if (apiCmdAnnotation == null || !apiCmdAnnotation.includeInApiDoc() || apiCmdAnnotation.name().isEmpty()) { continue; String apiName = apiCmdAnnotation.name(); if (s_logger.isTraceEnabled()) { s_logger.trace("Found api: " + apiName);
private ApiDiscoveryResponse getCmdRequestMap(Class<?> cmdClass, APICommand apiCmdAnnotation) { String apiName = apiCmdAnnotation.name(); ApiDiscoveryResponse response = new ApiDiscoveryResponse(); response.setName(apiName); response.setDescription(apiCmdAnnotation.description()); if (!apiCmdAnnotation.since().isEmpty()) { response.setSince(apiCmdAnnotation.since()); } Set<Field> fields = ReflectUtil.getAllFieldsForClass(cmdClass, new Class<?>[] {BaseCmd.class, BaseAsyncCmd.class, BaseAsyncCreateCmd.class}); boolean isAsync = ReflectUtil.isCmdClassAsync(cmdClass, new Class<?>[] {BaseAsyncCmd.class, BaseAsyncCreateCmd.class}); response.setAsync(isAsync); for (Field field : fields) { Parameter parameterAnnotation = field.getAnnotation(Parameter.class); if (parameterAnnotation != null && parameterAnnotation.expose() && parameterAnnotation.includeInApiDoc()) { ApiParameterResponse paramResponse = new ApiParameterResponse(); paramResponse.setName(parameterAnnotation.name()); paramResponse.setDescription(parameterAnnotation.description()); paramResponse.setType(parameterAnnotation.type().toString().toLowerCase()); paramResponse.setLength(parameterAnnotation.length()); paramResponse.setRequired(parameterAnnotation.required()); if (!parameterAnnotation.since().isEmpty()) { paramResponse.setSince(parameterAnnotation.since()); } paramResponse.setRelated(parameterAnnotation.entityType()[0].getName()); response.addParam(paramResponse); } } return response; }