コード例 #1
0
  @Override
  protected Object doProcessRequest(ActionParam inParam)
      throws InvalidParameterException, NoSuchProductException {

    final int skip = inParam.getInt(GetPressClip.SKIP_PARAM, 0);
    final int count = inParam.getInt(GetPressClip.COUNT_PARAM, 10);
    final String theLangCode = inParam.getString(GetPressClip.LANGUAGE_PARAM, true);
    final String theProductName = inParam.getString(GetPressClip.PRODUCT_PARAM, true);

    final ProductData theProductData = ProductData.findByName(theProductName);
    final SiteLangData theLang = SiteLangData.getByISOCode(theLangCode);
    final Product theProduct = theProductData.getReference();

    if (theProduct == null) {
      throw new NoSuchProductException(APIErrorMessage.NO_SUCH_PRODUCT, theProductName);
    }

    final List<PressInformationMap> pressFromProductAndLanguage =
        new LinkedList<PressInformationMap>();

    for (final PressData aPressData :
        PressData.findByLangAndProduct(theLang.getReference(), theProduct, skip, count)) {
      pressFromProductAndLanguage.add(new PressInformationMap(inParam.getCaller(), aPressData));
    }

    return pressFromProductAndLanguage;
  }
コード例 #2
0
  @Override
  protected Object doProcessRequest(ActionParam inParam)
      throws InvalidParameterException, NoSuchPersonException {

    final UserData theUser = getRequestedUser(inParam, null);
    return new PersonInformationMap(inParam.getCaller(), theUser, false);
  }
コード例 #3
0
  @Override
  protected Object doProcessRequest(ActionParam inParam)
      throws InvalidParameterException, ForbiddenException, InvalidSessionException {

    final UserData theSessionUser = SessionManager.getUserFromSessionParam(inParam);
    final Boolean activate = inParam.getBoolean(ManageToken.ACTIVATE);

    // just returns the token value if it exists
    if (activate == null) {
      if (theSessionUser.hasToken()) {
        return String.valueOf(theSessionUser.getToken());
      }

    } else {
      if (!theSessionUser.hasToken() && activate) {
        return String.valueOf(theSessionUser.generateToken());
      }

      if (theSessionUser.hasToken() && !activate) {
        theSessionUser.clearToken();
      }
    }

    return null;
  }
コード例 #4
0
  @Override
  protected Object doProcessRequest(ActionParam inParam)
      throws InvalidParameterException, NoSuchPersonException, ForbiddenException,
          InvalidSessionException, BadCredentialsException {

    final UserData theUser = getRequestedUser(inParam, null);

    // Check Session
    AbstractUserAction.doesSessionBelongToUser(theUser, inParam);

    final String old_password = inParam.getString("old_password", true);
    final String new_password = inParam.getString("new_password", true);
    if (old_password.equals(StringShop.EMPTY_STRING)) {
      throw new InvalidParameterException(
          APIErrorMessage.PASSWORD_CANNOT_BE_EMPTY, StringShop.EMPTY_STRING);
    }
    if (new_password.equals(StringShop.EMPTY_STRING)) {
      throw new InvalidParameterException(
          APIErrorMessage.PASSWORD_CANNOT_BE_EMPTY, StringShop.EMPTY_STRING);
    }

    if (!theUser.checkPasswordPlain(old_password)) {
      throw new BadCredentialsException(APIErrorMessage.INVALID_PASSWORD);
    }

    theUser.setPassword(new_password);

    return null;
  }
コード例 #5
0
  @Override
  protected Object doProcessRequest(ActionParam inParam) throws InvalidParameterException {

    final String startWith = inParam.getMainParamAsString();
    final String language = inParam.getString(GetApplications.LANGUAGE_PARAM, true);

    final List<ApplicationInformationMap> appInfoMaps = new ArrayList<ApplicationInformationMap>();

    final SiteLangData theLangData = SiteLangData.getByISOCode(language);

    if (!startWith.matches("net.violet.(rss|podcast|webradio|js|external).")) {
      throw new InvalidParameterException(APIErrorMessage.BAD_FORMAT, startWith);
    }

    final List<ApplicationData> appList =
        ApplicationData.findByLangAndApplicationNameStartingWith(theLangData, startWith);
    for (final ApplicationData appData : appList) {
      appInfoMaps.add(new ApplicationInformationMap(inParam.getCaller(), appData));
    }

    return appInfoMaps;
  }