class AcceptPolicyHandler implements ContextualRequestMessageHandler<Person> {

   @Override
   public MessageBody handleRequest(Person context, PlatformMessage msg) {
      if(context == null) {
         throw new NotFoundException(msg.getDestination());
      }
      Errors.assertValidRequest(
            Objects.equal(msg.getActor(), msg.getDestination()),
            "Only the same user can accept new policy terms"
      );
      
      MessageBody body = msg.getValue();
      validate(body);

      String policyType = PersonCapability.AcceptPolicyRequest.getType(body);
      if(PersonCapability.AcceptPolicyRequest.TYPE_PRIVACY.equals(policyType)) {
    	  context.setPrivacyPolicyAgreed(new Date());
      }else if(PersonCapability.AcceptPolicyRequest.TYPE_TERMS.equals(policyType)) {
    	  context.setTermsAgreed(new Date());
      }else {
    	  throw new ErrorEventException(Errors.CODE_INVALID_REQUEST, "policy type " + policyType + " is not valid.");
      }
      personDao.update(context);      
      return PersonCapability.AcceptPolicyResponse.instance();
   }

   @Inject public  AcceptPolicyHandler(
         PersonDAO personDao,
         BeanAttributesTransformer<Person> personTransformer,
         PlatformMessageBus bus);

}