@Action(name = "login") public String login(@ActionParam("username") final String username, @ActionParam("password") final String password) throws UserManagerException, ServletException { final String ip = ResourceUtils.getRealClientIpAddr(this.getContext()); logger .info("Attempting to login for " + username + " from ip '" + ip + "'"); final Session session = createSession(username, password, ip); logger.info("Session id created for user '" + username + "' and ip " + ip); return session.getSessionId(); }
String actionName = actionAnno.name(); List<Parameter<?>> parameters = getParameters(model, method, ResourceMethod.ACTION); if (model.getResourceLevel() == ResourceLevel.ENTITY && actionAnno.resourceLevel() == ResourceLevel.COLLECTION)
private static ResourceLevel getActionResourceLevel(Action annotation, ResourceModel definingModel) { return annotation.resourceLevel() == ResourceLevel.ANY ? definingModel.getResourceLevel() : annotation.resourceLevel(); }
private static TyperefDataSchema getActionTyperefDataSchema(ResourceModel model, Action actionAnno, String actionName) { TyperefDataSchema returnTyperefSchema = null; Class<? extends TyperefInfo> typerefInfoClass = actionAnno.returnTyperef(); try { returnTyperefSchema = getSchemaFromTyperefInfo(typerefInfoClass); } catch (Exception e) { throw new ResourceConfigException("Typeref @Action method named '" + actionName + "' on class '" + model.getResourceClass().getName() + "' cannot be instantiated, " + e.getMessage()); } return returnTyperefSchema; }
if (checkTyperefMessage != null) throw new ResourceConfigException("Typeref @Action method named '" + method.getAnnotation(Action.class).name() + "' on class '" + model.getResourceClass().getName() + "', " + checkTyperefMessage);
@Action(name = "getUserFromSessionId") public User getUserFromSessionId(@ActionParam("sessionId") final String sessionId) { final Session session = getSessionFromSessionId(sessionId); final azkaban.user.User azUser = session.getUser(); // Fill out the restli object with properties from the Azkaban user final User user = new User(); user.setUserId(azUser.getUserId()); user.setEmail(azUser.getEmail()); return user; }
@Action(name = "deploy") public String deploy(@ActionParam("sessionId") final String sessionId, @ActionParam("projectName") final String projectName,
@Action(name = "shutDownFlashback") public void shutDownFlashback() { validate(); _flashbackRunner.stop(); }
@Action(name = "changeMatchRule") public void changeMatchRule(@ActionParam("matchRule") String matchRule) { validate(); MatchRule namedMatchRule = NamedMatchRule.fromString(matchRule); if (namedMatchRule == null) { throw new RestLiServiceException(HttpStatus.S_400_BAD_REQUEST, "Unknown match rule" + matchRule); } _flashbackRunner.setMatchRule(namedMatchRule); }
@Action(name = "changeScene") public void changeScene(@ActionParam("sceneName") String sceneName) { validate(); SceneConfiguration sceneConfiguration = new SceneConfiguration(_scenePath, _currSceneMode, sceneName); try { _flashbackRunner.setScene(SceneFactory.create(sceneConfiguration)); } catch (IOException e) { throw new RestLiServiceException(HttpStatus.S_500_INTERNAL_SERVER_ERROR, e); } }
/** * Pretend to delete all greetings * @return the number of greetings purged, always 100 */ @Action(name = "purge") public int purge() { return 100; }
@Action(name = "returnNullActionResult") public ActionResult<Integer> returnNull() { return null; }
@Action(name = "nullPromise") public Promise<String> nullPromise() { return null; }
@Action(name = "arrayPromise") public Promise<Integer[]> arrayPromise() { return null; }
@Action(name="action") public int action() { return 1; }
@Action(name="spamContacts", resourceLevel=ResourceLevel.COLLECTION) public void spamContacts() { } }
@Action(name="returnInt") public int returnPrimitive() { return 0; }
@Action(name="get") public String get() { return "Hello, World"; }
@Action(name = "entityAction", resourceLevel = ResourceLevel.ENTITY) public int entityAction() { return 1; } }
@Action(name = "returnNullStringArray") public StringArray returnNullStringArray() { return null; }