You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by tr...@apache.org on 2005/06/24 17:44:52 UTC
svn commit: r201632 - in /incubator/jackrabbit/trunk/contrib/jcr-server:
commons/src/java/org/apache/jackrabbit/
server/src/java/org/apache/jackrabbit/server/io/
webdav/src/java/org/apache/jackrabbit/webdav/
Author: tripod
Date: Fri Jun 24 08:44:50 2005
New Revision: 201632
URL: http://svn.apache.org/viewcvs?rev=201632&view=rev
Log:
- adding configurable resource nodetype to FileImportCommand
- fixing unicode escaping problems
- fixing issues with docview/sysview import
Modified:
incubator/jackrabbit/trunk/contrib/jcr-server/commons/src/java/org/apache/jackrabbit/JcrConstants.java
incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/AbstractExportCommand.java
incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/DirListingExportCommand.java
incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/FileImportCommand.java
incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/XMLImportCommand.java
incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java
Modified: incubator/jackrabbit/trunk/contrib/jcr-server/commons/src/java/org/apache/jackrabbit/JcrConstants.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/commons/src/java/org/apache/jackrabbit/JcrConstants.java?rev=201632&r1=201631&r2=201632&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/commons/src/java/org/apache/jackrabbit/JcrConstants.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/commons/src/java/org/apache/jackrabbit/JcrConstants.java Fri Jun 24 08:44:50 2005
@@ -1,5 +1,18 @@
/*
- * Copyright (c) 2005 Your Corporation. All Rights Reserved.
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ * as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.jackrabbit;
Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/AbstractExportCommand.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/AbstractExportCommand.java?rev=201632&r1=201631&r2=201632&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/AbstractExportCommand.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/AbstractExportCommand.java Fri Jun 24 08:44:50 2005
@@ -65,7 +65,7 @@
return false;
}
- Node content = node.getPrimaryNodeType().getName().equals(NT_FILE)
+ Node content = node.isNodeType(NT_FILE)
? node.getNode(JCR_CONTENT)
: node;
if (content.hasProperty(JCR_LASTMODIFIED)) {
Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/DirListingExportCommand.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/DirListingExportCommand.java?rev=201632&r1=201631&r2=201632&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/DirListingExportCommand.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/DirListingExportCommand.java Fri Jun 24 08:44:50 2005
@@ -25,6 +25,8 @@
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.io.FileInputStream;
+import java.io.Writer;
+import java.io.OutputStreamWriter;
import java.util.HashSet;
/**
@@ -127,7 +129,7 @@
String repName = node.getSession().getRepository().getDescriptor(Repository.REP_NAME_DESC);
String repURL = node.getSession().getRepository().getDescriptor(Repository.REP_VENDOR_URL_DESC);
String repVersion = node.getSession().getRepository().getDescriptor(Repository.REP_VERSION_DESC);
- PrintWriter writer = new PrintWriter(out);
+ PrintWriter writer = new PrintWriter(new OutputStreamWriter(out, "utf8"));
writer.print("<html><head><title>");
writer.print(repName);
writer.print(" ");
@@ -167,7 +169,7 @@
context.setInputStream(new FileInputStream(tmpfile));
context.setContentLength(tmpfile.length());
context.setModificationTime(tmpfile.lastModified());
- context.setContentType("text/html");
+ context.setContentType("text/html; charset=utf8");
tmpfile.deleteOnExit();
return true;
Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/FileImportCommand.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/FileImportCommand.java?rev=201632&r1=201631&r2=201632&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/FileImportCommand.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/FileImportCommand.java Fri Jun 24 08:44:50 2005
@@ -21,9 +21,9 @@
import java.util.Calendar;
/**
- * This Class implements an import command that creates a "nt:resource" below
- * the current node and a add the resource data as binary property. It further
- * sets the following properties:
+ * This Class implements an import command that creates a "nt:resource" node or
+ * of any other configured nodetype below the current node and adds the resource
+ * data as binary property. It further sets the following properties:
* <ul>
* <li>jcr:mimeType (from {@link ImportContext#getContentType()})
* <li>jcr:lastModified (from current time)
@@ -33,6 +33,11 @@
public class FileImportCommand extends AbstractImportCommand {
/**
+ * The name of the nodetype for the resource node. Default: nt:resource
+ */
+ private String resourceNodeType = NT_RESOURCE;
+
+ /**
* Imports a resource by creating a new nt:resource node.
*
* @param ctx the import context
@@ -46,7 +51,7 @@
throws Exception {
Node content = parentNode.hasNode(JCR_CONTENT)
? parentNode.getNode(JCR_CONTENT)
- : parentNode.addNode(JCR_CONTENT, NT_RESOURCE);
+ : parentNode.addNode(JCR_CONTENT, resourceNodeType);
content.setProperty(JCR_MIMETYPE, ctx.getContentType());
content.setProperty(JCR_DATA, in);
Calendar lastMod = Calendar.getInstance();
@@ -55,6 +60,15 @@
}
content.setProperty(JCR_LASTMODIFIED, lastMod);
return true;
+ }
+
+ /**
+ * Sets the node type for the resource node.
+ *
+ * @param nodeType nodetype name.
+ */
+ public void setResourceNodeType(String nodeType) {
+ resourceNodeType = nodeType;
}
/**
Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/XMLImportCommand.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/XMLImportCommand.java?rev=201632&r1=201631&r2=201632&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/XMLImportCommand.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/io/XMLImportCommand.java Fri Jun 24 08:44:50 2005
@@ -100,23 +100,24 @@
FileOutputStream out = new FileOutputStream(tmpFile);
byte[] buffer = new byte[8192];
boolean first = true;
- boolean isSysView = false;
+ boolean isGenericXML = true;
int read;
while ((read=in.read(buffer))>0) {
out.write(buffer, 0, read);
if (first) {
first = false;
// could be too less information. is a bit a lazy test
- isSysView = new String(buffer, 0, read).indexOf("<sv:node") >= 0;
+ //isSysView = new String(buffer, 0, read).indexOf("<sv:node") >= 0;
+ isGenericXML = new String(buffer, 0, read).indexOf("jcr:primaryType") < 0;
}
}
out.close();
in.close();
- in = new FileInputStream(tmpFile);
- context.setInputStream(in);
+ context.setInputStream(new FileInputStream(tmpFile));
- if (isSysView) {
- // just import sys view
+ if (!isGenericXML) {
+ // just import sys/doc view
+ in = context.getInputStream();
try {
parentNode.getSession().importXML(parentNode.getPath(), in,
ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING);
@@ -126,23 +127,24 @@
} catch (RepositoryException e) {
// if error occurrs, reset input stream
context.setInputStream(new FileInputStream(tmpFile));
- log.error("Unable to import sysview. will store as normal file: " + e.toString());
+ log.error("Unable to import sys/doc view. will try default xml import: " + e.toString());
parentNode.refresh(false);
} finally {
in.close();
}
+ }
+
+ // check 'file' node
+ in = context.getInputStream();
+ Node fileNode = parentNode.hasNode(context.getSystemId())
+ ? parentNode.getNode(context.getSystemId())
+ : parentNode.addNode(context.getSystemId(), nodeType);
+ if (importResource(context, fileNode, in)) {
+ context.setInputStream(null);
+ // set current node
+ context.setNode(fileNode);
} else {
- // check 'file' node
- Node fileNode = parentNode.hasNode(context.getSystemId())
- ? parentNode.getNode(context.getSystemId())
- : parentNode.addNode(context.getSystemId(), nodeType);
- if (importResource(context, fileNode, in)) {
- context.setInputStream(null);
- // set current node
- context.setNode(fileNode);
- } else {
- context.setInputStream(new FileInputStream(tmpFile));
- }
+ context.setInputStream(new FileInputStream(tmpFile));
}
return false;
}
@@ -180,6 +182,7 @@
parentNode.getSession().importXML(content.getPath(), in, ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
} catch (RepositoryException e) {
// if this fails, we ignore import and pass to next command
+ log.error("Error while importing XML. Will pass to next command: " + e.toString());
if (content.isNew()) {
content.remove();
}
Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java?rev=201632&r1=201631&r2=201632&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java Fri Jun 24 08:44:50 2005
@@ -121,9 +121,10 @@
* @see DavServletRequest#getRequestLocator()
*/
public DavResourceLocator getRequestLocator() {
- String path = getPathInfo();
- if (path == null) {
- path = getServletPath();
+ String path = Text.unescape(getRequestURI());
+ String ctx = getContextPath();
+ if (path.startsWith(ctx)) {
+ path = path.substring(ctx.length());
}
return factory.createResourceLocator(hrefPrefix, path);
}