Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/support-3.6' into support-3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Aug 25, 2017
2 parents 8d8181c + d088494 commit 87304d6
Show file tree
Hide file tree
Showing 228 changed files with 4,503 additions and 3,302 deletions.
Expand Up @@ -23,6 +23,7 @@
import com.evolveum.midpoint.schema.result.OperationResultStatus;
import com.evolveum.midpoint.security.api.AuthorizationConstants;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.LocalizableMessage;
import com.evolveum.midpoint.util.exception.*;
import com.evolveum.midpoint.util.logging.LoggingUtils;
import com.evolveum.midpoint.util.logging.Trace;
Expand All @@ -33,6 +34,8 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.Validate;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.StringResourceModel;

import java.io.PrintWriter;
import java.io.Serializable;
Expand Down Expand Up @@ -79,13 +82,25 @@ public boolean isAlreadyShown() {
public void setAlreadyShown(boolean alreadyShown) {
this.alreadyShown = alreadyShown;
}

public static OpResult getOpResult(PageBase page, OperationResult result){
public static OpResult getOpResult(PageBase page, OperationResult result){
OpResult opResult = new OpResult();
Validate.notNull(result, "Operation result must not be null.");
Validate.notNull(result.getStatus(), "Operation result status must not be null.");

opResult.message = result.getMessage();
if (result.getCause() != null && result.getCause() instanceof CommonException){
LocalizableMessage localizableMessage = ((CommonException) result.getCause()).getUserFriendlyMessage();
if (localizableMessage != null) {
String key = localizableMessage.getKey() != null ? localizableMessage.getKey() : localizableMessage.getFallbackMessage();
StringResourceModel stringResourceModel = new StringResourceModel(key, page).setModel(new Model<String>()).setDefaultValue(localizableMessage.getFallbackMessage())
.setParameters(localizableMessage.getArgs());
opResult.message = stringResourceModel.getString();
}
}

if (opResult.message == null) {
opResult.message = result.getMessage();
}
opResult.operation = result.getOperation();
opResult.status = result.getStatus();
opResult.count = result.getCount();
Expand Down
Expand Up @@ -77,7 +77,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti
@Test
public void test000PreparationAndSanity() throws Exception {
final String TEST_NAME = "test100GetResourceDummy";
TestUtil.displayTestTile(this, TEST_NAME);
TestUtil.displayTestTitle(this, TEST_NAME);

// GIVEN
Task task = taskManager.createTaskInstance(AbstractInitializedGuiIntegrationTest.class.getName() + "." + TEST_NAME);
Expand Down
Expand Up @@ -69,7 +69,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti
// work in progress
@Test
public void test001Logfiles() throws Exception {
TestUtil.displayTestTile("test001Logfiles");
TestUtil.displayTestTitle("test001Logfiles");

// GIVEN - system startup and initialization that has already happened
LogfileTestTailer tailer = new LogfileTestTailer(LoggingConfigurationManager.AUDIT_LOGGER_NAME, false);
Expand Down
Expand Up @@ -61,7 +61,7 @@ public class TestDescriptorLoader extends AbstractGuiUnitTest {
@Test(enabled=false)
public void testDescriptorLoader() {
final String TEST_NAME = "testDescriptorLoader";
TestUtil.displayTestTile(TEST_NAME);
TestUtil.displayTestTitle(TEST_NAME);

MidPointApplication midPointApplication = new MidPointApplication();
ServletContext mockServletContext = new ServletContext() {
Expand Down
Expand Up @@ -113,7 +113,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti
@Test
public void test100CreateWrapperUserJack() throws Exception {
final String TEST_NAME = "test100CreateWrapperUserJack";
TestUtil.displayTestTile(TEST_NAME);
TestUtil.displayTestTitle(TEST_NAME);

PrismObject<UserType> user = getUser(USER_JACK_OID);

Expand Down Expand Up @@ -166,7 +166,7 @@ public void test100CreateWrapperUserJack() throws Exception {
@Test
public void test102CreateWrapperUserEmpty() throws Exception {
final String TEST_NAME = "test102CreateWrapperUserEmpty";
TestUtil.displayTestTile(TEST_NAME);
TestUtil.displayTestTitle(TEST_NAME);

PrismObject<UserType> user = getUser(USER_EMPTY_OID);

Expand Down Expand Up @@ -219,7 +219,7 @@ public void test102CreateWrapperUserEmpty() throws Exception {
@Test
public void test150CreateWrapperShadow() throws Exception {
final String TEST_NAME = "test150CreateWrapperShadow";
TestUtil.displayTestTile(TEST_NAME);
TestUtil.displayTestTitle(TEST_NAME);

PrismObject<ShadowType> shadow = getShadowModel(accountJackOid);
shadow.findReference(ShadowType.F_RESOURCE_REF).getValue().setObject(resourceDummy);
Expand Down Expand Up @@ -274,7 +274,7 @@ public void test150CreateWrapperShadow() throws Exception {
@Test
public void test220AssignRoleLandluberToWally() throws Exception {
final String TEST_NAME = "test220AssignRoleLandluberToWally";
TestUtil.displayTestTile(this, TEST_NAME);
displayTestTitle(TEST_NAME);

Task task = taskManager.createTaskInstance(TestIntegrationObjectWrapperFactory.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
Expand Down Expand Up @@ -356,7 +356,7 @@ public void test220AssignRoleLandluberToWally() throws Exception {
@Test
public void test800EditSchemaJackPropReadAllModifySomeUser() throws Exception {
final String TEST_NAME = "test800EditSchemaJackPropReadAllModifySomeUser";
TestUtil.displayTestTile(this, TEST_NAME);
displayTestTitle(TEST_NAME);
// GIVEN
cleanupAutzTest(USER_JACK_OID);
assignRole(USER_JACK_OID, ROLE_PROP_READ_ALL_MODIFY_SOME_USER_OID);
Expand Down Expand Up @@ -432,7 +432,7 @@ public void test800EditSchemaJackPropReadAllModifySomeUser() throws Exception {
@Test
public void test802EditSchemaJackPropReadSomeModifySomeUser() throws Exception {
final String TEST_NAME = "test800EditSchemaJackPropReadAllModifySomeUser";
TestUtil.displayTestTile(this, TEST_NAME);
displayTestTitle(TEST_NAME);
// GIVEN
cleanupAutzTest(USER_JACK_OID);
assignRole(USER_JACK_OID, ROLE_PROP_READ_SOME_MODIFY_SOME_USER_OID);
Expand Down
Expand Up @@ -43,7 +43,7 @@ public class TestUnitObjectWrapperFactory extends AbstractGuiUnitTest {
@Test
public void testCreateWrapperUser() throws Exception {
final String TEST_NAME = "testCreateWrapperUser";
TestUtil.displayTestTile(TEST_NAME);
TestUtil.displayTestTitle(TEST_NAME);

PrismObject<UserType> user = PrismTestUtil.parseObject(USER_JACK_REPO_FILE);
PrismObjectDefinition<UserType> objDef = user.getDefinition();
Expand Down
Expand Up @@ -461,6 +461,11 @@ public Collection<? extends QName> getNamesOfAssociationsWithOutboundExpressions
.map(a -> a.getName())
.collect(Collectors.toCollection(HashSet::new));
}

@Override
public boolean isTolerantAuxiliaryObjectClasses() {
return structuralObjectClassDefinition.isTolerantAuxiliaryObjectClasses();
}

@Override
public boolean hasAuxiliaryObjectClass(QName expectedObjectClassName) {
Expand Down
Expand Up @@ -595,6 +595,11 @@ public boolean hasAuxiliaryObjectClass(QName expectedObjectClassName) {
return refinedObjectClassDefinition.hasAuxiliaryObjectClass(expectedObjectClassName);
}

@Override
public boolean isTolerantAuxiliaryObjectClasses() {
return refinedObjectClassDefinition.isTolerantAuxiliaryObjectClasses();
}

@Override
public ObjectQuery createShadowSearchQuery(String resourceOid) throws SchemaException {
return refinedObjectClassDefinition.createShadowSearchQuery(resourceOid);
Expand Down
Expand Up @@ -149,6 +149,8 @@ default PrismObject<ShadowType> createBlankShadow() {
Collection<RefinedObjectClassDefinition> getAuxiliaryObjectClassDefinitions();

boolean hasAuxiliaryObjectClass(QName expectedObjectClassName);

boolean isTolerantAuxiliaryObjectClasses();

Collection<ResourceObjectPattern> getProtectedObjectPatterns();

Expand Down
Expand Up @@ -414,6 +414,19 @@ public boolean hasAuxiliaryObjectClass(QName expectedObjectClassName) {
return auxiliaryObjectClassDefinitions.stream()
.anyMatch(def -> QNameUtil.match(def.getTypeName(), expectedObjectClassName));
}

@Override
public boolean isTolerantAuxiliaryObjectClasses() {
if (schemaHandlingObjectTypeDefinitionType == null) {
return false;
}
Boolean tolerantAuxiliaryObjectClasses = schemaHandlingObjectTypeDefinitionType.isTolerantAuxiliaryObjectClasses();
if (tolerantAuxiliaryObjectClasses == null) {
return false;
} else {
return tolerantAuxiliaryObjectClasses;
}
}

@Override
public Collection<ResourceObjectPattern> getProtectedObjectPatterns() {
Expand Down
Expand Up @@ -55,7 +55,7 @@ public void setup() throws SchemaException, SAXException, IOException {
@Test
public void testValueElementsRoundtripString() throws Exception {
final String TEST_NAME = "testValueElementsRoundtripString";
TestUtil.displayTestTile(TEST_NAME);
TestUtil.displayTestTitle(TEST_NAME);

// GIVEN
PrismContext prismContext = PrismTestUtil.getPrismContext();
Expand All @@ -71,7 +71,7 @@ public void testValueElementsRoundtripString() throws Exception {
@Test
public void testValueElementsRoundtripInt() throws Exception {
final String TEST_NAME = "testValueElementsRoundtripInt";
TestUtil.displayTestTile(TEST_NAME);
TestUtil.displayTestTitle(TEST_NAME);

// GIVEN
PrismContext prismContext = PrismTestUtil.getPrismContext();
Expand Down
Expand Up @@ -94,7 +94,7 @@ public void setup() throws SchemaException, SAXException, IOException {
@Test
public void test010ParseFromResourceComplex() throws Exception {
final String TEST_NAME = "test010ParseFromResourceComplex";
TestUtil.displayTestTile(TEST_NAME);
TestUtil.displayTestTitle(TEST_NAME);

// GIVEN
PrismContext prismContext = createInitializedPrismContext();
Expand Down Expand Up @@ -134,7 +134,7 @@ private void assertLayerRefinedSchema(ResourceType resourceType, RefinedResource
@Test
public void test020ParseFromResourceSimple() throws Exception {
final String TEST_NAME = "test020ParseFromResourceSimple";
TestUtil.displayTestTile(TEST_NAME);
TestUtil.displayTestTitle(TEST_NAME);

// GIVEN
PrismContext prismContext = createInitializedPrismContext();
Expand Down Expand Up @@ -290,7 +290,7 @@ private void assertRefinedToLayer(ResourceAttributeDefinition attrDef, LayerType
@Test
public void test100ParseAccount() throws Exception {
final String TEST_NAME = "test100ParseAccount";
TestUtil.displayTestTile(TEST_NAME);
TestUtil.displayTestTitle(TEST_NAME);

// GIVEN
PrismContext prismContext = createInitializedPrismContext();
Expand Down Expand Up @@ -325,7 +325,7 @@ public void test100ParseAccount() throws Exception {
@Test
public void test110ApplyAttributeDefinition() throws Exception {
final String TEST_NAME = "test110ApplyAttributeDefinition";
TestUtil.displayTestTile(TEST_NAME);
TestUtil.displayTestTitle(TEST_NAME);

// GIVEN
PrismContext prismContext = createInitializedPrismContext();
Expand Down Expand Up @@ -402,7 +402,7 @@ private QName getAttrQName(PrismObject<ResourceType> resource, String localPart)
@Test
public void test120CreateShadow() throws Exception {
final String TEST_NAME = "test120CreateShadow";
TestUtil.displayTestTile(TEST_NAME);
TestUtil.displayTestTitle(TEST_NAME);

// GIVEN
PrismContext prismContext = createInitializedPrismContext();
Expand Down Expand Up @@ -432,7 +432,7 @@ public void test120CreateShadow() throws Exception {
@Test
public void test130ProtectedAccount() throws Exception {
final String TEST_NAME = "test130ProtectedAccount";
TestUtil.displayTestTile(TEST_NAME);
TestUtil.displayTestTitle(TEST_NAME);

// GIVEN
PrismContext prismContext = createInitializedPrismContext();
Expand Down Expand Up @@ -559,7 +559,7 @@ private ResourceAttribute<String> createStringAttribute(QName attrName, String v
@Test
public void test140ParseFromResourcePosix() throws Exception {
final String TEST_NAME = "test140ParseFromResourcePosix";
TestUtil.displayTestTile(TEST_NAME);
TestUtil.displayTestTitle(TEST_NAME);

// GIVEN
PrismContext prismContext = createInitializedPrismContext();
Expand Down
Expand Up @@ -957,7 +957,7 @@ public void recordWarning(String message) {
public void record(CommonException exception) {
// TODO: switch to a localized message later
// Exception is a fatal error in this context
recordFatalError(exception.getOperationResultMessage(), exception);
recordFatalError(exception.getErrorTypeMessage(), exception);
}

public void recordStatus(OperationResultStatus status, String message) {
Expand Down
Expand Up @@ -15,6 +15,8 @@
*/
package com.evolveum.midpoint.schema.util;

import com.evolveum.midpoint.util.LocalizableMessage;
import com.evolveum.midpoint.util.exception.CommonException;
import com.evolveum.midpoint.util.exception.CommunicationException;
import com.evolveum.midpoint.util.exception.ConfigurationException;
import com.evolveum.midpoint.util.exception.ExpressionEvaluationException;
Expand Down Expand Up @@ -80,4 +82,17 @@ private static boolean isSelected(Boolean value, boolean defaultValue) {
}
}

public static LocalizableMessage getUserFriendlyMessage(Throwable cause) {
while (cause != null) {
if (cause instanceof CommonException) {
LocalizableMessage userFriendlyMessage = ((CommonException)cause).getUserFriendlyMessage();
if (userFriendlyMessage != null) {
return userFriendlyMessage;
}
}
cause = cause.getCause();
}
return null;
}

}
Expand Up @@ -4293,6 +4293,17 @@
point to object class definition (complex type definition in resource schema) and
this definition should be marked as auxiliary.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="tolerantAuxiliaryObjectClasses" type="xsd:boolean" minOccurs="0" maxOccurs="1" default="false">
<xsd:annotation>
<xsd:documentation>
If set to true then midPoitn will tolerate existing auxiliary object classes on resource
objects. MidPoitn will add/remove auxiliary object classes only if there is an explicit
operation for that (e.g. assign/unassign of role with auxiliary object class definition).
If set to false then midPoint will strictly synchronize auxiliary object classes of resource
objects with the definition given in midPoint configuration.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="baseContext" type="tns:ResourceObjectReferenceType" minOccurs="0">
Expand Down
Expand Up @@ -174,12 +174,12 @@ public static void assertExceptionSanity(ObjectAlreadyExistsException e) {
+e.getMessage().length()+" characters): "+e.getMessage();
}

public static void displayTestTile(String testName) {
public static void displayTestTitle(String testName) {
System.out.println(TEST_OUT_PREFIX + testName + TEST_OUT_SUFFIX);
LOGGER.info(TEST_LOG_PREFIX + testName + TEST_LOG_SUFFIX);
}

public static void displayTestTile(Object testCase, String testName) {
public static void displayTestTitle(Object testCase, String testName) {
System.out.println(TEST_OUT_PREFIX + testCase.getClass().getSimpleName() + "." + testName + TEST_OUT_SUFFIX);
LOGGER.info(TEST_LOG_PREFIX + testCase.getClass().getSimpleName() + "." + testName + TEST_LOG_SUFFIX);
}
Expand Down

0 comments on commit 87304d6

Please sign in to comment.