Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
skublik committed Oct 14, 2019
2 parents 106ec41 + 3e0113f commit 503178c
Show file tree
Hide file tree
Showing 135 changed files with 2,515 additions and 2,591 deletions.
2 changes: 1 addition & 1 deletion build-system/pom.xml
Expand Up @@ -1391,7 +1391,7 @@
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.0.51.Final</version>
<version>4.1.42.Final</version>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
Expand Down
Expand Up @@ -249,7 +249,7 @@ public WebMarkupContainer createPanel(String panelId) {
}

tabs.add(
new CountablePanelTab(parentPage.createStringResource("pageAdminFocus.tasks"),
new CountablePanelTab(parentPage.createStringResource("pageAdminFocus.cases"),
getTabVisibility(ComponentConstants.UI_FOCUS_TAB_TASKS_URL, false, parentPage)){

private static final long serialVersionUID = 1L;
Expand Down
Expand Up @@ -49,7 +49,7 @@
@AuthorizationAction(actionUri = PageSelf.AUTH_SELF_ALL_URI,
label = PageSelf.AUTH_SELF_ALL_LABEL,
description = PageSelf.AUTH_SELF_ALL_DESCRIPTION),
@AuthorizationAction(actionUri = AuthorizationConstants.AUTZ_UI_SELF_ASSIGNMENT_SHOP_KART_URL,
@AuthorizationAction(actionUri = AuthorizationConstants.AUTZ_UI_SELF_REQUESTS_ASSIGNMENTS_URL,
label = "PageAssignmentShoppingCart.auth.requestAssignment.label",
description = "PageAssignmentShoppingCart.auth.requestAssignment.description")})
public class PageAssignmentShoppingCart<R extends AbstractRoleType> extends PageSelf {
Expand Down
Expand Up @@ -111,12 +111,14 @@ private static void addMappingExt(Class javaClass, QName xsdType, boolean both)
}
}

@NotNull
public static QName toXsdType(Class javaClass) {
QName xsdType = getJavaToXsdMapping(javaClass);
if (xsdType == null) {
if (xsdType != null) {
return xsdType;
} else {
throw new IllegalArgumentException("No XSD mapping for Java type " + javaClass.getCanonicalName());
}
return xsdType;
}

public static QName getJavaToXsdMapping(Class<?> type) {
Expand Down
Expand Up @@ -146,8 +146,7 @@ private <T> T unmarshalInternal(@NotNull XNodeImpl xnode, @NotNull Class<T> bean
PrimitiveXNodeImpl<T> prim = (PrimitiveXNodeImpl) xnode;
if (XmlTypeConverter.canConvert(beanClass)) {
QName xsdType = XsdTypeMapper.toXsdType(beanClass);
Object parsedValue = prim.getParsedValue(xsdType, beanClass);
return postConvertUnmarshal(parsedValue, pc);
return prim.getParsedValue(xsdType, beanClass);
} else if (beanClass.isEnum()) {
return unmarshalEnumFromPrimitive(prim, beanClass, pc);
}
Expand Down Expand Up @@ -1111,8 +1110,7 @@ private <T extends SearchFilterType> T unmarshalSearchFilterType(MapXNodeImpl xm

private ItemPathType unmarshalItemPath(PrimitiveXNodeImpl<ItemPathType> primitiveXNode, Class beanClass, ParsingContext parsingContext)
throws SchemaException {
ItemPathType parsedValue = primitiveXNode.getParsedValue(ItemPathType.COMPLEX_TYPE, ItemPathType.class);
return postConvertUnmarshal(parsedValue, parsingContext);
return primitiveXNode.getParsedValue(ItemPathType.COMPLEX_TYPE, ItemPathType.class);
}

private Object unmarshalPolyStringFromPrimitive(PrimitiveXNodeImpl<?> node, Class<?> beanClass, ParsingContext parsingContext)
Expand Down
Expand Up @@ -81,10 +81,12 @@ public T getParsedValue(@NotNull QName typeName) throws SchemaException {
return getParsedValue(typeName, null, XNodeProcessorEvaluationMode.STRICT);
}

// @post: return value is type-compliant with expectedClass (if both are non-null)
public T getParsedValue(@NotNull QName typeName, @Nullable Class<T> expectedClass) throws SchemaException {
return getParsedValue(typeName, expectedClass, XNodeProcessorEvaluationMode.STRICT);
}

// @post: return value is type-compliant with expectedClass (if both are non-null)
public T getParsedValue(@NotNull QName typeName, @Nullable Class<T> expectedClass, XNodeProcessorEvaluationMode mode) throws SchemaException {
if (!isParsed()) {
parseValue(typeName, mode);
Expand Down
Expand Up @@ -136,14 +136,24 @@ public class GetOperationOptions extends AbstractOptions implements Serializable
private Long staleness;

/**
* Force refresh of object before the data are retrieved. This option is a guarantee that we get the freshest
* data that is possible. However, strange things may happen here. E.g. object that existed before this operation
* may get deleted during refresh because it has expired in the meantime. Or get operation may in fact attempt
* to create, modify and even delete of an account. This may happen in case that there are some unfinished
* operations in the shadow. Therefore when using this option you have to be really prepared for everything.
* Force refresh of object before the data are retrieved. The operations are retried after the time perios passed.
* This option is a guarantee that we get the freshest data that is possible. However, strange things may happen here.
* E.g. object that existed before this operation may get deleted during refresh because it has expired in the
* meantime. Or get operation may in fact attempt to create, modify and even delete of an account. This may
* happen in case that there are some unfinished operations in the shadow. Therefore when using this option you
* have to be really prepared for everything.
*/
private Boolean forceRefresh;

/**
* Force retry of postponed operations of object before the data are retrieved even when the periods hasn't passed yet.
* This option is a guarantee that we get the freshest data that is possible. However, strange things may happen here.
* E.g. object that existed before this operation may get deleted during refresh because it has expired in the meantime.
* Or get operation may in fact attempt to create, modify and even delete of an account. This may happen in case that
* there are some unfinished operations in the shadow. Therefore when using this option you have to be really prepared for everything.
*/
private Boolean forceRetry;

/**
* Should the results be made distinct.
* Not all providers support this option.
Expand Down Expand Up @@ -694,6 +704,30 @@ public static GetOperationOptions createForceRefresh() {
return opts;
}

public Boolean getForceRetry() {
return forceRetry;
}

public void setForceRetry(Boolean forceRetry) {
this.forceRetry = forceRetry;
}

public static GetOperationOptions createForceRetry() {
GetOperationOptions opts = new GetOperationOptions();
opts.setForceRetry(Boolean.TRUE);
return opts;
}

public static boolean isForceRetry(GetOperationOptions options) {
if (options == null) {
return false;
}
if (options.forceRetry == null) {
return false;
}
return options.forceRetry;
}

public Boolean getDistinct() {
return distinct;
}
Expand Down
@@ -0,0 +1,137 @@
/*
* Copyright (c) 2010-2019 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.schema;

import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.util.DebugDumpable;
import com.evolveum.midpoint.util.DebugUtil;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType;

import java.util.Collection;

public class RefreshShadowOperaton implements DebugDumpable {

private static final transient Trace LOGGER = TraceManager.getTrace(RefreshShadowOperaton.class);

private PrismObject<ShadowType> refreshedShadow;
private Collection<ObjectDeltaOperation<ShadowType>> executedDeltas;
private OperationResult refreshResult;

public Collection<ObjectDeltaOperation<ShadowType>> getExecutedDeltas() {
return executedDeltas;
}

public void setExecutedDeltas(Collection<ObjectDeltaOperation<ShadowType>> executedDeltas) {
this.executedDeltas = executedDeltas;
}

public PrismObject<ShadowType> getRefreshedShadow() {
return refreshedShadow;
}

public void setRefreshedShadow(PrismObject<ShadowType> refreshedShadow) {
this.refreshedShadow = refreshedShadow;
}

public OperationResult getRefreshResult() {
return refreshResult;
}

public void setRefreshResult(OperationResult refreshResult) {
this.refreshResult = refreshResult;
}

public Exception getCause(OperationResult result) {
Throwable throwable = result.getCause();
if (throwable == null) {
return null;
}
if (Exception.class.isAssignableFrom(throwable.getClass())) {
return (Exception) throwable;
}

return null;
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((executedDeltas == null) ? 0 : executedDeltas.hashCode());
result = prime * result + ((refreshedShadow == null) ? 0 : refreshedShadow.hashCode());
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
RefreshShadowOperaton other = (RefreshShadowOperaton) obj;
if (executedDeltas == null) {
if (other.executedDeltas != null)
return false;
} else if (!executedDeltas.equals(other.executedDeltas))
return false;
if (refreshedShadow == null) {
if (other.refreshedShadow != null)
return false;
} else if (!refreshedShadow.equals(other.refreshedShadow))
return false;
return true;
}

@Override
public String toString() {
return getDebugDumpClassName() + "(" + executedDeltas
+ ": " + refreshedShadow + ")";
}

@Override
public String debugDump(int indent) {
StringBuilder sb = new StringBuilder();
debugDump(sb, indent, true);
return sb.toString();
}

public String shorterDebugDump(int indent) {
StringBuilder sb = new StringBuilder();
debugDump(sb, indent, false);
return sb.toString();
}

private void debugDump(StringBuilder sb, int indent, boolean detailedResultDump) {
DebugUtil.indentDebugDump(sb, indent);
sb.append(getDebugDumpClassName()).append("\n");
DebugUtil.debugDumpWithLabel(sb, "Delta", executedDeltas, indent + 1);
sb.append("\n");
if (detailedResultDump) {
DebugUtil.debugDumpWithLabel(sb, "Refreshed shadow", refreshedShadow, indent + 1);
} else {
DebugUtil.debugDumpLabel(sb, "Refreshed shadow", indent + 1);
if (refreshedShadow == null) {
sb.append("null");
} else {
refreshedShadow.debugDump();
}
}
}

protected String getDebugDumpClassName() {
return "RefreshShadowOperation";
}


}

Expand Up @@ -775,6 +775,21 @@ private static <T> void validateAttribute(ResourceAttribute<T> attribute,
}
}

public static ProtectedStringType getPasswordValue(ShadowType shadowType) {
if (shadowType == null) {
return null;
}
CredentialsType creds = shadowType.getCredentials();
if (creds == null) {
return null;
}
PasswordType passwd = creds.getPassword();
if (passwd == null) {
return null;
}
return passwd.getValue();
}

public static String shortDumpShadow(PrismObject<ShadowType> shadow) {
if (shadow == null) {
return "null";
Expand Down
8 changes: 4 additions & 4 deletions infra/schema/src/main/schemadoc/templates/items-inc.vm
Expand Up @@ -32,7 +32,7 @@

#if($modulo == 0)
<tr class="rowColor">
<td class="colFirst"><a href="#item-$itemDefinition.Name.LocalPart">$itemDefinition.Name.LocalPart</a></td>
<td class="colFirst"><a href="#item-$itemDefinition.ItemName.LocalPart">$itemDefinition.ItemName.LocalPart</a></td>
<td class="colOne">
$itemDefinition.DocClassName<br/>
#if ($typeUrl)
Expand All @@ -48,7 +48,7 @@
</tr>
#else
<tr class="altColor">
<td class="colFirst"><a href="#item-$itemDefinition.Name.LocalPart">$itemDefinition.Name.LocalPart</a></td>
<td class="colFirst"><a href="#item-$itemDefinition.ItemName.LocalPart">$itemDefinition.ItemName.LocalPart</a></td>
<td class="colOne">
$itemDefinition.DocClassName<br/>
#if ($typeUrl)
Expand All @@ -75,11 +75,11 @@
<h3>Items</h3>

#foreach($itemDefinition in $definition.getDefinitions())
<a name="$itemDefinition.Name.LocalPart"></a>
<a name="$itemDefinition.ItemName.LocalPart"></a>
<ul class="blockList">
<li class="blockList">
<h4>
<a id="item-$itemDefinition.Name.LocalPart">$itemDefinition.Name.LocalPart</a>
<a id="item-$itemDefinition.ItemName.LocalPart">$itemDefinition.ItemName.LocalPart</a>
</h4>
<p class="block">Flags: $!itemDefinition.debugFlags()</p>
<p class="block">Multiplicity: $itemDefinition.debugMultiplicity()</p>
Expand Down
Expand Up @@ -10,6 +10,7 @@
import com.evolveum.midpoint.util.exception.SystemException;
import com.evolveum.midpoint.util.logging.Trace;

import java.lang.reflect.InvocationTargetException;
import java.util.concurrent.ConcurrentHashMap;

/**
Expand All @@ -33,8 +34,8 @@ public static <T extends AbstractThreadLocalCache> T enter(ConcurrentHashMap<Thr
if (inst == null) {
logger.trace("Cache: creating for thread {}", currentThread.getName());
try {
inst = cacheClass.newInstance();
} catch (InstantiationException|IllegalAccessException e) {
inst = cacheClass.getDeclaredConstructor().newInstance();
} catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
throw new SystemException("Couldn't instantiate cache: " + e.getMessage(), e);
}
inst.setConfiguration(configuration);
Expand Down
Expand Up @@ -1414,8 +1414,8 @@ public <F extends FocusType> String computeProjectionLifecycle(F focus, ShadowTy
if (shadow.getKind() != null && shadow.getKind() != ShadowKindType.ACCOUNT) {
return null;
}
ProtectedStringType passwordPs = FocusTypeUtil.getPasswordValue((UserType) focus);
if (passwordPs != null && passwordPs.canGetCleartext()) {
ProtectedStringType focusPasswordPs = FocusTypeUtil.getPasswordValue((UserType) focus);
if (focusPasswordPs != null && focusPasswordPs.canGetCleartext()) {
return null;
}
CredentialsCapabilityType credentialsCapabilityType = ResourceTypeUtil
Expand Down
Expand Up @@ -659,10 +659,16 @@ private <F extends FocusType> void loadLinkRefsFromFocus(LensContext<F> context,
}
PrismObject<ShadowType> shadow = linkRefVal.getObject();
if (shadow == null) {
// Using NO_FETCH so we avoid reading in a full account. This is more efficient as we don't need full account here.
// We need to fetch from provisioning and not repository so the correct definition will be set.
GetOperationOptions rootOpts = GetOperationOptions.createNoFetch();
rootOpts.setPointInTimeType(PointInTimeType.FUTURE);
GetOperationOptions rootOpts = null;
if (context.isDoReconciliationForAllProjections()) {
rootOpts = GetOperationOptions.createForceRetry();
} else {
// Using NO_FETCH so we avoid reading in a full account. This is more efficient as we don't need full account here.
// We need to fetch from provisioning and not repository so the correct definition will be set.
rootOpts = GetOperationOptions.createNoFetch();
rootOpts.setPointInTimeType(PointInTimeType.FUTURE);
}

Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(rootOpts);
LOGGER.trace("Loading shadow {} from linkRef, options={}", oid, options);
try {
Expand Down Expand Up @@ -1028,7 +1034,7 @@ private <F extends FocusType> LensProjectionContext getOrCreateAccountContext(Le
LOGGER.trace("Projection {} already exists in context\nExisting:\n{}\nNew:\n{}", rsd,
existingShadow.debugDump(1), newShadow.debugDump(1));
}
if (!ShadowUtil.isDead(newShadow.asObjectable())) {
if (!ShadowUtil.isDead(existingShadow.asObjectable())) {
throw new PolicyViolationException("Projection "+rsd+" already exists in context (existing "+existingShadow+", new "+projection);
}
// Dead shadow. This is somehow expected, fix it and we can go on
Expand Down
Expand Up @@ -777,7 +777,8 @@ private boolean scanForUnfinishedOperations(RunningTask task, String resourceOid
RepositoryCache.enter(cacheConfigurationManager);
OperationResult provisioningResult = new OperationResult(OperationConstants.RECONCILIATION+".finishOperation");
try {
ProvisioningOperationOptions options = ProvisioningOperationOptions.createCompletePostponed(false);
// ProvisioningOperationOptions options = ProvisioningOperationOptions.createCompletePostponed(false);
ProvisioningOperationOptions options = ProvisioningOperationOptions.createForceRetry(Boolean.TRUE);
ModelImplUtils.clearRequestee(task);
provisioningService.refreshShadow(shadow, options, task, provisioningResult);
// retryFailedOperation(shadow.asObjectable(), opResult);
Expand Down

0 comments on commit 503178c

Please sign in to comment.