You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@clerezza.apache.org by mi...@apache.org on 2009/12/22 19:48:51 UTC

svn commit: r893269 - in /incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations: ./ org.apache.clerezza.platform.content.representations.core/ org.apache.clerezza.platform.content.representations.core/src/ org.apach...

Author: mir
Date: Tue Dec 22 18:48:50 2009
New Revision: 893269

URL: http://svn.apache.org/viewvc?rev=893269&view=rev
Log:
CLEREZZA-38: platform.content.representations is now a multimodule project. implemented Thumbnails service

Added:
    incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.core/   (with props)
    incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.core/pom.xml
    incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.core/src/
    incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.core/src/main/
    incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.core/src/main/java/
    incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.core/src/main/java/org/
    incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.core/src/main/java/org/apache/
    incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.core/src/main/java/org/apache/clerezza/
    incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.core/src/main/java/org/apache/clerezza/platform/
    incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.core/src/main/java/org/apache/clerezza/platform/content/
    incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.core/src/main/java/org/apache/clerezza/platform/content/representations/
    incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.core/src/main/java/org/apache/clerezza/platform/content/representations/core/
    incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.core/src/main/java/org/apache/clerezza/platform/content/representations/core/AlternativeRepresentationGenerator.java
    incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.core/src/main/java/org/apache/clerezza/platform/content/representations/core/ThumbnailService.java
    incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.ontologies/   (with props)
    incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.ontologies/pom.xml
    incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.ontologies/src/
    incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.ontologies/src/main/
    incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.ontologies/src/main/resources/
    incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.ontologies/src/main/resources/org/
    incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.ontologies/src/main/resources/org/apache/
    incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.ontologies/src/main/resources/org/apache/clerezza/
    incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.ontologies/src/main/resources/org/apache/clerezza/platform/
    incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.ontologies/src/main/resources/org/apache/clerezza/platform/content/
    incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.ontologies/src/main/resources/org/apache/clerezza/platform/content/representations/
    incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.ontologies/src/main/resources/org/apache/clerezza/platform/content/representations/ontologies/
    incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.ontologies/src/main/resources/org/apache/clerezza/platform/content/representations/ontologies/representations.rdf
Removed:
    incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/src/
Modified:
    incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/pom.xml

Propchange: incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.core/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Dec 22 18:48:50 2009
@@ -0,0 +1 @@
+target

Added: incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.core/pom.xml
URL: http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.core/pom.xml?rev=893269&view=auto
==============================================================================
--- incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.core/pom.xml (added)
+++ incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.core/pom.xml Tue Dec 22 18:48:50 2009
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<artifactId>org.apache.clerezza.platform.content.representations</artifactId>
+		<groupId>org.apache.clerezza</groupId>
+		<version>0.1-incubating-SNAPSHOT</version>
+	</parent>
+	<groupId>org.apache.clerezza</groupId>
+	<artifactId>org.apache.clerezza.platform.content.representations.core</artifactId>
+	<version>0.1-incubating-SNAPSHOT</version>
+	<packaging>bundle</packaging>
+	<name>Clerezza - Platform Content Representations Core</name>
+	<description>Provides a Meta Data Generator that generates alternative
+		representations for data of	various meta types</description>
+	<dependencies>
+		<dependency>
+			<groupId>org.osgi</groupId>
+			<artifactId>org.osgi.compendium</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.clerezza</groupId>
+			<artifactId>org.apache.clerezza.rdf.core</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.clerezza</groupId>
+			<artifactId>org.apache.clerezza.rdf.utils</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.clerezza</groupId>
+			<artifactId>org.apache.clerezza.platform.content</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.clerezza</groupId>
+			<artifactId>org.apache.clerezza.utils.imageprocessing</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.clerezza</groupId>
+			<artifactId>org.apache.clerezza.web.resources.style</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.clerezza</groupId>
+			<artifactId>org.apache.clerezza.platform.content.representations.ontologies</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.felix</groupId>
+			<artifactId>org.apache.felix.scr.annotations</artifactId>
+		</dependency>
+	</dependencies>
+</project>

