Mercurial Hosting > nabble
diff src/nabble/view/web/catalog/ExportConfirmation.jtp @ 0:7ecd1a4ef557
add content
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 21 Mar 2019 19:15:52 -0600 |
parents | |
children | 18cf4872fd7f |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/nabble/view/web/catalog/ExportConfirmation.jtp Thu Mar 21 19:15:52 2019 -0600 @@ -0,0 +1,133 @@ +<% +package nabble.view.web.catalog; + +import fschmidt.util.servlet.AuthorizingServlet; +import nabble.model.ModelHome; +import nabble.model.Node; +import nabble.model.User; +import nabble.model.export.Export; +import nabble.view.lib.Jtp; +import nabble.view.lib.Shared; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; + + +public class ExportConfirmation extends HttpServlet implements AuthorizingServlet { + private static final Logger logger = LoggerFactory.getLogger(ExportConfirmation.class); + + public String getAuthorizationKey(HttpServletRequest request) throws ServletException { + return Jtp.getReadAuthorizationKey( Jtp.getSiteNotNull(request).getNode(Jtp.getLong(request,"node")) ); + } + + public boolean authorize(String key,HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException { + return Jtp.authorizeForRead(key,request,response); + } + + protected void service(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException + { + PrintWriter out = response.getWriter(); + String nodeId = request.getParameter("node"); + Node node = Jtp.getSiteNotNull(request).getNode(Long.valueOf(nodeId)); + if (node == null) { + response.sendError(HttpServletResponse.SC_NOT_FOUND); + return; + } + + User user = Jtp.getUser(request, response); + boolean allowed = Jtp.canBeRemovedBy(node,user); + if (!allowed) { + Jtp.login("Only administrators can proceed in this area.", request, response); + return; + } + + String url = request.getParameter("url"); + if (url == null || !Export.isValidExportServer(url)) { + logger.error("Invalid export URL: ["+url+"] referer="+request.getHeader("referer")+" user="+Jtp.getUser(request,response)+" user-agent="+request.getHeader("user-agent")); + return; + } + + String action = request.getParameter("action"); + if ("export".equals(action) && "POST".equals(request.getMethod())) { + logger.info("Starting export of node ID=" + node.getId() + " to [" + url + ']'); + node.export(url, user.getEmail()); + response.sendRedirect(url); + return; + } + %> + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> + <html> + <head> + <% Shared.title(request, response, "Parent Options / Export Confirmation"); %> + </head> + <body> + <% Shared.minHeader(request,response, node); %> + <% Shared.editHeader(node.getSubjectHtml(), "Parent Options", out); %> + + <h2 style="margin-bottom:.6em">Export Confirmation</h2> + You have requested the following URL to be the new parent of <em>"<%=node.getSubjectHtml()%>"</em>: + <div class="highlight rounded" style="padding:.5em;margin: .5em 0 1em;font-weight:bold"> + <%=url%> + </div> + This new parent is not related to <em><%=node.getSubjectHtml()%></em>, + so Nabble must migrate the contents of your <%=Jtp.viewName(node).toLowerCase()%> to that new location. + You should understand that: + <ul> + <li style="padding-bottom:1em"> + <strong>This change may not happen immediately</strong>. + <div> + The system will have to move post by post to the new location and this may + take hours (or even days) to finish depending on the size of the moved elements. + You will be notified by email when the process is complete. + </div> + </li> + <li style="padding-bottom:1em"> + <strong>All links to the moved elements will change (including links to posts and replies).</strong> + <div> + <span class="important" style="font-weight:bold">Previous links will NOT work anymore.</span> + Users should update their links if they want to visit those pages again in the future. + </div> + </li> + <li style="padding-bottom:1em"> + <strong>Some user accounts may not be moved.</strong> + <div> + The system will move posts and all associated user accounts to the new destination. + Non-related users accounts will not be moved. + </div> + </li> + <li> + <strong>Customizations will not be moved.</strong> + <div> + Custom NAML code and other changes (e.g., font size, CSS and other settings from the <i>Change Appearance</i> page) will not be moved. + </div> + </li> + </ul> + <div style="margin-top:1.5em"> + Do you really want to start the export process for <em><%=node.getSubjectHtml()%></em>? + </div> + + <form method="post" action="/catalog/ExportConfirmation.jtp" accept-charset="UTF-8"> + <input type="hidden" name="action" value="export" /> + <input type="hidden" name="node" value="<%=node.getId()%>" /> + <input type="hidden" name="url" value="<%=url%>" /> + + <div style="margin-top:1.4em"> + <input type="submit" name="save" value="Yes, Export it" /> or <a href="<%=Jtp.path(node)%>">Cancel</a> + </div> + </form> + + <% Shared.footer(request, response); %> + <% Shared.analytics(request,response); %> + </body> + </html> + <% + } +} +%> \ No newline at end of file