Return-Path: X-Original-To: apmail-clerezza-commits-archive@www.apache.org Delivered-To: apmail-clerezza-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 08667179B0 for ; Tue, 14 Apr 2015 13:12:48 +0000 (UTC) Received: (qmail 73588 invoked by uid 500); 14 Apr 2015 13:12:38 -0000 Delivered-To: apmail-clerezza-commits-archive@clerezza.apache.org Received: (qmail 73525 invoked by uid 500); 14 Apr 2015 13:12:38 -0000 Mailing-List: contact commits-help@clerezza.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@clerezza.apache.org Delivered-To: mailing list commits@clerezza.apache.org Received: (qmail 73011 invoked by uid 99); 14 Apr 2015 13:12:37 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 Apr 2015 13:12:37 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B3E01E03C8; Tue, 14 Apr 2015 13:12:37 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: reto@apache.org To: commits@clerezza.apache.org Date: Tue, 14 Apr 2015 13:13:19 -0000 Message-Id: In-Reply-To: <79f2aa157d6c416d8d4f2d2b5548c555@git.apache.org> References: <79f2aa157d6c416d8d4f2d2b5548c555@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [44/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/concepts/platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/staticweb/scripts/selected-concepts.js ---------------------------------------------------------------------- diff --git a/platform/concepts/platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/staticweb/scripts/selected-concepts.js b/platform/concepts/platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/staticweb/scripts/selected-concepts.js new file mode 100644 index 0000000..f30cc14 --- /dev/null +++ b/platform/concepts/platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/staticweb/scripts/selected-concepts.js @@ -0,0 +1,58 @@ +/* + * 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. + */ +function SelectedConcepts(){}; + +SelectedConcepts.exists = function (concept) { + var exists = false; + $("input[name='concepts']").each( function () { + if ($(this).val() == concept) { + exists = true; + } + }); + return exists; +} + +SelectedConcepts.addConcept = function (prefLabel, uri) { + var div = $("
"); + ConceptFinder.createConceptWidgets(prefLabel, uri).appendTo(div); + SelectedConcepts.createDeleteButton(prefLabel, uri).appendTo(div); + $("
").appendTo(div); + $("
").appendTo(div); + $("#selected-concepts").append(div); +} + +/** + * Creates a button that allows to delete a concept. + */ +SelectedConcepts.createDeleteButton = function(prefLabel, uri) { + var deleteLink = $("").attr("href", "#"); + deleteLink.addClass("tx-icon tx-icon-delete").text("Delete"); + deleteLink.click(function() { + deleteLink.parent().remove(); + ConceptFinder.createSystemFoundConcept(prefLabel, uri) + }); + return deleteLink; +} + + +$(document).ready(function () { + $(".tx-icon-delete").click(function() { + $(this).parent().remove(); + }); +}); http://git-wip-us.apache.org/repos/asf/clerezza/blob/70220239/platform/concepts/platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/staticweb/style/form.css ---------------------------------------------------------------------- diff --git a/platform/concepts/platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/staticweb/style/form.css b/platform/concepts/platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/staticweb/style/form.css new file mode 100644 index 0000000..fe8d6fe --- /dev/null +++ b/platform/concepts/platform.concepts.core/src/main/resources/org/apache/clerezza/platform/concepts/core/staticweb/style/form.css @@ -0,0 +1,24 @@ +/* + * + * 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. + * +*/ + +input, select, textarea { + width: 32em; +} http://git-wip-us.apache.org/repos/asf/clerezza/blob/70220239/platform/concepts/platform.concepts.core/src/test/java/org/apache/clerezza/platform/concepts/core/ConceptProviderManagerTest.java ---------------------------------------------------------------------- diff --git a/platform/concepts/platform.concepts.core/src/test/java/org/apache/clerezza/platform/concepts/core/ConceptProviderManagerTest.java b/platform/concepts/platform.concepts.core/src/test/java/org/apache/clerezza/platform/concepts/core/ConceptProviderManagerTest.java new file mode 100644 index 0000000..c73da54 --- /dev/null +++ b/platform/concepts/platform.concepts.core/src/test/java/org/apache/clerezza/platform/concepts/core/ConceptProviderManagerTest.java @@ -0,0 +1,104 @@ +/* + * 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.Arrays; +import java.util.List; +import javax.ws.rs.core.Response; +import javax.ws.rs.ext.RuntimeDelegate; +import org.apache.clerezza.platform.concepts.ontologies.CONCEPTS; +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.access.LockableMGraph; +import org.apache.clerezza.rdf.core.access.LockableMGraphWrapper; +import org.apache.clerezza.rdf.core.impl.SimpleMGraph; +import org.apache.wink.common.internal.runtime.RuntimeDelegateImpl; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * This class tests the functionality of a SimpleConceptProviderManager. + * + * @author hasan + */ +public class ConceptProviderManagerTest { + + private class TestConceptProvider implements ConceptProvider { + @Override + public Graph retrieveConcepts(String searchTerm) { + return null; + } + } + + private class TestedConceptProviderManager extends SimpleConceptProviderManager { + public void fillConceptProviderList() { + ConceptProvider CP1 = new TestConceptProvider(); + ConceptProvider CP2 = new TestConceptProvider(); + getConceptProviders().add(CP1); + getConceptProviders().add(CP2); + } + } + + private static LockableMGraph mGraph = new LockableMGraphWrapper(new SimpleMGraph()); + + private TestedConceptProviderManager testedConceptProviderManager; + + @Before + public void setUp() { + RuntimeDelegate.setInstance(new RuntimeDelegateImpl()); + testedConceptProviderManager = new TestedConceptProviderManager(); + testedConceptProviderManager.cgProvider = new ContentGraphProvider() { + + @Override + public LockableMGraph getContentGraph() { + return mGraph; + } + }; + } + + @Test + public void testUpdateConceptProviders() { + testedConceptProviderManager.fillConceptProviderList(); + List cpl = testedConceptProviderManager + .getConceptProviders(); + Assert.assertTrue(cpl.get(0) instanceof TestConceptProvider); + Assert.assertTrue(cpl.get(1) instanceof TestConceptProvider); + Assert.assertTrue(cpl.size()==2); + List types = Arrays.asList( + CONCEPTS.LocalConceptProvider.getUnicodeString(), + CONCEPTS.RemoteConceptProvider.getUnicodeString()); + List sparqlEndPoint = Arrays.asList( + "", "http://example.org/sparql"); + List defaultGraphs = Arrays.asList( + "", "http://example.org/graph"); + List queryTemplates = Arrays.asList( + "", "CONSTRUCT {?a ?b ?c .} WHERE {?a ?b ?c .}"); + List conceptSchemes = Arrays.asList( + "http://localhost:8080/default", ""); + Response response = testedConceptProviderManager.updateConceptProviders( + types, sparqlEndPoint, defaultGraphs, queryTemplates, + conceptSchemes); + cpl = testedConceptProviderManager.getConceptProviders(); + Assert.assertTrue(cpl.get(0) instanceof LocalConceptProvider); + Assert.assertTrue(cpl.get(1) instanceof RemoteConceptProvider); + Assert.assertTrue(cpl.size()==2); + } +} http://git-wip-us.apache.org/repos/asf/clerezza/blob/70220239/platform/concepts/platform.concepts.core/src/test/java/org/apache/clerezza/platform/concepts/core/ConceptsFinderTest.java ---------------------------------------------------------------------- diff --git a/platform/concepts/platform.concepts.core/src/test/java/org/apache/clerezza/platform/concepts/core/ConceptsFinderTest.java b/platform/concepts/platform.concepts.core/src/test/java/org/apache/clerezza/platform/concepts/core/ConceptsFinderTest.java new file mode 100644 index 0000000..ef63d25 --- /dev/null +++ b/platform/concepts/platform.concepts.core/src/test/java/org/apache/clerezza/platform/concepts/core/ConceptsFinderTest.java @@ -0,0 +1,154 @@ +/* + * 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.Arrays; +import java.util.List; +import org.apache.clerezza.platform.config.PlatformConfig; +import org.apache.clerezza.platform.concepts.ontologies.QUERYRESULT; +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.LockableMGraph; +import org.apache.clerezza.rdf.core.access.LockableMGraphWrapper; +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.SKOS; +import org.apache.clerezza.rdf.utils.GraphNode; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * This class tests the functionality of a ConceptsFinder. + * + * @author hasan + */ +public class ConceptsFinderTest { + + private final UriRef concept1a = new UriRef("http://example.org/concept1a"); + private final UriRef concept1b = new UriRef("http://example.org/concept1b"); + private final UriRef concept1c = new UriRef("http://example.org/concept1c"); + private final UriRef concept1d = new UriRef("http://example.org/concept1d"); + + private final UriRef concept2a = new UriRef("http://example.org/concept2a"); + private final UriRef concept2b = new UriRef("http://example.org/concept2b"); + private final UriRef concept2c = new UriRef("http://example.org/concept2c"); + private final UriRef concept2d = new UriRef("http://example.org/concept2d"); + + private final List concepts1 = Arrays.asList( + concept1a, concept1b, concept1c, concept1d); + private final List concepts2 = Arrays.asList( + concept2a, concept2b, concept2c, concept2d); + + private class TestConceptProvider implements ConceptProvider { + MGraph conceptGraph = new SimpleMGraph(); + + public TestConceptProvider(List myConcepts, + List yourConcepts, List sameAs) { + Assert.assertTrue(myConcepts.size()==4); + Assert.assertTrue(yourConcepts.size()==4); + for (UriRef concept : myConcepts) { + conceptGraph.add(new TripleImpl(concept, RDF.type, SKOS.Concept)); + } + for (Integer index : sameAs) { + conceptGraph.add(new TripleImpl(myConcepts.get(index), OWL.sameAs, + yourConcepts.get(index))); + } + } + + @Override + public Graph retrieveConcepts(String searchTerm) { + return conceptGraph.getGraph(); + } + } + + private class TestedConceptProviderManager extends SimpleConceptProviderManager { + public void fillConceptProviderList() { + ConceptProvider CP1 = new TestConceptProvider(concepts1, concepts2, + Arrays.asList(1,3)); + ConceptProvider CP2 = new TestConceptProvider(concepts2, concepts1, + Arrays.asList(2,3)); + getConceptProviders().add(CP1); + getConceptProviders().add(CP2); + } + } + + private class TestedConceptsFinder extends ConceptsFinder { + } + + private static LockableMGraph mGraph = new LockableMGraphWrapper(new SimpleMGraph()); + private TestedConceptProviderManager testedConceptProviderManager; + private TestedConceptsFinder testedConceptsFinder; + + @Before + public void setUp() { + final PlatformConfig platformConfig = new PlatformConfig() { + + @Override + public UriRef getDefaultBaseUri() { + return new UriRef("http://testing.localhost/"); + } + + }; + final ContentGraphProvider cgProvider = new ContentGraphProvider() { + + @Override + public LockableMGraph getContentGraph() { + return new LockableMGraphWrapper(new SimpleMGraph()); + } + + }; + + testedConceptProviderManager = new TestedConceptProviderManager(); + testedConceptProviderManager.cgProvider = new ContentGraphProvider() { + @Override + public LockableMGraph getContentGraph() { + return mGraph; + } + }; + testedConceptsFinder = new TestedConceptsFinder() { + { + bindPlatformConfig(platformConfig); + bindCgProvider(cgProvider); + } + }; + testedConceptsFinder.conceptProviderManager = + testedConceptProviderManager; + + } + + @Test + public void testFindConcepts() { + testedConceptProviderManager.fillConceptProviderList(); + GraphNode proposals = testedConceptsFinder.findConcepts("any"); + Assert.assertEquals(5, proposals.countObjects(QUERYRESULT.concept)); + Assert.assertTrue(proposals.hasProperty(QUERYRESULT.concept, concept1a)); + Assert.assertTrue(proposals.hasProperty(QUERYRESULT.concept, concept1b)); + Assert.assertTrue(proposals.hasProperty(QUERYRESULT.concept, concept1c)); + Assert.assertTrue(proposals.hasProperty(QUERYRESULT.concept, concept1d)); + Assert.assertTrue(proposals.hasProperty(QUERYRESULT.concept, concept2a)); + Assert.assertFalse(proposals.hasProperty(QUERYRESULT.concept, concept2b)); + Assert.assertFalse(proposals.hasProperty(QUERYRESULT.concept, concept2c)); + Assert.assertFalse(proposals.hasProperty(QUERYRESULT.concept, concept2d)); + } +} http://git-wip-us.apache.org/repos/asf/clerezza/blob/70220239/platform/concepts/platform.concepts.ontologies/LICENSE ---------------------------------------------------------------------- diff --git a/platform/concepts/platform.concepts.ontologies/LICENSE b/platform/concepts/platform.concepts.ontologies/LICENSE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/platform/concepts/platform.concepts.ontologies/LICENSE @@ -0,0 +1,201 @@ + 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/concepts/platform.concepts.ontologies/pom.xml ---------------------------------------------------------------------- diff --git a/platform/concepts/platform.concepts.ontologies/pom.xml b/platform/concepts/platform.concepts.ontologies/pom.xml new file mode 100644 index 0000000..d266140 --- /dev/null +++ b/platform/concepts/platform.concepts.ontologies/pom.xml @@ -0,0 +1,65 @@ + + 4.0.0 + + org.apache.clerezza + platform.concepts + 0.2 + + org.apache.clerezza + platform.concepts.ontologies + 1.0.0-SNAPSHOT + bundle + Clerezza - Platform Concepts Ontologies + + Ontologies for Platform Concepts Core + + + + org.apache.clerezza + rdf.core + 0.14 + + + + + + org.apache.clerezza + maven-ontologies-plugin + + + generate-sources + + ${basedir}/src/main/resources + + ${basedir}/target/generated-sources/main/java + + + + generate + + + + 0.4 + + + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/clerezza/blob/70220239/platform/concepts/platform.concepts.ontologies/src/main/resources/org/apache/clerezza/platform/concepts/ontologies/concepts.rdf ---------------------------------------------------------------------- diff --git a/platform/concepts/platform.concepts.ontologies/src/main/resources/org/apache/clerezza/platform/concepts/ontologies/concepts.rdf b/platform/concepts/platform.concepts.ontologies/src/main/resources/org/apache/clerezza/platform/concepts/ontologies/concepts.rdf new file mode 100644 index 0000000..a8cb5e4 --- /dev/null +++ b/platform/concepts/platform.concepts.ontologies/src/main/resources/org/apache/clerezza/platform/concepts/ontologies/concepts.rdf @@ -0,0 +1,191 @@ + + + + + + + + + Revision: 0.1 + + Clerezza Concepts + + + + + + + + Concepts Page + + A web page containing a list of concept entries and associated information. + + + + + + Manage Concept Providers Page + + A web page for managing all concept providers + + + + + + Search Term + A search term + + + + + Concept Provider + + A Provider for retrieving concepts + + + + + + + Local Concept Provider + + A Concept Provider for retrieving concepts from a graph in localhost + + + + + + Remote Concept Provider + + + A Concept Provider for retrieving concepts via a sparql endpoint + + + + + + Concept Provider List + + A list of Concept Providers + + + + + + Concept Cache + A cache for all concepts retrieved from a + specific Graph managed by a specific SPARQL End Point. + + + + + + Generic Resource Page + + A web page containing a resource and selected concepts. + + + + + + + + selected concept scheme + Points to the selected concept scheme. + + + + + + + + query template + + Points to a template containing a sparql query string which will + be applied by the subject to retrieve concepts. + + + + + + + + search Term + Points to a string as a term to be + searched in concept labels. + + + + + + + search Result + Points to a concept which is a result of + a search using the term represented by the subject. + + + + + + + + Sparql End Point + + Points to a UriRef of a sparql endpoint. + + + + + + + default Graph + Points to a graph against which the subject + performs its queries. + + + + + + cache Entry + Points to a resource which describes + cached search results for a search term. + + + + + + + Resource + Points to a resource. + + + + http://git-wip-us.apache.org/repos/asf/clerezza/blob/70220239/platform/concepts/platform.concepts.ontologies/src/main/resources/org/apache/clerezza/platform/concepts/ontologies/queryresult.rdf ---------------------------------------------------------------------- diff --git a/platform/concepts/platform.concepts.ontologies/src/main/resources/org/apache/clerezza/platform/concepts/ontologies/queryresult.rdf b/platform/concepts/platform.concepts.ontologies/src/main/resources/org/apache/clerezza/platform/concepts/ontologies/queryresult.rdf new file mode 100644 index 0000000..4b298b0 --- /dev/null +++ b/platform/concepts/platform.concepts.ontologies/src/main/resources/org/apache/clerezza/platform/concepts/ontologies/queryresult.rdf @@ -0,0 +1,62 @@ + + + + + + Revision: 0.1 + + Ontology for describing the result of a Query for Concepts + + + + Query Result + + The result of a query for concepts. + + + + + concept + Points to a concept matching the query yielding to the subject. + + + + + + creationOfNewFreeConceptSuggested + Points to a boolean value that indicates whether + consumers of the subject are suggested to create new concepts with a query as + preferred label. + + + + + + http://git-wip-us.apache.org/repos/asf/clerezza/blob/70220239/platform/concepts/pom.xml ---------------------------------------------------------------------- diff --git a/platform/concepts/pom.xml b/platform/concepts/pom.xml new file mode 100644 index 0000000..7133468 --- /dev/null +++ b/platform/concepts/pom.xml @@ -0,0 +1,38 @@ + + 4.0.0 + + org.apache.clerezza + clerezza + 0.5 + ../parent + + org.apache.clerezza + platform.concepts + pom + 1.0.0-SNAPSHOT + Clerezza - Platform Concepts + Provides services for tagging resources with SKOS concepts. + + platform.concepts.ontologies + platform.concepts.core + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/clerezza/blob/70220239/platform/config.gui/LICENSE ---------------------------------------------------------------------- diff --git a/platform/config.gui/LICENSE b/platform/config.gui/LICENSE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/platform/config.gui/LICENSE @@ -0,0 +1,201 @@ + 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/config.gui/pom.xml ---------------------------------------------------------------------- diff --git a/platform/config.gui/pom.xml b/platform/config.gui/pom.xml new file mode 100644 index 0000000..96493dc --- /dev/null +++ b/platform/config.gui/pom.xml @@ -0,0 +1,92 @@ + + + + 4.0.0 + + org.apache.clerezza + clerezza + 0.5 + ../parent + + org.apache.clerezza + platform.config.gui + 1.0.0-SNAPSHOT + bundle + Clerezza - Platform Configuration GUI + This bundles initializes a GUI to + edit configuration options. + + + + org.osgi + org.osgi.compendium + + + org.apache.clerezza + rdf.core + 0.14 + + + org.apache.clerezza + rdf.ontologies + 0.12 + + + org.apache.clerezza + rdf.utils + 0.14 + + + org.apache.felix + org.apache.felix.scr.annotations + + + javax.ws.rs + jsr311-api + + + org.apache.clerezza + platform.globalmenu.api + 0.3 + + + org.apache.clerezza + platform.graphprovider.content + 0.7 + + + org.apache.clerezza + web.fileserver + 0.10 + + + org.apache.clerezza + platform.config + 0.4 + + + org.apache.clerezza + platform.typerendering.scalaserverpages + 0.4 + + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/clerezza/blob/70220239/platform/config.gui/src/main/java/org/apache/clerezza/platform/config/gui/ConfigGuiAccessPermission.java ---------------------------------------------------------------------- diff --git a/platform/config.gui/src/main/java/org/apache/clerezza/platform/config/gui/ConfigGuiAccessPermission.java b/platform/config.gui/src/main/java/org/apache/clerezza/platform/config/gui/ConfigGuiAccessPermission.java new file mode 100644 index 0000000..a341bc5 --- /dev/null +++ b/platform/config.gui/src/main/java/org/apache/clerezza/platform/config/gui/ConfigGuiAccessPermission.java @@ -0,0 +1,66 @@ +/* + * 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.config.gui; + +import java.security.Permission; +import org.apache.clerezza.permissiondescriptions.PermissionInfo; + +/** + * Permission to use the Config GUI. Note that the user + * additionally needs permission write into the system graph. + * + * @author tio + */ +@PermissionInfo(value="Config GUI Access Permission", description="Grants access " + + "to the Config GUI") +public class ConfigGuiAccessPermission extends Permission{ + + public ConfigGuiAccessPermission() { + super("Config GUI Access permission"); + } + /** + * + * @param target ignored + * @param action ignored + */ + public ConfigGuiAccessPermission(String target, String actions) { + super("Config GUI Access 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 2177987; + } + + @Override + public String getActions() { + return ""; + } +} http://git-wip-us.apache.org/repos/asf/clerezza/blob/70220239/platform/config.gui/src/main/java/org/apache/clerezza/platform/config/gui/PlatformConfigGui.java ---------------------------------------------------------------------- diff --git a/platform/config.gui/src/main/java/org/apache/clerezza/platform/config/gui/PlatformConfigGui.java b/platform/config.gui/src/main/java/org/apache/clerezza/platform/config/gui/PlatformConfigGui.java new file mode 100644 index 0000000..647a0e6 --- /dev/null +++ b/platform/config.gui/src/main/java/org/apache/clerezza/platform/config/gui/PlatformConfigGui.java @@ -0,0 +1,190 @@ +/* + * 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.config.gui; + +import java.io.IOException; +import java.net.URISyntaxException; +import java.net.URL; +import java.security.AccessControlException; +import java.security.AccessController; +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.locks.Lock; + +import javax.ws.rs.FormParam; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +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 org.apache.clerezza.platform.config.PlatformConfig; +import org.apache.clerezza.platform.config.SystemConfig; + +import org.apache.felix.scr.annotations.Component; +import org.apache.felix.scr.annotations.Property; +import org.apache.felix.scr.annotations.Reference; +import org.apache.felix.scr.annotations.Service; +import org.apache.felix.scr.annotations.Services; +import org.apache.clerezza.platform.globalmenu.GlobalMenuItem; +import org.osgi.framework.Bundle; +import org.osgi.service.component.ComponentContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.apache.clerezza.platform.globalmenu.GlobalMenuItemsProvider; +import org.apache.clerezza.platform.typerendering.RenderletManager; +import org.apache.clerezza.platform.typerendering.scalaserverpages.ScalaServerPagesRenderlet; +import org.apache.clerezza.rdf.core.UriRef; + +import org.apache.clerezza.rdf.core.impl.SimpleMGraph; +import org.apache.clerezza.rdf.utils.GraphNode; + +import org.apache.clerezza.rdf.core.BNode; +import org.apache.clerezza.rdf.core.access.LockableMGraph; +import org.apache.clerezza.rdf.core.access.security.TcPermission; + +import org.apache.clerezza.rdf.ontologies.*; +import org.apache.clerezza.web.fileserver.BundlePathNode; +import org.apache.clerezza.web.fileserver.FileServer; +import org.wymiwyg.commons.util.dirbrowser.PathNode; + +/** + * Provides a GUI to change platform default values. + * + * @author osr + */ +@Component +@Services({ + @Service(value = Object.class), + @Service(value = GlobalMenuItemsProvider.class) +}) +@Property(name = "javax.ws.rs", boolValue = true) +@Path("/admin/configuration") +public class PlatformConfigGui implements GlobalMenuItemsProvider { + + private final static char SLASH = '/'; + @Reference + private PlatformConfig platformConfig; + @Reference + private RenderletManager renderletManager; + private final Logger logger = LoggerFactory.getLogger(getClass()); + private final UriRef CONFIG_PAGE = new UriRef("http://clerezza.org/2009/08/platform#ConfigPage"); + private FileServer fileServer; + + protected void activate(ComponentContext context) throws IOException, + URISyntaxException { + Bundle bundle = context.getBundleContext().getBundle(); + URL resourceDir = getClass().getResource("staticweb"); + PathNode pathNode = new BundlePathNode(bundle, resourceDir.getPath()); + + logger.debug("Initializing file server for {} ({})", resourceDir, + resourceDir.getFile()); + + fileServer = new FileServer(pathNode); + + URL template = getClass().getResource( + "config.ssp"); + renderletManager.registerRenderlet(ScalaServerPagesRenderlet.class.getName(), + new UriRef(template.toURI().toString()), + CONFIG_PAGE, "naked", + MediaType.APPLICATION_XHTML_XML_TYPE, true); + + } + + protected void deactivate(ComponentContext context) { + fileServer = null; + } + + /** + * Returns a headed page listing RSS Feeds. The optional parameter query is a + * search term, which tests if the term is contained in thee title or uri + * of the feed. + * + * @param query an optional parameter which specifies a search term criteria. + * The search term will be tested if contained in the title or the uri of the feed. + * + * @return {@link GraphNode} + * + */ + @GET + public GraphNode getConfig() { + AccessController.checkPermission(new ConfigGuiAccessPermission()); + GraphNode node = new GraphNode(new BNode(), new SimpleMGraph()); + node.addProperty(RDF.type, CONFIG_PAGE); + node.addProperty(RDF.type, PLATFORM.HeadedPage); + node.addProperty(PLATFORM.defaultBaseUri, platformConfig.getDefaultBaseUri()); + return node; + + } + + @POST + public Response setConfig(@FormParam(value = "defaultBaseUri") String defaultBaseUri, + @Context UriInfo uriInfo) { + AccessController.checkPermission(new ConfigGuiAccessPermission()); + logger.debug("Setting base-uri to {}", defaultBaseUri); + if (defaultBaseUri.charAt(defaultBaseUri.length() - 1) != SLASH) { + defaultBaseUri += SLASH; + } + UriRef uri = new UriRef(defaultBaseUri); + GraphNode node = platformConfig.getPlatformInstance(); + LockableMGraph sysGraph = (LockableMGraph) node.getGraph(); + Lock writeLock = sysGraph.getLock().writeLock(); + writeLock.lock(); + try { + node.deleteProperties(PLATFORM.defaultBaseUri); + node.addProperty(PLATFORM.defaultBaseUri, uri); + } finally { + writeLock.unlock(); + } + return Response.status(Response.Status.ACCEPTED).build(); + } + + @Override + public Set getMenuItems() { + Set items = new HashSet(); + try { + AccessController.checkPermission(new ConfigGuiAccessPermission()); + AccessController.checkPermission( + new TcPermission(SystemConfig.SYSTEM_GRAPH_URI.toString(), + TcPermission.READWRITE)); + } catch (AccessControlException e) { + return items; + } + items.add(new GlobalMenuItem("/admin/configuration", "Configuration", "Configuration", 2, + "Administration")); + return items; + } + + /** + * Returns a PathNode of a static file from the staticweb folder. + * + * @param path specifies the path parameter + * @return {@link PathNode} + */ + @GET + @Path("{path:.+}") + public PathNode getStaticFile( + @PathParam("path") String path) { + return fileServer.getNode(path); + + + } +} http://git-wip-us.apache.org/repos/asf/clerezza/blob/70220239/platform/config.gui/src/main/resources/org/apache/clerezza/platform/config/gui/config.ssp ---------------------------------------------------------------------- diff --git a/platform/config.gui/src/main/resources/org/apache/clerezza/platform/config/gui/config.ssp b/platform/config.gui/src/main/resources/org/apache/clerezza/platform/config/gui/config.ssp new file mode 100644 index 0000000..627cf18 --- /dev/null +++ b/platform/config.gui/src/main/resources/org/apache/clerezza/platform/config/gui/config.ssp @@ -0,0 +1,49 @@ +/* + * + * 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. + * +*/ + +def platform(s: Any) = new UriRef("http://clerezza.org/2009/08/platform#"+s) +resultDocModifier.addStyleSheet("style/form.css"); +resultDocModifier.addScriptReference("/jquery/jquery-1.3.2.min.js"); +resultDocModifier.addScriptReference("/admin/configuration/js/platformconfig.js"); +resultDocModifier.addStyleSheet("/yui/2/container/assets/container-core.css"); +resultDocModifier.addScriptReference("/yui/2/yahoo-dom-event/yahoo-dom-event.js"); +resultDocModifier.addScriptReference("/yui/2/element/element-min.js"); +resultDocModifier.addScriptReference("/yui/2/container/container-min.js"); +resultDocModifier.addScriptReference("/scripts/alert-message.js"); +resultDocModifier.addScriptReference("/scripts/ajax-options.js"); +resultDocModifier.addScriptReference("/scripts/modification-status.js"); +resultDocModifier.addScripts("ModificationStatus.watchElements(\"input\");"); + +resultDocModifier.setTitle("Apache Clerezza Configuration"); +resultDocModifier.addNodes2Elem("tx-module",

Apache Clerezza Configuration

); +resultDocModifier.addNodes2Elem("tx-contextual-buttons-ol",
  • Save
  • ); +
    +
    + +
      +
    1. + + + +
    2. +
    +
    +
    http://git-wip-us.apache.org/repos/asf/clerezza/blob/70220239/platform/config.gui/src/main/resources/org/apache/clerezza/platform/config/gui/staticweb/js/platformconfig.js ---------------------------------------------------------------------- diff --git a/platform/config.gui/src/main/resources/org/apache/clerezza/platform/config/gui/staticweb/js/platformconfig.js b/platform/config.gui/src/main/resources/org/apache/clerezza/platform/config/gui/staticweb/js/platformconfig.js new file mode 100644 index 0000000..5e922a1 --- /dev/null +++ b/platform/config.gui/src/main/resources/org/apache/clerezza/platform/config/gui/staticweb/js/platformconfig.js @@ -0,0 +1,52 @@ +/* + * 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. + */ +$(document).ready(function() { + $('#saveButton').click(function(){ + + if(isUrl($('#defaultBaseUri').val())){ + var q = "Are you sure you want to change the URI to "+$('#defaultBaseUri').val(); + AlertMessage.show(function(){ + + var data = "defaultBaseUri=" + encodeURIComponent($("#defaultBaseUri").val()); + var options = new AjaxOptions("platform-config", "Save Config", function() { + ModificationStatus.isModified = false; + }); + options.type = "POST"; + options.url = "/admin/configuration/"; + options.data = data; + $.ajax(options); + }, q , "Change Config?"); + + }else { + AlertMessage.show(function(){}, " No valid URL ", "Error", "OK"); + } + + + + + }) +}) + + + +function isUrl(s) { + var regexp = /(http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/ + return regexp.test(s); +} + http://git-wip-us.apache.org/repos/asf/clerezza/blob/70220239/platform/config/LICENSE ---------------------------------------------------------------------- diff --git a/platform/config/LICENSE b/platform/config/LICENSE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/platform/config/LICENSE @@ -0,0 +1,201 @@ + 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.