Esempio n. 1
0
  public boolean isProtectedAccount() {
    if (object == null || !(ShadowType.class.isAssignableFrom(object.getCompileTimeClass()))) {
      return false;
    }

    PrismProperty<Boolean> protectedObject = object.findProperty(ShadowType.F_PROTECTED_OBJECT);
    if (protectedObject == null) {
      return false;
    }

    return protectedObject.getRealValue() != null ? protectedObject.getRealValue() : false;
  }
  /* (non-Javadoc)
   * @see com.evolveum.midpoint.model.sync.Action#handle(com.evolveum.midpoint.model.lens.LensContext, com.evolveum.midpoint.model.sync.SynchronizationSituation, java.util.Map, com.evolveum.midpoint.task.api.Task, com.evolveum.midpoint.schema.result.OperationResult)
   */
  @Override
  public <F extends FocusType> void handle(
      LensContext<F> context,
      SynchronizationSituation<F> situation,
      Map<QName, Object> parameters,
      Task task,
      OperationResult parentResult) {
    ActivationStatusType desiredStatus = ActivationStatusType.DISABLED;

    LensProjectionContext projectionContext = context.getProjectionContextsIterator().next();
    PrismObject<ShadowType> objectCurrent = projectionContext.getObjectCurrent();
    if (objectCurrent != null) {
      PrismProperty<Object> administrativeStatusProp =
          objectCurrent.findProperty(SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS);
      if (administrativeStatusProp != null) {
        if (desiredStatus.equals(administrativeStatusProp.getRealValue())) {
          // Desired status already set, nothing to do
          return;
        }
      }
    }
    ObjectDelta<ShadowType> activationDelta =
        ObjectDelta.createModificationReplaceProperty(
            ShadowType.class,
            projectionContext.getOid(),
            SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS,
            getPrismContext(),
            desiredStatus);
    projectionContext.setPrimaryDelta(activationDelta);
  }
Esempio n. 3
0
  @Override
  protected void assertStepSyncToken(String syncTaskOid, int step, long tsStart, long tsEnd)
      throws ObjectNotFoundException, SchemaException {
    OperationResult result =
        new OperationResult(AbstractIntegrationTest.class.getName() + ".assertSyncToken");
    Task task = taskManager.getTask(syncTaskOid, result);
    result.computeStatus();
    TestUtil.assertSuccess(result);

    PrismProperty<String> syncTokenProperty = task.getExtensionProperty(SchemaConstants.SYNC_TOKEN);
    assertNotNull("No sync token in " + task, syncTokenProperty);
    String syncToken = syncTokenProperty.getRealValue();
    assertNotNull("No sync token in " + task, syncToken);
    IntegrationTestTools.display("Sync token", syncToken);

    GeneralizedTime syncTokenGt;
    try {
      syncTokenGt = new GeneralizedTime(syncToken);
    } catch (ParseException e) {
      throw new RuntimeException(e.getMessage(), e);
    }
    TestUtil.assertBetween(
        "Wrong time in sync token: " + syncToken,
        roundTsDown(tsStart),
        roundTsUp(tsEnd),
        syncTokenGt.getCalendar().getTimeInMillis());
  }
  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");
  }
 private long parseLong(PrismProperty<?> prop) {
   Object realValue = prop.getRealValue();
   if (realValue instanceof Long) {
     return (Long) realValue;
   } else if (realValue instanceof Integer) {
     return ((Integer) realValue);
   } else {
     throw new IllegalArgumentException("Cannot convert " + realValue.getClass() + " to long");
   }
 }
  @Override
  public Object getObject() {
    PrismProperty property;
    try {
      property = getPrismObject().findOrCreateProperty(path);
    } catch (SchemaException ex) {
      LoggingUtils.logException(LOGGER, "Couldn't create property in path {}", ex, path);
      // todo show message in page error [lazyman]
      throw new RestartResponseException(PageError.class);
    }

    Object val = getRealValue(property != null ? property.getRealValue() : null);
    if (val == null) {
      return defaultValue;
    } else {
      return val;
    }
  }
  @Test
  public void test200FetchChanges() throws Exception {
    final String TEST_NAME = "test200FetchChanges";
    TestUtil.displayTestTile(this, TEST_NAME);

    OperationResult result = new OperationResult(this.getClass().getName() + "." + TEST_NAME);
    ObjectClassComplexTypeDefinition accountDefinition =
        resourceSchema.findObjectClassDefinition(
            ProvisioningTestUtil.OBJECT_CLASS_INETORGPERSON_NAME);
    PrismProperty<Integer> lastToken = cc.fetchCurrentToken(accountDefinition, result);

    System.out.println("Property:");
    System.out.println(SchemaDebugUtil.prettyPrint(lastToken));
    System.out.println("token " + lastToken.toString());

    assertNotNull("No last token", lastToken);
    assertNotNull("No last token value", lastToken.getRealValue());

    List<Change<ShadowType>> changes = cc.fetchChanges(accountDefinition, lastToken, null, result);
    AssertJUnit.assertEquals(0, changes.size());
  }
 private boolean parseBoolean(PrismProperty<?> prop) {
   return prop.getRealValue(Boolean.class);
 }
 private int parseInt(PrismProperty<?> prop) {
   return prop.getRealValue(Integer.class);
 }