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
mederly committed Oct 15, 2014
2 parents 75d6aee + bf6692e commit 864be46
Show file tree
Hide file tree
Showing 17 changed files with 1,075 additions and 54 deletions.
Expand Up @@ -24,6 +24,8 @@
import com.evolveum.midpoint.prism.xjc.AnyArrayList;
import com.evolveum.midpoint.prism.xml.XsdTypeMapper;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.schema.processor.ResourceAttribute;
import com.evolveum.midpoint.schema.util.ShadowUtil;
import com.evolveum.midpoint.util.DOMUtil;
import com.evolveum.midpoint.web.component.input.*;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
Expand All @@ -33,9 +35,9 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import com.evolveum.midpoint.xml.ns.model.workflow.common_forms_3.RoleApprovalFormType;
import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType;

import com.sun.org.apache.xerces.internal.dom.ElementNSImpl;
import com.sun.org.apache.xerces.internal.dom.TextImpl;

import org.apache.commons.lang.ClassUtils;
import org.apache.commons.lang.Validate;
import org.apache.wicket.AttributeModifier;
Expand All @@ -57,6 +59,7 @@
import javax.xml.namespace.QName;

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

/**
Expand Down Expand Up @@ -436,22 +439,51 @@ private String createAssociationTooltipText(PrismProperty property){
PrismObject<ShadowType> shadowPrism = (PrismObject<ShadowType>)property.getParent().getParent();
ShadowType shadow = shadowPrism.asObjectable();

if(shadow.getAttributes() != null){
ShadowAttributesType attributes = shadow.getAttributes();
AnyArrayList attrs = (AnyArrayList)attributes.getAny();

for(Object o: attrs){
ElementNSImpl element = (ElementNSImpl)o;
sb.append(element.getLocalName() + ": ");
sb.append(((TextImpl)element.getFirstChild()).getData() + "<br>");
}
Collection<ResourceAttribute<?>> attributes = ShadowUtil.getAttributes(shadowPrism);
if (attributes == null || attributes.isEmpty()){
return sb.toString();
}

for (ResourceAttribute<?> attr : attributes){
for (Object realValue : attr.getRealValues()){
sb.append(getAttributeName(attr));
sb.append(":");
sb.append(realValue);
sb.append("<br>");
}
}
// if(shadow.getAttributes() != null){
// ShadowAttributesType attributes = shadow.getAttributes();
// AnyArrayList attrs = (AnyArrayList)attributes.getAny();
//
// for(Object o: attrs){
// ElementNSImpl element = (ElementNSImpl)o;
// sb.append(element.getLocalName() + ": ");
// sb.append(((TextImpl)element.getFirstChild()).getData() + "<br>");
// }
// }
}

return sb.toString();
}

private void addValue(AjaxRequestTarget target) {
private String getAttributeName(ResourceAttribute<?> attr) {
if (attr.getDisplayName() != null){
return attr.getDisplayName();
}

if (attr.getNativeAttributeName() != null){
return attr.getNativeAttributeName();
}

if (attr.getElementName() != null){
return attr.getElementName().getLocalPart();
}

return null; //TODO: is this ok?? or better is exception or some default name??
}

private void addValue(AjaxRequestTarget target) {
ValueWrapper wrapper = model.getObject();
PropertyWrapper propertyWrapper = wrapper.getProperty();
propertyWrapper.addValue();
Expand Down
Expand Up @@ -23,6 +23,7 @@
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Random;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
Expand Down Expand Up @@ -458,8 +459,8 @@ private synchronized <T extends DummyObject> String addObject(Map<String,T> map,

//this is "resource-generated" attribute (used to simulate resource which generate by default attributes which we need to sync)
if (generateDefaultValues){
int internalId = allObjects.size();
newObject.addAttributeValue(DummyAccount.ATTR_INTERNAL_ID, internalId++);
// int internalId = allObjects.size();
newObject.addAttributeValue(DummyAccount.ATTR_INTERNAL_ID, new Random().nextInt());
}


Expand Down
Expand Up @@ -610,16 +610,19 @@ public static <F extends ObjectType> void loadFullAccount(LensContext<F> context
LOGGER.trace("Loading full account {} from provisioning", accCtx);

try{
GetOperationOptions getOptions = GetOperationOptions.createDoNotDiscovery();
getOptions.setAllowNotFound(true);
Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(getOptions);
PrismObject<ShadowType> objectOld = provisioningService.getObject(ShadowType.class,
accCtx.getOid(), SelectorOptions.createCollection(GetOperationOptions.createDoNotDiscovery()),
accCtx.getOid(), options,
null, result);
// TODO: use setLoadedObject() instead?
accCtx.setObjectCurrent(objectOld);
ShadowType oldShadow = objectOld.asObjectable();
accCtx.determineFullShadowFlag(oldShadow.getFetchResult());

} catch (ObjectNotFoundException ex){
if (accCtx.isDelete()){
if (accCtx.isDelete() || context.getFocusContext().isDelete()){
//this is OK, shadow was deleted, but we will continue in processing with old shadow..and set it as full so prevent from other full loading
accCtx.setFullShadow(true);
} else
Expand Down
Expand Up @@ -162,7 +162,7 @@ private <F extends FocusType> ObjectDelta<ShadowType> consolidateValuesToModifyD
LensProjectionContext projCtx, boolean addUnchangedValues, OperationResult result)
throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException,
ConfigurationException, SecurityViolationException, PolicyViolationException {

// "Squeeze" all the relevant mappings into a data structure that we can process conveniently. We want to have all the
// (meta)data about relevant for a specific attribute in one data structure, not spread over several account constructions.
MappingExtractor<PrismPropertyValue<?>, F> attributeExtractor = new MappingExtractor<PrismPropertyValue<?>, F>() {
Expand Down
Expand Up @@ -896,6 +896,7 @@ private <F extends ObjectType> void finishLoadOfProjectionContext(LensContext<F>
projContext.setExists(true);
GetOperationOptions rootOptions = projContext.isDoReconciliation() ?
GetOperationOptions.createDoNotDiscovery() : GetOperationOptions.createNoFetch();
rootOptions.setAllowNotFound(true);
Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(rootOptions);
try{
PrismObject<ShadowType> objectOld = provisioningService.getObject(
Expand Down
Expand Up @@ -407,20 +407,6 @@ public <F extends ObjectType> boolean checkDependencies(LensContext<F> context,
|| strictness == ResourceObjectTypeDependencyStrictnessType.RELAXED) {
if (wasProvisioned(dependencyAccountContext, context.getExecutionWave())) {
// everything OK
// if (ResourceTypeUtil.isForceLoadDependentShadow(dependency) && !dependencyAccountContext.isDelete()){
// LOGGER.info("FORCE TO LOAD FULL ACCOUNT " + dependencyAccountContext);
// try {
// LensUtil.loadFullAccount(context, dependencyAccountContext, provisioningService, result);
// dependencyAccountContext.setDoReconciliation(true);
// if (dependencyAccountContext.getExecutedDeltas() != null && !dependencyAccountContext.getExecutedDeltas().isEmpty()){
// context.resetProjectionWave();
// }
// } catch (ObjectNotFoundException | CommunicationException | SchemaException
// | ConfigurationException | SecurityViolationException e) {
// // this is not fatal error. we can continue without full account..the incosinstencies will be treaten later, by reconciliation
// LOGGER.warn("Could not load dependent shadow, continue with the shadow loaded before.");
// }
// }
} else {
// We do not want to throw exception here. That will stop entire projection.
// Let's just mark the projection as broken and skip it.
Expand Down
Expand Up @@ -265,6 +265,9 @@ public <T extends ObjectType> PrismObject<T> getObject(Class<T> type, String oid
} catch (ObjectNotFoundException e) {
if (!GetOperationOptions.isAllowNotFound(rootOptions)){
recordFatalError(LOGGER, result, "Error getting object OID=" + oid + ": " + e.getMessage(), e);
} else{
result.muteLastSubresultError();
result.computeStatus();
}
throw e;
} catch (CommunicationException e) {
Expand Down Expand Up @@ -1475,6 +1478,9 @@ private <T extends ObjectType> PrismObject<T> getRepoObject(Class<T> type, Strin
} catch (ObjectNotFoundException e) {
if (!GetOperationOptions.isAllowNotFound(options)){
recordFatalError(LOGGER, result, "Can't get object with oid " + oid + ". Reason " + e.getMessage(), e);
} else {
result.muteLastSubresultError();
result.computeStatus();
}
throw e;
} catch (SchemaException ex) {
Expand Down

0 comments on commit 864be46

Please sign in to comment.