001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com) 006 * 007 * This library is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * This library is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * For further information about Alkacon Software GmbH & Co. KG, please see the 018 * company website: http://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: http://www.opencms.org 022 * 023 * You should have received a copy of the GNU Lesser General Public 024 * License along with this library; if not, write to the Free Software 025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 026 */ 027 028package org.opencms.workplace.commons; 029 030import org.opencms.file.CmsObject; 031import org.opencms.file.CmsResource; 032import org.opencms.main.CmsException; 033import org.opencms.workplace.explorer.CmsResourceUtil; 034import org.opencms.workplace.list.A_CmsListExplorerDialog; 035import org.opencms.workplace.list.A_CmsListResourceCollector; 036import org.opencms.workplace.list.CmsListItem; 037 038import java.util.ArrayList; 039import java.util.Iterator; 040import java.util.List; 041import java.util.Map; 042 043/** 044 * Collector for resources with links that could get broken after deletion.<p> 045 * 046 * @since 6.5.4 047 */ 048public class CmsDeleteBrokenRelationsCollector extends A_CmsListResourceCollector { 049 050 /** Parameter of the default collector name. */ 051 public static final String COLLECTOR_NAME = "brokenResources"; 052 053 /** 054 * Constructor, creates a new instance.<p> 055 * 056 * @param wp the workplace object 057 * @param resources list of locked resources 058 */ 059 public CmsDeleteBrokenRelationsCollector(A_CmsListExplorerDialog wp, List<String> resources) { 060 061 super(wp); 062 setResourcesParam(resources); 063 } 064 065 /** 066 * @see org.opencms.file.collectors.I_CmsResourceCollector#getCollectorNames() 067 */ 068 public List<String> getCollectorNames() { 069 070 List<String> names = new ArrayList<String>(); 071 names.add(COLLECTOR_NAME); 072 return names; 073 } 074 075 /** 076 * @see org.opencms.workplace.list.A_CmsListResourceCollector#getResources(org.opencms.file.CmsObject, java.util.Map) 077 */ 078 @Override 079 public List<CmsResource> getResources(CmsObject cms, Map<String, String> params) throws CmsException { 080 081 List<CmsResource> resources = new ArrayList<CmsResource>(); 082 Iterator<String> itResourceNames = getResourceNamesFromParam(params).iterator(); 083 while (itResourceNames.hasNext()) { 084 String resName = itResourceNames.next(); 085 resources.add(cms.readResource(resName)); 086 } 087 return resources; 088 } 089 090 /** 091 * @see org.opencms.workplace.list.A_CmsListResourceCollector#setAdditionalColumns(org.opencms.workplace.list.CmsListItem, org.opencms.workplace.explorer.CmsResourceUtil) 092 */ 093 @Override 094 protected void setAdditionalColumns(CmsListItem item, CmsResourceUtil resUtil) { 095 096 // no-op 097 } 098}