Package org.apache.shindig.protocol

Examples of org.apache.shindig.protocol.ProtocolException


            if (fields == null || fields.size() == 0) {
                applicationData.setData(values);
            }
            //if there are keys in the values map that aren't in the fields set, its a bad request
            else if (!fields.containsAll(values.keySet())) {
                throw new ProtocolException(HttpServletResponse.SC_BAD_REQUEST, "Fields parameter must either be empty or contain keys " +
                        "for all name value pairs sent in request.");
            }
            //we have a partial update - we know that the fields set contains keys for all the entries in the values
            //map (due to the check above), so we can just enumerate over it now to finish our work.  So we want to remove
            //any fields found in the fields set that are not found in the values map and update the rest.
View Full Code Here


        Set<UserId> userIds = new HashSet<UserId>(Arrays.asList(userId));
        List<String> personIds = validateReadRequest(userIds, groupId, appId, token);

        //and now check the write level validation which is "only the VIEWER's data is writable"
        if (personIds.size() != 1 || !personIds.get(0).equalsIgnoreCase(token.getViewerId())) {
            throw new ProtocolException(HttpServletResponse.SC_BAD_REQUEST, "Writing appdata for anyone but the " +
                    "current viewer is forbidden.");
        }

        return personIds.get(0);
    }
View Full Code Here

        return personIds.get(0);
    }

    private void validateAppIdMatches(String appId, SecurityToken token) {
        if (StringUtils.isBlank(appId) || !appId.equalsIgnoreCase(token.getAppId())) {
            throw new ProtocolException(HttpServletResponse.SC_BAD_REQUEST, "Requesting appdata for a different " +
                    "application is forbidden.");
        }
    }
View Full Code Here

        return ImmediateFuture.newInstance(convertPerson(getPersonForId(id, token), fields));
    }

    @Override
    public Future<Person> updatePerson(UserId id, Person person, SecurityToken token) throws ProtocolException {
        throw new ProtocolException(HttpServletResponse.SC_NOT_IMPLEMENTED, "Not Implemented");
    }
View Full Code Here

                return getGroupMembersFromRepository(collectionOptions, groupId.getObjectId().toString(), token.getAppId());
            case self:
                UserId id = userIds.size() == 1 ? userIds.iterator().next() : new UserId(UserId.Type.me, null);
                return Lists.newArrayList(getPersonForId(id, token));
            case custom:
                throw new ProtocolException(HttpServletResponse.SC_NOT_IMPLEMENTED, "Custom GroupIDs are not tracked by the container");
            default:
                throw new ProtocolException(HttpServletResponse.SC_BAD_REQUEST, "Invalid group id specified by request");
        }
    }
View Full Code Here

    private org.apache.rave.model.Person getFromRepository(String userId) {

        org.apache.rave.model.Person person = repository.findByUsername(userId);
        if (person == null) {
            throw new ProtocolException(HttpServletResponse.SC_NOT_FOUND, "The person with the id " + userId + " was not found.");
        }
        return person;
    }
View Full Code Here

            case groupId:
                return getGroupMembersFromRepository(collectionOptions, groupId.getGroupId(), token.getAppId());
            case self:
                return Lists.newArrayList(getPersonForId(new UserId(UserId.Type.me, null), token));
            case deleted:
                throw new ProtocolException(HttpServletResponse.SC_NOT_IMPLEMENTED, "Deleted Friends are not tracked by the container");
            default:
                throw new ProtocolException(HttpServletResponse.SC_BAD_REQUEST, "Invalid group id specified by request");
        }
    }
View Full Code Here

    private org.apache.rave.portal.model.Person getFromRepository(String userId) {
        long id = Long.parseLong(userId);
        org.apache.rave.portal.model.Person person = repository.get(id);
        if (person == null) {
            throw new ProtocolException(HttpServletResponse.SC_NOT_FOUND, "The person with the id " + userId + " was not found.");
        }
        return person;
    }
View Full Code Here

      // select self
      sb.append(PersonDb.JPQL_FINDPERSON);
      lastPos = JPQLUtils.addInClause(sb, "p", "id", lastPos, paramList.size());
      break;
    default:
      throw new ProtocolException(HttpServletResponse.SC_BAD_REQUEST, "Group ID not recognized");

    }

    if (GroupId.Type.self.equals(groupId.getType())) {
      plist = JPQLUtils.getListQuery(entiyManager, sb.toString(), paramList, collectionOptions);
      totalResults = Long.valueOf(1);
      if (plist.isEmpty()) {
        throw new ProtocolException(HttpServletResponse.SC_BAD_REQUEST, "Person not found");
      }
    } else {
      int filterPos = addFilterClause(sb, PersonDb.getFilterCapability(), collectionOptions,
          lastPos);
      if (filterPos > 0) {
View Full Code Here

      throws ProtocolException {
    String viewer = token.getViewerId(); // viewer
    String uid = id.getUserId(token); // person to update

    if (!viewerCanUpdatePerson(viewer,uid)) {
      throw new ProtocolException(HttpServletResponse.SC_FORBIDDEN, "User '" + viewer + "' does not have enough privileges to update person '"+uid+"'");
    }

    Query q = null;
    // Get the person object from db
    q = entiyManager.createNamedQuery(PersonDb.FINDBY_PERSONID);
View Full Code Here

TOP

Related Classes of org.apache.shindig.protocol.ProtocolException

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.