Package org.gatein.management.api.model

Examples of org.gatein.management.api.model.ModelValue


   public void writeTo(ManagedResponse managedResponse, Class<?> aClass, Type type, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> stringObjectMultivaluedMap, OutputStream outputStream) throws IOException, WebApplicationException
   {
      String pretty = uriInfo.getQueryParameters().getFirst("pretty");
      if (managedResponse.getResult() instanceof ModelValue)
      {
         ModelValue value = (ModelValue) managedResponse.getResult();
         resolveLinks(value, uriInfo);
      }
      if ("false".equalsIgnoreCase(pretty))
      {
         managedResponse.writeResult(outputStream, false);
View Full Code Here


      {
         return valueType.cast(this);
      }
      else if (getValueType() == ModelValueType.UNDEFINED)
      {
         ModelValue mv;
         if (ModelReference.class.isAssignableFrom(valueType))
         {
            mv = new DmrModelReference(value);
         }
         else if (ModelObject.class.isAssignableFrom(valueType))
         {
            mv = new DmrModelObject(value);
         }
         else if (ModelList.class.isAssignableFrom(valueType))
         {
            mv = new DmrModelList(value);
         }
         else if (ModelString.class.isAssignableFrom(valueType))
         {
            mv = new DmrModelString(value);
         }
         else if (ModelNumber.class.isAssignableFrom(valueType))
         {
            mv = new DmrModelNumber(value);
         }
         else if (ModelBoolean.class.isAssignableFrom(valueType))
         {
            mv = new DmrModelBoolean(value);
         }
         else
         {
            throw new IllegalArgumentException("No mapping defined for ModelValue type " + valueType);
         }

         return valueType.cast(mv);
      }
      else
      {
         ModelValue value = asValue(this.value);
         try
         {
            return valueType.cast(value);
         }
         catch (ClassCastException e)
         {
            throw new IllegalArgumentException("ModelValue type is " + value.getValueType() + " and cannot be cast to " + valueType.getName());
         }
      }
   }
View Full Code Here

            site.setEditPermission(permission);
        }
        if (siteModel.hasDefined("attributes")) {
            ModelList list = get(siteModel, ModelList.class, "attributes");
            for (int i = 0; i < list.size(); i++) {
                ModelValue mv = list.get(i);
                String field = "attributes["+i+"]"; // Used for error reporting
                if (mv.getValueType() != ModelValue.ModelValueType.OBJECT) {
                    throw invalidType(mv, ModelValue.ModelValueType.OBJECT, field);
                }
                ModelObject attrModel = mv.asValue(ModelObject.class);
                if (!attrModel.hasDefined("key")) {
                    throw requiredField(field, "key");
                }
                String key = get(attrModel, ModelString.class, "key").getValue();
                if (!attrModel.has("value")) {
View Full Code Here

        if (!allowNull && !permissionsModel.isDefined()) {
            throw invalidValue(null, names);
        }
        Permission permission = null;
        for (int i=0; i<permissionsModel.size(); i++) {
            ModelValue mv = permissionsModel.get(i);
            String field = resolveField(names) + "[" + i + "]"; // Used for error reporting
            if (mv.getValueType() != ModelValue.ModelValueType.STRING) {
                throw invalidType(mv, ModelValue.ModelValueType.STRING, field);
            }
            String perm = mv.asValue(ModelString.class).getValue();
            if (perm == null) {
                throw requiredFieldWhen("permissions are defined", field);
            }

            if (perm.equals("Everyone")) {
View Full Code Here

TOP

Related Classes of org.gatein.management.api.model.ModelValue

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.