summaryrefslogtreecommitdiff
path: root/source/com/c2kernel/lifecycle/instance/predefined/Import.java
blob: 36b7fc91951f0a633138c9ff1ac1f21a517bd1a7 (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/**************************************************************************
 * AddDomainPath
 *
 * Copyright (C) 2001 CERN - European Organization for Nuclear Research
 * All rights reserved.
 **************************************************************************/

package com.c2kernel.lifecycle.instance.predefined;

import com.c2kernel.common.*;
import com.c2kernel.lookup.AgentPath;
import com.c2kernel.utils.Logger;

/**************************************************************************
 *
 * $Revision: 1.21 $
 * $Date: 2005/06/02 12:17:22 $
 * 
 * Params: Schemaname_version:Viewpoint (optional), Outcome
 *
 * Copyright (C) 2003 CERN - European Organization for Nuclear Research
 * All rights reserved.
 **************************************************************************/
public class Import extends PredefinedStep
{
    public Import()
    {
        super();
    }

	//requestdata is xmlstring
    public void request( AgentPath agent, int transitionID, String requestData)
        throws AccessRightsException,
               InvalidTransitionException,
               InvalidDataException
    {
        Logger.msg(8,"Import::request()");

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

        checkAccessRights(agent);

        String[] params = getDataList(requestData);
        
       
        int split1 = params[0].indexOf('_');
        int split2 = params[0].indexOf(':');
        
        String schemaName = params[0].substring(0, split1);
        String viewpoint = "last";
        int schemaVersion;
        if (split2 > -1) {
            schemaVersion = Integer.parseInt(params[0].substring(split1+1, split2));
            viewpoint = params[0].substring(split2+1);
        }
        else
            schemaVersion = Integer.parseInt(params[0].substring(split1+1));
        
        // set type & ver
        getProperties().put("SchemaType", schemaName);
        getProperties().put("SchemaVersion", String.valueOf(schemaVersion));
        getProperties().put("Viewpoint", viewpoint);
        
        requestData = params[1];
        
        sendEventStoreOutcome(transitionID, requestData, agent);
    }
}