/* * Copyright (C) 2005-2010 Alfresco Software Limited. * * This file is part of Alfresco * * Alfresco is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Alfresco is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ package org.alfresco.web.bean.trashcan; import java.util.List; import javax.faces.context.FacesContext; import javax.faces.event.ActionEvent; import org.alfresco.repo.node.archive.RestoreNodeReport; import org.alfresco.web.app.Application; import org.alfresco.web.bean.repository.Repository; public class TrashcanRecoverAllItemsDialog extends TrashcanDialog { private static final long serialVersionUID = -1869377322722271833L; private static final String OUTCOME_RECOVERY_REPORT = "dialog:recoveryReport"; private static final String MSG_NO = "no"; private static final String MSG_YES = "yes"; private String recoverAllItems(FacesContext context, String outcome) { if (property.isInProgress()) return null; property.setInProgress(true); try { // restore all nodes - the user may have requested a restore to a // different parent List reports; if (property.getDestination() == null) { reports = property.getNodeArchiveService().restoreAllArchivedNodes(Repository.getStoreRef()); } else { reports = property.getNodeArchiveService().restoreAllArchivedNodes(Repository.getStoreRef(), property.getDestination(), null, null); } saveReportDetail(reports); } finally { property.setInProgress(false); } return OUTCOME_RECOVERY_REPORT; } @Override protected String finishImpl(FacesContext context, String outcome) throws Exception { return recoverAllItems(context, outcome); } @Override public String getCancelButtonLabel() { return Application.getMessage(FacesContext.getCurrentInstance(), MSG_NO); } @Override public boolean getFinishButtonDisabled() { return false; } @Override public String getFinishButtonLabel() { return Application.getMessage(FacesContext.getCurrentInstance(), MSG_YES); } @Override public void setupListAction(ActionEvent event) { super.setupListAction(event); clearSearch(event); getItems(); } }