Skip to content

Commit

Permalink
Fixing provisioning test failures.
Browse files Browse the repository at this point in the history
Working around XMLGregorianCalendarImpl clone problem in some environments.
Started implementation of task state display (unfinished, uncompilable).
  • Loading branch information
mederly committed Sep 14, 2015
1 parent 7ec3e46 commit 04e6abe
Show file tree
Hide file tree
Showing 10 changed files with 258 additions and 76 deletions.
Expand Up @@ -142,7 +142,7 @@ <h2><wicket:message key="pageTaskEdit.scheduleTitle"/><br />
</tr>
</tbody>
<tbody>
<tr>
<tr> f
<td><wicket:message key="pageTaskEdit.notStartBefore"/></td>
<td><span wicket:id="notStartBeforeField" /></td>
</tr>
Expand Down Expand Up @@ -180,8 +180,8 @@ <h2><span wicket:id="workflowInformationLabel" /></h2>
<h2><span wicket:id="modelOperationStatusLabel" /></h2>
<div wicket:id="modelOperationStatusPanel"/>

<h2><wicket:message key="pageTaskEdit.opResult"/></h2>
<div wicket:id="operationResult"/>
<h2><wicket:message key="pageTaskEdit.taskState"/></h2>
<div wicket:id="taskStatePanel"/>

