com.memority.domino.shared.api.DominoBuiltinAttributeId Maven / Gradle / Ivy
Show all versions of domino-api Show documentation
/*
* Copyright (c) 2016-2023 Memority. All Rights Reserved.
*
* This file is part of Memority Domino API , a Memority project.
*
* This file is released under the Memority Public Artifacts End-User License Agreement,
* see
* Unauthorized copying of this file, via any medium is strictly prohibited.
*/
package com.memority.domino.shared.api;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import static java.util.stream.Collectors.toList;
/**
* This enum lists all the pre-defined attribute identifiers that are reserved for internal Domino attributes.
*
* @author Pierre Sion <[email protected]>
* Date: 2018/01/18
*/
public enum DominoBuiltinAttributeId {
/**
* The identifier of an object found on a remote application, such as a LDAP DN or a CSV "UID".
*/
OBJECT_ID(Values.OBJECT_ID),
/**
* The class of the object found on a remote application, such as "inetOrgPerson".
*/
OBJECT_CLASS(Values.OBJECT_CLASS),
/**
* Possible auxiliary object classes
*/
AUXILIARY_OBJECT_CLASSES(Values.AUXILIARY_OBJECT_CLASSES),
/**
* A Shadow's owner
*/
OWNER(Values.OWNER),
/**
* A Shadow's sync situation
*/
SYNC_SITUATION(Values.SYNC_SITUATION),
/**
* A Shadow's last sync date
*/
LAST_SYNC_DATE(Values.LAST_SYNC_DATE),
/**
* Pertains to the outbound case: the account status
*/
ACCOUNT_STATUS(Values.ACCOUNT_STATUS),
/**
* Key-values gathered during the correlation process.
*/
CONTEXT(Values.CONTEXT),
/**
* Is the Shadow enabled in the remote Application
*/
ENABLED(Values.ENABLED),
/**
* Is the Shadow locked in the remote Application.
*/
LOCKED(Values.LOCKED);
/*
* These constants are to be used when the properties are exposed to other modules, typically when building
* a context that is fed to Rules. Must be kept in sync with the enum names.
*
* They are armored with a leading/trailing double underscore (e.g. "__objectId__") to avoid clashes with native
* attribute names coming from remote applications.
*/
public static final class Values {
// The "KIND" enum is already defined in Citadel's BuiltinAttributeId
public static final String KIND = "__kind__";
// The "TYPE" enum is already defined in Citadel's BuiltinAttributeId
public static final String TYPE = "__type__";
// The "ID" enum is already defined in Citadel's BuiltinAttributeId
public static final String ID = "__id__";
public static final String APPLICATION_ID = "__applicationId__";
public static final String OBJECT_ID = "__objectId__";
public static final String OBJECT_CLASS = "__objectClass__";
// Must be consistent with PredefinedAttributes.AUXILIARY_OBJECT_CLASS_NAME, see [SYNC-613]
public static final String AUXILIARY_OBJECT_CLASSES = "__auxiliary_object_class__";
public static final String OWNER = "__owner__";
public static final String SYNC_SITUATION = "__syncSituation__";
public static final String LAST_SYNC_DATE = "__lastSyncDate__";
public static final String ACCOUNT_STATUS = "__accountStatus__";
public static final String CONTEXT = "__context__";
public static final String NAME = "__name__";
public static final String ENABLED = "__enabled__";
public static final String LOCKED = "__locked__";
}
private static final List ID_LIST = Arrays.stream(DominoBuiltinAttributeId.values())
.map(DominoBuiltinAttributeId::toId)
.collect(toList());
private final String idValue;
DominoBuiltinAttributeId(String idValue) {
this.idValue = idValue;
}
public String toId() {
return this.idValue;
}
public static boolean contains(String id) {
return ID_LIST.contains(id);
}
public static List getIdList() {
return ID_LIST;
}
public static DominoBuiltinAttributeId fromId(String id) {
return fromIdOptional(id)
.orElseThrow(() -> new IllegalArgumentException("Unrecognized Domino builtin attribute id '"+id+"'!"));
}
public static Optional fromIdOptional(String id) {
if (id == null || id.isEmpty()) {
return Optional.empty();
}
for (DominoBuiltinAttributeId dominoBuiltinAttributeId: DominoBuiltinAttributeId.values()) {
if (dominoBuiltinAttributeId.toId().equals(id)) {
return Optional.of(dominoBuiltinAttributeId);
}
}
return Optional.empty();
}
}