@Test void missingCSRFToken() throws Exception { when(this.csrfToken.isTokenValid(null)).thenReturn(false); assertFalse(this.undeleteAction.action(this.oldcore.getXWikiContext())); verify(this.csrfToken).getResubmissionURL(); }
@Override public boolean action(XWikiContext context) throws XWikiException { XWikiRequest request = context.getRequest(); XWikiResponse response = context.getResponse(); XWikiDocument doc = context.getDoc(); XWikiDeletedDocument deletedDocument = getDeletedDocument(context); if (deletedDocument == null) { sendRedirect(response, doc.getURL(VIEW_ACTION, context)); return false; } if (TRUE.equals(request.getParameter(SHOW_BATCH_PARAMETER)) && !TRUE.equals(request.getParameter(CONFIRM_PARAMETER))) { return true; } if (!csrfTokenCheck(context)) { return false; } DeletedDocument deletedDocumentAPI = new DeletedDocument(deletedDocument, context); if (!deletedDocumentAPI.canUndelete()) { return true; } boolean redirected = false; if (deletedDocument != null) { redirected = restoreDocument(deletedDocument, context); } if (!redirected) { String queryString = getRedirectQueryString(context, deletedDocument.getLocale()); sendRedirect(response, doc.getURL(VIEW_ACTION, queryString, context)); redirected = true; } return !redirected; }
UndeleteAction extends XWikiAction { @Override public boolean action(XWikiContext context) throws XWikiException { XWikiRequest request = context.getRequest(); XWikiResponse response = context.getResponse(); XWikiDocument doc = context.getDoc(); XWikiDeletedDocument deletedDocument = getDeletedDocument(context); if (deletedDocument == null) { sendRedirect(response, doc.getURL(VIEW_ACTION, context)); return false; } if (TRUE.equals(request.getParameter(SHOW_BATCH_PARAMETER)) && !TRUE.equals(request.getParameter(CONFIRM_PARAMETER))) { return true; } if (!csrfTokenCheck(context)) { return false; } DeletedDocument deletedDocumentAPI = new DeletedDocument(deletedDocument, context); if (!deletedDocumentAPI.canUndelete()) { return true; } boolean redirected = false; if (deletedDocument != null) { redirected = restoreDocument(deletedDocument, context); } if (!redirected) { String queryString = getRedirectQueryString(context, deletedDocument.getLocale()); sendRedirect(response, doc.getURL(VIEW_ACTION, queryString, context)); redirected = true; } return !redirected; } }
UndeleteAction extends XWikiAction { @Override public boolean action(XWikiContext context) throws XWikiException { XWikiRequest request = context.getRequest(); XWikiResponse response = context.getResponse(); XWikiDocument doc = context.getDoc(); XWikiDeletedDocument deletedDocument = getDeletedDocument(context); if (deletedDocument == null) { sendRedirect(response, doc.getURL(VIEW_ACTION, context)); return false; } if (TRUE.equals(request.getParameter(SHOW_BATCH_PARAMETER)) && !TRUE.equals(request.getParameter(CONFIRM_PARAMETER))) { return true; } if (!csrfTokenCheck(context)) { return false; } DeletedDocument deletedDocumentAPI = new DeletedDocument(deletedDocument, context); if (!deletedDocumentAPI.canUndelete()) { return true; } boolean redirected = false; if (deletedDocument != null) { redirected = restoreDocument(deletedDocument, context); } if (!redirected) { String queryString = getRedirectQueryString(context, deletedDocument.getLocale()); sendRedirect(response, doc.getURL(VIEW_ACTION, queryString, context)); redirected = true; } return !redirected; }  }
UndeleteAction extends XWikiAction { @Override public boolean action(XWikiContext context) throws XWikiException { XWikiRequest request = context.getRequest(); XWikiResponse response = context.getResponse(); XWikiDocument doc = context.getDoc(); XWikiDeletedDocument deletedDocument = getDeletedDocument(context); if (deletedDocument == null) { sendRedirect(response, doc.getURL(VIEW_ACTION, context)); return false; } if (TRUE.equals(request.getParameter(SHOW_BATCH_PARAMETER)) && !TRUE.equals(request.getParameter(CONFIRM_PARAMETER))) { return true; } if (!csrfTokenCheck(context)) { return false; } DeletedDocument deletedDocumentAPI = new DeletedDocument(deletedDocument, context); if (!deletedDocumentAPI.canUndelete()) { return true; } boolean redirected = false; if (deletedDocument != null) { redirected = restoreDocument(deletedDocument, context); } if (!redirected) { String queryString = getRedirectQueryString(context, deletedDocument.getLocale()); sendRedirect(response, doc.getURL(VIEW_ACTION, queryString, context)); redirected = true; } return !redirected; }  @Override boolean action(XWikiContext context); @Override String render(XWikiContext context); }
UndeleteAction extends XWikiAction { @Override public boolean action(XWikiContext context) throws XWikiException { XWikiRequest request = context.getRequest(); XWikiResponse response = context.getResponse(); XWikiDocument doc = context.getDoc(); XWikiDeletedDocument deletedDocument = getDeletedDocument(context); if (deletedDocument == null) { sendRedirect(response, doc.getURL(VIEW_ACTION, context)); return false; } if (TRUE.equals(request.getParameter(SHOW_BATCH_PARAMETER)) && !TRUE.equals(request.getParameter(CONFIRM_PARAMETER))) { return true; } if (!csrfTokenCheck(context)) { return false; } DeletedDocument deletedDocumentAPI = new DeletedDocument(deletedDocument, context); if (!deletedDocumentAPI.canUndelete()) { return true; } boolean redirected = false; if (deletedDocument != null) { redirected = restoreDocument(deletedDocument, context); } if (!redirected) { String queryString = getRedirectQueryString(context, deletedDocument.getLocale()); sendRedirect(response, doc.getURL(VIEW_ACTION, queryString, context)); redirected = true; } return !redirected; }  @Override boolean action(XWikiContext context); @Override String render(XWikiContext context);  }