1 31 32 package org.opencms.workplace.tools.projects; 33 34 import org.opencms.db.CmsPublishList; 35 import org.opencms.file.CmsProject; 36 import org.opencms.jsp.CmsJspActionElement; 37 import org.opencms.main.CmsException; 38 import org.opencms.main.CmsRuntimeException; 39 import org.opencms.util.CmsStringUtil; 40 import org.opencms.workplace.CmsReport; 41 import org.opencms.workplace.CmsWorkplaceSettings; 42 import org.opencms.workplace.commons.Messages; 43 import org.opencms.workplace.threads.CmsPublishThread; 44 import org.opencms.workplace.threads.CmsXmlDocumentLinkValidatorThread; 45 46 import javax.servlet.http.HttpServletRequest ; 47 import javax.servlet.http.HttpServletResponse ; 48 import javax.servlet.jsp.JspException ; 49 import javax.servlet.jsp.PageContext ; 50 51 61 public class CmsPublishProjectReport extends CmsReport { 62 63 64 public static final String PARAM_PROJECTID = "projectid"; 65 66 67 private String m_paramProjectid; 68 69 74 public CmsPublishProjectReport(CmsJspActionElement jsp) { 75 76 super(jsp); 77 } 78 79 86 public CmsPublishProjectReport(PageContext context, HttpServletRequest req, HttpServletResponse res) { 87 88 this(new CmsJspActionElement(context, req, res)); 89 } 90 91 96 public void displayReport() throws JspException { 97 98 getJsp().getRequest().setAttribute(SESSION_WORKPLACE_CLASS, this); 100 switch (getAction()) { 101 case ACTION_REPORT_END: 102 actionCloseDialog(); 103 break; 104 case ACTION_CANCEL: 105 actionCloseDialog(); 106 break; 107 case ACTION_REPORT_UPDATE: 108 setParamAction(REPORT_UPDATE); 109 getJsp().include(FILE_REPORT_OUTPUT); 110 break; 111 case ACTION_REPORT_BEGIN: 112 case ACTION_CONFIRMED: 113 case ACTION_DEFAULT: 114 default: 115 try { 116 if (getCms().readProject(new Integer (getParamProjectid()).intValue()).getType() == CmsProject.PROJECT_TYPE_TEMPORARY) { 117 setParamRefreshWorkplace(CmsStringUtil.TRUE); 119 } 120 } catch (Exception e) { 121 } 123 124 CmsPublishList list = null; 125 try { 126 CmsProject currentProject = getCms().getRequestContext().currentProject(); 127 getCms().getRequestContext().setCurrentProject( 128 getCms().readProject(new Integer (getParamProjectid()).intValue())); 129 list = getCms().getPublishList(); 130 getCms().getRequestContext().setCurrentProject(currentProject); 131 } catch (CmsException e) { 132 throw new CmsRuntimeException(e.getMessageContainer(), e); 133 } 134 135 startValidationThread(list); 137 getJsp().include(FILE_REPORT_OUTPUT); 138 } 139 } 140 141 146 public String getParamProjectid() { 147 148 return m_paramProjectid; 149 } 150 151 156 public void setParamProjectid(String projectId) { 157 158 m_paramProjectid = projectId; 159 } 160 161 164 protected void initWorkplaceRequestValues(CmsWorkplaceSettings settings, HttpServletRequest request) { 165 166 fillParamValues(request); 168 169 if (REPORT_UPDATE.equals(getParamAction())) { 170 setAction(ACTION_REPORT_UPDATE); 171 } else if (REPORT_BEGIN.equals(getParamAction())) { 172 setAction(ACTION_REPORT_BEGIN); 173 } else if (REPORT_END.equals(getParamAction())) { 174 if (Boolean.valueOf(getParamThreadHasNext()).booleanValue()) { 175 startPublishThread(); 177 } else { 178 setAction(ACTION_REPORT_END); 180 } 181 } else if (DIALOG_CANCEL.equals(getParamAction())) { 182 setAction(ACTION_CANCEL); 183 } else { 184 setAction(ACTION_DEFAULT); 186 } 187 } 188 189 192 private void startPublishThread() { 193 194 CmsPublishList publishList = getSettings().getPublishList(); 196 CmsPublishThread thread = new CmsPublishThread(getCms(), publishList, getSettings()); 197 198 setParamThread(thread.getUUID().toString()); 200 setParamThreadHasNext(CmsStringUtil.FALSE); 201 202 setParamAction(REPORT_UPDATE); 203 setAction(ACTION_REPORT_UPDATE); 204 205 thread.start(); 207 } 208 209 212 private void startValidationThread(CmsPublishList publishList) throws JspException { 213 214 try { 215 CmsXmlDocumentLinkValidatorThread thread = new CmsXmlDocumentLinkValidatorThread(getCms(), publishList, getSettings()); 216 217 setParamThread(thread.getUUID().toString()); 218 setParamThreadHasNext(CmsStringUtil.TRUE); 219 220 setParamAction(REPORT_BEGIN); 221 222 setParamReportContinueKey(Messages.GUI_PUBLISH_CONTINUE_BROKEN_LINKS_0); 224 } catch (Throwable e) { 225 226 includeErrorpage(this, e); 228 } 229 } 230 } 231 | Popular Tags |