Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into hibernate_upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Jan 9, 2015
2 parents fcbe57b + 7351f06 commit 6bb46ac
Show file tree
Hide file tree
Showing 29 changed files with 736 additions and 125 deletions.
4 changes: 2 additions & 2 deletions build-system/pom.xml
Expand Up @@ -64,7 +64,7 @@
<cron4j.version>2.2.3</cron4j.version>
<hibernate.version>4.3.7.Final</hibernate.version>
<h2.version>1.3.171</h2.version>
<jdbc.postgres>9.1-901.jdbc4</jdbc.postgres>
<jdbc.postgres>9.3-1102-jdbc41</jdbc.postgres>
<jdbc.mysql>5.1.31</jdbc.mysql>
<wicket.version>6.17.0</wicket.version>
<groovy.version>1.8.6</groovy.version>
Expand Down Expand Up @@ -532,7 +532,7 @@
<version>${jdbc.mysql}</version>
</dependency>
<dependency>
<groupId>postgresql</groupId>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${jdbc.postgres}</version>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion gui/admin-gui/pom.xml
Expand Up @@ -208,7 +208,7 @@

<!-- JDBC DRIVERS -->
<dependency>
<groupId>postgresql</groupId>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>

Expand Down
Expand Up @@ -409,7 +409,6 @@ private SystemConfigurationType saveNotificationConfiguration(SystemConfiguratio
NotificationConfigurationDto dto;
NotificationConfigurationType notificationConfig;
MailConfigurationType mailConfig;
MailServerConfigurationType mailServerConfig;

if(systemConfigPanel != null && systemConfigPanel.getModel().getObject().getNotificationConfig() != null){
dto = systemConfigPanel.getModel().getObject().getNotificationConfig();
Expand Down Expand Up @@ -442,6 +441,8 @@ private SystemConfigurationType saveNotificationConfiguration(SystemConfiguratio
ProtectedStringType pass = new ProtectedStringType();
pass.setClearValue(serverDto.getPassword());
newConfig.setPassword(pass);
} else {
newConfig.setPassword(serverDto.getOldConfig().getPassword());
}

mailConfig.getServer().add(newConfig);
Expand Down
Expand Up @@ -25,7 +25,9 @@
import com.evolveum.midpoint.web.util.InfoTooltipBehavior;
import com.evolveum.midpoint.web.util.WebMiscUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.MailTransportSecurityType;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.form.AjaxFormSubmitBehavior;
import org.apache.wicket.ajax.form.OnChangeAjaxBehavior;
import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink;
import org.apache.wicket.behavior.AttributeAppender;
Expand Down Expand Up @@ -140,10 +142,29 @@ public String getIdValue(MailServerConfigurationTypeDto object, int index) {
}
});
mailServerConfigChooser.setNullValid(true);
mailServerConfigChooser.add(new AjaxFormSubmitBehavior("onclick"){

@Override
protected void onEvent(AjaxRequestTarget target) {
getForm().onFormSubmitted();
}
});
mailServerConfigChooser.add(new OnChangeAjaxBehavior() {

@Override
protected void onUpdate(AjaxRequestTarget target) {
PasswordTextField passwordField = (PasswordTextField)get(ID_MAIN_FORM + ":" + ID_MAIL_SERVER_CONFIG_CONTAINER + ":" + ID_PASSWORD);

if(getModelObject() != null){
if(getModelObject().getNotificationConfig().getSelectedServer() != null &&
getModelObject().getNotificationConfig().getSelectedServer().getPassword() != null){

passwordField.add(new AttributeModifier("placeholder", createStringResource("SystemConfigPanel.mail.password.placeholder.set")));
} else {
passwordField.add(new AttributeModifier("placeholder", createStringResource("SystemConfigPanel.mail.password.placeholder.empty")));
}
}

target.add(SystemConfigPanel.this);
}
});
Expand Down Expand Up @@ -175,16 +196,6 @@ public boolean isVisible() {
PasswordTextField passwordField = new PasswordTextField(ID_PASSWORD, new PropertyModel<String>(getModel(), "notificationConfig.selectedServer.password"));
passwordField.setRequired(false);

if(getModelObject() != null){
if(getModelObject().getNotificationConfig().getSelectedServer() != null &&
getModelObject().getNotificationConfig().getSelectedServer().getPassword() != null){

passwordField.add(new AttributeAppender("placeholder", createStringResource("SystemConfigPanel.mail.password.placeholder.set")));
} else {
passwordField.add(new AttributeAppender("placeholder", createStringResource("SystemConfigPanel.mail.password.placeholder.empty")));
}
}

TextField<String> redirectToFileField = new TextField<>(ID_REDIRECT_TO_FILE, new PropertyModel<String>(getModel(), "notificationConfig.redirectToFile"));

DropDownFormGroup transportSecurity = new DropDownFormGroup<>(ID_TRANSPORT_SECURITY, new PropertyModel<MailTransportSecurityType>(getModel(),
Expand Down
Expand Up @@ -32,6 +32,7 @@ public class MailServerConfigurationTypeDto implements Serializable {
public static final String F_PASSWORD = "password";
public static final String F_MAIL_TRANSPORT_SECURITY_TYPE = "mailTransportSecurityType";

private MailServerConfigurationType oldConfig;
private String host;
private Integer port;
private String username;
Expand All @@ -42,6 +43,7 @@ public MailServerConfigurationTypeDto(){}

public MailServerConfigurationTypeDto(MailServerConfigurationType config){

oldConfig = config;
host = config.getHost();
port = config.getPort();
username = config.getUsername();
Expand Down Expand Up @@ -95,15 +97,24 @@ public void setMailTransportSecurityType(MailTransportSecurityType mailTransport
this.mailTransportSecurityType = mailTransportSecurityType;
}

public MailServerConfigurationType getOldConfig() {
return oldConfig;
}

public void setOldConfig(MailServerConfigurationType oldConfig) {
this.oldConfig = oldConfig;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!(o instanceof MailServerConfigurationTypeDto)) return false;

MailServerConfigurationTypeDto that = (MailServerConfigurationTypeDto) o;

if (host != null ? !host.equals(that.host) : that.host != null) return false;
if (mailTransportSecurityType != that.mailTransportSecurityType) return false;
if (oldConfig != null ? !oldConfig.equals(that.oldConfig) : that.oldConfig != null) return false;
if (password != null ? !password.equals(that.password) : that.password != null) return false;
if (port != null ? !port.equals(that.port) : that.port != null) return false;
if (username != null ? !username.equals(that.username) : that.username != null) return false;
Expand All @@ -113,7 +124,8 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
int result = host != null ? host.hashCode() : 0;
int result = oldConfig != null ? oldConfig.hashCode() : 0;
result = 31 * result + (host != null ? host.hashCode() : 0);
result = 31 * result + (port != null ? port.hashCode() : 0);
result = 31 * result + (username != null ? username.hashCode() : 0);
result = 31 * result + (password != null ? password.hashCode() : 0);
Expand Down
Expand Up @@ -157,6 +157,8 @@ public abstract class SchemaConstants {
public static final String NS_MODEL_CHANNEL = NS_MODEL + "/channels-3";
public static final QName CHANNEL_WEB_SERVICE_QNAME = new QName(NS_MODEL_CHANNEL, "webService");
public static final String CHANNEL_WEB_SERVICE_URI = QNameUtil.qNameToUri(CHANNEL_WEB_SERVICE_QNAME);
public static final QName CHANNEL_OBJECT_IMPORT_QNAME = new QName(NS_MODEL_CHANNEL, "objectImport");
public static final String CHANNEL_OBJECT_IMPORT_URI = QNameUtil.qNameToUri(CHANNEL_OBJECT_IMPORT_QNAME);

public static final String NS_MODEL_SERVICE = NS_MODEL + "/service-3";

Expand Down
Expand Up @@ -18,6 +18,7 @@

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

import javax.xml.namespace.QName;
Expand Down Expand Up @@ -397,6 +398,33 @@ protected void copyValues(ResourceAttributeContainer clone) {
// Nothing to copy
}


@Override
public void checkConsistenceInternal(Itemable rootItem, boolean requireDefinitions, boolean prohibitRaw,
ConsistencyCheckScope scope) {
super.checkConsistenceInternal(rootItem, requireDefinitions, prohibitRaw, scope);
List<PrismContainerValue> values = getValues();
if (values == null) {
throw new IllegalStateException("Null values in ResourceAttributeContainer");
}
if (values.isEmpty()) {
return;
}
if (values.size() > 1) {
throw new IllegalStateException(values.size()+" values in ResourceAttributeContainer, expected just one");
}
PrismContainerValue value = values.get(0);
List<Item<?>> items = value.getItems();
if (items == null) {
return;
}
for (Item item: items) {
if (!(item instanceof ResourceAttribute)) {
throw new IllegalStateException("Found illegal item in ResourceAttributeContainer: "+item+" ("+item.getClass()+")");
}
}
}

/**
* Return a human readable name of this class suitable for logs.
*/
Expand Down
Expand Up @@ -174,6 +174,14 @@
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="keepMetadata" type="xsd:boolean" minOccurs="0" default="false">
<xsd:annotation>
<xsd:documentation>
If set to true then the importer will keep the metadata from the source file.
If set to false then the imported will re-generate metadata on each object.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>

Expand Down
Expand Up @@ -620,14 +620,17 @@ public static void assertAttribute(SearchResultEntry response, String name, Stri
for (String value: values) {
boolean found = false;
Iterator<AttributeValue> iterator = attribute.iterator();
List<String> attrVals = new ArrayList<String>();
while (iterator.hasNext()) {
AttributeValue attributeValue = iterator.next();
if (attributeValue.toString().equals(value)) {
String attrVal = attributeValue.toString();
attrVals.add(attrVal);
if (attrVal.equals(value)) {
found = true;
}
}
if (!found) {
AssertJUnit.fail("Attribute "+name+" does not contain value "+value);
AssertJUnit.fail("Attribute "+name+" does not contain value "+value+", it has values: "+attrVals);
}
}
}
Expand Down
Expand Up @@ -15,6 +15,7 @@
*/
package com.evolveum.midpoint.model.impl.importer;

import com.evolveum.midpoint.common.Clock;
import com.evolveum.midpoint.common.crypto.CryptoUtil;
import com.evolveum.midpoint.common.validator.EventHandler;
import com.evolveum.midpoint.common.validator.EventResult;
Expand All @@ -33,8 +34,10 @@
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.prism.query.QueryJaxbConvertor;
import com.evolveum.midpoint.prism.schema.PrismSchema;
import com.evolveum.midpoint.prism.xml.XmlTypeConverter;
import com.evolveum.midpoint.repo.api.RepoAddOptions;
import com.evolveum.midpoint.repo.api.RepositoryService;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.schema.result.OperationConstants;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.result.OperationResultStatus;
Expand Down Expand Up @@ -108,6 +111,8 @@ public class ObjectImporter {
private RepositoryService repository;
@Autowired(required = true)
private ModelService modelService;
@Autowired(required = true)
private Clock clock;

private Migrator migrator = new Migrator();

Expand Down Expand Up @@ -174,6 +179,17 @@ public <T extends Objectable> EventResult postMarshall(PrismObject<T> prismObjec
opResult.recordFatalError(e);
}
}

if (options == null || (options != null && !BooleanUtils.isTrue(options.isKeepMetadata()))) {
MetadataType metaData = new MetadataType();
String channel = SchemaConstants.CHANNEL_OBJECT_IMPORT_URI;
metaData.setCreateChannel(channel);
metaData.setCreateTimestamp(clock.currentTimeXMLGregorianCalendar());
if (task.getOwner() != null) {
metaData.setCreatorRef(ObjectTypeUtil.createObjectRef(task.getOwner()));
}
object.asObjectable().setMetadata(metaData);
}

objectResult.computeStatus();
if (!objectResult.isAcceptable()) {
Expand Down
Expand Up @@ -21,6 +21,7 @@
import static com.evolveum.midpoint.model.api.ProgressInformation.ActivityType.RESOURCE_OBJECT_OPERATION;
import static com.evolveum.midpoint.model.api.ProgressInformation.StateType.ENTERING;

import com.evolveum.midpoint.common.Clock;
import com.evolveum.midpoint.common.refinery.ResourceShadowDiscriminator;
import com.evolveum.midpoint.model.api.ModelAuthorizationAction;
import com.evolveum.midpoint.model.api.ModelExecuteOptions;
Expand Down Expand Up @@ -132,6 +133,9 @@ public class ChangeExecutor {
@Autowired(required = false)
private WorkflowManager workflowManager;

@Autowired(required = true)
private Clock clock;

private PrismObjectDefinition<UserType> userDefinition = null;
private PrismObjectDefinition<ShadowType> shadowDefinition = null;

Expand Down Expand Up @@ -232,7 +236,7 @@ public <O extends ObjectType> boolean executeChanges(LensContext<O> syncContext,

ObjectDelta<ShadowType> accDelta = accCtx.getExecutableDelta();
if (accCtx.getSynchronizationPolicyDecision() == SynchronizationPolicyDecision.BROKEN) {
if (syncContext.getFocusContext().getDelta() != null
if (syncContext.getFocusContext() != null && syncContext.getFocusContext().getDelta() != null
&& syncContext.getFocusContext().getDelta().isDelete()
&& syncContext.getOptions() != null
&& ModelExecuteOptions.isForce(syncContext.getOptions())) {
Expand Down Expand Up @@ -1036,7 +1040,7 @@ private <T extends ObjectType, F extends ObjectType> void applyMetadata(LensCont
MetadataType metaData = new MetadataType();
String channel = getChannel(context, task);
metaData.setCreateChannel(channel);
metaData.setCreateTimestamp(XmlTypeConverter.createXMLGregorianCalendar(System.currentTimeMillis()));
metaData.setCreateTimestamp(clock.currentTimeXMLGregorianCalendar());
if (task.getOwner() != null) {
metaData.setCreatorRef(ObjectTypeUtil.createObjectRef(task.getOwner()));
}
Expand Down
Expand Up @@ -51,6 +51,7 @@
import com.evolveum.midpoint.model.impl.lens.LensFocusContext;
import com.evolveum.midpoint.model.impl.lens.LensProjectionContext;
import com.evolveum.midpoint.model.impl.lens.LensUtil;
import com.evolveum.midpoint.prism.Containerable;
import com.evolveum.midpoint.prism.PrismContainer;
import com.evolveum.midpoint.prism.PrismContainerDefinition;
import com.evolveum.midpoint.prism.PrismContainerValue;
Expand Down Expand Up @@ -243,6 +244,7 @@ private <F extends FocusType> void processAssignmentsProjectionsWithFocus(LensCo
for (PrismContainerValue<AssignmentType> assignmentCVal : allAssignments) {
AssignmentType assignmentType = assignmentCVal.asContainerable();
PrismContainerValue<AssignmentType> assignmentCValOld = assignmentCVal;
PrismContainerValue<AssignmentType> assignmentCValNew = assignmentCVal;
ItemDeltaItem<PrismContainerValue<AssignmentType>> assignmentIdi = new ItemDeltaItem<>();
assignmentIdi.setItemOld(LensUtil.createAssignmentSingleValueContainerClone(assignmentType));

Expand All @@ -268,6 +270,8 @@ private <F extends FocusType> void processAssignmentsProjectionsWithFocus(LensCo
forceRecon = true;

isAssignmentChanged = true;
PrismContainer<AssignmentType> assContNew = focusContext.getObjectNew().findContainer(FocusType.F_ASSIGNMENT);
assignmentCValNew = assContNew.getValue(assignmentCVal.getId());
}
}

Expand Down Expand Up @@ -380,12 +384,13 @@ private <F extends FocusType> void processAssignmentsProjectionsWithFocus(LensCo
// of provisioning/deprovisioning of the projections. So check that explicitly. Other changes are
// not significant, i.e. reconciliation can handle them.
boolean isValidOld = LensUtil.isValid(assignmentCValOld.asContainerable(), now, activationComputer);
boolean isValid = LensUtil.isValid(assignmentType, now, activationComputer);
boolean isValid = LensUtil.isValid(assignmentCValNew.asContainerable(), now, activationComputer);
if (isValid == isValidOld) {
// No change in validity -> right to the zero set
// The change is not significant for assignment applicability. Recon will sort out the details.
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Processing changed assignment, minor change (add={}, delete={}, valid={}): {}", new Object[]{isAdd, isDelete, isValid, SchemaDebugUtil.prettyPrint(assignmentCVal)});
LOGGER.trace("Processing changed assignment, minor change (add={}, delete={}, valid={}): {}",
new Object[]{isAdd, isDelete, isValid, SchemaDebugUtil.prettyPrint(assignmentCVal)});
}
EvaluatedAssignment<F> evaluatedAssignment = evaluateAssignment(assignmentIdi, false, context, source, assignmentEvaluator, assignmentPlacementDesc, task, result);
if (evaluatedAssignment == null) {
Expand All @@ -395,7 +400,8 @@ private <F extends FocusType> void processAssignmentsProjectionsWithFocus(LensCo
} else if (isValid) {
// Assignment became valid. We need to place it in plus set to initiate provisioning
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Processing changed assignment, assignment becomes valid (add={}, delete={}): {}", new Object[]{isAdd, isDelete, SchemaDebugUtil.prettyPrint(assignmentCVal)});
LOGGER.trace("Processing changed assignment, assignment becomes valid (add={}, delete={}): {}",
new Object[]{isAdd, isDelete, SchemaDebugUtil.prettyPrint(assignmentCVal)});
}
EvaluatedAssignment<F> evaluatedAssignment = evaluateAssignment(assignmentIdi, false, context, source, assignmentEvaluator, assignmentPlacementDesc, task, result);
if (evaluatedAssignment == null) {
Expand All @@ -405,7 +411,8 @@ private <F extends FocusType> void processAssignmentsProjectionsWithFocus(LensCo
} else {
// Assignment became invalid. We need to place is in minus set to initiate deprovisioning
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Processing changed assignment, assignment becomes invalid (add={}, delete={}): {}", new Object[]{isAdd, isDelete, SchemaDebugUtil.prettyPrint(assignmentCVal)});
LOGGER.trace("Processing changed assignment, assignment becomes invalid (add={}, delete={}): {}",
new Object[]{isAdd, isDelete, SchemaDebugUtil.prettyPrint(assignmentCVal)});
}
EvaluatedAssignment<F> evaluatedAssignment = evaluateAssignment(assignmentIdi, false, context, source, assignmentEvaluator, assignmentPlacementDesc, task, result);
if (evaluatedAssignment == null) {
Expand Down

0 comments on commit 6bb46ac

Please sign in to comment.