コード例 #1
0
  public static <T> T deserializeValue(
      String value,
      Class clazz,
      QName itemName,
      ItemDefinition itemDef,
      PrismContext prismContext,
      String language)
      throws SchemaException {
    // System.out.println("item value deserialization");

    XNode xnode = prismContext.getParserDom().parse(value);

    //		System.out.println("xnode: " + xnode.debugDump());

    XNode xmap = null;
    if (xnode instanceof RootXNode) {
      xmap = ((RootXNode) xnode).getSubnode();
    }

    //		System.out.println("xmap: " + xmap);
    //		else if (xnode instanceof MapXNode){
    //			xmap = (MapXNode) xnode;
    //		} else if (xnode instanceof PrimitiveXNode){
    //			xmap = new MapXNode();
    //			xmap.put(itemName, xnode);
    //		}

    Item item = prismContext.getXnodeProcessor().parseItem(xmap, itemName, itemDef);

    //		System.out.println("item: " + item.debugDump());

    if (item instanceof PrismProperty) {
      PrismProperty prop = (PrismProperty) item;

      if (prop.isSingleValue()) {
        return (T) prop.getRealValue();
      }
      return (T) prop.getRealValues();
    } else if (item instanceof PrismContainer) {
      PrismContainer cont = (PrismContainer) item;
      return (T) cont.getValue().asContainerable();
    } else if (item instanceof PrismReference) {
      PrismReference ref = (PrismReference) item;
      return (T) ref.getValue();
    }
    if (item != null) {
      return (T) item.getValue(0);
    }
    //		if (prismContext.getBeanConverter().canConvert(clazz)){
    //			prismContext.getBeanConverter().unmarshall(xmap, clazz);
    //		} else{
    //			prismContext.getXnodeProcessor().parseContainer(xnode, clazz);
    //		}

    throw new UnsupportedOperationException("need to be implemented");
  }
コード例 #2
0
 private <O extends ObjectType, T> void checkUserProperty(
     PrismObject<O> object, QName propQName, OperationResult parentResult, T... expectedValues) {
   String propName = propQName.getLocalPart();
   OperationResult result =
       parentResult.createSubresult(parentResult.getOperation() + "." + propName);
   PrismProperty<T> prop = object.findProperty(propQName);
   Collection<T> actualValues = prop.getRealValues();
   result.addArbitraryCollectionAsParam("actualValues", actualValues);
   assertMultivalue("User, property '" + propName + "'", expectedValues, actualValues, result);
   result.recordSuccessIfUnknown();
 }