Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.

Commit

Permalink
#169 reformatting to match coding standards, including using spaces i…
Browse files Browse the repository at this point in the history
…nstead of tabs
  • Loading branch information
dmcassel committed Jan 13, 2014
1 parent 0841cf3 commit e0080e3
Show file tree
Hide file tree
Showing 7 changed files with 671 additions and 662 deletions.
100 changes: 50 additions & 50 deletions src/roxy/config/defaults.xqy
Original file line number Diff line number Diff line change
Expand Up @@ -29,63 +29,63 @@ declare namespace rest = "http://marklogic.com/appservices/rest";
: ***********************************************
:)
declare variable $ROXY-OPTIONS :=
<options>
<!-- the default controller that the URL http://server:port/ maps to
use appbuilder for an appbuilder clone -->
<default-controller>appbuilder</default-controller>
<options>
<!-- the default controller that the URL http://server:port/ maps to
use appbuilder for an appbuilder clone -->
<default-controller>appbuilder</default-controller>

<!-- the default funciton that gets called when none is specified -->
<default-function>main</default-function>
<!-- the default funciton that gets called when none is specified -->
<default-function>main</default-function>

<!-- the default format to use when rendering views -->
<default-format>html</default-format>
<!-- the default format to use when rendering views -->
<default-format>html</default-format>

<!-- a mapping of default layouts to view formats -->
<layouts>
<layout format="html">two-column</layout>
</layouts>
</options>;
<!-- a mapping of default layouts to view formats -->
<layouts>
<layout format="html">two-column</layout>
</layouts>
</options>;


