You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@clerezza.apache.org by re...@apache.org on 2015/03/22 13:11:38 UTC
[42/51] [partial] clerezza git commit: CLEREZZA-966: started
hierarchical project structure, moved platform bundles to platform,
only moved RDF artifacts ported to use commons to the rdf folder.
http://git-wip-us.apache.org/repos/asf/clerezza/blob/af0d99b2/platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/DirectoryOverlay.scala
----------------------------------------------------------------------
diff --git a/platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/DirectoryOverlay.scala b/platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/DirectoryOverlay.scala
deleted file mode 100644
index 40bfb21..0000000
--- a/platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/DirectoryOverlay.scala
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * 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.fsadaptor
-
-import org.apache.clerezza.rdf.core.NonLiteral
-import org.apache.clerezza.rdf.core.Resource
-import org.apache.clerezza.rdf.core.Triple
-import org.apache.clerezza.rdf.core.TripleCollection
-import org.apache.clerezza.rdf.core.UriRef
-import org.apache.clerezza.rdf.core.impl.AbstractTripleCollection
-import org.apache.clerezza.rdf.core.impl.SimpleMGraph
-import org.apache.clerezza.utils.IteratorMerger
-import org.wymiwyg.commons.util.dirbrowser.PathNode
-import java.util.Iterator
-
-class DirectoryOverlay(pathNode: PathNode, base: TripleCollection)
- extends AbstractTripleCollection {
-
-
-
- import collection.JavaConversions._
-
-
-
- override def performFilter(s: NonLiteral, p: UriRef,
- o: Resource): Iterator[Triple] = {
- val addedTriples = new SimpleMGraph()
-
- PathNode2MGraph.describeInGraph(pathNode, addedTriples)
-
- val subjects = (for (triple <- addedTriples; subject = triple.getSubject) yield {
- subject
- }).toSet
-
- class FilteringIterator(baseIter: Iterator[Triple]) extends Iterator[Triple] {
- var nextElem: Triple = null
- def prepareNext {
- nextElem = if (baseIter.hasNext) baseIter.next else null
- if ((nextElem != null) &&
- (subjects.contains(nextElem.getSubject))) {
- //println("skipping "+nextElem)
- prepareNext
- }
- }
- prepareNext
-
- override def next = {
- val result = nextElem
- prepareNext
- result
- }
- override def hasNext = nextElem != null
- override def remove = throw new UnsupportedOperationException
- }
-
- new IteratorMerger(new FilteringIterator(base.filter(s, p, o)), addedTriples.filter(s,p, o))
- }
-
- /**
- * returns an upper bound of the size (removals in abse are not deducted)
- */
- override def size = {
- val addedTriples = new SimpleMGraph()
-
- PathNode2MGraph.describeInGraph(pathNode, addedTriples)
-
- base.size+addedTriples.size
- }
-}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/af0d99b2/platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/Logger.scala
----------------------------------------------------------------------
diff --git a/platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/Logger.scala b/platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/Logger.scala
deleted file mode 100644
index 684992a..0000000
--- a/platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/Logger.scala
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.fsadaptor
-
-import org.slf4j.LoggerFactory
-//import org.slf4j.ext.LoggerWrapper
-
-trait Logger {
-
- private val slf4jLogger = LoggerFactory.getLogger(this.getClass)
-// val logger: org.slf4j.Logger = new LoggerWrapper(slf4jLogger, this.getClass.getName)
-
-}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/af0d99b2/platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/PathNode2MGraph.scala
----------------------------------------------------------------------
diff --git a/platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/PathNode2MGraph.scala b/platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/PathNode2MGraph.scala
deleted file mode 100644
index 8a62774..0000000
--- a/platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/PathNode2MGraph.scala
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * 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.fsadaptor;
-
-import java.io.ByteArrayOutputStream
-import javax.ws.rs.core.MediaType
-import org.apache.clerezza.platform.Constants
-import org.apache.clerezza.rdf.core.LiteralFactory
-import org.apache.clerezza.rdf.core.MGraph;
-import org.apache.clerezza.rdf.core.UriRef;
-import org.apache.clerezza.rdf.core.impl.PlainLiteralImpl
-import org.apache.clerezza.rdf.core.impl.TripleImpl
-import org.apache.clerezza.rdf.ontologies.DISCOBITS
-import org.apache.clerezza.rdf.ontologies.HIERARCHY
-import org.apache.clerezza.rdf.ontologies.RDF
-import org.apache.clerezza.rdf.utils.GraphNode
-import org.apache.clerezza.web.fileserver.util.MediaTypeGuesser
-import org.wymiwyg.commons.util.dirbrowser.PathNode
-
-
-/**
- *
- * @author reto
- */
-object PathNode2MGraph {
-
- private val URI_PREFIX = Constants.URN_LOCAL_INSTANCE
-
- private val literalFactory = LiteralFactory.getInstance
-
- private def getMediaType(file: PathNode) = {
- val guessedMediaType: MediaType = MediaTypeGuesser.getInstance().guessTypeForName(file.getPath());
- if (guessedMediaType != null) {
- guessedMediaType.toString
- } else {
- "application/octet-stream"
- }
-
- }
-
- private def getData(file: PathNode) = {
- val baos = new ByteArrayOutputStream
- val in = file.getInputStream()
- val buffer = new Array[Byte](4096)
- var read = in.read(buffer)
- while (read != -1) {
- baos.write(buffer, 0, read)
- read = in.read(buffer)
- }
- in.close()
- baos.toByteArray
- }
-
- def describeInGraph(directory: PathNode, mGraph: MGraph) {
- val basePathLength = directory.getPath.length
- def createUriRef(file: PathNode, isDirectory: Boolean) = {
- def addSlashIfNeeded(s: String) = {
- if (s.endsWith("/")) {
- s
- } else {
- s+'/'
- }
- }
- val path = if (isDirectory) {
- addSlashIfNeeded(file.getPath.substring(basePathLength))
- } else {
- file.getPath.substring(basePathLength)
- }
- new UriRef(URI_PREFIX+path)
- }
- def processDirectory(directory: PathNode) {
- val directoryResource = createUriRef(directory, true)
- mGraph.add(new TripleImpl(directoryResource, RDF.`type`, HIERARCHY.Collection))
- for (subPath <- directory.list) {
- val file = directory.getSubPath(subPath)
- val isDirectory = file.isDirectory
- val resource = createUriRef(file, isDirectory)
- mGraph.add(new TripleImpl(resource, HIERARCHY.parent, directoryResource))
- if (isDirectory) {
- processDirectory(file)
- } else {
- mGraph.add(new TripleImpl(resource, RDF.`type`, DISCOBITS.InfoDiscoBit))
- val data = getData(file)
- mGraph.add(new TripleImpl(resource, DISCOBITS.infoBit, literalFactory.createTypedLiteral(data)))
- mGraph.add(new TripleImpl(resource, DISCOBITS.mediaType,
- literalFactory.createTypedLiteral(getMediaType(file))));
- }
- }
- }
- processDirectory(directory)
- }
-
- def removeNodesFromGraph(directory: PathNode, mGraph: MGraph) {
- val basePathLength = directory.getPath.length
- def createUriRef(file: PathNode, isDirectory: Boolean) = {
- def addSlashIfNeeded(s: String) = {
- if (s.endsWith("/")) {
- s
- } else {
- s+'/'
- }
- }
- val path = if (isDirectory) {
- addSlashIfNeeded(file.getPath.substring(basePathLength))
- } else {
- file.getPath.substring(basePathLength)
- }
- new UriRef(URI_PREFIX+path)
- }
- def processDirectory(directory: PathNode) {
- val directoryResource = createUriRef(directory, true)
- mGraph.remove(new TripleImpl(directoryResource, RDF.`type`, HIERARCHY.Collection))
- for (subPath <- directory.list) {
- val file = directory.getSubPath(subPath)
- val isDirectory = file.isDirectory
- val resource = createUriRef(file, isDirectory)
- val node = new GraphNode(resource, mGraph)
- if (isDirectory) {
- processDirectory(file)
- }
- node.deleteProperties(HIERARCHY.parent)
- node.deleteProperties(RDF.`type`)
- node.deleteProperties(DISCOBITS.infoBit)
- node.deleteProperties(DISCOBITS.mediaType)
- }
- }
- processDirectory(directory)
- }
-}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/af0d99b2/platform.content.imagemetadata/LICENSE
----------------------------------------------------------------------
diff --git a/platform.content.imagemetadata/LICENSE b/platform.content.imagemetadata/LICENSE
deleted file mode 100644
index 261eeb9..0000000
--- a/platform.content.imagemetadata/LICENSE
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- 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.
http://git-wip-us.apache.org/repos/asf/clerezza/blob/af0d99b2/platform.content.imagemetadata/pom.xml
----------------------------------------------------------------------
diff --git a/platform.content.imagemetadata/pom.xml b/platform.content.imagemetadata/pom.xml
deleted file mode 100644
index 6b82b03..0000000
--- a/platform.content.imagemetadata/pom.xml
+++ /dev/null
@@ -1,67 +0,0 @@
-<?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">
-<!--
-
- 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.
-
--->
-
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <artifactId>clerezza</artifactId>
- <groupId>org.apache.clerezza</groupId>
- <version>0.5</version>
- <relativePath>../parent</relativePath>
- </parent>
- <groupId>org.apache.clerezza</groupId>
- <artifactId>platform.content.imagemetadata</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- <packaging>bundle</packaging>
- <name>Clerezza - Platform Content Image Metadata</name>
- <description>Provides a Meta Data Generator that generates metadata for
- images.</description>
- <dependencies>
- <dependency>
- <groupId>org.apache.clerezza</groupId>
- <artifactId>rdf.core</artifactId>
- <version>0.14</version>
- </dependency>
- <dependency>
- <groupId>org.apache.clerezza</groupId>
- <artifactId>rdf.utils</artifactId>
- <version>0.14</version>
- </dependency>
- <dependency>
- <groupId>org.apache.clerezza</groupId>
- <artifactId>utils.imageprocessing</artifactId>
- <version>0.8</version>
- </dependency>
- <dependency>
- <groupId>org.apache.clerezza</groupId>
- <artifactId>rdf.metadata</artifactId>
- <version>0.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.scr.annotations</artifactId>
- </dependency>
- <dependency>
- <groupId>javax.ws.rs</groupId>
- <artifactId>jsr311-api</artifactId>
- </dependency>
- </dependencies>
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/clerezza/blob/af0d99b2/platform.content.imagemetadata/src/main/java/org/apache/clerezza/platform/content/imagemetadata/ImageMetaDataGenerator.java
----------------------------------------------------------------------
diff --git a/platform.content.imagemetadata/src/main/java/org/apache/clerezza/platform/content/imagemetadata/ImageMetaDataGenerator.java b/platform.content.imagemetadata/src/main/java/org/apache/clerezza/platform/content/imagemetadata/ImageMetaDataGenerator.java
deleted file mode 100644
index b49bffc..0000000
--- a/platform.content.imagemetadata/src/main/java/org/apache/clerezza/platform/content/imagemetadata/ImageMetaDataGenerator.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.imagemetadata;
-
-import java.awt.image.BufferedImage;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import javax.ws.rs.core.MediaType;
-import org.apache.clerezza.rdf.core.LiteralFactory;
-import org.apache.clerezza.rdf.metadata.MetaDataGenerator;
-import org.apache.clerezza.rdf.ontologies.EXIF;
-import org.apache.clerezza.rdf.utils.GraphNode;
-import org.apache.clerezza.utils.imageprocessing.ImageReaderService;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.Service;
-
-/**
- * This class generates metadata about image data.
- *
- * @author mir, hasan
- */
-@Component(metatype=true)
-@Service(MetaDataGenerator.class)
-public class ImageMetaDataGenerator implements MetaDataGenerator {
-
- @Reference
- private ImageReaderService imageReaderService;
-
- @Override
- public void generate(GraphNode node, byte[] data, MediaType mediaType) {
-
- if (mediaType.getType().startsWith("image")) {
- try {
- BufferedImage buffImage = imageReaderService.getBufferedImage(
- new ByteArrayInputStream(data));
- node.deleteProperties(EXIF.width);
- node.deleteProperties(EXIF.height);
- node.addProperty(EXIF.width, LiteralFactory.getInstance().
- createTypedLiteral(Integer.valueOf(buffImage.getWidth())));
- node.addProperty(EXIF.height, LiteralFactory.getInstance().
- createTypedLiteral(Integer.valueOf(buffImage.getHeight())));
- } catch (IOException ex) {
- throw new RuntimeException(ex);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/af0d99b2/platform.content.representations/LICENSE
----------------------------------------------------------------------
diff --git a/platform.content.representations/LICENSE b/platform.content.representations/LICENSE
deleted file mode 100644
index 261eeb9..0000000
--- a/platform.content.representations/LICENSE
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- 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.
http://git-wip-us.apache.org/repos/asf/clerezza/blob/af0d99b2/platform.content.representations/platform.content.representations.core/LICENSE
----------------------------------------------------------------------
diff --git a/platform.content.representations/platform.content.representations.core/LICENSE b/platform.content.representations/platform.content.representations.core/LICENSE
deleted file mode 100644
index 261eeb9..0000000
--- a/platform.content.representations/platform.content.representations.core/LICENSE
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- 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.
http://git-wip-us.apache.org/repos/asf/clerezza/blob/af0d99b2/platform.content.representations/platform.content.representations.core/pom.xml
----------------------------------------------------------------------
diff --git a/platform.content.representations/platform.content.representations.core/pom.xml b/platform.content.representations/platform.content.representations.core/pom.xml
deleted file mode 100644
index 996e2a0..0000000
--- a/platform.content.representations/platform.content.representations.core/pom.xml
+++ /dev/null
@@ -1,87 +0,0 @@
-<?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">
-<!--
-
- 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.
-
--->
-
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <artifactId>platform.content.representations</artifactId>
- <groupId>org.apache.clerezza</groupId>
- <version>0.2</version>
- </parent>
- <groupId>org.apache.clerezza</groupId>
- <artifactId>platform.content.representations.core</artifactId>
- <version>1.0.0-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 media types</description>
- <dependencies>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.clerezza</groupId>
- <artifactId>rdf.core</artifactId>
- <version>0.14</version>
- </dependency>
- <dependency>
- <groupId>org.apache.clerezza</groupId>
- <artifactId>rdf.utils</artifactId>
- <version>0.14</version>
- </dependency>
- <dependency>
- <groupId>org.apache.clerezza</groupId>
- <artifactId>rdf.metadata</artifactId>
- <version>0.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.clerezza</groupId>
- <artifactId>jaxrs.utils</artifactId>
- <version>0.9</version>
- </dependency>
- <dependency>
- <groupId>org.apache.clerezza</groupId>
- <artifactId>utils.imageprocessing</artifactId>
- <version>0.8</version>
- </dependency>
- <dependency>
- <groupId>org.apache.clerezza</groupId>
- <artifactId>platform.content</artifactId>
- <version>0.14</version>
- </dependency>
-<!--
- <dependency>
- <groupId>org.apache.clerezza</groupId>
- <artifactId>web.resources.style</artifactId>
- </dependency>
--->
- <dependency>
- <groupId>org.apache.clerezza</groupId>
- <artifactId>platform.content.representations.ontologies</artifactId>
- <version>0.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.scr.annotations</artifactId>
- </dependency>
- </dependencies>
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/clerezza/blob/af0d99b2/platform.content.representations/platform.content.representations.core/src/main/java/org/apache/clerezza/platform/content/representations/core/AlternativeRepresentationGenerator.java
----------------------------------------------------------------------
diff --git a/platform.content.representations/platform.content.representations.core/src/main/java/org/apache/clerezza/platform/content/representations/core/AlternativeRepresentationGenerator.java b/platform.content.representations/platform.content.representations.core/src/main/java/org/apache/clerezza/platform/content/representations/core/AlternativeRepresentationGenerator.java
deleted file mode 100644
index f7e5f57..0000000
--- a/platform.content.representations/platform.content.representations.core/src/main/java/org/apache/clerezza/platform/content/representations/core/AlternativeRepresentationGenerator.java
+++ /dev/null
@@ -1,327 +0,0 @@
-/*
- * 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 java.util.concurrent.locks.Lock;
-import javax.imageio.ImageIO;
-import javax.ws.rs.core.MediaType;
-import org.apache.clerezza.platform.content.DiscobitsHandler;
-import org.apache.clerezza.platform.content.InfoDiscobit;
-import org.apache.clerezza.rdf.core.UriRef;
-import org.apache.clerezza.rdf.metadata.MetaDataGenerator;
-import org.apache.clerezza.rdf.ontologies.DISCOBITS;
-import org.apache.clerezza.rdf.utils.GraphNode;
-import org.apache.clerezza.utils.imageprocessing.ImageProcessor;
-import org.apache.clerezza.utils.imageprocessing.ImageReaderService;
-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;
-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,
- AlternativeRepresentationGenerator.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]);
- }
-
- /**
- * A Resolution with the specified width and height.
- *
- * @param width
- * @param height
- */
- public Resolution(int width, int height) {
- this.width = width;
- this.height = height;
- }
-
- public int getHeight() {
- return height;
- }
-
- public int getWidth() {
- return width;
- }
- }
- final static String EXACT_APPENDIX = "-exact";
-
- @Reference
- private ImageProcessor imageProcessor;
-
- @Reference
- private ImageReaderService imageReaderService;
-
- @Property(value="100x100,200x200", 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";
-
- @Property(value="100x100,200x200", description="Specifies the exact resolutions of alternative" +
- " representations in the format [width]x[height]. Multiple resolutions" +
- " are separated by comma (e.g. 100x100,30x30). The image will be cropped if it has not " +
- "the needed proportions")
- public static final String EXACT_RESOLUTIONS = "exact_resolutions";
-
- private volatile ServiceTracker discobitTracker;
- private Resolution[] resolutions;
- private Resolution[] exactResolutions;
-
- /**
- * 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) {
- resolutions = createResolutionArray((String) context.getProperties().get(RESOLUTIONS));
- exactResolutions = createResolutionArray((String) context.getProperties().get(EXACT_RESOLUTIONS));
- discobitTracker = new ServiceTracker(context.getBundleContext(),
- DiscobitsHandler.class.getName(), null);
- new Thread() {
- @Override
- public void run() {
- discobitTracker.open();
- }
- }.start();
- }
-
- private Resolution[] createResolutionArray(String resolutionsString) {
- String[] resoultionStrings = resolutionsString.split(",");
- Resolution[] resolutionArray = new Resolution[resoultionStrings.length];
- for (int i = 0; i < resoultionStrings.length; i++) {
- resolutionArray[i] = new Resolution(resoultionStrings[i].trim());
- }
- return resolutionArray;
- }
-
- 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")) {
- generateAlternativeImages(data, mediaType, node);
- }
- }
-
- /**
- * Generates an alternative image of the image at the specified infoBitNode.
- * The parameters width and height specify the dimensions the generated
- * image should have. The image will be resized to fit the specified
- * dimensions (height and width of the generated image will be smaller
- * or equals the specified width and height). Returns the URI of the
- * generated image.
- *
- * @param infoBitNode an infoDiscoBit of media type image
- * @param width the width the generated image should have
- * @param height the height the generated image should have
- * @return the URI of the generated image
- */
- public UriRef generateAlternativeImage(GraphNode infoBitNode, int width, int height) {
- return generateAlternativeImage(infoBitNode, width, height, false);
- }
-
- /**
- * Generates an alternative image of the image at the specified infoBitNode.
- * The parameters width and height specify the dimensions the generated
- * image should have. If exact is true, then the generated image will be
- * resized and cropped to match the specified width and height exactly. If
- * exact is false, then the image will be resized to fit the specified
- * dimensions (height and width of the generated image will be smaller
- * or equals the specified width and height). Returns the URI of the
- * generated image.
- *
- * @param infoBitNode an infoDiscoBit of media type image
- * @param width the width the generated image should have
- * @param height the height the generated image should have
- * @param exact specifies if the generated image must have the exact
- * width and height or not.
- * @return the URI of the generated image
- */
- public UriRef generateAlternativeImage(GraphNode infoBitNode, int width, int height,
- boolean exact) {
- try {
- isAltRepresentation.set(Boolean.TRUE);
- InfoDiscobit infoBit = InfoDiscobit.createInstance(infoBitNode);
- BufferedImage buffImage = imageReaderService.getBufferedImage(
- new ByteArrayInputStream(infoBit.getData()));
- return generateAlternativeImage(buffImage, new Resolution(width, height),
- MediaType.valueOf(infoBit.getContentType()), infoBitNode, exact);
- } catch (IOException ex) {
- throw new RuntimeException(ex);
- } finally {
- isAltRepresentation.set(Boolean.FALSE);
- }
- }
-
- private void generateAlternativeImages(byte[] data, MediaType mediaType,
- GraphNode node) throws RuntimeException {
- try {
- isAltRepresentation.set(Boolean.TRUE);
- BufferedImage buffImage = imageReaderService.getBufferedImage(
- new ByteArrayInputStream(data));
- int imgWidth = buffImage.getWidth();
- int imgHeigth = buffImage.getHeight();
- for (Resolution resolution : resolutions) {
- if (imgWidth > resolution.getWidth() || imgHeigth > resolution.getHeight()) {
- generateAlternativeImage(buffImage, resolution, mediaType, node, false);
- }
- }
- for (Resolution resolution : exactResolutions) {
- if (imgWidth > resolution.getWidth() && imgHeigth > resolution.getHeight()) {
- generateAlternativeImage(buffImage, resolution, mediaType, node, true);
- }
- }
- } catch (IOException ex) {
- throw new RuntimeException(ex);
- } finally {
- isAltRepresentation.set(Boolean.FALSE);
- }
- }
-
- private UriRef generateAlternativeImage(BufferedImage buffImage, Resolution resolution,
- MediaType mediaType, GraphNode node, boolean extact) throws IOException {
- BufferedImage alternativeImage;
- if (extact) {
- alternativeImage = resizeAndCrop(resolution, buffImage);
- if (alternativeImage == null) {
- return null;
- }
- } else {
- 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, extact);
- contentHandler.put(thumbnailUri, mediaType, alternativeImageBytes);
- Lock writeLock = node.writeLock();
- writeLock.lock();
- try {
- node.addProperty(DISCOBITS.thumbnail, thumbnailUri);
- return thumbnailUri;
- } finally {
- writeLock.unlock();
- }
- }
-
- private BufferedImage resizeAndCrop(Resolution resolution, BufferedImage buffImage) {
- BufferedImage alternativeImage;
- int imageHeight = 0;
- int imageWidth = 0;
- int widthDiff = buffImage.getWidth() - resolution.getWidth() ;
- int heightDiff = buffImage.getHeight() - resolution.getHeight();
- // resize if both dimension are bigger than the dimensions of the needed resolution
- if (widthDiff >= 0 && heightDiff >= 0) {
- if (widthDiff < heightDiff) {
- imageWidth = resolution.getWidth();
- } else {
- imageHeight = resolution.getHeight();
- }
- alternativeImage = imageProcessor.resizeProportional(buffImage, imageWidth, imageHeight);
- } else {
- return null;
- }
- // crop image to fit exact the resolution
- if (widthDiff < heightDiff) {
- heightDiff = alternativeImage.getHeight() - resolution.getHeight();
- alternativeImage = alternativeImage.getSubimage(0, heightDiff/2, resolution.getWidth(),
- resolution.getHeight());
- } else {
- widthDiff = alternativeImage.getWidth() - resolution.getWidth();
- alternativeImage = alternativeImage.getSubimage(widthDiff/2, 0, resolution.getWidth(),
- resolution.getHeight());
- }
- return alternativeImage;
- }
-
- 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, boolean exact) {
- String resolution = "-" + img.getWidth() + "x" + img.getHeight() + (exact ? EXACT_APPENDIX: "");
- String oldUri = uriRef.getUnicodeString();
- String newUri;
- int lastIndexOfDot = oldUri.lastIndexOf(".");
- int lastIndexOfSlash = oldUri.lastIndexOf("/");
- // 6 characters to keep the extension at the end.
- 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);
- }
-}