Skip to content

Commit

Permalink
Merge branch 'MODE-1337' of https://github.com/hchiorean/modeshape in…
Browse files Browse the repository at this point in the history
…to hchiorean-MODE-1337
  • Loading branch information
rhauch committed Jan 18, 2012
2 parents 728f3eb + 2c76c5e commit c71985b
Show file tree
Hide file tree
Showing 249 changed files with 21,853 additions and 349 deletions.
13 changes: 0 additions & 13 deletions modeshape-jcr-api/pom.xml
Expand Up @@ -49,19 +49,6 @@

<build>
<plugins>
<!-- Specify the compiler options and settings -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.plugin.version}</version>
<configuration>
<source>${java.version.jcr.graph}</source>
<target>${java.version.jcr.graph}</target>
<showDeprecation>false</showDeprecation>
<showWarnings>false</showWarnings>
</configuration>
</plugin>

<!--
Adding OSGI metadata to the JAR without changing the packaging type.
-->
Expand Down
Expand Up @@ -35,6 +35,7 @@ public final class JcrConstants {
public static final String JCR_DATA = "jcr:data";
public static final String JCR_MIXIN_TYPES = "jcr:mixinTypes";
public static final String JCR_PRIMARY_TYPE = "jcr:primaryType";
public static final String JCR_MIME_TYPE = "jcr:mimeType";

public static final String NT_UNSTRUCTURED = "nt:unstructured";

Expand Down
@@ -0,0 +1,54 @@
/*
* ModeShape (http://www.modeshape.org)
* See the COPYRIGHT.txt file distributed with this work for information
* regarding copyright ownership. Some portions may be licensed
* to Red Hat, Inc. under one or more contributor license agreements.
* See the AUTHORS.txt file in the distribution for a full listing of
* individual contributors.
*
* ModeShape is free software. Unless otherwise indicated, all code in ModeShape
* is licensed to you under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* ModeShape is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org
*/
package org.modeshape.jcr.api;

import javax.jcr.Value;
import javax.jcr.ValueFormatException;
import java.util.Date;

/**
* Extension of the standard {@link javax.jcr.ValueFactory} which allows conversion to the jcr {@link Value} from additional
* types.
*
* @author Horia Chiorean
*/
public interface ValueFactory extends javax.jcr.ValueFactory {

/**
* Creates a JCR compatible {@link Value} from a {@link Date} instance.
*
* @param value a non-null date instance
* @return a JCR value
* @throws ValueFormatException if the given value cannot be converted
*/
public Value createValue( Date value ) throws ValueFormatException;

/**
* Creates a JCR {@link Binary} value from the given byte array.
*
* @param value a non-null byte array
* @return a Binary implementation instance
*/
public Binary createBinary( byte[] value );
}
@@ -0,0 +1,124 @@
/*
* ModeShape (http://www.modeshape.org)
* See the COPYRIGHT.txt file distributed with this work for information
* regarding copyright ownership. Some portions may be licensed
* to Red Hat, Inc. under one or more contributor license agreements.
* See the AUTHORS.txt file in the distribution for a full listing of
* individual contributors.
*
* ModeShape is free software. Unless otherwise indicated, all code in ModeShape
* is licensed to you under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* ModeShape is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org
*/
package org.modeshape.jcr.api.mimetype;

/**
* Class used to hold a series of mime-type constants
*
* @author Horia Chiorean
*/
public final class MimeTypeConstants {
private MimeTypeConstants() {
}

public static final String TEXT_PLAIN = "text/plain";
public static final String RTF = "text/rtf";
public static final String XML = "text/xml";
public static final String HTML = "text/html";

public static final String MP3 = "audio/mpeg";
public static final String WAV = "audio/x-wav";
public static final String AU = "audio/basic";
public static final String OGG = "application/x-ogg";

public static final String FLI = "video/x-fli";
public static final String BMP = "image/bmp";
public static final String GIF = "image/gif";
public static final String ICON = "image/x-icon";
public static final String JPEG = "image/jpeg";
public static final String PORTABLE_PIXMAP = "image/x-portable-pixmap";
public static final String PNG = "image/png";
public static final String TIFF = "image/tiff";
public static final String TGA = "image/x-tga";
public static final String WMF= "image/wmf";
public static final String XCF= "image/xcf";
public static final String XPM= "image/xpm";
public static final String PHOTOSHOP = "image/vnd.adobe.photoshop";
public static final String PCX = "image/x-pcx";

public static final String JAVA = "text/java";
public static final String JAVA_CLASS = "application/x-java-class";
public static final String JAR = "application/java-archive";
public static final String JAR_MANIFEST = "application/x-java-manifest";

public static final String PDF = "application/pdf";
public static final String POSTSCRIPT = "application/postscript";

public static final String GZIP = "application/gzip";
public static final String ZIP = "application/zip";
public static final String LZW = "application/x-compress";
public static final String TAR = "application/x-tar";


public static final String BASH = "application/x-bash";
public static final String SH = "application/x-sh";

public static final String OPEN_DOC_FORMULA = "application/vnd.oasis.opendocument.formula";
public static final String OPEN_DOC_GRAPHICS = "application/vnd.oasis.opendocument.graphics";
public static final String OPEN_DOC_GRAPHICS_TEMPLATE = "application/vnd.oasis.opendocument.graphics-template";
public static final String OPEN_DOC_PRESENTATION = "application/vnd.oasis.opendocument.presentation";
public static final String OPEN_DOC_PRESENTATION_TEMPLATE = "application/vnd.oasis.opendocument.presentation-template";
public static final String OPEN_DOC_SPREADSHEET = "application/vnd.oasis.opendocument.spreadsheet";
public static final String OPEN_DOC_SPREADSHEET_TEMPLATE = "application/vnd.oasis.opendocument.spreadsheet-template";
public static final String OPEN_DOC_TEXT = "application/vnd.oasis.opendocument.text";
public static final String OPEN_DOC_TEXT_TEMPLATE = "application/vnd.oasis.opendocument.text-template";

public static final String OPEN_OFFICE_CALC = "application/vnd.sun.xml.calc";
public static final String OPEN_OFFICE_CALC_TEMPLATE = "application/vnd.sun.xml.calc.template";
public static final String OPEN_OFFICE_DRAW = "application/vnd.sun.xml.draw";
public static final String OPEN_OFFICE_DRAW_TEMPLATE = "application/vnd.sun.xml.draw.template";
public static final String OPEN_OFFICE_IMPRESS = "application/vnd.sun.xml.impress";
public static final String OPEN_OFFICE_IMPRESS_TEMPLATE = "application/vnd.sun.xml.impress.template";
public static final String OPEN_OFFICE_WRITER = "application/vnd.sun.xml.writer";
public static final String OPEN_OFFICE_WRITER_TEMPLATE = "application/vnd.sun.xml.writer.template";

public static final String STAR_OFFICE_CALC = "application/vnd.stardivision.calc";
public static final String STAR_OFFICE_DRAW = "application/vnd.stardivision.draw";
public static final String STAR_OFFICE_IMPRESS = "application/vnd.stardivision.impress";
public static final String STAR_OFFICE_WRITER = "application/vnd.stardivision.writer";

public static final String MICROSOFT_OFFICE = "application/vnd.ms-office";
public static final String MICROSOFT_WORD = "application/vnd.ms-word";
public static final String MICROSOFT_OFFICE_DOCUMENT_OPENXML = "application/vnd.openxmlformats-officedocument.wordprocessingml";
public static final String MICROSOFT_WORKS = "application/vnd.ms-works";
public static final String MICROSOFT_EXCEL = "application/vnd.ms-excel";
public static final String MICROSOFT_EXCEL_OPENXML = "application/vnd.openxmlformats-officedocument.spreadsheetml";
public static final String MICROSOFT_POWERPOINT_OPENXML = "application/vnd.openxmlformats-officedocument.presentationml";
public static final String MICROSOFT_POWERPOINT = "application/vnd.ms-powerpoint";
public static final String MICROSOFT_PUBLISHER = "application/x-mspublisher";
public static final String MICROSOFT_VISIO = "application/vnd.visio";
public static final String MICROSOFT_OUTLOOK = "application/vnd.ms-outlook";

public static final String COREL_PRESENTATION = "application/presentations";
public static final String COREL_QUATTRO_SPREADSHEET = "application/wb2";
public static final String COREL_QUATTRO_PRO = "application/x-quattropro";
public static final String COREL_WORD_PERFECT = "application/vnd.wordperfect";

public static final String MESSAGE_RFC = "message/rfc822";
public static final String MOZILLA_ADDRESS_BOOK = "application/x-mozilla-addressbook";
public static final String VCARD = "text/x-vcard";
public static final String CALENDAR = "text/calendar";

public static final String OCTET_STREAM = "application/octet-stream";
}
Expand Up @@ -21,32 +21,33 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.modeshape.jcr.core.mimetype;
package org.modeshape.jcr.api.mimetype;

import java.io.IOException;
import java.io.InputStream;
import org.modeshape.common.annotation.ThreadSafe;

/**
* MIME-type detection libraries must provide thread-safe implementations of this interface to enable ModeShape to use the
* libraries to return MIME-types for data sources.
*
* Implementors are expected to have a public, no-arg constructor.
*/
@ThreadSafe

public interface MimeTypeDetector {

/**
* Returns the MIME-type of a data source, using its supplied content and/or its supplied name, depending upon the
* implementation. If the MIME-type cannot be determined, either a "default" MIME-type or <code>null</code> may be returned,
* where the former will prevent earlier registered MIME-type detectors from being consulted.
* <p>
* Note that detector implementations should <i>not</i> {@link InputStream#close() close} the supplied input stream.
* Note that detector implementations should <i>not</i> {@link InputStream#close() close} the supplied input stream and should
* try their best to {@link java.io.InputStream#reset() reset} the stream.
* </p>
*
* @param name The name of the data source; may be <code>null</code>.
* @param content The content of the data source; may be <code>null</code>.
* @return The MIME-type of the data source, or optionally <code>null</code> if the MIME-type could not be determined.
* @throws IOException If an error occurs reading the supplied content.
*/
String mimeTypeOf( String name,
InputStream content ) throws IOException;
String mimeTypeOf( String name, InputStream content ) throws IOException;
}
Expand Up @@ -30,6 +30,7 @@
import java.util.List;
import javax.jcr.*;
import javax.jcr.nodetype.NodeTypeExistsException;
import org.modeshape.jcr.api.mimetype.MimeTypeDetector;
import org.modeshape.jcr.api.nodetype.NodeTypeManager;

/**
Expand Down Expand Up @@ -221,6 +222,22 @@ public interface Context {
* @return timestamp the "current" timestamp; never null
*/
Calendar getTimestamp();


/**
* Returns a {@link org.modeshape.jcr.api.ValueFactory} instance which can be used to perform additional type conversions,
* from what {@link javax.jcr.ValueFactory} offers
*
* @return a non-null value factory, using the output node's session as context
*/
org.modeshape.jcr.api.ValueFactory valueFactory();

/**
* Returns a {@link MimeTypeDetector} implementation which can be used to determine content mime-type.
*
* @return a non-null value, using the output node's session as context
*/
MimeTypeDetector mimeTypeDetector();
}

}

0 comments on commit c71985b

Please sign in to comment.