Package org.eurekastreams.commons.exceptions

Examples of org.eurekastreams.commons.exceptions.ExecutionException


        context.checking(new Expectations()
        {
            {
                oneOf(serviceActionControllerMock).execute(with(any(ServiceActionContext.class)),
                        with(any(ServiceAction.class)));
                will(throwException(new ExecutionException()));
            }
        });

        sut.setTokenInfo(securityToken, consumerInfo, "serviceName", "tokenName", tokenInfo);
        context.assertIsSatisfied();
View Full Code Here


        context.checking(new Expectations()
        {
            {
                oneOf(serviceActionControllerMock).execute(with(any(ServiceActionContext.class)),
                        with(any(ServiceAction.class)));
                will(throwException(new ExecutionException()));
            }
        });

        sut.getTokenInfo(securityToken, consumerInfo, "serviceName", "tokenName");
        context.assertIsSatisfied();
View Full Code Here

        context.checking(new Expectations()
        {
            {
                oneOf(serviceActionControllerMock).execute(with(any(ServiceActionContext.class)),
                        with(any(ServiceAction.class)));
                will(throwException(new ExecutionException()));
            }
        });

        sut.removeToken(securityToken, consumerInfo, "serviceName", "tokenName");
        context.assertIsSatisfied();
View Full Code Here

                oneOf(validationStrategy).validate(serviceActionContext);

                oneOf(authorizationStrategy).authorize(serviceActionContext);

                oneOf(executionStrategy).execute(serviceActionContext);
                will(throwException(new ExecutionException()));

                oneOf(transStatus).isCompleted();
                will(returnValue(false));

                oneOf(transMgrMock).rollback(transStatus);
View Full Code Here

                oneOf(validationStrategy).validate(with(any(ServiceActionContext.class)));

                oneOf(authorizationStrategy).authorize(with(any(ServiceActionContext.class)));

                oneOf(taskHandlerExecutionStrategy).execute(with(any(TaskHandlerActionContext.class)));
                will(throwException(new ExecutionException()));

                oneOf(transStatus).isCompleted();
                will(returnValue(false));

                oneOf(transMgrMock).rollback(transStatus);
View Full Code Here

        expectAuthorizePrincipal(true);
        mockery.checking(new Expectations()
        {
            {
                oneOf(executionStrategy).execute(with(contextWithPrincipalMatcher));
                will(throwException(new ExecutionException("BAD!")));
            }
        });
        coreTest(true, serviceAction, serviceActionInnerContext, childParam);
        mockery.assertIsSatisfied();
    }
View Full Code Here

                oneOf(asyncActionMock).getExecutionStrategy();
                will(returnValue(executionStrategy));

                oneOf(executionStrategy).execute(asyncActionContext);
                will(throwException(new ExecutionException()));

                oneOf(transStatus).isCompleted();
                will(returnValue(false));

                oneOf(transMgrMock).rollback(transStatus);
View Full Code Here

                oneOf(queueSubmitterActionMock).getExecutionStrategy();
                will(returnValue(taskHandlerExecutionStrategy));

                oneOf(taskHandlerExecutionStrategy).execute(with(any(TaskHandlerActionContext.class)));
                will(throwException(new ExecutionException()));

                oneOf(transStatus).isCompleted();
                will(returnValue(false));

                oneOf(transMgrMock).rollback(transStatus);
View Full Code Here

        // get info about stream
        ServiceAction action = typeToFetchActionIndex.get(streamType);
        if (action == null)
        {
            throw new ExecutionException("Stream type not supported.");
        }
        Identifiable entity = (Identifiable) serviceActionController.execute(new ServiceActionContext(id, principal),
                action);

        // Get address
View Full Code Here

        String json;

        if(!Arrays.asList(acceptablePrefixes).contains(imagePrefix))
        {
          logger.error("Invalid image size");
      throw new ExecutionException("Invalid image size.");
        }
        //parse the json input from the url
        try
        {
      json = URLDecoder.decode(urlJson, "UTF-8");
    }
        catch (UnsupportedEncodingException e)
        {
      logger.error("Invalid incoming JSON");
      throw new ExecutionException("Invalid JSON.");
    }       
        JSONArray jsonArray = JSONArray.fromObject(json);
       
        //get users from url list and create map of users
        try
        {
          List<String> peopleIdsToFetch = new ArrayList<String>();
            for (Object jsonItem:jsonArray)
            {
              String accountId = ((JSONObject) jsonItem).get("id").toString();
              String avatarId = ((JSONObject) jsonItem).get("avatarId").toString();
                peopleIdsToFetch.add(accountId);
                if(avatarId!=null && !avatarId.isEmpty())
                {
                  avatarIdToPeopleMap.put(avatarId, accountId);
                }
            }
           
            // fetch the people
            people = peopleMapper.execute(peopleIdsToFetch);
        }
        catch (Exception ex)
        {
            logger.error("Error occurred retrieving the users from the db.", ex);
            throw new ExecutionException("error retrieving users");
        }
       
        //create new object to be passed back as json and create list of avatarIds to be passed to the db query
        JSONArray personProperties = new JSONArray();
        List<String> avatarIdList = new ArrayList<String>();
        for (PersonModelView currentPersonProperties : people)
        {
      if(!avatarIdToPeopleMap.containsKey(currentPersonProperties.getAvatarId()))
        {
            avatarIdList.add(imagePrefix+currentPersonProperties.getAvatarId());
        }
        }
       
        //get all avatar by avatarId
        try
        {
          if(!avatarIdList.isEmpty())
          {
            avatars = avatarMapper.execute(avatarIdList);
          }
        }
        catch (Exception ex)
        {
            logger.error("Error occurred retrieving the users from the db.", ex);
            throw new ExecutionException("Error retieving avatars");
        }
       
        //loop through and build json object for response
        for (PersonModelView currentPersonProperties : people)
        {
          JSONObject p = new JSONObject();
          //if it's not the same send back base64 image and info
        if(avatarIdList.contains(imagePrefix+currentPersonProperties.getAvatarId()))
        {
          p.put("id", currentPersonProperties.getAccountId());
          p.put("avatarId", currentPersonProperties.getAvatarId());
          for(Map<String, Object>currentAvatar:avatars)
          {
              String imageId = (String) currentAvatar.get("imageIdentifier");
              if((imagePrefix+currentPersonProperties.getAvatarId()).equals(imageId))
              {
              byte[] baseBytes = Base64.encodeBase64((byte[]) currentAvatar.get("imageBlob"));
              String baseString = new String(baseBytes);
              p.put("imageBlob", baseString);
              }
          }
          personProperties.add(p);
        }
        }
       
        //return response
        response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate, max-age=0");
        response.addHeader("Pragma", "no-cache");
        response.setHeader("Content-Type", "application/json");
        JsonGenerator jsonGenerator;
    try
    {
      jsonGenerator = jsonFactory.createJsonGenerator(response.getWriter());
      jsonObjectMapper.writeValue(jsonGenerator, personProperties);
    }
    catch (IOException e)
    {
      logger.error("error creating json", e);
      throw new ExecutionException("error creating json format");
    }
    }
View Full Code Here

TOP

Related Classes of org.eurekastreams.commons.exceptions.ExecutionException

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.