use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAttributesType in project midpoint by Evolveum.
the class AbstractTestForExchangeConnector method createAddressBookPolicy.
protected String createAddressBookPolicy(String name, Collection<String> addressLists, String gal, String oab, String rooms) throws FaultMessage {
Document doc = ModelClientUtil.getDocumnent();
ShadowType shadow = new ShadowType();
shadow.setName(ModelClientUtil.createPolyStringType(name, doc));
shadow.setResourceRef(createObjectReferenceType(ResourceType.class, getResourceOid()));
shadow.setObjectClass(OC_ADDRESS_BOOK_POLICY);
shadow.setKind(ShadowKindType.GENERIC);
shadow.setIntent("address-book-policy");
ShadowAttributesType attributes = new ShadowAttributesType();
attributes.getAny().add(ModelClientUtil.createTextElement(new QName(NS_ICFS, "name"), name, doc));
for (String addressList : addressLists) {
attributes.getAny().add(ModelClientUtil.createTextElement(new QName(NS_RI, "AddressLists"), addressList, doc));
}
attributes.getAny().add(ModelClientUtil.createTextElement(new QName(NS_RI, "GlobalAddressList"), gal, doc));
attributes.getAny().add(ModelClientUtil.createTextElement(new QName(NS_RI, "OfflineAddressBook"), oab, doc));
attributes.getAny().add(ModelClientUtil.createTextElement(new QName(NS_RI, "RoomList"), rooms, doc));
shadow.setAttributes(attributes);
return createShadow(shadow);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAttributesType in project midpoint by Evolveum.
the class AbstractTestForExchangeConnector method prepareShadowType.
// additionalAttributes: e.g. "OfflineAddressBook" -> "OAB123"
private ShadowType prepareShadowType(String givenName, String sn, String name, String recipientType, String overrideMail, String samAccountName, String upn, Map<String, Object> additionalAttributes) {
if (samAccountName == null) {
samAccountName = sn.toLowerCase();
}
Document doc = ModelClientUtil.getDocumnent();
ShadowType user = new ShadowType();
user.setName(ModelClientUtil.createPolyStringType(name, doc));
user.setResourceRef(createObjectReferenceType(ResourceType.class, getResourceOid()));
user.setObjectClass(OC_ACCOUNT);
user.setKind(ShadowKindType.ACCOUNT);
ShadowAttributesType attributes = new ShadowAttributesType();
attributes.getAny().add(ModelClientUtil.createTextElement(new QName(NS_ICFS, "name"), name, doc));
attributes.getAny().add(ModelClientUtil.createTextElement(new QName(NS_RI, "givenName"), givenName, doc));
attributes.getAny().add(ModelClientUtil.createTextElement(new QName(NS_RI, "sn"), sn, doc));
attributes.getAny().add(ModelClientUtil.createTextElement(new QName(NS_RI, "RecipientType"), recipientType, doc));
attributes.getAny().add(ModelClientUtil.createTextElement(new QName(NS_RI, "sAMAccountName"), samAccountName, doc));
if (overrideMail != null) {
attributes.getAny().add(ModelClientUtil.createTextElement(new QName(NS_RI, "EmailAddressPolicyEnabled"), "true", doc));
attributes.getAny().add(ModelClientUtil.createTextElement(new QName(NS_RI, "EmailAddresses"), overrideMail, doc));
}
if (upn != null) {
attributes.getAny().add(ModelClientUtil.createTextElement(new QName(NS_RI, "userPrincipalName"), upn, doc));
}
if (additionalAttributes != null) {
for (Map.Entry<String, Object> entry : additionalAttributes.entrySet()) {
if (entry.getValue() instanceof Collection) {
for (Object value : (Collection) entry.getValue()) {
addAttribute(attributes, entry.getKey(), value, doc);
}
} else {
addAttribute(attributes, entry.getKey(), entry.getValue(), doc);
}
}
}
user.setAttributes(attributes);
return user;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAttributesType in project midpoint by Evolveum.
the class AbstractTestForExchangeConnector method createOfflineAddressBook.
protected String createOfflineAddressBook(String name, String addressList, String tenantName) throws FaultMessage {
Document doc = ModelClientUtil.getDocumnent();
ShadowType shadow = new ShadowType();
shadow.setName(ModelClientUtil.createPolyStringType(name, doc));
shadow.setResourceRef(createObjectReferenceType(ResourceType.class, getResourceOid()));
shadow.setObjectClass(OC_OFFLINE_ADDRESS_BOOK);
shadow.setKind(ShadowKindType.GENERIC);
shadow.setIntent("offline-address-book");
ShadowAttributesType attributes = new ShadowAttributesType();
attributes.getAny().add(ModelClientUtil.createTextElement(new QName(NS_ICFS, "name"), name, doc));
attributes.getAny().add(ModelClientUtil.createTextElement(new QName(NS_RI, "AddressLists"), addressList, doc));
//attributes.getAny().add(ModelClientUtil.createTextElement(new QName(NS_RI, "_TenantName"), tenantName, doc));
shadow.setAttributes(attributes);
return createShadow(shadow);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAttributesType in project midpoint by Evolveum.
the class TestExchangeConnectorLow method test210ModifyingNonexistingPowerShellObject.
@Test
public void test210ModifyingNonexistingPowerShellObject() throws Exception {
// create shadow with non-existing GUID
System.out.println("Creating shadow with non-existing GUID...");
Document doc = ModelClientUtil.getDocumnent();
String name = "Wrong GUID shadow";
ShadowType shadow = new ShadowType();
shadow.setName(ModelClientUtil.createPolyStringType(name, doc));
shadow.setResourceRef(createObjectReferenceType(ResourceType.class, getResourceOid()));
shadow.setObjectClass(OC_ACCEPTED_DOMAIN);
shadow.setKind(ShadowKindType.GENERIC);
shadow.setIntent("custom-accepted-domain");
ShadowAttributesType attributes = new ShadowAttributesType();
attributes.getAny().add(ModelClientUtil.createTextElement(new QName(NS_ICFS, "name"), name, doc));
attributes.getAny().add(ModelClientUtil.createTextElement(new QName(NS_ICFS, "uid"), "wrong-GUID", doc));
shadow.setAttributes(attributes);
String oid = createObject(ShadowType.class, shadow, createRaw());
System.out.println("Done, reading it back...");
ShadowType shadowReadAgain = getObjectNoFetch(ShadowType.class, oid);
dumpAttributes(shadowReadAgain);
System.out.println("Now launching modifyObject operation...");
//Class objectType, String oid, String path, ModificationTypeType modType, Object value, ModelExecuteOptionsType optionsType, boolean assertSuccess
ObjectDeltaOperationType odo = modifyObject(ShadowType.class, oid, "attributes/DomainType", ModificationTypeType.REPLACE, "InternalRelay", null, false);
OperationResultType r = odo.getExecutionResult();
System.out.println("Done: " + r.getStatus() + ":" + r.getMessage());
OperationResultType found = findOperationResult(r, new OperationResultMatcher() {
@Override
public boolean match(OperationResultType r) {
return r.getDetails() != null && r.getDetails().contains("UnknownUidException");
}
});
AssertJUnit.assertNotNull("UnknownUidException was not detected", found);
System.out.println("======================================================================================================");
System.out.println("Details: " + found.getDetails());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAttributesType in project midpoint by Evolveum.
the class ShadowIntegrityCheckResultHandler method reportOrFixUniqueness.
private String reportOrFixUniqueness(Task task, OperationResult result) {
StringBuilder details = new StringBuilder();
StringBuilder stat = new StringBuilder();
for (Map.Entry<Pair<String, ShadowKindType>, ObjectTypeContext> entry : contextMap.entrySet()) {
String resourceOid = entry.getKey().getLeft();
ShadowKindType kind = entry.getKey().getRight();
ObjectTypeContext ctx = entry.getValue();
PrismObject<ResourceType> resource = resources.get(resourceOid);
if (resource == null) {
// should not happen
LOGGER.error("No resource for {}", resourceOid);
continue;
}
for (Map.Entry<QName, Map<String, List<PrismObject<ShadowType>>>> idValEntry : ctx.getIdentifierValueMap().entrySet()) {
QName identifier = idValEntry.getKey();
boolean first = true;
for (Map.Entry<String, List<PrismObject<ShadowType>>> valListEntry : idValEntry.getValue().entrySet()) {
List<PrismObject<ShadowType>> shadows = valListEntry.getValue();
if (shadows.size() <= 1) {
continue;
}
if (first) {
details.append("Duplicates for ").append(ObjectTypeUtil.toShortString(resource));
details.append(", kind = ").append(kind);
details.append(", identifier = ").append(identifier).append(":\n");
first = false;
}
details.append(" - value: ").append(valListEntry.getKey()).append(", shadows: ").append(shadows.size()).append("\n");
List<PrismObject<ShadowType>> shadowsToConsider = new ArrayList<>();
for (PrismObject<ShadowType> shadow : shadows) {
details.append(" - ").append(ObjectTypeUtil.toShortString(shadow));
details.append("; sync situation = ").append(shadow.asObjectable().getSynchronizationSituation()).append("\n");
PrismContainer<ShadowAttributesType> attributesContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES);
if (attributesContainer != null && !attributesContainer.isEmpty()) {
for (Item item : attributesContainer.getValue().getItems()) {
details.append(" - ").append(item.getElementName().getLocalPart()).append(" = ");
details.append(item.getRealValues());
details.append("\n");
}
}
if (duplicateShadowsDeleted.contains(shadow.getOid())) {
details.append(" (already deleted)\n");
} else {
shadowsToConsider.add(shadow);
}
}
if (fixUniqueness && shadowsToConsider.size() > 1) {
DuplicateShadowsTreatmentInstruction instruction = duplicateShadowsResolver.determineDuplicateShadowsTreatment(shadowsToConsider);
deleteShadows(instruction, details, task, result);
}
}
}
}
stat.append("Duplicate shadows detected: ").append(duplicateShadowsDetected.size());
if (fixUniqueness) {
stat.append(", deleted: ").append(duplicateShadowsDeleted.size());
// TODO report the duplicates that remain
}
// there can be many 'search owner' subresults
result.summarize();
return stat.toString() + "\n" + details.toString();
}
Aggregations