All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.openas2.app.partner.DeletePartnershipCommand Maven / Gradle / Ivy

Go to download

Open source implementation of the AS2 standard for signed encrypted and compressed document transfer

There is a newer version: 2.10.1
Show newest version
package org.openas2.app.partner;

import java.util.Iterator;

import org.openas2.OpenAS2Exception;
import org.openas2.cmd.CommandResult;
import org.openas2.partner.Partnership;
import org.openas2.partner.PartnershipFactory;

/** removes a partnership entry in partnership store
 * 
 * @author joseph mcverry
 *
 */
public class DeletePartnershipCommand extends AliasedPartnershipsCommand {
	public String getDefaultDescription() {
		return "Delete the partnership associated with an name.";
	}

	public String getDefaultName() {
		return "delete";
	}

	public String getDefaultUsage() {
		return "delete ";
	}

	public CommandResult execute(PartnershipFactory partFx, Object[] params)
			throws OpenAS2Exception {
		if (params.length < 1) {
			return new CommandResult(CommandResult.TYPE_INVALID_PARAM_COUNT,
					getUsage());
		}

		synchronized (partFx) {

			String name = params[0].toString();
			Iterator parts = partFx.getPartnerships().iterator();

			while (parts.hasNext()) {
				Partnership part = (Partnership) parts.next();
				if (part.getName().equals(name)) {
					partFx.getPartnerships().remove(part);
					return new CommandResult(CommandResult.TYPE_OK, "deleted "
							+ name);
				}
			}

			return new CommandResult(CommandResult.TYPE_ERROR,
					"Unknown partnership name");
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy