Ejemplo n.º 1
0
 private void assertAttributesFetched(List<PrismValue> data) {
   for (PrismValue value : data) {
     if (((PrismObjectValue<ShadowType>) value).asObjectable().getAttributes().getAny().size()
         <= 2) {
       throw new AssertionError("There are no attributes present in " + value.debugDump());
     }
   }
 }
  @Override
  public T getValue() {

    if (actualValue != null) {
      return actualValue;
    }

    if (valueForStorageWhenNotEncoded != null) {
      actualValue = valueForStorageWhenNotEncoded;
      return actualValue;
    }

    if (valueForStorageWhenEncoded != null) {
      if (prismContext == null) {
        throw new IllegalStateException(
            "PrismContext not set for SerializationSafeContainer holding "
                + StringUtils.abbreviate(valueForStorageWhenEncoded, MAX_WIDTH));
      }

      if (encodingScheme == EncodingScheme.PRISM) {
        try {
          PrismValue prismValue =
              prismContext.parserFor(valueForStorageWhenEncoded).xml().parseItemValue();
          actualValue = prismValue != null ? prismValue.getRealValue() : null;
        } catch (SchemaException e) {
          throw new SystemException(
              "Couldn't deserialize value from JAXB: "
                  + StringUtils.abbreviate(valueForStorageWhenEncoded, MAX_WIDTH),
              e);
        }
        return actualValue;
      } else {
        throw new IllegalStateException("Unexpected encoding scheme " + encodingScheme);
      }
    }

    return null;
  }