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 2013/12/04 16:21:24 UTC

[7/9] CLEREZZA-435: repaced tabs with spaces in scala files

http://git-wip-us.apache.org/repos/asf/clerezza/blob/35448624/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/AcpPermissionDescriptionsProvider.scala
----------------------------------------------------------------------
diff --git a/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/AcpPermissionDescriptionsProvider.scala b/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/AcpPermissionDescriptionsProvider.scala
index a357de8..5d41410 100644
--- a/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/AcpPermissionDescriptionsProvider.scala
+++ b/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/AcpPermissionDescriptionsProvider.scala
@@ -30,46 +30,46 @@ import org.apache.felix.scr.annotations.Service
  * <code>PermissionDescripton</code>s of Account Control Panel permissions.
  * The following permissions are described:
  * <ul>
- * 	<li>org.apache.clerezza.platform.accountcontrolpanel.AccountControlPanelAppPermission</li>
- * 	<li>org.apache.clerezza.platform.accountcontrolpanel.ChangePasswordPermission</li>
- * 	<li>org.apache.clerezza.platform.accountcontrolpanel.UserBundlePermission</li>
+ *   <li>org.apache.clerezza.platform.accountcontrolpanel.AccountControlPanelAppPermission</li>
+ *   <li>org.apache.clerezza.platform.accountcontrolpanel.ChangePasswordPermission</li>
+ *   <li>org.apache.clerezza.platform.accountcontrolpanel.UserBundlePermission</li>
  * </ul>
  *
  * @author mir
  */
 object AcpPermissionDescriptionsProvider {
-	private  val ACP_PERMISSION_DESCRIPTIONS: Set[PermissionDescripton] = new HashSet[PermissionDescripton]
-	ACP_PERMISSION_DESCRIPTIONS.add(
-		new PermissionDescripton("Change Own Password Permission",
-			"Grants permission to the user to change its own password",
-			null, classOf[ChangePasswordPermission],
-			"(org.apache.clerezza.platform.accountcontrolpanel.ChangePasswordPermission \"{username}\" \"\")"
-		)
-	)
+  private  val ACP_PERMISSION_DESCRIPTIONS: Set[PermissionDescripton] = new HashSet[PermissionDescripton]
+  ACP_PERMISSION_DESCRIPTIONS.add(
+    new PermissionDescripton("Change Own Password Permission",
+      "Grants permission to the user to change its own password",
+      null, classOf[ChangePasswordPermission],
+      "(org.apache.clerezza.platform.accountcontrolpanel.ChangePasswordPermission \"{username}\" \"\")"
+    )
+  )
 
-	ACP_PERMISSION_DESCRIPTIONS.add(
-		new PermissionDescripton("Access Own Account Control Panel Permission",
-			"Grants permission to the user to access its own Account Control Panel",
-			null, classOf[AccountControlPanelAppPermission],
-			"(org.apache.clerezza.platform.accountcontrolpanel.AccountControlPanelAppPermission \"{username}\" \"\")"
-		)
-	)
+  ACP_PERMISSION_DESCRIPTIONS.add(
+    new PermissionDescripton("Access Own Account Control Panel Permission",
+      "Grants permission to the user to access its own Account Control Panel",
+      null, classOf[AccountControlPanelAppPermission],
+      "(org.apache.clerezza.platform.accountcontrolpanel.AccountControlPanelAppPermission \"{username}\" \"\")"
+    )
+  )
 
-	ACP_PERMISSION_DESCRIPTIONS.add(
-		new PermissionDescripton("Bundle Upload Permission",
-			"Grants permission to the user to upload a bundle",
-			null, classOf[AccountControlPanelAppPermission],
-			"(org.apache.clerezza.platform.accountcontrolpanel.UserBundlePermission \"{username}\" \"\")"
-		)
-	)
+  ACP_PERMISSION_DESCRIPTIONS.add(
+    new PermissionDescripton("Bundle Upload Permission",
+      "Grants permission to the user to upload a bundle",
+      null, classOf[AccountControlPanelAppPermission],
+      "(org.apache.clerezza.platform.accountcontrolpanel.UserBundlePermission \"{username}\" \"\")"
+    )
+  )
 
 }
 
 class AcpPermissionDescriptionsProvider extends PermissionDescriptionsProvider {
 
-	import AcpPermissionDescriptionsProvider._
+  import AcpPermissionDescriptionsProvider._
 
-	def getPermissionDescriptors: Set[PermissionDescripton] = {
-		return ACP_PERMISSION_DESCRIPTIONS
-	}
+  def getPermissionDescriptors: Set[PermissionDescripton] = {
+    return ACP_PERMISSION_DESCRIPTIONS
+  }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/clerezza/blob/35448624/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/MenuItemProvider.scala
----------------------------------------------------------------------
diff --git a/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/MenuItemProvider.scala b/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/MenuItemProvider.scala
index 3d9e3c1..7ab15dd 100644
--- a/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/MenuItemProvider.scala
+++ b/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/MenuItemProvider.scala
@@ -44,28 +44,28 @@ import org.apache.stanbol.commons.security.UserUtil
  * @author reto
  */
 class MenuItemProvider extends GlobalMenuItemsProvider {
-	def getMenuItems: Set[GlobalMenuItem] = {
-		var items: Set[GlobalMenuItem] = new HashSet[GlobalMenuItem]
-		var userName: String = UserUtil.getCurrentUserName
-		if (userName != null) {
-			try {
-				AccessController.checkPermission(new AccountControlPanelAppPermission(userName, ""))
-			}
-			catch {
-				case e: AccessControlException => {
-					return items
-				}
-			}
-			try {
-				var path: String = "/user/" + URLEncoder.encode(userName, "utf-8") + "/control-panel"
-				items.add(new GlobalMenuItem(path, "ACP", "Account Control Panel", 5, "Administration"))
-			}
-			catch {
-				case e: UnsupportedEncodingException => {
-					throw new RuntimeException(e)
-				}
-			}
-		}
-		return items
-	}
+  def getMenuItems: Set[GlobalMenuItem] = {
+    var items: Set[GlobalMenuItem] = new HashSet[GlobalMenuItem]
+    var userName: String = UserUtil.getCurrentUserName
+    if (userName != null) {
+      try {
+        AccessController.checkPermission(new AccountControlPanelAppPermission(userName, ""))
+      }
+      catch {
+        case e: AccessControlException => {
+          return items
+        }
+      }
+      try {
+        var path: String = "/user/" + URLEncoder.encode(userName, "utf-8") + "/control-panel"
+        items.add(new GlobalMenuItem(path, "ACP", "Account Control Panel", 5, "Administration"))
+      }
+      catch {
+        case e: UnsupportedEncodingException => {
+          throw new RuntimeException(e)
+        }
+      }
+    }
+    return items
+  }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/clerezza/blob/35448624/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/ProfilePanel.scala
----------------------------------------------------------------------
diff --git a/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/ProfilePanel.scala b/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/ProfilePanel.scala
index 5a4ef94..0104077 100644
--- a/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/ProfilePanel.scala
+++ b/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/ProfilePanel.scala
@@ -65,402 +65,402 @@ import org.apache.clerezza.rdf.scala.utils._
 @Path("/user/{id}/profile")
 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)
-		//not checking as public profile must be public, more selective access control TBD
-		//AccessController.checkPermission(new AccountControlPanelAppPermission(userName, ""))
-		val resultNode= getPersonalProfile(userName, uriInfo)
-		return resultNode
-	}
-
-	private def getPersonalProfile(userName: String, info: UriInfo): GraphNode = {
-		lazy val suggestedPPDUri = getSuggestedPPDUri(userName)
-
-		val profile = AccessController.doPrivileged(new PrivilegedAction[GraphNode] {
-			def run: GraphNode = {
-				val userInSysGraph = userManager.getUserInSystemGraph(userName)
-				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 --> suggestedPPDUri
-						-- FOAF.primaryTopic --> (bnode -- PLATFORM.userName --> userName))
-						profile
-					}
-					case webid: UriRef => {
-						var webIDInfo = webIdGraphsService.getWebIdInfo(webid)
-						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(userResource.asInstanceOf[NonLiteral], FOAF.knows, null)
-				                      if kn.getObject.isInstanceOf[UriRef];
-				                      friend = kn.getObject.asInstanceOf[UriRef]
-				                      if (friend != suggestedPPDUri)
-				) yield {
-					try {
-						val friendGraph = tcManager.getGraph(FoafBrowser.removeHash(friend))
-						new RichGraphNode(friend, friendGraph).getNodeContext
-					} catch {
-						case e => {
-							logger.warn("cought exception trying to fetch graph - these graphs should already be in store " + friend, e)
-							new EzMGraph() {
-								friend -- SKOS.note --> ("problem with fetching this node: " + e)
-							}
-						}
-					}
-				}
-				//vera bad: mixing data from different sources
-				for (g <- friendInfo) profile.getGraph.addAll(g) */
-				profile
-			}
-		})
-
-
-		(profile a   PLATFORM.HeadedPage
-		         a  CONTROLPANEL.ProfilePage)
-	}
-
-	/**
-	 * @param userName
-	 * @return the suggested Personal Profile Document URI
-	 */
-	def getSuggestedPPDUri(userName: String): UriRef = {
-		return new UriRef(platformConfig.getDefaultBaseUri.getUnicodeString + "user/" + userName + "/profile")
-	}
-
-	@POST
-	@Path("set-existing-webid")
-	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)
-				userInSystemGraph.replaceWith(webId)
-				return RedirectUtil.createSeeOtherResponse("../profile", uriInfo)
-			}
-		})
-	}
-
-	@POST
-	@Path("create-new-web-id")
-	def createNewWebId(@Context uriInfo: UriInfo,
-	                   @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(
-						webId.getUnicodeString, TcPermission.READWRITE).toString))
-				tcManager.getTcAccessController.setRequiredReadPermissionStrings(
-					ppd, Collections.singleton(new TcPermission(
-							Constants.CONTENT_GRAPH_URI_STRING, TcPermission.READ).toString))
-				tcManager.createMGraph(ppd)
-				val webIDInfo = webIdGraphsService.getWebIdInfo(webId)
-				webIDInfo.localPublicUserData.addAll(
-					Arrays.asList(
-						new TripleImpl(ppd, RDF.`type`, FOAF.PersonalProfileDocument),
-						new TripleImpl(ppd, FOAF.primaryTopic, webId))
-				)
-				var userInSystemGraph: GraphNode = userManager.getUserInSystemGraph(userName)
-				userInSystemGraph.replaceWith(webId)
-				return RedirectUtil.createSeeOtherResponse("../profile", uriInfo)
-			}
-		})
-	}
-
-	/**
-	 * 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(@PathParam(value = "id") userName: String, @Context uriInfo: UriInfo,
-	               @FormParam("webId") newContacts: java.util.List[UriRef]): Response = {
-		import collection.JavaConversions._
-		if (newContacts.size > 0) {
-			var me: GraphNode = AccessController.doPrivileged(new PrivilegedAction[GraphNode] {
-				def run: GraphNode = {
-					return userManager.getUserGraphNode(userName)
-				}
-			})
-			for (contactWebID <- newContacts) {
-				val webIdGraphs = webIdGraphsService.getWebIdInfo(me.getNode.asInstanceOf[UriRef])
-				var meGrph: GraphNode = new GraphNode(me.getNode, webIdGraphs.localPublicUserData)
-				meGrph.addProperty(FOAF.knows, contactWebID)
-			} //todo: one should catch errors here (bad uris sent for ex
-		}
-		return RedirectUtil.createSeeOtherResponse("../profile", uriInfo)
-	}
-
-	/**
-	 * 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
-	 * @param crmf hey request in format generated by M$ Explorer
-	 * @param csr key request as generated by Javascript of Netscape
-	 * @param hours the certificate should last  (hours and days add up)
-	 * @param days the certificate should last
-	 * @param comment a comment to be attached to the public key in the database
-	 */
-	@POST
-	@Path("keygen")
-	def createCert(@FormParam("webId") webIds: java.util.List[URI],
-	               @FormParam("cn") commonName: String,
-	               @FormParam("spkac") spkac: String,
-	               @FormParam("crmf") crmf: String,
-	               @FormParam("csr") csr: String,
-	               @FormParam("hours") hours: String,
-	               @FormParam("days") days: String,
-	               @FormParam("comment") comment: String): Response = {
-		import scala.collection.JavaConversions._
-		var cert: Certificate = null
-		if (spkac != null && spkac.length > 0) {
-			cert = keygenSrvc.createFromSpkac(spkac)
-			if (cert == null) {
-				logger.warn("unable to create certificate from spkac request")
-			}
-		}
-		if (cert == null && crmf != null && crmf.length > 0) {
-			cert = keygenSrvc.createFromCRMF(crmf)
-			if (cert == null) {
-				logger.warn("unable to create certificate from crmf requrest :" + crmf)
-			}
-		}
-		if (cert == null && csr != null && csr.length > 0) {
-			cert = keygenSrvc.createFromPEM(csr)
-			if (cert == null) {
-				logger.warn("unable to create certificate from csr request :" + csr)
-			}
-		}
-		if (cert == null) {
-			throw new RuntimeException("The server was unable to create a certificate")
-		}
-		cert.setSubjectCommonName(commonName)
-		cert.addDurationInHours(hours)
-		cert.addDurationInDays(days)
-		cert.startEarlier("2")
-		for(san: URI<-webIds) {
-		  cert.addSubjectAlternativeName(san.toString)
-		}
-		var ser: CertSerialisation = null
-		try {
-			ser = cert.getSerialisation
-		}
-		catch {
-			case ex: Exception => {
-				throw new RuntimeException(ex)
-			}
-		}
-		var pubKey: RSAPublicKey = cert.getSubjectPublicKey.getPublicKey.asInstanceOf[RSAPublicKey]
-		var publicExponent: BigInteger = pubKey.getPublicExponent
-		var modulus: BigInteger = pubKey.getModulus
-
-		for (webid: URI<-webIds
-		     if (webid.getScheme=="https"||webid.getScheme=="http");
-	  		  val webidRef = new UriRef(webid.toString);
-		     val webIdInfo = webIdGraphsService.getWebIdInfo(webidRef);
-		     if (webIdInfo.isLocal)
-		) {
-			val certGraph = new EzMGraph(webIdInfo.localPublicUserData)
-			import certGraph._
-			val certNode = certGraph.bnode
-			( (certNode a  RSA.RSAPublicKey)
-			   -- CERT.identity -->  webidRef
-			   -- RSA.modulus -->  modulus
-			   -- RSA.public_exponent -->  publicExponent
-			   -- DC.date -->  cert.getStartDate )
-			if (comment != null && comment.length > 0) {
-				certNode --  RDFS.comment -->  comment
-			}
-		}
-		var resBuild: Response.ResponseBuilder = Response.ok(ser.getContent, MediaType.valueOf(ser.getMimeType))
-		return resBuild.build
-	}
-
-	@POST
-	@Path("deletekey")
-	def deleteKey(@Context uriInfo: UriInfo,
-	              @FormParam("webId") webId: UriRef,
-	              @FormParam("keyhash") keys: List[String]): Response = {
-		val webIDInfo = webIdGraphsService.getWebIdInfo(webId)
-		val agent: GraphNode = new GraphNode(webId, webIDInfo.localPublicUserData)
-		var subjects: Iterator[GraphNode] = agent.getSubjectNodes(CERT.identity)
-		import scala.util.control.Breaks._
-		breakable {
-			import scala.collection.JavaConversions._
-			//to for loop through iterators
-			for (nl <- subjects) {
-				var modulusIt: Iterator[Resource] = nl.getObjects(RSA.modulus)
-				if (!modulusIt.hasNext) break
-				var modLit: Resource = modulusIt.next
-				if (modulusIt.hasNext) logger.warn("data error, a modulus too many in cert for " + webId)
-				if (!(modLit.isInstanceOf[TypedLiteral])) {
-					logger.warn("a public key has a modulus that is not a literal for " + webId)
-					break
-				}
-				var modulus: BigInteger = LiteralFactory.getInstance.createObject(classOf[BigInteger], modLit.asInstanceOf[TypedLiteral])
-				for (key <- keys) {
-					if (modulus.hashCode == Integer.decode(key)) {
-						nl.deleteNodeContext
-						break
-					}
-				}
-			}
-		}
-		return RedirectUtil.createSeeOtherResponse("../profile", uriInfo)
-	}
-
-	@POST
-	@Path("modify")
-	def modifyProfile(@Context uriInfo: UriInfo,
-	                  @PathParam("id") userName: String,
-	                  @FormParam("webId") webId: UriRef,
-	                  @FormParam("name") name: String,
-	                  @FormParam("description") description: String): Response = {
-		val webIDInfo = AccessController.doPrivileged(new PrivilegedAction[WebIdInfo] {
-			def run = {
-				webIdGraphsService.getWebIdInfo(webId)
-			}
-		})
-		val agent: GraphNode = new GraphNode(webId, webIDInfo.localPublicUserData)
-		agent.deleteProperties(FOAF.name)
-		agent.addPropertyValue(FOAF.name, name)
-		agent.deleteProperties(DC.description)
-		agent.addPropertyValue(DC.description, description)
-		logger.debug("local graph (uri: {}) is now of size {}".format(webIDInfo.webId, webIDInfo.localPublicUserData.size))
-		RedirectUtil.createSeeOtherResponse("../profile", uriInfo)
-	}
-
-	protected def bindUserManager(usermanager: UserManager): Unit = {
-		userManager = usermanager
-	}
-
-	protected def unbindUserManager(usermanager: UserManager): Unit = {
-		if (userManager == usermanager) {
-			userManager = null
-		}
-	}
-
-	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
-	}
-
-	protected def unbindKeygenSrvc(keygenservice: KeygenService): Unit = {
-		if (keygenSrvc == keygenservice) {
-			keygenSrvc = null
-		}
-	}
-
-
-	protected def bindWebIdGraphsService(webidgraphsservice: WebIdGraphsService): Unit = {
-		webIdGraphsService = webidgraphsservice
-	}
-
-	protected def unbindWebIdGraphsService(webidgraphsservice: WebIdGraphsService): Unit = {
-		webIdGraphsService = null
-	}
-
-	protected def bindPlatformConfig(platformconfig: PlatformConfig): Unit = {
-		platformConfig = platformconfig
-	}
-
-	protected def unbindPlatformConfig(platformconfig: PlatformConfig): Unit = {
-		if (platformConfig == platformconfig) {
-			platformConfig = null
-		}
-	}
-
-	protected def bindTcManager(tcManager: TcManager) = {
-		this.tcManager = tcManager
-	}
-
-	protected def unbindTcManager(tcManager: TcManager) = {
-		this.tcManager = null
-	}
-
-	protected def activate(componentContext: ComponentContext): Unit = {
-		this.componentContext = componentContext
-	}
-
-
-	private var userManager: UserManager = null
-
-	private var graphNodeProvider: GraphNodeProvider = null
-
-	private var webIdGraphsService: WebIdGraphsService = null
-
-	private var keygenSrvc: KeygenService = null
-	private var platformConfig: PlatformConfig = null
-
-
-	private var componentContext: ComponentContext = null
-
-	private var tcManager: TcManager = null;
+  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)
+    //not checking as public profile must be public, more selective access control TBD
+    //AccessController.checkPermission(new AccountControlPanelAppPermission(userName, ""))
+    val resultNode= getPersonalProfile(userName, uriInfo)
+    return resultNode
+  }
+
+  private def getPersonalProfile(userName: String, info: UriInfo): GraphNode = {
+    lazy val suggestedPPDUri = getSuggestedPPDUri(userName)
+
+    val profile = AccessController.doPrivileged(new PrivilegedAction[GraphNode] {
+      def run: GraphNode = {
+        val userInSysGraph = userManager.getUserInSystemGraph(userName)
+        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 --> suggestedPPDUri
+            -- FOAF.primaryTopic --> (bnode -- PLATFORM.userName --> userName))
+            profile
+          }
+          case webid: UriRef => {
+            var webIDInfo = webIdGraphsService.getWebIdInfo(webid)
+            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(userResource.asInstanceOf[NonLiteral], FOAF.knows, null)
+                              if kn.getObject.isInstanceOf[UriRef];
+                              friend = kn.getObject.asInstanceOf[UriRef]
+                              if (friend != suggestedPPDUri)
+        ) yield {
+          try {
+            val friendGraph = tcManager.getGraph(FoafBrowser.removeHash(friend))
+            new RichGraphNode(friend, friendGraph).getNodeContext
+          } catch {
+            case e => {
+              logger.warn("cought exception trying to fetch graph - these graphs should already be in store " + friend, e)
+              new EzMGraph() {
+                friend -- SKOS.note --> ("problem with fetching this node: " + e)
+              }
+            }
+          }
+        }
+        //vera bad: mixing data from different sources
+        for (g <- friendInfo) profile.getGraph.addAll(g) */
+        profile
+      }
+    })
+
+
+    (profile a   PLATFORM.HeadedPage
+             a  CONTROLPANEL.ProfilePage)
+  }
+
+  /**
+   * @param userName
+   * @return the suggested Personal Profile Document URI
+   */
+  def getSuggestedPPDUri(userName: String): UriRef = {
+    return new UriRef(platformConfig.getDefaultBaseUri.getUnicodeString + "user/" + userName + "/profile")
+  }
+
+  @POST
+  @Path("set-existing-webid")
+  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)
+        userInSystemGraph.replaceWith(webId)
+        return RedirectUtil.createSeeOtherResponse("../profile", uriInfo)
+      }
+    })
+  }
+
+  @POST
+  @Path("create-new-web-id")
+  def createNewWebId(@Context uriInfo: UriInfo,
+                     @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(
+            webId.getUnicodeString, TcPermission.READWRITE).toString))
+        tcManager.getTcAccessController.setRequiredReadPermissionStrings(
+          ppd, Collections.singleton(new TcPermission(
+              Constants.CONTENT_GRAPH_URI_STRING, TcPermission.READ).toString))
+        tcManager.createMGraph(ppd)
+        val webIDInfo = webIdGraphsService.getWebIdInfo(webId)
+        webIDInfo.localPublicUserData.addAll(
+          Arrays.asList(
+            new TripleImpl(ppd, RDF.`type`, FOAF.PersonalProfileDocument),
+            new TripleImpl(ppd, FOAF.primaryTopic, webId))
+        )
+        var userInSystemGraph: GraphNode = userManager.getUserInSystemGraph(userName)
+        userInSystemGraph.replaceWith(webId)
+        return RedirectUtil.createSeeOtherResponse("../profile", uriInfo)
+      }
+    })
+  }
+
+  /**
+   * 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(@PathParam(value = "id") userName: String, @Context uriInfo: UriInfo,
+                 @FormParam("webId") newContacts: java.util.List[UriRef]): Response = {
+    import collection.JavaConversions._
+    if (newContacts.size > 0) {
+      var me: GraphNode = AccessController.doPrivileged(new PrivilegedAction[GraphNode] {
+        def run: GraphNode = {
+          return userManager.getUserGraphNode(userName)
+        }
+      })
+      for (contactWebID <- newContacts) {
+        val webIdGraphs = webIdGraphsService.getWebIdInfo(me.getNode.asInstanceOf[UriRef])
+        var meGrph: GraphNode = new GraphNode(me.getNode, webIdGraphs.localPublicUserData)
+        meGrph.addProperty(FOAF.knows, contactWebID)
+      } //todo: one should catch errors here (bad uris sent for ex
+    }
+    return RedirectUtil.createSeeOtherResponse("../profile", uriInfo)
+  }
+
+  /**
+   * 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
+   * @param crmf hey request in format generated by M$ Explorer
+   * @param csr key request as generated by Javascript of Netscape
+   * @param hours the certificate should last  (hours and days add up)
+   * @param days the certificate should last
+   * @param comment a comment to be attached to the public key in the database
+   */
+  @POST
+  @Path("keygen")
+  def createCert(@FormParam("webId") webIds: java.util.List[URI],
+                 @FormParam("cn") commonName: String,
+                 @FormParam("spkac") spkac: String,
+                 @FormParam("crmf") crmf: String,
+                 @FormParam("csr") csr: String,
+                 @FormParam("hours") hours: String,
+                 @FormParam("days") days: String,
+                 @FormParam("comment") comment: String): Response = {
+    import scala.collection.JavaConversions._
+    var cert: Certificate = null
+    if (spkac != null && spkac.length > 0) {
+      cert = keygenSrvc.createFromSpkac(spkac)
+      if (cert == null) {
+        logger.warn("unable to create certificate from spkac request")
+      }
+    }
+    if (cert == null && crmf != null && crmf.length > 0) {
+      cert = keygenSrvc.createFromCRMF(crmf)
+      if (cert == null) {
+        logger.warn("unable to create certificate from crmf requrest :" + crmf)
+      }
+    }
+    if (cert == null && csr != null && csr.length > 0) {
+      cert = keygenSrvc.createFromPEM(csr)
+      if (cert == null) {
+        logger.warn("unable to create certificate from csr request :" + csr)
+      }
+    }
+    if (cert == null) {
+      throw new RuntimeException("The server was unable to create a certificate")
+    }
+    cert.setSubjectCommonName(commonName)
+    cert.addDurationInHours(hours)
+    cert.addDurationInDays(days)
+    cert.startEarlier("2")
+    for(san: URI<-webIds) {
+      cert.addSubjectAlternativeName(san.toString)
+    }
+    var ser: CertSerialisation = null
+    try {
+      ser = cert.getSerialisation
+    }
+    catch {
+      case ex: Exception => {
+        throw new RuntimeException(ex)
+      }
+    }
+    var pubKey: RSAPublicKey = cert.getSubjectPublicKey.getPublicKey.asInstanceOf[RSAPublicKey]
+    var publicExponent: BigInteger = pubKey.getPublicExponent
+    var modulus: BigInteger = pubKey.getModulus
+
+    for (webid: URI<-webIds
+         if (webid.getScheme=="https"||webid.getScheme=="http");
+          val webidRef = new UriRef(webid.toString);
+         val webIdInfo = webIdGraphsService.getWebIdInfo(webidRef);
+         if (webIdInfo.isLocal)
+    ) {
+      val certGraph = new EzMGraph(webIdInfo.localPublicUserData)
+      import certGraph._
+      val certNode = certGraph.bnode
+      ( (certNode a  RSA.RSAPublicKey)
+         -- CERT.identity -->  webidRef
+         -- RSA.modulus -->  modulus
+         -- RSA.public_exponent -->  publicExponent
+         -- DC.date -->  cert.getStartDate )
+      if (comment != null && comment.length > 0) {
+        certNode --  RDFS.comment -->  comment
+      }
+    }
+    var resBuild: Response.ResponseBuilder = Response.ok(ser.getContent, MediaType.valueOf(ser.getMimeType))
+    return resBuild.build
+  }
+
+  @POST
+  @Path("deletekey")
+  def deleteKey(@Context uriInfo: UriInfo,
+                @FormParam("webId") webId: UriRef,
+                @FormParam("keyhash") keys: List[String]): Response = {
+    val webIDInfo = webIdGraphsService.getWebIdInfo(webId)
+    val agent: GraphNode = new GraphNode(webId, webIDInfo.localPublicUserData)
+    var subjects: Iterator[GraphNode] = agent.getSubjectNodes(CERT.identity)
+    import scala.util.control.Breaks._
+    breakable {
+      import scala.collection.JavaConversions._
+      //to for loop through iterators
+      for (nl <- subjects) {
+        var modulusIt: Iterator[Resource] = nl.getObjects(RSA.modulus)
+        if (!modulusIt.hasNext) break
+        var modLit: Resource = modulusIt.next
+        if (modulusIt.hasNext) logger.warn("data error, a modulus too many in cert for " + webId)
+        if (!(modLit.isInstanceOf[TypedLiteral])) {
+          logger.warn("a public key has a modulus that is not a literal for " + webId)
+          break
+        }
+        var modulus: BigInteger = LiteralFactory.getInstance.createObject(classOf[BigInteger], modLit.asInstanceOf[TypedLiteral])
+        for (key <- keys) {
+          if (modulus.hashCode == Integer.decode(key)) {
+            nl.deleteNodeContext
+            break
+          }
+        }
+      }
+    }
+    return RedirectUtil.createSeeOtherResponse("../profile", uriInfo)
+  }
+
+  @POST
+  @Path("modify")
+  def modifyProfile(@Context uriInfo: UriInfo,
+                    @PathParam("id") userName: String,
+                    @FormParam("webId") webId: UriRef,
+                    @FormParam("name") name: String,
+                    @FormParam("description") description: String): Response = {
+    val webIDInfo = AccessController.doPrivileged(new PrivilegedAction[WebIdInfo] {
+      def run = {
+        webIdGraphsService.getWebIdInfo(webId)
+      }
+    })
+    val agent: GraphNode = new GraphNode(webId, webIDInfo.localPublicUserData)
+    agent.deleteProperties(FOAF.name)
+    agent.addPropertyValue(FOAF.name, name)
+    agent.deleteProperties(DC.description)
+    agent.addPropertyValue(DC.description, description)
+    logger.debug("local graph (uri: {}) is now of size {}".format(webIDInfo.webId, webIDInfo.localPublicUserData.size))
+    RedirectUtil.createSeeOtherResponse("../profile", uriInfo)
+  }
+
+  protected def bindUserManager(usermanager: UserManager): Unit = {
+    userManager = usermanager
+  }
+
+  protected def unbindUserManager(usermanager: UserManager): Unit = {
+    if (userManager == usermanager) {
+      userManager = null
+    }
+  }
+
+  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
+  }
+
+  protected def unbindKeygenSrvc(keygenservice: KeygenService): Unit = {
+    if (keygenSrvc == keygenservice) {
+      keygenSrvc = null
+    }
+  }
+
+
+  protected def bindWebIdGraphsService(webidgraphsservice: WebIdGraphsService): Unit = {
+    webIdGraphsService = webidgraphsservice
+  }
+
+  protected def unbindWebIdGraphsService(webidgraphsservice: WebIdGraphsService): Unit = {
+    webIdGraphsService = null
+  }
+
+  protected def bindPlatformConfig(platformconfig: PlatformConfig): Unit = {
+    platformConfig = platformconfig
+  }
+
+  protected def unbindPlatformConfig(platformconfig: PlatformConfig): Unit = {
+    if (platformConfig == platformconfig) {
+      platformConfig = null
+    }
+  }
+
+  protected def bindTcManager(tcManager: TcManager) = {
+    this.tcManager = tcManager
+  }
+
+  protected def unbindTcManager(tcManager: TcManager) = {
+    this.tcManager = null
+  }
+
+  protected def activate(componentContext: ComponentContext): Unit = {
+    this.componentContext = componentContext
+  }
+
+
+  private var userManager: UserManager = null
+
+  private var graphNodeProvider: GraphNodeProvider = null
+
+  private var webIdGraphsService: WebIdGraphsService = null
+
+  private var keygenSrvc: KeygenService = null
+  private var platformConfig: PlatformConfig = null
+
+
+  private var componentContext: ComponentContext = null
+
+  private var tcManager: TcManager = null;
 
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/clerezza/blob/35448624/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/SettingsPanel.scala
----------------------------------------------------------------------
diff --git a/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/SettingsPanel.scala b/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/SettingsPanel.scala
index d7631a1..3d8d929 100644
--- a/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/SettingsPanel.scala
+++ b/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/SettingsPanel.scala
@@ -92,7 +92,7 @@ import org.apache.clerezza.rdf.utils.GraphNode
 import org.apache.clerezza.rdf.utils.UnionMGraph
 
 object SettingPanel {
-	val logger: Logger = LoggerFactory.getLogger(classOf[SettingsPanel])
+  val logger: Logger = LoggerFactory.getLogger(classOf[SettingsPanel])
 }
 
 /**
@@ -104,543 +104,543 @@ object SettingPanel {
 @Path("/user/{id}/control-panel")
 class SettingsPanel {
 
-	import SettingPanel.logger
+  import SettingPanel.logger
 
-	/**
-	 * Mainpage
-	 *
-	 * @param id is the username as given in the URL
-	 * @return an array of installed {@link Bundle}s to be managed
-	 *
-	 */
-	@GET
-	def settingsPage(@PathParam(value = "id") idP: String,
-						  @QueryParam("changedPassword") changedPassword: String,
-						  @Context uriInfo: UriInfo): GraphNode = {
-		TrailingSlash.enforceNotPresent(uriInfo)
-		val id: String = idP
-		var graphNode: GraphNode = null
-		AccessController.checkPermission(new AccountControlPanelAppPermission(id, ""))
-		try {
-			AccessController.checkPermission(new UserBundlePermission(id, ""))
-			graphNode = AccessController.doPrivileged(new PrivilegedAction[GraphNode] {
-				def run: GraphNode = {
-					var bundles: Array[Bundle] = userBundles(getAgent(id))
-					return asGraphNode(id, bundles)
-				}
-			})
-		}
-		catch {
-			case e: AccessControlException => {
-				graphNode = new GraphNode(new BNode, new SimpleMGraph)
-				graphNode.addProperty(CONTROLPANEL.userBundlePermission, LiteralFactory.getInstance.createTypedLiteral(false))
-			}
-		}
-		try {
-			AccessController.checkPermission(new ChangePasswordPermission(id, ""))
-			graphNode.addProperty(CONTROLPANEL.changePasswordPermission, LiteralFactory.getInstance.createTypedLiteral(true))
-		}
-		catch {
-			case e: AccessControlException => {
-				graphNode.addProperty(CONTROLPANEL.changePasswordPermission, LiteralFactory.getInstance.createTypedLiteral(false))
-			}
-		}
-		if (changedPassword != null && changedPassword.equals("false")) {
-			graphNode.addProperty(CONTROLPANEL.changedPassword, new PlainLiteralImpl("false"))
-		}
-		graphNode.addProperty(RDF.`type`, CONTROLPANEL.SettingsPage)
-		graphNode.addProperty(RDF.`type`, PLATFORM.HeadedPage)
-		return graphNode
-	}
+  /**
+   * Mainpage
+   *
+   * @param id is the username as given in the URL
+   * @return an array of installed {@link Bundle}s to be managed
+   *
+   */
+  @GET
+  def settingsPage(@PathParam(value = "id") idP: String,
+              @QueryParam("changedPassword") changedPassword: String,
+              @Context uriInfo: UriInfo): GraphNode = {
+    TrailingSlash.enforceNotPresent(uriInfo)
+    val id: String = idP
+    var graphNode: GraphNode = null
+    AccessController.checkPermission(new AccountControlPanelAppPermission(id, ""))
+    try {
+      AccessController.checkPermission(new UserBundlePermission(id, ""))
+      graphNode = AccessController.doPrivileged(new PrivilegedAction[GraphNode] {
+        def run: GraphNode = {
+          var bundles: Array[Bundle] = userBundles(getAgent(id))
+          return asGraphNode(id, bundles)
+        }
+      })
+    }
+    catch {
+      case e: AccessControlException => {
+        graphNode = new GraphNode(new BNode, new SimpleMGraph)
+        graphNode.addProperty(CONTROLPANEL.userBundlePermission, LiteralFactory.getInstance.createTypedLiteral(false))
+      }
+    }
+    try {
+      AccessController.checkPermission(new ChangePasswordPermission(id, ""))
+      graphNode.addProperty(CONTROLPANEL.changePasswordPermission, LiteralFactory.getInstance.createTypedLiteral(true))
+    }
+    catch {
+      case e: AccessControlException => {
+        graphNode.addProperty(CONTROLPANEL.changePasswordPermission, LiteralFactory.getInstance.createTypedLiteral(false))
+      }
+    }
+    if (changedPassword != null && changedPassword.equals("false")) {
+      graphNode.addProperty(CONTROLPANEL.changedPassword, new PlainLiteralImpl("false"))
+    }
+    graphNode.addProperty(RDF.`type`, CONTROLPANEL.SettingsPage)
+    graphNode.addProperty(RDF.`type`, PLATFORM.HeadedPage)
+    return graphNode
+  }
 
