Package com.gadglet.core

Examples of com.gadglet.core.RequestException


      } finally {
        if (pmToken.currentTransaction().isActive())
          pmToken.currentTransaction().rollback();
        pmToken.close();
      }
      throw new RequestException("userChangedIdOnRegistration");
    }

    Query accountQry = pmDomain.newQuery(DomainAccount.class);
    try {
View Full Code Here


    pm.currentTransaction().begin();
    try {
      item = (BookMarksList) helper.getSingleItemByKeyForAction(pm, request, BookMarksList.class);

      if (item == null)
        throw new RequestException(ReqErrorTypes.ITEM_NOT_FOUND);
     
      sharing =   item.getSharedItemReff();
     
      for(SharedItemReff share: sharing)
      {
        // in case not the owner (shared item)
        if(share.getSharedWithId().equals(request.getCurrentUserId()) && !share.getSharingType().equals(SharingType.OWNER))
          sharing.remove(share);
     
      }

      pm.makePersistent(item);
      pm.currentTransaction().commit();
    } catch (Exception e) {
      log.warning(e.getMessage());
      throw new RequestException(ReqErrorTypes.REQUEST_FAILED);
    } finally {
      if (pm.currentTransaction().isActive())
        pm.currentTransaction().rollback();
      pm.close();
    }
View Full Code Here

 
 

  @Override
  public void doAdd(GadgletRequestWrapper request, GadgletResponse response)throws RequestException{
    throw new RequestException(ReqErrorTypes.UNRECOGNIZED_ACTION);
  }
View Full Code Here

  }

  @Override
  public void doUpdate(GadgletRequestWrapper request, GadgletResponse response)
      throws RequestException {
    throw new RequestException(ReqErrorTypes.UNRECOGNIZED_ACTION);
  }
View Full Code Here


  @Override
  public void doView(GadgletRequestWrapper request, GadgletResponse response)
      throws RequestException {
    throw new RequestException(ReqErrorTypes.UNRECOGNIZED_ACTION);
  }
View Full Code Here

        params[1] = gadgletResponse;
        method.invoke((Object)handler, (Object[])params);
       
      }
      else
        throw new RequestException(
            ReqErrorTypes.UNRECOGNIZED_ACTION);

    }

    catch (RequestException e) {
      gadgletResponse.setError(e);
    } catch (Exception e) {
      gadgletResponse.setError(new RequestException(
          ReqErrorTypes.REQUEST_FAILED));

      printStackTrace(e);
    }
    PrintWriter out = null;
View Full Code Here

        if (pmToken.currentTransaction().isActive())
          pmToken.currentTransaction().rollback();

        pmToken.close();
      }
      throw new RequestException("userChangedIdOnRegistration");
    }

    // check if user exists
    DomainUser newUser = null;
    newUser = getDomainUserByOpenId(openIdUser);
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

      userLogin = true;


    } catch (OAuthRequestException e) {
      printStackTrace(e);
      throw new RequestException(ReqErrorTypes.USER_NOT_LOGGEDIN);

    }
    // in case the user changed his id during session (possible ?)
    if (domainUser != null && !user.getUserId().equals(domainUser.getId()))
      domainUser = null;

    if (domainUser != null) {
      NamespaceManager.set(domainUser.getAccount());
      return true;
    }


   
    domainUser = DomainUserUtils.getMyDomainUserWithOauth();
    // set user in session
   
    if (platformRequestWrapper != null && domainUser != null) {
         
      if (domainUser.getAccount() == null)
        throw new RequestException(ReqErrorTypes.USER_MISSING_ACCOUNT);
      if (domainUser.getStatus() != DomainUserStatus.ACTIVE.getUserStatus())
        throw new RequestException(ReqErrorTypes.USER_NOT_ACTIVE);
     
      platformRequestWrapper.getSession().setAttribute("domainUser",
          domainUser);
      NamespaceManager.set(domainUser.getAccount());
      return true;
    }
   
   
    if (domainUser == null)
    {
      // Registration

      RegistrationToken token = null;
      // in case of SIGNED
      if (userRegistrationMethod.equalsIgnoreCase(SharedConstants.registrationMethodSigned))
        jsonResponse.addCustomFieldError(SharedConstants.registrationProcessParamName,
            SharedConstants.registrationDoSigned);

      else
      {
     
        String tokenId = null;
        // work on token created in the current session

        if (platformRequestWrapper.getRegistrationTokenId() != null) {
          tokenId = platformRequestWrapper.getRegistrationTokenId();
          try {
            token = RegistrationTokenUtils.updateTokenForOauth(
                tokenId, user);
          } catch (Exception e) {
            printStackTrace(e);

          }
        }
        if (token == null) {
     
          try {
            token = RegistrationTokenUtils.createNew(user);

          } catch (Exception e) {
            printStackTrace(e);;
          }
        }

        //
        if (token != null) {
          jsonResponse.addCustomFieldError(
              SharedConstants.registrationTokenParamName,
              token.getTokenID());

          if (!token.isOpenSocialReady())
            jsonResponse.addCustomFieldError(
                SharedConstants.registrationProcessParamName,
                SharedConstants.registrationDoSigned);
        }
      }

      if (token != null)
        throw new RequestException(ReqErrorTypes.USER_NOT_REGISTERED);
      else
        throw new RequestException(ReqErrorTypes.REQUEST_FAILED);
    }

    return userLogin;
  }
