@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(); }
@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); } }
@Action(name = "arrayPromise") public Promise<Integer[]> arrayPromise() { return null; }
@Action(name="action") public int action() { return 1; }
@Action(name = "exceptionTest") public void exceptionTest() { throw new RestLiServiceException(HttpStatus.S_500_INTERNAL_SERVER_ERROR, "Test Exception"); }
@Action(name="calendarAction") public int calendarAction(@ActionParam(value="calendar", typeref=CalendarRef.class) Calendar calendar) { return calendar.get(Calendar.YEAR); }
@Action(name = "floatFunc2", returnTyperef=FloatRef.class) public Float FloatFunc(@ActionParam(value="arg1", typeref=FloatRef.class) Float arg1) { return 100.0f; }
@Action(name = "doubleFunc", returnTyperef=DoubleRef.class) public double doubleFunc(@ActionParam(value="arg1", typeref=DoubleRef.class) double arg1) { return 100.0f; }
@Action(name = "timeout") public Promise<Void> timeout() { return Promises.settable(); // do nothing }
/** * Action that fails by throwing an exception */ @Action(name = "failCallbackThrow") public void failThrow(@CallbackParam final Callback<Void> callback) { throw new RuntimeException("This is an error."); }
@Action(name="echoMessageArray") public Message[] echoMessage(@ActionParam("messages") final Message[] messages) { return messages; }
/** * Action that responds HTTP 500 with integer value */ @Action(name = "exceptionWithValue") public ActionResult<Integer> exceptionWithValue() { return new ActionResult<Integer>(42, HttpStatus.S_500_INTERNAL_SERVER_ERROR); }
@Action(name="returnBoolOptionalParam") public boolean returnBoolOptionalParam(@Optional @ActionParam("param") final Boolean param) { return (param == null? Boolean.TRUE : param); }
@Action(name = "theAction") public void theAction(@CallbackParam Callback<String> callback) { callback.onSuccess("theResult"); } }
@Action(name = "startFlashback") public void startFlashback(@ActionParam("sceneMode") String sceneMode, @ActionParam("sceneName") String sceneName,
@Action(name = "someAction", resourceLevel = ResourceLevel.ENTITY) public Greeting someAction(@ActionParam("a") @Optional("1") int a, @ActionParam("b") @Optional("default") String b, @ActionParam("c") @Optional TransferOwnershipRequest c, @ActionParam("d") TransferOwnershipRequest d, @ActionParam("e") Integer e) { return createGreeting(); }