-	private def addBundleDescriptionToGraph(responseGraph: MGraph, bundle: Bundle): Unit = {
-		var status: TypedLiteral = LiteralFactory.getInstance.createTypedLiteral(bundle.getState)
-		var bundleUri: UriRef = new UriRef(bundle.getLocation)
-		var triple: Triple = new TripleImpl(bundleUri, OSGI.status, status)
-		responseGraph.add(triple)
-		var bundleId: TypedLiteral = LiteralFactory.getInstance.createTypedLiteral(bundle.getBundleId)
-		triple = new TripleImpl(bundleUri, OSGI.bundle_id, bundleId)
-		responseGraph.add(triple)
-	}
+  private def addBundleDescriptionToGraph(responseGraph: MGraph, bundle: Bundle): Unit = {
+    var status: TypedLiteral = LiteralFactory.getInstance.createTypedLiteral(bundle.getState)
+    var bundleUri: UriRef = new UriRef(bundle.getLocation)
+    var triple: Triple = new TripleImpl(bundleUri, OSGI.status, status)
+    responseGraph.add(triple)
+    var bundleId: TypedLiteral = LiteralFactory.getInstance.createTypedLiteral(bundle.getBundleId)
+    triple = new TripleImpl(bundleUri, OSGI.bundle_id, bundleId)
+    responseGraph.add(triple)
+  }
 