Added: incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.core/src/main/java/org/apache/clerezza/platform/content/representations/core/AlternativeRepresentationGenerator.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.core/src/main/java/org/apache/clerezza/platform/content/representations/core/AlternativeRepresentationGenerator.java?rev=893269&view=auto
==============================================================================
--- incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.core/src/main/java/org/apache/clerezza/platform/content/representations/core/AlternativeRepresentationGenerator.java (added)
+++ incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.core/src/main/java/org/apache/clerezza/platform/content/representations/core/AlternativeRepresentationGenerator.java Tue Dec 22 18:48:50 2009
@@ -0,0 +1,183 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.clerezza.platform.content.representations.core;
+
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import javax.imageio.ImageIO;
+import javax.ws.rs.core.MediaType;
+import org.apache.clerezza.platform.content.DiscobitsHandler;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.clerezza.utils.imageprocessing.ImageProcessor;
+import org.apache.clerezza.rdf.ontologies.DISCOBITS;
+import org.apache.clerezza.rdf.utils.GraphNode;
+import org.apache.clerezza.platform.content.MetaDataGenerator;
+import org.osgi.service.component.ComponentContext;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * This class provides a method that generates a thumbnail for specified data
+ * if the specified media type is supported. The supported media types are "image/*".
+ * The generated thumbnail is added as a property to the specified
+ * <code>GraphNode</code>. The property URI is
+ * "http://discobits.org/ontology#thumbnail".
+ *
+ * @author mir
+ */
+@Component(metatype=true)
+@Service(MetaDataGenerator.class)
+public class AlternativeRepresentationGenerator implements MetaDataGenerator {
+
+	private static class Resolution {
+
+		private int width;
+
+		private int height;
+		/**
+		 * Takes a String, which contains a resoultion in the format
+		 * [width]x[height].
+		 *
+		 * @param resoulutionString
+		 */
+		public Resolution(String resoulutionString) {
+			String[] widthAndHeight = resoulutionString.split("x");
+			width = new Integer(widthAndHeight[0]);
+			height = new Integer(widthAndHeight[1]);
+		}
+
+		public int getHeight() {
+			return height;
+		}
+
+		public int getWidth() {
+			return width;
+		}
+	}
+
+	@Reference
+	private ImageProcessor imageProcessor;
+	@Property(value="100x100", description="Specifies the resolutions of alternative" +
+			" representations in the format [width]x[height]. Multiple resolutions" +
+			" are separated by comma (e.g. 100x100,30x30)")
+	public static final String RESOLUTIONS = "resolutions";
+	
+	private volatile ServiceTracker discobitTracker;
+	private Resolution[] resolutions;
+
+	/**
+	 * Indicates if data given to the AlternativeRepresentationGenerator is a
+	 * alternative representation itself and therefore does not have to have a
+	 * alternative representation generated for it.
+	 */
+	private ThreadLocal<Boolean> isAltRepresentation = new ThreadLocal<Boolean>() {
+
+		@Override
+		protected Boolean initialValue() {
+			return false;
+		}
+	};
+
+	protected void activate(ComponentContext context) {
+		setupResolutionArray((String) context.getProperties().get(RESOLUTIONS));
+		discobitTracker = new ServiceTracker(context.getBundleContext(),
+				DiscobitsHandler.class.getName(), null);
+		new Thread() {
+			@Override
+			public void run() {
+				discobitTracker.open();
+			}
+		}.start();
+	}
+
+	private void setupResolutionArray(String resolutionsString) {
+		String[] resoultionStrings = resolutionsString.split(",");
+		resolutions = new Resolution[resoultionStrings.length];
+		for (int i = 0; i < resoultionStrings.length; i++) {
+			resolutions[i] = new Resolution(resoultionStrings[i].trim());
+		}
+	}
+
+	protected void deactivate(ComponentContext context) {
+		discobitTracker.close();
+		discobitTracker = null;
+	}
+
+	@Override
+	public void generate(GraphNode node, byte[] data, MediaType mediaType) {
+		if (isAltRepresentation.get()) {
+			return;
+		}
+		if (mediaType.getType().startsWith("image")) {
+			try {
+				isAltRepresentation.set(Boolean.TRUE);
+				BufferedImage buffImage = ImageIO.read(new ByteArrayInputStream(data));
+				int imgWidth = buffImage.getWidth();
+				int imgHeigth = buffImage.getHeight();
+				for (Resolution resolution : resolutions) {
+					if (imgWidth > resolution.getWidth() ||
+							imgHeigth > resolution.getHeight()){
+						BufferedImage alternativeImage = imageProcessor.makeAThumbnail(
+								buffImage, resolution.getWidth(), resolution.getHeight());
+						byte[] alternativeImageBytes = bufferedImage2ByteArray(alternativeImage, mediaType);
+						DiscobitsHandler contentHandler = (DiscobitsHandler)discobitTracker.getService();
+						UriRef thumbnailUri = createThumbnailUri((UriRef) node.getNode(), alternativeImage);
+						contentHandler.put(thumbnailUri, mediaType, alternativeImageBytes);
+						node.addProperty(DISCOBITS.thumbnail, thumbnailUri);
+					}
+				}
+			} catch (IOException ex) {
+				throw new RuntimeException(ex);
+			} finally {
+				isAltRepresentation.set(Boolean.FALSE);
+			}
+		}
+	}
+
+	private byte[] bufferedImage2ByteArray(BufferedImage image,
+			MediaType mediaType) throws IOException {
+		ByteArrayOutputStream baos = new ByteArrayOutputStream();
+		ImageIO.write(image, mediaType.getSubtype(), baos);
+		byte[] bytes = baos.toByteArray();
+		baos.flush();
+		return bytes;
+	}
+
+	private UriRef createThumbnailUri(UriRef uriRef, BufferedImage img) {
+		String resolution = "-" + img.getWidth() + "x" + img.getHeight();
+		String oldUri = uriRef.getUnicodeString();
+		String newUri;
+		int lastIndexOfDot = oldUri.lastIndexOf(".");
+		int lastIndexOfSlash = oldUri.lastIndexOf("/");
+		if (lastIndexOfSlash < lastIndexOfDot &&
+				lastIndexOfDot >= (oldUri.length() - 6)) {
+			String firstPart = oldUri.substring(0, lastIndexOfDot);
+			String lastPart = oldUri.substring(lastIndexOfDot, oldUri.length());
+			newUri = firstPart + resolution + lastPart;
+		} else {
+			newUri = oldUri + resolution;
+		}
+		return new UriRef(newUri);
+	}
+}

