01: /*
02: * %W% %G% Sun Microsystems
03: *
04: * Copyright 2000 Sun Microsystems, Inc. All rights reserved.
05: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
06: */
07:
08: package com.sun.portal.wireless.taglibs.ab;
09:
10: import javax.servlet.jsp.*;
11: import javax.servlet.jsp.tagext.*;
12: import com.sun.portal.wireless.taglibs.base.*;
13: import com.sun.portal.log.common.PortalLogger;
14:
15: import com.sun.addressbook.Entry;
16: import com.sun.addressbook.Element;
17:
18: import java.util.logging.Logger;
19:
20: /**
21: * The ABDeleteTag class executes the address book add command.
22: *
23: * Attributes needed: entryid
24: *
25: * @author Mihir Sambhus
26: * @version 1.0
27: */
28: public class ABDeleteTag extends ABBaseCommandTag {
29:
30: // Create a logger for this class
31: private static Logger debugLogger = PortalLogger
32: .getLogger(ABDeleteTag.class);
33:
34: /**
35: * Execute the delete element command on the address book.
36: * Returns the command status.
37: * If the command fails then the tag body is included,
38: * Else if the command succeeds then the tag body is skipped.
39: *
40: * @return true if the command succeeds.
41: * false if the command fails.
42: * @exception JspException
43: */
44: public boolean execute() throws JspException {
45:
46: // entryid attribute must be present for delete.. if not jsp
47: // exception is throw
48: verifyEntryid();
49:
50: // Get the contactDB object interacting with the Backend LDAP server
51: ContactDB contactDB = getContactDB();
52: // Get the element object corresponsing to the entryid, from context
53: Element element = getEntry(Integer.parseInt(entryid));
54:
55: // perform delete command
56: if (!contactDB.deleteElementFromABook(element)) {
57: debugLogger.fine("PSMA_CSPWTA0011");
58: getABContext().setErrorCode("");
59: return false;
60: }
61: return true;
62: }
63:
64: }
|