-	private def asGraphNode(userId: String, bundles: Array[Bundle]): GraphNode = {
-		val responseGraph: MGraph = new SimpleMGraph
-		for (bundle <- bundles) {
-			addBundleDescriptionToGraph(responseGraph, bundle)
-		}
-		return AccessController.doPrivileged(new PrivilegedAction[GraphNode] {
-			def run: GraphNode = {
-				var userDescriptionGraph: Graph = new GraphNode(getAgent(userId), systemGraph).getNodeContext
-				var unionGraph: UnionMGraph = new UnionMGraph(responseGraph, userDescriptionGraph)
-				var graphNode: GraphNode = new GraphNode(getAgent(userId), unionGraph)
-				graphNode.addProperty(CONTROLPANEL.userBundlePermission, LiteralFactory.getInstance.createTypedLiteral(true))
-				return graphNode
-			}
-		})
-	}
+  private def asGraphNode(userId: String, bundles: Array[Bundle]): GraphNode = {
+    val responseGraph: MGraph = new SimpleMGraph
+    for (bundle <- bundles) {
+      addBundleDescriptionToGraph(responseGraph, bundle)
+    }
+    return AccessController.doPrivileged(new PrivilegedAction[GraphNode] {
+      def run: GraphNode = {
+        var userDescriptionGraph: Graph = new GraphNode(getAgent(userId), systemGraph).getNodeContext
+        var unionGraph: UnionMGraph = new UnionMGraph(responseGraph, userDescriptionGraph)
+        var graphNode: GraphNode = new GraphNode(getAgent(userId), unionGraph)
+        graphNode.addProperty(CONTROLPANEL.userBundlePermission, LiteralFactory.getInstance.createTypedLiteral(true))
+        return graphNode
+      }
+    })
+  }
 
