/** * Copyright (c) Istituto Nazionale di Fisica Nucleare (INFN). 2006-2016 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.glite.security.voms.admin.view.actions.register; import org.apache.struts2.convention.annotation.Result; import org.apache.struts2.convention.annotation.Results; import org.glite.security.voms.admin.persistence.dao.generic.DAOFactory; import org.glite.security.voms.admin.persistence.dao.generic.RequestDAO; import org.glite.security.voms.admin.persistence.model.request.Request.STATUS; import org.glite.security.voms.admin.view.actions.BaseAction; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @Results({ @Result(name = BaseAction.SUCCESS, location = "registrationCancelled"), @Result(name = BaseAction.ERROR, location = "registrationConfirmationError") }) public class CancelRequestAction extends RegisterActionSupport { /** * */ private static final long serialVersionUID = 1L; public static final Logger log = LoggerFactory .getLogger(CancelRequestAction.class); String confirmationId; @Override public String execute() throws Exception { if (!registrationEnabled()) return REGISTRATION_DISABLED; if (request == null){ addActionError("Request not found!"); return ERROR; } if (!request.getStatus().equals(STATUS.SUBMITTED)) { addActionError("Your request cannot be canceled at this stage!"); return ERROR; } if (request.getConfirmId().equals(confirmationId)) { RequestDAO rDAO = DAOFactory.instance().getRequestDAO(); log.info("Removing request '" + request + "' on user's request."); rDAO.makeTransient(request); return SUCCESS; } addActionError("Wrong confirmation id!"); return ERROR; } public String getConfirmationId() { return confirmationId; } public void setConfirmationId(String confirmationId) { this.confirmationId = confirmationId; } }