Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feature/admin-lte
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Apr 13, 2016
2 parents e35db47 + d02028f commit b5d14f9
Show file tree
Hide file tree
Showing 31 changed files with 594 additions and 618 deletions.
Expand Up @@ -18,6 +18,9 @@

import com.evolveum.midpoint.security.api.SecurityEnforcer;
import org.apache.commons.lang.Validate;
import org.apache.wicket.Application;
import org.apache.wicket.Session;
import org.apache.wicket.ThreadContext;
import org.springframework.security.core.Authentication;

import java.util.concurrent.Callable;
Expand Down Expand Up @@ -49,5 +52,14 @@ public final V call() throws Exception {
}
}

protected void setupContext(Application application, Session session) {
if (!Application.exists() && application != null) {
ThreadContext.setApplication(application);
}
if (!Session.exists() && session != null) {
ThreadContext.setSession(session);
}
}

public abstract V callWithContextPrepared() throws Exception;
}
Expand Up @@ -22,8 +22,6 @@
import com.evolveum.midpoint.web.component.AsyncUpdatePanel;
import com.evolveum.midpoint.web.component.util.CallableResult;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;

import org.apache.commons.lang.StringUtils;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
Expand Down
Expand Up @@ -447,7 +447,7 @@ private ObjectQuery createQuery(boolean useNameFilter, boolean isNot) {
List<ObjectFilter> conditions = new ArrayList<>();
PrismReferenceValue roleRef = new PrismReferenceValue();
roleRef.setOid(roleId);
roleRef.setTargetType(RoleType.COMPLEX_TYPE);
// roleRef.setTargetType(RoleType.COMPLEX_TYPE);
ObjectFilter roleFilter = RefFilter.createReferenceEqual(
new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_TARGET_REF), UserType.class,
getPrismContext(), roleRef);
Expand Down
Expand Up @@ -140,7 +140,9 @@ public void detach() {
});
add(linksPanel);

// TODO is this correct? [med]
application = getApplication();
final Session session = Session.get();

AsyncDashboardPanel<Object, List<WorkItemDto>> workItemsPanel =
new AsyncDashboardPanel<Object, List<WorkItemDto>>(ID_WORK_ITEMS_PANEL, createStringResource("PageSelfDashboard.workItems"),
Expand All @@ -155,9 +157,7 @@ protected SecurityContextAwareCallable<CallableResult<List<WorkItemDto>>> create

@Override
public CallableResult<List<WorkItemDto>> callWithContextPrepared() throws Exception {
if (!Application.exists()) {
ThreadContext.setApplication(application);
}
setupContext(application, session); // TODO is this correct? [med]
return loadWorkItems();
}
};
Expand Down Expand Up @@ -191,9 +191,7 @@ protected SecurityContextAwareCallable<CallableResult<List<ProcessInstanceDto>>>

@Override
public CallableResult<List<ProcessInstanceDto>> callWithContextPrepared() throws Exception {
if (!Application.exists()) {
ThreadContext.setApplication(application);
}
setupContext(application, session);
return loadMyRequests();
}
};
Expand Down
4 changes: 4 additions & 0 deletions infra/prism/pom.xml
Expand Up @@ -55,6 +55,10 @@
<groupId>org.apache.santuario</groupId>
<artifactId>xmlsec</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations-java5</artifactId>
</dependency>
<!-- Uncomment for JSON support (experimental) -->
<!-- <dependency> -->
<!-- <groupId>org.codehaus.jackson</groupId> -->
Expand Down
@@ -0,0 +1,93 @@
/*
* Copyright (c) 2010-2016 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.evolveum.midpoint.prism;

import com.evolveum.midpoint.prism.parser.XNodeProcessorEvaluationMode;
import com.evolveum.midpoint.util.logging.Trace;

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

/**
* @author mederly
*/
public class ParsingContext {

private XNodeProcessorEvaluationMode evaluationMode = XNodeProcessorEvaluationMode.STRICT;
private boolean allowMissingRefTypes;
private final List<String> warnings = new ArrayList<>();

private ParsingContext() {
}

private void setAllowMissingRefTypes(boolean allowMissingRefTypes) {
this.allowMissingRefTypes = allowMissingRefTypes;
}

private void setEvaluationMode(XNodeProcessorEvaluationMode evaluationMode) {
this.evaluationMode = evaluationMode;
}

public boolean isAllowMissingRefTypes() {
return allowMissingRefTypes;
}

public XNodeProcessorEvaluationMode getEvaluationMode() {
return evaluationMode;
}

public static ParsingContext forMode(XNodeProcessorEvaluationMode mode) {
ParsingContext pc = new ParsingContext();
pc.setEvaluationMode(mode);
return pc;
}

public static ParsingContext allowMissingRefTypes() {
ParsingContext pc = new ParsingContext();
pc.setAllowMissingRefTypes(true);
return pc;
}

public static ParsingContext createDefault() {
return new ParsingContext();
}

public boolean isCompat() {
return evaluationMode == XNodeProcessorEvaluationMode.COMPAT;
}

public boolean isStrict() {
return evaluationMode == XNodeProcessorEvaluationMode.STRICT;
}

public void warn(Trace logger, String message) {
logger.warn("{}", message);
warn(message);
}

public void warn(String message) {
warnings.add(message);
}

public List<String> getWarnings() {
return warnings;
}

public boolean hasWarnings() {
return !warnings.isEmpty();
}
}
Expand Up @@ -1111,7 +1111,7 @@ private PrismContainerValue<C> parseRawElementsToNewValue(PrismContainerValue<C>
XNode origRawXnode = origCVal.rawXNode;
if (origRawXnode != null) {
XNodeProcessor xnodeProcessor = definition.getPrismContext().getXnodeProcessor();
PrismContainerValue<C> newCVal = xnodeProcessor.parsePrismContainerValue(origRawXnode, definition);
PrismContainerValue<C> newCVal = xnodeProcessor.parsePrismContainerValue(origRawXnode, definition, ParsingContext.createDefault());
return newCVal;
}

Expand Down Expand Up @@ -1185,8 +1185,9 @@ public void applyDefinition(PrismContainerDefinition<C> containerDef, boolean fo
rawElements = null;
}
if (rawXNode != null) {
XNodeProcessor xnodeProcessor = valueDefinition.getPrismContext().getXnodeProcessor();
PrismContainerValue<C> newCVal = xnodeProcessor.parsePrismContainerValue(rawXNode, valueDefinition);
PrismContext prismContext = valueDefinition.getPrismContext();
XNodeProcessor xnodeProcessor = prismContext.getXnodeProcessor();
PrismContainerValue<C> newCVal = xnodeProcessor.parsePrismContainerValue(rawXNode, valueDefinition, ParsingContext.createDefault());
// Maybe we need to manually reset parent on items?
addAll(newCVal.getItems());
rawXNode = null;
Expand Down

0 comments on commit b5d14f9

Please sign in to comment.