-	/**
-	 * Retrieves all bundles owned by a user represented by agent
-	 *
-	 * @param agent represents the user who owns bundles to be returned
-	 * @return an array of {@link Bundle}s owned by the user
-	 *
-	 */
-	private def userBundles(agent: NonLiteral): Array[Bundle] = {
-		logger.debug("Retrieve all bundles from user: {}", agent)
-		var installedBundles: Array[Bundle] = componentContext.getBundleContext.getBundles
-		val locationMapper: Map[String, Long] = new HashMap[String, Long]
-		for (b <- installedBundles) {
-			locationMapper.put(b.getLocation, b.getBundleId)
-		}
-		return AccessController.doPrivileged(new PrivilegedAction[Array[Bundle]] {
-			def run: Array[Bundle] = {
-				var bundles: Set[Bundle] = new HashSet[Bundle]
-				var agentBundles: Iterator[Triple] = systemGraph.filter(null, OSGI.owner, agent)
-				while (agentBundles.hasNext) {
-					val location: String = (agentBundles.next.getSubject.asInstanceOf[UriRef]).getUnicodeString
-					try {
-						val id: Long = locationMapper.get(location)
-						bundles.add(componentContext.getBundleContext.getBundle(id))
-					} catch {
-						case _:NumberFormatException => None
-					}
-				}
-				return bundles.toArray(new Array[Bundle](bundles.size))
-			}
-		})
-	}
+  /**
+   * Retrieves all bundles owned by a user represented by agent
+   *
+   * @param agent represents the user who owns bundles to be returned
+   * @return an array of {@link Bundle}s owned by the user
+   *
+   */
+  private def userBundles(agent: NonLiteral): Array[Bundle] = {
+    logger.debug("Retrieve all bundles from user: {}", agent)
+    var installedBundles: Array[Bundle] = componentContext.getBundleContext.getBundles
+    val locationMapper: Map[String, Long] = new HashMap[String, Long]
+    for (b <- installedBundles) {
+      locationMapper.put(b.getLocation, b.getBundleId)
+    }
+    return AccessController.doPrivileged(new PrivilegedAction[Array[Bundle]] {
+      def run: Array[Bundle] = {
+        var bundles: Set[Bundle] = new HashSet[Bundle]
+        var agentBundles: Iterator[Triple] = systemGraph.filter(null, OSGI.owner, agent)
+        while (agentBundles.hasNext) {
+          val location: String = (agentBundles.next.getSubject.asInstanceOf[UriRef]).getUnicodeString
+          try {
+            val id: Long = locationMapper.get(location)
+            bundles.add(componentContext.getBundleContext.getBundle(id))
+          } catch {
+            case _:NumberFormatException => None
+          }
+        }
+        return bundles.toArray(new Array[Bundle](bundles.size))
+      }
+    })
+  }
 
