Hi everyone,
I installed OpenKM last week and so far it seems to be the best solution for the project I'm working on. I needed a server side application that could let users modify a file structure (in this case the repository) which can then be simply exported to the server's file system for file backups and use with a website. On the website, I have a button that will need to export the files from the repository out to the file system as these files are used in the dynamic generation of the site's content. Is there a way that I can export the repository contents to the server's file system without needing to log in? I currently modified the repository_export.jsp file and brought it up one level hoping that it would bypass the need to log in, but it didn't. The source code is:
EDIT: I'm using OpenKM 6.2.1 Build 7659 hosted on Ubuntu 12.04 LTS Desktop. I have tried Chrome, Firefox and IE8.
Thanks,
Mike
I installed OpenKM last week and so far it seems to be the best solution for the project I'm working on. I needed a server side application that could let users modify a file structure (in this case the repository) which can then be simply exported to the server's file system for file backups and use with a website. On the website, I have a button that will need to export the files from the repository out to the file system as these files are used in the dynamic generation of the site's content. Is there a way that I can export the repository contents to the server's file system without needing to log in? I currently modified the repository_export.jsp file and brought it up one level hoping that it would bypass the need to log in, but it didn't. The source code is:
Code: Select all
When I try to access it through the web browser when I am not logged in, I get: "Error: 872a4a15-be33-4455-bcbb-f9b53d5ff630 : /okm:root", but if I log in as any user (admin privileges or not) it works. I think it has something to do with a Session ID or cookie that is generated when you log in. Is there any way to fix this or any other means by which I can export the repository without having to open up the website?// Automated Repository Export
<%@ page import="java.io.FileNotFoundException"%>
<%@ page import="java.io.IOException"%>
<%@ page import="java.io.File" %>
<%@ page import="com.openkm.core.Config" %>
<%@ page import="com.openkm.servlet.admin.BaseServlet" %>
<%@ page import="com.openkm.bean.ContentInfo" %>
<%@ page import="com.openkm.api.OKMFolder" %>
<%@ page import="com.openkm.util.WebUtils"%>
<%@ page import="com.openkm.util.FormatUtil" %>
<%@ page import="com.openkm.util.impexp.RepositoryExporter" %>
<%@ page import="com.openkm.util.impexp.HTMLInfoDecorator" %>
<%@ page import="com.openkm.util.impexp.ImpExpStats"%>
<%@ page import="com.openkm.bean.Repository"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="Shortcut icon" href="favicon.ico" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script type="text/javascript" src="../js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="js/jquery.DOMWindow.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$dm = $('.ds').openDOMWindow({
height:200, width:300,
eventType:'click',
overlayOpacity:'57',
windowSource:'iframe', windowPadding:0
});
});
function dialogClose() {
$dm.closeDOMWindow();
}
</script>
<title>Repository Export</title>
</head>
<body>
<%
request.setCharacterEncoding("UTF-8");
String repoPath = "/okm:root";
String fsPath = "/openkm";
boolean metadata = false;
boolean history = false;
out.println("<ul id=\"breadcrumb\">");
out.println(" <li class=\"path\"><a href=\"repo_export.jsp\">Repository export</a></li>");
out.println("</ul>");
out.println("<br/>");
try {
if (repoPath != null && !repoPath.equals("") && fsPath != null && !fsPath.equals("")) {
out.println("<hr/>");
if (fsPath.startsWith(Config.INSTANCE_CHROOT_PATH)) {
File dir = new File(fsPath);
ContentInfo cInfo = OKMFolder.getInstance().getContentInfo(null, repoPath);
out.println("<b>Files & directories to export:</b> "+(cInfo.getDocuments() + cInfo.getFolders())+"<br/>");
long begin = System.currentTimeMillis();
ImpExpStats stats = RepositoryExporter.exportDocuments(null, repoPath, dir, metadata, history, out,
new HTMLInfoDecorator((int) cInfo.getDocuments() + (int) cInfo.getFolders()));
long end = System.currentTimeMillis();
out.println("<hr/>");
out.println("<div class=\"ok\">Folder '"+repoPath+"' exported to '"+new File(fsPath).getAbsolutePath()+"'</div>");
out.println("<br/>");
out.println("<b>Documents:</b> "+stats.getDocuments()+"<br/>");
out.println("<b>Folders:</b> "+stats.getFolders()+"<br/>");
out.println("<b>Size:</b> "+FormatUtil.formatSize(stats.getSize())+"<br/>");
out.println("<b>Time:</b> "+FormatUtil.formatSeconds(end - begin)+"<br/>");
} else {
out.println("<div class=\"error\">Path out of root: "+Config.INSTANCE_CHROOT_PATH+"<div>");
}
}
} catch (FileNotFoundException e) {
out.println("<div class=\"error\">File Not Found: "+e.getMessage()+"<div>");
} catch (IOException e) {
out.println("<div class=\"error\">IO Error: "+e.getMessage()+"<div>");
} catch (Exception e) {
out.println("<div class=\"error\">Error: "+e.getMessage()+"<div>");
}
%>
</body>
</html>
EDIT: I'm using OpenKM 6.2.1 Build 7659 hosted on Ubuntu 12.04 LTS Desktop. I have tried Chrome, Firefox and IE8.
Thanks,
Mike
