You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@clerezza.apache.org by re...@apache.org on 2011/07/12 01:34:28 UTC
svn commit: r1145398 - in /incubator/clerezza/trunk/parent:
platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/resources/OSGI-INF/
platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/pl...
Author: reto
Date: Mon Jul 11 23:34:27 2011
New Revision: 1145398
URL: http://svn.apache.org/viewvc?rev=1145398&view=rev
Log:
CLEREZZA-605: Added a simple implementations to add/remove contacts. The code from open issues, namely code committed for the unresolved CLEREZZA-473, CLEREZZA-509 and CLEREZZA-516 has been partially integrated and partially removed. The naked-resource template in platform.content is configured to also apply for *-naked mode, so that the uri of foaf:Knows target that are not known to be persons are displayed as well
Added:
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/html/ContactConfirmRenderlet.scala
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/html/PersonBox.scala
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/html/RenderingUtility.scala
Removed:
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/FoafBrowser.scala
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/html/PersonPanel.scala
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.ontologies/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/ontologies/pingback.n3
Modified:
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/resources/OSGI-INF/serviceComponents.xml
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/ProfilePanel.scala
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/html/ProfilePanel.scala
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.ontologies/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/ontologies/controlpanel.rdf
incubator/clerezza/trunk/parent/platform.content/src/main/java/org/apache/clerezza/platform/content/DiscobitTemplating.java
Modified: incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/resources/OSGI-INF/serviceComponents.xml
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/resources/OSGI-INF/serviceComponents.xml?rev=1145398&r1=1145397&r2=1145398&view=diff
==============================================================================
--- incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/resources/OSGI-INF/serviceComponents.xml (original)
+++ incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/resources/OSGI-INF/serviceComponents.xml Mon Jul 11 23:34:27 2011
@@ -45,6 +45,8 @@
<property name="service.pid" value="org.apache.clerezza.platform.accountcontrolpanel.ProfilePanel"/>
<reference name="userManager" interface="org.apache.clerezza.platform.usermanager.UserManager"
cardinality="1..1" policy="static" bind="bindUserManager" unbind="unbindUserManager"/>
+ <reference name="graphNodeProvider" interface="org.apache.clerezza.platform.graphnodeprovider.GraphNodeProvider"
+ cardinality="1..1" policy="static" bind="bindGraphNodeProvider" unbind="unbindGraphNodeProvider"/>
<reference name="keygenSrvc" interface="org.apache.clerezza.ssl.keygen.KeygenService"
cardinality="1..1" policy="static" bind="bindKeygenSrvc" unbind="unbindKeygenSrvc"/>
<reference name="webIdGraphsService" interface="org.apache.clerezza.platform.users.WebIdGraphsService"
@@ -72,12 +74,18 @@
<reference name="tcManager" interface="org.apache.clerezza.rdf.core.access.TcManager"
cardinality="1..1" policy="static" bind="bindTcManager" unbind="unbindTcManager"/>
</scr:component>
- <scr:component enabled="true" name="org.apache.clerezza.platform.accountcontrolpanel.html.PersonPanel">
- <implementation class="org.apache.clerezza.platform.accountcontrolpanel.html.PersonPanel"/>
+ <scr:component enabled="true" name="org.apache.clerezza.platform.accountcontrolpanel.html.ContactConfirmRenderlet">
+ <implementation class="org.apache.clerezza.platform.accountcontrolpanel.html.ContactConfirmRenderlet"/>
<service servicefactory="false">
<provide interface="org.apache.clerezza.platform.typerendering.TypeRenderlet"/>
</service>
- <property name="javax.ws.rs" type="Boolean" value="true"/>
- <property name="service.pid" value="org.apache.clerezza.platform.accountcontrolpanel.html.PersonPanel"/>
+ <property name="service.pid" value="org.apache.clerezza.platform.accountcontrolpanel.html.ContactConfirmRenderlet"/>
+ </scr:component>
+ <scr:component enabled="true" name="org.apache.clerezza.platform.accountcontrolpanel.html.PersonBox">
+ <implementation class="org.apache.clerezza.platform.accountcontrolpanel.html.PersonBox"/>
+ <service servicefactory="false">
+ <provide interface="org.apache.clerezza.platform.typerendering.TypeRenderlet"/>
+ </service>
+ <property name="service.pid" value="org.apache.clerezza.platform.accountcontrolpanel.html.PersonBox"/>
</scr:component>
</components>
Modified: incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/ProfilePanel.scala
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/ProfilePanel.scala?rev=1145398&r1=1145397&r2=1145398&view=diff
==============================================================================
--- incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/ProfilePanel.scala (original)
+++ incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/ProfilePanel.scala Mon Jul 11 23:34:27 2011
@@ -22,8 +22,8 @@ import java.util.List
import java.util.Arrays
import java.util.Collections
import java.util.Iterator
-import ontologies.{PINGBACK, CONTROLPANEL}
-import org.apache.clerezza.platform.security.UserUtil
+import ontologies.CONTROLPANEL
+import org.apache.clerezza.platform.graphnodeprovider.GraphNodeProvider
import org.apache.clerezza.ssl.keygen.CertSerialisation
import org.apache.clerezza.ssl.keygen.Certificate
import org.apache.clerezza.foafssl.ontologies.CERT
@@ -53,25 +53,9 @@ import java.net.URI
import org.apache.clerezza.rdf.core.access.security.TcPermission
import org.apache.clerezza.rdf.ontologies._
import org.slf4j.scala.Logging
-import javax.security.auth.Subject
import org.apache.clerezza.platform.users.{WebIdInfo, WebIdGraphsService}
import org.apache.clerezza.rdf.scala.utils._
-object ProfilePanel {
- //val webIdTemplate = classOf[ProfilePanel].getAnnotation(classOf[Path]).value+"#me"
-
-
- /*
- * return the WebID for the given user name given the UriInfo (which contains information for
- * server default name)
- **/
- /*def webID(uname: String, uriInfo: UriInfo): UriRef = {
- val path = PingBack.interpolate(webIdTemplate, uname)
- val uriStr = uriInfo.getBaseUri.resolve(path); //a bit expensive for something so simple
- new UriRef(uriStr.toString)
- }*/
-}
-
/**
* Presents a panel where the user can create a webid and edit her profile.
*
@@ -84,47 +68,53 @@ class ProfilePanel extends Logging {
import collection.JavaConversions._
import Preamble._
-
+ /**
+ * Returns a GraphNode describing a ProfilePage for the user identified by
+ * the specified UserName. A ProfilePage resourcve is retuned for any user
+ * disregarding if they have a WebId and if this is local. The renderlet
+ * may provide instrcutions on how a WebId is created for users that do
+ * not have a WebId and redirect them to their WebId provider if they have
+ * a remote WebId.
+ */
@GET
def getPersonalProfilePage(@Context uriInfo: UriInfo,
@PathParam(value = "id") userName: String): GraphNode = {
TrailingSlash.enforceNotPresent(uriInfo)
+ AccessController.checkPermission(new AccountControlPanelAppPermission(userName, ""))
val resultNode= getPersonalProfile(userName, uriInfo)
-
return resultNode
}
- //todo: there is a bit of repetition in the graphs, and it is not clear why these relations should not go straight into the DB. What should, what should not?
private def getPersonalProfile(userName: String, info: UriInfo): GraphNode = {
- val profileDocUri = getSuggestedPPDUri(userName)
+ lazy val suggestedPPDUri = getSuggestedPPDUri(userName)
val profile = AccessController.doPrivileged(new PrivilegedAction[GraphNode] {
def run: GraphNode = {
val userInSysGraph = userManager.getUserInSystemGraph(userName)
- val user = userInSysGraph.getNode
- val profile: GraphNode = userInSysGraph.getNode match {
+ val userResource = userInSysGraph.getNode
+ val profile: GraphNode = userResource match {
case blank: BNode => {
//user does not have a webId yet
val g = new EzMGraph()
import g._
val profile = bnode
(profile -- CONTROLPANEL.isLocalProfile --> bool2lit(true)
- -- CONTROLPANEL.suggestedPPDUri --> profileDocUri
- -- FOAF.primaryTopic --> (bnode -- PLATFORM.userName --> userName))
+ -- CONTROLPANEL.suggestedPPDUri --> suggestedPPDUri
+ -- FOAF.primaryTopic --> (bnode -- PLATFORM.userName --> userName))
profile
}
case webid: UriRef => {
var webIDInfo = webIdGraphsService.getWebIdInfo(webid)
- var res = new GraphNode(profileDocUri, new UnionMGraph(new SimpleMGraph, webIDInfo.localPublicUserData))
+ var res = new GraphNode(suggestedPPDUri, new UnionMGraph(new SimpleMGraph, webIDInfo.localPublicUserData))
(res -- CONTROLPANEL.isLocalProfile --> bool2lit(webIDInfo.isLocal)
-- FOAF.primaryTopic --> webid)
res
}
}
- val friendInfo:Iterator[TripleCollection] = for (kn: Triple <- profile.getGraph.filter(user.asInstanceOf[NonLiteral], FOAF.knows, null)
+ /*val friendInfo:Iterator[TripleCollection] = for (kn: Triple <- profile.getGraph.filter(userResource.asInstanceOf[NonLiteral], FOAF.knows, null)
if kn.getObject.isInstanceOf[UriRef];
friend = kn.getObject.asInstanceOf[UriRef]
- if (friend != profileDocUri)
+ if (friend != suggestedPPDUri)
) yield {
try {
val friendGraph = tcManager.getGraph(FoafBrowser.removeHash(friend))
@@ -139,7 +129,7 @@ class ProfilePanel extends Logging {
}
}
//vera bad: mixing data from different sources
- for (g <- friendInfo) profile.getGraph.addAll(g)
+ for (g <- friendInfo) profile.getGraph.addAll(g) */
profile
}
})
@@ -162,6 +152,7 @@ class ProfilePanel extends Logging {
def setExistingWebId(@Context uriInfo: UriInfo,
@FormParam("webid") webId: UriRef,
@PathParam(value = "id") userName: String): Response = {
+ AccessController.checkPermission(new AccountControlPanelAppPermission(userName, ""))
return AccessController.doPrivileged(new PrivilegedAction[Response] {
def run: Response = {
var userInSystemGraph: GraphNode = userManager.getUserInSystemGraph(userName)
@@ -177,6 +168,7 @@ class ProfilePanel extends Logging {
@PathParam(value = "id") userName: String): Response = {
val ppd: UriRef = getSuggestedPPDUri(userName)
val webId: UriRef = new UriRef(ppd.getUnicodeString + "#me")
+ AccessController.checkPermission(new AccountControlPanelAppPermission(userName, ""))
return AccessController.doPrivileged(new PrivilegedAction[Response] {
def run: Response = {
userManager.assignPermissionsToUser(userName, java.util.Collections.singletonList(new TcPermission(
@@ -198,16 +190,35 @@ class ProfilePanel extends Logging {
})
}
+ /**
+ * Presents a confirmation form for adding a contact
+ */
+ @GET
+ @Path("addContact")
+ def addContactConfirm(@PathParam(value = "id") userName: String,
+ @QueryParam("contactWebId") contactWebId: UriRef): GraphNode = {
+ AccessController.checkPermission(new AccountControlPanelAppPermission(userName, ""))
+ val contactNode = AccessController.doPrivileged(new PrivilegedAction[GraphNode] {
+ def run = {
+ graphNodeProvider.get(contactWebId);
+ }
+ })
+ val resultGraph = new EzMGraph(new UnionMGraph(new SimpleMGraph, contactNode.getGraph))
+ import resultGraph._
+ val result: GraphNode = bnode
+ result a CONTROLPANEL.ContactConfirmPage
+ result -- FOAF.primaryTopic --> contactNode
+ }
+
@POST
@Path("addContact")
- def addContact(@Context uriInfo: UriInfo,
+ def addContact(@PathParam(value = "id") userName: String, @Context uriInfo: UriInfo,
@FormParam("webId") newContacts: java.util.List[UriRef]): Response = {
import collection.JavaConversions._
if (newContacts.size > 0) {
- val subject = UserUtil.getCurrentUserName
var me: GraphNode = AccessController.doPrivileged(new PrivilegedAction[GraphNode] {
def run: GraphNode = {
- return userManager.getUserGraphNode(subject)
+ return userManager.getUserGraphNode(userName)
}
})
for (contactWebID <- newContacts) {
@@ -220,6 +231,25 @@ class ProfilePanel extends Logging {
}
/**
+ * Removes a contact
+ */
+ @POST
+ @Path("deleteContact")
+ def deleteContact(@PathParam(value = "id") userName: String, @Context uriInfo: UriInfo,
+ @FormParam("contactWebId") contactWebId: UriRef): Response = {
+ import collection.JavaConversions._
+ var me: GraphNode = AccessController.doPrivileged(new PrivilegedAction[GraphNode] {
+ def run: GraphNode = {
+ return userManager.getUserGraphNode(userName)
+ }
+ })
+ val webIdGraphs = webIdGraphsService.getWebIdInfo(me.getNode.asInstanceOf[UriRef])
+ var meGrph: GraphNode = new GraphNode(me.getNode, webIdGraphs.localPublicUserData)
+ meGrph.deleteProperty(FOAF.knows, contactWebId)
+ return RedirectUtil.createSeeOtherResponse("../profile", uriInfo)
+ }
+
+ /**
* @parm webId: A list of WebIDs to be added as Subject Alternative Names
* @param cn Common Name, the name that usually appears in the certificate selection box
* @param spkac key request in format generated by Netscape, Safari, Opera
@@ -368,6 +398,14 @@ class ProfilePanel extends Logging {
}
}
+ protected def bindGraphNodeProvider(graphNodeProvider: GraphNodeProvider): Unit = {
+ this.graphNodeProvider = graphNodeProvider
+ }
+
+ protected def unbindGraphNodeProvider(graphNodeProvider: GraphNodeProvider): Unit = {
+ this.graphNodeProvider = null
+ }
+
protected def bindKeygenSrvc(keygenservice: KeygenService): Unit = {
keygenSrvc = keygenservice
}
@@ -412,6 +450,8 @@ class ProfilePanel extends Logging {
private var userManager: UserManager = null
+ private var graphNodeProvider: GraphNodeProvider = null
+
private var webIdGraphsService: WebIdGraphsService = null
private var keygenSrvc: KeygenService = null
Added: incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/html/ContactConfirmRenderlet.scala
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/html/ContactConfirmRenderlet.scala?rev=1145398&view=auto
==============================================================================
--- incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/html/ContactConfirmRenderlet.scala (added)
+++ incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/html/ContactConfirmRenderlet.scala Mon Jul 11 23:34:27 2011
@@ -0,0 +1,109 @@
+package org.apache.clerezza.platform.accountcontrolpanel.html
+
+/*
+ * 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.
+ */
+import org.apache.clerezza.platform.accountcontrolpanel.ontologies.CONTROLPANEL
+import org.apache.clerezza.rdf.core._
+import org.apache.clerezza.rdf.scala.utils._
+import org.apache.clerezza.rdf.ontologies.FOAF
+import org.apache.clerezza.rdf.ontologies.RDF
+import org.apache.clerezza.rdf.scala.utils.Preamble._
+import org.apache.clerezza.platform.typerendering.scala._
+
+
+
+/**
+ * Metadata class for the person panel
+ */
+class ContactConfirmRenderlet extends SRenderlet {
+ def getRdfType() = CONTROLPANEL.ContactConfirmPage
+
+
+ override def renderedPage(arguments: XmlResult.Arguments) = new XmlPerson(arguments)
+
+ /**
+ * Content class for the Person Panel
+ */
+ class XmlPerson(args: XmlResult.Arguments) extends XmlResult(args) {
+
+ import RenderingUtility._
+
+ //
+ // the content itself.
+ // This is the piece that is closest to a pure ssp, though there is still too much code in it
+ //
+
+ override def content = {
+ val primarySubject = res/FOAF.primaryTopic
+ <div id="tx-content">
+ {
+ if (primarySubject.hasProperty(RDF.`type`, FOAF.Person)) {
+ <form action="addContact" method="post">
+ {render(primarySubject, "box-naked")}
+ <input type="hidden" name="webId" value={primarySubject*} />
+ <input type="submit" value="Add this contact" />
+ </form>
+ } else {
+ <div>
+ <span>The resource {primarySubject!} of type {primarySubject/RDF.`type`} is not known to be a Person</span>
+ {
+ import collection.JavaConversions._
+ val otherPersons = (for (t <- primarySubject.getNodeContext.filter(null, RDF.`type`, FOAF.Person))
+ yield t.getSubject).toList
+ val personsWithUri: List[UriRef] = for (otherPerson <- otherPersons;
+ if otherPerson.isInstanceOf[UriRef]) yield otherPerson.asInstanceOf[UriRef]
+ if (personsWithUri.isEmpty) {
+ <span>No person could be found</span>
+ } else {
+ <div>
+ Maybe you want to add {
+ if (personsWithUri.size > 1) {
+ "one of the following "+personsWithUri.size+" persons:"
+ } else {
+ "the person"
+ }
+ }
+ {
+ for (otherPerson <- personsWithUri) yield {
+ <form action="addContact" method="post">
+ <span>{otherPerson}</span>
+ {render(otherPerson, "box-naked")}
+ <input type="hidden" name="webId" value={otherPerson.getUnicodeString} />
+ <input type="submit" value="Add this contact" />
+ </form>
+ }
+ }
+ </div>
+ }
+ }
+ {
+ <form action="addContact" method="post">
+ You can add {primarySubject} as contact even though it does not seem to be a person.
+ <input type="hidden" name="webId" value={primarySubject*} />
+ <input type="submit" value="Add anyway" />
+ </form>
+ } </div>
+ }
+ }
+ <a href="../profile" onclick="history.go(-1)">Cancel</a>
+ </div>
+ }
+
+ }
+}
Added: incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/html/PersonBox.scala
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/html/PersonBox.scala?rev=1145398&view=auto
==============================================================================
--- incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/html/PersonBox.scala (added)
+++ incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/html/PersonBox.scala Mon Jul 11 23:34:27 2011
@@ -0,0 +1,63 @@
+package org.apache.clerezza.platform.accountcontrolpanel.html
+
+/*
+ * 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.
+ */
+import org.apache.clerezza.platform.accountcontrolpanel.ontologies.CONTROLPANEL
+import org.apache.clerezza.rdf.core._
+import org.apache.clerezza.rdf.scala.utils._
+import org.apache.clerezza.rdf.ontologies.FOAF
+import org.apache.clerezza.rdf.scala.utils.Preamble._
+import org.apache.clerezza.platform.typerendering.scala._
+import scala.xml.Text
+
+
+
+/**
+ * Metadata class for the person panel
+ */
+class PersonBox extends SRenderlet {
+ def getRdfType() = FOAF.Person
+
+ override def getModePattern = "box-naked"
+
+ override def renderedPage(arguments: XmlResult.Arguments) = new XmlPerson(arguments)
+
+ /**
+ * Content class for the Person Panel
+ */
+ class XmlPerson(args: XmlResult.Arguments) extends XmlResult(args) {
+
+ import RenderingUtility._
+
+ //
+ // the content itself.
+ // This is the piece that is closest to a pure ssp, though there is still too much code in it
+ //
+
+ override def content = {
+ val pixml= getAgentPix(res)
+ <div class="personInABox">
+ <table><tr><td>{pixml}</td></tr>
+ <tr><td>{new Text(getName(res))}</td></tr>
+ </table>
+ </div>
+ }
+
+ }
+}
Modified: incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/html/ProfilePanel.scala
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/html/ProfilePanel.scala?rev=1145398&r1=1145397&r2=1145398&view=diff
==============================================================================
--- incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/html/ProfilePanel.scala (original)
+++ incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/html/ProfilePanel.scala Mon Jul 11 23:34:27 2011
@@ -148,15 +148,29 @@ class ProfilePanel extends SRenderlet {
</form>
<h3>Contacts</h3>
- <form id="addContact" method="get" action="/browse/person">
+
<table>{ var i =0
val friends = for (friend <- agent/FOAF.knows) yield {
- import PersonPanel._
- <td class="personInABox">{personInABox(friend)}</td>
+ <td><form method="post" action="profile/deleteContact">
+ {
+ friend! match {
+ case webId: UriRef => render(webId, "box-naked")
+ case _ => render(friend, "box-naked")
+ }
+ }
+ <br/>
+ <input type="hidden" name="contactWebId" value={friend*}/>
+ <input type="submit" value="remove contact" />
+ </form></td>
+ /*render(friend!.asInstanceOf[UriRef])
+ import PersonPanel._
+ <td class="personInABox">{personInABox(friend)}</td>*/
}
for (row <- friends.grouped(5)) yield <tr>{row}</tr>
}</table>
- <input type="text" name="uri" size="80"/><input type="submit" value="add contact" />
+ <form id="addContact" method="get" action="profile/addContact">
+ <label for="contactWebId">Add contact bei WebId:<br/></label>
+ <input type="text" name="contactWebId" size="80"/><input type="submit" value="add contact" />
</form>
<h3>Key and Certificate Creation</h3>
Added: incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/html/RenderingUtility.scala
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/html/RenderingUtility.scala?rev=1145398&view=auto
==============================================================================
--- incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/html/RenderingUtility.scala (added)
+++ incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/html/RenderingUtility.scala Mon Jul 11 23:34:27 2011
@@ -0,0 +1,94 @@
+/*
+ * 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.html
+
+
+import scala.xml.Node
+import scala.xml.NodeSeq
+import scala.xml.Text
+import java.net.URLEncoder
+import org.apache.clerezza._
+import org.apache.clerezza.rdf.core.UriRef
+import org.apache.clerezza.rdf.ontologies.FOAF
+import org.apache.clerezza.rdf.ontologies.RDFS
+import rdf.scala.utils.CollectedIter
+import rdf.scala.utils.RichGraphNode
+import rdf.scala.utils.Preamble._
+/**
+ * Some utility methods for the renderlets
+ */
+object RenderingUtility {
+ val emptyText = new Text("")
+
+ def ifE[T](arg:T)(template: T=>Node ):NodeSeq = {
+ def isEmpty(arg: Any): Boolean = {
+ arg match {
+ case prod: Product => prod.productIterator.forall(isEmpty(_))
+ case str: String => (str.size == 0)
+ case it: CollectedIter[RichGraphNode] => (it.size == 0)
+ case node: RichGraphNode => (null == node)
+ case other: AnyRef => (null == other)
+ case _ => false //literals can't be empty
+ }
+ }
+ if (isEmpty(arg)) return emptyText else template(arg)
+ }
+
+ def firstOf(node: RichGraphNode, uris: UriRef*):CollectedIter[RichGraphNode] = {
+ for (uri <- uris) {
+ val res : CollectedIter[RichGraphNode] = node/uri
+ 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 getAgentPix(p: RichGraphNode) = {
+ val pix = firstOf(p, FOAF.depiction, FOAF.logo, FOAF.img).getNode match {
+ case uri: UriRef => uri.getUnicodeString
+ case _ => "http://upload.wikimedia.org/wikipedia/commons/0/0a/Gnome-stock_person.svg"
+ }
+ <a href={"/browse/person?uri="+encode(p*)}><img class="mugshot" src={pix}/></a>
+ }
+
+ private def encode(url: String): String = URLEncoder.encode(url,"UTF8")
+
+ /**
+ * get a usable name from the properties available including nick
+ */
+ def getName(p: RichGraphNode): String = {
+ val name = p/FOAF.name*;
+ if ("" != name ) { return name }
+ val firstNm: String = p/FOAF.firstName*;
+ val fmlyNm :String = firstOf(p, FOAF.family_name,FOAF.familyName)*;
+ if ("" != firstNm || "" != fmlyNm) { return firstNm+" "+fmlyNm }
+ return p*
+
+ }
+
+}
+
Modified: incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.ontologies/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/ontologies/controlpanel.rdf
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.ontologies/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/ontologies/controlpanel.rdf?rev=1145398&r1=1145397&r2=1145398&view=diff
==============================================================================
--- incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.ontologies/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/ontologies/controlpanel.rdf (original)
+++ incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.ontologies/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/ontologies/controlpanel.rdf Mon Jul 11 23:34:27 2011
@@ -35,11 +35,10 @@
<rdfs:isDefinedBy rdf:resource="http://clerezza.org/2009/03/controlpanel#" />
</rdfs:Class>
-<rdfs:Class rdf:about="#ProfileViewerPage">
+<rdfs:Class rdf:about="#ContactConfirmPage">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
- <rdfs:label xml:lang="en">profile viewer page</rdfs:label>
- <skos:definition xml:lang="en">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 contacts
+ <rdfs:label xml:lang="en">ContactConfirmPage</rdfs:label>
+ <skos:definition xml:lang="en">page for confiming a new contact
</skos:definition>
<rdfs:isDefinedBy rdf:resource="http://clerezza.org/2009/03/controlpanel#" />
</rdfs:Class>
Modified: incubator/clerezza/trunk/parent/platform.content/src/main/java/org/apache/clerezza/platform/content/DiscobitTemplating.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.content/src/main/java/org/apache/clerezza/platform/content/DiscobitTemplating.java?rev=1145398&r1=1145397&r2=1145398&view=diff
==============================================================================
--- incubator/clerezza/trunk/parent/platform.content/src/main/java/org/apache/clerezza/platform/content/DiscobitTemplating.java (original)
+++ incubator/clerezza/trunk/parent/platform.content/src/main/java/org/apache/clerezza/platform/content/DiscobitTemplating.java Mon Jul 11 23:34:27 2011
@@ -51,7 +51,7 @@ public class DiscobitTemplating {
renderletManager.registerRenderlet(SeedsnipeRenderlet.class.getName(),
new UriRef(getClass().getResource("Resource_naked.xhtml").toString()),
- RDFS.Resource, "naked", MediaType.APPLICATION_XHTML_XML_TYPE, true);
+ RDFS.Resource, "(naked|.*-naked)", MediaType.APPLICATION_XHTML_XML_TYPE, true);
renderletManager.registerRenderlet(SeedsnipeRenderlet.class.getName(),
new UriRef(getClass().getResource("XHTML_InfoDiscoBit_naked.xhtml").toString()),