-	private def getAgent(id: String): NonLiteral = {
-		logger.debug("Get agent with id {}", id)
-		var agents: Iterator[Triple] = systemGraph.filter(null, PLATFORM.userName, new PlainLiteralImpl(id))
-		if (agents.hasNext) {
-			return agents.next.getSubject
-		}
-		else {
-			logger.debug("System graph does not contain user: {}", id)
-			var responseBuilder: Response.ResponseBuilder = Response.ok("<html><body>User does not exist</body></html>")
-			throw new WebApplicationException(responseBuilder.build)
-		}
-	}
+  private def getAgent(id: String): NonLiteral = {
+    logger.debug("Get agent with id {}", id)
+    var agents: Iterator[Triple] = systemGraph.filter(null, PLATFORM.userName, new PlainLiteralImpl(id))
+    if (agents.hasNext) {
+      return agents.next.getSubject
+    }
+    else {
+      logger.debug("System graph does not contain user: {}", id)
+      var responseBuilder: Response.ResponseBuilder = Response.ok("<html><body>User does not exist</body></html>")
+      throw new WebApplicationException(responseBuilder.build)
+    }
+  }
 
-	private def getAgentPathPrefix(agent: NonLiteral): PlainLiteralImpl = {
-		return AccessController.doPrivileged(new PrivilegedAction[PlainLiteralImpl] {
-			def run: PlainLiteralImpl = {
-				var pathPrefixes: Iterator[Triple] = systemGraph.filter(agent, OSGI.agent_path_prefix, null)
-				if (pathPrefixes.hasNext) {
-					return pathPrefixes.next.getObject.asInstanceOf[PlainLiteralImpl]
-				}
-				return null
-			}
-		})
-	}
+  private def getAgentPathPrefix(agent: NonLiteral): PlainLiteralImpl = {
+    return AccessController.doPrivileged(new PrivilegedAction[PlainLiteralImpl] {
+      def run: PlainLiteralImpl = {
+        var pathPrefixes: Iterator[Triple] = systemGraph.filter(agent, OSGI.agent_path_prefix, null)
+        if (pathPrefixes.hasNext) {
+          return pathPrefixes.next.getObject.asInstanceOf[PlainLiteralImpl]
+        }
+        return null
+      }
+    })
+  }
 
-	/**
-	 * Installs a bundle from the specified location.
-	 *
-	 * @param id is the username as given in the URL
-	 * @param location specifies the URL of the bundle to be installed
-	 * @return an array of installed {@link Bundle}s to be managed
-	 *
-	 */
-	@POST
-	@Path("install-bundle")
-	@Consumes def installBundle(@PathParam(value = "id") id: String, multiForm: MultiPartBody, @Context uriInfo: UriInfo): Response = {
-		AccessController.checkPermission(new AccountControlPanelAppPermission(id, ""))
-		AccessController.checkPermission(new UserBundlePermission(id, ""))
-		var formFiles: Array[FormFile] = multiForm.getFormFileParameterValues("bundle")
-		var filename: String = formFiles(0).getFileName
-		var bundleBytes: Array[Byte] = formFiles(0).getContent
-		if (bundleBytes.length == 0) {
-			var message: String = null
-			if (filename.equals("")) {
-				message = "No bundle specified"
-			}
-			else {
-				message = "Bundle has length 0"
-			}
-			var responseBuilder: Response.ResponseBuilder = Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message)
-			throw new WebApplicationException(responseBuilder.build)
-		}
-		val bundleInputStream: InputStream = new ByteArrayInputStream(bundleBytes)
-		val location: String = "userbundle:" + id + "/" + filename
-		logger.info("Install bundle {} to location {}", id, location)
-		AccessController.doPrivileged(new PrivilegedAction[AnyRef] {
-			def run: Array[Bundle] = {
-				val agent: NonLiteral = getAgent(id)
-				val triple: Triple = new TripleImpl(new UriRef(location), OSGI.owner, agent)
-				try {
-					systemGraph.add(triple)
-					var bundle: Bundle = componentContext.getBundleContext.installBundle(location, bundleInputStream)
-					var prefix: PlainLiteralImpl = getAgentPathPrefix(agent)
-					if (prefix != null) {
-						addBundlePrefix(bundle, prefix.getLexicalForm)
-					}
-					return null
-				}
-				catch {
-					case ex: BundleException => {
-						systemGraph.remove(triple)
-						logger.debug("Failed to install a bundle from: {}", location)
-						logger.error("Exception during install bundle: {}", ex)
-						var responseBuilder: Response.ResponseBuilder = Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(ex.getMessage)
-						throw new WebApplicationException(responseBuilder.build)
-					}
-				}
-			}
-		})
-		return RedirectUtil.createSeeOtherResponse("../control-panel", uriInfo)
-	}
+  /**
+   * Installs a bundle from the specified location.
+   *
+   * @param id is the username as given in the URL
+   * @param location specifies the URL of the bundle to be installed
+   * @return an array of installed {@link Bundle}s to be managed
+   *
+   */
+  @POST
+  @Path("install-bundle")
+  @Consumes def installBundle(@PathParam(value = "id") id: String, multiForm: MultiPartBody, @Context uriInfo: UriInfo): Response = {
+    AccessController.checkPermission(new AccountControlPanelAppPermission(id, ""))
+    AccessController.checkPermission(new UserBundlePermission(id, ""))
+    var formFiles: Array[FormFile] = multiForm.getFormFileParameterValues("bundle")
+    var filename: String = formFiles(0).getFileName
+    var bundleBytes: Array[Byte] = formFiles(0).getContent
+    if (bundleBytes.length == 0) {
+      var message: String = null
+      if (filename.equals("")) {
+        message = "No bundle specified"
+      }
+      else {
+        message = "Bundle has length 0"
+      }
+      var responseBuilder: Response.ResponseBuilder = Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message)
+      throw new WebApplicationException(responseBuilder.build)
+    }
+    val bundleInputStream: InputStream = new ByteArrayInputStream(bundleBytes)
+    val location: String = "userbundle:" + id + "/" + filename
+    logger.info("Install bundle {} to location {}", id, location)
+    AccessController.doPrivileged(new PrivilegedAction[AnyRef] {
+      def run: Array[Bundle] = {
+        val agent: NonLiteral = getAgent(id)
+        val triple: Triple = new TripleImpl(new UriRef(location), OSGI.owner, agent)
+        try {
+          systemGraph.add(triple)
+          var bundle: Bundle = componentContext.getBundleContext.installBundle(location, bundleInputStream)
+          var prefix: PlainLiteralImpl = getAgentPathPrefix(agent)
+          if (prefix != null) {
+            addBundlePrefix(bundle, prefix.getLexicalForm)
+          }
+          return null
+        }
+        catch {
+          case ex: BundleException => {
+            systemGraph.remove(triple)
+            logger.debug("Failed to install a bundle from: {}", location)
+            logger.error("Exception during install bundle: {}", ex)
+            var responseBuilder: Response.ResponseBuilder = Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(ex.getMessage)
+            throw new WebApplicationException(responseBuilder.build)
+          }
+        }
+      }
+    })
+    return RedirectUtil.createSeeOtherResponse("../control-panel", uriInfo)
+  }
 
