Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed May 4, 2017
2 parents 9672c1c + c3eeec4 commit 0132a76
Show file tree
Hide file tree
Showing 62 changed files with 3,328 additions and 956 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2013 Evolveum
* Copyright (c) 2010-2017 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -246,18 +246,18 @@ private void acceptSet(Collection<V> set, Visitor visitor) {
}

public void checkNoParent() {
checkNoParent(zeroSet);
checkNoParent(plusSet);
checkNoParent(minusSet);
checkNoParent(zeroSet, "zero");
checkNoParent(plusSet, "plus");
checkNoParent(minusSet, "minus");
}

private void checkNoParent(Collection<V> set) {
private void checkNoParent(Collection<V> set, String desc) {
if (set == null) {
return;
}
for (V val: set) {
if (val.getParent() != null) {
throw new IllegalStateException("Value "+val+" in triple set "+this+" has a parrent "+val.getParent()+". This is unexpected");
throw new IllegalStateException("Value "+val+" in "+desc+" triple set "+this+" has a parrent "+val.getParent()+". This is unexpected");
}
}
}
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2016 Evolveum
* Copyright (c) 2010-2017 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -22,6 +22,7 @@
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.util.DebugDumpable;
import com.evolveum.midpoint.util.DebugUtil;
import com.evolveum.midpoint.util.HumanReadableDescribable;
import com.evolveum.midpoint.util.PrettyPrinter;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType;
Expand All @@ -41,7 +42,7 @@
*
* @author Radovan Semancik
*/
public class ResourceShadowDiscriminator implements Serializable, DebugDumpable {
public class ResourceShadowDiscriminator implements Serializable, DebugDumpable, HumanReadableDescribable {
private static final long serialVersionUID = 346600684011645741L;

private String resourceOid;
Expand Down Expand Up @@ -255,10 +256,10 @@ public static boolean equalsIntent(String a, String b) {

@Override
public String toString() {
return "Discr("+toHumanReadableString()+")";
return toHumanReadableDescription();
}

public String toHumanReadableString() {
public String toHumanReadableDescription() {
StringBuilder sb = new StringBuilder("RSD(");
sb.append(kind==null?"null":kind.value());
sb.append(" (").append(intent).append(")");
Expand Down
Expand Up @@ -15,20 +15,24 @@
*/
package com.evolveum.midpoint.schema.util;

import java.util.ArrayList;
import java.util.List;

import javax.xml.namespace.QName;

import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentSelectorType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ConstructionType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.OrderConstraintsType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ServiceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;
import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType;
Expand Down Expand Up @@ -166,4 +170,69 @@ public static ProtectedStringType getPasswordValue(UserType user) {
}
return passwd.getValue();
}

public static <O extends ObjectType> List<String> determineSubTypes(PrismObject<O> object) {
if (object == null) {
return null;
}

// TODO: get subType (from ObjectType)

if (object.canRepresent(UserType.class)) {
return (((UserType)object.asObjectable()).getEmployeeType());
}
if (object.canRepresent(OrgType.class)) {
return (((OrgType)object.asObjectable()).getOrgType());
}
if (object.canRepresent(RoleType.class)) {
List<String> roleTypes = new ArrayList<>(1);
roleTypes.add((((RoleType)object.asObjectable()).getRoleType()));
return roleTypes;
}
if (object.canRepresent(ServiceType.class)) {
return (((ServiceType)object.asObjectable()).getServiceType());
}
return null;
}

public static <O extends ObjectType> boolean hasSubtype(PrismObject<O> object, String subtype) {
List<String> objectSubtypes = determineSubTypes(object);
if (objectSubtypes == null) {
return false;
}
return objectSubtypes.contains(subtype);
}

public static <O extends ObjectType> void setSubtype(PrismObject<O> object, List<String> subtypes) {

// TODO: set subType (from ObjectType)

List<String> objSubtypes = null;
if (object.canRepresent(UserType.class)) {
objSubtypes = (((UserType)object.asObjectable()).getEmployeeType());
}
if (object.canRepresent(OrgType.class)) {
objSubtypes = (((OrgType)object.asObjectable()).getOrgType());
}
if (object.canRepresent(RoleType.class)) {
if (subtypes == null || subtypes.isEmpty()) {
((RoleType)object.asObjectable()).setRoleType(null);
} else {
((RoleType)object.asObjectable()).setRoleType(subtypes.get(0));
}
return;
}
if (object.canRepresent(ServiceType.class)) {
objSubtypes = (((ServiceType)object.asObjectable()).getServiceType());
}
if (objSubtypes != null) {
if (!objSubtypes.isEmpty()) {
objSubtypes.clear();
}
if (subtypes != null) {
objSubtypes.addAll(subtypes);
}
}

}
}

0 comments on commit 0132a76

Please sign in to comment.