SLING-6134 org.apache.sling.samples.jcr.contentloader does not build
move sample to whiteboard
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1764333 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/org.apache.sling.samples.jcr.contentloader/README.md b/org.apache.sling.samples.jcr.contentloader/README.md
deleted file mode 100644
index 314154f..0000000
--- a/org.apache.sling.samples.jcr.contentloader/README.md
+++ /dev/null
@@ -1,4 +0,0 @@
-Sling JCR Content Loader Sample
-===============================
-
-Basic sample to show how to provide a custom content reader and use it instead of the default one for JSON.
diff --git a/org.apache.sling.samples.jcr.contentloader/pom.xml b/org.apache.sling.samples.jcr.contentloader/pom.xml
deleted file mode 100644
index 2a4ec81..0000000
--- a/org.apache.sling.samples.jcr.contentloader/pom.xml
+++ /dev/null
@@ -1,117 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<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/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.sling</groupId>
- <artifactId>sling</artifactId>
- <version>22</version>
- <relativePath/>
- </parent>
-
- <groupId>org.apache.sling.samples</groupId>
- <artifactId>org.apache.sling.samples.jcr.contentloader</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- <packaging>bundle</packaging>
-
- <name>Apache Sling JCR Content Loader Sample</name>
- <description>sample providing custom reader for Sling JCR Content Loader</description>
-
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
- <sling.java.version>7</sling.java.version>
- </properties>
-
- <dependencies>
- <!-- javax -->
- <dependency>
- <groupId>javax.jcr</groupId>
- <artifactId>jcr</artifactId>
- <scope>provided</scope>
- </dependency>
- <!-- OSGi -->
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- <version>4.3.1</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <version>4.3.1</version>
- <scope>provided</scope>
- </dependency>
- <!-- Apache Commons -->
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <version>2.4</version>
- <scope>provided</scope>
- </dependency>
- <!-- Apache Sling -->
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.jcr.contentloader</artifactId>
- <version>2.1.11-SNAPSHOT</version>
- <scope>provided</scope>
- </dependency>
- <!-- Google Gson -->
- <dependency>
- <groupId>com.google.code.gson</groupId>
- <artifactId>gson</artifactId>
- <version>2.3.1</version>
- <scope>provided</scope>
- </dependency>
- <!-- logging -->
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <scope>provided</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>3.1</version>
- <configuration>
- <source>1.7</source>
- <target>1.7</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-scr-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
-
-</project>
diff --git a/org.apache.sling.samples.jcr.contentloader/src/main/java/org/apache/sling/samples/jcr/contentloader/internal/GsonReader.java b/org.apache.sling.samples.jcr.contentloader/src/main/java/org/apache/sling/samples/jcr/contentloader/internal/GsonReader.java
deleted file mode 100644
index efbccad..0000000
--- a/org.apache.sling.samples.jcr.contentloader/src/main/java/org/apache/sling/samples/jcr/contentloader/internal/GsonReader.java
+++ /dev/null
@@ -1,140 +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.sling.samples.jcr.contentloader.internal;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.net.URL;
-import java.nio.charset.StandardCharsets;
-
-import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonObject;
-import org.apache.commons.io.IOUtils;
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Modified;
-import org.apache.felix.scr.annotations.Properties;
-import org.apache.felix.scr.annotations.Property;
-import org.apache.felix.scr.annotations.PropertyUnbounded;
-import org.apache.felix.scr.annotations.Service;
-import org.apache.sling.jcr.contentloader.BaseContentReader;
-import org.apache.sling.jcr.contentloader.ContentCreator;
-import org.apache.sling.jcr.contentloader.ContentReader;
-import org.osgi.framework.Constants;
-import org.osgi.service.component.ComponentContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Component(
- label = "Apache Sling JCR Content Loader Sample GsonReader",
- description = "parses JSON content with Gson",
- immediate = true,
- metatype = true
-)
-@Service
-@Properties({
- @Property(
- name = Constants.SERVICE_VENDOR,
- value = "The Apache Software Foundation"
- ),
- @Property(
- name = Constants.SERVICE_DESCRIPTION,
- value = "Apache Sling JCR Content Loader Sample GsonReader"
- ),
- @Property(
- name = ContentReader.PROPERTY_EXTENSIONS,
- value = {
- "json"
- },
- unbounded = PropertyUnbounded.ARRAY
- ),
- @Property(
- name = ContentReader.PROPERTY_CONTENTTYPES,
- value = {
- "application/json"
- },
- unbounded = PropertyUnbounded.ARRAY
- ),
- @Property(
- name = Constants.SERVICE_RANKING,
- intValue = 1,
- propertyPrivate = false
- )
-})
-public final class GsonReader extends BaseContentReader implements ContentReader {
-
- private GsonBuilder gsonBuilder;
-
- private final Logger logger = LoggerFactory.getLogger(GsonReader.class);
-
- public GsonReader() {
- }
-
- @Activate
- protected void activate(final ComponentContext componentContext) {
- configure(componentContext);
- gsonBuilder = new GsonBuilder();
- }
-
- @Modified
- protected void modified(final ComponentContext componentContext) {
- configure(componentContext);
- }
-
- @Deactivate
- protected void deactivate(final ComponentContext componentContext) {
- extensions = null;
- contentTypes = null;
- gsonBuilder = null;
- }
-
- @Override
- public void parse(final URL url, final ContentCreator contentCreator) throws IOException, RepositoryException {
- InputStream inputStream = null;
- try {
- inputStream = url.openStream();
- parse(inputStream, contentCreator);
- } finally {
- IOUtils.closeQuietly(inputStream);
- }
- }
-
- /**
- * TODO well, implement real parsing...
- */
- @Override
- public void parse(final InputStream inputStream, final ContentCreator contentCreator) throws IOException, RepositoryException {
- final Gson gson = gsonBuilder.create();
- final Reader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
- final JsonObject jsonObject = gson.fromJson(reader, JsonObject.class);
- final String json = jsonObject.toString();
- logger.debug("json: {}", json);
- contentCreator.createNode(null, "nt:unstructured", null);
- contentCreator.createProperty("json", PropertyType.STRING, json);
- contentCreator.finishNode();
- }
-
-}