-	private def addBundlePrefix(bundle: Bundle, prefix: String): Unit = {
-		var symbolicName: String = bundle.getSymbolicName
-		/*if (configAdmin != null) {
-			try {
-				var configuration: Configuration = configAdmin.getConfiguration(classOf[TriaxrsPrefixManager].getName)
-				val properties = configuration.getProperties match {
-					case null => new Hashtable[String, AnyRef]()
-					case dict: Dictionary[String, AnyRef] => dict
-				}
-				var mappings = TriaxrsPrefixManager.parseMappings(properties.get(TriaxrsPrefixManager.TRIAXRS_MAPPINGS).asInstanceOf[Array[String]])
-				logger.debug("Prefix {} added to bundle {}", prefix, symbolicName)
-				mappings.put(symbolicName, prefix)
-				var newMappings: Array[String] = TriaxrsPrefixManager.unparseMappings(mappings)
-				properties.put(TriaxrsPrefixManager.TRIAXRS_MAPPINGS, newMappings)
-				configuration.update(properties)
-			}
-			catch {
-				case e: IOException => {
-					logger.warn("Unable to update configuration: {}", e.toString)
-				}
-			}
-		}
-		else {
-			logger.warn("Cannot add prefix mapping. Configuration Admin is missing")
-		}*/
-	}
+  private def addBundlePrefix(bundle: Bundle, prefix: String): Unit = {
+    var symbolicName: String = bundle.getSymbolicName
+    /*if (configAdmin != null) {
+      try {
+        var configuration: Configuration = configAdmin.getConfiguration(classOf[TriaxrsPrefixManager].getName)
+        val properties = configuration.getProperties match {
+          case null => new Hashtable[String, AnyRef]()
+          case dict: Dictionary[String, AnyRef] => dict
+        }
+        var mappings = TriaxrsPrefixManager.parseMappings(properties.get(TriaxrsPrefixManager.TRIAXRS_MAPPINGS).asInstanceOf[Array[String]])
+        logger.debug("Prefix {} added to bundle {}", prefix, symbolicName)
+        mappings.put(symbolicName, prefix)
+        var newMappings: Array[String] = TriaxrsPrefixManager.unparseMappings(mappings)
+        properties.put(TriaxrsPrefixManager.TRIAXRS_MAPPINGS, newMappings)
+        configuration.update(properties)
+      }
+      catch {
+        case e: IOException => {
+          logger.warn("Unable to update configuration: {}", e.toString)
+        }
+      }
+    }
+    else {
+      logger.warn("Cannot add prefix mapping. Configuration Admin is missing")
+    }*/
+  }
 
-	private[accountcontrolpanel] def removeBundlePrefix(bundle: Bundle): Unit = {
-		var symbolicName: String = bundle.getSymbolicName
-		/*if ((this.configAdmin != null) && (symbolicName != null)) {
-			try {
-				val configuration: Configuration = configAdmin.getConfiguration(classOf[TriaxrsPrefixManager].getName)
-				val properties = configuration.getProperties match {
-					case null => new Hashtable[String, AnyRef]()
-					case dict: Dictionary[String, AnyRef] => dict
-				}
-				val mappings = TriaxrsPrefixManager.parseMappings(properties.get(TriaxrsPrefixManager.TRIAXRS_MAPPINGS).asInstanceOf[Array[String]])
-				mappings.remove(symbolicName)
-				val newMappings: Array[String] = TriaxrsPrefixManager.unparseMappings(mappings)
-				properties.put(TriaxrsPrefixManager.TRIAXRS_MAPPINGS, newMappings)
-				configuration.update(properties)
-			}
-			catch {
-				case e: IOException => {
-					logger.warn("Unable to update configuration: {}", e.toString)
-				}
-			}
-		}
-		else {
-			logger.warn("Cannot add prefix mapping. Configuration Admin is missing")
-		}*/
-	}
+  private[accountcontrolpanel] def removeBundlePrefix(bundle: Bundle): Unit = {
+    var symbolicName: String = bundle.getSymbolicName
+    /*if ((this.configAdmin != null) && (symbolicName != null)) {
+      try {
+        val configuration: Configuration = configAdmin.getConfiguration(classOf[TriaxrsPrefixManager].getName)
+        val properties = configuration.getProperties match {
+          case null => new Hashtable[String, AnyRef]()
+          case dict: Dictionary[String, AnyRef] => dict
+        }
+        val mappings = TriaxrsPrefixManager.parseMappings(properties.get(TriaxrsPrefixManager.TRIAXRS_MAPPINGS).asInstanceOf[Array[String]])
+        mappings.remove(symbolicName)
+        val newMappings: Array[String] = TriaxrsPrefixManager.unparseMappings(mappings)
+        properties.put(TriaxrsPrefixManager.TRIAXRS_MAPPINGS, newMappings)
+        configuration.update(properties)
+      }
+      catch {
+        case e: IOException => {
+          logger.warn("Unable to update configuration: {}", e.toString)
+        }
+      }
+    }
+    else {
+      logger.warn("Cannot add prefix mapping. Configuration Admin is missing")
+    }*/
+  }
 
-	/**
-	 * Starts the bundle with the specified bundle id.
-	 *
-	 * @param id is the username as given in the URL
-	 * @param bundleIdString specifies the id of the bundle to be started
-	 * @return an array of installed {@link Bundle}s to be managed
-	 *
-	 */
-	@POST
-	@Path("start-bundle")
-	def startBundle(@PathParam(value = "id") idP: String,
-						 @FormParam("bundleId") bundleIdStringP: String,
-						 @Context uriInfo: UriInfo): Response = {
-		val id: String = idP
-		val bundleIdString: String = bundleIdStringP
-		AccessController.checkPermission(new AccountControlPanelAppPermission(id, ""))
-		AccessController.checkPermission(new UserBundlePermission(id, ""))
-		logger.info("Start bundle {} ", id)
-		val bundleId: Long = bundleIdString.toLong
-		AccessController.doPrivileged(new PrivilegedAction[AnyRef] {
-			def run: Array[Bundle] = {
-				try {
-					val bundle: Bundle = componentContext.getBundleContext.getBundle(bundleId)
-					bundle.start
-				}
-				catch {
-					case e: BundleException => {
-						logger.debug("Failed to start bundle {}", bundleIdString)
-						logger.error("Exception during start bundle: {}", e)
-						var responseBuilder: Response.ResponseBuilder = Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage)
-						throw new WebApplicationException(responseBuilder.build)
-					}
-				}
-				return null
-			}
-		})
-		return RedirectUtil.createSeeOtherResponse("../control-panel", uriInfo)
-	}
+  /**
+   * Starts the bundle with the specified bundle id.
+   *
+   * @param id is the username as given in the URL
+   * @param bundleIdString specifies the id of the bundle to be started
+   * @return an array of installed {@link Bundle}s to be managed
+   *
+   */
+  @POST
+  @Path("start-bundle")
+  def startBundle(@PathParam(value = "id") idP: String,
+             @FormParam("bundleId") bundleIdStringP: String,
+             @Context uriInfo: UriInfo): Response = {
+    val id: String = idP
+    val bundleIdString: String = bundleIdStringP
+    AccessController.checkPermission(new AccountControlPanelAppPermission(id, ""))
+    AccessController.checkPermission(new UserBundlePermission(id, ""))
+    logger.info("Start bundle {} ", id)
+    val bundleId: Long = bundleIdString.toLong
+    AccessController.doPrivileged(new PrivilegedAction[AnyRef] {
+      def run: Array[Bundle] = {
+        try {
+          val bundle: Bundle = componentContext.getBundleContext.getBundle(bundleId)
+          bundle.start
+        }
+        catch {
+          case e: BundleException => {
+            logger.debug("Failed to start bundle {}", bundleIdString)
+            logger.error("Exception during start bundle: {}", e)
+            var responseBuilder: Response.ResponseBuilder = Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage)
+            throw new WebApplicationException(responseBuilder.build)
+          }
+        }
+        return null
+      }
+    })
+    return RedirectUtil.createSeeOtherResponse("../control-panel", uriInfo)
+  }
 
-	/**
-	 * Stops the bundle with the specified bundle id.
-	 *
-	 * @param id is the username as given in the URL
-	 * @param bundleIdString specifies the id of the bundle to be stopped
-	 * @return an array of installed {@link Bundle}s to be managed
-	 *
-	 */
-	@POST
-	@Path("stop-bundle") def stopBundle(@PathParam(value = "id") idP: String,
-													@FormParam("bundleId") bundleIdStringP: String,
-													@Context uriInfo: UriInfo): Response = {
-		val id: String = idP
-		val bundleIdString: String = bundleIdStringP
-		AccessController.checkPermission(new AccountControlPanelAppPermission(id, ""))
-		AccessController.checkPermission(new UserBundlePermission(id, ""))
-		logger.info("Stop bundle {}", id)
-		val bundleId: Long = bundleIdString.toLong
-		AccessController.doPrivileged(new PrivilegedAction[AnyRef] {
-			def run: Array[Bundle] = {
-				try {
-					var bundle: Bundle = componentContext.getBundleContext.getBundle(bundleId)
-					bundle.stop
-				}
-				catch {
-					case e: BundleException => {
-						logger.debug("Failed to stop bundle ", bundleIdString)
-						logger.error("Exception during stop bundle: {}", e)
-						var responseBuilder: Response.ResponseBuilder = Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage)
-						throw new WebApplicationException(responseBuilder.build)
-					}
-				}
-				return null
-			}
-		})
-		return RedirectUtil.createSeeOtherResponse("../control-panel", uriInfo)
-	}
+  /**
+   * Stops the bundle with the specified bundle id.
+   *
+   * @param id is the username as given in the URL
+   * @param bundleIdString specifies the id of the bundle to be stopped
+   * @return an array of installed {@link Bundle}s to be managed
+   *
+   */
+  @POST
+  @Path("stop-bundle") def stopBundle(@PathParam(value = "id") idP: String,
+                          @FormParam("bundleId") bundleIdStringP: String,
+                          @Context uriInfo: UriInfo): Response = {
+    val id: String = idP
+    val bundleIdString: String = bundleIdStringP
+    AccessController.checkPermission(new AccountControlPanelAppPermission(id, ""))
+    AccessController.checkPermission(new UserBundlePermission(id, ""))
+    logger.info("Stop bundle {}", id)
+    val bundleId: Long = bundleIdString.toLong
+    AccessController.doPrivileged(new PrivilegedAction[AnyRef] {
+      def run: Array[Bundle] = {
+        try {
+          var bundle: Bundle = componentContext.getBundleContext.getBundle(bundleId)
+          bundle.stop
+        }
+        catch {
+          case e: BundleException => {
+            logger.debug("Failed to stop bundle ", bundleIdString)
+            logger.error("Exception during stop bundle: {}", e)
+            var responseBuilder: Response.ResponseBuilder = Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage)
+            throw new WebApplicationException(responseBuilder.build)
+          }
+        }
+        return null
+      }
+    })
+    return RedirectUtil.createSeeOtherResponse("../control-panel", uriInfo)
+  }
 
