summaryrefslogtreecommitdiff
path: root/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/CreateNewItem.java
blob: 49f8adabb30df75dde3d24655da8fa4e90a7966e (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
/**************************************************************************
 * CreateNewItem
 *
 * Copyright (C) 2005 CERN - European Organization for Nuclear Research
 * All rights reserved.
 **************************************************************************/

package com.c2kernel.lifecycle.instance.predefined.entitycreation;




import com.c2kernel.common.AccessRightsException;
import com.c2kernel.common.InvalidDataException;
import com.c2kernel.common.InvalidTransitionException;
import com.c2kernel.lifecycle.instance.predefined.PredefinedStep;
import com.c2kernel.lookup.AgentPath;
import com.c2kernel.utils.CastorXMLUtility;
import com.c2kernel.utils.Logger;

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

	//requestdata is xmlstring
    public void request( AgentPath agent, int transitionID, String requestData)
        throws AccessRightsException,
               InvalidTransitionException,
               InvalidDataException
    {
        checkAccessRights(agent);

        try {
            NewItem item = (NewItem)CastorXMLUtility.unmarshall(requestData);
            item.create(agent.getSysKey());
        } catch (Exception ex) {
            Logger.error(ex);
            throw new InvalidDataException("Error creating item", "");
        }
        sendEventStoreOutcome(transitionID, requestData, agent);
    }
}