Added: incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.core/src/main/java/org/apache/clerezza/platform/content/representations/core/ThumbnailService.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.core/src/main/java/org/apache/clerezza/platform/content/representations/core/ThumbnailService.java?rev=893269&view=auto
==============================================================================
--- incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.core/src/main/java/org/apache/clerezza/platform/content/representations/core/ThumbnailService.java (added)
+++ incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.core/src/main/java/org/apache/clerezza/platform/content/representations/core/ThumbnailService.java Tue Dec 22 18:48:50 2009
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.clerezza.platform.content.representations.core;
+
+import java.net.URI;
+import java.util.Iterator;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import org.apache.clerezza.platform.config.PlatformConfig;
+import org.apache.clerezza.platform.content.representations.ontologies.REPRESENTATIONS;
+import org.apache.clerezza.platform.graphprovider.content.ContentGraphProvider;
+import org.apache.clerezza.rdf.core.InvalidLiteralTypeException;
+import org.apache.clerezza.rdf.core.LiteralFactory;
+import org.apache.clerezza.rdf.core.NoConvertorException;
+import org.apache.clerezza.rdf.core.NonLiteral;
+import org.apache.clerezza.rdf.core.Resource;
+import org.apache.clerezza.rdf.core.TypedLiteral;
+import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.clerezza.rdf.core.impl.TripleImpl;
+import org.apache.clerezza.rdf.ontologies.DISCOBITS;
+import org.apache.clerezza.rdf.ontologies.EXIF;
+import org.apache.clerezza.rdf.utils.GraphNode;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.Service;
+import org.osgi.service.component.ComponentContext;
+
+/**
+ * This JAX-RS resource provides a method to retrieve the uri to
+ * the thumbnail or a other small representation of a InfoDiscoBit.
+ * 
+ * @author mir
+ */
+@Component
+@Service(value = Object.class)
+@Property(name = "javax.ws.rs", boolValue = true)
+@Path("thumbnail-service")
+public class ThumbnailService {
+
+	@Reference
+	ContentGraphProvider cgProvider;
+
+	@Reference
+	PlatformConfig config;
+
+	private UriRef defaultIconUri;
+
+	protected void activate(ComponentContext context) {
+		String baseUri = config.getDefaultBaseUri().getUnicodeString();
+		addMediaTypeIcon(createUriRef(baseUri, "style/images/icons/mediatype/text/plain.png"), MediaType.TEXT_PLAIN);
+		addMediaTypeIcon(createUriRef(baseUri, "style/images/icons/mediatype/application/msword.png"), "application/msword");
+		addMediaTypeIcon(createUriRef(baseUri, "style/images/icons/mediatype/application/x-amf.png"), "application/x-shockwave-flash");
+		addMediaTypeIcon(createUriRef(baseUri, "style/images/icons/mediatype/application/pdf.png"), "application/pdf");
+		addMediaTypeIcon(createUriRef(baseUri, "style/images/icons/mediatype/application/vnd.ms-powerpoint.png"), "application/vnd.ms-powerpoint");
+		addMediaTypeIcon(createUriRef(baseUri, "style/images/icons/mediatype/application/x-tar.png"), "application/x-tar");
+		addMediaTypeIcon(createUriRef(baseUri, "style/images/icons/mediatype/application/x-amf.png"), "application/x-amf");
+		addMediaTypeIcon(createUriRef(baseUri, "style/images/icons/mediatype/application/vnd.ms-excel.png"), "application/vnd.ms-excel");
+		addMediaTypeIcon(createUriRef(baseUri, "style/images/icons/mediatype/application/octet-stream.png"), "application/octet-stream");
+		addMediaTypeIcon(createUriRef(baseUri, "style/images/icons/mediatype/audio/any.png"), "audio/x-wav");
+		addMediaTypeIcon(createUriRef(baseUri, "style/images/icons/mediatype/audio/any.png"), "audio/mpeg");
+		addMediaTypeIcon(createUriRef(baseUri, "style/images/icons/mediatype/audio/any.png"), "audio/mid");
+		defaultIconUri = createUriRef(baseUri, "style/images/icons/mediatype/any.png");
+	}
+
+	private UriRef createUriRef(String baseUri, String relativeUri) {
+		return new UriRef(baseUri + relativeUri);
+	}
+
+	private void addMediaTypeIcon(UriRef icon, String type) {
+		cgProvider.getContentGraph().add(
+				new TripleImpl(icon, REPRESENTATIONS.isIconFor ,
+				LiteralFactory.getInstance().createTypedLiteral(type)));
+	}
+
+	/**
+	 * Returns the thumbnail uri for a specified InfoDiscoBit. If no thumbnail
+	 * is available then the uri of the icon representing the media type is
+	 * returned. If also no media type icon is available the uri to default
+	 * icon is returned.
+	 * @param infoBitUri
+	 * @return
+	 */
+	@GET
+	public Response getThumbnailUri(@QueryParam("uri") UriRef infoBitUri,
+			@QueryParam("width") Integer width,
+			@QueryParam("height") Integer height) {		
+		if (width == null) {
+			width = Integer.MAX_VALUE;
+		}
+		if (height == null) {
+			height = Integer.MAX_VALUE;
+		}
+		GraphNode infoBitNode = new GraphNode(infoBitUri, cgProvider.getContentGraph());
+		UriRef thumbnailUri = getThumbnailUri(infoBitNode, height, width);
+		if (thumbnailUri != null) {
+			return Response.seeOther(
+					URI.create((thumbnailUri).getUnicodeString())).build();
+		}		
+		Iterator<Resource> mediaTypes = infoBitNode.getObjects(DISCOBITS.mediaType);
+		if (mediaTypes.hasNext()) {
+			GraphNode mediaType = new GraphNode(mediaTypes.next(), 
+					cgProvider.getContentGraph());
+			
+			Iterator<NonLiteral> icons = mediaType.getSubjects(REPRESENTATIONS.isIconFor);
+			if (icons.hasNext()) {
+				return Response.seeOther(
+					URI.create(((UriRef)icons.next()).getUnicodeString())).build();
+			}
+		}
+		return Response.seeOther(URI.create(defaultIconUri.getUnicodeString())).build();
+	}
+
+	private UriRef getThumbnailUri(GraphNode infoBitNode, Integer height,
+			Integer width) {
+		UriRef resultThumbnailUri = null;
+		int pixels = 0;
+		Iterator<Resource> thumbnails = infoBitNode.getObjects(DISCOBITS.thumbnail);
+		while (thumbnails.hasNext()) {
+			UriRef thumbnailUri = (UriRef) thumbnails.next();
+			GraphNode thumbnailNode = new GraphNode(thumbnailUri, 
+					cgProvider.getContentGraph());
+			Integer thumbnailWidth = LiteralFactory.getInstance().createObject(
+					Integer.class, (TypedLiteral) thumbnailNode.getObjects(EXIF.width).next());
+			Integer thumbnailHeight = LiteralFactory.getInstance().createObject(
+					Integer.class, (TypedLiteral) thumbnailNode.getObjects(EXIF.height).next());
+			int thumbnailPixels = thumbnailWidth * thumbnailHeight;
+			if (thumbnailHeight <= height && thumbnailWidth <= width && thumbnailPixels > pixels) {
+				resultThumbnailUri = thumbnailUri;
+				pixels = thumbnailPixels;
+			}
+		}
+		return resultThumbnailUri;
+	}
+}
\ No newline at end of file

