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/04/14 15:12:44 UTC
[09/87] [abbrv] [partial] clerezza git commit: CLEREZZA-966: removed
platform. prefix of folder names
http://git-wip-us.apache.org/repos/asf/clerezza/blob/70220239/platform/platform.concepts/LICENSE
----------------------------------------------------------------------
diff --git a/platform/platform.concepts/LICENSE b/platform/platform.concepts/LICENSE
deleted file mode 100644
index 261eeb9..0000000
--- a/platform/platform.concepts/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/70220239/platform/platform.concepts/README.txt
----------------------------------------------------------------------
diff --git a/platform/platform.concepts/README.txt b/platform/platform.concepts/README.txt
deleted file mode 100644
index 9edd812..0000000
--- a/platform/platform.concepts/README.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-JAX-RS resource called GenericResourcePage can be used to retrieve a resource and its associated concepts.
-Go to http://[your.server]/concepts/generic-resource?uri=[resource] where [resource]
-specifies the UriRef of the resource. Furthermore there is a JAX-RS resource called ResourceTagger
- for associating concepts with resources. POST to http://[your.server]/concepts/tagger/set a form
-with form parameter uri which specifies the UriRef of the resource and a form parameter
-concepts which contains the UriRefs of the concepts.
-
-JAX-RS resource called ConceptManipulator can be used to add concept into the content graph
-The resource path is "/concepts/manipulator/add-concept" and the form parameters are
-pref-label, lang, and comment.
-
-On the client side there is a ConceptManipulator widget to add free concepts to the content graph
-and there is also a ConceptFinder widget to find exisiting concepts to be suggested for a specified search term.
-
-In ConceptManipulator widget and ConceptFinder widget a developer can register a callback function
-which is called when a concept is added to the list of selected concept.
-
-
http://git-wip-us.apache.org/repos/asf/clerezza/blob/70220239/platform/platform.concepts/platform.concepts.core/LICENSE
----------------------------------------------------------------------
diff --git a/platform/platform.concepts/platform.concepts.core/LICENSE b/platform/platform.concepts/platform.concepts.core/LICENSE
deleted file mode 100644
index 261eeb9..0000000
--- a/platform/platform.concepts/platform.concepts.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/70220239/platform/platform.concepts/platform.concepts.core/pom.xml
----------------------------------------------------------------------
diff --git a/platform/platform.concepts/platform.concepts.core/pom.xml b/platform/platform.concepts/platform.concepts.core/pom.xml
deleted file mode 100644
index 579930a..0000000
--- a/platform/platform.concepts/platform.concepts.core/pom.xml
+++ /dev/null
@@ -1,111 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?><!--
-
- 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/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.clerezza</groupId>
- <artifactId>platform.concepts</artifactId>
- <version>0.2</version>
- </parent>
- <groupId>org.apache.clerezza</groupId>
- <artifactId>platform.concepts.core</artifactId>
- <packaging>bundle</packaging>
- <version>1.0.0-SNAPSHOT</version>
- <name>Clerezza - Platform Concepts Core</name>
- <description>The core part of Platform Concepts</description>
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>javax.ws.rs</groupId>
- <artifactId>jsr311-api</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.ontologies</artifactId>
- <version>0.12</version>
- </dependency>
- <dependency>
- <groupId>org.apache.clerezza</groupId>
- <artifactId>rdf.utils</artifactId>
- <version>0.14</version>
- </dependency>
- <dependency>
- <groupId>org.apache.clerezza</groupId>
- <artifactId>platform.concepts.ontologies</artifactId>
- <version>0.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.clerezza</groupId>
- <artifactId>platform.graphprovider.content</artifactId>
- <version>0.7</version>
- </dependency>
- <dependency>
- <groupId>org.apache.clerezza</groupId>
- <artifactId>platform.typerendering.core</artifactId>
- <version>0.3</version>
- </dependency>
- <dependency>
- <groupId>org.apache.clerezza</groupId>
- <artifactId>platform.typerendering.scalaserverpages</artifactId>
- <version>0.4</version>
- </dependency>
- <dependency>
- <groupId>org.apache.clerezza</groupId>
- <artifactId>jaxrs.utils</artifactId>
- <version>0.9</version>
- </dependency>
- <dependency>
- <groupId>org.apache.clerezza</groupId>
- <artifactId>platform.config</artifactId>
- <version>0.4</version>
- </dependency>
- <dependency>
- <groupId>org.apache.clerezza</groupId>
- <artifactId>platform.globalmenu.api</artifactId>
- <version>0.3</version>
- </dependency>
- <dependency>
- <groupId>org.apache.clerezza</groupId>
- <artifactId>permissiondescriptions</artifactId>
- <version>0.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.clerezza</groupId>
- <artifactId>web.fileserver</artifactId>
- <scope>compile</scope>
- <version>0.10</version>
- </dependency>
- <dependency>
- <groupId>org.apache.wink</groupId>
- <artifactId>wink-common</artifactId>
- <version>1.2.1-incubating</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/clerezza/blob/70220239/platform/platform.concepts/platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/ConceptCache.java
----------------------------------------------------------------------
diff --git a/platform/platform.concepts/platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/ConceptCache.java b/platform/platform.concepts/platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/ConceptCache.java
deleted file mode 100644
index 25409bc..0000000
--- a/platform/platform.concepts/platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/ConceptCache.java
+++ /dev/null
@@ -1,285 +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.concepts.core;
-
-import java.util.Date;
-import java.util.Iterator;
-import org.apache.clerezza.platform.concepts.ontologies.CONCEPTS;
-import org.apache.clerezza.rdf.core.BNode;
-import org.apache.clerezza.rdf.core.Graph;
-import org.apache.clerezza.rdf.core.Literal;
-import org.apache.clerezza.rdf.core.LiteralFactory;
-import org.apache.clerezza.rdf.core.MGraph;
-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.TypedLiteral;
-import org.apache.clerezza.rdf.core.UriRef;
-import org.apache.clerezza.rdf.core.access.NoSuchEntityException;
-import org.apache.clerezza.rdf.core.access.TcManager;
-import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
-import org.apache.clerezza.rdf.core.impl.TripleImpl;
-import org.apache.clerezza.rdf.ontologies.DC;
-import org.apache.clerezza.rdf.ontologies.OWL;
-import org.apache.clerezza.rdf.ontologies.RDF;
-import org.apache.clerezza.rdf.ontologies.RDFS;
-import org.apache.clerezza.rdf.ontologies.SKOS;
-import org.apache.clerezza.rdf.utils.GraphNode;
-
-/**
- * This class manages caches of SPARQL query results against a specific EndPoint
- * and Graph.
- *
- * @author hasan
- */
-class ConceptCache {
- private UriRef sparqlEndPoint;
- private UriRef defaultGraph;
- private UriRef CONCEPT_CACHE_MGRAPH = new UriRef("urn:x-localinstance:/concept.cache");
-
- /**
- * Constructs a {@link ConceptCache} for the specified SPARQL EndPoint and
- * Graph.
- *
- * @param sparqlEndPoint
- * the SPARQL EndPoint used in the query.
- * @param defaultGraph
- * the Graph against which the query was executed.
- *
- */
- public ConceptCache(UriRef sparqlEndPoint, UriRef defaultGraph) {
- this.sparqlEndPoint = sparqlEndPoint;
- this.defaultGraph = defaultGraph;
- }
-
- /**
- * Caches the query results available in the specified Graph under a
- * particular search term.
- *
- * @param searchTerm
- * the term used for querying concepts.
- * @param parsedGraph
- * the Graph which contains query results.
- */
- void cache(String searchTerm, Graph parsedGraph) {
- MGraph conceptCacheMGraph = getConceptCacheMGraph();
- NonLiteral conceptCacheNode = getConceptCacheNode(conceptCacheMGraph);
- if (conceptCacheNode != null) {
- removeCachedConcepts(searchTerm, conceptCacheNode, conceptCacheMGraph);
- }
- addCacheEntry(searchTerm, conceptCacheNode, conceptCacheMGraph,
- parsedGraph);
- }
-
- private MGraph getConceptCacheMGraph() {
- MGraph conceptCacheMGraph = null;
- TcManager tcManager = TcManager.getInstance();
- try {
- conceptCacheMGraph = tcManager.getMGraph(CONCEPT_CACHE_MGRAPH);
- } catch (NoSuchEntityException nsee) {
- conceptCacheMGraph = tcManager.createMGraph(CONCEPT_CACHE_MGRAPH);
- }
- return conceptCacheMGraph;
- }
-
- private NonLiteral getConceptCacheNode(MGraph conceptCacheMGraph) {
- Iterator<Triple> conceptCaches = conceptCacheMGraph.filter(
- null, RDF.type, CONCEPTS.ConceptCache);
- while (conceptCaches.hasNext()) {
- NonLiteral conceptCacheNode = conceptCaches.next().getSubject();
- if (!conceptCacheMGraph.filter(conceptCacheNode,
- CONCEPTS.sparqlEndPoint, sparqlEndPoint).hasNext()) {
- continue;
- }
- if (defaultGraph != null) {
- if (!conceptCacheMGraph.filter(conceptCacheNode,
- CONCEPTS.defaultGraph, defaultGraph).hasNext()) {
- continue;
- }
- }
- return conceptCacheNode;
- }
- return null;
- }
-
- private void removeCachedConcepts(String searchTerm,
- NonLiteral conceptCacheNode, MGraph conceptCacheMGraph) {
- NonLiteral conceptCacheEntryNode = getConceptCacheEntryNode(
- searchTerm, conceptCacheNode, conceptCacheMGraph);
- if (conceptCacheEntryNode == null) {
- return;
- }
- GraphNode conceptCacheEntryGraphNode = new GraphNode(
- conceptCacheEntryNode, conceptCacheMGraph);
- removeCachedConcepts(conceptCacheEntryGraphNode);
- conceptCacheMGraph.remove(new TripleImpl(conceptCacheNode,
- CONCEPTS.cacheEntry, conceptCacheEntryNode));
- }
-
- private NonLiteral getConceptCacheEntryNode(String searchTerm,
- NonLiteral conceptCacheNode, MGraph conceptCacheMGraph) {
- TypedLiteral searchLiteral = LiteralFactory.getInstance()
- .createTypedLiteral(searchTerm);
- Iterator<Triple> cacheEntries = conceptCacheMGraph.filter(
- conceptCacheNode, CONCEPTS.cacheEntry, null);
- while (cacheEntries.hasNext()) {
- NonLiteral conceptCacheEntryNode = (NonLiteral) cacheEntries.next()
- .getObject();
- if (!conceptCacheMGraph.filter(conceptCacheEntryNode,
- CONCEPTS.searchTerm, searchLiteral).hasNext()) {
- continue;
- }
- return conceptCacheEntryNode;
- }
- return null;
- }
-
- private void removeCachedConcepts(GraphNode conceptCacheEntryGraphNode) {
- Iterator<Resource> searchResults =
- conceptCacheEntryGraphNode.getObjects(CONCEPTS.searchResult);
- while (searchResults.hasNext()) {
- Resource concept = searchResults.next();
- GraphNode conceptGraphNode = new GraphNode(concept,
- conceptCacheEntryGraphNode.getGraph());
- conceptGraphNode.deleteProperties(OWL.sameAs);
- conceptGraphNode.deleteProperties(RDFS.comment);
- conceptGraphNode.deleteProperties(SKOS.prefLabel);
- conceptGraphNode.deleteProperties(RDF.type);
- }
- conceptCacheEntryGraphNode.deleteProperties(CONCEPTS.searchResult);
- conceptCacheEntryGraphNode.deleteProperties(DC.date);
- conceptCacheEntryGraphNode.deleteProperties(CONCEPTS.searchTerm);
- conceptCacheEntryGraphNode.deleteProperties(RDF.type);
- }
-
- private void addCacheEntry(String searchTerm, NonLiteral conceptCacheNode,
- MGraph conceptCacheMGraph, Graph parsedGraph) {
- GraphNode conceptCacheGraphNode = null;
- if (conceptCacheNode == null) {
- conceptCacheGraphNode = addConceptCacheNode(conceptCacheMGraph);
- } else {
- conceptCacheGraphNode = new GraphNode(conceptCacheNode,
- conceptCacheMGraph);
- }
- GraphNode conceptCacheEntryGraphNode = new GraphNode(new BNode(),
- conceptCacheMGraph);
- conceptCacheGraphNode.addProperty(CONCEPTS.cacheEntry,
- conceptCacheEntryGraphNode.getNode());
- conceptCacheEntryGraphNode.addProperty(RDF.type, CONCEPTS.SearchTerm);
- conceptCacheEntryGraphNode.addProperty(CONCEPTS.searchTerm,
- LiteralFactory.getInstance().createTypedLiteral(searchTerm));
- conceptCacheEntryGraphNode.addProperty(DC.date,
- LiteralFactory.getInstance().createTypedLiteral(new Date()));
-
- Iterator<Triple> concepts = parsedGraph.filter(null, RDF.type, SKOS.Concept);
- while (concepts.hasNext()) {
- conceptCacheEntryGraphNode.addProperty(CONCEPTS.searchResult,
- concepts.next().getSubject());
- }
- conceptCacheMGraph.addAll(parsedGraph);
- }
-
- private GraphNode addConceptCacheNode(MGraph conceptCacheMGraph) {
- GraphNode conceptCacheGraphNode = new GraphNode(new BNode(),
- conceptCacheMGraph);
- conceptCacheGraphNode.addProperty(RDF.type, CONCEPTS.ConceptCache);
- conceptCacheGraphNode.addProperty(CONCEPTS.sparqlEndPoint,
- sparqlEndPoint);
- if (defaultGraph != null) {
- conceptCacheGraphNode.addProperty(CONCEPTS.defaultGraph,
- defaultGraph);
- }
- return conceptCacheGraphNode;
- }
-
- /**
- * Retrieves concepts from the cache stored under the specified search term.
- * Cache entries are invalid if they are older than the specified date.
- *
- * @param searchTerm
- * the search term under which the concepts are cached.
- * @param acceptableOldestCachingDate
- * the Date before which a cache entry is considered invalid.
- * @return
- * an {@link MGraph} containing the valid cached concepts.
- */
- MGraph retrieve(String searchTerm, Date acceptableOldestCachingDate) {
- MGraph conceptCacheMGraph = getConceptCacheMGraph();
-
- NonLiteral conceptCacheNode = getConceptCacheNode(conceptCacheMGraph);
- if (conceptCacheNode == null) {
- return null;
- }
- NonLiteral conceptCacheEntryNode = getConceptCacheEntryNode(searchTerm,
- conceptCacheNode, conceptCacheMGraph);
- if (conceptCacheEntryNode == null) {
- return null;
- }
- GraphNode conceptCacheEntryGraphNode = new GraphNode(
- conceptCacheEntryNode, conceptCacheMGraph);
- Date cachingDate = getCachingDate(conceptCacheEntryGraphNode);
- if (cachingDate == null || cachingDate.before(acceptableOldestCachingDate)) {
- removeCachedConcepts(conceptCacheEntryGraphNode);
- conceptCacheMGraph.remove(new TripleImpl(conceptCacheNode,
- CONCEPTS.cacheEntry, conceptCacheEntryNode));
- return null;
- }
- return getCachedConcepts(conceptCacheEntryGraphNode);
- }
-
- private Date getCachingDate(GraphNode conceptCacheEntryGraphNode) {
- Iterator<Literal> cachingDates = conceptCacheEntryGraphNode.getLiterals(
- DC.date);
- if (cachingDates.hasNext()) {
- return LiteralFactory.getInstance().createObject(Date.class,
- (TypedLiteral) cachingDates.next());
- }
- return null;
- }
-
- private MGraph getCachedConcepts(GraphNode conceptCacheEntryGraphNode) {
- MGraph resultMGraph = new SimpleMGraph();
- MGraph conceptCacheMGraph = (MGraph) conceptCacheEntryGraphNode.getGraph();
- NonLiteral conceptCacheNode = (NonLiteral) conceptCacheEntryGraphNode.getNode();
- Iterator<Triple> triples = conceptCacheMGraph.filter(
- conceptCacheNode, CONCEPTS.searchResult, null);
- while (triples.hasNext()) {
- UriRef concept = (UriRef) triples.next().getObject();
- GraphNode graphNode = new GraphNode(concept, conceptCacheMGraph);
- resultMGraph.add(new TripleImpl(concept, RDF.type, SKOS.Concept));
-
- Iterator<Literal> prefLabelStatements = graphNode.getLiterals(SKOS.prefLabel);
- while (prefLabelStatements.hasNext()) {
- resultMGraph.add(new TripleImpl(concept, SKOS.prefLabel,
- prefLabelStatements.next()));
- }
- Iterator<Literal> commentStatements = graphNode.getLiterals(RDFS.comment);
- while (commentStatements.hasNext()) {
- resultMGraph.add(new TripleImpl(concept, RDFS.comment,
- commentStatements.next()));
- }
- Iterator<UriRef> sameAsStatements = graphNode.getUriRefObjects(OWL.sameAs);
- while (sameAsStatements.hasNext()) {
- resultMGraph.add(new TripleImpl(concept, OWL.sameAs,
- sameAsStatements.next()));
- }
- }
- return resultMGraph;
- }
-}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/70220239/platform/platform.concepts/platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/ConceptManipulator.java
----------------------------------------------------------------------
diff --git a/platform/platform.concepts/platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/ConceptManipulator.java b/platform/platform.concepts/platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/ConceptManipulator.java
deleted file mode 100644
index 18b1e6c..0000000
--- a/platform/platform.concepts/platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/ConceptManipulator.java
+++ /dev/null
@@ -1,124 +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.concepts.core;
-
-import javax.ws.rs.FormParam;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
-import org.apache.clerezza.platform.config.PlatformConfig;
-import org.apache.clerezza.platform.graphprovider.content.ContentGraphProvider;
-import org.apache.clerezza.rdf.core.Language;
-import org.apache.clerezza.rdf.core.MGraph;
-import org.apache.clerezza.rdf.core.PlainLiteral;
-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.RDF;
-import org.apache.clerezza.rdf.ontologies.RDFS;
-import org.apache.clerezza.rdf.ontologies.SKOS;
-import org.apache.clerezza.rdf.utils.UriRefUtil;
-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;
-
-/**
- * This JAX-RS resource can be used to add free concepts to the content graph.
- * The URI path of this resource is /concepts/manipulator.
- *
- * @author hasan
- */
-@Component
-@Service(Object.class)
-@Property(name = "javax.ws.rs", boolValue = true)
-@Path("/concepts/manipulator")
-public class ConceptManipulator {
-
- public static String FREE_CONCEPT_SCHEME = "concept-scheme/free-concepts";
-
- @Reference
- protected ContentGraphProvider cgProvider;
-
- @Reference
- private PlatformConfig platformConfig;
-
- /**
- * Creates and stores a concept with the specified prefLabel and comment
- * into the content graph if a concept with this prefLabel does not already
- * exist in the graph.
- *
- * @param prefLabel
- * if it is an empty string no concept is generated
- * @param lang
- * the language of the prefLabel
- * @param comment
- * is a human-readable description of the concept
- * @return
- * - BAD REQUEST response if prefLabel is undefined or empty
- * - CONFLICT response if a concept with the same prefLabel and lang exists
- * - CREATED if everything is ok
- */
- @POST
- @Path("add-concept")
- public Response addConcept(@FormParam("pref-label") String prefLabel,
- @FormParam("lang") String lang,
- @FormParam("comment") String comment) {
-
- if ((prefLabel == null) || (prefLabel.isEmpty())) {
- return Response.status(Status.BAD_REQUEST)
- .entity("A concept must have a label!")
- .build();
- }
- MGraph contentGraph = cgProvider.getContentGraph();
- PlainLiteral preferredLabel = new PlainLiteralImpl(prefLabel,
- new Language(lang));
-
- if (contentGraph.filter(null, SKOS.prefLabel, preferredLabel).hasNext()) {
- return Response.status(Status.CONFLICT)
- .entity("A concept with the same label and language already exists!")
- .build();
- }
-
- UriRef concept = getConceptUriRef(platformConfig, prefLabel);
- contentGraph.add(new TripleImpl(concept, RDF.type,
- SKOS.Concept));
- String baseUri = platformConfig.getDefaultBaseUri().getUnicodeString();
- contentGraph.add(new TripleImpl(concept, SKOS.inScheme,
- new UriRef(baseUri + FREE_CONCEPT_SCHEME)));
- contentGraph.add(new TripleImpl(concept, SKOS.prefLabel, preferredLabel));
- if (!comment.isEmpty()) {
- contentGraph.add(new TripleImpl(concept, RDFS.comment,
- new PlainLiteralImpl(comment, new Language(lang))));
- }
- return Response.status(Status.CREATED).entity(concept.getUnicodeString())
- .build();
- }
-
- static UriRef getConceptUriRef(PlatformConfig platformConfig, String prefLabel) {
- String baseUri = platformConfig.getDefaultBaseUri().getUnicodeString();
- return new UriRef(baseUri + "concept/" +
- UriRefUtil.stripNonUriRefChars(prefLabel));
- }
-}
-
-
-
-
http://git-wip-us.apache.org/repos/asf/clerezza/blob/70220239/platform/platform.concepts/platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/ConceptProvider.java
----------------------------------------------------------------------
diff --git a/platform/platform.concepts/platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/ConceptProvider.java b/platform/platform.concepts/platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/ConceptProvider.java
deleted file mode 100644
index cedd350..0000000
--- a/platform/platform.concepts/platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/ConceptProvider.java
+++ /dev/null
@@ -1,40 +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.concepts.core;
-
-import org.apache.clerezza.rdf.core.Graph;
-
-/**
- * An implementation of this interface provides a function to retrieve
- * concepts based on a search term.
- *
- * @author hasan
- */
-public interface ConceptProvider {
- /**
- * Returns a graph containing all concepts whose SKOS:prefLabels
- * or SKOS:altLabels contain the search term.
- *
- * @param searchTerm a filter condition that specifies the term that must
- * be contained within SKOS:prefLabels or SKOS:altLabels of a concept.
- * @return a Graph containing all concepts that meet the filter condition.
- *
- */
- public Graph retrieveConcepts(String searchTerm);
-}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/70220239/platform/platform.concepts/platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/ConceptProviderManager.java
----------------------------------------------------------------------
diff --git a/platform/platform.concepts/platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/ConceptProviderManager.java b/platform/platform.concepts/platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/ConceptProviderManager.java
deleted file mode 100644
index a7b39ec..0000000
--- a/platform/platform.concepts/platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/ConceptProviderManager.java
+++ /dev/null
@@ -1,39 +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.concepts.core;
-
-import java.util.List;
-
-/**
- * An implementation of this class manages {@link ConceptProvider}s.
- *
- * @author hasan
- */
-public interface ConceptProviderManager {
-
- /**
- * Returns a list of {@link ConceptProvider}s. The list order determines
- * the priority of a {@link ConceptProvider}. The meaning of the priority
- * is left to the implementation and application.
- *
- * @return
- * a list of managed {@link ConceptProvider}s.
- */
- public List<ConceptProvider> getConceptProviders();
-}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/70220239/platform/platform.concepts/platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/ConceptProviderManagerAppPermission.java
----------------------------------------------------------------------
diff --git a/platform/platform.concepts/platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/ConceptProviderManagerAppPermission.java b/platform/platform.concepts/platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/ConceptProviderManagerAppPermission.java
deleted file mode 100644
index c346a12..0000000
--- a/platform/platform.concepts/platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/ConceptProviderManagerAppPermission.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright 2010 reto.
- *
- * 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.
- * under the License.
- */
-
-package org.apache.clerezza.platform.concepts.core;
-
-import java.security.Permission;
-import org.apache.clerezza.permissiondescriptions.PermissionInfo;
-
-/**
- * Permssion to use an application to Manage Concept-Providers. Note that the
- * user additionally need the respecitive rights on the underlying graphs.
- *
- * @author reto
- */
-@PermissionInfo(value="Concept Provider Manager Access Permission", description="Grants access " +
- "to the Concept Provider Manager page")
-public class ConceptProviderManagerAppPermission extends Permission {
-
- public ConceptProviderManagerAppPermission() {
- super("Graph Management permission");
- }
-
- /**
- *
- * @param target ignored
- * @param action ignored
- */
- public ConceptProviderManagerAppPermission(String target, String actions) {
- super("Graph Management permission");
- }
-
- @Override
- public boolean implies(Permission permission) {
- return equals(permission);
- }
-
- @Override
- public boolean equals(Object obj) {
- return getClass().equals(obj.getClass());
- }
-
- @Override
- public int hashCode() {
- return 77985;
- }
-
- @Override
- public String getActions() {
- return "";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/70220239/platform/platform.concepts/platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/ConceptsFinder.java
----------------------------------------------------------------------
diff --git a/platform/platform.concepts/platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/ConceptsFinder.java b/platform/platform.concepts/platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/ConceptsFinder.java
deleted file mode 100644
index f3ac14e..0000000
--- a/platform/platform.concepts/platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/ConceptsFinder.java
+++ /dev/null
@@ -1,266 +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.concepts.core;
-
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
-
-import org.apache.clerezza.platform.concepts.ontologies.QUERYRESULT;
-import org.apache.clerezza.platform.config.PlatformConfig;
-import org.apache.clerezza.platform.graphprovider.content.ContentGraphProvider;
-import org.apache.clerezza.platform.typerendering.RenderletManager;
-import org.apache.clerezza.platform.typerendering.scalaserverpages.ScalaServerPagesRenderlet;
-import org.apache.clerezza.rdf.core.BNode;
-import org.apache.clerezza.rdf.core.Graph;
-import org.apache.clerezza.rdf.core.Literal;
-import org.apache.clerezza.rdf.core.LiteralFactory;
-import org.apache.clerezza.rdf.core.MGraph;
-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.UriRef;
-import org.apache.clerezza.rdf.core.access.TcManager;
-import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
-import org.apache.clerezza.rdf.core.impl.TripleImpl;
-import org.apache.clerezza.rdf.ontologies.OWL;
-import org.apache.clerezza.rdf.ontologies.RDF;
-import org.apache.clerezza.rdf.ontologies.RDFS;
-import org.apache.clerezza.rdf.ontologies.SKOS;
-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 can be used to search concepts accessible through
- * registered {@link ConceptProvider}s. If no {@link LocalConceptProvider} is
- * registered for {@link ConceptManipulator.FREE_CONCEPT_SCHEME}, then one is
- * created to find free concepts in the content graph.
- * Concept providers are prioritized.
- * The URI, SKOS:prefLabel and RDFS:comment of a concept from a provider of a
- * higher priority will be used instead of those concepts having an OWL:sameAs
- * relation with this concept, but from a provider of lower priority.
- * Implicitly created {@link LocalConceptProvider} for free concepts has the
- * lowest priority.
- *
- * The URI path of this service is /concepts/find.
- *
- * @author hasan
- */
-@Component
-@Service(Object.class)
-@Property(name = "javax.ws.rs", boolValue = true)
-@Path("/concepts/find")
-public class ConceptsFinder {
-
- @Reference
- private RenderletManager renderletManager;
-
- @Reference
- protected ConceptProviderManager conceptProviderManager;
-
- @Reference
- private TcManager tcManager;
-
- @Reference
- private ContentGraphProvider cgProvider;
-
- @Reference
- private PlatformConfig platformConfig;
-
- private LocalConceptProvider freeConceptProvider = null;
-
- private UriRef freeConceptScheme = null;
-
- protected void activate(ComponentContext context) throws URISyntaxException {
- URL template = getClass().getResource("skos-collection-json.ssp");
- renderletManager.registerRenderlet(ScalaServerPagesRenderlet.class.getName(),
- new UriRef(template.toURI().toString()),
- SKOS.Collection, null,
- MediaType.APPLICATION_JSON_TYPE, true);
-
- freeConceptScheme =
- new UriRef(platformConfig.getDefaultBaseUri().getUnicodeString()
- + ConceptManipulator.FREE_CONCEPT_SCHEME);
- freeConceptProvider = new LocalConceptProvider(tcManager, cgProvider,
- freeConceptScheme);
- }
-
- /**
- * Searches concepts for a specified search term. The actual search task
- * is delegated to each {@link ConceptProvider} instance. The results from
- * each {@link ConceptProvider} are merged into a single result graph.
- * However, concepts from providers of lower priority are only considered if
- * they are not staying in an OWL:sameAs relation with concepts from
- * providers of higher priority.
- *
- * @param searchTerm
- * The search term in form of a String.
- * @return
- * A GraphNode containing the search results.
- */
- @GET
- @Produces("application/rdf+json")
- public GraphNode findConcepts(@QueryParam(value="searchTerm")
- String searchTerm) {
-
- boolean freeConceptProviderFound = false;
-
- List<ConceptProvider> conceptProviderList = conceptProviderManager
- .getConceptProviders();
-
- MGraph resultMGraph = new SimpleMGraph();
- GraphNode resultNode = new GraphNode(new BNode(), resultMGraph);
- boolean first = true;
- for (ConceptProvider cp : conceptProviderList) {
- if (!freeConceptProviderFound) {
- if (cp instanceof LocalConceptProvider) {
- if (((LocalConceptProvider) cp).getSelectedScheme().equals(
- freeConceptScheme)) {
- freeConceptProviderFound = true;
- }
- }
- }
- retrieveConcepts(cp, first, resultNode, searchTerm);
- if (first) {
- first = false;
- }
- }
- if (!freeConceptProviderFound && freeConceptProvider != null) {
- retrieveConcepts(freeConceptProvider, first, resultNode, searchTerm);
- }
- addCreationOfNewFreeConceptSuggested(resultNode, searchTerm);
- resultNode.addProperty(RDF.type, QUERYRESULT.QueryResult);
- return resultNode;
- }
-
- /**
- * Adds a boolean value that answers whether the UI shall suggest to create
- * a new free concept. A new free concept may not be added if the has the
- * same base uri and search term. Therefore the consumer shall be suggested
- * not to propose creation.
- *
- * @param resultNode
- * the result node to add the property to
- * @param searchTerm
- * the search term the data was searched for
- */
- private void addCreationOfNewFreeConceptSuggested(GraphNode resultNode,
- String searchTerm) {
- UriRef conceptUriRef = ConceptManipulator.getConceptUriRef(
- platformConfig, searchTerm);
- resultNode.addProperty(QUERYRESULT.creationOfNewFreeConceptSuggested,
- LiteralFactory.getInstance().createTypedLiteral(
- !cgProvider.getContentGraph().contains(
- new TripleImpl(conceptUriRef, RDF.type,
- SKOS.Concept))));
- }
-
- /**
- * Retrieve concepts for the given search term.
- *
- * @param conceptProvider
- * the provider delivers concepts
- * @param first
- * is this the first execution
- * @param resultNode
- * the node to attach the concepts to
- * @param searchTerm
- * the search term that the concepts have to match against
- */
- private void retrieveConcepts(ConceptProvider conceptProvider,
- boolean first, GraphNode resultNode, String searchTerm) {
- MGraph resultMGraph = (MGraph) resultNode.getGraph();
- Graph graph = conceptProvider.retrieveConcepts(searchTerm);
- Iterator<Triple> concepts = graph.filter(null, RDF.type, SKOS.Concept);
- if (first) {
- while (concepts.hasNext()) {
- resultNode.addProperty(QUERYRESULT.concept, concepts.next()
- .getSubject());
- }
- resultMGraph.addAll(graph);
- } else {
- while (concepts.hasNext()) {
- NonLiteral concept = concepts.next().getSubject();
- GraphNode conceptGraphNode = new GraphNode(concept, graph);
- Iterator<Resource> sameAsConcepts = conceptGraphNode
- .getObjects(OWL.sameAs);
- if (!(hasSameAs(resultMGraph, concept) || hasAnyConcept(
- resultMGraph, sameAsConcepts))) {
- resultNode.addProperty(QUERYRESULT.concept, concept);
- addConceptToResultMGraph(resultMGraph, conceptGraphNode);
- }
-
- }
- }
- }
-
- private boolean hasSameAs(MGraph graph, NonLiteral sameAsConcept) {
- Iterator<Triple> concepts = graph.filter(null, RDF.type, SKOS.Concept);
- while (concepts.hasNext()) {
- NonLiteral concept = concepts.next().getSubject();
- if (graph.filter(concept, OWL.sameAs, sameAsConcept).hasNext()) {
- return true;
- }
- }
- return false;
- }
-
- private boolean hasAnyConcept(MGraph graph, Iterator<Resource> concepts) {
- while (concepts.hasNext()) {
- NonLiteral concept = (NonLiteral) concepts.next();
- if (graph.filter(concept, RDF.type, SKOS.Concept).hasNext()) {
- return true;
- }
- }
- return false;
- }
-
- private void addConceptToResultMGraph(MGraph resultMGraph,
- GraphNode graphNode) {
- NonLiteral concept = (NonLiteral) graphNode.getNode();
- resultMGraph.add(new TripleImpl(concept, RDF.type, SKOS.Concept));
-
- Iterator<Literal> prefLabelStatements = graphNode.getLiterals(SKOS.prefLabel);
- while (prefLabelStatements.hasNext()) {
- resultMGraph.add(new TripleImpl(concept, SKOS.prefLabel,
- prefLabelStatements.next()));
- }
- Iterator<Literal> commentStatements = graphNode.getLiterals(RDFS.comment);
- while (commentStatements.hasNext()) {
- resultMGraph.add(new TripleImpl(concept, RDFS.comment,
- commentStatements.next()));
- }
- Iterator<UriRef> sameAsStatements = graphNode.getUriRefObjects(OWL.sameAs);
- while (sameAsStatements.hasNext()) {
- resultMGraph.add(new TripleImpl(concept, OWL.sameAs,
- sameAsStatements.next()));
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/70220239/platform/platform.concepts/platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/GenericResourcePage.java
----------------------------------------------------------------------
diff --git a/platform/platform.concepts/platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/GenericResourcePage.java b/platform/platform.concepts/platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/GenericResourcePage.java
deleted file mode 100644
index e96069e..0000000
--- a/platform/platform.concepts/platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/GenericResourcePage.java
+++ /dev/null
@@ -1,111 +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.concepts.core;
-
-import java.net.URISyntaxException;
-import java.net.URL;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
-import javax.ws.rs.core.Response.Status;
-
-import org.apache.clerezza.platform.concepts.ontologies.CONCEPTS;
-import org.apache.clerezza.platform.graphprovider.content.ContentGraphProvider;
-import org.apache.clerezza.platform.typerendering.RenderletManager;
-import org.apache.clerezza.platform.typerendering.scalaserverpages.ScalaServerPagesRenderlet;
-import org.apache.clerezza.rdf.core.BNode;
-import org.apache.clerezza.rdf.core.UriRef;
-import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
-import org.apache.clerezza.rdf.ontologies.PLATFORM;
-import org.apache.clerezza.rdf.ontologies.RDF;
-import org.apache.clerezza.rdf.utils.GraphNode;
-import org.apache.clerezza.rdf.utils.UnionMGraph;
-import org.apache.clerezza.utils.UriException;
-import org.apache.clerezza.web.fileserver.FileServer;
-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 can be used to show selected concepts of a resource.
- * The URI path of this service is /concepts/generic-resource.
- *
- * @author tio
- */
-@Component
-@Service(Object.class)
-@Property(name = "javax.ws.rs", boolValue = true)
-@Path("/concepts/generic-resource")
-public class GenericResourcePage extends FileServer {
-
- @Reference
- protected ContentGraphProvider cgProvider;
- @Reference
- private RenderletManager renderletManager;
-
- private RemoteConceptsDescriptionManager remoteConceptsDescriptionManager = null;
-
- protected void activate(ComponentContext context)
- throws URISyntaxException {
-
- configure(context.getBundleContext());
-
- URL template = getClass().getResource("generic-resource-page.ssp");
- renderletManager.registerRenderlet(ScalaServerPagesRenderlet.class.getName(),
- new UriRef(template.toURI().toString()),
- CONCEPTS.GenericResourcePage, "naked",
- MediaType.APPLICATION_XHTML_XML_TYPE, true);
-
- remoteConceptsDescriptionManager = new RemoteConceptsDescriptionManager();
- }
-
- /**
- * Retrieves a resource and its associated concepts to be rendered with a template
- * registered for CONCEPTS.GenericResourcePage.
- *
- * @param uri specifies the uri of a resource
- *
- * @return GraphNode
- */
- @GET
- public GraphNode GenericResourcePage(@QueryParam("uri") UriRef uri,
- @Context UriInfo uriInfo) {
-
- GraphNode node = new GraphNode(new BNode(), new UnionMGraph(new SimpleMGraph(),
- cgProvider.getContentGraph(),
- remoteConceptsDescriptionManager.getRemoteConceptsDescriptionMGraph()));
- node.addProperty(RDF.type, PLATFORM.HeadedPage);
- node.addProperty(RDF.type, CONCEPTS.GenericResourcePage);
- if (uri != null) {
- node.addProperty(CONCEPTS.resource, uri);
- } else {
- throw new WebApplicationException(Response.status(Status.BAD_REQUEST)
- .entity("No resource uri defined.").build());
- }
- return node;
- }
-}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/70220239/platform/platform.concepts/platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/LocalConceptProvider.java
----------------------------------------------------------------------
diff --git a/platform/platform.concepts/platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/LocalConceptProvider.java b/platform/platform.concepts/platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/LocalConceptProvider.java
deleted file mode 100644
index 4b96110..0000000
--- a/platform/platform.concepts/platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/LocalConceptProvider.java
+++ /dev/null
@@ -1,90 +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.concepts.core;
-
-import org.apache.clerezza.platform.graphprovider.content.ContentGraphProvider;
-import org.apache.clerezza.rdf.core.Graph;
-import org.apache.clerezza.rdf.core.MGraph;
-import org.apache.clerezza.rdf.core.UriRef;
-import org.apache.clerezza.rdf.core.access.TcManager;
-import org.apache.clerezza.rdf.core.sparql.ParseException;
-import org.apache.clerezza.rdf.core.sparql.QueryParser;
-import org.apache.clerezza.rdf.core.sparql.query.ConstructQuery;
-
-/**
- * This {@link ConceptProvider} operates on concepts available in the localhost.
- *
- * @author tio, hasan
- */
-public class LocalConceptProvider implements ConceptProvider {
-
- private TcManager tcManager = null;
- private ContentGraphProvider contentGraphProvider = null;
- private UriRef selectedScheme = null;
-
- /**
- * Constructs a {@link LocalConceptProvider} with the specified parameters.
- *
- * @param tcManager
- * Reference to the {@link TcManager}
- * @param contentGraphProvider
- * Reference to a {@link ContentGraphProvider}
- * @param selectedScheme
- * The scheme in which concepts are to be searched.
- */
- public LocalConceptProvider(TcManager tcManager,
- ContentGraphProvider contentGraphProvider, UriRef selectedScheme) {
- this.tcManager = tcManager;
- this.contentGraphProvider = contentGraphProvider;
- this.selectedScheme = selectedScheme;
- }
-
- public UriRef getSelectedScheme() {
- return this.selectedScheme;
- }
-
- @Override
- public Graph retrieveConcepts(String searchTerm) {
- QueryParser queryParser = QueryParser.getInstance();
-
- String query = "PREFIX owl: <http://www.w3.org/2002/07/owl#> " +
- "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> " +
- "PREFIX skos: <http://www.w3.org/2008/05/skos#> " +
- "CONSTRUCT {?concept a skos:Concept; skos:prefLabel ?prefLabel; " +
- "rdfs:comment ?comment; owl:sameAs ?sameConcept .} " +
- "WHERE {?concept skos:inScheme " + selectedScheme.toString() +
- "; skos:prefLabel ?prefLabel . " +
- "OPTIONAL { ?concept skos:altLabel ?altLabel .} " +
- "OPTIONAL { ?concept rdfs:comment ?comment .} " +
- "OPTIONAL { ?concept owl:sameAs ?sameConcept .} " +
- "FILTER (REGEX(STR(?prefLabel), '" +
- searchTerm + "', 'i') || REGEX(STR(?altLabel), '" +
- searchTerm + "', 'i'))}";
-
- ConstructQuery constructQuery;
- try {
- constructQuery = (ConstructQuery) queryParser.parse(query);
- } catch (ParseException ex) {
- throw new RuntimeException(ex);
- }
-
- MGraph defaultGraph = contentGraphProvider.getContentGraph();
- return tcManager.executeSparqlQuery(constructQuery, defaultGraph);
- }
-}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/70220239/platform/platform.concepts/platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/RemoteConceptProvider.java
----------------------------------------------------------------------
diff --git a/platform/platform.concepts/platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/RemoteConceptProvider.java b/platform/platform.concepts/platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/RemoteConceptProvider.java
deleted file mode 100644
index f933a53..0000000
--- a/platform/platform.concepts/platform.concepts.core/src/main/java/org/apache/clerezza/platform/concepts/core/RemoteConceptProvider.java
+++ /dev/null
@@ -1,134 +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.concepts.core;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.ProtocolException;
-import java.net.URL;
-import java.net.URLEncoder;
-import java.util.Calendar;
-import java.util.Date;
-import org.apache.clerezza.rdf.core.Graph;
-import org.apache.clerezza.rdf.core.MGraph;
-import org.apache.clerezza.rdf.core.UriRef;
-import org.apache.clerezza.rdf.core.serializedform.Parser;
-import org.apache.clerezza.rdf.core.serializedform.SupportedFormat;
-
-/**
- * This implementation of {@link ConceptProvider} provides a functionality
- * to query a SPARQL End Point for a given search term. The query is to be
- * generated from a template by replacing the place holder for the search term
- * with the specified search term.
- *
- * @author tio, hasan
- */
-public class RemoteConceptProvider implements ConceptProvider {
-
- private UriRef sparqlEndPoint = null;
- private UriRef defaultGraph = null;
- private String queryTemplate = null;
- private ConceptCache conceptCache = null;
- private RemoteConceptsDescriptionManager remoteConceptsDescriptionManager = null;
-
- /**
- * Constructs a {@link RemoteConceptProvider} with the specified parameters.
- *
- * @param sparqlEndPoint
- * the SPARQL End Point to connect to
- * @param defaultGraph
- * the Graph to query for concepts
- * @param queryTemplate
- * the template for query containing place holders for the search term.
- */
- public RemoteConceptProvider(
- UriRef sparqlEndPoint, UriRef defaultGraph, String queryTemplate) {
- this.sparqlEndPoint = sparqlEndPoint;
- this.defaultGraph = defaultGraph;
- this.queryTemplate = queryTemplate;
- this.conceptCache = new ConceptCache(sparqlEndPoint, defaultGraph);
- this.remoteConceptsDescriptionManager = new RemoteConceptsDescriptionManager();
- }
-
- @Override
- public Graph retrieveConcepts(String searchTerm) {
-
- Calendar calendar = Calendar.getInstance();
- calendar.add(Calendar.DAY_OF_MONTH, -30);
- Date acceptableOldestCachingDate = calendar.getTime();
- MGraph cachedConcepts = conceptCache.retrieve(searchTerm.toLowerCase(),
- acceptableOldestCachingDate);
- if (cachedConcepts != null) {
- return cachedConcepts.getGraph();
- } else {
- final int connectionTimeout = 4000;
- String query = queryTemplate.replace("${searchTerm}", searchTerm);
- try {
- String param = "query=" + URLEncoder.encode(query, "UTF-8");
- if (defaultGraph != null) {
- param += "&default-graph-uri=" + defaultGraph.getUnicodeString();
- }
- final URL url = new URL(sparqlEndPoint.getUnicodeString());
- final HttpURLConnection con =
- (HttpURLConnection) url.openConnection();
- con.setRequestProperty("Accept", "application/rdf+xml");
- con.setRequestMethod("POST");
- con.setDoOutput(true);
- con.setDoInput(true);
- con.setUseCaches(false);
- con.setConnectTimeout(connectionTimeout);
-
- final OutputStream os = con.getOutputStream();
- os.write(param.getBytes());
- os.close();
-
- if (con.getResponseCode() < 400) {
- final InputStream is = con.getInputStream();
- Graph parsedGraph = Parser.getInstance().parse(is,
- SupportedFormat.RDF_XML);
- is.close();
- conceptCache.cache(searchTerm.toLowerCase(), parsedGraph);
- remoteConceptsDescriptionManager.storeConceptsDescription(parsedGraph);
- return parsedGraph;
- } else {
- final InputStream es = con.getErrorStream();
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- for (int ch = es.read(); ch != -1; ch = es.read()) {
- baos.write(ch);
- }
- es.close();
- throw new RuntimeException(baos.toString());
- }
- } catch (ProtocolException ex) {
- throw new RuntimeException(ex);
- } catch (MalformedURLException ex) {
- throw new RuntimeException(ex);
- } catch (UnsupportedEncodingException ex) {
- throw new RuntimeException(ex);
- } catch (IOException ex) {
- throw new RuntimeException(ex);
- }
- }
- }
-}