Package com.gadglet.core

Examples of com.gadglet.core.RequestException


      else
        hasMore.setFalse();
    } catch (Exception e) {
   
      log.warning(e.getMessage());
      throw new RequestException(ReqErrorTypes.REQUEST_FAILED);
    } finally {
      query.closeAll();
      pm.close();
    }
    return items;
View Full Code Here


     
      // load gadget
      Gadget g = GadgetUtils.getGadget(platformRequestWrapper.getGadgetName());
     
      if(g==null || g.getGadgletType()==null || !g.getGadgletType().equals(GadgetType.BIZLET.getGadgetType()))
        throw new RequestException(
            ReqErrorTypes.UNRECOGNIZED_GADGET);
      else
        platformRequestWrapper.setRequestedGadget(g);

    } catch (RequestException e) {
   
      userIsValid = false;
      gadgetServerResponse.setError(e);
    } catch (Exception e) {
     
      userIsValid = false;
      gadgetServerResponse.setError(new RequestException(
          ReqErrorTypes.REQUEST_FAILED));
      printStackTrace(e);
    }

    if (userIsValid)
View Full Code Here

    boolean userLogin = false;
 
    if (platformRequestWrapper.getOpenSocialViewerId() == null) {
     
      log.warning("opensocial_viewer_id is null");
      throw new RequestException(ReqErrorTypes.USER_NOT_LOGGEDIN);
    }

    if (!validateSignedRequestWithContainer(platformRequestWrapper)) {
      userLogin = false;
   
      throw new RequestException(ReqErrorTypes.USER_NOT_LOGGEDIN);
     
    }

    DomainUser domainUser = null;

    domainUser = (DomainUser) platformRequestWrapper.getSession()
        .getAttribute("domainUser");

    if (domainUser != null
        && domainUser.getOauthConsumerKey().equals(
            platformRequestWrapper.getOpenSocialConsumerKey())
        && domainUser.getOpensocialViewerId().equals(
            platformRequestWrapper.getOpenSocialViewerId())) {
   
      NamespaceManager.set(domainUser.getAccount());
      return true;
    }
    else
      domainUser = DomainUserUtils.getDomainUserByOpenSocial(platformRequestWrapper);
   
    if (domainUser != null){
      if (domainUser.getStatus() != DomainUserStatus.ACTIVE.getUserStatus())
        throw new RequestException(ReqErrorTypes.USER_NOT_ACTIVE);
     
      // set user in session
      if (platformRequestWrapper != null && domainUser != null) {
        platformRequestWrapper.getSession().setAttribute("domainUser",
            domainUser);
        NamespaceManager.set(domainUser.getAccount());
        return true;
      }
    }
   
   
    if (domainUser == null) {
      // Registration
      RegistrationToken token = null;
      // 5 cases:
      //  - token is ready with both OAUTH + SIGNED - send registration url
      //  - token is ready for SIGNED and only SIGNED is needed - send
      // registration url
      // - token is already SIGNED created - send do to OAUTH
      // - token is OAUTH created and id in the session - update SIGNED and
      // send registration url
      // - token is null. send request failed

      String tokenId = null;
      if (platformRequestWrapper.getRegistrationTokenId() != null) {
        tokenId = platformRequestWrapper.getRegistrationTokenId();
        try {
          token = RegistrationTokenUtils.updateTokenForOpenSocial(
              tokenId,
              platformRequestWrapper.getOpenSocialViewerId(),
              platformRequestWrapper.getOpenSocialConsumerKey());
        } catch (Exception e) {
          printStackTrace(e);
        }
      }

      if (token == null) {
        try {
          token = RegistrationTokenUtils
              .createNew(platformRequestWrapper);
          platformRequestWrapper.getSession().setAttribute(SharedConstants.registrationTokenParamName,token.getTokenID());
        } catch (Exception e) {
          log.warning(e.getMessage());
        }
      }
      if(token ==null)
        log.warning("token is null we have a problem");
      else if (token.isTokenReady())
        jsonResponse.addCustomFieldError(
            SharedConstants.registrationTokenParamName,
            token.getTokenID());
      else if (token.isOpenSocialReady() && userRegistrationMethod.equalsIgnoreCase(SharedConstants.registrationMethodSigned))
        jsonResponse.addCustomFieldError(
            SharedConstants.registrationTokenParamName,
            token.getTokenID());
      else if (!token.isOauthReady()){
        jsonResponse.addCustomFieldError(
            SharedConstants.registrationTokenParamName,
            token.getTokenID());
        jsonResponse.addCustomFieldError(SharedConstants.registrationProcessParamName, SharedConstants.registrationDoOAuth);
      }
      else
        token =null;
     
      if (token != null)
        throw new RequestException(ReqErrorTypes.USER_NOT_REGISTERED);
      else
        throw new RequestException(ReqErrorTypes.REQUEST_FAILED);
    }

    return userLogin;
  }
View Full Code Here

TOP

Related Classes of com.gadglet.core.RequestException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.