declare variable $ROXY-ROUTES :=
(: The default Roxy routes :)
let $default-controller :=
(
$config:ROXY-OPTIONS/*:default-controller,
$ROXY-OPTIONS/*:default-controller
)[1]
let $default-function :=
(
$config:ROXY-OPTIONS/*:default-function,
$ROXY-OPTIONS/*:default-function
)[1]
return
<routes xmlns="http://marklogic.com/appservices/rest">
<request uri="^/test/(js|img|css)/(.*)" />
<request uri="^/test/(.*)" endpoint="/test/default.xqy">
<uri-param name="func" default="{$default-function}">$1</uri-param>
</request>
<request uri="^/test$" redirect="/test/" />
<request uri="^/(css|js|images)/(.*)" endpoint="/public/$1/$2"/>
<request uri="^/favicon.ico$" endpoint="/public/favicon.ico"/>
(: The default Roxy routes :)
let $default-controller :=
(
$config:ROXY-OPTIONS/*:default-controller,
$ROXY-OPTIONS/*:default-controller
)[1]
let $default-function :=
(
$config:ROXY-OPTIONS/*:default-function,
$ROXY-OPTIONS/*:default-function
)[1]
return
<routes xmlns="http://marklogic.com/appservices/rest">
<request uri="^/test/(js|img|css)/(.*)" />
<request uri="^/test/(.*)" endpoint="/test/default.xqy">
<uri-param name="func" default="{$default-function}">$1</uri-param>
</request>
<request uri="^/test$" redirect="/test/" />
<request uri="^/(css|js|images)/(.*)" endpoint="/public/$1/$2"/>
<request uri="^/favicon.ico$" endpoint="/public/favicon.ico"/>
<request uri="^/v1/.+$"/>
<request uri="^/([\w\d_\-]*)/?([\w\d_\-]*)\.?(\w*)/?$" endpoint="/roxy/query-router.xqy">
<uri-param name="controller" default="{$default-controller}">$1</uri-param>
<uri-param name="func" default="{$default-function}">$2</uri-param>
<uri-param name="format">$3</uri-param>
<http method="GET"/>
<http method="HEAD"/>
</request>
<request uri="^/([\w\d_\-]*)/?([\w\d_\-]*)\.?(\w*)/?$" endpoint="/roxy/update-router.xqy">
<uri-param name="controller" default="{$default-controller}">$1</uri-param>
<uri-param name="func" default="{$default-function}">$2</uri-param>
<uri-param name="format">$3</uri-param>
<http method="POST"/>
<http method="PUT"/>
<http method="DELETE"/>
</request>
<request uri="^.+$"/>
</routes>;
<request uri="^/([\w\d_\-]*)/?([\w\d_\-]*)\.?(\w*)/?$" endpoint="/roxy/query-router.xqy">
<uri-param name="controller" default="{$default-controller}">$1</uri-param>
<uri-param name="func" default="{$default-function}">$2</uri-param>
<uri-param name="format">$3</uri-param>
<http method="GET"/>
<http method="HEAD"/>
</request>
<request uri="^/([\w\d_\-]*)/?([\w\d_\-]*)\.?(\w*)/?$" endpoint="/roxy/update-router.xqy">
<uri-param name="controller" default="{$default-controller}">$1</uri-param>
<uri-param name="func" default="{$default-function}">$2</uri-param>
<uri-param name="format">$3</uri-param>
<http method="POST"/>
<http method="PUT"/>
<http method="DELETE"/>
</request>
<request uri="^.+$"/>
</routes>;

(:
: ***********************************************
Expand Down
182 changes: 91 additions & 91 deletions src/roxy/lib/cpf-private.xqy
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@ declare option xdmp:mapping "false";

declare private function local:clean-cpf()
{
let $config := try { dom:configuration-get() } catch ($e) {}
return
if ($config) then
(
for $d in dom:domains()
let $name as xs:string := $d/dom:domain-name
return
dom:remove($name),
let $config := try { dom:configuration-get() } catch ($e) {}
return
if ($config) then
(
for $d in dom:domains()
let $name as xs:string := $d/dom:domain-name
return
dom:remove($name),

for $x as xs:string in p:pipelines( )/p:pipeline-name
return
p:remove($x)
)
else ()
for $x as xs:string in p:pipelines( )/p:pipeline-name
return
p:remove($x)
)
else ()
};

declare private function local:get-cpf-files($dir as xs:string, $extension as xs:string) as xs:string*
Expand Down Expand Up @@ -97,15 +97,15 @@ declare private function local:install-cpf-pipelines(
{
for $uri in $pipeline-uris
let $doc :=
let $map :=
let $map := map:map()
let $_ := (
map:put($map, "function", "get-doc"),
map:put($map, "uri", $uri))
return
$map
return
local:call-private-function($map, $modules-database)
let $map :=
let $map := map:map()
let $_ := (
map:put($map, "function", "get-doc"),
map:put($map, "uri", $uri))
return
$map
return
local:call-private-function($map, $modules-database)
return
p:insert($doc/*)
};
Expand All @@ -118,81 +118,81 @@ declare private function local:create-cpf-domain(
$pipeline-ids as xs:unsignedLong*,
$permissions as element(sec:permission)*) as xs:unsignedLong
{
let $domain-id := try { fn:data(dom:get($domain-name)/dom:domain-id) } catch ($e) { () }
return
(: update the existing domain :)
if ($domain-id) then
let $_ :=
(
dom:set-description($domain-name, $description),
dom:set-domain-scope($domain-name, $domain-scope),
dom:set-evaluation-context($domain-name, $context),
dom:set-pipelines($domain-name, $pipeline-ids),
dom:set-permissions($domain-name, $permissions)
)
return
$domain-id
(: create a new domain :)
else
let $domain-id := dom:create($domain-name, $description, $domain-scope, $context, $pipeline-ids, $permissions)
return
$domain-id
let $domain-id := try { fn:data(dom:get($domain-name)/dom:domain-id) } catch ($e) { () }
return
(: update the existing domain :)
if ($domain-id) then
let $_ :=
(
dom:set-description($domain-name, $description),
dom:set-domain-scope($domain-name, $domain-scope),
dom:set-evaluation-context($domain-name, $context),
dom:set-pipelines($domain-name, $pipeline-ids),
dom:set-permissions($domain-name, $permissions)
)
return
$domain-id
(: create a new domain :)
else
let $domain-id := dom:create($domain-name, $description, $domain-scope, $context, $pipeline-ids, $permissions)
return
$domain-id
};

declare private function local:create-cpf-configuration(
$restart-user as xs:string,
$evaluation-context as element(dom:evaluation-context),
$default-domain as xs:unsignedLong,
$permissions as element(sec:permission)*)
$evaluation-context as element(dom:evaluation-context),
$default-domain as xs:unsignedLong,
$permissions as element(sec:permission)*)
{
let $config :=
let $map :=
let $map := map:map()
let $_ := map:put($map, "function", "configuration-get")
return
$map
return
local:call-private-function($map, ())
return
if ($config) then
let $config := dom:configuration-set-restart-user($restart-user)
let $config := dom:configuration-set-evaluation-context($evaluation-context)
let $config := dom:configuration-set-default-domain($default-domain)
let $config := dom:configuration-set-permissions($permissions)
let $config := dom:configuration-set-conversion-enabled(fn:false())
return
"Updated configuration"
else
let $config :=
let $map :=
let $map := map:map()
let $_ := (
map:put($map, "function", "configuration-create"),
map:put($map, "restart-user", $restart-user),
let $config :=
let $map :=
let $map := map:map()
let $_ := map:put($map, "function", "configuration-get")
return
$map
return
local:call-private-function($map, ())
return
if ($config) then
let $config := dom:configuration-set-restart-user($restart-user)
let $config := dom:configuration-set-evaluation-context($evaluation-context)
let $config := dom:configuration-set-default-domain($default-domain)
let $config := dom:configuration-set-permissions($permissions)
let $config := dom:configuration-set-conversion-enabled(fn:false())
return
"Updated configuration"
else
let $config :=
let $map :=
let $map := map:map()
let $_ := (
map:put($map, "function", "configuration-create"),
map:put($map, "restart-user", $restart-user),
map:put($map, "evaluation-context", $evaluation-context),
map:put($map, "default-domain", $default-domain),
map:put($map, "permissions", $permissions))
return
$map
return
local:call-private-function($map, ())
let $option :=
let $map :=
let $map := map:map()
let $_ := (
map:put($map, "function", "enable-conversion"),
map:put($map, "enable", fn:false()))
return
$map
return
local:call-private-function($map, ())
return
"Created configuration"
return
$map
return
local:call-private-function($map, ())
let $option :=
let $map :=
let $map := map:map()
let $_ := (
map:put($map, "function", "enable-conversion"),
map:put($map, "enable", fn:false()))
return
$map
return
local:call-private-function($map, ())
return
"Created configuration"
};

declare private function local:evaluation-context(
$database as xs:unsignedLong,
$root as xs:string) as element(dom:evaluation-context)
$root as xs:string) as element(dom:evaluation-context)
{
dom:evaluation-context($database, $root)
};
Expand All @@ -208,9 +208,9 @@ declare private function local:configuration-get() as element(dom:configuration)

declare private function local:configuration-create(
$restart-user as xs:string,
$evaluation-context as element(dom:evaluation-context),
$default-domain as xs:unsignedLong,
$permissions as element(sec:permission)*) as xs:unsignedLong
$evaluation-context as element(dom:evaluation-context),
$default-domain as xs:unsignedLong,
$permissions as element(sec:permission)*) as xs:unsignedLong
{
dom:configuration-create($restart-user, $evaluation-context, $default-domain, $permissions)
};
Expand All @@ -229,9 +229,9 @@ declare private function local:call-private-function(
(xs:QName("map"), $map),
if ($database-id) then
<options xmlns="xdmp:eval">
<database>{$database-id}</database>
</options>
else ())
<database>{$database-id}</database>
</options>
else ())
};

declare private function local:get-doc($uri as xs:string)
Expand Down
22 changes: 11 additions & 11 deletions src/roxy/lib/cpf.xqy
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ declare option xdmp:mapping "false";
</context>
<restart-user>your-restart-user-name</restart-user>
<permissions>
<permission>
<capability>read</capability>
<role-name>admin</role-name>
</permission>
<permission>
<capability>read</capability>
<role-name>admin</role-name>
</permission>
</permissions>
</domain>
</domains>
Expand Down Expand Up @@ -198,9 +198,9 @@ declare function cpf:create-cpf-domain(
:)
declare function cpf:create-cpf-configuration(
$restart-user as xs:string,
$evaluation-context as element(dom:evaluation-context),
$default-domain as xs:unsignedLong,
$permissions as element(sec:permission)*)
$evaluation-context as element(dom:evaluation-context),
$default-domain as xs:unsignedLong,
$permissions as element(sec:permission)*)
{
let $map := map:map()
let $_ :=
Expand Down Expand Up @@ -241,8 +241,8 @@ declare function cpf:domain-scope(
: @return - a constructed dom:evaluation-context element
:)
declare function cpf:evaluation-context(
$database as xs:unsignedLong,
$root as xs:string) as element(dom:evaluation-context)
$database as xs:unsignedLong,
$root as xs:string) as element(dom:evaluation-context)
{
dom:evaluation-context($database, $root)
};
Expand All @@ -266,6 +266,6 @@ declare private function cpf:call-private-function(
"/roxy/lib/cpf-private.xqy",
(xs:QName("map"), $map),
<options xmlns="xdmp:eval">
<database>{$database-id}</database>
</options>)
<database>{$database-id}</database>
</options>)
};
Loading

0 comments on commit e0080e3

Please sign in to comment.