1 31 32 package org.opencms.workplace.commons; 33 34 import org.opencms.jsp.CmsJspActionElement; 35 import org.opencms.main.CmsException; 36 import org.opencms.security.CmsPermissionSet; 37 import org.opencms.workplace.CmsMultiDialog; 38 import org.opencms.workplace.CmsWorkplaceSettings; 39 40 import java.util.Iterator ; 41 42 import javax.servlet.http.HttpServletRequest ; 43 import javax.servlet.http.HttpServletResponse ; 44 import javax.servlet.jsp.JspException ; 45 import javax.servlet.jsp.PageContext ; 46 47 62 public class CmsUndelete extends CmsMultiDialog { 63 64 65 public static final int ACTION_UNDELETE = 100; 66 67 68 public static final String DIALOG_TYPE = "undelete"; 69 70 75 public CmsUndelete(CmsJspActionElement jsp) { 76 77 super(jsp); 78 } 79 80 87 public CmsUndelete(PageContext context, HttpServletRequest req, HttpServletResponse res) { 88 89 this(new CmsJspActionElement(context, req, res)); 90 } 91 92 97 public void actionUndelete() throws JspException { 98 99 getJsp().getRequest().setAttribute(SESSION_WORKPLACE_CLASS, this); 101 try { 102 if (performDialogOperation()) { 103 actionCloseDialog(); 105 } else { 106 getJsp().include(FILE_DIALOG_SCREEN_WAIT); 108 } 109 } catch (Throwable e) { 110 includeErrorpage(this, e); 112 } 113 } 114 115 120 public String buildConfirmationMessage() { 121 122 if (isMultiOperation()) { 123 return key(Messages.GUI_UNDELETE_MULTI_CONFIRMATION_0); 124 } else { 125 return key(Messages.GUI_UNDELETE_CONFIRMATION_0); 126 } 127 } 128 129 132 protected void initWorkplaceRequestValues(CmsWorkplaceSettings settings, HttpServletRequest request) { 133 134 fillParamValues(request); 136 137 if (! checkResourcePermissions(CmsPermissionSet.ACCESS_WRITE, false)) { 139 setParamAction(DIALOG_CANCEL); 141 } 142 143 setParamDialogtype(DIALOG_TYPE); 145 if (DIALOG_TYPE.equals(getParamAction())) { 147 setAction(ACTION_UNDELETE); 148 } else if (DIALOG_WAIT.equals(getParamAction())) { 149 setAction(ACTION_WAIT); 150 } else if (DIALOG_CANCEL.equals(getParamAction())) { 151 setAction(ACTION_CANCEL); 152 } else { 153 setAction(ACTION_DEFAULT); 154 setDialogTitle(Messages.GUI_UNDELETE_RESOURCE_1, Messages.GUI_UNDELETE_MULTI_2); 156 } 157 } 158 159 165 protected boolean performDialogOperation() throws CmsException { 166 167 boolean isFolder = isOperationOnFolder(); 169 if ((isMultiOperation() || isFolder) && !DIALOG_WAIT.equals(getParamAction())) { 171 return false; 173 } 174 175 Iterator i = getResourceList().iterator(); 176 while (i.hasNext()) { 178 String resName = (String )i.next(); 179 try { 180 checkLock(resName); 182 getCms().undeleteResource(resName); 184 } catch (CmsException e) { 185 if (isMultiOperation()) { 186 addMultiOperationException(e); 188 } else { 189 throw e; 191 } 192 } 193 } 194 checkMultiOperationException(Messages.get(), Messages.ERR_UNDELETE_MULTI_0); 196 return true; 197 } 198 } 199 | Popular Tags |