summaryrefslogtreecommitdiff
path: root/source/com/c2kernel/lifecycle/instance/predefined/ReplaceDomainWorkflow.java
blob: e8c6a6f32a0283072ee631a4954b82195328d785 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package com.c2kernel.lifecycle.instance.predefined;

//Java
import java.awt.Point;

import com.c2kernel.common.AccessRightsException;
import com.c2kernel.common.InvalidDataException;
import com.c2kernel.common.InvalidTransitionException;
import com.c2kernel.lifecycle.instance.CompositeActivity;
import com.c2kernel.lifecycle.instance.Workflow;
import com.c2kernel.lookup.AgentPath;
import com.c2kernel.process.Gateway;
import com.c2kernel.utils.CastorXMLUtility;
import com.c2kernel.utils.Logger;

public class ReplaceDomainWorkflow extends PredefinedStep
{
	public ReplaceDomainWorkflow()
	{
		super();
	}

	public void request( AgentPath agent, int transitionID, String requestData)
		throws AccessRightsException, InvalidTransitionException, InvalidDataException
	{
		Workflow lifeCycle = getWf();

		Logger.msg(1, "ReplaceDomainWorkflow::request() - Starting ");

		checkAccessRights(agent);

		try
		{

			Logger.msg(8, "ReplaceDomainWorkflow::request() - data:" + getDataList(requestData)[0]);
			lifeCycle.getChildGraphModel().removeVertex(lifeCycle.search("workflow/domain"));
			CompositeActivity domain = (CompositeActivity) CastorXMLUtility.unmarshall(getDataList(requestData)[0]);
			lifeCycle.initChild(domain, true, new Point(150, 100));
			Gateway.getStorage().put(getItemEntityPath().getSysKey(), lifeCycle, null);
			Logger.msg(1, "ReplaceDomainWorkflow::request() - DONE.");
			sendEventStoreOutcome(transitionID, requestData, agent);
            // refresh jobs
            lifeCycle.refreshJobs();
		}
		catch (Exception ex)
		{
			Logger.error("ReplaceDomainWorkflow::request() - during unmarshall.");
			Logger.error(ex);
			throw new InvalidDataException("ReplaceDomainWorkflow::request() - during unmarshall.", null);
		}
	}
}