Package com.gadglet.core

Examples of com.gadglet.core.RequestException


    // add security checks ...
   
    DomainAccount domainAccount = DomainAccountUtils.getDomainAccountByID(getAccount());
   
    if(!DomainUserUtils.isCurrentUserDomainAdmin() && !domainAccount.isAllowUsersSelfActivation())
      throw new RequestException (ReqErrorTypes.UNAUTHORIZED_OPERATION);
     
    ifdomainAccount.getDomainActiveUsersNum()>=domainAccount.getMaxUsers())
      throw new RequestException (ReqErrorTypes.DOMAIN_ACCOUNT_EXCEED_USERS_QUATA);
   
    setStatus(status.getUserStatus());
    try {
      save();
    } catch (Exception e) {
View Full Code Here


   * @throws Exception
   */
  public void setAdmin() throws Exception {

    if (DomainUserUtils.isCurrentUserDomainAdmin())
      throw new RequestException (ReqErrorTypes.UNAUTHORIZED_OPERATION);
     
    this.domainAdmin = true;

    try {
      save();
View Full Code Here

   * @throws Exception
   */
  public void disableAdmin() throws Exception {

    if (DomainUserUtils.isCurrentUserDomainAdmin())
      throw new RequestException (ReqErrorTypes.UNAUTHORIZED_OPERATION);
   
    this.domainAdmin = false;

    try {
      save();
View Full Code Here

    try {
      pm = PMF.get().getPersistenceManager();
      item = getSingleItemByKeyForAction(pm, request, className);

      if (!isItemOwner(item, request))
        throw new RequestException(ReqErrorTypes.UNAUTHORIZED_OPERATION);

    } catch (RequestException e) {
      throw new RequestException(e.getErrorType());
    } catch (Exception e) {
      log.warning(e.getMessage());
      throw new RequestException(ReqErrorTypes.REQUEST_FAILED);
    }

    try {

      pm.deletePersistent(item);
    } catch (Exception e) {
      log.warning(e.getMessage());
      throw new RequestException(ReqErrorTypes.REQUEST_FAILED);

    } finally {
      pm.close();
    }
    return true;
View Full Code Here

    List<SharedItemReff> sharings = null;

    // missing shareWith
    if (shareWith == null) {
      pm.close();
      throw new RequestException(ReqErrorTypes.MISSING_ARGUMENT);
    }

    // not owner
    if (!item.getOwnerId().equals(request.getCurrentUserId())) {
      pm.close();
      throw new RequestException(ReqErrorTypes.UNAUTHORIZED_OPERATION);

    }

    // can't change owner settings
    if (item.getOwnerId().equals(shareWith)) {
      pm.close();
      throw new RequestException(ReqErrorTypes.UNAUTHORIZED_OPERATION);

    }

    try {
      sharings = item.getSharedItemReff();
      int index = 0;
      for (SharedItemReff share : sharings) {

        if (share.getSharedWithId().equals(shareWith)
            && !share.getSharingType().equals(SharingType.OWNER)) {
          shareExists = true;

          if (sharingType == null)
            remove = index;
          else
            share.setSharingType(sharingType);
        }

        index++;
      }
      // add
      if (remove > -1)
        item.getSharedItemReff().remove(remove);
      // add new sharing
      if (!shareExists && request.getSharingType() != null
          && !request.getSharingType().equals(SharingType.OWNER)) {
        newShare = new SharedItemReff();

        newShare.setSharedWithId(request
            .getParameter(ReqParamNames.SHARE_WITH.getParamName()));
        newShare.setSharingType(request.getSharingType());
        item.addSharedItemReff(newShare);
      }

      updated(pm, item, request);
    } catch (RequestException e) {
      throw e;
    } catch (Exception e) {
      log.warning(e.getMessage());
      throw new RequestException(ReqErrorTypes.REQUEST_FAILED);
    }

  }
View Full Code Here

    PersonalShareableContentItem item = null;

    String key = request.getItemKeyField();
    if (key == null)
      throw new RequestException(ReqErrorTypes.ITEM_NOT_FOUND);

    try {

      item = (PersonalShareableContentItem) pm.getObjectById(className,
          key);
      // access all fields before pm is closed to ensure fields are
      // available
      if (item != null && item.getSharedItemReff() != null)
        for (SharedItemReff ref : item.getSharedItemReff())
          ref.getSharingType();

    } catch (Exception e) {
      log.warning(e.getMessage());
      throw new RequestException(ReqErrorTypes.ITEM_NOT_FOUND);
    }

    if (item == null)
      throw new RequestException(ReqErrorTypes.ITEM_NOT_FOUND);

    return item;

  }
View Full Code Here

    PersonalShareableContentItem item = null;

    String key = request.getItemKeyField();
    if (key == null)
      throw new RequestException(ReqErrorTypes.ITEM_NOT_FOUND);

    PersistenceManager pm = PMF.get().getPersistenceManager();

    try {

      item = (PersonalShareableContentItem) pm.getObjectById(className,
          key);

      // access all fields before pm is closed to ensure fields are
      // available
      if (item != null && item.getSharedItemReff() != null)
        for (SharedItemReff ref : item.getSharedItemReff())
          ref.getSharingType();

    } catch (Exception e) {
      log.warning(e.getMessage());
      throw new RequestException(ReqErrorTypes.ITEM_NOT_FOUND);
    } finally {
      pm.close();
    }

    if (item == null)
      throw new RequestException(ReqErrorTypes.ITEM_NOT_FOUND);

    return item;

  }
View Full Code Here

      PersonalShareableContentItem item, GadgletRequestWrapper request)
      throws RequestException {
    if (!canUserModifyItem(item, request)) {
      if (pm != null)
        pm.close();
      throw new RequestException(ReqErrorTypes.UNAUTHORIZED_OPERATION);

    }

    item.setUpdate();
    if (pm == null)
      pm = PMF.get().getPersistenceManager();
    pm.currentTransaction().begin();
    try {

      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

      savedItem = 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

        hasMore.setTrue();
      else
        hasMore.setFalse();
    } catch (Exception e) {
      log.warning(e.toString());
      throw new RequestException(ReqErrorTypes.REQUEST_FAILED);
    } finally {
      query.closeAll();
      pm.close();
    }
    return items;
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.