+/*
+ * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
+ *
+ * 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.argeo.jcr;
import java.io.IOException;
import java.util.Calendar;
import java.util.List;
-import javax.activation.MimetypesFileTypeMap;
import javax.jcr.Node;
import javax.jcr.Property;
import javax.jcr.RepositoryException;
import javax.jcr.version.VersionHistory;
import javax.jcr.version.VersionIterator;
-import org.apache.commons.io.FilenameUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.argeo.ArgeoException;
import org.springframework.core.io.Resource;
+/**
+ * Bridge Spring resources and JCR folder / files semantics (nt:folder /
+ * nt:file), supporting versioning as well.
+ */
public class JcrResourceAdapter {
private final static Log log = LogFactory.getLog(JcrResourceAdapter.class);
}
public void mkdirs(String path) {
- JcrUtils.mkdirs(session(), path, "nt:folder", versioning);
+ JcrUtils.mkdirs(session(), path, "nt:folder", "nt:folder", versioning);
}
public void create(String path, Resource file, String mimeType) {
try {
if (!session().itemExists(path)) {
- String type = new MimetypesFileTypeMap()
- .getContentType(FilenameUtils.getName(path));
+ String type = null;
+ // FIXME: using javax.activation leads to conflict between Java
+ // 1.5 and 1.6 (since javax.activation was included in Java 1.6)
+ // String type = new MimetypesFileTypeMap()
+ // .getContentType(FilenameUtils.getName(path));
create(path, in, type);
return;
}
protected InputStream fromVersion(Version version)
throws RepositoryException {
Node frozenNode = version.getNode("jcr:frozenNode");
- InputStream in = frozenNode.getNode("jcr:content").getProperty(
- "jcr:data").getStream();
+ InputStream in = frozenNode.getNode("jcr:content")
+ .getProperty("jcr:data").getStream();
return in;
}