Propchange: incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.ontologies/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Dec 22 18:48:50 2009
@@ -0,0 +1 @@
+target

Added: incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.ontologies/pom.xml
URL: http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.ontologies/pom.xml?rev=893269&view=auto
==============================================================================
--- incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.ontologies/pom.xml (added)
+++ incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.ontologies/pom.xml Tue Dec 22 18:48:50 2009
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<groupId>org.apache.clerezza</groupId>
+		<artifactId>org.apache.clerezza.platform.content.representations</artifactId>
+		<version>0.1-incubating-SNAPSHOT</version>
+	</parent>
+	<groupId>org.apache.clerezza</groupId>
+	<artifactId>org.apache.clerezza.platform.content.representations.ontologies</artifactId>
+	<version>0.1-incubating-SNAPSHOT</version>
+	<packaging>bundle</packaging>
+	<name>Clerezza - Platform Content Representations Ontologies</name>
+	<description>
+		Representations Ontologies
+	</description>
+	<dependencies>
+		<dependency>
+			<groupId>org.apache.clerezza</groupId>
+			<artifactId>org.apache.clerezza.rdf.core</artifactId>
+		</dependency>
+	</dependencies>
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.clerezza</groupId>
+				<artifactId>org.apache.clerezza.maven-ontologies-plugin</artifactId>
+				<executions>
+					<execution>
+						<phase>generate-sources</phase>
+						<configuration>
+							<resourcePath>${basedir}/src/main/resources</resourcePath>
+							<sources>
+								<source>${basedir}/target/generated-sources/main/java</source>
+							</sources>
+						</configuration>
+						<goals>
+							<goal>generate</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+		</plugins>
+	</build>
+</project>

Added: incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.ontologies/src/main/resources/org/apache/clerezza/platform/content/representations/ontologies/representations.rdf
URL: http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.ontologies/src/main/resources/org/apache/clerezza/platform/content/representations/ontologies/representations.rdf?rev=893269&view=auto
==============================================================================
--- incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.ontologies/src/main/resources/org/apache/clerezza/platform/content/representations/ontologies/representations.rdf (added)
+++ incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/org.apache.clerezza.platform.content.representations.ontologies/src/main/resources/org/apache/clerezza/platform/content/representations/ontologies/representations.rdf Tue Dec 22 18:48:50 2009
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<rdf:RDF
+	xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+	xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
+	xmlns:owl="http://www.w3.org/2002/07/owl#"
+	xmlns:dc="http://purl.org/dc/elements/1.1/"
+	xmlns:skos="http://www.w3.org/2008/05/skos#"
+>
+
+<!-- Ontology -->
+
+<owl:Ontology rdf:about="http://clerezza.org/2009/12/representations#">
+	<owl:versionInfo>Revision: 0.1</owl:versionInfo>
+	<dc:title xml:lang="en">
+		Clerezza Content Representations
+	</dc:title>
+</owl:Ontology>
+
+
+<!-- Properties -->
+
+<rdf:Property rdf:about="http://clerezza.org/2009/12/representations#isIconFor">
+	<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#ObjectProperty" />
+	<rdfs:label xml:lang="en">is icon for</rdfs:label>
+	<skos:definition xml:lang="en">Points to a string of which the subject is a icon for.</skos:definition>
+	<rdfs:isDefinedBy rdf:resource="http://clerezza.org/2009/11/globalMenu#" />
+	<rdfs:domain rdf:resource="http://xmlns.com/foaf/0.1/Image" />
+	<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string" />
+</rdf:Property>
+</rdf:RDF>
+

Modified: incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/pom.xml
URL: http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/pom.xml?rev=893269&r1=893268&r2=893269&view=diff
==============================================================================
--- incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/pom.xml (original)
+++ incubator/clerezza/issues/CLEREZZA-38/org.apache.clerezza.platform.content.representations/pom.xml Tue Dec 22 18:48:50 2009
@@ -1,45 +1,19 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<?xml version="1.0" encoding="UTF-8" standalone="no"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 	<modelVersion>4.0.0</modelVersion>
 	<parent>
-		<artifactId>org.apache.clerezza.parent</artifactId>
 		<groupId>org.apache.clerezza</groupId>
+		<artifactId>org.apache.clerezza.parent</artifactId>
 		<version>0.2-incubating-SNAPSHOT</version>
 	</parent>
 	<groupId>org.apache.clerezza</groupId>
 	<artifactId>org.apache.clerezza.platform.content.representations</artifactId>
+	<packaging>pom</packaging>
 	<version>0.1-incubating-SNAPSHOT</version>
-	<packaging>bundle</packaging>
-	<name>Clerezza - Platform Content Representations</name>
-	<description>Provides a Meta Data Generator that generates alternative
-		representations for data of	various meta types</description>
-	<dependencies>
-		<dependency>
-			<groupId>org.osgi</groupId>
-			<artifactId>org.osgi.core</artifactId>
-		</dependency>
-		<dependency>
-			<groupId>org.osgi</groupId>
-			<artifactId>org.osgi.compendium</artifactId>
-		</dependency>
-		<dependency>
-			<groupId>org.apache.clerezza</groupId>
-			<artifactId>org.apache.clerezza.rdf.core</artifactId>
-		</dependency>
-		<dependency>
-			<groupId>org.apache.clerezza</groupId>
-			<artifactId>org.apache.clerezza.rdf.utils</artifactId>
-		</dependency>
-		<dependency>
-			<groupId>org.apache.clerezza</groupId>
-			<artifactId>org.apache.clerezza.platform.content</artifactId>
-		</dependency>
-		<dependency>
-			<groupId>org.apache.clerezza</groupId>
-			<artifactId>org.apache.clerezza.utils.imageprocessing</artifactId>
-		</dependency>
-		<dependency>
-			<groupId>org.apache.felix</groupId>
-			<artifactId>org.apache.felix.scr.annotations</artifactId>
-		</dependency>
-	</dependencies>
+	<name>Clerezza - Platform Representations</name>
+	<description>Provides services for creating and retrieving alternative representations of content.</description>
+	
+	<modules>
+		<module>org.apache.clerezza.platform.content.representations.ontologies</module>
+		<module>org.apache.clerezza.platform.content.representations.core</module>
+	</modules>
 </project>