View Full Code Here

      setResponseHeaders(httpServletResponse);

    try {
      if (platformRequestWrapper.getOpenSocialConsumerKey() == null) {
        log.warning("oauth_consumer_key is null");
        throw new RequestException(ReqErrorTypes.UNSUPPORETED_PLATFORM);
      }
      if (platformRequestWrapper.getOpenSocialViewerId() == null) {
        log.warning("opensocial_viewer_id is null");
        throw new RequestException(ReqErrorTypes.USER_NOT_LOGGEDIN);
      }

      if (!UrlUtils.isOnDevPort8888(platformRequestWrapper)
          && !validateSignedRequestWithContainer(platformRequestWrapper)) {
        throw new RequestException(ReqErrorTypes.USER_NOT_LOGGEDIN);
      }

      if (platformRequestWrapper.getCurrentUserProfile() != null){
        // check if user changed in session the middle ?
        userProfile = platformRequestWrapper.getCurrentUserProfile();
       
        if(!userProfile.getOpenSocialViewerId().equals(platformRequestWrapper.getOpenSocialViewerId()))
          platformRequestWrapper.getSession().setAttribute(
              "userProfile", null);
      }
     
      if (platformRequestWrapper.getCurrentUserProfile() == null) {

        userProfile = UserProfilesUtils
            .getMyProfile(platformRequestWrapper);
        if (userProfile != null){
          platformRequestWrapper.getSession().setAttribute(
              "userProfile", userProfile);
         
          userIsValid = true;
        }
        else if (platformRequestWrapper.getGadgetActionType().equals(
            ReqActionTypes.ADD_PROFILE))
          userIsValid = true; // proceed to profile creation
        else
          throw new RequestException(
              ReqErrorTypes.PROFILE_DOESNT_EXISTS);
      }
      else
        userIsValid = true;
     
      // load gadget
      Gadget g = GadgetUtils.getGadget(platformRequestWrapper.getGadgetName());
      if(g==null || g.getGadgletType()==null || !g.getGadgletType().equals(GadgetType.MINGLET.getGadgetType()))
        throw new RequestException(
            ReqErrorTypes.UNRECOGNIZED_GADGET);
      else
        platformRequestWrapper.setRequestedGadget(g);
     
     
    } catch (RequestException e) {
      userIsValid = false;
      gadgetServerResponse.setError(e);
    } catch (Exception e) {
      userIsValid = false;
      printStackTrace(e);
      gadgetServerResponse.setError(new RequestException(
          ReqErrorTypes.REQUEST_FAILED));
    }

    if (userIsValid)
      performRequest(platformRequestWrapper, gadgetServerResponse,
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.