/*
 * $Id: UserAdminDeleteAction.java,v 1.3 2003/06/06 17:59:23 egli Exp $
 * <License>
 * The Apache Software License
 *
 * Copyright (c) 2003 Wyona. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment: "This product
 *    includes software developed by Wyona (http://www.wyona.com)"
 *
 * 4. The name "Lenya" must not be used to endorse or promote products
 *    derived from this software without prior written permission. For
 *    written permission, please contact contact@wyona.com
 *
 * 5. Products derived from this software may not be called "Lenya" nor
 *    may "Lenya" appear in their names without prior written permission
 *    of Wyona.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment: "This product includes software developed by Wyona
 *    (http://www.wyona.com)"
 *
 * THIS SOFTWARE IS PROVIDED BY Wyona "AS IS" WITHOUT ANY WARRANTY EXPRESS
 * OR IMPLIED, INCLUDING THE WARRANTY OF NON-INFRINGEMENT AND THE IMPLIED
 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 * Wyona WILL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY YOU AS A RESULT
 * OF USING THIS SOFTWARE. IN NO EVENT WILL lenya BE LIABLE FOR ANY SPECIAL,
 * INDIRECT OR CONSEQUENTIAL DAMAGES OR LOST PROFITS EVEN IF Wyona HAS BEEN
 * ADVISED OF THE POSSIBILITY OF THEIR OCCURRENCE. Wyona WILL NOT BE LIABLE
 * FOR ANY THIRD PARTY CLAIMS AGAINST YOU.
 *
 * Lenya includes software developed by the Apache Software Foundation, W3C,
 * DOM4J Project, BitfluxEditor and Xopus.
 * </License>
 */

package org.apache.lenya.cms.cocoon.acting;

import java.util.Collections;
import java.util.Map;

import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.acting.AbstractAction;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Redirector;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.lenya.cms.ac.AccessControlException;
import org.apache.lenya.cms.ac.User;
import org.apache.lenya.cms.ac.UserManager;
import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.cms.publication.PublicationFactory;

/**
 * @author egli
 * 
 * 
 */
public class UserAdminDeleteAction
	extends AbstractAction
	implements UserAdminActionInterface {

	/* (non-Javadoc)
	 * @see org.apache.cocoon.acting.Action#act(org.apache.cocoon.environment.Redirector, org.apache.cocoon.environment.SourceResolver, java.util.Map, java.lang.String, org.apache.avalon.framework.parameters.Parameters)
	 */
	public Map act(
		Redirector redirector,
		SourceResolver resolver,
		Map objectModel,
		String source,
		Parameters parameters)
		throws Exception {

		Request request = ObjectModelHelper.getRequest(objectModel);
		Publication publication = PublicationFactory.getPublication(objectModel);

		Map emptyMap = Collections.EMPTY_MAP;

		String userId = request.getParameter(USER_ID);

		UserManager manager = null;
		try {
			manager = UserManager.instance(publication);
		} catch (AccessControlException e) {
			getLogger().error(e.getMessage(), e);
			return null;
		}
		User user = manager.getUser(userId);

		try {
			user.delete();
		} catch (AccessControlException e) {
			getLogger().error(e.getMessage(), e);
			return null;
		}

		return emptyMap;
	}

}

@@ -35,17 +35,17 @@
 ava,v 1.
-3
+4
  2003/06
@@ -49,19 +49,19 @@
 /06/
+1
 0
-6
  1
-7
+3
 :59:2
-3
+5
  egl
@@ -3424,17 +3424,20 @@
 cation =
- 
+%0A%09%09%09
 Publicat
@@ -3793,16 +3793,134 @@
 serId);%0A
+%09%09%0A%09%09if (user == null) %7B%0A%09%09%09getLogger().warn(%22Trying to delete non-existing user: %22 + userId);%0A%09%09%09return null;%09%0A%09%09%7D%0A%09%09
 %0A%09%09try %7B

Handle the case where the request tries to delete a non-existing user.