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:23 UTC
[6/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/html/PersonBox.scala
----------------------------------------------------------------------
diff --git a/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/html/PersonBox.scala b/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/html/PersonBox.scala
index ada733a..2b9913c 100644
--- a/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/html/PersonBox.scala
+++ b/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/html/PersonBox.scala
@@ -32,32 +32,32 @@ 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>
- }
-
- }
+ 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>
+ }
+
+ }
}
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/ProfilePanel.scala
----------------------------------------------------------------------
diff --git a/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/html/ProfilePanel.scala b/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/html/ProfilePanel.scala
index d0d095e..7d65dff 100644
--- a/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/html/ProfilePanel.scala
+++ b/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/html/ProfilePanel.scala
@@ -33,263 +33,263 @@ import org.apache.clerezza.rdf.ontologies.{RDFS, DC, FOAF}
class ProfilePanel extends SRenderlet {
- override def getRdfType() = CONTROLPANEL.ProfilePage
-
- override def renderedPage(arguments: XmlResult.Arguments) = new ProfilePanelXHTML(arguments)
-
- class ProfilePanelXHTML(arguments: XmlResult.Arguments) extends XmlResult(arguments ) {
-
- //set header properties
-
- resultDocModifier.addStyleSheet("/account-control-panel/style/profile.css");
- resultDocModifier.addScriptReference("/account-control-panel/scripts/profile.js");
- resultDocModifier.addScriptReference("/account-control-panel/scripts/IEKeygen.js");
- resultDocModifier.setTitle("Account Control Panel");
- resultDocModifier.addNodes2Elem("tx-module", <h1>Account Control Panel</h1>);
- resultDocModifier.addNodes2Elem("tx-module-tabs-ol", <li class="tx-active"><a href="#">Profile</a></li>);
- resultDocModifier.addNodes2Elem("tx-module-tabs-ol", <li><a href="control-panel">Settings</a></li>);
-
- //constants and variables
-
- lazy val agent: RichGraphNode = res / FOAF.primaryTopic
-
-
- // the content itself
- // clearly in this case there is so much more in the the methods, that one could hesitate to call this an ssp
-
- override def content = {
- <div id="tx-content">
- <h2>Personal Profile</h2>{agent ! match {
- case _: BNode => createWebId()
- case _: UriRef => existingWebId()
- }}
- </div>
-
- }
-
- //methods used to create content
-
- def cp(s: Any) = new UriRef("http://clerezza.org/2009/03/controlpanel#" + s)
- def platform(s: Any) = new UriRef("http://clerezza.org/2009/08/platform#" + s)
-
-
- def createWebId() = {
- <h3>Associate Profile to WebID</h3>
- <div id="newOrExistingSelection">
- <p>Your profile is not currently associated to a WebID. A WebID allows you
- to link your friends as well as to log-in to many sites (supporting foaf+ssl
- or open-id).
- </p>
- <p>You may either create a new WebID or associate your account to an
- existing WebID. Only creating a WebID here will allow you to manage your
- profile here.
- </p>
- <form action="#" id="associateSelection">
- <button type="button" id="newWebIdButton">Create a new Web-Id</button>
- <button type="button" id="existingWebIdButton">I already have a Web-ID and want to use it</button>
- </form>
- </div>
- <div id="createNewWebId">
- <p>You have chosen to create a new Web-Id.</p>
- <p>The Web-ID will be created as follows:
- <br/>
- <ol>
- <li>Web-Id:
- {var webId = res / cp("suggestedPPDUri") *;
- webId += "#me";
- webId}
- </li>
- <li>Personal-Profile Document: {res/cp("suggestedPPDUri")*}</li>
- </ol>
- </p>
- <form method="post" action="profile/create-new-web-id">
- <input value="Create it!" type="submit"/>
- </form>
- </div>
- <div id="setExistingWebId">
- <p>Please enter your Web-Id, if your Web-Id supports Foaf+SSL you will
- be able to use it to log in to this site.</p>
- <form method="post" action="profile/set-existing-webid">
- <label for="webid">WebID</label> <input type="text" name="webid" size="80" title="Web-ID"/>
- <br/>
- <input value="Associate Profile to Web-Id" type="submit"/>
- <p/>
- </form>
- </div>
-
- }
-
- def existingWebId() = {
- if ((res / cp("isLocalProfile")).as[Boolean]) {
- existingLocalWebId()
- } else {
- roamingUser()
- }
- }
-
-
- def existingLocalWebId() = {
- <h3>Manage your profile</h3>
- <p>Here you can change your public profile.</p>
-
- <form method="post" action="profile/modify">
- <input type="hidden" name="webId" value={agent *}/>
- <table>
- <tr><td class="formlabel">Name:</td>
- <td><input type="text" name="name" value={agent / FOAF.name *}/></td>
- </tr>
- <tr><td class="formlabel multiline">Description:</td>
- <td><textarea name="description" rows="3" cols="80">{agent / DC.description *}</textarea></td>
- </tr>
- <tr><td class="formlabel"><input value="Modify" type="submit"/></td><td/></tr>
- </table>
-
- <p/>
- </form>
-
- <h3>Contacts</h3>
-
- <table>{ var i =0
- val friends = for (friend <- agent/FOAF.knows) yield {
- <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>
- <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>
-
- <script type="text/javascript"> <![CDATA[$(document).ready( function() { configurePage(); } ); ]]> </script>
-
- <div id="iehelptext" style="display: none;">
- <p>Using Internet Explorer under Windows Vista or above or Windows
- Server 2008, you need to configure the following for this to work:</p>
- <ul>
- <li>Add this site to the <i>Trusted Sites</i> list: in Internet
- Options -> Security -> Trusted Sites -> Sites -> Add ...</li>
- <li>You may need to configure the trust level (in this tab), using
- <i>Custom Level...</i>: enable <i>Initialize and script ActiveX
- controls not marked as safe for scripting</i>.</li>
- <li>If you are using Windows Vista without SP1 or above, you will
- probably need to install <a href="cacert.crt">this certificate</a> as a
- Trusted Root Certification Authority Certificate for your own
- certificate installation to succeed. You should probably remove that
- trusted root CA certificate afterwards.</li>
- </ul>
- </div>
- <form id="keygenform" method="post" action="profile/keygen">
- <input name="webId" id="webId" type="hidden" value={agent*} />
- <table>
- <colgroup><col width="1*"/><col/></colgroup>
- <tr>
- <td class="formlabel">Certificate Name:</td>
- <td>
- <input alt="create a certificate name that will help you distinguish it from others you may have" name="cn"
- size="35" id="cn" type="text" value={ ((agent/FOAF.name*)+"@clerezza")}/>
- </td>
- </tr>
- <tr>
- <td class="formlabel">Key strength:</td>
- <td id="keystrenghtd">
- <keygen id="spkac" name="spkac" challenge="TheChallenge1"/>
- </td>
- </tr>
- <tr>
- <td class="formlabel">Valid for:</td>
- <td>
- <input type="text" name="days" value="365" size="4"/>
- days <input type="text" name="hours" value="0.0" size="4"/> hours</td>
- </tr>
- <tr>
- <td class="formlabel">Comment:</td>
- <td><input type="text" name="comment" value="" size="80"/></td>
- </tr>
- <tr><td class="formlabel"><input id="keygensubmit" type="submit" value="create certificate" /></td><td/></tr>
- </table>
- </form>
- <h3>Existing Certificates</h3>
- <form method="post" action="profile/deletekey">
- <table>
- <tr><th>Delete</th><th>Certificate Details</th></tr>
- <input name="webId" id="webId" type="hidden" value={agent*} />
- <tbody>{
- for (key <- agent/-CERT.identity )
- yield { val modulus = (key/RSA.modulus).as[BigInteger]
- if (modulus == null) <span/> //todo: broken public key, should delete it
- else <tr><td><input type="checkbox" name="keyhash" value={modulus.hashCode().toString()}/></td>
- <td><table>
- <tr><td class="propvalue">Created:</td><td>{beautifyDate(key/DC.date )}</td></tr>
- <tr><td class="propvalue">Comment:</td><td>{ key/RDFS.comment* }</td></tr>
- <tr><td class="propvalue multiline">Modulus:</td><td><code>{ beautifyHex(key/RSA.modulus) }</code></td></tr>
- <tr><td class="propvalue">Exponent:</td><td><code>{ beautifyInt(key/RSA.public_exponent) }</code></td></tr>
- </table>
- </td>
- </tr>}
- }</tbody>
- </table>
- <input type="submit" value="Disable Keys"/>
- </form>
- <p></p>
-
- }
-
- def roamingUser() = {
- <h3>Using remote profile</h3>
- <p>
- {agent / FOAF.nick *}, you have accessed this site using your WebID
- {"<" + (agent *) + ">"}
- which has not been
- created on this site.To edit your profile you should visit the site issuing the
- profile.</p>
- }
-
-
-
-
- def beautifyDate(dtIt: CollectedIter[RichGraphNode]) {
- if (0 == dtIt.size) return "_"
- DateFormat.getDateTimeInstance(DateFormat.LONG,DateFormat.FULL).format(dtIt.as[Date])
- }
-
-
- def beautifyHex(dtIt: CollectedIter[RichGraphNode]): String = {
- if (0 == dtIt.size) return "warning! missing. Key invalid"
- //this is a problem, it should always be here or it is invalid, and key should be removed
- val bigint: BigInteger = dtIt.as[BigInteger]
- val bstr = bigint.toString(16).toUpperCase;
- val sbuf = new StringBuffer(bstr.size + (bstr.size/2)+10)
- var cnt = 0
- for (c <- bstr.toCharArray) {
- if ((cnt % 2) == 0) sbuf.append(' ')
- sbuf.append(c)
- cnt += 1
- }
- sbuf.toString
- }
-
-
-
- def beautifyInt(dtIt: CollectedIter[RichGraphNode] ) :String = {
- if (0 == dtIt.size) return "warning! missing. Key invalid"
- else return dtIt.as[BigInteger].toString
- }
- }
+ override def getRdfType() = CONTROLPANEL.ProfilePage
+
+ override def renderedPage(arguments: XmlResult.Arguments) = new ProfilePanelXHTML(arguments)
+
+ class ProfilePanelXHTML(arguments: XmlResult.Arguments) extends XmlResult(arguments ) {
+
+ //set header properties
+
+ resultDocModifier.addStyleSheet("/account-control-panel/style/profile.css");
+ resultDocModifier.addScriptReference("/account-control-panel/scripts/profile.js");
+ resultDocModifier.addScriptReference("/account-control-panel/scripts/IEKeygen.js");
+ resultDocModifier.setTitle("Account Control Panel");
+ resultDocModifier.addNodes2Elem("tx-module", <h1>Account Control Panel</h1>);
+ resultDocModifier.addNodes2Elem("tx-module-tabs-ol", <li class="tx-active"><a href="#">Profile</a></li>);
+ resultDocModifier.addNodes2Elem("tx-module-tabs-ol", <li><a href="control-panel">Settings</a></li>);
+
+ //constants and variables
+
+ lazy val agent: RichGraphNode = res / FOAF.primaryTopic
+
+
+ // the content itself
+ // clearly in this case there is so much more in the the methods, that one could hesitate to call this an ssp
+
+ override def content = {
+ <div id="tx-content">
+ <h2>Personal Profile</h2>{agent ! match {
+ case _: BNode => createWebId()
+ case _: UriRef => existingWebId()
+ }}
+ </div>
+
+ }
+
+ //methods used to create content
+
+ def cp(s: Any) = new UriRef("http://clerezza.org/2009/03/controlpanel#" + s)
+ def platform(s: Any) = new UriRef("http://clerezza.org/2009/08/platform#" + s)
+
+
+ def createWebId() = {
+ <h3>Associate Profile to WebID</h3>
+ <div id="newOrExistingSelection">
+ <p>Your profile is not currently associated to a WebID. A WebID allows you
+ to link your friends as well as to log-in to many sites (supporting foaf+ssl
+ or open-id).
+ </p>
+ <p>You may either create a new WebID or associate your account to an
+ existing WebID. Only creating a WebID here will allow you to manage your
+ profile here.
+ </p>
+ <form action="#" id="associateSelection">
+ <button type="button" id="newWebIdButton">Create a new Web-Id</button>
+ <button type="button" id="existingWebIdButton">I already have a Web-ID and want to use it</button>
+ </form>
+ </div>
+ <div id="createNewWebId">
+ <p>You have chosen to create a new Web-Id.</p>
+ <p>The Web-ID will be created as follows:
+ <br/>
+ <ol>
+ <li>Web-Id:
+ {var webId = res / cp("suggestedPPDUri") *;
+ webId += "#me";
+ webId}
+ </li>
+ <li>Personal-Profile Document: {res/cp("suggestedPPDUri")*}</li>
+ </ol>
+ </p>
+ <form method="post" action="profile/create-new-web-id">
+ <input value="Create it!" type="submit"/>
+ </form>
+ </div>
+ <div id="setExistingWebId">
+ <p>Please enter your Web-Id, if your Web-Id supports Foaf+SSL you will
+ be able to use it to log in to this site.</p>
+ <form method="post" action="profile/set-existing-webid">
+ <label for="webid">WebID</label> <input type="text" name="webid" size="80" title="Web-ID"/>
+ <br/>
+ <input value="Associate Profile to Web-Id" type="submit"/>
+ <p/>
+ </form>
+ </div>
+
+ }
+
+ def existingWebId() = {
+ if ((res / cp("isLocalProfile")).as[Boolean]) {
+ existingLocalWebId()
+ } else {
+ roamingUser()
+ }
+ }
+
+
+ def existingLocalWebId() = {
+ <h3>Manage your profile</h3>
+ <p>Here you can change your public profile.</p>
+
+ <form method="post" action="profile/modify">
+ <input type="hidden" name="webId" value={agent *}/>
+ <table>
+ <tr><td class="formlabel">Name:</td>
+ <td><input type="text" name="name" value={agent / FOAF.name *}/></td>
+ </tr>
+ <tr><td class="formlabel multiline">Description:</td>
+ <td><textarea name="description" rows="3" cols="80">{agent / DC.description *}</textarea></td>
+ </tr>
+ <tr><td class="formlabel"><input value="Modify" type="submit"/></td><td/></tr>
+ </table>
+
+ <p/>
+ </form>
+
+ <h3>Contacts</h3>
+
+ <table>{ var i =0
+ val friends = for (friend <- agent/FOAF.knows) yield {
+ <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>
+ <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>
+
+ <script type="text/javascript"> <![CDATA[$(document).ready( function() { configurePage(); } ); ]]> </script>
+
+ <div id="iehelptext" style="display: none;">
+ <p>Using Internet Explorer under Windows Vista or above or Windows
+ Server 2008, you need to configure the following for this to work:</p>
+ <ul>
+ <li>Add this site to the <i>Trusted Sites</i> list: in Internet
+ Options -> Security -> Trusted Sites -> Sites -> Add ...</li>
+ <li>You may need to configure the trust level (in this tab), using
+ <i>Custom Level...</i>: enable <i>Initialize and script ActiveX
+ controls not marked as safe for scripting</i>.</li>
+ <li>If you are using Windows Vista without SP1 or above, you will
+ probably need to install <a href="cacert.crt">this certificate</a> as a
+ Trusted Root Certification Authority Certificate for your own
+ certificate installation to succeed. You should probably remove that
+ trusted root CA certificate afterwards.</li>
+ </ul>
+ </div>
+ <form id="keygenform" method="post" action="profile/keygen">
+ <input name="webId" id="webId" type="hidden" value={agent*} />
+ <table>
+ <colgroup><col width="1*"/><col/></colgroup>
+ <tr>
+ <td class="formlabel">Certificate Name:</td>
+ <td>
+ <input alt="create a certificate name that will help you distinguish it from others you may have" name="cn"
+ size="35" id="cn" type="text" value={ ((agent/FOAF.name*)+"@clerezza")}/>
+ </td>
+ </tr>
+ <tr>
+ <td class="formlabel">Key strength:</td>
+ <td id="keystrenghtd">
+ <keygen id="spkac" name="spkac" challenge="TheChallenge1"/>
+ </td>
+ </tr>
+ <tr>
+ <td class="formlabel">Valid for:</td>
+ <td>
+ <input type="text" name="days" value="365" size="4"/>
+ days <input type="text" name="hours" value="0.0" size="4"/> hours</td>
+ </tr>
+ <tr>
+ <td class="formlabel">Comment:</td>
+ <td><input type="text" name="comment" value="" size="80"/></td>
+ </tr>
+ <tr><td class="formlabel"><input id="keygensubmit" type="submit" value="create certificate" /></td><td/></tr>
+ </table>
+ </form>
+ <h3>Existing Certificates</h3>
+ <form method="post" action="profile/deletekey">
+ <table>
+ <tr><th>Delete</th><th>Certificate Details</th></tr>
+ <input name="webId" id="webId" type="hidden" value={agent*} />
+ <tbody>{
+ for (key <- agent/-CERT.identity )
+ yield { val modulus = (key/RSA.modulus).as[BigInteger]
+ if (modulus == null) <span/> //todo: broken public key, should delete it
+ else <tr><td><input type="checkbox" name="keyhash" value={modulus.hashCode().toString()}/></td>
+ <td><table>
+ <tr><td class="propvalue">Created:</td><td>{beautifyDate(key/DC.date )}</td></tr>
+ <tr><td class="propvalue">Comment:</td><td>{ key/RDFS.comment* }</td></tr>
+ <tr><td class="propvalue multiline">Modulus:</td><td><code>{ beautifyHex(key/RSA.modulus) }</code></td></tr>
+ <tr><td class="propvalue">Exponent:</td><td><code>{ beautifyInt(key/RSA.public_exponent) }</code></td></tr>
+ </table>
+ </td>
+ </tr>}
+ }</tbody>
+ </table>
+ <input type="submit" value="Disable Keys"/>
+ </form>
+ <p></p>
+
+ }
+
+ def roamingUser() = {
+ <h3>Using remote profile</h3>
+ <p>
+ {agent / FOAF.nick *}, you have accessed this site using your WebID
+ {"<" + (agent *) + ">"}
+ which has not been
+ created on this site.To edit your profile you should visit the site issuing the
+ profile.</p>
+ }
+
+
+
+
+ def beautifyDate(dtIt: CollectedIter[RichGraphNode]) {
+ if (0 == dtIt.size) return "_"
+ DateFormat.getDateTimeInstance(DateFormat.LONG,DateFormat.FULL).format(dtIt.as[Date])
+ }
+
+
+ def beautifyHex(dtIt: CollectedIter[RichGraphNode]): String = {
+ if (0 == dtIt.size) return "warning! missing. Key invalid"
+ //this is a problem, it should always be here or it is invalid, and key should be removed
+ val bigint: BigInteger = dtIt.as[BigInteger]
+ val bstr = bigint.toString(16).toUpperCase;
+ val sbuf = new StringBuffer(bstr.size + (bstr.size/2)+10)
+ var cnt = 0
+ for (c <- bstr.toCharArray) {
+ if ((cnt % 2) == 0) sbuf.append(' ')
+ sbuf.append(c)
+ cnt += 1
+ }
+ sbuf.toString
+ }
+
+
+
+ def beautifyInt(dtIt: CollectedIter[RichGraphNode] ) :String = {
+ if (0 == dtIt.size) return "warning! missing. Key invalid"
+ else return dtIt.as[BigInteger].toString
+ }
+ }
}
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/RenderingUtility.scala
----------------------------------------------------------------------
diff --git a/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/html/RenderingUtility.scala b/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/html/RenderingUtility.scala
index 7de03f0..735aee0 100644
--- a/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/html/RenderingUtility.scala
+++ b/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/html/RenderingUtility.scala
@@ -35,60 +35,60 @@ import rdf.scala.utils.Preamble._
* Some utility methods for the renderlets
*/
object RenderingUtility {
- val emptyText = new Text("")
+ 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 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]()
- }
+ 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>
- }
+ /**
+ * 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")
+ 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*
+ /**
+ * 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*
- }
+ }
}
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/SettingsPanel.scala
----------------------------------------------------------------------
diff --git a/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/html/SettingsPanel.scala b/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/html/SettingsPanel.scala
index afa4ffa..a2a58e6 100644
--- a/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/html/SettingsPanel.scala
+++ b/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/html/SettingsPanel.scala
@@ -26,10 +26,10 @@ import org.apache.clerezza.platform.typerendering.scala._
class SettingsPanel extends SRenderlet {
- val getRdfType = CONTROLPANEL.SettingsPage
+ val getRdfType = CONTROLPANEL.SettingsPage
- override def renderedPage(arguments: XmlResult.Arguments) = new XmlResult(arguments ) {
- override def content = {
+ override def renderedPage(arguments: XmlResult.Arguments) = new XmlResult(arguments ) {
+ override def content = {
import org.apache.clerezza.rdf.core.UriRef
import scala.xml.NodeBuffer
import scala.collection.mutable.ListBuffer
@@ -43,121 +43,121 @@ resultDocModifier.addNodes2Elem("tx-module-tabs-ol", <li><a href="profile">Profi
resultDocModifier.addNodes2Elem("tx-module-tabs-ol", <li class="tx-active"><a href="#">Settings</a></li>);
if ((res/cp("userBundlePermission")*) == "true") {
- nodeBuff +=(<h2>Bundle Control Panel</h2>
- <h3>Install Bundle</h3>
-
- <form method="post" action="control-panel/install-bundle" enctype="multipart/form-data">
- <input type="file" class="FieldText" name="bundle" size="30" title="bundle path"/><br/><br/>
- <input style="width: 5em;" value="Install" type="submit"/><p />
- </form>
- <br/><br/>
- <h3>User Bundles</h3>
- <table border="1">
- <tbody>
- <tr>
- <th>Location</th>
- <th>Status</th>
- <th colspan="4">Action</th>
- </tr>
-
- {for (renderlet <- (res/-osgi("owner")).sort((a,b) => ((a*)<(b*)))) yield
- <tr>
- <td>{renderlet*}</td>
- <td>{renderlet/osgi("status")* match {
- case "2" => "Installed"
- case "4" => "Resolved"
- case "8" => "Starting"
- case "16" => "Stopping"
- case "32" => "Active"
- }}
- </td>
- {if (((renderlet/osgi("bundle_id")).length) > 0)
- <td>
- <form method="post" action="control-panel/start-bundle">
- <input name="bundleId" value={(renderlet/osgi("bundle_id"))*} type="hidden"/>
- <input value="start" type="submit"/>
- </form>
- </td>
- <td>
- <form method="post" action="control-panel/stop-bundle">
- <input name="bundleId" value={(renderlet/osgi("bundle_id"))*} type="hidden"/>
- <input value="stop" type="submit"/>
- </form>
- </td>
- <td>
- <form method="post" action="control-panel/uninstall-bundle">
- <input name="bundleId" value={(renderlet/osgi("bundle_id"))*} type="hidden"/>
- <input value="uninstall" type="submit"/>
- </form>
- </td>
- else
- <td colspan="3">Not registered as bundle</td>}
- </tr>
- }
- </tbody>
- </table>
- <br/>)
+ nodeBuff +=(<h2>Bundle Control Panel</h2>
+ <h3>Install Bundle</h3>
+
+ <form method="post" action="control-panel/install-bundle" enctype="multipart/form-data">
+ <input type="file" class="FieldText" name="bundle" size="30" title="bundle path"/><br/><br/>
+ <input style="width: 5em;" value="Install" type="submit"/><p />
+ </form>
+ <br/><br/>
+ <h3>User Bundles</h3>
+ <table border="1">
+ <tbody>
+ <tr>
+ <th>Location</th>
+ <th>Status</th>
+ <th colspan="4">Action</th>
+ </tr>
+
+ {for (renderlet <- (res/-osgi("owner")).sort((a,b) => ((a*)<(b*)))) yield
+ <tr>
+ <td>{renderlet*}</td>
+ <td>{renderlet/osgi("status")* match {
+ case "2" => "Installed"
+ case "4" => "Resolved"
+ case "8" => "Starting"
+ case "16" => "Stopping"
+ case "32" => "Active"
+ }}
+ </td>
+ {if (((renderlet/osgi("bundle_id")).length) > 0)
+ <td>
+ <form method="post" action="control-panel/start-bundle">
+ <input name="bundleId" value={(renderlet/osgi("bundle_id"))*} type="hidden"/>
+ <input value="start" type="submit"/>
+ </form>
+ </td>
+ <td>
+ <form method="post" action="control-panel/stop-bundle">
+ <input name="bundleId" value={(renderlet/osgi("bundle_id"))*} type="hidden"/>
+ <input value="stop" type="submit"/>
+ </form>
+ </td>
+ <td>
+ <form method="post" action="control-panel/uninstall-bundle">
+ <input name="bundleId" value={(renderlet/osgi("bundle_id"))*} type="hidden"/>
+ <input value="uninstall" type="submit"/>
+ </form>
+ </td>
+ else
+ <td colspan="3">Not registered as bundle</td>}
+ </tr>
+ }
+ </tbody>
+ </table>
+ <br/>)
}
if((res/cp("changePasswordPermission")*) == "true") {
- nodeBuff +=(<h2>Change Password</h2>
-
-
- <form action="control-panel/change-password" method="post">
- <fieldset>
- <ol style="display: block;">
- <li class="tx-line" style="background-image: none;">
- <label>Current Password:</label>
- <span class="tx-item">
- <input type="password" name="oldPW"/>
- </span>
- </li>
- <li class="tx-line" style="background-image: none;">
- <label>New Password:</label>
- <span class="tx-item">
- <input type="password" name="newPW"/>
- </span>
- </li>
- <li class="tx-line" style="background-image: none;">
- <label>Confirm new Password:</label>
- <span class="tx-item">
- <input type="password" name="confirmNewPW"/>
- </span>
- </li>
- <br />
- <input style="width: 5em;" type="submit" name="submit" value="Submit"/>
- </ol>
- <br/>
- </fieldset>
- </form>)
+ nodeBuff +=(<h2>Change Password</h2>
+
+
+ <form action="control-panel/change-password" method="post">
+ <fieldset>
+ <ol style="display: block;">
+ <li class="tx-line" style="background-image: none;">
+ <label>Current Password:</label>
+ <span class="tx-item">
+ <input type="password" name="oldPW"/>
+ </span>
+ </li>
+ <li class="tx-line" style="background-image: none;">
+ <label>New Password:</label>
+ <span class="tx-item">
+ <input type="password" name="newPW"/>
+ </span>
+ </li>
+ <li class="tx-line" style="background-image: none;">
+ <label>Confirm new Password:</label>
+ <span class="tx-item">
+ <input type="password" name="confirmNewPW"/>
+ </span>
+ </li>
+ <br />
+ <input style="width: 5em;" type="submit" name="submit" value="Submit"/>
+ </ol>
+ <br/>
+ </fieldset>
+ </form>)
}
if((res/cp("changedPassword")).length > 0) {
- nodeBuff +=(<br /><span>Password has not changed, either wrong current password or the
- new password and the confirmation didn't match!<br /><br /></span>)
+ nodeBuff +=(<br /><span>Password has not changed, either wrong current password or the
+ new password and the confirmation didn't match!<br /><br /></span>)
}
nodeBuff +=(<h2>Change user's default language</h2>
- <form method="post" action="control-panel/change-language">
- {render(context/platform("instance")/platform("languages"), "naked")}
- <br/><br/>
- <script type="text/javascript">$("#availablelanguages").val({"'" + (context/platform("user")/platform("preferredLangInISOCode")*) + "'"})</script>
- <input style="width: 5em;" type="submit" name="submit" value="Submit"/>
- <br/><br/>
- </form>)
+ <form method="post" action="control-panel/change-language">
+ {render(context/platform("instance")/platform("languages"), "naked")}
+ <br/><br/>
+ <script type="text/javascript">$("#availablelanguages").val({"'" + (context/platform("user")/platform("preferredLangInISOCode")*) + "'"})</script>
+ <input style="width: 5em;" type="submit" name="submit" value="Submit"/>
+ <br/><br/>
+ </form>)
<div id="tx-content">
- <div class="tx-edit" style="margin-left: 0.5em;">
- {if(nodeBuff.isEmpty)
- <span>There are no settings you can configure for this account!</span>
- else
- nodeBuff
- }
- </div>
+ <div class="tx-edit" style="margin-left: 0.5em;">
+ {if(nodeBuff.isEmpty)
+ <span>There are no settings you can configure for this account!</span>
+ else
+ nodeBuff
+ }
+ </div>
</div>
- }
- }
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/35448624/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/permissions.scala
----------------------------------------------------------------------
diff --git a/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/permissions.scala b/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/permissions.scala
index 5684ba6..ae7953f 100644
--- a/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/permissions.scala
+++ b/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/permissions.scala
@@ -32,40 +32,40 @@ import org.slf4j.scala.Logging
*/
abstract
class AbstractPermission(val accountName: String, val actions: String ="")
- extends Permission(accountName) with Logging {
+ extends Permission(accountName) with Logging {
- if (actions != "") {
- throw new RuntimeException(getClass.getName+": actions must be an empty String "+
- "(second argument only in constructor for supporting building from canonical form")
- }
+ if (actions != "") {
+ throw new RuntimeException(getClass.getName+": actions must be an empty String "+
+ "(second argument only in constructor for supporting building from canonical form")
+ }
- def getActions: String = actions
+ def getActions: String = actions
- /**
- * A subclass implies another permission if and only if they are equals
- */
+ /**
+ * A subclass implies another permission if and only if they are equals
+ */
override
- def implies(permission: Permission): Boolean = {
- logger.debug("checking for "+permission+" is implied by "+ this)
- var result: Boolean = equals(permission)
- return result
- }
-
- override
- def equals(other: Any): Boolean =
- other match {
- case that: AbstractPermission =>
- (that eq this ) || ((this.getClass == that.getClass) && accountName == that.accountName )
- case _ => false
- }
-
- /**
- * For the hashCode the class and the accountName is considered
- */
- override
- def hashCode: Int = {
- return getClass.hashCode + (if (accountName != null) accountName.hashCode else 0)
- }
+ def implies(permission: Permission): Boolean = {
+ logger.debug("checking for "+permission+" is implied by "+ this)
+ var result: Boolean = equals(permission)
+ return result
+ }
+
+ override
+ def equals(other: Any): Boolean =
+ other match {
+ case that: AbstractPermission =>
+ (that eq this ) || ((this.getClass == that.getClass) && accountName == that.accountName )
+ case _ => false
+ }
+
+ /**
+ * For the hashCode the class and the accountName is considered
+ */
+ override
+ def hashCode: Int = {
+ return getClass.hashCode + (if (accountName != null) accountName.hashCode else 0)
+ }
}
/**
@@ -74,7 +74,7 @@ class AbstractPermission(val accountName: String, val actions: String ="")
*
*/
class ChangePasswordPermission(accountName: String, actions: String ="")
- extends AbstractPermission(accountName, actions) {
+ extends AbstractPermission(accountName, actions) {
}
@@ -85,7 +85,7 @@ class ChangePasswordPermission(accountName: String, actions: String ="")
*
*/
class AccountControlPanelAppPermission(accountName: String, actions: String ="")
- extends AbstractPermission(accountName) {
+ extends AbstractPermission(accountName) {
}
@@ -97,7 +97,7 @@ class AccountControlPanelAppPermission(accountName: String, actions: String ="")
*
*/
class UserBundlePermission( accountName: String, actions: String ="")
- extends AbstractPermission(accountName) {
+ extends AbstractPermission(accountName) {
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/clerezza/blob/35448624/platform.content.default404/src/main/scala/org/apache/clerezza/platform/content/default404/DefaultPageNotFoundService.scala
----------------------------------------------------------------------
diff --git a/platform.content.default404/src/main/scala/org/apache/clerezza/platform/content/default404/DefaultPageNotFoundService.scala b/platform.content.default404/src/main/scala/org/apache/clerezza/platform/content/default404/DefaultPageNotFoundService.scala
index af7d6fe..a0c4ab6 100644
--- a/platform.content.default404/src/main/scala/org/apache/clerezza/platform/content/default404/DefaultPageNotFoundService.scala
+++ b/platform.content.default404/src/main/scala/org/apache/clerezza/platform/content/default404/DefaultPageNotFoundService.scala
@@ -35,30 +35,30 @@ import javax.ws.rs.core.Response.Status
*/
class DefaultPageNotFoundService extends PageNotFoundService {
- private val notFoundPagePath = "/page-not-found"
+ private val notFoundPagePath = "/page-not-found"
- override def createResponse(uriInfo: UriInfo) = {
- if (uriInfo.getPath == notFoundPagePath) {
- Response.status(Status.NOT_FOUND).build();
- } else {
- val pageNotFoundUrl = new URL(uriInfo.getBaseUri.toURL, notFoundPagePath)
- AccessController.doPrivileged(
- new PrivilegedAction[Option[(String, InputStream)]] {
- def run() = {
- val connection = pageNotFoundUrl.openConnection()
- try {
- Some(connection.getContentType, connection.getInputStream)
- } catch {
- case _: FileNotFoundException => None
- }
- }
- }
- ) match {
- case Some((mediaTypeString, in)) => Response.status(Status.NOT_FOUND).`type`(mediaTypeString).entity(in).build();
- case None => Response.status(Status.NOT_FOUND).build();
- }
+ override def createResponse(uriInfo: UriInfo) = {
+ if (uriInfo.getPath == notFoundPagePath) {
+ Response.status(Status.NOT_FOUND).build();
+ } else {
+ val pageNotFoundUrl = new URL(uriInfo.getBaseUri.toURL, notFoundPagePath)
+ AccessController.doPrivileged(
+ new PrivilegedAction[Option[(String, InputStream)]] {
+ def run() = {
+ val connection = pageNotFoundUrl.openConnection()
+ try {
+ Some(connection.getContentType, connection.getInputStream)
+ } catch {
+ case _: FileNotFoundException => None
+ }
+ }
+ }
+ ) match {
+ case Some((mediaTypeString, in)) => Response.status(Status.NOT_FOUND).`type`(mediaTypeString).entity(in).build();
+ case None => Response.status(Status.NOT_FOUND).build();
+ }
- }
- }
-
+ }
+ }
+
}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/35448624/platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/BundleFsLoader.scala
----------------------------------------------------------------------
diff --git a/platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/BundleFsLoader.scala b/platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/BundleFsLoader.scala
index 5aa7ef8..d9548c1 100644
--- a/platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/BundleFsLoader.scala
+++ b/platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/BundleFsLoader.scala
@@ -55,242 +55,242 @@ import scala.util._
*/
class BundleFsLoader extends BundleListener with Logger with WeightedTcProvider {
- private val RESOURCE_MGRAPH_URI = new UriRef(Constants.URN_LOCAL_INSTANCE+"/web-resources.graph")
- private val cacheGraphPrefix = Constants.URN_LOCAL_INSTANCE+"/web-resources-cache.graph"
- private var currentCacheUri: UriRef = null
-
- private var tcManager: TcManager = null
- private var cgProvider: ContentGraphProvider = null
- private var startLevel: StartLevel = null
- private var pathNodes: List[PathNode] = Nil
- private var bundleList = List[Bundle]()
- private var currentCacheMGraph: MGraph = null
-
- private var frequentUpdateDirectory: Option[PathNode] = None
-
- private val virtualMGraph: MGraph = new AbstractMGraph() {
-
- private def baseGraph: TripleCollection = frequentUpdateDirectory match {
- case Some(p) => new DirectoryOverlay(p, currentCacheMGraph)
- case None => currentCacheMGraph
- }
-
- override def performFilter(s: NonLiteral, p: UriRef,
- o: Resource): java.util.Iterator[Triple] = {
- val baseIter = baseGraph.filter(s,p,o)
- new java.util.Iterator[Triple]() {
- override def next = {
- baseIter.next
- }
- override def hasNext = baseIter.hasNext
- override def remove = throw new UnsupportedOperationException
- }
- }
-
- override def size = baseGraph.size
-
- override def toString = "BundleFsLoader virtual graph"
-
- }
-
- class UpdateThread extends Thread {
-
- private var updateRequested = false;
-
- start()
-
- override def run() {
- try {
- while (!isInterrupted) {
- synchronized {
- while (!updateRequested) wait();
- }
- updateRequested = false
- updateCache()
- }
- } catch {
- case e: InterruptedException => BundleFsLoader.log.debug("Update thread interrupted");
- }
- }
-
- def update() = {
- synchronized {
- updateRequested = true
- notify();
- }
- }
- }
-
- private var updateThread: UpdateThread = null
-
-
- private def deleteCacheGraphs() {
- import collection.JavaConversions._
- for(mGraphUri <- tcManager.listMGraphs) {
- if(mGraphUri.getUnicodeString.startsWith(cacheGraphPrefix)) {
- tcManager.deleteTripleCollection(mGraphUri);
- }
- }
- }
-
- protected def activate(context: ComponentContext) {
- synchronized {
- deleteCacheGraphs()
- for (bundle <- context.getBundleContext().getBundles();
- if bundle.getState == Bundle.ACTIVE) {
- bundleList ::= bundle
- }
- context.getBundleContext().addBundleListener(this);
- updateCache
- tcManager.getTcAccessController.setRequiredReadPermissions(
- RESOURCE_MGRAPH_URI, Collections.singleton(new TcPermission(Constants.CONTENT_GRAPH_URI_STRING, TcPermission.READ)))
- cgProvider.addTemporaryAdditionGraph(RESOURCE_MGRAPH_URI)
- updateThread = new UpdateThread()
- }
- }
- protected def deactivate(context: ComponentContext) {
- synchronized {
- context.getBundleContext().removeBundleListener(this);
- updateThread.interrupt()
- cgProvider.removeTemporaryAdditionGraph(RESOURCE_MGRAPH_URI)
- tcManager.deleteTripleCollection(currentCacheUri);
- }
- }
-
- private def updateCache() = {
- def getVirtualTripleCollection(bundles: Seq[Bundle]): TripleCollection = {
- if (bundles.isEmpty) {
- new SimpleMGraph()
- } else {
- val pathNode = new BundlePathNode(bundles.head, "CLEREZZA-INF/web-resources");
- if (pathNode.isDirectory) {
- BundleFsLoader.log.debug("Creating directory overlay for "+bundles.head)
- new DirectoryOverlay(pathNode, getVirtualTripleCollection(bundles.tail))
- } else {
- getVirtualTripleCollection(bundles.tail)
- }
- }
- }
- synchronized {
- val sortedList = Sorting.stableSort(bundleList, (b:Bundle) => -startLevel.getBundleStartLevel(b))
- val newCacheUri = new UriRef(cacheGraphPrefix+System.currentTimeMillis)
- val newChacheMGraph = tcManager.createMGraph(newCacheUri);
- tcManager.getTcAccessController.setRequiredReadPermissions(
- newCacheUri, Collections.singleton(new TcPermission(Constants.CONTENT_GRAPH_URI_STRING, TcPermission.READ)))
- newChacheMGraph.addAll(getVirtualTripleCollection(sortedList))
- currentCacheMGraph = newChacheMGraph
- val oldCacheUri = currentCacheUri
- currentCacheUri = newCacheUri
- if (oldCacheUri != null) tcManager.deleteTripleCollection(oldCacheUri);
- BundleFsLoader.log.debug("updated web-resource cache")
- }
- }
-
-
-
- override def getWeight() = 30
-
- override def getMGraph(name: UriRef) = {
- if (name.equals(RESOURCE_MGRAPH_URI)) {
- virtualMGraph
- } else {
- throw new NoSuchEntityException(name);
- }
- }
-
- override def getTriples(name: UriRef) = {
- getMGraph(name);
- }
-
- override def getGraph(name: UriRef) = {
- throw new NoSuchEntityException(name);
- }
-
-
- override def listMGraphs(): java.util.Set[UriRef] = {
- java.util.Collections.singleton(RESOURCE_MGRAPH_URI);
- }
-
- override def listGraphs() = {
- new java.util.HashSet[UriRef]();
- }
-
- override def listTripleCollections() = {
- Collections.singleton(RESOURCE_MGRAPH_URI);
- }
-
- override def createMGraph(name: UriRef) = {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- override def createGraph(name: UriRef, triples: TripleCollection): Graph = {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- override def deleteTripleCollection(name: UriRef) {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- override def getNames(graph: Graph) = {
- val result = new java.util.HashSet[UriRef]();
- result;
- }
-
-
- def bundleChanged(event: BundleEvent) {
- val bundle = event.getBundle();
- event.getType() match {
- case BundleEvent.STARTED => {
- bundleList ::= bundle
- updateThread.update()
- }
- case BundleEvent.STOPPED => {
- bundleList = bundleList.filterNot(b => b == bundle)
- updateThread.update()
- }
- case _ => BundleFsLoader.log.debug("only reacting on bundle start and stop")
- }
- }
-
-
- def bindTcManager(tcManager: TcManager) {
- this.tcManager = tcManager;
- }
-
- def unbindTcManager(tcManager: TcManager) {
- this.tcManager = null;
- }
-
- def bindContentGraphProvider(p: ContentGraphProvider) {
- cgProvider = p
- }
-
- def unbindContentGraphProvider(p: ContentGraphProvider) {
- cgProvider = null
- }
-
- def bindStartLevel(startLevel: StartLevel) {
- this.startLevel = startLevel;
- }
-
- def unbindStartLevel(startLevel: StartLevel) {
- this.startLevel = null;
- }
-
- def bindPathNode(pathNode: PathNode) {
- this.pathNodes ::= pathNode;
- frequentUpdateDirectory = Some(new MultiPathNode(pathNodes: _*))
- }
-
- def unbindPathNode(pathNode: PathNode) {
- this.pathNodes = this.pathNodes.filter(_ != pathNode);
- frequentUpdateDirectory = pathNodes match {
- case Nil => None
- case _ => Some(new MultiPathNode(pathNodes: _*))
- }
- }
-
+ private val RESOURCE_MGRAPH_URI = new UriRef(Constants.URN_LOCAL_INSTANCE+"/web-resources.graph")
+ private val cacheGraphPrefix = Constants.URN_LOCAL_INSTANCE+"/web-resources-cache.graph"
+ private var currentCacheUri: UriRef = null
+
+ private var tcManager: TcManager = null
+ private var cgProvider: ContentGraphProvider = null
+ private var startLevel: StartLevel = null
+ private var pathNodes: List[PathNode] = Nil
+ private var bundleList = List[Bundle]()
+ private var currentCacheMGraph: MGraph = null
+
+ private var frequentUpdateDirectory: Option[PathNode] = None
+
+ private val virtualMGraph: MGraph = new AbstractMGraph() {
+
+ private def baseGraph: TripleCollection = frequentUpdateDirectory match {
+ case Some(p) => new DirectoryOverlay(p, currentCacheMGraph)
+ case None => currentCacheMGraph
+ }
+
+ override def performFilter(s: NonLiteral, p: UriRef,
+ o: Resource): java.util.Iterator[Triple] = {
+ val baseIter = baseGraph.filter(s,p,o)
+ new java.util.Iterator[Triple]() {
+ override def next = {
+ baseIter.next
+ }
+ override def hasNext = baseIter.hasNext
+ override def remove = throw new UnsupportedOperationException
+ }
+ }
+
+ override def size = baseGraph.size
+
+ override def toString = "BundleFsLoader virtual graph"
+
+ }
+
+ class UpdateThread extends Thread {
+
+ private var updateRequested = false;
+
+ start()
+
+ override def run() {
+ try {
+ while (!isInterrupted) {
+ synchronized {
+ while (!updateRequested) wait();
+ }
+ updateRequested = false
+ updateCache()
+ }
+ } catch {
+ case e: InterruptedException => BundleFsLoader.log.debug("Update thread interrupted");
+ }
+ }
+
+ def update() = {
+ synchronized {
+ updateRequested = true
+ notify();
+ }
+ }
+ }
+
+ private var updateThread: UpdateThread = null
+
+
+ private def deleteCacheGraphs() {
+ import collection.JavaConversions._
+ for(mGraphUri <- tcManager.listMGraphs) {
+ if(mGraphUri.getUnicodeString.startsWith(cacheGraphPrefix)) {
+ tcManager.deleteTripleCollection(mGraphUri);
+ }
+ }
+ }
+
+ protected def activate(context: ComponentContext) {
+ synchronized {
+ deleteCacheGraphs()
+ for (bundle <- context.getBundleContext().getBundles();
+ if bundle.getState == Bundle.ACTIVE) {
+ bundleList ::= bundle
+ }
+ context.getBundleContext().addBundleListener(this);
+ updateCache
+ tcManager.getTcAccessController.setRequiredReadPermissions(
+ RESOURCE_MGRAPH_URI, Collections.singleton(new TcPermission(Constants.CONTENT_GRAPH_URI_STRING, TcPermission.READ)))
+ cgProvider.addTemporaryAdditionGraph(RESOURCE_MGRAPH_URI)
+ updateThread = new UpdateThread()
+ }
+ }
+ protected def deactivate(context: ComponentContext) {
+ synchronized {
+ context.getBundleContext().removeBundleListener(this);
+ updateThread.interrupt()
+ cgProvider.removeTemporaryAdditionGraph(RESOURCE_MGRAPH_URI)
+ tcManager.deleteTripleCollection(currentCacheUri);
+ }
+ }
+
+ private def updateCache() = {
+ def getVirtualTripleCollection(bundles: Seq[Bundle]): TripleCollection = {
+ if (bundles.isEmpty) {
+ new SimpleMGraph()
+ } else {
+ val pathNode = new BundlePathNode(bundles.head, "CLEREZZA-INF/web-resources");
+ if (pathNode.isDirectory) {
+ BundleFsLoader.log.debug("Creating directory overlay for "+bundles.head)
+ new DirectoryOverlay(pathNode, getVirtualTripleCollection(bundles.tail))
+ } else {
+ getVirtualTripleCollection(bundles.tail)
+ }
+ }
+ }
+ synchronized {
+ val sortedList = Sorting.stableSort(bundleList, (b:Bundle) => -startLevel.getBundleStartLevel(b))
+ val newCacheUri = new UriRef(cacheGraphPrefix+System.currentTimeMillis)
+ val newChacheMGraph = tcManager.createMGraph(newCacheUri);
+ tcManager.getTcAccessController.setRequiredReadPermissions(
+ newCacheUri, Collections.singleton(new TcPermission(Constants.CONTENT_GRAPH_URI_STRING, TcPermission.READ)))
+ newChacheMGraph.addAll(getVirtualTripleCollection(sortedList))
+ currentCacheMGraph = newChacheMGraph
+ val oldCacheUri = currentCacheUri
+ currentCacheUri = newCacheUri
+ if (oldCacheUri != null) tcManager.deleteTripleCollection(oldCacheUri);
+ BundleFsLoader.log.debug("updated web-resource cache")
+ }
+ }
+
+
+
+ override def getWeight() = 30
+
+ override def getMGraph(name: UriRef) = {
+ if (name.equals(RESOURCE_MGRAPH_URI)) {
+ virtualMGraph
+ } else {
+ throw new NoSuchEntityException(name);
+ }
+ }
+
+ override def getTriples(name: UriRef) = {
+ getMGraph(name);
+ }
+
+ override def getGraph(name: UriRef) = {
+ throw new NoSuchEntityException(name);
+ }
+
+
+ override def listMGraphs(): java.util.Set[UriRef] = {
+ java.util.Collections.singleton(RESOURCE_MGRAPH_URI);
+ }
+
+ override def listGraphs() = {
+ new java.util.HashSet[UriRef]();
+ }
+
+ override def listTripleCollections() = {
+ Collections.singleton(RESOURCE_MGRAPH_URI);
+ }
+
+ override def createMGraph(name: UriRef) = {
+ throw new UnsupportedOperationException("Not supported.");
+ }
+
+ override def createGraph(name: UriRef, triples: TripleCollection): Graph = {
+ throw new UnsupportedOperationException("Not supported.");
+ }
+
+ override def deleteTripleCollection(name: UriRef) {
+ throw new UnsupportedOperationException("Not supported.");
+ }
+
+ override def getNames(graph: Graph) = {
+ val result = new java.util.HashSet[UriRef]();
+ result;
+ }
+
+
+ def bundleChanged(event: BundleEvent) {
+ val bundle = event.getBundle();
+ event.getType() match {
+ case BundleEvent.STARTED => {
+ bundleList ::= bundle
+ updateThread.update()
+ }
+ case BundleEvent.STOPPED => {
+ bundleList = bundleList.filterNot(b => b == bundle)
+ updateThread.update()
+ }
+ case _ => BundleFsLoader.log.debug("only reacting on bundle start and stop")
+ }
+ }
+
+
+ def bindTcManager(tcManager: TcManager) {
+ this.tcManager = tcManager;
+ }
+
+ def unbindTcManager(tcManager: TcManager) {
+ this.tcManager = null;
+ }
+
+ def bindContentGraphProvider(p: ContentGraphProvider) {
+ cgProvider = p
+ }
+
+ def unbindContentGraphProvider(p: ContentGraphProvider) {
+ cgProvider = null
+ }
+
+ def bindStartLevel(startLevel: StartLevel) {
+ this.startLevel = startLevel;
+ }
+
+ def unbindStartLevel(startLevel: StartLevel) {
+ this.startLevel = null;
+ }
+
+ def bindPathNode(pathNode: PathNode) {
+ this.pathNodes ::= pathNode;
+ frequentUpdateDirectory = Some(new MultiPathNode(pathNodes: _*))
+ }
+
+ def unbindPathNode(pathNode: PathNode) {
+ this.pathNodes = this.pathNodes.filter(_ != pathNode);
+ frequentUpdateDirectory = pathNodes match {
+ case Nil => None
+ case _ => Some(new MultiPathNode(pathNodes: _*))
+ }
+ }
+
}
object BundleFsLoader {
- private val log = LoggerFactory.getLogger(classOf[BundleFsLoader])
+ private val log = LoggerFactory.getLogger(classOf[BundleFsLoader])
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/clerezza/blob/35448624/platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/DirectoryOverlay.scala
----------------------------------------------------------------------
diff --git a/platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/DirectoryOverlay.scala b/platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/DirectoryOverlay.scala
index 8c78010..40bfb21 100644
--- a/platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/DirectoryOverlay.scala
+++ b/platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/DirectoryOverlay.scala
@@ -31,56 +31,56 @@ import org.wymiwyg.commons.util.dirbrowser.PathNode
import java.util.Iterator
class DirectoryOverlay(pathNode: PathNode, base: TripleCollection)
- extends AbstractTripleCollection {
+ extends AbstractTripleCollection {
-
+
- import collection.JavaConversions._
+ import collection.JavaConversions._
-
+
- override def performFilter(s: NonLiteral, p: UriRef,
- o: Resource): Iterator[Triple] = {
- val addedTriples = new SimpleMGraph()
+ override def performFilter(s: NonLiteral, p: UriRef,
+ o: Resource): Iterator[Triple] = {
+ val addedTriples = new SimpleMGraph()
- PathNode2MGraph.describeInGraph(pathNode, addedTriples)
-
- val subjects = (for (triple <- addedTriples; subject = triple.getSubject) yield {
- subject
- }).toSet
-
- class FilteringIterator(baseIter: Iterator[Triple]) extends Iterator[Triple] {
- var nextElem: Triple = null
- def prepareNext {
- nextElem = if (baseIter.hasNext) baseIter.next else null
- if ((nextElem != null) &&
- (subjects.contains(nextElem.getSubject))) {
- //println("skipping "+nextElem)
- prepareNext
- }
- }
- prepareNext
-
- override def next = {
- val result = nextElem
- prepareNext
- result
- }
- override def hasNext = nextElem != null
- override def remove = throw new UnsupportedOperationException
- }
-
- new IteratorMerger(new FilteringIterator(base.filter(s, p, o)), addedTriples.filter(s,p, o))
- }
+ PathNode2MGraph.describeInGraph(pathNode, addedTriples)
+
+ val subjects = (for (triple <- addedTriples; subject = triple.getSubject) yield {
+ subject
+ }).toSet
+
+ class FilteringIterator(baseIter: Iterator[Triple]) extends Iterator[Triple] {
+ var nextElem: Triple = null
+ def prepareNext {
+ nextElem = if (baseIter.hasNext) baseIter.next else null
+ if ((nextElem != null) &&
+ (subjects.contains(nextElem.getSubject))) {
+ //println("skipping "+nextElem)
+ prepareNext
+ }
+ }
+ prepareNext
+
+ override def next = {
+ val result = nextElem
+ prepareNext
+ result
+ }
+ override def hasNext = nextElem != null
+ override def remove = throw new UnsupportedOperationException
+ }
+
+ new IteratorMerger(new FilteringIterator(base.filter(s, p, o)), addedTriples.filter(s,p, o))
+ }
- /**
- * returns an upper bound of the size (removals in abse are not deducted)
- */
- override def size = {
- val addedTriples = new SimpleMGraph()
+ /**
+ * returns an upper bound of the size (removals in abse are not deducted)
+ */
+ override def size = {
+ val addedTriples = new SimpleMGraph()
- PathNode2MGraph.describeInGraph(pathNode, addedTriples)
+ PathNode2MGraph.describeInGraph(pathNode, addedTriples)
- base.size+addedTriples.size
- }
+ base.size+addedTriples.size
+ }
}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/35448624/platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/Logger.scala
----------------------------------------------------------------------
diff --git a/platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/Logger.scala b/platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/Logger.scala
index bac16ce..684992a 100644
--- a/platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/Logger.scala
+++ b/platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/Logger.scala
@@ -24,7 +24,7 @@ import org.slf4j.LoggerFactory
trait Logger {
- private val slf4jLogger = LoggerFactory.getLogger(this.getClass)
-// val logger: org.slf4j.Logger = new LoggerWrapper(slf4jLogger, this.getClass.getName)
+ private val slf4jLogger = LoggerFactory.getLogger(this.getClass)
+// val logger: org.slf4j.Logger = new LoggerWrapper(slf4jLogger, this.getClass.getName)
}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/35448624/platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/PathNode2MGraph.scala
----------------------------------------------------------------------
diff --git a/platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/PathNode2MGraph.scala b/platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/PathNode2MGraph.scala
index ad9b189..8a62774 100644
--- a/platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/PathNode2MGraph.scala
+++ b/platform.content.fsadaptor/src/main/scala/org/apache/clerezza/platform/content/fsadaptor/PathNode2MGraph.scala
@@ -41,106 +41,106 @@ import org.wymiwyg.commons.util.dirbrowser.PathNode
*/
object PathNode2MGraph {
- private val URI_PREFIX = Constants.URN_LOCAL_INSTANCE
+ private val URI_PREFIX = Constants.URN_LOCAL_INSTANCE
- private val literalFactory = LiteralFactory.getInstance
+ private val literalFactory = LiteralFactory.getInstance
- private def getMediaType(file: PathNode) = {
- val guessedMediaType: MediaType = MediaTypeGuesser.getInstance().guessTypeForName(file.getPath());
- if (guessedMediaType != null) {
- guessedMediaType.toString
- } else {
- "application/octet-stream"
- }
+ private def getMediaType(file: PathNode) = {
+ val guessedMediaType: MediaType = MediaTypeGuesser.getInstance().guessTypeForName(file.getPath());
+ if (guessedMediaType != null) {
+ guessedMediaType.toString
+ } else {
+ "application/octet-stream"
+ }
- }
+ }
- private def getData(file: PathNode) = {
- val baos = new ByteArrayOutputStream
- val in = file.getInputStream()
- val buffer = new Array[Byte](4096)
- var read = in.read(buffer)
- while (read != -1) {
- baos.write(buffer, 0, read)
- read = in.read(buffer)
- }
- in.close()
- baos.toByteArray
- }
+ private def getData(file: PathNode) = {
+ val baos = new ByteArrayOutputStream
+ val in = file.getInputStream()
+ val buffer = new Array[Byte](4096)
+ var read = in.read(buffer)
+ while (read != -1) {
+ baos.write(buffer, 0, read)
+ read = in.read(buffer)
+ }
+ in.close()
+ baos.toByteArray
+ }
- def describeInGraph(directory: PathNode, mGraph: MGraph) {
- val basePathLength = directory.getPath.length
- def createUriRef(file: PathNode, isDirectory: Boolean) = {
- def addSlashIfNeeded(s: String) = {
- if (s.endsWith("/")) {
- s
- } else {
- s+'/'
- }
- }
- val path = if (isDirectory) {
- addSlashIfNeeded(file.getPath.substring(basePathLength))
- } else {
- file.getPath.substring(basePathLength)
- }
- new UriRef(URI_PREFIX+path)
- }
- def processDirectory(directory: PathNode) {
- val directoryResource = createUriRef(directory, true)
- mGraph.add(new TripleImpl(directoryResource, RDF.`type`, HIERARCHY.Collection))
- for (subPath <- directory.list) {
- val file = directory.getSubPath(subPath)
- val isDirectory = file.isDirectory
- val resource = createUriRef(file, isDirectory)
- mGraph.add(new TripleImpl(resource, HIERARCHY.parent, directoryResource))
- if (isDirectory) {
- processDirectory(file)
- } else {
- mGraph.add(new TripleImpl(resource, RDF.`type`, DISCOBITS.InfoDiscoBit))
- val data = getData(file)
- mGraph.add(new TripleImpl(resource, DISCOBITS.infoBit, literalFactory.createTypedLiteral(data)))
- mGraph.add(new TripleImpl(resource, DISCOBITS.mediaType,
- literalFactory.createTypedLiteral(getMediaType(file))));
- }
- }
- }
- processDirectory(directory)
- }
+ def describeInGraph(directory: PathNode, mGraph: MGraph) {
+ val basePathLength = directory.getPath.length
+ def createUriRef(file: PathNode, isDirectory: Boolean) = {
+ def addSlashIfNeeded(s: String) = {
+ if (s.endsWith("/")) {
+ s
+ } else {
+ s+'/'
+ }
+ }
+ val path = if (isDirectory) {
+ addSlashIfNeeded(file.getPath.substring(basePathLength))
+ } else {
+ file.getPath.substring(basePathLength)
+ }
+ new UriRef(URI_PREFIX+path)
+ }
+ def processDirectory(directory: PathNode) {
+ val directoryResource = createUriRef(directory, true)
+ mGraph.add(new TripleImpl(directoryResource, RDF.`type`, HIERARCHY.Collection))
+ for (subPath <- directory.list) {
+ val file = directory.getSubPath(subPath)
+ val isDirectory = file.isDirectory
+ val resource = createUriRef(file, isDirectory)
+ mGraph.add(new TripleImpl(resource, HIERARCHY.parent, directoryResource))
+ if (isDirectory) {
+ processDirectory(file)
+ } else {
+ mGraph.add(new TripleImpl(resource, RDF.`type`, DISCOBITS.InfoDiscoBit))
+ val data = getData(file)
+ mGraph.add(new TripleImpl(resource, DISCOBITS.infoBit, literalFactory.createTypedLiteral(data)))
+ mGraph.add(new TripleImpl(resource, DISCOBITS.mediaType,
+ literalFactory.createTypedLiteral(getMediaType(file))));
+ }
+ }
+ }
+ processDirectory(directory)
+ }
- def removeNodesFromGraph(directory: PathNode, mGraph: MGraph) {
- val basePathLength = directory.getPath.length
- def createUriRef(file: PathNode, isDirectory: Boolean) = {
- def addSlashIfNeeded(s: String) = {
- if (s.endsWith("/")) {
- s
- } else {
- s+'/'
- }
- }
- val path = if (isDirectory) {
- addSlashIfNeeded(file.getPath.substring(basePathLength))
- } else {
- file.getPath.substring(basePathLength)
- }
- new UriRef(URI_PREFIX+path)
- }
- def processDirectory(directory: PathNode) {
- val directoryResource = createUriRef(directory, true)
- mGraph.remove(new TripleImpl(directoryResource, RDF.`type`, HIERARCHY.Collection))
- for (subPath <- directory.list) {
- val file = directory.getSubPath(subPath)
- val isDirectory = file.isDirectory
- val resource = createUriRef(file, isDirectory)
- val node = new GraphNode(resource, mGraph)
- if (isDirectory) {
- processDirectory(file)
- }
- node.deleteProperties(HIERARCHY.parent)
- node.deleteProperties(RDF.`type`)
- node.deleteProperties(DISCOBITS.infoBit)
- node.deleteProperties(DISCOBITS.mediaType)
- }
- }
- processDirectory(directory)
- }
+ def removeNodesFromGraph(directory: PathNode, mGraph: MGraph) {
+ val basePathLength = directory.getPath.length
+ def createUriRef(file: PathNode, isDirectory: Boolean) = {
+ def addSlashIfNeeded(s: String) = {
+ if (s.endsWith("/")) {
+ s
+ } else {
+ s+'/'
+ }
+ }
+ val path = if (isDirectory) {
+ addSlashIfNeeded(file.getPath.substring(basePathLength))
+ } else {
+ file.getPath.substring(basePathLength)
+ }
+ new UriRef(URI_PREFIX+path)
+ }
+ def processDirectory(directory: PathNode) {
+ val directoryResource = createUriRef(directory, true)
+ mGraph.remove(new TripleImpl(directoryResource, RDF.`type`, HIERARCHY.Collection))
+ for (subPath <- directory.list) {
+ val file = directory.getSubPath(subPath)
+ val isDirectory = file.isDirectory
+ val resource = createUriRef(file, isDirectory)
+ val node = new GraphNode(resource, mGraph)
+ if (isDirectory) {
+ processDirectory(file)
+ }
+ node.deleteProperties(HIERARCHY.parent)
+ node.deleteProperties(RDF.`type`)
+ node.deleteProperties(DISCOBITS.infoBit)
+ node.deleteProperties(DISCOBITS.mediaType)
+ }
+ }
+ processDirectory(directory)
+ }
}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/35448624/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/HtmlInfoDicobitRDFaNaked.scala
----------------------------------------------------------------------
diff --git a/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/HtmlInfoDicobitRDFaNaked.scala b/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/HtmlInfoDicobitRDFaNaked.scala
index 408ac6d..5b5c23b 100644
--- a/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/HtmlInfoDicobitRDFaNaked.scala
+++ b/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/HtmlInfoDicobitRDFaNaked.scala
@@ -15,22 +15,22 @@ import org.apache.felix.scr.annotations.Service;import scala.xml.Unparsed
@Service(Array(classOf[TypeRenderlet]))
class HtmlInfoDicobitRDFaNaked extends SRenderlet {
- val getRdfType = DISCOBITS.XHTMLInfoDiscoBit
+ val getRdfType = DISCOBITS.XHTMLInfoDiscoBit
override val getMediaType = MediaType.TEXT_HTML_TYPE
- override def getModePattern = "rdfa-naked"
+ override def getModePattern = "rdfa-naked"
- override def renderedPage(arguments: XmlResult.Arguments) = {
- new XmlResult(arguments) {
- override def content = {
+ override def renderedPage(arguments: XmlResult.Arguments) = {
+ new XmlResult(arguments) {
+ override def content = {
<div typeof="disco:XHTMLInfoDiscoBit" about={res*}>
<span property="disco:infoBit">
{Unparsed(res/DISCOBITS.infoBit*)}
</span>
</div>
- }
- }
- }
+ }
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/clerezza/blob/35448624/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/OrderedContentRDFaNaked.scala
----------------------------------------------------------------------
diff --git a/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/OrderedContentRDFaNaked.scala b/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/OrderedContentRDFaNaked.scala
index 1427f34..e8e00f5 100644
--- a/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/OrderedContentRDFaNaked.scala
+++ b/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/OrderedContentRDFaNaked.scala
@@ -14,15 +14,15 @@ import org.apache.felix.scr.annotations.Service;
@Service(Array(classOf[TypeRenderlet]))
class OrderedContentRDFaNaked extends SRenderlet {
- val getRdfType = DISCOBITS.OrderedContent
+ val getRdfType = DISCOBITS.OrderedContent
override val getMediaType = MediaType.TEXT_HTML_TYPE
- override def getModePattern = "rdfa-naked"
+ override def getModePattern = "rdfa-naked"
- override def renderedPage(arguments: XmlResult.Arguments) = {
- new XmlResult(arguments) {
- override def content = {
+ override def renderedPage(arguments: XmlResult.Arguments) = {
+ new XmlResult(arguments) {
+ override def content = {
<div about={res*} typeof="disco:OrderedContent">
{for (part <- (res/DISCOBITS.contains).sortBy(part => (part/DISCOBITS.pos*).toInt))
yield <div property="disco:contains" typeof="disco:Entry">
@@ -31,8 +31,8 @@ class OrderedContentRDFaNaked extends SRenderlet {
</div>
}
</div>
- }
- }
- }
+ }
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/clerezza/blob/35448624/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/TitledContentRDFaNaked.scala
----------------------------------------------------------------------
diff --git a/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/TitledContentRDFaNaked.scala b/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/TitledContentRDFaNaked.scala
index ad0deda..5e1e1cc 100644
--- a/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/TitledContentRDFaNaked.scala
+++ b/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/TitledContentRDFaNaked.scala
@@ -14,15 +14,15 @@ import org.apache.felix.scr.annotations.Service;
@Service(Array(classOf[TypeRenderlet]))
class TitledContentRDFaNaked extends SRenderlet {
- val getRdfType = DISCOBITS.TitledContent
+ val getRdfType = DISCOBITS.TitledContent
override val getMediaType = MediaType.TEXT_HTML_TYPE
- override def getModePattern = "rdfa-naked"
+ override def getModePattern = "rdfa-naked"
- override def renderedPage(arguments: XmlResult.Arguments) = {
- new XmlResult(arguments) {
- override def content = {
+ override def renderedPage(arguments: XmlResult.Arguments) = {
+ new XmlResult(arguments) {
+ override def content = {
<div typeof="disco:TitledContent" about={res*}>
{for (part <- res/DISCOBITS.contains; if ((part/DISCOBITS.pos*) == "0"))
yield <span property="disco:holds" typeof="disco:Entry">
@@ -35,8 +35,8 @@ class TitledContentRDFaNaked extends SRenderlet {
<div property="disco:holds" resource={part/DISCOBITS.holds*}>{render(part/DISCOBITS.holds, "rdfa-naked")}</div>
</div>}
</div>
- }
- }
- }
+ }
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/clerezza/blob/35448624/platform.graphnodeprovider/src/main/scala/org/apache/clerezza/platform/graphnodeprovider/GraphNodeProvider.scala
----------------------------------------------------------------------
diff --git a/platform.graphnodeprovider/src/main/scala/org/apache/clerezza/platform/graphnodeprovider/GraphNodeProvider.scala b/platform.graphnodeprovider/src/main/scala/org/apache/clerezza/platform/graphnodeprovider/GraphNodeProvider.scala
index e8d3edd..5c9f12b 100644
--- a/platform.graphnodeprovider/src/main/scala/org/apache/clerezza/platform/graphnodeprovider/GraphNodeProvider.scala
+++ b/platform.graphnodeprovider/src/main/scala/org/apache/clerezza/platform/graphnodeprovider/GraphNodeProvider.scala
@@ -40,27 +40,27 @@ import java.security.{PrivilegedAction, AccessController}
*/
class GraphNodeProvider extends Logging {
- /**
- * Get a GraphNode for the specified resource, see class comments for details.
- */
- def get(uriRef: UriRef): GraphNode = {
- val uriString = uriRef.getUnicodeString
- val isLocal: Boolean = {
- import scala.collection.JavaConversions._
- //we assume all non http* uris to be local
- !uriString.toLowerCase.startsWith("http") || platformConfig.getBaseUris.exists(baseUri => uriString.startsWith(baseUri.getUnicodeString))
- }
- get(uriRef, isLocal)
- }
-
- /**
- * Get a GraphNode for the specified resource, The resource is assumed to be local, i.e. the method behaves like
- * get(UriRef) for a Uri with an authority section contained in the Set retuned by
- * <code>org.apache.clerezza.platform.config.PlatformConfig#getBaseUris()</code>
- */
- def getLocal(uriRef: UriRef): GraphNode = {
- get(uriRef, true)
- }
+ /**
+ * Get a GraphNode for the specified resource, see class comments for details.
+ */
+ def get(uriRef: UriRef): GraphNode = {
+ val uriString = uriRef.getUnicodeString
+ val isLocal: Boolean = {
+ import scala.collection.JavaConversions._
+ //we assume all non http* uris to be local
+ !uriString.toLowerCase.startsWith("http") || platformConfig.getBaseUris.exists(baseUri => uriString.startsWith(baseUri.getUnicodeString))
+ }
+ get(uriRef, isLocal)
+ }
+
+ /**
+ * Get a GraphNode for the specified resource, The resource is assumed to be local, i.e. the method behaves like
+ * get(UriRef) for a Uri with an authority section contained in the Set retuned by
+ * <code>org.apache.clerezza.platform.config.PlatformConfig#getBaseUris()</code>
+ */
+ def getLocal(uriRef: UriRef): GraphNode = {
+ get(uriRef, true)
+ }
/**
@@ -70,8 +70,8 @@ class GraphNodeProvider extends Logging {
val cgGraph = cgProvider.getContentGraph
lazy val localInstanceUri = {
val uri = new java.net.URI(uriRef.getUnicodeString)
- new UriRef(Constants.URN_LOCAL_INSTANCE + uri.getPath)
- }
+ new UriRef(Constants.URN_LOCAL_INSTANCE + uri.getPath)
+ }
//TODO handle /user/
existsInGraph(uriRef,cgGraph) || existsInGraph(localInstanceUri, cgGraph)
}
@@ -88,157 +88,157 @@ class GraphNodeProvider extends Logging {
}
- private def get(uriRef: UriRef, isLocal: Boolean): GraphNode = {
- val uriString = uriRef.getUnicodeString
-
-
- val uriPath = {
- val uri = new java.net.URI(uriString)
- uri.getPath
- }
-
- lazy val uriPrefix = {
- val uri = new java.net.URI(uriString)
- uri.getScheme+"://"+uri.getAuthority
- }
-
- val anyHostUri = new UriRef(Constants.URN_LOCAL_INSTANCE + uriPath)
-
- var mGraphs: List[TripleCollection] = Nil
-
- def addToUnion(mGraph: LockableMGraph) {
- //adding uncondinionately if (existsInGraph(uriRef, mGraph)) {
- mGraphs ::= mGraph
- //}
- if (isLocal) {
- if (existsInGraph(anyHostUri, mGraph)) {
- mGraphs ::= new UriMutatingTripleCollection(mGraph, Constants.URN_LOCAL_INSTANCE, uriPrefix)
- }
- }
- }
-
- val cgGraph = cgProvider.getContentGraph
-
- addToUnion(cgGraph)
-
- if (isLocal && uriPath.startsWith("/user/")) {
- val nextSlash = uriPath.indexOf('/',6)
- if (nextSlash != -1) {
- val userName = uriPath.substring(6, nextSlash)
- val webIdOption = AccessController.doPrivileged(new PrivilegedAction[Option[UriRef]]() {
- def run(): Option[UriRef] = {
- val userNode: GraphNode = userManager.getUserInSystemGraph(userName)
- if (userNode != null) {
- userNode.getNode match {
- case u: UriRef => Some(u)
- case _ => None
- }
- } else {
- None
- }
- }
- }
- )
- webIdOption match {
- case Some(u) => {
- val webIdInfo = webIdGraphsService.getWebIdInfo(u)
- addToUnion(webIdInfo.localPublicUserData)
- }
- case None => ;
- }
- }
- }
-
- if (!isLocal) {
- /**
- * As the resource might identify something other than a document we use this to find the redirect location
- */
- lazy val redirectLocationString = {
- val acceptHeader = "application/rdf+xml,*/*;q.1"
- val url = new URL(uriString)
- val connection = url.openConnection()
- connection match {
- case hc : HttpURLConnection => {
- hc.setRequestMethod("HEAD");
- hc.setInstanceFollowRedirects(false)
- hc.addRequestProperty("Accept", acceptHeader)
- hc.getResponseCode match {
- case HttpURLConnection.HTTP_SEE_OTHER => {
- val location = hc.getHeaderField("Location")
- if (location == null) {
- throw new RuntimeException("No Location Headers in 303 response")
- }
- location
- }
- case _ => uriString
- }
- }
- case _ => uriString
- }
- }
-
- //TODO add method to WebProxy to get the graph location location
- val graphUriString = {
- val hashPos = uriString.indexOf('#')
- if (hashPos != -1) {
- uriString.substring(0, hashPos)
- } else {
- redirectLocationString
- }
- }
-
- addToUnion(tcManager.getMGraph(new UriRef(graphUriString)))
- }
-
- val unionMGraph = new UnionMGraph(mGraphs:_*);
- new GraphNode(uriRef, unionMGraph)
- }
-
- private var tcManager: TcManager = null;
-
- protected def bindTcManager(tcManager: TcManager) = {
- this.tcManager = tcManager
- }
-
- protected def unbindTcManager(tcManager: TcManager) = {
- this.tcManager = null
- }
-
- private var platformConfig: PlatformConfig = null;
-
- protected def bindPlatformConfig(c: PlatformConfig) = {
- this.platformConfig = c
- }
-
- protected def unbindPlatformConfig(c: PlatformConfig) = {
- this.platformConfig = null
- }
-
- private var cgProvider: ContentGraphProvider = null
- protected def bindCgProvider(p: ContentGraphProvider) {
- this.cgProvider = p
- }
- protected def unbindCgProvider(p: ContentGraphProvider) {
- this.cgProvider = null
- }
-
- private var webIdGraphsService: WebIdGraphsService = null
- protected def bindWebIdGraphsService(webIdGraphsService: WebIdGraphsService): Unit = {
- this.webIdGraphsService = webIdGraphsService
- }
-
- protected def unbindWebIdGraphsService(webIdGraphsService: WebIdGraphsService): Unit = {
- this.webIdGraphsService = null
- }
-
- private var userManager: UserManager = null
-
- protected def bindUserManager(userManager: UserManager): Unit = {
- this.userManager = userManager
- }
-
- protected def unbindUserManager(userManager: UserManager): Unit = {
- this.userManager = null
- }
+ private def get(uriRef: UriRef, isLocal: Boolean): GraphNode = {
+ val uriString = uriRef.getUnicodeString
+
+
+ val uriPath = {
+ val uri = new java.net.URI(uriString)
+ uri.getPath
+ }
+
+ lazy val uriPrefix = {
+ val uri = new java.net.URI(uriString)
+ uri.getScheme+"://"+uri.getAuthority
+ }
+
+ val anyHostUri = new UriRef(Constants.URN_LOCAL_INSTANCE + uriPath)
+
+ var mGraphs: List[TripleCollection] = Nil
+
+ def addToUnion(mGraph: LockableMGraph) {
+ //adding uncondinionately if (existsInGraph(uriRef, mGraph)) {
+ mGraphs ::= mGraph
+ //}
+ if (isLocal) {
+ if (existsInGraph(anyHostUri, mGraph)) {
+ mGraphs ::= new UriMutatingTripleCollection(mGraph, Constants.URN_LOCAL_INSTANCE, uriPrefix)
+ }
+ }
+ }
+
+ val cgGraph = cgProvider.getContentGraph
+
+ addToUnion(cgGraph)
+
+ if (isLocal && uriPath.startsWith("/user/")) {
+ val nextSlash = uriPath.indexOf('/',6)
+ if (nextSlash != -1) {
+ val userName = uriPath.substring(6, nextSlash)
+ val webIdOption = AccessController.doPrivileged(new PrivilegedAction[Option[UriRef]]() {
+ def run(): Option[UriRef] = {
+ val userNode: GraphNode = userManager.getUserInSystemGraph(userName)
+ if (userNode != null) {
+ userNode.getNode match {
+ case u: UriRef => Some(u)
+ case _ => None
+ }
+ } else {
+ None
+ }
+ }
+ }
+ )
+ webIdOption match {
+ case Some(u) => {
+ val webIdInfo = webIdGraphsService.getWebIdInfo(u)
+ addToUnion(webIdInfo.localPublicUserData)
+ }
+ case None => ;
+ }
+ }
+ }
+
+ if (!isLocal) {
+ /**
+ * As the resource might identify something other than a document we use this to find the redirect location
+ */
+ lazy val redirectLocationString = {
+ val acceptHeader = "application/rdf+xml,*/*;q.1"
+ val url = new URL(uriString)
+ val connection = url.openConnection()
+ connection match {
+ case hc : HttpURLConnection => {
+ hc.setRequestMethod("HEAD");
+ hc.setInstanceFollowRedirects(false)
+ hc.addRequestProperty("Accept", acceptHeader)
+ hc.getResponseCode match {
+ case HttpURLConnection.HTTP_SEE_OTHER => {
+ val location = hc.getHeaderField("Location")
+ if (location == null) {
+ throw new RuntimeException("No Location Headers in 303 response")
+ }
+ location
+ }
+ case _ => uriString
+ }
+ }
+ case _ => uriString
+ }
+ }
+
+ //TODO add method to WebProxy to get the graph location location
+ val graphUriString = {
+ val hashPos = uriString.indexOf('#')
+ if (hashPos != -1) {
+ uriString.substring(0, hashPos)
+ } else {
+ redirectLocationString
+ }
+ }
+
+ addToUnion(tcManager.getMGraph(new UriRef(graphUriString)))
+ }
+
+ val unionMGraph = new UnionMGraph(mGraphs:_*);
+ new GraphNode(uriRef, unionMGraph)
+ }
+
+ private var tcManager: TcManager = null;
+
+ protected def bindTcManager(tcManager: TcManager) = {
+ this.tcManager = tcManager
+ }
+
+ protected def unbindTcManager(tcManager: TcManager) = {
+ this.tcManager = null
+ }
+
+ private var platformConfig: PlatformConfig = null;
+
+ protected def bindPlatformConfig(c: PlatformConfig) = {
+ this.platformConfig = c
+ }
+
+ protected def unbindPlatformConfig(c: PlatformConfig) = {
+ this.platformConfig = null
+ }
+
+ private var cgProvider: ContentGraphProvider = null
+ protected def bindCgProvider(p: ContentGraphProvider) {
+ this.cgProvider = p
+ }
+ protected def unbindCgProvider(p: ContentGraphProvider) {
+ this.cgProvider = null
+ }
+
+ private var webIdGraphsService: WebIdGraphsService = null
+ protected def bindWebIdGraphsService(webIdGraphsService: WebIdGraphsService): Unit = {
+ this.webIdGraphsService = webIdGraphsService
+ }
+
+ protected def unbindWebIdGraphsService(webIdGraphsService: WebIdGraphsService): Unit = {
+ this.webIdGraphsService = null
+ }
+
+ private var userManager: UserManager = null
+
+ protected def bindUserManager(userManager: UserManager): Unit = {
+ this.userManager = userManager
+ }
+
+ protected def unbindUserManager(userManager: UserManager): Unit = {
+ this.userManager = null
+ }
}