Return-Path: Delivered-To: apmail-incubator-clerezza-dev-archive@minotaur.apache.org Received: (qmail 89334 invoked from network); 16 Mar 2011 20:05:40 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 16 Mar 2011 20:05:40 -0000 Received: (qmail 39197 invoked by uid 500); 16 Mar 2011 20:05:40 -0000 Delivered-To: apmail-incubator-clerezza-dev-archive@incubator.apache.org Received: (qmail 39164 invoked by uid 500); 16 Mar 2011 20:05:40 -0000 Mailing-List: contact clerezza-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: clerezza-dev@incubator.apache.org Delivered-To: mailing list clerezza-dev@incubator.apache.org Received: (qmail 39154 invoked by uid 99); 16 Mar 2011 20:05:40 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Mar 2011 20:05:40 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [209.85.214.47] (HELO mail-bw0-f47.google.com) (209.85.214.47) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Mar 2011 20:05:19 +0000 Received: by bwz10 with SMTP id 10so1777362bwz.6 for ; Wed, 16 Mar 2011 13:04:59 -0700 (PDT) MIME-Version: 1.0 Received: by 10.204.170.130 with SMTP id d2mr410098bkz.116.1300305898726; Wed, 16 Mar 2011 13:04:58 -0700 (PDT) Sender: reto@trialox.org Received: by 10.204.58.17 with HTTP; Wed, 16 Mar 2011 13:04:58 -0700 (PDT) X-Originating-IP: [217.71.247.242] Date: Wed, 16 Mar 2011 21:04:58 +0100 X-Google-Sender-Auth: gAZDSOBeSktbqmfU-pK7RxP9jJc Message-ID: Subject: Re: svn commit: r1081290 - in /incubator/clerezza/trunk/parent: internal.archetype/src/main/resources/archetype-resources/ platform.accountcontrolpanel/platform.accountcontrolpanel.core/ platform.accountcontrolpanel/platform.accountcontrolpanel.core/ From: Reto Bachmann-Gmuer To: clerezza-dev@incubator.apache.org Cc: bblfish@apache.org, clerezza-commits@incubator.apache.org Content-Type: multipart/alternative; boundary=bcaec5196ce531665f049e9f0f7d X-Virus-Checked: Checked by ClamAV on apache.org --bcaec5196ce531665f049e9f0f7d Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Henry, Most of the changes you did are really very valuable and I realise splittin= g things and associating them to issues might be an unnecessary big effort, s= o I wouldn't say -1 if you could go through your changes and fix some things: - remove experiments (the public bundlecontext variable) - rename classes to conform with coding conventions (e.g. org.apache.clerezza. platform.accountcontrolpanel.profile_panel) - ideally also transform TODO into issues Cheers, Reto On Mon, Mar 14, 2011 at 10:04 AM, wrote: > Author: bblfish > Date: Mon Mar 14 09:04:51 2011 > New Revision: 1081290 > > URL: http://svn.apache.org/viewvc?rev=3D1081290&view=3Drev > Log: > Merge branch 'foaf' > > Added: > > incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.ac= countcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountc= ontrolpanel/PersonPanel.scala > > incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.ac= countcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountc= ontrolpanel/person_panel.scala > Modified: > > incubator/clerezza/trunk/parent/internal.archetype/src/main/resources/ar= chetype-resources/pom.xml > > incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.ac= countcontrolpanel.core/pom.xml > > incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.ac= countcontrolpanel.core/src/main/resources/OSGI-INF/serviceComponents.xml > > incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.ac= countcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountc= ontrolpanel/ProfilePanel.scala > > incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.ac= countcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountc= ontrolpanel/profile_panel.scala > > incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.ac= countcontrolpanel.ontologies/src/main/resources/org/apache/clerezza/platfor= m/accountcontrolpanel/ontologies/controlpanel.rdf > incubator/clerezza/trunk/parent/platform.security.foafssl/core/pom.xml > > incubator/clerezza/trunk/parent/platform.security.foafssl/core/src/main/= scala/org/apache/clerezza/foafssl/ssl/X509TrustManagerWrapperService.scala > incubator/clerezza/trunk/parent/platform.security.foafssl/test/pom.xml > incubator/clerezza/trunk/parent/platform.typerendering.scala/pom.xml > > incubator/clerezza/trunk/parent/platform.typerendering.scala/src/main/sc= ala/org/apache/clerezza/platform/typerendering/scala/RenderedPage.scala > > incubator/clerezza/trunk/parent/platform.typerendering/platform.typerend= ering.core/src/main/java/org/apache/clerezza/platform/typerendering/Rendere= r.java > > incubator/clerezza/trunk/parent/platform.typerendering/platform.typerend= ering.core/src/main/java/org/apache/clerezza/platform/typerendering/Renderl= et.java > > incubator/clerezza/trunk/parent/platform.users/core/src/main/scala/org/a= pache/clerezza/platform/users/WebDescriptionProvider.scala > > incubator/clerezza/trunk/parent/platform.users/core/src/main/scala/org/a= pache/clerezza/platform/users/WebIdGraphsService.scala > > incubator/clerezza/trunk/parent/rdf.scala.utils/src/main/scala/org/apach= e/clerezza/rdf/scala/utils/CollectedIter.scala > > incubator/clerezza/trunk/parent/rdf.scala.utils/src/main/scala/org/apach= e/clerezza/rdf/scala/utils/RichGraphNode.scala > > Modified: > incubator/clerezza/trunk/parent/internal.archetype/src/main/resources/arc= hetype-resources/pom.xml > URL: > http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/internal.arc= hetype/src/main/resources/archetype-resources/pom.xml?rev=3D1081290&r1=3D10= 81289&r2=3D1081290&view=3Ddiff > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- > incubator/clerezza/trunk/parent/internal.archetype/src/main/resources/arc= hetype-resources/pom.xml > (original) > +++ > incubator/clerezza/trunk/parent/internal.archetype/src/main/resources/arc= hetype-resources/pom.xml > Mon Mar 14 09:04:51 2011 > @@ -6,11 +6,11 @@ > main.parent > 0.5-incubating-SNAPSHOT > > - ${groupId} > - ${artifactId} > + ${project.groupId} > + ${project.artifactId} > bundle > - ${version} > - Clerezza - ${artifactId} > + ${project.version} > + Clerezza - ${project.artifactId} > A clerezza project > > > > Modified: > incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.acc= ountcontrolpanel.core/pom.xml > URL: > http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.acc= ountcontrolpanel/platform.accountcontrolpanel.core/pom.xml?rev=3D1081290&r1= =3D1081289&r2=3D1081290&view=3Ddiff > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- > incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.acc= ountcontrolpanel.core/pom.xml > (original) > +++ > incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.acc= ountcontrolpanel.core/pom.xml > Mon Mar 14 09:04:51 2011 > @@ -45,7 +45,7 @@ > > > OSGI-INF/serviceComponents.xml > > org.apache.clerezza.platform.accountcontrolpanel > - > ${groupId}.${artifactId} > + > ${project.groupId}.${project.artifactId} > > > > > Modified: > incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.acc= ountcontrolpanel.core/src/main/resources/OSGI-INF/serviceComponents.xml > URL: > http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.acc= ountcontrolpanel/platform.accountcontrolpanel.core/src/main/resources/OSGI-= INF/serviceComponents.xml?rev=3D1081290&r1=3D1081289&r2=3D1081290&view=3Ddi= ff > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- > incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.acc= ountcontrolpanel.core/src/main/resources/OSGI-INF/serviceComponents.xml > (original) > +++ > incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.acc= ountcontrolpanel.core/src/main/resources/OSGI-INF/serviceComponents.xml > Mon Mar 14 09:04:51 2011 > @@ -33,13 +33,33 @@ > > > value=3D"org.apache.clerezza.platform.accountcontrolpanel.ProfilePanel"/> > - interface=3D"org.apache.clerezza.platform.usermanager.UserManager" > cardinality=3D"1..1" policy=3D"static" bind=3D"bindUserManager" > unbind=3D"unbindUserManager"/> > - interface=3D"org.apache.clerezza.ssl.keygen.KeygenService" cardinality=3D= "1..1" > policy=3D"static" bind=3D"bindKeygenSrvc" unbind=3D"unbindKeygenSrvc"/> > - interface=3D"org.apache.clerezza.rdf.core.access.TcManager" cardinality= =3D"1..1" > policy=3D"static" bind=3D"bindTcManager" unbind=3D"unbindTcManager"/> > - interface=3D"org.apache.clerezza.platform.typerendering.RenderletManager" > cardinality=3D"1..1" policy=3D"static" bind=3D"bindRenderletManager" > unbind=3D"unbindRenderletManager"/> > - interface=3D"org.apache.clerezza.platform.users.WebIdGraphsService" > cardinality=3D"1..1" policy=3D"static" bind=3D"bindWebIdGraphsService" > unbind=3D"unbindWebIdGraphsService"/> > - interface=3D"org.apache.clerezza.platform.config.PlatformConfig" > cardinality=3D"1..1" policy=3D"static" bind=3D"bindPlatformConfig" > unbind=3D"unbindPlatformConfig"/> > + interface=3D"org.apache.clerezza.platform.usermanager.UserManager" > + cardinality=3D"1..1" policy=3D"static" > bind=3D"bindUserManager" unbind=3D"unbindUserManager"/> > + interface=3D"org.apache.clerezza.ssl.keygen.KeygenService" > + cardinality=3D"1..1" policy=3D"static" > bind=3D"bindKeygenSrvc" unbind=3D"unbindKeygenSrvc"/> > + interface=3D"org.apache.clerezza.platform.typerendering.RenderletManager" > + cardinality=3D"1..1" policy=3D"static" > bind=3D"bindRenderletManager" unbind=3D"unbindRenderletManager"/> > + interface=3D"org.apache.clerezza.platform.users.WebIdGraphsService" > + cardinality=3D"1..1" policy=3D"static" > bind=3D"bindWebIdGraphsService" unbind=3D"unbindWebIdGraphsService"/> > + interface=3D"org.apache.clerezza.platform.config.PlatformConfig" > + cardinality=3D"1..1" policy=3D"static" > bind=3D"bindPlatformConfig" unbind=3D"unbindPlatformConfig"/> > + interface=3D"org.apache.clerezza.platform.users.WebDescriptionProvider" > + cardinality=3D"1..1" policy=3D"static" > bind=3D"bindWebDescriptionProvider" unbind=3D"unbindWebDescriptionProvide= r"/> > > + name=3D"org.apache.clerezza.platform.accountcontrolpanel.PersonPanel"> > + class=3D"org.apache.clerezza.platform.accountcontrolpanel.PersonPanel"/> > + > + > + > + > + value=3D"org.apache.clerezza.platform.accountcontrolpanel.PersonPanel"/> > + interface=3D"org.apache.clerezza.platform.users.WebIdGraphsService" > + cardinality=3D"1..1" policy=3D"static" > bind=3D"bindWebIdGraphsService" unbind=3D"unbindWebIdGraphsService"/> > + interface=3D"org.apache.clerezza.platform.users.WebDescriptionProvider" > + cardinality=3D"1..1" policy=3D"static" > bind=3D"bindWebDescriptionProvider" unbind=3D"unbindWebDescriptionProvide= r"/> > + interface=3D"org.apache.clerezza.platform.typerendering.RenderletManager" > + cardinality=3D"1..1" policy=3D"static" > bind=3D"bindRenderletManager" unbind=3D"unbindRenderletManager"/> > + > name=3D"org.apache.clerezza.platform.accountcontrolpanel.profile_panel"> > class=3D"org.apache.clerezza.platform.accountcontrolpanel.profile_panel"/= > > > @@ -56,4 +76,12 @@ > value=3D"org.apache.clerezza.platform.accountcontrolpanel.settings_panel"= /> > interface=3D"org.apache.clerezza.platform.typerendering.RenderletManager" > cardinality=3D"1..1" policy=3D"static" bind=3D"bindRenderletManager" > unbind=3D"unbindRenderletManager"/> > > + name=3D"org.apache.clerezza.platform.accountcontrolpanel.person_panel"> > + class=3D"org.apache.clerezza.platform.accountcontrolpanel.person_panel"/> > + > + interface=3D"org.apache.clerezza.platform.typerendering.Renderlet"/> > + > + value=3D"org.apache.clerezza.platform.accountcontrolpanel.person_panel"/> > + interface=3D"org.apache.clerezza.platform.typerendering.RenderletManager" > cardinality=3D"1..1" policy=3D"static" bind=3D"bindRenderletManager" > unbind=3D"unbindRenderletManager"/> > + > > > Added: > incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.acc= ountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountco= ntrolpanel/PersonPanel.scala > URL: > http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.acc= ountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apach= e/clerezza/platform/accountcontrolpanel/PersonPanel.scala?rev=3D1081290&vie= w=3Dauto > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- > incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.acc= ountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountco= ntrolpanel/PersonPanel.scala > (added) > +++ > incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.acc= ountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountco= ntrolpanel/PersonPanel.scala > Mon Mar 14 09:04:51 2011 > @@ -0,0 +1,157 @@ > +/* > + * 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.accountcontrolpanel > + > +import java.util.ArrayList > +import java.util.Arrays > +import java.util.Iterator > +import org.apache.clerezza.platform.security.UserUtil > +import org.apache.clerezza.ssl.keygen.CertSerialisation > +import org.apache.clerezza.ssl.keygen.Certificate > +import org.apache.clerezza.foafssl.ontologies.CERT > +import org.apache.clerezza.foafssl.ontologies.RSA > +import org.apache.clerezza.jaxrs.utils.RedirectUtil > +import org.apache.clerezza.jaxrs.utils.TrailingSlash > +import > org.apache.clerezza.platform.accountcontrolpanel.ontologies.CONTROLPANEL > +import org.apache.clerezza.platform.config.PlatformConfig > +import org.apache.clerezza.platform.typerendering.RenderletManager > +import > org.apache.clerezza.platform.typerendering.scalaserverpages.ScalaServerPa= gesRenderlet > +import org.apache.clerezza.platform.usermanager.UserManager > +import org.apache.clerezza.rdf.core._ > +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.FOAF > +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.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 > +import org.slf4j.Logger > +import org.slf4j.LoggerFactory > +import javax.ws.rs._ > +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 java.math.BigInteger > +import java.net.URL > +import java.security.AccessController > +import java.security.PrivilegedAction > +import java.security.interfaces.RSAPublicKey > +import java.util.List > +import org.apache.clerezza.platform.typerendering.scala.PageRenderlet > +import org.apache.clerezza.rdf.ontologies.RDFS > +import org.apache.clerezza.ssl.keygen.KeygenService > +import org.apache.clerezza.platform.users.{Cache, WebDescriptionProvider= , > WebIdGraphsService} > + > +object PersonPanel { > + private val logger: Logger =3D > LoggerFactory.getLogger(classOf[ProfilePanel]) > +} > + > +/** > + * Presents a panel where the user can create a webid and edit her > profile. > + * > + * @author bblfish > + */ > +@Path("/user/{id}/people") > +class PersonPanel { > + > + import PersonPanel.logger > + > + protected def activate(componentContext: ComponentContext): Unit = =3D > { > +// this.componentContext =3D componentContext. > + } > + > + @GET > + def viewPerson(@Context uriInfo: UriInfo, > + @QueryParam("uri") uri: > UriRef): GraphNode =3D { > + if (uri !=3D null) {//show some error page > + System.out.println("uri =3D=3D"+uri.getUnicodeStr= ing) > + } > + > + //val foaf =3D descriptionProvider.fetchSemantics(uri, > Cache.Fetch) > + //so here the initial fetch could be used to decide if > information is available at all, > + //ie, if the URL is accessible, if there are error > conditions - try later for example... > + > + > + //Here we make a BNode the subject of the properties as a > workaround to CLEREZZA-447 > + val resultNode: GraphNode =3D new GraphNode(new > UriRef(uriInfo.getRequestUri().toString),new SimpleMGraph()) > + resultNode.addProperty(RDF.`type`, PLATFORM.HeadedPage) > + resultNode.addProperty(RDF.`type`, > CONTROLPANEL.ProfileViewerPage) > + resultNode.addProperty(FOAF.primaryTopic,uri) > +// val result =3D new GraphNode(new > UriRef(uri.getUnicodeString),resultNode.fetchSemantics) > + return resultNode > + } > + > + protected def bindWebIdGraphsService(webidgraphsservice: > WebIdGraphsService): Unit =3D { > + webIdGraphsService =3D webidgraphsservice > + } > + > + protected def unbindWebIdGraphsService(webidgraphsservice: > WebIdGraphsService): Unit =3D { > + if (webIdGraphsService =3D=3D webidgraphsservice) { > + webIdGraphsService =3D null > + } > + } > + > + protected def bindWebDescriptionProvider(descriptionProvider: > WebDescriptionProvider) =3D { > + this.descriptionProvider =3D descriptionProvider > + } > + > + protected def unbindWebDescriptionProvider(descriptionProvider: > WebDescriptionProvider) =3D { > + if (descriptionProvider =3D=3D this.descriptionProvider) = { > + this.descriptionProvider =3D null > + } > + } > + > + > + protected def bindRenderletManager(renderletmanager: > RenderletManager): Unit =3D { > + renderletManager =3D renderletmanager > + } > + > + protected def unbindRenderletManager(renderletmanager: > RenderletManager): Unit =3D { > + if (renderletManager =3D=3D renderletmanager) { > + renderletManager =3D null > + } > + } > + > + > + // > + //needed by code > + // > + private var descriptionProvider: WebDescriptionProvider =3D null > + private var webIdGraphsService: WebIdGraphsService =3D null > + > + // > + //needed by framework > + // > + > + //called by the ssp, web component > + private var renderletManager: RenderletManager =3D null > + > + //set in activate. But is it useful to keep an pointer to it? > + //private var componentContext: ComponentContext =3D null > + > +} > \ No newline at end of file > > Modified: > incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.acc= ountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountco= ntrolpanel/ProfilePanel.scala > URL: > http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.acc= ountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apach= e/clerezza/platform/accountcontrolpanel/ProfilePanel.scala?rev=3D1081290&r1= =3D1081289&r2=3D1081290&view=3Ddiff > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- > incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.acc= ountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountco= ntrolpanel/ProfilePanel.scala > (original) > +++ > incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.acc= ountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountco= ntrolpanel/ProfilePanel.scala > Mon Mar 14 09:04:51 2011 > @@ -18,7 +18,7 @@ > */ > package org.apache.clerezza.platform.accountcontrolpanel > > -import java.util.ArrayList > +import java.util.List > import java.util.Arrays > import java.util.Iterator > import org.apache.clerezza.platform.security.UserUtil > @@ -33,7 +33,6 @@ import org.apache.clerezza.platform.conf > import org.apache.clerezza.platform.typerendering.RenderletManager > import > org.apache.clerezza.platform.typerendering.scalaserverpages.ScalaServerPa= gesRenderlet > import org.apache.clerezza.platform.usermanager.UserManager > -import org.apache.clerezza.platform.users.WebIdGraphsService > import org.apache.clerezza.rdf.core._ > import org.apache.clerezza.rdf.core.access.TcManager > import org.apache.clerezza.rdf.core.impl.SimpleMGraph > @@ -62,31 +61,30 @@ import java.net.URL > import java.security.AccessController > import java.security.PrivilegedAction > import java.security.interfaces.RSAPublicKey > -import java.util.List > import org.apache.clerezza.platform.typerendering.scala.PageRenderlet > import org.apache.clerezza.rdf.ontologies.RDFS > import org.apache.clerezza.ssl.keygen.KeygenService > +import org.apache.clerezza.platform.users.{WebDescriptionProvider, > WebIdGraphsService} > + > +object ProfilePanel { > + private val logger: Logger =3D > LoggerFactory.getLogger(classOf[ProfilePanel]) > +} > > /** > * Presents a panel where the user can create a webid and edit her profil= e. > * > * @author reto > */ > -@Path("/user/{id}/profile") > -object ProfilePanel { > - private val logger: Logger =3D > LoggerFactory.getLogger(classOf[ProfilePanel]) > -} > > @Path("/user/{id}/profile") > -class ProfilePanel extends FileServer { > +class ProfilePanel { > + > import ProfilePanel.logger > > - protected def activate(componentContext: ComponentContext): Unit = =3D > { > - configure(componentContext.getBundleContext, > "profile-staticweb") > - } > > @GET > - def getPersonalProfilePage(@Context uriInfo: UriInfo, > @PathParam(value =3D "id") userName: String): GraphNode =3D { > + def getPersonalProfilePage(@Context uriInfo: UriInfo, > + > @PathParam(value =3D "id") userName: String): GraphNode =3D { > TrailingSlash.enforceNotPresent(uriInfo) > var resultNode: GraphNode =3D getPersonalProfile(userName,= new > UriRef(uriInfo.getAbsolutePath.toString)) > resultNode.addProperty(RDF.`type`, PLATFORM.HeadedPage) > @@ -94,7 +92,8 @@ class ProfilePanel extends FileServer { > return resultNode > } > > - private def getPersonalProfile(userName: String, profile: UriRef)= : > GraphNode =3D { > + private def getPersonalProfile(userName: String, > + > profile: UriRef): GraphNode =3D { > return AccessController.doPrivileged(new > PrivilegedAction[GraphNode] { > def run: GraphNode =3D { > var userInSystemGraph: GraphNode =3D > userManager.getUserInSystemGraph(userName) > @@ -143,7 +142,10 @@ class ProfilePanel extends FileServer { > } > > @POST > - @Path("set-existing-webid") def setExistingWebId(@Context uriInfo= : > UriInfo, @FormParam("webid") webId: UriRef, @PathParam(value =3D "id") > userName: String): Response =3D { > + @Path("set-existing-webid") > + def setExistingWebId(@Context uriInfo: UriInfo, > + > @FormParam("webid") webId: UriRef, > + > @PathParam(value =3D "id") userName: String): Response =3D { > return AccessController.doPrivileged(new > PrivilegedAction[Response] { > def run: Response =3D { > var userInSystemGraph: GraphNode =3D > userManager.getUserInSystemGraph(userName) > @@ -154,7 +156,9 @@ class ProfilePanel extends FileServer { > } > > @POST > - @Path("create-new-web-id") def createNewWebId(@Context uriInfo: > UriInfo, @PathParam(value =3D "id") userName: String): Response =3D { > + @Path("create-new-web-id") > + def createNewWebId(@Context uriInfo: UriInfo, > + @PathParam(value= =3D > "id") userName: String): Response =3D { > val ppd: UriRef =3D getSuggestedPPDUri(userName) > val webId: UriRef =3D new UriRef(ppd.getUnicodeString + "#= me") > val webIdGraphs: WebIdGraphsService#WebIdGraphs =3D > webIdGraphsService.getWebIdGraphs(webId) > @@ -169,24 +173,38 @@ class ProfilePanel extends FileServer { > } > > @POST > - @Path("addContact") def addContact(@Context uriInfo: UriInfo, > @FormParam("webId") contactWebID: UriRef): Response =3D { > - if (contactWebID !=3D null) { > + @Path("addContact") > + def addContact(@Context uriInfo: UriInfo, > + @FormParam("webId") > newContacts: java.util.List[UriRef]): Response =3D { > + import collection.JavaConversions._ > + if (newContacts.size >0) { > val userName: String =3D UserUtil.getCurrentUserNa= me > var me: GraphNode =3D > AccessController.doPrivileged(new PrivilegedAction[GraphNode] { > def run: GraphNode =3D { > return > userManager.getUserGraphNode(userName) > } > }) > - val webIdGraphs: WebIdGraphsService#WebIdGraphs = =3D > webIdGraphsService.getWebIdGraphs(me.getNode.asInstanceOf[UriRef]) > - var meGrph: GraphNode =3D new GraphNode(me.getNod= e, > webIdGraphs.localGraph) > - webIdGraphsService.getWebIdGraphs(contactWebID) > - meGrph.addProperty(FOAF.knows, contactWebID) > + for (contactWebID <- newContacts) { > + val webIdGraphs: > WebIdGraphsService#WebIdGraphs =3D > webIdGraphsService.getWebIdGraphs(me.getNode.asInstanceOf[UriRef]) > + var meGrph: GraphNode =3D new > GraphNode(me.getNode, webIdGraphs.localGraph) > + > webIdGraphsService.getWebIdGraphs(contactWebID) > + meGrph.addProperty(FOAF.knows, > contactWebID) > + } //todo: one should catch errors here (bad uris > sent for ex > } > return RedirectUtil.createSeeOtherResponse("../profile", > uriInfo) > } > > + > @POST > - @Path("keygen") def createCert(@FormParam("webId") webId: UriRef, > @FormParam("cn") commonName: String, @FormParam("spkac") spkac: String, > @FormParam("crmf") crmf: String, @FormParam("hours") hours: String, > @FormParam("days") days: String, @FormParam("csr") csr: String, > @FormParam("comment") comment: String): Response =3D { > + @Path("keygen") > + def createCert(@FormParam("webId") webId: UriRef, > + @FormParam("cn") > commonName: String, > + @FormParam("spkac") spkac= : > String, > + @FormParam("crmf") crmf: > String, > + @FormParam("hours") hours= : > String, > + @FormParam("days") days: > String, > + @FormParam("csr") csr: > String, > + @FormParam("comment") > comment: String): Response =3D { > logger.info("in keygen code. webId=3D{}", webId) > logger.info("cn=3D{}", commonName) > logger.info("hours=3D{}", hours) > @@ -255,9 +273,10 @@ class ProfilePanel extends FileServer { > val webIdGraphs: WebIdGraphsService#WebIdGraphs =3D > webIdGraphsService.getWebIdGraphs(webId) > val agent: GraphNode =3D new GraphNode(webId, > webIdGraphs.localGraph) > var subjects: Iterator[GraphNode] =3D > agent.getSubjectNodes(CERT.identity) > - import scala.util.control.Breaks._ > + import scala.util.control.Breaks._ > breakable { > - import scala.collection.JavaConversions._ //to > for loop through iterators > + import scala.collection.JavaConversions._ > + //to for loop through iterators > for (nl <- subjects) { > var modulusIt: Iterator[Resource] =3D > nl.getObjects(RSA.modulus) > if (!modulusIt.hasNext) break > @@ -316,16 +335,6 @@ class ProfilePanel extends FileServer { > } > } > > - protected def bindTcManager(tcmanager: TcManager): Unit =3D { > - tcManager =3D tcmanager > - } > - > - protected def unbindTcManager(tcmanager: TcManager): Unit =3D { > - if (tcManager =3D=3D tcmanager) { > - tcManager =3D null > - } > - } > - > protected def bindRenderletManager(renderletmanager: > RenderletManager): Unit =3D { > renderletManager =3D renderletmanager > } > @@ -356,10 +365,33 @@ class ProfilePanel extends FileServer { > } > } > > + protected def bindWebDescriptionProvider(descriptionProvider: > WebDescriptionProvider) =3D { > + this.descriptionProvider =3D descriptionProvider > + } > + > + protected def unbindWebDescriptionProvider(descriptionProvider: > WebDescriptionProvider) =3D { > + if (descriptionProvider =3D=3D this.descriptionProvider) = { > + this.descriptionProvider =3D null > + } > + } > + > + protected def activate(componentContext: ComponentContext): Unit = =3D > { > + this.componentContext =3D componentContext > + } > + > + > private var userManager: UserManager =3D null > - private var keygenSrvc: KeygenService =3D null > - private var tcManager: TcManager =3D null > - private var renderletManager: RenderletManager =3D null > + > + //todo: does one need both of these? > private var webIdGraphsService: WebIdGraphsService =3D null > + private var descriptionProvider: WebDescriptionProvider =3D null > + > + private var keygenSrvc: KeygenService =3D null > private var platformConfig: PlatformConfig =3D null > + > + //todo: are these this needed? It's not used it seems > + private var renderletManager: RenderletManager =3D null > + > + private var componentContext: ComponentContext =3D null > + > } > \ No newline at end of file > > Added: > incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.acc= ountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountco= ntrolpanel/person_panel.scala > URL: > http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.acc= ountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apach= e/clerezza/platform/accountcontrolpanel/person_panel.scala?rev=3D1081290&vi= ew=3Dauto > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- > incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.acc= ountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountco= ntrolpanel/person_panel.scala > (added) > +++ > incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.acc= ountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountco= ntrolpanel/person_panel.scala > Mon Mar 14 09:04:51 2011 > @@ -0,0 +1,215 @@ > +/* > + * 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.accountcontrolpanel > + > +import org.apache.clerezza.rdf.core._ > +import org.apache.clerezza.rdf.scala.utils._ > +import org.apache.clerezza.rdf.scala.utils.Preamble._ > +import org.apache.clerezza.platform.typerendering.scala._ > +import org.apache.clerezza.rdf.core.UriRef > +import > org.apache.clerezza.platform.accountcontrolpanel.ontologies.CONTROLPANEL > +import org.apache.clerezza.rdf.utils.GraphNode > +import org.apache.clerezza.rdf.ontologies.{RDFS, RDF, FOAF} > +import xml.{NodeSeq, NodeBuffer, Text, Node} > +import java.net.{URLEncoder, URL} > + > +object person_panel { > + final val emptyText =3D new Text("") > + > + def ifE[T](arg:T)(template: T=3D>Node ):NodeSeq =3D { > + def isEmpty(arg: Any): Boolean =3D { > + arg match { > + case prod: Product =3D> > prod.productIterator.forall(isEmpty(_)) > + case str: String =3D> (str.size =3D=3D 0) > + case it: CollectedIter[RichGraphNode] =3D= > > (it.size =3D=3D 0) > + case node: RichGraphNode =3D> (null =3D= =3D node) > + case other: AnyRef =3D> (null =3D=3D othe= r) > + case _ =3D> false //literals can't be emp= ty > + } > + } > + if (isEmpty(arg)) return emptyText else template(arg) > + } > + > + def firstOf(node: RichGraphNode, uris: > UriRef*):CollectedIter[RichGraphNode] =3D { > + for (uri <- uris) { > + val res : CollectedIter[RichGraphNode] =3D node/u= ri > + if (res.size>0) return res > + } > + return new CollectedIter[RichGraphNode]() > + } > + > + /** > + * Show a person: a picture, a link to their local profile and > their name > + * Different default icons should be shown if the agent is a > person, company, group, robot... > + * > + * assumes the p is WebID node (can change later) > + */ > + def personInABox(p: RichGraphNode): NodeSeq =3D { > + val pix =3D firstOf(p, FOAF.depiction, FOAF.logo).getNode > match { > + case uri: UriRef =3D> uri.getUnicodeString > + case _ =3D> " > http://upload.wikimedia.org/wikipedia/commons/0/0a/Gnome-stock_person.svg= " > + } > + > + val pixml=3D { src=3D{pix} width=3D"70px" /> } > + return pixml ++ new Text(getName(p)) > + } > + > + def encode(url: String): String =3D URLEncoder.encode(url,"UTF8"= ) > + > + /** > + * get a useable name from the properties available including nic= k > + */ > + def getName(p: RichGraphNode): String =3D { > + val name =3D p/FOAF.name*; > + if ("" !=3D name ) { return name } > + val firstNm: String =3D p/FOAF.firstName*; > + val fmlyNm :String =3D firstOf(p, > FOAF.family_name,FOAF.familyName)*; > + if ("" !=3D firstNm || "" !=3D fmlyNm) { return firstNm+= " > "+fmlyNm } > + return p* > + > + } > + > + def personHtml(p: RichGraphNode): NodeSeq =3D { > + {Person}++ > + ifE(p!){case f:UriRef=3D>( name=3D"webId" value=3D{p*}/>Add as contact href=3D{p*}>{p*}); > + case _ =3D> emptyText;}++ > + > ifE(p/FOAF.name){f=3D>(Name:{f*})}++ > + ifE(p/FOAF.firstName){f=3D>(First > Name:{f})} ++ > + > ifE(firstOf(p,FOAF.family_name,FOAF.familyName)){f=3D>(Family > Name:{f*})} ++ > + ifE(p/FOAF.mbox){f =3D>(Mbox:
    {for > (m<-f)yield {
  • {m*}
  • }}
)}++ > + ifE(p/FOAF.homepage){f > =3D>(Homepage:)}++ > + ifE(p/FOAF.currentProject){f =3D>(Current > Project(s):
    {for (x<-f) yield >
  • {linkNlabel(x)}
  • }
)}++ > + ifE(p/FOAF.depiction){f=3D>(Depictions:= src=3D{f*} />)}++ > + ifE(p/FOAF.logo){f=3D>(Logo: />)}++ > + ifE(p/FOAF.knows){k=3D>(claims to > know{for (fr<-k) yield displayAgent(fr)}
)} > + } > + > + > + def groupHtml(grp: RichGraphNode): NodeSeq =3D { > + > ifE(grp/FOAF.name){f=3D>(Name:{f})}++ > + ifE(grp/FOAF.logo*){f=3D>(Logo: />)} > + } > + > + > + def displayAgent(agent: RichGraphNode): NodeSeq =3D { > + val typ: Resource =3D (agent/RDF.`type`).! > + return typ match { > + case FOAF.Person =3D> personHtml(agent) > + case FOAF.Group =3D> groupHtml(agent) > + case FOAF.Agent =3D> agentHtml(agent) > + case _ =3D> emptyText > + } > + } > + > + def linkNlabel(res: RichGraphNode): Node =3D { > + var label: String =3D res/RDFS.label! match { > + case uri: UriRef =3D> uri.toString > + case _ =3D> res* > + } > + return {label} > + } > + > + def agentHtml(agent: RichGraphNode) =3D {{ > + ifE({agent/FOAF.name}){ case > (f)=3D>()}++ > + > ifE(agent/FOAF.logo*){f=3D>(<= /tr>)} > + }
Name:{f}
Logo:
} > + > +} > + > +class person_panel extends PageRenderlet { > + val rdfType =3D CONTROLPANEL.ProfileViewerPage > + override def mode =3D "naked" > + import person_panel._ > + > + > + override def renderedPage(arguments: RenderedPage.Arguments): > RenderedPage =3D { > + new RenderedPage(arguments) { > + > + override def content =3D { > + def cp(s: Any) =3D new UriRef(" > http://clerezza.org/2009/03/controlpanel#" + s) > + def platform(s: Any) =3D new UriRef(" > http://clerezza.org/2009/08/platform#" + s) > + > resultDocModifier.addStyleSheet("profile/style/profile.css"); > + resultDocModifier.setTitle("Profile Viewer"); > + resultDocModifier.addNodes2Elem("tx-module",

Account > Control Panel

); > + resultDocModifier.addNodes2Elem("tx-module-tabs-ol",
  • class=3D"tx-active">Profile Viewer
  • ); > + resultDocModifier.addNodes2Elem("tx-module-tabs-ol",
  • = href=3D"control-panel">Settings
  • ); > + resultDocModifier.addNodes2Elem("tx-module-tabs-ol",
  • href=3D"profile">Profile
  • ); > + > + val it: CollectedIter[RichGraphNode] =3D res / FOAF.primaryTop= ic > + val primeTpc: RichGraphNode =3D it.apply(0) > + val agent : RichGraphNode=3D primeTpc! match { > + case uri : UriRef =3D> fetch(uri) > + case _ =3D> res > + } > + > + def relations() =3D { > + {for (friend <- agent/FOAF.knows) { > + > + } > + > + }
    {friend*}
    action=3D"profile/people"> > + > + > +
    > + } > + > + > + def allAgentsHtml(tc: TripleCollection): Node =3D { > + All agents found > + { import collection.JavaConversions._ > + val base =3D new > URL(primeTpc.getNode.asInstanceOf[UriRef].getUnicodeString()); > + val lclPrson =3D for (tr: Triple <- tc.filter(n= ull, > RDF.`type`, FOAF.Person); > + subjUrl =3D try { new > URL(tr.getSubject.asInstanceOf[UriRef].getUnicodeString) } catch { case = _ > =3D> null } > + if (subjUrl !=3D null && > base.sameFile(subjUrl)) > + ) yield tr.getSubject > + for (p <- lclPrson) yield > + {personHtml(new > GraphNode(p,tc))} > + } > + } > + > +
    > +

    Profile Viewer

    > +
    > + > + { val typ: Resource =3D (agent/RDF.`type`).! > + typ match { > + case FOAF.Person =3D> personHtml(agent) > + case FOAF.Group =3D> groupHtml(agent) > + case FOAF.Agent =3D> agentHtml(agent) > + case _ =3D> allAgentsHtml(agent.getGrap= h) > + } > + } > +
    > + > +
    > +
    {
    > +                         val s
    > =3Dorg.apache.clerezza.rdf.core.serializedform.Serializer.getInstance();
    > +                         import java.io._
    > +                         val bout =3D new ByteArrayOutputStream()
    > +                         s.serialize(bout,agent.getGraph(),"text/rdf+n3"=
    );
    > +                         bout.toString("UTF-8")
    > +                       }
    > +
    > + } > + > + } > + } > +} > + > + > > Modified: > incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.acc= ountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountco= ntrolpanel/profile_panel.scala > URL: > http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.acc= ountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apach= e/clerezza/platform/accountcontrolpanel/profile_panel.scala?rev=3D1081290&r= 1=3D1081289&r2=3D1081290&view=3Ddiff > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- > incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.acc= ountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountco= ntrolpanel/profile_panel.scala > (original) > +++ > incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.acc= ountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountco= ntrolpanel/profile_panel.scala > Mon Mar 14 09:04:51 2011 > @@ -27,6 +27,7 @@ import java.text._ > import org.apache.clerezza.rdf.core.UriRef > import > org.apache.clerezza.platform.accountcontrolpanel.ontologies.CONTROLPANEL > import org.apache.clerezza.rdf.ontologies.{RDFS, DC, FOAF} > +import org.apache.clerezza.rdf.utils.GraphNode > > class profile_panel extends PageRenderlet { > val rdfType =3D CONTROLPANEL.ProfilePage > @@ -123,16 +124,22 @@ class profile_panel extends PageRenderle > > >

    Contacts

    > - > - {for (friend <- agent/FOAF.knows) { > - > - } > - > - }
    {friend*}
    action=3D"profile/addContact"> > - > - > -
    > - > +
    > + { var i =3D0 > + val friends =3D for (friend <- agent/FOAF.knows= ) > yield { > + import person_panel._ > + val node =3D friend.getNode() match { > + case uri: UriRef =3D> > personInABox(fetch(uri)) > + case _ =3D> emptyText //one could show = info > with bnodes too... > + } > + > + } > + for (row <- friends.grouped(5)) yield > {row} > + } > + > +
    {node}
    /> > +
    > +
    > >

    Key and Certificate Creation

    > > @@ -220,12 +227,13 @@ class profile_panel extends PageRenderle > profile.

    > } > > -
    > +
    >

    Personal Profile

    {agent ! match { > - case _: BNode =3D> createWebId() > - case _: UriRef =3D> existingWebId() > - }} > -
    > + case _: BNode =3D> createWebId() > + case _: UriRef =3D> existingWebId() > + }} > +
    > + > } > } > } > @@ -244,7 +252,7 @@ class profile_panel extends PageRenderle > val sbuf =3D new StringBuffer(bstr.size + (bstr.size/2)+10) > var cnt =3D 0 > for (c <- bstr.toCharArray) { > - if ((cnt % 2) =3D=3D 0) { sbuf.append(' ') } > + if ((cnt % 2) =3D=3D 0) sbuf.append(' ') > sbuf.append(c) > cnt +=3D 1 > } > > Modified: > incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.acc= ountcontrolpanel.ontologies/src/main/resources/org/apache/clerezza/platform= /accountcontrolpanel/ontologies/controlpanel.rdf > URL: > http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.acc= ountcontrolpanel/platform.accountcontrolpanel.ontologies/src/main/resources= /org/apache/clerezza/platform/accountcontrolpanel/ontologies/controlpanel.r= df?rev=3D1081290&r1=3D1081289&r2=3D1081290&view=3Ddiff > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- > incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.acc= ountcontrolpanel.ontologies/src/main/resources/org/apache/clerezza/platform= /accountcontrolpanel/ontologies/controlpanel.rdf > (original) > +++ > incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.acc= ountcontrolpanel.ontologies/src/main/resources/org/apache/clerezza/platform= /accountcontrolpanel/ontologies/controlpanel.rdf > Mon Mar 14 09:04:51 2011 > @@ -35,6 +35,15 @@ > http://clerezza.org/2009/03/controlpanel#" /> > > > + > + > + profile viewer page > + A web page for viewing profiles = of > agents (individuals or groups) information on the > + web. Should allow a logged in user to add them as contact= s > + > + http://clerezza.org/2009/03/controlpanel#" /> > + > + > > > > > Modified: > incubator/clerezza/trunk/parent/platform.security.foafssl/core/pom.xml > URL: > http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.sec= urity.foafssl/core/pom.xml?rev=3D1081290&r1=3D1081289&r2=3D1081290&view=3Dd= iff > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- incubator/clerezza/trunk/parent/platform.security.foafssl/core/pom.xm= l > (original) > +++ incubator/clerezza/trunk/parent/platform.security.foafssl/core/pom.xm= l > Mon Mar 14 09:04:51 2011 > @@ -100,7 +100,7 @@ > > OSGI-INF/serviceComponents.xml > > !org.apache.clerezza.foafssl.ontologies, > > org.apache.clerezza.foafssl.* > - > ${groupId}.${artifactId} > + > ${project.groupId}.${project.artifactId} > > > > > Modified: > incubator/clerezza/trunk/parent/platform.security.foafssl/core/src/main/s= cala/org/apache/clerezza/foafssl/ssl/X509TrustManagerWrapperService.scala > URL: > http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.sec= urity.foafssl/core/src/main/scala/org/apache/clerezza/foafssl/ssl/X509Trust= ManagerWrapperService.scala?rev=3D1081290&r1=3D1081289&r2=3D1081290&view=3D= diff > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- > incubator/clerezza/trunk/parent/platform.security.foafssl/core/src/main/s= cala/org/apache/clerezza/foafssl/ssl/X509TrustManagerWrapperService.scala > (original) > +++ > incubator/clerezza/trunk/parent/platform.security.foafssl/core/src/main/s= cala/org/apache/clerezza/foafssl/ssl/X509TrustManagerWrapperService.scala > Mon Mar 14 09:04:51 2011 > @@ -30,7 +30,6 @@ import java.security.interfaces.RSAPubli > import java.util.Date > import javax.net.ssl.X509TrustManager; > import org.apache.clerezza.foafssl.Utilities > -import org.apache.clerezza.platform.users.WebDescriptionProvider > import org.apache.clerezza.foafssl.ontologies.CERT > import org.apache.clerezza.foafssl.ontologies.RSA > import org.apache.clerezza.platform.Constants > @@ -56,7 +55,8 @@ import org.apache.clerezza.rdf.ontologie > import org.apache.clerezza.rdf.scala.utils.Preamble._ > import org.jsslutils.sslcontext.X509TrustManagerWrapper > import > org.jsslutils.sslcontext.trustmanagers.TrustAllClientsWrappingTrustManage= r > -import org.slf4j.LoggerFactory; > +import org.slf4j.LoggerFactory > +import org.apache.clerezza.platform.users.{Cache, WebDescriptionProvider= } > > class X509TrustManagerWrapperService() extends X509TrustManagerWrapper { > > @@ -117,11 +117,11 @@ class X509TrustManagerWrapperService() e > private val systemGraphUri =3D Constants.SYSTEM_GRAPH_URI; > > private def verify(uriRef: UriRef, publicKey: PublicKey): Unit =3D= { > - var webDescription =3D > descriptionProvider.getWebDescription(uriRef, false) > + var webDescription =3D > descriptionProvider.getWebDescription(uriRef, Cache.CacheOnly) > if ( > !verify(uriRef, publicKey, webDescription.getGraph= ) > ) { > - webDescription =3D > descriptionProvider.getWebDescription(uriRef, true) > + webDescription =3D > descriptionProvider.getWebDescription(uriRef, Cache.ForceUpdate) > if ( > !verify(uriRef, publicKey, > webDescription.getGraph) > ) throw new CertificateException > > Modified: > incubator/clerezza/trunk/parent/platform.security.foafssl/test/pom.xml > URL: > http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.sec= urity.foafssl/test/pom.xml?rev=3D1081290&r1=3D1081289&r2=3D1081290&view=3Dd= iff > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- incubator/clerezza/trunk/parent/platform.security.foafssl/test/pom.xm= l > (original) > +++ incubator/clerezza/trunk/parent/platform.security.foafssl/test/pom.xm= l > Mon Mar 14 09:04:51 2011 > @@ -107,7 +107,7 @@ > > > OSGI-INF/serviceComponents.xml > > org.apache.clerezza.foafssl.testservlets > - > ${groupId}.${artifactId} > + > ${project.groupId}.${project.artifactId} > > > > > Modified: > incubator/clerezza/trunk/parent/platform.typerendering.scala/pom.xml > URL: > http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.typ= erendering.scala/pom.xml?rev=3D1081290&r1=3D1081289&r2=3D1081290&view=3Ddif= f > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- incubator/clerezza/trunk/parent/platform.typerendering.scala/pom.xml > (original) > +++ incubator/clerezza/trunk/parent/platform.typerendering.scala/pom.xml > Mon Mar 14 09:04:51 2011 > @@ -28,6 +28,10 @@ > org.scala-lang > scala-library >
    > + > + org.apache.clerezza > + platform.users.core > + >
    > > > > Modified: > incubator/clerezza/trunk/parent/platform.typerendering.scala/src/main/sca= la/org/apache/clerezza/platform/typerendering/scala/RenderedPage.scala > URL: > http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.typ= erendering.scala/src/main/scala/org/apache/clerezza/platform/typerendering/= scala/RenderedPage.scala?rev=3D1081290&r1=3D1081289&r2=3D1081290&view=3Ddif= f > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- > incubator/clerezza/trunk/parent/platform.typerendering.scala/src/main/sca= la/org/apache/clerezza/platform/typerendering/scala/RenderedPage.scala > (original) > +++ > incubator/clerezza/trunk/parent/platform.typerendering.scala/src/main/sca= la/org/apache/clerezza/platform/typerendering/scala/RenderedPage.scala > Mon Mar 14 09:04:51 2011 > @@ -5,7 +5,6 @@ import java.io.PrintWriter > import java.net.URI > import javax.ws.rs.core.HttpHeaders > import javax.ws.rs.core.MediaType > -import org.osgi.framework.BundleContext > import scala.xml._ > import org.apache.clerezza.platform.typerendering._ > import > org.apache.clerezza.platform.typerendering.Renderlet.RequestProperties > @@ -14,14 +13,18 @@ import org.apache.clerezza.rdf.ontologie > import org.apache.clerezza.rdf.core._ > import org.apache.clerezza.rdf.utils._ > import org.apache.clerezza.rdf.scala.utils.Preamble._ > - > +import java.security.{PrivilegedAction, AccessController} > +import org.osgi.framework.{BundleContext, ServiceReference} > +import org.apache.clerezza.platform.users.{WebDescriptionProvider, Cache= } > +import org.apache.clerezza.rdf.scala.utils.RichGraphNode > > /** > * PageRenderlet.renderedPage returns an instance of this class, > implementing > - * the content method to produce an XML Elmenet suitable as response to > the > + * the content method to produce an XML Element suitable as response to > the > * request yielding to the arguments passed to the constructor. > */ > abstract class RenderedPage(arguments: RenderedPage.Arguments) { > + > val RenderedPage.Arguments( > res: GraphNode, > context: GraphNode, > @@ -41,32 +44,59 @@ abstract class RenderedPage(arguments: R > val requestHeaders =3D requestProperties.getRequestHeaders > val responseHeaders =3D requestProperties.getResponseHeaders > > - def render(resource : GraphNode) : Seq[Node] =3D { > + def render(resource: GraphNode): Seq[Node] =3D { > modeOption match { > case Some(m) =3D> render(resource, m) > case None =3D> render(resource, "naked") > } > } > > - def render(resource : GraphNode, mode : String) =3D { > - def parseNodeSeq(string : String) =3D { > - > _root_.scala.xml.XML.loadString(""+string+"").child > + def render(resource: GraphNode, mode: String) =3D { > + def parseNodeSeq(string: String) =3D { > + _root_.scala.xml.XML.loadString("" + string= + > "").child > } > val baos =3D new java.io.ByteArrayOutputStream > renderer.render(resource, context, mode, baos) > parseNodeSeq(new String(baos.toByteArray)) > } > > + def fetch(uri: UriRef) : GraphNode =3D { > + val webSrvc =3D AccessController.doPrivileged(new > PrivilegedAction[WebDescriptionProvider] { > + def run: WebDescriptionProvider =3D { > + val cntxt: BundleContext =3D > requestProperties.bundleContext > + var serviceReference: ServiceReference = =3D > cntxt.getServiceReference("org.apache.clerezza.platform.users.WebDescript= ionProvider") > + if (serviceReference !=3D null) { > + return > cntxt.getService(serviceReference).asInstanceOf[WebDescriptionProvider] > + } else { > + return null > + } > + } > + }) > + //This should return not a graph, but a graph surrounded > with HTTP metadata, so that the user > + //connection error messages can be designed, and so on. > + //The graph should be fetched as the user also if this is > required. > + val grph =3D webSrvc.fetchSemantics(uri,Cache.Fetch) > + return new GraphNode(uri,grph) > + } > + > + /** > + * This is an object that allows one to use some nice shortcuts i= n > scala based subclasses > + * - $variable will get the value of the sharedRenderingValues ha= sh > + * - $variable =3D value allows one to update the > sharedRenderingValues hash > + * - $? not sure there... > + */ > object $ { > def apply(key: String) =3D sharedRenderingValues.get(key) > + > def update(key: String, value: Object) =3D > sharedRenderingValues.put(key, value) > + > def apply[T](implicit m: Manifest[T]): T =3D { > val clazz =3D m.erasure.asInstanceOf[Class[T]] > requestProperties.getRenderingService(clazz) > } > } > > - def ifx[T](con: =3D> Boolean)(f: =3D> T) : T =3D { > + def ifx[T](con: =3D> Boolean)(f: =3D> T): T =3D { > if (con) f else null.asInstanceOf[T] > } > > @@ -82,17 +112,38 @@ abstract class RenderedPage(arguments: R > ) > out.flush() > > - def content : AnyRef; > + /** > + * This is the main method/variable that needs to be implemented = by > subclasses > + */ > + def content: AnyRef; > > > } > + > object RenderedPage { > - case class Arguments(res: GraphNode, context: GraphNode, > - sharedRenderingValues: > java.util.Map[String, Object], > - renderer: CallbackRenderer , > - renderingSpecificationOption: > Option[URI], > - modeOption: Option[String], > - mediaType: MediaType, > - requestProperties: > RequestProperties, > - os: OutputStream); > + > + /** > + * Class to encapsulate information sent to the rendering engine. > + * > + * @param res RDF resource to be rendered with the template. > + * @param context RDF resource providing a rendering context. > + * @param sharedRenderingValues a map that can be used for sharin= g > values > + * across the different Renderlets involved in a rendering proces= s > + * @param callbackRenderer renderer for call backs. > + * @param renderingSpecification the rendering specification > + * @param modeOption the mode this Renderlet was invoked with, th= is > is mainly used > + * so that the callbackRenderer can be claeed inheriting the mode= . > + * @param mediaType the media type this media produces (a part o= f) > + * @param requestProperties properties of the http request, may b= e > null > + * @param os where the output will be written to. > + */ > + case class Arguments(res: GraphNode, > + context: > GraphNode, > + > sharedRenderingValues: java.util.Map[String, Object], > + renderer: > CallbackRenderer, > + > renderingSpecificationOption: Option[URI], > + modeOptio= n: > Option[String], > + mediaType= : > MediaType, > + > requestProperties: RequestProperties, > + os: > OutputStream); > } > \ No newline at end of file > > Modified: > incubator/clerezza/trunk/parent/platform.typerendering/platform.typerende= ring.core/src/main/java/org/apache/clerezza/platform/typerendering/Renderer= .java > URL: > http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.typ= erendering/platform.typerendering.core/src/main/java/org/apache/clerezza/pl= atform/typerendering/Renderer.java?rev=3D1081290&r1=3D1081289&r2=3D1081290&= view=3Ddiff > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- > incubator/clerezza/trunk/parent/platform.typerendering/platform.typerende= ring.core/src/main/java/org/apache/clerezza/platform/typerendering/Renderer= .java > (original) > +++ > incubator/clerezza/trunk/parent/platform.typerendering/platform.typerende= ring.core/src/main/java/org/apache/clerezza/platform/typerendering/Renderer= .java > Mon Mar 14 09:04:51 2011 > @@ -64,7 +64,7 @@ public interface Renderer { > * rendering specification. > * > * @param res RDF resource to be rendered with the template. > - * @param context RDF resource providing a redering context. > + * @param context RDF resource providing a rendering context. > * @param uriInfo the uriInfo of the request, the renderlet may us= e > * @param httpHeaders the http-headers of the request > * @param os where the output will be written to. > > Modified: > incubator/clerezza/trunk/parent/platform.typerendering/platform.typerende= ring.core/src/main/java/org/apache/clerezza/platform/typerendering/Renderle= t.java > URL: > http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.typ= erendering/platform.typerendering.core/src/main/java/org/apache/clerezza/pl= atform/typerendering/Renderlet.java?rev=3D1081290&r1=3D1081289&r2=3D1081290= &view=3Ddiff > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- > incubator/clerezza/trunk/parent/platform.typerendering/platform.typerende= ring.core/src/main/java/org/apache/clerezza/platform/typerendering/Renderle= t.java > (original) > +++ > incubator/clerezza/trunk/parent/platform.typerendering/platform.typerende= ring.core/src/main/java/org/apache/clerezza/platform/typerendering/Renderle= t.java > Mon Mar 14 09:04:51 2011 > @@ -49,7 +49,7 @@ public interface Renderlet { > private UriInfo uriInfo; > private MultivaluedMap responseHeaders; > private HttpHeaders requestHeaders; > - private final BundleContext bundleContext; > + public final BundleContext bundleContext; //public > only to test an idea > > public RequestProperties(UriInfo uriInfo, > HttpHeaders requestHeaders, > @@ -77,7 +77,7 @@ public interface Renderlet { > * Rendering services > * > * @param type > - * @return a intsance of the requested rendering services > + * @return a instance of the requested rendering services > */ > public T getRenderingService(final Class type) { > return AccessController.doPrivileged( > @@ -107,14 +107,14 @@ public interface Renderlet { > * engine. > * > * @param res RDF resource to be rendered with the template. > - * @param context RDF resource providing a redering context. > + * @param context RDF resource providing a rendering context. > * @param sharedRenderingValues a map that can be used for sharing > values > - * across the different renderlets involved in a rendering proces= s > + * across the different Renderlets involved in a rendering proces= s > * @param callbackRenderer renderer for call backs. > * @param renderingSpecification the rendering specification > * @param mediaType the media type this media produces (a part of= ) > * @param mode the mode this Renderlet was invoked with, this is > mainly used > - * so that the callbackeRenderer can be claeed inheriting the mod= e. > + * so that the callbackRenderer can be claeed inheriting the mode= . > * @param requestProperties properties of the http request, may be > null > * @param os where the output will be written to. > */ > > Modified: > incubator/clerezza/trunk/parent/platform.users/core/src/main/scala/org/ap= ache/clerezza/platform/users/WebDescriptionProvider.scala > URL: > http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.use= rs/core/src/main/scala/org/apache/clerezza/platform/users/WebDescriptionPro= vider.scala?rev=3D1081290&r1=3D1081289&r2=3D1081290&view=3Ddiff > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- > incubator/clerezza/trunk/parent/platform.users/core/src/main/scala/org/ap= ache/clerezza/platform/users/WebDescriptionProvider.scala > (original) > +++ > incubator/clerezza/trunk/parent/platform.users/core/src/main/scala/org/ap= ache/clerezza/platform/users/WebDescriptionProvider.scala > Mon Mar 14 09:04:51 2011 > @@ -20,15 +20,16 @@ > package org.apache.clerezza.platform.users > > import org.apache.clerezza.platform.Constants > -import org.apache.clerezza.rdf.core.TripleCollection > -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.utils.GraphNode > import org.apache.clerezza.rdf.utils.UnionMGraph > import org.osgi.service.component.ComponentContext > +import org.apache.clerezza.rdf.core.{MGraph, TripleCollection, UriRef} > +import org.apache.clerezza.rdf.core.impl.SimpleMGraph > > - > +//todo: this class can be generalised to a generalised semweb caching > service > +//there's not really a reason to have it specialised for WebIDs. > /** > * delivers the description of a resource. This description is based on > local > * data as well as (cached) web-data > @@ -59,7 +60,8 @@ class WebDescriptionProvider { > Constants.CONFIG_GRAPH_URI) > > private var authoritativeLocalGraphUnion: TripleCollection =3D nul= l > - > + > + /** OSGI method, called on activation */ > protected def activate(context: ComponentContext) =3D { > val baseTripleCollections =3D for (uri <- > authoritativeLocalGraphs) yield { > tcManager.getTriples(uri) > @@ -71,31 +73,61 @@ class WebDescriptionProvider { > authoritativeLocalGraphUnion =3D null > } > > + //todo: this should probably return Some[GraphNode] as it is > possible that there is no URI > + //todo: or it should return an explanation of what went wrong, fo= r > user processing > + //todo: why do we really need the merge with the system graph? Ho= w > doangerous is this? > /** > + * This graph merges remote information and local system > information > * > * @param uri the URI to fetch > * @param update true if the local cache is to be updated, false > otherwise > - * @return the cached Node as GraphNode with the > authoritativeLocalGraphUnion and if available the cache of the remote gra= ph > as underlying graph > + * @return the cached Node as GraphNode with the > authoritativeLocalGraphUnion > */ > - def getWebDescription(uri: UriRef, update: Boolean): GraphNode = =3D { > + def getWebDescription(uri: UriRef, update: Cache.Value): GraphNod= e > =3D { > + > + val grph =3D fetchSemantics(uri, update) > + val tc =3D new UnionMGraph(authoritativeLocalGraphUnion, > grph, authoritativeLocalGraphUnion) > + new GraphNode(uri, tc) > > - val webIdGraphs =3D webIdGraphsService.getWebIdGraphs(uri= ) > - if (webIdGraphs.isLocal) return new > GraphNode(uri,webIdGraphs.localGraph) > - if (update) { > - webIdGraphs.updateLocalCache() > + } > + > + /** > + * similar to cwm log:semantics relation. Fetches the graph > associated with a URI > + * this just returns a simple Graph for the representation at the > given URI.121 > + * > + * todo: should this return an MGraph, or a TripleCollection, or > something else? > + * > + * @param uri the URI to fetch > + * @param update true if the local cache is to be updated, false > otherwise > + * @return the cached Node as an MGraph > + * > + */ > + def fetchSemantics(uri: UriRef, update: Cache.Value): MGraph =3D = { > + val webIdGraphs =3D > webIdGraphsService.getWebIdGraphs(uri) > + if (webIdGraphs.isLocal) return webIdGraphs.localGraph > + > + //the logic here is not quite right, as we don't look at > time of previous fetch. > + update match { > + case Cache.Fetch =3D> if > (webIdGraphs.localCache.size() =3D=3D 0) webIdGraphs.updateLocalCache() > + case Cache.ForceUpdate =3D> > webIdGraphs.updateLocalCache() > + case Cache.CacheOnly =3D> {} > } > - val cacheGraphOption: Option[TripleCollection] =3D try { > - > Some(tcManager.getTriples(webIdGraphs.localCacheUri)) > + return try { > + new > SimpleMGraph(tcManager.getTriples(webIdGraphs.localCacheUri)) > } catch { > - case e: NoSuchEntityException =3D> None > - } > - val tripleCollection =3D cacheGraphOption match { > - case Some(g) =3D> new > UnionMGraph(authoritativeLocalGraphUnion, g) > - case None =3D> authoritativeLocalGraphUnion > + case e: NoSuchEntityException =3D> new > SimpleMGraph() > } > - new GraphNode(uri, tripleCollection) > - > + > } > > > } > + > +object Cache extends Enumeration { > + /** fetch if not in cache, if version in cache is out of date, or > return cache */ > + val Fetch =3D Value > + /** fetch from source whatever is in cache */ > + val ForceUpdate =3D Value > + /** only get cached version. If none exists return empty graph */ > + val CacheOnly =3D Value > +} > > Modified: > incubator/clerezza/trunk/parent/platform.users/core/src/main/scala/org/ap= ache/clerezza/platform/users/WebIdGraphsService.scala > URL: > http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.use= rs/core/src/main/scala/org/apache/clerezza/platform/users/WebIdGraphsServic= e.scala?rev=3D1081290&r1=3D1081289&r2=3D1081290&view=3Ddiff > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- > incubator/clerezza/trunk/parent/platform.users/core/src/main/scala/org/ap= ache/clerezza/platform/users/WebIdGraphsService.scala > (original) > +++ > incubator/clerezza/trunk/parent/platform.users/core/src/main/scala/org/ap= ache/clerezza/platform/users/WebIdGraphsService.scala > Mon Mar 14 09:04:51 2011 > @@ -38,6 +38,7 @@ import org.apache.clerezza.rdf.ontologie > import org.apache.clerezza.rdf.utils.UnionMGraph > > > +//todo: this class can be generalised to a generalised semweb caching > service > /** > * For agents with a Web-Id various graphs are available, these graphs ar= e > * grouped by WebIdGraphs which this service provides. > @@ -188,7 +189,14 @@ class WebIdGraphsService() { > case _ =3D> us > } > } > - > + > + //todo: follow redirects and keep track of them > + //todo: keep track of headers especially date and etag. > test for etag similarity > + //todo: it may be important to have blank node identifier= s > for graphs as the same webid, when called by different > + // agents could have very different content > + //todo: for https connection allow user to specify his > webid and send his key: ie allow web server to be an agent > + //todo: add GRDDL functionality, so that other return typ= es > can be processed too > + //todo: enable ftp and other formats (though content > negotiation won't work there) > def updateLocalCache() =3D { > val url =3D new URL(representationGraphUriString) > val connection =3D url.openConnection() > > Modified: > incubator/clerezza/trunk/parent/rdf.scala.utils/src/main/scala/org/apache= /clerezza/rdf/scala/utils/CollectedIter.scala > URL: > http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/rdf.scala.ut= ils/src/main/scala/org/apache/clerezza/rdf/scala/utils/CollectedIter.scala?= rev=3D1081290&r1=3D1081289&r2=3D1081290&view=3Ddiff > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- > incubator/clerezza/trunk/parent/rdf.scala.utils/src/main/scala/org/apache= /clerezza/rdf/scala/utils/CollectedIter.scala > (original) > +++ > incubator/clerezza/trunk/parent/rdf.scala.utils/src/main/scala/org/apache= /clerezza/rdf/scala/utils/CollectedIter.scala > Mon Mar 14 09:04:51 2011 > @@ -38,6 +38,7 @@ import java.util.concurrent.locks.Lock > class CollectedIter[T](iterCreator: () =3D> Iterator[T], readLock: Lock) > extends immutable.Seq[T] { > > def this(jList : java.util.List[T], readLock: Lock) =3D this(() = =3D> > jList.iterator(), readLock) > + def this() =3D this( ()=3D> > java.util.Collections.emptyList[T].iterator(),null) > > var iter =3D iterCreator() > var firstIter =3D true > > Modified: > incubator/clerezza/trunk/parent/rdf.scala.utils/src/main/scala/org/apache= /clerezza/rdf/scala/utils/RichGraphNode.scala > URL: > http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/rdf.scala.ut= ils/src/main/scala/org/apache/clerezza/rdf/scala/utils/RichGraphNode.scala?= rev=3D1081290&r1=3D1081289&r2=3D1081290&view=3Ddiff > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- > incubator/clerezza/trunk/parent/rdf.scala.utils/src/main/scala/org/apache= /clerezza/rdf/scala/utils/RichGraphNode.scala > (original) > +++ > incubator/clerezza/trunk/parent/rdf.scala.utils/src/main/scala/org/apache= /clerezza/rdf/scala/utils/RichGraphNode.scala > Mon Mar 14 09:04:51 2011 > @@ -26,6 +26,14 @@ import _root_.scala.collection.JavaConve > import _root_.scala.reflect.Manifest > > class RichGraphNode(node: GraphNode) extends GraphNode(node.getNode, > node.getGraph) { > + > + /* because it is tedious to wrap nodes as happens in a lot of cod= e. > + * > + * todo: does one really need to create the graph node? Is there = a > reason this is passed ike that, > + * todo: or was that just a quick hack? If it is because we don't > want to use any of the superclass implementations > + * todo: then it would be worth creating an interface above > GraphNode and implementing the interface instead... > + */ > + def this(node: Resource, graph: GraphNode ) =3D this(new > GraphNode(node,graph)) > /** > * Operator syntax shortcut to get all objects as > RichGraphNodes > */ > @@ -56,17 +64,14 @@ class RichGraphNode(node: GraphNode) ext > /** > * returns the lexical form of literals, the unicode-string for > UriRef for > * BNodes the value returned by toString > + * todo: not sure this is a good symbol as it is usually a binary > symbol, and so if it is found at the end of a line the > + * todo: the parsers expect the expression to go on the next line > */ > - def * =3D { > - val wrappedNode =3D node.getNode(); > - if (wrappedNode.isInstanceOf[Literal]) { > - wrappedNode.asInstanceOf[Literal].getLexicalForm > - } else { > - if (wrappedNode.isInstanceOf[UriRef]) { > - > wrappedNode.asInstanceOf[UriRef].getUnicodeString > - } else { > - wrappedNode.toString > - } > + def * : String =3D { > + node.getNode() match { > + case lit: Literal =3D> lit.getLexicalForm > + case uri: UriRef =3D> uri.getUnicodeString > + case wrappedNode =3D> wrappedNode.toString > } > } > > > > --bcaec5196ce531665f049e9f0f7d--