Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
intranet-rest-fs-openacs
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
project-open
intranet-rest-fs-openacs
Commits
ddcec6a3
Commit
ddcec6a3
authored
Aug 27, 2018
by
Frank Bergmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial Import
parents
Pipeline
#965
failed with stages
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
235 additions
and
0 deletions
+235
-0
intranet-rest-fs-openacs.info
intranet-rest-fs-openacs.info
+29
-0
intranet-rest-fs-openacs-procs.tcl
tcl/intranet-rest-fs-openacs-procs.tcl
+23
-0
current-version.json.adp
www/current-version.json.adp
+1
-0
file-tree.json.adp
www/v1/file-tree.json.adp
+3
-0
file-tree.json.tcl
www/v1/file-tree.json.tcl
+179
-0
No files found.
intranet-rest-fs-openacs.info
0 → 100644
View file @
ddcec6a3
<?xml version="1.0"?>
<!-- Generated by the OpenACS Package Manager -->
<package
key=
"intranet-rest-fs-openacs"
url=
"http://openacs.org/repository/apm/packages/intranet-rest-filestorage"
type=
"apm_application"
>
<package-name>
]project-open[ REST Filestorage OpenACS
</package-name>
<pretty-plural>
]project-open[ REST Filestorage OpenACS
</pretty-plural>
<initial-install-p>
f
</initial-install-p>
<singleton-p>
t
</singleton-p>
<implements-subsite-p>
f
</implements-subsite-p>
<inherit-templates-p>
f
</inherit-templates-p>
<auto-mount>
intranet-rest-fs-openacs
</auto-mount>
<version
name=
"0.1d"
url=
"http://openacs.org/repository/download/apm/intranet-rest-fs-openacs-0.1d.apm"
>
<owner
url=
"mailto:frank.bergmann@project-open.com"
>
Frank Bergmann
</owner>
<summary>
REST Interface to OpenACS filestorage
</summary>
<vendor
url=
"http://www.project-open.com/"
>
]project-open[ Business Solutions, S.L.
</vendor>
<description
format=
"text/plain"
>
Implements a REST interface to OpenACS filestorage
</description>
<maturity>
0
</maturity>
<provides
url=
"intranet-rest-fs-openacs"
version=
"0.1d"
/>
<callbacks>
</callbacks>
<parameters>
<!-- No version parameters -->
</parameters>
</version>
</package>
tcl/intranet-rest-fs-openacs-procs.tcl
0 → 100755
View file @
ddcec6a3
# /packages/intranet-rest-fs-openacs/tcl/intranet-rest-fs-openacs-procs.tcl
#
# Copyright (C
)
2018
]
project-open
[
#
# All rights reserved. Please check
# http://www.project-open.com/license/ for details.
ad_library
{
Procs used in filestorage API for OpenACS
@author frank.bergmann@project-open.com
}
# ----------------------------------------------------------------------
# Constants
# ---------------------------------------------------------------------
# ----------------------------------------------------------------------
# Components
# ---------------------------------------------------------------------
www/current-version.json.adp
0 → 100644
View file @
ddcec6a3
{'success': true, 'message': 'success', 'version': 'v1'}
www/v1/file-tree.json.adp
0 → 100644
View file @
ddcec6a3
{'text':'.','children': [
@file_json;noquote@
}
www/v1/file-tree.json.tcl
0 → 100644
View file @
ddcec6a3
# /packages/intranet-rest-fs-openacs/www/v1/file-tree.json.tcl
#
# Copyright (C
)
2013-2018
]
project-open
[
ad_page_contract
{
Returns a JSON tree structure suitable for batch-loading a project TreeStore
@param object_id ]po
[
Business Object to which the FS belongs.
0 identifies the global
"Home"
FS
@author frank.bergmann@project-open.com
@param node Passed by ExtJS to load sub-trees of a tree.
Normally not used, just in case of error.
}
{
{
object_id:integer 0
}
{
debug_p 0
}
{
node
""
}
}
set
root_file_id
$object
_id
if
{
""
ne
$node
&&
[
string
is integer
$node
]}
{
set root_file_id
$node
}
# --------------------------------------------
# Security & Permissions
#
set
current_user_id
[
auth::require_login
]
set
ttt
{
im_object_permissions
$current
_user_id
$object
_id view read write admin
if
{
!$read
}
{
im_rest_error -format
"json"
-http_status 403 -message
"You (user #
$current
_user_id) have no permissions to read object #
$object
_id"
ad_script_abort
}
}
set
folder_id
[
fs_get_root_folder
]
set
folder_id 36012
# permission::require_permission -party_id $current_user_id -object_id $folder_id -privilege "read"
# set package_and_root [fs::get_folder_package_and_root $folder_id
]
# set package_id [lindex $package_and_root 0
]
# set root_folder_id [lindex $package_and_root 1
]
set
folder_path
""
# --------------------------------------------
# Main hierarchical SQL
#
set
sql
"
select
ci.item_id as file_id,
ci.name as file_name,
tree_level(ci.tree_sortkey) as level,
(select count(*) from cr_items child where child.parent_id = ci.item_id) as num_children,
ci.*,
cr.*,
CASE WHEN bts.open_p = 'o' THEN 'true' ELSE 'false' END as expanded,
CASE
WHEN ci.content_type::text = 'content_folder'::text THEN 'folder'::character varying
WHEN ci.content_type::text = 'content_extlink'::text THEN 'url'::character varying
WHEN ci.content_type::text = 'content_symlink'::text THEN 'symlink'::character varying
ELSE cr.mime_type
END AS type
from cr_items parent_ci,
cr_items ci
LEFT JOIN cr_extlinks ce ON ci.item_id = ce.extlink_id
LEFT JOIN cr_folders cf ON ci.item_id = cf.folder_id
LEFT JOIN cr_revisions cr ON ci.live_revision = cr.revision_id
LEFT JOIN cr_mime_types cm ON cr.mime_type = cm.mime_type
JOIN acs_objects o ON ci.item_id = o.object_id
LEFT OUTER JOIN im_biz_object_tree_status bts ON (
ci.item_id = bts.object_id and
bts.page_url = 'rest-fs-openacs' and
bts.user_id = :current_user_id
)
where
parent_ci.item_id = :folder_id and
ci.tree_sortkey between parent_ci.tree_sortkey and tree_right(parent_ci.tree_sortkey)
order by
ci.tree_sortkey
"
# ad_return_complaint 1 [im_ad_hoc_query -subtotals_p 0 -format html $sql
]
# Read the query into a Multirow, so that we can order
# it according to sort_order within the individual sub-levels.
db_multirow file_multirow file_list
$sql
{
# By default keep the top-level file-storage
"open"
.
if
{
""
==
$parent
_id
}
{
set expanded
"true"
}
}
# --------------------------------------------
# Get all the extra variables for a file ci_item:
# fraber 2018-08-22: No meta-variables yet...
set
valid_vars
[
list
title description type publish_date mime_type content_length
]
set
valid_vars
[
lsort
-unique
$valid
_vars
]
set
file_json
""
set
ctr 0
set
old_level
[
db_string top_level
"select tree_level(tree_sortkey) from cr_items where item_id = :folder_id"
]
set
indent
""
template::multirow foreach file_multirow
{
ns_log Notice
"file-tree.json.tcl: file_id=
$file
_id, file_id=
$file
_id"
if
{
$debug
_p
}
{
append file_json
"
\n
// finish: ctr=
$ctr
, level=
$level
, old_level=
$old
_level
\n
"
}
# -----------------------------------------
# Close off the previous entry
# -----------------------------------------
# This is the first child of the previous item
# Increasing the level always happens in steps of 1
if
{
$level
>
$old
_level
}
{
append file_json
",
\n
${indent}
\t
children:
\[\n
"
}
# A group of children needs to be closed.
# Please note that this can cascade down to several levels.
while
{
$level
<
$old
_level
}
{
append file_json
"
\n
${indent}
\}\]\n
"
incr old_level -1
set indent
""
for
{
set
i 0
}
{
$i
<
$old
_level
}
{
incr
i
}
{
append indent
"
\t
"
}
}
# The current file is on the same level as the previous.
# This is also executed after reducing the old_level in the previous while loop
if
{
$level
==
$old
_level
}
{
if
{
0 !=
$ctr
}
{
append file_json
"
${indent}
\n
${indent}
\}
,
\n
"
}
}
if
{
$debug
_p
}
{
append file_json
"
\n
//
$file
_name: ctr=
$ctr
, level=
$level
, old_level=
$old
_level
\n
"
}
set indent
""
for
{
set
i 0
}
{
$i
<
$level
}
{
incr
i
}
{
append indent
"
\t
"
}
if
{
0 ==
$num
_children
}
{
set leaf_json
"true"
}
else
{
set leaf_json
"false"
}
set quoted_char_map
{
"
\n
"
"
\\
n"
"
\r
"
"
\\
r"
"
\"
"
"
\\\"
"
"
\\
"
"
\\\\
"
}
set quoted_file_name
[
string
map
$quoted
_char_map
$file
_name
]
append file_json
"
${indent}
\{
${indent}
\t
id:
$file
_id,
${indent}
\t
text:
\"
$quoted
_file_name
\"
,
${indent}
\t
iconCls:
\"
icon-
$type
\"
,
${indent}
\t
expanded:
$expanded
,
"
foreach var
$valid
_vars
{
# Skip xml_* variables
(
only used by MS-File
)
if
{[
regexp
{
^xml_
}
$var
match
]}
{
continue
}
# Append the value to the JSON output
set value
[
set
$var
]
set quoted_value
[
string
map
$quoted
_char_map
$value
]
append file_json
"
${indent}
\t
$var:
\"
$quoted
_value
\"
,
\n
"
}
append file_json
"
${indent}
\t
leaf:
$leaf
_json"
incr ctr
set old_level
$level
}
set
level 0
while
{
$level
<
$old
_level
}
{
# A group of children needs to be closed.
# Please note that this can cascade down to several levels.
append file_json
"
\n
${indent}
\}\]\n
"
incr old_level -1
set indent
""
for
{
set
i 0
}
{
$i
<
$old
_level
}
{
incr
i
}
{
append indent
"
\t
"
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment