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
Conflicts:
	gui/admin-gui/src/main/resources/localization/Midpoint.properties
  • Loading branch information
katkav committed Aug 22, 2017
2 parents 8d20963 + b3fe837 commit 5c45a69
Show file tree
Hide file tree
Showing 258 changed files with 9,858 additions and 3,274 deletions.
9 changes: 7 additions & 2 deletions build-system/pom.xml
Expand Up @@ -74,7 +74,7 @@
<jdbc.postgres>9.4.1212.jre7</jdbc.postgres>
<jdbc.mariadb>1.5.5</jdbc.mariadb>
<jdbc.mysql>6.0.5</jdbc.mysql>
<wicket.version>7.6.0</wicket.version>
<wicket.version>7.9.0-SNAPSHOT</wicket.version>
<groovy.version>2.4.0</groovy.version>
<activiti-engine.version>5.22.0</activiti-engine.version>
<activiti-spring.version>5.22.0</activiti-spring.version>
Expand All @@ -84,7 +84,7 @@
<jasper.version>6.4.1</jasper.version>
<derby.version>10.11.1.1</derby.version>
<wro4j.version>1.8.0</wro4j.version>
<jackson.version>2.8.6</jackson.version>
<jackson.version>2.8.9</jackson.version>
<snakeyaml.version>1.15</snakeyaml.version>
<surefire.version>2.20</surefire.version>
</properties>
Expand Down Expand Up @@ -272,6 +272,11 @@
<artifactId>stax-api</artifactId>
<version>1.0-2</version>
</dependency>
<dependency>
<groupId>org.codehaus.staxmate</groupId>
<artifactId>staxmate</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>stax</groupId>
<artifactId>stax-api</artifactId>
Expand Down
Expand Up @@ -39,6 +39,7 @@
import java.io.StringWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -100,23 +101,23 @@ public static OpResult getOpResult(PageBase page, OperationResult result){
}

if (result.getParams() != null) {
for (Map.Entry<String, Serializable> entry : result.getParams().entrySet()) {
for (Map.Entry<String, Collection<String>> entry : result.getParams().entrySet()) {
String paramValue = null;
Object value = entry.getValue();
if (value != null) {
paramValue = value.toString();
Collection<String> values = entry.getValue();
if (values != null) {
paramValue = values.toString();
}

opResult.getParams().add(new Param(entry.getKey(), paramValue));
}
}

if(result.getContext() != null){
for (Map.Entry<String, Serializable> entry : result.getContext().entrySet()) {
for (Map.Entry<String, Collection<String>> entry : result.getContext().entrySet()) {
String contextValue = null;
Object value = entry.getValue();
if (value != null) {
contextValue = value.toString();
Collection<String> values = entry.getValue();
if (values != null) {
contextValue = values.toString();
}

opResult.getContexts().add(new Context(entry.getKey(), contextValue));
Expand Down
Expand Up @@ -1079,25 +1079,29 @@ public RestartResponseException getRestartResponseException(Class<? extends Page
}

// TODO untangle this brutal code (list vs objectable vs other cases)
public <T> void validateObject(String lexicalRepresentation, final Holder<T> objectHolder,
String language, boolean validateSchema, Class<T> clazz, OperationResult result) {
public <T> void parseObject(String lexicalRepresentation, final Holder<T> objectHolder,
String language, boolean validateSchema, boolean skipChecks, Class<T> clazz, OperationResult result) {

boolean isListOfObjects = List.class.isAssignableFrom(clazz);
boolean isObjectable = Objectable.class.isAssignableFrom(clazz);
if (language == null || PrismContext.LANG_JSON.equals(language) || PrismContext.LANG_YAML.equals(language)
if (skipChecks || language == null || PrismContext.LANG_JSON.equals(language) || PrismContext.LANG_YAML.equals(language)
|| (!isObjectable && !isListOfObjects)) {
T object;
try {
if (isListOfObjects) {
List<PrismObject<? extends Objectable>> prismObjects = getPrismContext().parserFor(lexicalRepresentation)
.language(language).parseObjects();
for (PrismObject<? extends Objectable> prismObject : prismObjects) {
prismObject.checkConsistence();
if (!skipChecks) {
for (PrismObject<? extends Objectable> prismObject : prismObjects) {
prismObject.checkConsistence();
}
}
object = (T) prismObjects;
} else if (isObjectable) {
PrismObject<ObjectType> prismObject = getPrismContext().parserFor(lexicalRepresentation).language(language).parse();
prismObject.checkConsistence();
if (!skipChecks) {
prismObject.checkConsistence();
}
object = (T) prismObject.asObjectable();
} else {
object = getPrismContext().parserFor(lexicalRepresentation).language(language).type(clazz).parseRealValue();
Expand Down
Expand Up @@ -1100,8 +1100,10 @@ public static boolean isSuccessOrHandledError(OperationResult result) {
}

public static boolean isSuccessOrHandledError(OperationResultType resultType) {
OperationResult result = OperationResult.createOperationResult(resultType);
return isSuccessOrHandledError(result);
if (resultType == null) {
return false;
}
return resultType.getStatus() == OperationResultStatusType.SUCCESS || resultType.getStatus() == OperationResultStatusType.HANDLED_ERROR;
}

public static boolean isSuccessOrHandledErrorOrWarning(OperationResult result) {
Expand Down
Expand Up @@ -256,11 +256,21 @@ public String load() {
if(config != null){
ObjectReferenceType ref = config.getTemplateRef();

if(ref != null){
sb.append(WebComponentUtil.getOrigStringFromPoly(ref.getTargetName())).append(": ");
if (ref != null) {
sb.append(WebComponentUtil.getOrigStringFromPoly(ref.getTargetName()));
}

if(config.getType() != null){
if (config.getConflictResolution() != null) {
if (sb.length() > 0) {
sb.append(" ");
}
sb.append(getString("ObjectPolicyConfigurationEditor.conflictResolution"));
}

if(config.getType() != null) {
if (sb.length() > 0) {
sb.append(": ");
}
sb.append(config.getType().getLocalPart());
}

Expand Down
Expand Up @@ -39,6 +39,8 @@
import com.evolveum.midpoint.schema.SelectorOptions;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.exception.SystemException;
import com.evolveum.midpoint.util.logging.LoggingUtils;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
Expand Down Expand Up @@ -209,11 +211,15 @@ protected Iterator<SelectableBean<O>> handleNotSuccessOrHandledErrorInIterator(O

public SelectableBean<O> createDataObjectWrapper(O obj) {
SelectableBean<O> selectable = new SelectableBean<O>(obj);
if (!WebComponentUtil.isSuccessOrHandledError(obj.getFetchResult())){
selectable.setResult(obj.getFetchResult());
if (!WebComponentUtil.isSuccessOrHandledError(obj.getFetchResult())) {
try {
selectable.setResult(obj.getFetchResult());
} catch (SchemaException e) {
throw new SystemException(e.getMessage(), e);
}
}
for (O s : selected){
if (s.getOid().equals(obj.getOid())){
if (s.getOid().equals(obj.getOid())) {
selectable.setSelected(true);
}
}
Expand Down
Expand Up @@ -20,7 +20,7 @@
import com.evolveum.midpoint.prism.Objectable;
import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.prism.PrismSerializer;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.util.Holder;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -76,23 +76,27 @@ protected void onStateChanged(int updatedIndex, AjaxRequestTarget target) {
return;
}

OperationResult result = new OperationResult(DataLanguagePanel.class.getName() + ".validateObject");
OperationResult result = new OperationResult(DataLanguagePanel.class.getName() + ".parseObject");
Holder<T> objectHolder = new Holder<>(null);

try {
pageBase.validateObject(currentObjectString, objectHolder, LANGUAGES.get(currentLanguageIndex), isValidateSchema(), dataType, result);
pageBase.parseObject(currentObjectString, objectHolder, LANGUAGES.get(currentLanguageIndex), false, true, dataType, result);
if (result.isAcceptable()) {
Object updatedObject = objectHolder.getValue();
String updatedObjectString;
PrismSerializer<String> serializer = pageBase.getPrismContext().serializerFor(updatedLanguage);
if (List.class.isAssignableFrom(dataType)) {
updatedObjectString = pageBase.getPrismContext().serializerFor(updatedLanguage)
.serializeObjects((List<PrismObject<?>>) updatedObject, SchemaConstants.C_OBJECTS);
@SuppressWarnings({ "unchecked", "raw" })
List<PrismObject<?>> list = (List<PrismObject<?>>) updatedObject;
if (list.size() != 1) {
updatedObjectString = serializer.serializeObjects(list, null);
} else {
updatedObjectString = serializer.serialize(list.get(0));
}
} else if (Objectable.class.isAssignableFrom(dataType)) {
updatedObjectString = pageBase.getPrismContext().serializerFor(updatedLanguage)
.serialize(((Objectable) updatedObject).asPrismObject());
updatedObjectString = serializer.serialize(((Objectable) updatedObject).asPrismObject());
} else {
updatedObjectString = pageBase.getPrismContext().serializerFor(updatedLanguage)
.serializeRealValue(updatedObject);
updatedObjectString = serializer.serializeRealValue(updatedObject);
}
processLanguageSwitch(target, updatedIndex, updatedLanguage, updatedObjectString);
} else {
Expand Down
Expand Up @@ -25,6 +25,7 @@
import com.evolveum.midpoint.schema.util.MiscSchemaUtil;
import com.evolveum.midpoint.util.DebugDumpable;
import com.evolveum.midpoint.util.DebugUtil;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.data.column.InlineMenuable;
Expand Down Expand Up @@ -77,7 +78,7 @@ public void setResult(OperationResult result) {
this.result = result;
}

public void setResult(OperationResultType resultType) {
public void setResult(OperationResultType resultType) throws SchemaException {
this.result = OperationResult.createOperationResult(resultType);
}

Expand Down
Expand Up @@ -142,7 +142,7 @@ private void startPerformed(AjaxRequestTarget target) {
getScriptingService().evaluateExpression((ScriptingExpressionType) parsed, task, result);
result.recordStatus(OperationResultStatus.SUCCESS, "Action executed. Returned " + executionResult.getDataOutput().size() + " item(s). Console and data output available via 'Export to XML' function.");
result.addReturn("console", executionResult.getConsoleOutput());
result.addCollectionOfSerializablesAsReturn("data", executionResult.getDataOutput());
result.addArbitraryObjectCollectionAsReturn("data", executionResult.getDataOutput());
} catch (ScriptExecutionException|SchemaException|SecurityViolationException e) {
result.recordFatalError("Couldn't execute bulk action", e);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't execute bulk action", e);
Expand Down
Expand Up @@ -410,6 +410,6 @@ public void savePerformed(AjaxRequestTarget target) {
}

private void validateObject(OperationResult result, Holder<Objectable> objectHolder) {
validateObject(objectViewDto.getXml(), objectHolder, dataLanguage, validateSchema.getObject(), Objectable.class, result);
parseObject(objectViewDto.getXml(), objectHolder, dataLanguage, validateSchema.getObject(), false, Objectable.class, result);
}
}
Expand Up @@ -92,13 +92,13 @@ public class PageImportObject extends PageAdminConfiguration {
private static final Integer INPUT_FILE = 1;
private static final Integer INPUT_XML = 2;

private LoadableModel<ImportOptionsType> model;
private LoadableModel<ImportOptionsType> optionsModel;
private IModel<String> xmlEditorModel;

private String dataLanguage;

public PageImportObject() {
model = new LoadableModel<ImportOptionsType>(false) {
optionsModel = new LoadableModel<ImportOptionsType>(false) {

@Override
protected ImportOptionsType load() {
Expand All @@ -114,7 +114,7 @@ private void initLayout() {
Form mainForm = new Form(ID_MAIN_FORM);
add(mainForm);

ImportOptionsPanel importOptions = new ImportOptionsPanel(ID_IMPORT_OPTIONS, model);
ImportOptionsPanel importOptions = new ImportOptionsPanel(ID_IMPORT_OPTIONS, optionsModel);
mainForm.add(importOptions);

final WebMarkupContainer input = new WebMarkupContainer(ID_INPUT);
Expand Down Expand Up @@ -336,7 +336,7 @@ private void savePerformed(boolean raw, String operationName, AjaxRequestTarget
Task task = createSimpleTask(operationName);
InputDescription inputDescription = getInputDescription(raw);
stream = inputDescription.inputStream;
getModelService().importObjectsFromStream(stream, inputDescription.dataLanguage, model.getObject(), task, result);
getModelService().importObjectsFromStream(stream, inputDescription.dataLanguage, optionsModel.getObject(), task, result);

result.recomputeStatus();
} catch (Exception ex) {
Expand Down
Expand Up @@ -341,6 +341,7 @@ private void saveObjectPolicies(SystemConfigurationType systemConfig) {
}

newObjectPolicyConfig.getPropertyConstraint().addAll(constraintList);
newObjectPolicyConfig.setConflictResolution(o.getConflictResolution());

confList.add(newObjectPolicyConfig);
}
Expand Down
Expand Up @@ -54,28 +54,22 @@
</label>
<label class="col-lg-2 checkbox-inline">
<input wicket:id="validateDynamicSchema" type="checkbox" name="optionsRadios" checked>
<wicket:message key="importOptionsPanel.validateDynamicSchema"/>*
<wicket:message key="importOptionsPanel.validateDynamicSchema"/>
</label>
<label class="col-lg-2 checkbox-inline">
<input wicket:id="validateStaticSchema" type="checkbox" name="optionsRadios" checked>
<wicket:message key="importOptionsPanel.validateStaticSchema"/>*
<wicket:message key="importOptionsPanel.validateStaticSchema"/>
</label>
</div>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label"><wicket:message key="importOptionsPanel.stopAfter"/>*</label>
<label class="col-lg-2 control-label"><wicket:message key="importOptionsPanel.stopAfter"/></label>

<div class="col-lg-1">
<input wicket:id="errors" wicket:message="placeholder:ImportOptionsPanel.errorCount" type="text"
class="form-control input-sm">
</div>
</div>
<div>
<label class="col-lg-2"></label>
<label class="col-lg-10" style="font-weight: normal">
<wicket:message key="importOptionsPanel.note"/>
</label>
</div>
</wicket:panel>
</html>
Expand Up @@ -32,6 +32,15 @@

<div class="form-group" wicket:id="objectTemplate" />

<div class="form-group" wicket:id="conflictResolutionContainer">
<label class="col-md-4 control-label">
<wicket:message key="ObjectPolicyDialog.conflictResolution" />
</label>
<div class="col-md-8">
<wicket:message key="ObjectPolicyDialog.present" />
</div>
</div>

<div class="form-group">
<label class="col-md-4 control-label">
<wicket:message key="ObjectPolicyDialog.propertyConstraint" />
Expand Down
Expand Up @@ -93,6 +93,7 @@ public class ObjectPolicyPanel extends BasePanel<ObjectPolicyDialogDto> implemen
private static final String ID_BUTTON_GROUP = "buttonGroup";
private static final String ID_BUTTON_REMOVE = "remove";
private static final String ID_BUTTON_ADD = "add";
private static final String ID_CONFLICT_RESOLUTION_CONTAINER = "conflictResolutionContainer";

private static final String ID_LABEL_SIZE = "col-md-4";
private static final String ID_INPUT_SIZE = "col-md-8";
Expand All @@ -114,7 +115,7 @@ protected ObjectPolicyDialogDto load() {
}
};

initLayout();
initLayout(config);

setOutputMarkupId(true);
// setTitle(createStringResource("ObjectPolicyDialog.label"));
Expand Down Expand Up @@ -154,7 +155,7 @@ public StringResourceModel createStringResource(String resourceKey, Object... ob
// target.add(getContent());
// }

public void initLayout() {
public void initLayout(ObjectPolicyConfigurationTypeDto config) {
Form form = new Form(ID_FORM);
form.setOutputMarkupId(true);
add(form);
Expand All @@ -164,8 +165,8 @@ public void initLayout() {
new QNameChoiceRenderer(), createStringResource("ObjectPolicyDialog.type"), ID_LABEL_SIZE,
ID_INPUT_SIZE, false);
form.add(type);
type.getInput().setNullValid(false);
type.getInput().setRequired(true);
type.getInput().setNullValid(config.getConflictResolution() != null);
type.getInput().setRequired(config.getConflictResolution() == null); // traditional template entries still require object type

TextField<String> fieldSubtype = new TextField<>(ID_SUBTYPE, new PropertyModel<String>(model, ObjectPolicyDialogDto.F_SUBTYPE));
form.add(fieldSubtype);
Expand All @@ -176,8 +177,12 @@ public void initLayout() {
createObjectTemplateList(), new ChoiceableChoiceRenderer<ObjectTemplateConfigTypeReferenceDto>(),
createStringResource("ObjectPolicyDialog.template"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
form.add(template);
template.getInput().setNullValid(false);
template.getInput().setRequired(true);
template.getInput().setNullValid(config.getConflictResolution() != null);
template.getInput().setRequired(config.getConflictResolution() == null);

WebMarkupContainer conflictResolutionContainer = new WebMarkupContainer(ID_CONFLICT_RESOLUTION_CONTAINER);
conflictResolutionContainer.setVisible(config.getConflictResolution() != null);
form.add(conflictResolutionContainer);

ListView repeater = new ListView<PropertyConstraintTypeDto>(ID_REPEATER,
new PropertyModel<List<PropertyConstraintTypeDto>>(model, ObjectPolicyDialogDto.F_PROPERTY_LIST)) {
Expand Down

0 comments on commit 5c45a69

Please sign in to comment.