KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > rm > commands > CmdGetPendingVersions


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * See the License for the specific language governing rights and
10  * limitations under the License.
11  *
12  * The Initial Developer of the Original Code is Simulacra Media Ltd.
13  * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14  *
15  * All Rights Reserved.
16  *
17  * Contributor(s):
18  */

19 package org.openharmonise.rm.commands;
20
21 import org.openharmonise.rm.DataAccessException;
22 import org.openharmonise.rm.resources.lifecycle.Editable;
23
24
25 /**
26  * Gets the pending versions of the 'command object', if it
27  * is an instance of <code>Editable</code>.
28  *
29  * @author Michael Bell
30  * @version $Revision: 1.3 $
31  *
32  */

33 public class CmdGetPendingVersions extends AbstractCmd {
34
35     /**
36      * Creats an instance of the command.
37      *
38      */

39     public CmdGetPendingVersions() {
40         super();
41     }
42
43     /* (non-Javadoc)
44      * @see org.openharmonise.rm.commands.AbstractCmd#execute()
45      */

46     public Object JavaDoc execute(Context context) throws CommandException {
47         if ((m_commandObj instanceof Editable) == false) {
48             throw new InvalidCommandException(
49                 "Command is not valid for this object:"
50                     + m_commandObj.getClass());
51         }
52
53         if (isAvailable(context) == false) {
54             throw new InvalidCommandException("Command is not available for this object");
55         }
56
57         Editable editable = (Editable) getCommandObject(context);
58         Object JavaDoc cmdResult = null;
59
60         try {
61             cmdResult = editable.getPendingVersions();
62         } catch (DataAccessException e) {
63             throw new CommandExecutionException(
64                 "Error getting historical versions",
65                 e);
66         }
67
68         return cmdResult;
69     }
70
71     /* (non-Javadoc)
72      * @see org.openharmonise.rm.commands.AbstractCmd#getName()
73      */

74     public String JavaDoc getName() {
75         return "GetPendingVersions";
76     }
77
78     /* (non-Javadoc)
79      * @see org.openharmonise.rm.commands.AbstractCmd#isValidCommandObject(java.lang.Object)
80      */

81     public boolean isValidCommandObject(Object JavaDoc obj) {
82         return (obj instanceof Editable);
83     }
84 }
Popular Tags