<div class="form-group">
<label class="col-lg-2 control-label"><wicket:message key="pageTaskEdit.options"/></label>
Expand Down
Expand Up @@ -57,6 +57,7 @@
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.midpoint.web.page.PageBase;
import com.evolveum.midpoint.web.page.PageTemplate;
import com.evolveum.midpoint.web.page.admin.server.currentState.TaskStatePanel;
import com.evolveum.midpoint.web.page.admin.server.dto.*;
import com.evolveum.midpoint.web.page.admin.server.subtasks.SubtasksPanel;
import com.evolveum.midpoint.web.page.admin.server.workflowInformation.WorkflowInformationPanel;
Expand Down Expand Up @@ -126,6 +127,7 @@ public class PageTaskEdit extends PageAdminTasks {
private static final String ID_SUBTASKS_PANEL = "subtasksPanel";
private static final String ID_WORKFLOW_INFORMATION_LABEL = "workflowInformationLabel";
private static final String ID_WORKFLOW_INFORMATION_PANEL = "workflowInformationPanel";
private static final String ID_TASK_STATE_PANEL = "taskStatePanel";
private static final String ID_NAME = "name";
private static final String ID_NAME_LABEL = "nameLabel";
private static final String ID_DESCRIPTION = "description";
Expand Down Expand Up @@ -287,14 +289,9 @@ public boolean isVisible() {
panel.add(modelOpBehaviour);
mainForm.add(panel);

SortableDataProvider<OperationResult, String> provider = new ListDataProvider<>(this,
new PropertyModel<List<OperationResult>>(model, "opResult"));
TablePanel result = new TablePanel<>("operationResult", provider, initResultColumns());
result.setStyle("padding-top: 0px;");
result.setShowPaging(false);
result.setOutputMarkupId(true);
result.add(hiddenWhenEditing);
mainForm.add(result);
TaskStatePanel taskStatePanel = new TaskStatePanel(ID_TASK_STATE_PANEL, model);
taskStatePanel.add(hiddenWhenEditing);
mainForm.add(taskStatePanel);

DropDownChoice threadStop = new DropDownChoice<>("threadStop", new Model<ThreadStopActionType>() {

Expand Down
Expand Up @@ -55,7 +55,7 @@ pageTaskEdit.tightlyBound=Tightly bound
pageTaskEdit.runUntilNodeDown=Run only until node down
pageTaskEdit.threadStop=Thread stop action

pageTaskEdit.opResult=Operation result
pageTaskEdit.taskState=Task state

pageTaskEdit.modelOperationStatusLabel=Model operation status
pageTaskEdit.subtasksLabel=Subtasks
Expand Down
@@ -0,0 +1,26 @@
<!--
~ Copyright (c) 2010-2015 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.
-->

<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>


<h3><wicket:message key="TaskStatePanel.opResult"/></h3>
<div wicket:id="operationResult"/>

</wicket:panel>
</html>
@@ -0,0 +1,80 @@
/*
* Copyright (c) 2010-2015 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.web.page.admin.server.currentState;

import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.web.component.data.TablePanel;
import com.evolveum.midpoint.web.component.data.column.LinkPanel;
import com.evolveum.midpoint.web.component.util.ListDataProvider;
import com.evolveum.midpoint.web.component.util.SimplePanel;
import com.evolveum.midpoint.web.component.wf.WfDeltasPanel;
import com.evolveum.midpoint.web.component.wf.WfHistoryEventDto;
import com.evolveum.midpoint.web.component.wf.WfHistoryPanel;
import com.evolveum.midpoint.web.page.PageBase;
import com.evolveum.midpoint.web.page.admin.server.dto.TaskDto;
import com.evolveum.midpoint.web.page.admin.workflow.PageProcessInstance;
import com.evolveum.midpoint.web.util.OnePageParameterEncoder;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.model.StringResourceModel;
import org.apache.wicket.request.mapper.parameter.PageParameters;

import java.util.List;

/**
* @author mederly
*/
public class TaskStatePanel extends SimplePanel<TaskDto> {

private static final String ID_DELTAS_PANEL = "deltasPanel";
private static final String ID_HISTORY_PANEL = "historyPanel";
private static final String ID_PAGE_PROCESS_INSTANCE_LINK = "pageProcessInstanceLink";

public TaskStatePanel(String id, IModel<TaskDto> model) {
super(id, model);
}

@Override
protected void initLayout() {

SortableDataProvider<OperationResult, String> provider = new ListDataProvider<>(this,
new PropertyModel<List<OperationResult>>(model, "opResult"));
TablePanel result = new TablePanel<>("operationResult", provider, initResultColumns());
result.setStyle("padding-top: 0px;");
result.setShowPaging(false);
result.setOutputMarkupId(true);
result.add(hiddenWhenEditing);
mainForm.add(result);

add(new LinkPanel(ID_PAGE_PROCESS_INSTANCE_LINK, new StringResourceModel("WorkflowInformationPanel.link.processInstance", getModel())) {
@Override
public void onClick(AjaxRequestTarget target) {
String pid = TaskStatePanel.this.getModel().getObject().getWorkflowProcessInstanceId();
boolean finished = TaskStatePanel.this.getModel().getObject().isWorkflowProcessInstanceFinished();
PageParameters parameters = new PageParameters();
parameters.add(OnePageParameterEncoder.PARAMETER, pid);
parameters.add(PageProcessInstance.PARAM_PROCESS_INSTANCE_FINISHED, finished);
TaskStatePanel.this.setResponsePage(new PageProcessInstance(parameters, (PageBase) TaskStatePanel.this.getPage()));
}
});

add(new WfDeltasPanel(ID_DELTAS_PANEL, getModel()));
add(new WfHistoryPanel(ID_HISTORY_PANEL, new PropertyModel<List<WfHistoryEventDto>>(getModel(), TaskDto.F_WORKFLOW_HISTORY)));
}
}
@@ -0,0 +1,18 @@
#
# Copyright (c) 2010-2015 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.
#


TaskStatePanel.opResult=Operation result
Expand Up @@ -23,6 +23,7 @@
import java.util.Collection;
import java.util.List;

import com.evolveum.midpoint.prism.xml.XmlTypeConverter;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import org.apache.commons.lang.SerializationUtils;
Expand All @@ -37,6 +38,7 @@
import com.evolveum.prism.xml.ns._public.types_3.RawType;
import org.springframework.util.ClassUtils;

import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.namespace.QName;

/**
Expand Down Expand Up @@ -98,6 +100,15 @@ public static <T> T clone(T orig) {
if (orig instanceof Definition) {
return (T) ((Definition)orig).clone();
}
/*
* In some environments we cannot clone XMLGregorianCalendar because of this:
* Error when cloning class org.apache.xerces.jaxp.datatype.XMLGregorianCalendarImpl, will try serialization instead.
* java.lang.IllegalAccessException: Class com.evolveum.midpoint.prism.util.CloneUtil can not access a member of
* class org.apache.xerces.jaxp.datatype.XMLGregorianCalendarImpl with modifiers "public"
*/
if (orig instanceof XMLGregorianCalendar) {
return (T) XmlTypeConverter.createXMLGregorianCalendar((XMLGregorianCalendar) orig);
}
if (orig instanceof Cloneable) {
T clone = javaLangClone(orig);
if (clone != null) {
Expand Down
Expand Up @@ -463,6 +463,14 @@ public static XMLGregorianCalendar createXMLGregorianCalendar(String string) {
public static XMLGregorianCalendar createXMLGregorianCalendar(GregorianCalendar cal) {
return getDatatypeFactory().newXMLGregorianCalendar(cal);
}

// in some environments, XMLGregorianCalendar.clone does not work
public static XMLGregorianCalendar createXMLGregorianCalendar(XMLGregorianCalendar cal) {
if (cal == null) {
return null;
}
return getDatatypeFactory().newXMLGregorianCalendar(cal.toGregorianCalendar()); // TODO find a better way
}

public static XMLGregorianCalendar createXMLGregorianCalendar(int year, int month, int day, int hour, int minute,
int second, int millisecond, int timezone) {
Expand Down
Expand Up @@ -23,6 +23,7 @@
import com.evolveum.midpoint.util.logging.TraceManager;
import org.identityconnectors.framework.common.objects.Uid;

import javax.xml.namespace.QName;
import java.util.Date;

/**
Expand Down Expand Up @@ -83,11 +84,7 @@ public void recordIcfOperationStart(ProvisioningOperation operation, ObjectClass
if (uid != null) {
object = " " + uid.getUidValue();
}
recordState("Starting " + operation + " of " + objectClassDef.getTypeName().getLocalPart() + object + " on " + getResourceName());
}

public void recordIcfOperationStart(ProvisioningOperation operation, ObjectClassComplexTypeDefinition objectClassDefinition) {
recordIcfOperationStart(operation, objectClassDefinition, null);
recordState("Starting " + operation + " of " + getObjectClassName(objectClassDef) + object + " on " + getResourceName());
}

// we just add duration, not count (we'll do this on end)
Expand Down Expand Up @@ -118,14 +115,22 @@ public void recordIcfOperationResume(ProvisioningOperation operation, ObjectClas
recordState("Continuing " + operation + " of " + objectClassDef.getTypeName().getLocalPart() + " on " + getResourceName());
}

private String getObjectClassName(ObjectClassComplexTypeDefinition objectClassDef) {
return objectClassDef != null && objectClassDef.getTypeName() != null ? objectClassDef.getTypeName().getLocalPart() : "(null)";
}

private QName getObjectClassQName(ObjectClassComplexTypeDefinition objectClassDef) {
return objectClassDef != null ? objectClassDef.getTypeName() : null;
}

public void recordIcfOperationEnd(ProvisioningOperation operation, ObjectClassComplexTypeDefinition objectClassDef, Throwable ex, Uid uid) {
long duration = -1L;
if (lastOperation != operation) {
LOGGER.warn("Finishing operation other than current: finishing {}, last recorded {}",
operation, lastOperation);
} else if (lastObjectClass == null || !lastObjectClass.getTypeName().equals(objectClassDef.getTypeName())) {
} else if (objectClassDef != null && (lastObjectClass == null || !lastObjectClass.getTypeName().equals(objectClassDef.getTypeName()))) {
LOGGER.warn("Finishing operation on object class other than current: finishing on {}, last recorded {}",
objectClassDef.getTypeName(), lastObjectClass != null ? lastObjectClass.getTypeName() : "(null)");
getObjectClassName(objectClassDef), getObjectClassName(lastObjectClass));
} else {
duration = System.currentTimeMillis() - lastStarted.getTime();
}
Expand All @@ -146,25 +151,13 @@ public void recordIcfOperationEnd(ProvisioningOperation operation, ObjectClassCo
if (uid != null) {
object = " " + uid.getUidValue();
}
recordState(finished + " " + operation + " of " + objectClassDef.getTypeName().getLocalPart() + object + " on " + getResourceName() + durationString);
recordState(finished + " " + operation + " of " + getObjectClassName(objectClassDef) + object + " on " + getResourceName() + durationString);
if (task != null && duration >= 0) {
task.recordProvisioningOperation(resourceOid, getResourceName(), objectClassDef.getTypeName(), lastOperation, ex == null, 1, duration);
task.recordProvisioningOperation(resourceOid, getResourceName(), getObjectClassQName(objectClassDef), lastOperation, ex == null, 1, duration);
}
lastOperation = null;
}

public void recordIcfOperationEnd(ProvisioningOperation operation, ObjectClassComplexTypeDefinition objectClassDef, Uid uid) {
recordIcfOperationEnd(operation, objectClassDef, null, uid);
}

public void recordIcfOperationEnd(ProvisioningOperation operation, ObjectClassComplexTypeDefinition objectClassDefinition) {
recordIcfOperationEnd(operation, objectClassDefinition, null, null);
}

public void recordIcfOperationEnd(ProvisioningOperation operation, ObjectClassComplexTypeDefinition objectClassDef, Throwable ex) {
recordIcfOperationEnd(operation, objectClassDef, ex, null);
}

private void recordState(String message) {
if (task != null) {
task.recordState(message);
Expand Down

0 comments on commit 04e6abe

Please sign in to comment.