-	/**
-	 * Uninstalls the bundle with the specified bundle id.
-	 *
-	 * @param id is the username as given in the URL
-	 * @param bundleIdString specifies the id of the bundle to be uninstalled
-	 * @return an array of installed {@link Bundle}s to be managed
-	 *
-	 */
-	@POST
-	@Path("uninstall-bundle")
-	def uninstallBundle(@PathParam(value = "id") idP: String,
-							  @FormParam("bundleId") bundleIdStringP: String,
-							  @Context uriInfo: UriInfo): Response = {
-		val id: String = idP
-		val bundleIdString: String = bundleIdStringP
-		AccessController.checkPermission(new AccountControlPanelAppPermission(id, ""))
-		AccessController.checkPermission(new UserBundlePermission(id, ""))
-		logger.info("Uninstall bundle {}", id)
-		val bundleId: Long = bundleIdString.toLong
-		AccessController.doPrivileged(new PrivilegedAction[AnyRef] {
-			def run: Array[Bundle] = {
-				val agent: NonLiteral = getAgent(id)
-				try {
-					var bundle: Bundle = componentContext.getBundleContext.getBundle(bundleId)
-					bundle.uninstall
-					val triple: Triple = new TripleImpl(new UriRef(bundle.getLocation), OSGI.owner, agent)
-					systemGraph.remove(triple)
-					removeBundlePrefix(bundle)
-				}
-				catch {
-					case e: BundleException => {
-						logger.debug("Failed to uninstall bundle {}", bundleIdString)
-						logger.error("Exception during uninstall bundle: {}", e)
-						var responseBuilder: Response.ResponseBuilder = Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage)
-						throw new WebApplicationException(responseBuilder.build)
-					}
-				}
-				return null
-			}
-		})
-		return RedirectUtil.createSeeOtherResponse("../control-panel", uriInfo)
-	}
+  /**
+   * Uninstalls the bundle with the specified bundle id.
+   *
+   * @param id is the username as given in the URL
+   * @param bundleIdString specifies the id of the bundle to be uninstalled
+   * @return an array of installed {@link Bundle}s to be managed
+   *
+   */
+  @POST
+  @Path("uninstall-bundle")
+  def uninstallBundle(@PathParam(value = "id") idP: String,
+                @FormParam("bundleId") bundleIdStringP: String,
+                @Context uriInfo: UriInfo): Response = {
+    val id: String = idP
+    val bundleIdString: String = bundleIdStringP
+    AccessController.checkPermission(new AccountControlPanelAppPermission(id, ""))
+    AccessController.checkPermission(new UserBundlePermission(id, ""))
+    logger.info("Uninstall bundle {}", id)
+    val bundleId: Long = bundleIdString.toLong
+    AccessController.doPrivileged(new PrivilegedAction[AnyRef] {
+      def run: Array[Bundle] = {
+        val agent: NonLiteral = getAgent(id)
+        try {
+          var bundle: Bundle = componentContext.getBundleContext.getBundle(bundleId)
+          bundle.uninstall
+          val triple: Triple = new TripleImpl(new UriRef(bundle.getLocation), OSGI.owner, agent)
+          systemGraph.remove(triple)
+          removeBundlePrefix(bundle)
+        }
+        catch {
+          case e: BundleException => {
+            logger.debug("Failed to uninstall bundle {}", bundleIdString)
+            logger.error("Exception during uninstall bundle: {}", e)
+            var responseBuilder: Response.ResponseBuilder = Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage)
+            throw new WebApplicationException(responseBuilder.build)
+          }
+        }
+        return null
+      }
+    })
+    return RedirectUtil.createSeeOtherResponse("../control-panel", uriInfo)
+  }
 
-	/**
-	 * changes the password of an user
-	 *
-	 * @param idP id is the username as given in the URL
-	 * @param lang represents the user's new standard language.
-	 * @return
-	 */
-	@POST
-	@Path("change-language")
-	def changeUserLanguage(@PathParam(value = "id") idP: String,
-								  @FormParam("availablelanguages") lang: String,
-								  @Context uriInfo: UriInfo): Response = {
-		val id: String = idP
-		AccessController.checkPermission(new AccountControlPanelAppPermission(id, ""))
-		AccessController.doPrivileged(new PrivilegedAction[AnyRef] {
-			def run: AnyRef = {
-				var userNode: GraphNode = new GraphNode(getAgent(id), systemGraph)
-				userNode.deleteProperties(PLATFORM.preferredLangInISOCode)
-				userNode.addProperty(PLATFORM.preferredLangInISOCode, LiteralFactory.getInstance.createTypedLiteral(lang))
-				return null
-			}
-		})
-		return RedirectUtil.createSeeOtherResponse("../control-panel", uriInfo)
-	}
+  /**
+   * changes the password of an user
+   *
+   * @param idP id is the username as given in the URL
+   * @param lang represents the user's new standard language.
+   * @return
+   */
+  @POST
+  @Path("change-language")
+  def changeUserLanguage(@PathParam(value = "id") idP: String,
+                  @FormParam("availablelanguages") lang: String,
+                  @Context uriInfo: UriInfo): Response = {
+    val id: String = idP
+    AccessController.checkPermission(new AccountControlPanelAppPermission(id, ""))
+    AccessController.doPrivileged(new PrivilegedAction[AnyRef] {
+      def run: AnyRef = {
+        var userNode: GraphNode = new GraphNode(getAgent(id), systemGraph)
+        userNode.deleteProperties(PLATFORM.preferredLangInISOCode)
+        userNode.addProperty(PLATFORM.preferredLangInISOCode, LiteralFactory.getInstance.createTypedLiteral(lang))
+        return null
+      }
+    })
+    return RedirectUtil.createSeeOtherResponse("../control-panel", uriInfo)
+  }
 
