01: /***************************************************************
02: * This file is part of the [fleXive](R) project.
03: *
04: * Copyright (c) 1999-2007
05: * UCS - unique computing solutions gmbh (http://www.ucs.at)
06: * All rights reserved
07: *
08: * The [fleXive](R) project is free software; you can redistribute
09: * it and/or modify it under the terms of the GNU General Public
10: * License as published by the Free Software Foundation;
11: * either version 2 of the License, or (at your option) any
12: * later version.
13: *
14: * The GNU General Public License can be found at
15: * http://www.gnu.org/copyleft/gpl.html.
16: * A copy is found in the textfile GPL.txt and important notices to the
17: * license from the author are found in LICENSE.txt distributed with
18: * these libraries.
19: *
20: * This library is distributed in the hope that it will be useful,
21: * but WITHOUT ANY WARRANTY; without even the implied warranty of
22: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23: * GNU General Public License for more details.
24: *
25: * For further information about UCS - unique computing solutions gmbh,
26: * please see the company website: http://www.ucs.at
27: *
28: * For further information about [fleXive](R), please see the
29: * project website: http://www.flexive.org
30: *
31: *
32: * This copyright notice MUST APPEAR in all copies of the file!
33: ***************************************************************/package com.flexive.war.javascript;
34:
35: import com.flexive.shared.EJBLookup;
36: import com.flexive.shared.content.FxPK;
37: import org.apache.commons.logging.Log;
38: import org.apache.commons.logging.LogFactory;
39:
40: import java.io.Serializable;
41:
42: /**
43: * Content editor actions invoked via JSON/RPC.
44: *
45: * @author Daniel Lichtenberger (daniel.lichtenberger@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
46: * @version $Rev: 1 $
47: */
48: public class ContentEditor implements Serializable {
49: private static final long serialVersionUID = 8418186403482323113L;
50: private static final transient Log LOG = LogFactory
51: .getLog(ContentEditor.class);
52:
53: /**
54: * Delete the given content.
55: *
56: * @param id the content ID
57: * @return an empty result
58: * @throws Exception if an error occured
59: */
60: public String remove(long id) throws Exception {
61: return removeMultiple(new long[] { id });
62: }
63:
64: /**
65: * Delete the given contents.
66: *
67: * @param ids the content IDs
68: * @return an empty result
69: * @throws Exception if an error occured
70: */
71: public String removeMultiple(long[] ids) throws Exception {
72: try {
73: for (long id : ids) {
74: EJBLookup.getContentEngine().remove(new FxPK(id));
75: }
76: return "[]";
77: } catch (Exception e) {
78: LOG.error("Failed to remove content: " + e.getMessage());
79: throw e;
80: }
81: }
82: }
|