-	/**
-	 * changes the password of an user
-	 *
-	 * @param idP id is the username as given in the URL
-	 * @param oldPW the current user password
-	 * @param newPW the new password
-	 * @param confirmNewPW the new password
-	 * @return
-	 */
-	@POST
-	@Path("change-password")
-	def changePassword(@PathParam(value = "id") idP: String,
-							 @FormParam("oldPW") oldPW: String,
-							 @FormParam("newPW") newPW: String,
-							 @FormParam("confirmNewPW") confirmNewPW: String,
-							 @Context uriInfo: UriInfo): Response = {
-		val id: String = idP
-		AccessController.checkPermission(new AccountControlPanelAppPermission(id, ""))
-		AccessController.checkPermission(new ChangePasswordPermission(id, ""))
-		var changedPassword: Boolean = false
-		if (newPW.trim.equals(confirmNewPW.trim) && checkPWStrings(oldPW, newPW)) {
-			changedPassword = AccessController.doPrivileged(new PrivilegedAction[Boolean] {
-				private def getCurrentPassword(agent: NonLiteral): String = {
-					var currentPassword: String = null
-					var oldPWTriple: Iterator[Triple] = systemGraph.filter(agent, PERMISSION.passwordSha1, null)
-					if (oldPWTriple.hasNext) {
-						var currentPWLiteral: Literal = oldPWTriple.next.getObject.asInstanceOf[Literal]
-						currentPassword = currentPWLiteral.getLexicalForm
-					}
-					return currentPassword
-				}
+  /**
+   * changes the password of an user
+   *
+   * @param idP id is the username as given in the URL
+   * @param oldPW the current user password
+   * @param newPW the new password
+   * @param confirmNewPW the new password
+   * @return
+   */
+  @POST
+  @Path("change-password")
+  def changePassword(@PathParam(value = "id") idP: String,
+               @FormParam("oldPW") oldPW: String,
+               @FormParam("newPW") newPW: String,
+               @FormParam("confirmNewPW") confirmNewPW: String,
+               @Context uriInfo: UriInfo): Response = {
+    val id: String = idP
+    AccessController.checkPermission(new AccountControlPanelAppPermission(id, ""))
+    AccessController.checkPermission(new ChangePasswordPermission(id, ""))
+    var changedPassword: Boolean = false
+    if (newPW.trim.equals(confirmNewPW.trim) && checkPWStrings(oldPW, newPW)) {
+      changedPassword = AccessController.doPrivileged(new PrivilegedAction[Boolean] {
+        private def getCurrentPassword(agent: NonLiteral): String = {
+          var currentPassword: String = null
+          var oldPWTriple: Iterator[Triple] = systemGraph.filter(agent, PERMISSION.passwordSha1, null)
+          if (oldPWTriple.hasNext) {
+            var currentPWLiteral: Literal = oldPWTriple.next.getObject.asInstanceOf[Literal]
+            currentPassword = currentPWLiteral.getLexicalForm
+          }
+          return currentPassword
+        }
 
-				def run: Boolean = {
-					val agent: NonLiteral = getAgent(id)
-					var encodedOlpPW: String = getEncodedPW(oldPW)
-					var currentPassword: String = getCurrentPassword(agent)
-					if ((currentPassword != null) && !currentPassword.equals(encodedOlpPW)) {
-						logger.info("Typed wrong current password!")
-						return false
-					}
-					else {
-						removeOldPwAndAddNewPW(agent, currentPassword, newPW)
-						return true
-					}
-				}
+        def run: Boolean = {
+          val agent: NonLiteral = getAgent(id)
+          var encodedOlpPW: String = getEncodedPW(oldPW)
+          var currentPassword: String = getCurrentPassword(agent)
+          if ((currentPassword != null) && !currentPassword.equals(encodedOlpPW)) {
+            logger.info("Typed wrong current password!")
+            return false
+          }
+          else {
+            removeOldPwAndAddNewPW(agent, currentPassword, newPW)
+            return true
+          }
+        }
 
-				private def removeOldPwAndAddNewPW(agent: NonLiteral, currentPassword: String, newPW: String): Unit = {
-					var newPWTriple: Triple = new TripleImpl(agent, PERMISSION.passwordSha1, new PlainLiteralImpl(getEncodedPW(newPW)))
-					if (currentPassword != null) {
-						var oldPWTriple: Triple = new TripleImpl(agent, PERMISSION.passwordSha1, new PlainLiteralImpl(currentPassword))
-						systemGraph.remove(oldPWTriple)
-						logger.debug("removed old password from systemgraph")
-					}
-					systemGraph.add(newPWTriple)
-					logger.debug("user " + id + " changed password")
-				}
+        private def removeOldPwAndAddNewPW(agent: NonLiteral, currentPassword: String, newPW: String): Unit = {
+          var newPWTriple: Triple = new TripleImpl(agent, PERMISSION.passwordSha1, new PlainLiteralImpl(getEncodedPW(newPW)))
+          if (currentPassword != null) {
+            var oldPWTriple: Triple = new TripleImpl(agent, PERMISSION.passwordSha1, new PlainLiteralImpl(currentPassword))
+            systemGraph.remove(oldPWTriple)
+            logger.debug("removed old password from systemgraph")
+          }
+          systemGraph.add(newPWTriple)
+          logger.debug("user " + id + " changed password")
+        }
 
-				private def getEncodedPW(password: String): String = {
-					if (password == null) {
-						return null
-					}
-					try {
-						return bytes2HexString(MessageDigest.getInstance("SHA1").digest(password.getBytes("UTF-8")))
-					}
-					catch {
-						case e: NoSuchAlgorithmException => {
-							throw new RuntimeException(e)
-						}
-						case e: UnsupportedEncodingException => {
-							throw new RuntimeException(e)
-						}
-					}
-				}
+        private def getEncodedPW(password: String): String = {
+          if (password == null) {
+            return null
+          }
+          try {
+            return bytes2HexString(MessageDigest.getInstance("SHA1").digest(password.getBytes("UTF-8")))
+          }
+          catch {
+            case e: NoSuchAlgorithmException => {
+              throw new RuntimeException(e)
+            }
+            case e: UnsupportedEncodingException => {
+              throw new RuntimeException(e)
+            }
+          }
+        }
 
-				private def bytes2HexString(bytes: Array[Byte]): String = {
-					val HEXDIGITS: Array[Char] = "0123456789abcdef".toCharArray
-					val result = new Array[Char](bytes.length << 1)
-					var j: Int = 0
-					for (i <- 0 to bytes.length - 1) {
-						result(j) = HEXDIGITS(bytes(i) >> 4 & 0xF)
-						result(j + 1) = HEXDIGITS(bytes(i) & 0xF)
-						j += 2
-					}
-					return new String(result)
-				}
-			})
-		}
-		else {
-			logger.info("Changing password failed!")
-			changedPassword = false
-		}
-		if (changedPassword) {
-			return RedirectUtil.createSeeOtherResponse("../control-panel", uriInfo)
-		}
-		else {
-			return RedirectUtil.createSeeOtherResponse("../control-panel?changedPassword=false", uriInfo)
-		}
-	}
+        private def bytes2HexString(bytes: Array[Byte]): String = {
+          val HEXDIGITS: Array[Char] = "0123456789abcdef".toCharArray
+          val result = new Array[Char](bytes.length << 1)
+          var j: Int = 0
+          for (i <- 0 to bytes.length - 1) {
+            result(j) = HEXDIGITS(bytes(i) >> 4 & 0xF)
+            result(j + 1) = HEXDIGITS(bytes(i) & 0xF)
+            j += 2
+          }
+          return new String(result)
+        }
+      })
+    }
+    else {
+      logger.info("Changing password failed!")
+      changedPassword = false
+    }
+    if (changedPassword) {
+      return RedirectUtil.createSeeOtherResponse("../control-panel", uriInfo)
+    }
+    else {
+      return RedirectUtil.createSeeOtherResponse("../control-panel?changedPassword=false", uriInfo)
+    }
+  }
 
-	/**
-	 * checks if the typed strings are valid
-	 */
-	private def checkPWStrings(oldPW: String, newPW: String): Boolean = {
-		if (newPW.length == 0) {
-			return false
-		}
-		return true
-	}
+  /**
+   * checks if the typed strings are valid
+   */
+  private def checkPWStrings(oldPW: String, newPW: String): Boolean = {
+    if (newPW.length == 0) {
+      return false
+    }
+    return true
+  }
 
-	/**
-	 * The activate method is called when SCR activates the component configuration.
-	 *
-	 * @param componentContext
-	 */
-	protected def activate(componentContext: ComponentContext): Unit = {
-		this.componentContext = componentContext
-	}
+  /**
+   * The activate method is called when SCR activates the component configuration.
+   *
+   * @param componentContext
+   */
+  protected def activate(componentContext: ComponentContext): Unit = {
+    this.componentContext = componentContext
+  }
 
-	protected def bindConfigurationAdmin(configAdmin: ConfigurationAdmin): Unit = {
-		logger.debug("Binding configuration admin")
-		this.configAdmin = configAdmin
-	}
+  protected def bindConfigurationAdmin(configAdmin: ConfigurationAdmin): Unit = {
+    logger.debug("Binding configuration admin")
+    this.configAdmin = configAdmin
+  }
 
-	protected def unbindConfigurationAdmin(configAdmin: ConfigurationAdmin): Unit = {
-		logger.debug("Unbinding configuration admin")
-		this.configAdmin = null
-	}
+  protected def unbindConfigurationAdmin(configAdmin: ConfigurationAdmin): Unit = {
+    logger.debug("Unbinding configuration admin")
+    this.configAdmin = null
+  }
 
-	protected def bindSystemGraph(mgraph: MGraph): Unit = {
-		systemGraph = mgraph
-	}
+  protected def bindSystemGraph(mgraph: MGraph): Unit = {
+    systemGraph = mgraph
+  }
 
-	protected def unbindSystemGraph(mgraph: MGraph): Unit = {
-		if (systemGraph == mgraph) {
-			systemGraph = null
-		}
-	}
+  protected def unbindSystemGraph(mgraph: MGraph): Unit = {
+    if (systemGraph == mgraph) {
+      systemGraph = null
+    }
+  }
 
-	protected def bindCgProvider(contentgraphprovider: ContentGraphProvider): Unit = {
-		cgProvider = contentgraphprovider
-	}
+  protected def bindCgProvider(contentgraphprovider: ContentGraphProvider): Unit = {
+    cgProvider = contentgraphprovider
+  }
 
-	protected def unbindCgProvider(contentgraphprovider: ContentGraphProvider): Unit = {
-		if (cgProvider == contentgraphprovider) {
-			cgProvider = null
-		}
-	}
+  protected def unbindCgProvider(contentgraphprovider: ContentGraphProvider): Unit = {
+    if (cgProvider == contentgraphprovider) {
+      cgProvider = null
+    }
+  }
 
-	private var componentContext: ComponentContext = null
-	private var systemGraph: MGraph = null
-	private var cgProvider: ContentGraphProvider = null
-	private var configAdmin: ConfigurationAdmin = null
+  private var componentContext: ComponentContext = null
+  private var systemGraph: MGraph = null
+  private var cgProvider: ContentGraphProvider = null
+  private var configAdmin: ConfigurationAdmin = null
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/clerezza/blob/35448624/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/html/ContactConfirmRenderlet.scala
----------------------------------------------------------------------
diff --git a/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/html/ContactConfirmRenderlet.scala b/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/html/ContactConfirmRenderlet.scala
index 23e7dc3..bb306aa 100644
--- a/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/html/ContactConfirmRenderlet.scala
+++ b/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/html/ContactConfirmRenderlet.scala
@@ -32,78 +32,78 @@ import org.apache.clerezza.platform.typerendering.scala._
  * Metadata class for the person panel
  */
 class ContactConfirmRenderlet extends SRenderlet {
-	def getRdfType() = CONTROLPANEL.ContactConfirmPage
+  def getRdfType() = CONTROLPANEL.ContactConfirmPage
 
 
-	override def renderedPage(arguments: XmlResult.Arguments) = new XmlPerson(arguments)
+  override def renderedPage(arguments: XmlResult.Arguments) = new XmlPerson(arguments)
 
-	/**
-	 * Content class for the Person Panel
-	 */
-	class XmlPerson(args: XmlResult.Arguments) extends XmlResult(args) {
+  /**
+   * 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
-		//
+    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>
-		}
+    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>
+    }
 
-	}
+  }
 }