merged with private version at 181504
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@181670 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
2b54518c31
commit
40f4088413
|
@ -1,12 +1,13 @@
|
||||||
<ReleaseNotes>
|
<ReleaseNotes>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-27-0"
|
<Changeset
|
||||||
date="2019-07-30">
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-27-0"
|
||||||
<change>Added support to workspace users discovery by VREs [ticket:
|
date="${buildDate}">
|
||||||
#17169]</change>
|
<Change>[Task #17226] Workspace and Workspace Tree: migrate HL remaining methods to SHUB
|
||||||
<Change>Updated the list of classes shared with sharing widget
|
</Change>
|
||||||
component</Change>
|
<Change>Updated the list of classes shared with sharing widget component</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-26-0"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-26-0"
|
||||||
date="${buildDate}">
|
date="${buildDate}">
|
||||||
<Change>[Task #17135] Workspace: assign the file extension during the
|
<Change>[Task #17135] Workspace: assign the file extension during the
|
||||||
download
|
download
|
||||||
|
@ -15,13 +16,15 @@
|
||||||
shared folder
|
shared folder
|
||||||
</Change>
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-25-1"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-25-1"
|
||||||
date="${buildDate}">
|
date="${buildDate}">
|
||||||
<Change>[Task #17018] Move some methods to SHUB due to backward
|
<Change>[Task #17018] Move some methods to SHUB due to backward
|
||||||
compatibility broken between SHUB and HL
|
compatibility broken between SHUB and HL
|
||||||
</Change>
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-25-0"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-25-0"
|
||||||
date="${buildDate}">
|
date="${buildDate}">
|
||||||
<Change>Updated to StorageHub [ticket: #13226]</Change>
|
<Change>Updated to StorageHub [ticket: #13226]</Change>
|
||||||
<Change>[Support #16430] fixed</Change>
|
<Change>[Support #16430] fixed</Change>
|
||||||
|
@ -29,7 +32,8 @@
|
||||||
should be managed by dedicated message on WS-side
|
should be managed by dedicated message on WS-side
|
||||||
</Change>
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-24-1"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-24-1"
|
||||||
date="${buildDate}">
|
date="${buildDate}">
|
||||||
<Change>Updated regular expression to validate Folder and File names
|
<Change>Updated regular expression to validate Folder and File names
|
||||||
</Change>
|
</Change>
|
||||||
|
@ -39,7 +43,8 @@
|
||||||
<Change>[Task #13106] Provide public links for versioned files
|
<Change>[Task #13106] Provide public links for versioned files
|
||||||
</Change>
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-23-0"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-23-0"
|
||||||
date="${buildDate}">
|
date="${buildDate}">
|
||||||
<Change>[Task #12521] Migrate the tree view
|
<Change>[Task #12521] Migrate the tree view
|
||||||
</Change>
|
</Change>
|
||||||
|
@ -65,7 +70,8 @@
|
||||||
<Change>[Incident #12922] Workspace get link not working
|
<Change>[Incident #12922] Workspace get link not working
|
||||||
</Change>
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-22-0"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-22-0"
|
||||||
date="2018-09-14">
|
date="2018-09-14">
|
||||||
<Change>[Task #12489] Migrate delete operation to StorageHub
|
<Change>[Task #12489] Migrate delete operation to StorageHub
|
||||||
</Change>
|
</Change>
|
||||||
|
@ -73,65 +79,76 @@
|
||||||
Switchboard service discovery
|
Switchboard service discovery
|
||||||
</Change>
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-21-1"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-21-1"
|
||||||
date="2018-07-02">
|
date="2018-07-02">
|
||||||
<Change>[Task #12089] Migrate to workspace-uploader 2.0
|
<Change>[Task #12089] Migrate to workspace-uploader 2.0
|
||||||
</Change>
|
</Change>
|
||||||
<Change>[Release #12006] Removed Send to
|
<Change>[Release #12006] Removed Send to
|
||||||
</Change>
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-21-0"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-21-0"
|
||||||
date="2018-06-07">
|
date="2018-06-07">
|
||||||
<Change>[Project Activity #11690] Integrated with Task Executor Widget
|
<Change>[Project Activity #11690] Integrated with Task Executor Widget
|
||||||
</Change>
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-20-1"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-20-1"
|
||||||
date="2018-04-19">
|
date="2018-04-19">
|
||||||
<Change>Managed case of Exception in order to avoid failure on
|
<Change>Managed case of Exception in order to avoid failure on
|
||||||
checkItemLocked
|
checkItemLocked
|
||||||
</Change>
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-20-0"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-20-0"
|
||||||
date="2018-03-01">
|
date="2018-03-01">
|
||||||
<Change>[Task #11127] Porting to new ws-thredds engine</Change>
|
<Change>[Task #11127] Porting to new ws-thredds engine</Change>
|
||||||
<Change>[Feature #11325] Workspace: add New URL feature in the context
|
<Change>[Feature #11325] Workspace: add New URL feature in the context
|
||||||
menu of right pane
|
menu of right pane
|
||||||
</Change>
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-19-0"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-19-0"
|
||||||
date="2018-01-09">
|
date="2018-01-09">
|
||||||
<Change>Issue #10831, Workspace download folder tomcat temp occupation
|
<Change>Issue #10831, Workspace download folder tomcat temp occupation
|
||||||
issue
|
issue
|
||||||
</Change>
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-18-0"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-18-0"
|
||||||
date="2017-09-29">
|
date="2017-09-29">
|
||||||
<Change>Feature #9760: WS-Thredds synch folder integration</Change>
|
<Change>Feature #9760: WS-Thredds synch folder integration</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-17-2"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-17-2"
|
||||||
date="2017-09-13">
|
date="2017-09-13">
|
||||||
<Change>Incident #9676: fixed. Removed check on get sub-folder public
|
<Change>Incident #9676: fixed. Removed check on get sub-folder public
|
||||||
link when operation is performed by an administrator
|
link when operation is performed by an administrator
|
||||||
</Change>
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-17-1"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-17-1"
|
||||||
date="2017-07-10">
|
date="2017-07-10">
|
||||||
<Change>Added regex in order to remove list of chars when renaming or
|
<Change>Added regex in order to remove list of chars when renaming or
|
||||||
creating new item. It is different for folder and item name
|
creating new item. It is different for folder and item name
|
||||||
</Change>
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-17-0"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-17-0"
|
||||||
date="2017-05-22">
|
date="2017-05-22">
|
||||||
<Change>[Feature #5207] Integrate Image Preview Widget</Change>
|
<Change>[Feature #5207] Integrate Image Preview Widget</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-16-1"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-16-1"
|
||||||
date="2017-04-11">
|
date="2017-04-11">
|
||||||
<Change>Quick fix to set folder as public</Change>
|
<Change>Quick fix to set folder as public</Change>
|
||||||
<Change>Updated messages to history including version of file if it is
|
<Change>Updated messages to history including version of file if it is
|
||||||
present
|
present
|
||||||
</Change>
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-16-0"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-16-0"
|
||||||
date="2017-03-03">
|
date="2017-03-03">
|
||||||
<Change>Removed no longer used dependency: accesslogger</Change>
|
<Change>Removed no longer used dependency: accesslogger</Change>
|
||||||
<Change>[Feature #7006] File Versioning</Change>
|
<Change>[Feature #7006] File Versioning</Change>
|
||||||
|
@ -141,7 +158,8 @@
|
||||||
<Change>[Task #7382] Added a quick fix to 'Edit Permissions'</Change>
|
<Change>[Task #7382] Added a quick fix to 'Edit Permissions'</Change>
|
||||||
<Change>'Edit Permissions' can be performed by Administrators</Change>
|
<Change>'Edit Permissions' can be performed by Administrators</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-15-2"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-15-2"
|
||||||
date="2016-01-20">
|
date="2016-01-20">
|
||||||
<Change>Added a loader on share window when contacts are loading from
|
<Change>Added a loader on share window when contacts are loading from
|
||||||
server
|
server
|
||||||
|
@ -150,12 +168,14 @@
|
||||||
external servlets
|
external servlets
|
||||||
</Change>
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-15-1"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-15-1"
|
||||||
date="2016-01-05">
|
date="2016-01-05">
|
||||||
<Change>Removed message box shown in case of failure on getAllContatcs
|
<Change>Removed message box shown in case of failure on getAllContatcs
|
||||||
</Change>
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-15-0"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-15-0"
|
||||||
date="2016-11-29">
|
date="2016-11-29">
|
||||||
<Change>[Feature #5873] Remove ASL Session from the Workspace and its
|
<Change>[Feature #5873] Remove ASL Session from the Workspace and its
|
||||||
components
|
components
|
||||||
|
@ -164,7 +184,8 @@
|
||||||
access is granted for owner or admin
|
access is granted for owner or admin
|
||||||
</Change>
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-14-0"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-14-0"
|
||||||
date="2016-09-29">
|
date="2016-09-29">
|
||||||
<Change>[Feature #2335] Added "Get Folder Link" facility</Change>
|
<Change>[Feature #2335] Added "Get Folder Link" facility</Change>
|
||||||
<Change>[Incident #4878] Fixed: Workspace tree not displaying user's
|
<Change>[Incident #4878] Fixed: Workspace tree not displaying user's
|
||||||
|
@ -181,33 +202,39 @@
|
||||||
</Change>
|
</Change>
|
||||||
<Change>[Bug #5218] Fixed return to the Workspace root Folder</Change>
|
<Change>[Bug #5218] Fixed return to the Workspace root Folder</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-13-0"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-13-0"
|
||||||
date="2016-05-31">
|
date="2016-05-31">
|
||||||
<Change>[Feature #4128] Migration to Liferay 6.2</Change>
|
<Change>[Feature #4128] Migration to Liferay 6.2</Change>
|
||||||
<Change>Data Catalogue publishing supported</Change>
|
<Change>Data Catalogue publishing supported</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-12-0"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-12-0"
|
||||||
date="2016-05-16">
|
date="2016-05-16">
|
||||||
<Change>Integrated with new workspace uploader</Change>
|
<Change>Integrated with new workspace uploader</Change>
|
||||||
<Change>Bug fixed: Css for Dialog Cancel multiple files</Change>
|
<Change>Bug fixed: Css for Dialog Cancel multiple files</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-11-1"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-11-1"
|
||||||
date="2016-02-24">
|
date="2016-02-24">
|
||||||
<Change>Added icons for: .odt, .ods, .ott, .odg, .odp
|
<Change>Added icons for: .odt, .ods, .ott, .odg, .odp
|
||||||
</Change>
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-11-0"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-11-0"
|
||||||
date="2016-01-20">
|
date="2016-01-20">
|
||||||
<Change>[Feature #1925] Added, new public link format:
|
<Change>[Feature #1925] Added, new public link format:
|
||||||
http://host/storageID
|
http://host/storageID
|
||||||
</Change>
|
</Change>
|
||||||
<Change>[Feature #1298] Update public link generation</Change>
|
<Change>[Feature #1298] Update public link generation</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-10-1"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-10-1"
|
||||||
date="2015-12-16">
|
date="2015-12-16">
|
||||||
<Change>Bug Fixing - #1804; #1808; #1822; #1333</Change>
|
<Change>Bug Fixing - #1804; #1808; #1822; #1333</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-10-0"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-10-0"
|
||||||
date="2015-11-19">
|
date="2015-11-19">
|
||||||
<Change>[Feature #124] Remove a user from shared folder</Change>
|
<Change>[Feature #124] Remove a user from shared folder</Change>
|
||||||
<Change>[Feature #1259] Enhancement to workspace item history</Change>
|
<Change>[Feature #1259] Enhancement to workspace item history</Change>
|
||||||
|
@ -220,7 +247,8 @@
|
||||||
</Change>
|
</Change>
|
||||||
<Change>[Bug: #1459] Fixed: get link disabled</Change>
|
<Change>[Bug: #1459] Fixed: get link disabled</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-9-0"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-9-0"
|
||||||
date="2015-10-30">
|
date="2015-10-30">
|
||||||
<Change>[Bug #718] Fixed breadcrumb path</Change>
|
<Change>[Bug #718] Fixed breadcrumb path</Change>
|
||||||
<Change>[Bug #546] Fixed bug</Change>
|
<Change>[Bug #546] Fixed bug</Change>
|
||||||
|
@ -231,7 +259,8 @@
|
||||||
after an delete multiple
|
after an delete multiple
|
||||||
</Change>
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-8-0"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-8-0"
|
||||||
date="2015-07-06">
|
date="2015-07-06">
|
||||||
<Change>[Feature #129] Porting to HL 2.0
|
<Change>[Feature #129] Porting to HL 2.0
|
||||||
</Change>
|
</Change>
|
||||||
|
@ -239,12 +268,14 @@
|
||||||
complete link
|
complete link
|
||||||
</Change>
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-7-2"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-7-2"
|
||||||
date="2015-04-15">
|
date="2015-04-15">
|
||||||
<Change>Integrated with Contact Edit Permissions
|
<Change>Integrated with Contact Edit Permissions
|
||||||
</Change>
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-7-1"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-7-1"
|
||||||
date="2014-10-29">
|
date="2014-10-29">
|
||||||
<Change>Added user storage usage
|
<Change>Added user storage usage
|
||||||
</Change>
|
</Change>
|
||||||
|
@ -252,14 +283,16 @@
|
||||||
shared folder
|
shared folder
|
||||||
</Change>
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-6-7"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-6-7"
|
||||||
date="2014-09-01">
|
date="2014-09-01">
|
||||||
<Change>Support Ticket #813: Broken Breadcrumb for long path
|
<Change>Support Ticket #813: Broken Breadcrumb for long path
|
||||||
</Change>
|
</Change>
|
||||||
<Change>Ticket #3053: Load current ACL stored to Shared Folder
|
<Change>Ticket #3053: Load current ACL stored to Shared Folder
|
||||||
</Change>
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-6-6"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-6-6"
|
||||||
date="2014-07-02">
|
date="2014-07-02">
|
||||||
<Change>#2798 Sharing Panel usability improved
|
<Change>#2798 Sharing Panel usability improved
|
||||||
</Change>
|
</Change>
|
||||||
|
@ -267,7 +300,8 @@
|
||||||
https://support.social.isti.cnr.it/ticket/126
|
https://support.social.isti.cnr.it/ticket/126
|
||||||
</Change>
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-6-5"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-6-5"
|
||||||
date="2014-06-04">
|
date="2014-06-04">
|
||||||
<Change>Added Trash:
|
<Change>Added Trash:
|
||||||
https://issue.imarine.research-infrastructures.eu/ticket/2497
|
https://issue.imarine.research-infrastructures.eu/ticket/2497
|
||||||
|
@ -276,7 +310,8 @@
|
||||||
3.2)
|
3.2)
|
||||||
</Change>
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-6-4"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-6-4"
|
||||||
date="2014-05-22">
|
date="2014-05-22">
|
||||||
<Change>Fixed:
|
<Change>Fixed:
|
||||||
https://support.d4science.research-infrastructures.eu/ticket/843
|
https://support.d4science.research-infrastructures.eu/ticket/843
|
||||||
|
@ -285,12 +320,14 @@
|
||||||
https://issue.imarine.research-infrastructures.eu/ticket/282
|
https://issue.imarine.research-infrastructures.eu/ticket/282
|
||||||
</Change>
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-6-2"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-6-2"
|
||||||
date="2014-3-17">
|
date="2014-3-17">
|
||||||
<Change>Management of My Special Folder</Change>
|
<Change>Management of My Special Folder</Change>
|
||||||
<Change>Added change permissions to VRE shared folder</Change>
|
<Change>Added change permissions to VRE shared folder</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-6-0"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-6-0"
|
||||||
date="2014-2-07">
|
date="2014-2-07">
|
||||||
<Change>#2634 Workspace: support for setting permissions over shared
|
<Change>#2634 Workspace: support for setting permissions over shared
|
||||||
folders
|
folders
|
||||||
|
@ -300,18 +337,21 @@
|
||||||
session validation
|
session validation
|
||||||
</Change>
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-5-1"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-5-1"
|
||||||
date="2013-12-12">
|
date="2013-12-12">
|
||||||
<Change>Changed several labels into Logger
|
<Change>Changed several labels into Logger
|
||||||
</Change>
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-5-0"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-5-0"
|
||||||
date="2013-10-21">
|
date="2013-10-21">
|
||||||
<Change>#Ticket 2223. This project was enhancements to gwt 2.5.1
|
<Change>#Ticket 2223. This project was enhancements to gwt 2.5.1
|
||||||
</Change>
|
</Change>
|
||||||
<Change>GCF dependency was removed</Change>
|
<Change>GCF dependency was removed</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-4-0"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-4-0"
|
||||||
date="2013-09-16">
|
date="2013-09-16">
|
||||||
<Change>Provide support for public link, Related ticket: #1993
|
<Change>Provide support for public link, Related ticket: #1993
|
||||||
</Change>
|
</Change>
|
||||||
|
@ -320,20 +360,23 @@
|
||||||
</Change>
|
</Change>
|
||||||
<Change>Fixed bug on shared links, Ticket #630 </Change>
|
<Change>Fixed bug on shared links, Ticket #630 </Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-3-0"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-3-0"
|
||||||
date="2013-07-08">
|
date="2013-07-08">
|
||||||
<Change>Provide support for share link, Related ticket: #1504</Change>
|
<Change>Provide support for share link, Related ticket: #1504</Change>
|
||||||
<Change>Edit description on sharing, Related ticket: #1822 </Change>
|
<Change>Edit description on sharing, Related ticket: #1822 </Change>
|
||||||
<Change>Bugs fixed, Related Tickets: #628, #633, #630</Change>
|
<Change>Bugs fixed, Related Tickets: #628, #633, #630</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-2-0"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-2-0"
|
||||||
date="2013-05-29">
|
date="2013-05-29">
|
||||||
<Change>Provide support for accounting, related ticket: #1752</Change>
|
<Change>Provide support for accounting, related ticket: #1752</Change>
|
||||||
<Change>Enable notification for file upload in shared folder, related
|
<Change>Enable notification for file upload in shared folder, related
|
||||||
ticket: #1732
|
ticket: #1732
|
||||||
</Change>
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-1-0"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-1-0"
|
||||||
date="2013-04-19">
|
date="2013-04-19">
|
||||||
<Change>Workspace portlet was enhanced to meet the requests coming
|
<Change>Workspace portlet was enhanced to meet the requests coming
|
||||||
from the User Community
|
from the User Community
|
||||||
|
@ -342,20 +385,23 @@
|
||||||
#1497, #1536
|
#1497, #1536
|
||||||
</Change>
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-0-0"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.6-0-0"
|
||||||
date="2013-03-05">
|
date="2013-03-05">
|
||||||
<Change>#1247 The workspace tree was mavenized</Change>
|
<Change>#1247 The workspace tree was mavenized</Change>
|
||||||
<Change>#230, #205 The Workspace environment now supports the sharing
|
<Change>#230, #205 The Workspace environment now supports the sharing
|
||||||
of folder between users
|
of folder between users
|
||||||
</Change>
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.5-1-0"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.5-1-0"
|
||||||
date="2012-09-21">
|
date="2012-09-21">
|
||||||
<Change>Old Send Message removed, added support for new mail sender
|
<Change>Old Send Message removed, added support for new mail sender
|
||||||
</Change>
|
</Change>
|
||||||
<Change>Bug fixed: upload file/archive</Change>
|
<Change>Bug fixed: upload file/archive</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.5-0-0"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.5-0-0"
|
||||||
date="2012-05-04">
|
date="2012-05-04">
|
||||||
<Change>#216 New version of Workspace Tree is developed using the GXT
|
<Change>#216 New version of Workspace Tree is developed using the GXT
|
||||||
framework
|
framework
|
||||||
|
@ -363,38 +409,45 @@
|
||||||
<Change>#216 New tree is asynchronous</Change>
|
<Change>#216 New tree is asynchronous</Change>
|
||||||
<Change>#216 Reviews tree GUI and adding new features</Change>
|
<Change>#216 Reviews tree GUI and adding new features</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.4-3-0"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.4-3-0"
|
||||||
date="2011-09-01">
|
date="2011-09-01">
|
||||||
<Change>#1740: ICIS / Download csv / added extension .xlw</Change>
|
<Change>#1740: ICIS / Download csv / added extension .xlw</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.4-2-0"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.4-2-0"
|
||||||
date="2011-07-01">
|
date="2011-07-01">
|
||||||
<Change>#1555: WorkflowTemplate and WorkflowReport required in
|
<Change>#1555: WorkflowTemplate and WorkflowReport required in
|
||||||
Workspace Portlet
|
Workspace Portlet
|
||||||
</Change>
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.4-1-0"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.4-1-0"
|
||||||
date="2011-05-06">
|
date="2011-05-06">
|
||||||
<Change>Synch with others changes in HomeLibrary</Change>
|
<Change>Synch with others changes in HomeLibrary</Change>
|
||||||
<Change>GWT 2.2.0</Change>
|
<Change>GWT 2.2.0</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.4-0-0"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.4-0-0"
|
||||||
date="2011-02-07">
|
date="2011-02-07">
|
||||||
<Change>Removed Workspace and Basket type, replaced with folder option
|
<Change>Removed Workspace and Basket type, replaced with folder option
|
||||||
</Change>
|
</Change>
|
||||||
<Change>Synch with others changes in HomeLibrary</Change>
|
<Change>Synch with others changes in HomeLibrary</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.3-2-1"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.3-2-1"
|
||||||
date="2010-11-09">
|
date="2010-11-09">
|
||||||
<Change>Added more checks on GWT model construction</Change>
|
<Change>Added more checks on GWT model construction</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.3-2-0"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.3-2-0"
|
||||||
date="2010-10-22">
|
date="2010-10-22">
|
||||||
<Change>Enabled details panel for Report, ReportTemplate and
|
<Change>Enabled details panel for Report, ReportTemplate and
|
||||||
AquaMapsItem workspace items
|
AquaMapsItem workspace items
|
||||||
</Change>
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.3-1-0"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.3-1-0"
|
||||||
date="2010-09-03">
|
date="2010-09-03">
|
||||||
<Change>#36: ICIS / Workspace / Upload an archive</Change>
|
<Change>#36: ICIS / Workspace / Upload an archive</Change>
|
||||||
<Change>Merged ThumbnailServlet and ImageServlet</Change>
|
<Change>Merged ThumbnailServlet and ImageServlet</Change>
|
||||||
|
@ -402,13 +455,15 @@
|
||||||
link not working
|
link not working
|
||||||
</Change>
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.3-0-0"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.3-0-0"
|
||||||
date="2010-07-16">
|
date="2010-07-16">
|
||||||
<Change>Ported to GWT 2.0</Change>
|
<Change>Ported to GWT 2.0</Change>
|
||||||
<Change>Updated project structure to WebPortlet</Change>
|
<Change>Updated project structure to WebPortlet</Change>
|
||||||
<Change>Update to LifeRay portal</Change>
|
<Change>Update to LifeRay portal</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.2-6-0"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.2-6-0"
|
||||||
date="2010-05-14">
|
date="2010-05-14">
|
||||||
<Change>#424: Workspace code refactoring an enanchement</Change>
|
<Change>#424: Workspace code refactoring an enanchement</Change>
|
||||||
<Change>refactored code</Change>
|
<Change>refactored code</Change>
|
||||||
|
@ -417,35 +472,43 @@
|
||||||
Report Template
|
Report Template
|
||||||
</Change>
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.2-5-0"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.2-5-0"
|
||||||
date="2010-01-29">
|
date="2010-01-29">
|
||||||
<Change>gcube release 1.7.0</Change>
|
<Change>gcube release 1.7.0</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.2-4-0"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.2-4-0"
|
||||||
date="2009-11-30">
|
date="2009-11-30">
|
||||||
<Change>gcube release 1.6.0</Change>
|
<Change>gcube release 1.6.0</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.2-3-0"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.2-3-0"
|
||||||
date="2009-11-16">
|
date="2009-11-16">
|
||||||
<Change>gcube release 1.5.0</Change>
|
<Change>gcube release 1.5.0</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.2-2-0"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.2-2-0"
|
||||||
date="2009-10-16">
|
date="2009-10-16">
|
||||||
<Change>gcube release</Change>
|
<Change>gcube release</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.2-1-1"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.2-1-1"
|
||||||
date="2009-07-29">
|
date="2009-07-29">
|
||||||
<Change>gcube release 1.2.2</Change>
|
<Change>gcube release 1.2.2</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.2-1-0"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.2-1-0"
|
||||||
date="2009-07-14">
|
date="2009-07-14">
|
||||||
<Change>gcube release 1.2.0</Change>
|
<Change>gcube release 1.2.0</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.2-0-0"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.2-0-0"
|
||||||
date="2009-05-19">
|
date="2009-05-19">
|
||||||
<Change>gcube release 1.2.0 rc1</Change>
|
<Change>gcube release 1.2.0 rc1</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.1-1-2"
|
<Changeset
|
||||||
|
component="org.gcube.portlets-user.workspace-portlet-tree.1-1-2"
|
||||||
date="2009-01-12">
|
date="2009-01-12">
|
||||||
<Change>first release</Change>
|
<Change>first release</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
|
|
91
pom.xml
91
pom.xml
|
@ -131,20 +131,6 @@
|
||||||
<artifactId>ws-thredds-sync-widget</artifactId>
|
<artifactId>ws-thredds-sync-widget</artifactId>
|
||||||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<artifactId>home-library-model</artifactId>
|
|
||||||
<groupId>org.gcube.common</groupId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<artifactId>home-library-jcr</artifactId>
|
|
||||||
<groupId>org.gcube.common</groupId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<artifactId>home-library</artifactId>
|
|
||||||
<groupId>org.gcube.common</groupId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- FWS -->
|
<!-- FWS -->
|
||||||
|
@ -192,34 +178,41 @@
|
||||||
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
|
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.tika</groupId>
|
||||||
|
<artifactId>tika-core</artifactId>
|
||||||
|
<version>1.21</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- HOME LIBRARY -->
|
<!-- HOME LIBRARY -->
|
||||||
<dependency>
|
<!-- <dependency> -->
|
||||||
<groupId>org.gcube.common</groupId>
|
<!-- <groupId>org.gcube.common</groupId> -->
|
||||||
<artifactId>home-library-model</artifactId>
|
<!-- <artifactId>home-library-model</artifactId> -->
|
||||||
<scope>provided</scope>
|
<!-- <scope>provided</scope> -->
|
||||||
</dependency>
|
<!-- </dependency> -->
|
||||||
<dependency>
|
<!-- <dependency> -->
|
||||||
<groupId>org.gcube.common</groupId>
|
<!-- <groupId>org.gcube.common</groupId> -->
|
||||||
<artifactId>home-library-jcr</artifactId>
|
<!-- <artifactId>home-library-jcr</artifactId> -->
|
||||||
<scope>provided</scope>
|
<!-- <scope>provided</scope> -->
|
||||||
<exclusions>
|
<!-- <exclusions> -->
|
||||||
<exclusion>
|
<!-- <exclusion> -->
|
||||||
<artifactId>asm-debug-all</artifactId>
|
<!-- <artifactId>asm-debug-all</artifactId> -->
|
||||||
<groupId>org.ow2.asm</groupId>
|
<!-- <groupId>org.ow2.asm</groupId> -->
|
||||||
</exclusion>
|
<!-- </exclusion> -->
|
||||||
</exclusions>
|
<!-- </exclusions> -->
|
||||||
</dependency>
|
<!-- </dependency> -->
|
||||||
<dependency>
|
<!-- <dependency> -->
|
||||||
<groupId>org.gcube.common</groupId>
|
<!-- <groupId>org.gcube.common</groupId> -->
|
||||||
<artifactId>home-library</artifactId>
|
<!-- <artifactId>home-library</artifactId> -->
|
||||||
<scope>provided</scope>
|
<!-- <scope>provided</scope> -->
|
||||||
<exclusions>
|
<!-- <exclusions> -->
|
||||||
<exclusion>
|
<!-- <exclusion> -->
|
||||||
<artifactId>asm-all</artifactId>
|
<!-- <artifactId>asm-all</artifactId> -->
|
||||||
<groupId>asm</groupId>
|
<!-- <groupId>asm</groupId> -->
|
||||||
</exclusion>
|
<!-- </exclusion> -->
|
||||||
</exclusions>
|
<!-- </exclusions> -->
|
||||||
</dependency>
|
<!-- </dependency> -->
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.portlets.widgets</groupId>
|
<groupId>org.gcube.portlets.widgets</groupId>
|
||||||
|
@ -269,20 +262,14 @@
|
||||||
<artifactId>commons-io</artifactId>
|
<artifactId>commons-io</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- LOGGER -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>log4j</groupId>
|
|
||||||
<artifactId>log4j</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.slf4j</groupId>
|
|
||||||
<artifactId>slf4j-log4j12</artifactId>
|
|
||||||
<scope>runtime</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
<scope>runtime</scope>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-log4j12</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -48,8 +48,6 @@ import org.gcube.portlets.user.workspace.client.event.FileDownloadEvent.Download
|
||||||
import org.gcube.portlets.user.workspace.client.event.FileDownloadEventHandler;
|
import org.gcube.portlets.user.workspace.client.event.FileDownloadEventHandler;
|
||||||
import org.gcube.portlets.user.workspace.client.event.FileUploadEvent;
|
import org.gcube.portlets.user.workspace.client.event.FileUploadEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.FileUploadEventHandler;
|
import org.gcube.portlets.user.workspace.client.event.FileUploadEventHandler;
|
||||||
import org.gcube.portlets.user.workspace.client.event.FilterScopeEvent;
|
|
||||||
import org.gcube.portlets.user.workspace.client.event.FilterScopeEventHandler;
|
|
||||||
import org.gcube.portlets.user.workspace.client.event.GetFolderLinkEvent;
|
import org.gcube.portlets.user.workspace.client.event.GetFolderLinkEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.GetFolderLinkEventHandler;
|
import org.gcube.portlets.user.workspace.client.event.GetFolderLinkEventHandler;
|
||||||
import org.gcube.portlets.user.workspace.client.event.GetInfoEvent;
|
import org.gcube.portlets.user.workspace.client.event.GetInfoEvent;
|
||||||
|
@ -61,12 +59,12 @@ import org.gcube.portlets.user.workspace.client.event.GetSharedLinkEventHandler;
|
||||||
import org.gcube.portlets.user.workspace.client.event.ImagePreviewEvent;
|
import org.gcube.portlets.user.workspace.client.event.ImagePreviewEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.ImagePreviewEventHandler;
|
import org.gcube.portlets.user.workspace.client.event.ImagePreviewEventHandler;
|
||||||
import org.gcube.portlets.user.workspace.client.event.LoadFolderEvent;
|
import org.gcube.portlets.user.workspace.client.event.LoadFolderEvent;
|
||||||
|
import org.gcube.portlets.user.workspace.client.event.LoadTreeEvent;
|
||||||
|
import org.gcube.portlets.user.workspace.client.event.LoadTreeEventHandler;
|
||||||
import org.gcube.portlets.user.workspace.client.event.MoveItemsEvent;
|
import org.gcube.portlets.user.workspace.client.event.MoveItemsEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.MoveItemsEventHandler;
|
import org.gcube.portlets.user.workspace.client.event.MoveItemsEventHandler;
|
||||||
import org.gcube.portlets.user.workspace.client.event.OpenContextMenuTreeEvent;
|
import org.gcube.portlets.user.workspace.client.event.OpenContextMenuTreeEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.OpenContextMenuTreeEventHandler;
|
import org.gcube.portlets.user.workspace.client.event.OpenContextMenuTreeEventHandler;
|
||||||
import org.gcube.portlets.user.workspace.client.event.OpenReportsEvent;
|
|
||||||
import org.gcube.portlets.user.workspace.client.event.OpenReportsEventHandler;
|
|
||||||
import org.gcube.portlets.user.workspace.client.event.OpenUrlEvent;
|
import org.gcube.portlets.user.workspace.client.event.OpenUrlEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.OpenUrlEventHandler;
|
import org.gcube.portlets.user.workspace.client.event.OpenUrlEventHandler;
|
||||||
import org.gcube.portlets.user.workspace.client.event.PublishOnDataCatalogueEvent;
|
import org.gcube.portlets.user.workspace.client.event.PublishOnDataCatalogueEvent;
|
||||||
|
@ -101,8 +99,6 @@ import org.gcube.portlets.user.workspace.client.event.VRESettingPermissionEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.VRESettingPermissionEventHandler;
|
import org.gcube.portlets.user.workspace.client.event.VRESettingPermissionEventHandler;
|
||||||
import org.gcube.portlets.user.workspace.client.event.VersioningHistoryShowEvent;
|
import org.gcube.portlets.user.workspace.client.event.VersioningHistoryShowEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.VersioningHistoryShowEventHandler;
|
import org.gcube.portlets.user.workspace.client.event.VersioningHistoryShowEventHandler;
|
||||||
import org.gcube.portlets.user.workspace.client.event.WebDavUrlEvent;
|
|
||||||
import org.gcube.portlets.user.workspace.client.event.WebDavUrlEventHandler;
|
|
||||||
import org.gcube.portlets.user.workspace.client.interfaces.EventsTypeEnum;
|
import org.gcube.portlets.user.workspace.client.interfaces.EventsTypeEnum;
|
||||||
import org.gcube.portlets.user.workspace.client.interfaces.GXTFolderItemTypeEnum;
|
import org.gcube.portlets.user.workspace.client.interfaces.GXTFolderItemTypeEnum;
|
||||||
import org.gcube.portlets.user.workspace.client.interfaces.GuiEventInterface;
|
import org.gcube.portlets.user.workspace.client.interfaces.GuiEventInterface;
|
||||||
|
@ -110,7 +106,6 @@ import org.gcube.portlets.user.workspace.client.interfaces.SubscriberInterface;
|
||||||
import org.gcube.portlets.user.workspace.client.interfaces.TreeAppControllerInterface;
|
import org.gcube.portlets.user.workspace.client.interfaces.TreeAppControllerInterface;
|
||||||
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||||||
import org.gcube.portlets.user.workspace.client.model.FolderModel;
|
import org.gcube.portlets.user.workspace.client.model.FolderModel;
|
||||||
import org.gcube.portlets.user.workspace.client.model.SmartFolderModel;
|
|
||||||
import org.gcube.portlets.user.workspace.client.model.SubTree;
|
import org.gcube.portlets.user.workspace.client.model.SubTree;
|
||||||
import org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService;
|
import org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService;
|
||||||
import org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceServiceAsync;
|
import org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceServiceAsync;
|
||||||
|
@ -128,7 +123,6 @@ import org.gcube.portlets.user.workspace.client.view.windows.DialogGetLink;
|
||||||
import org.gcube.portlets.user.workspace.client.view.windows.DialogGetLink.Link_Type;
|
import org.gcube.portlets.user.workspace.client.view.windows.DialogGetLink.Link_Type;
|
||||||
import org.gcube.portlets.user.workspace.client.view.windows.DialogShareLink;
|
import org.gcube.portlets.user.workspace.client.view.windows.DialogShareLink;
|
||||||
import org.gcube.portlets.user.workspace.client.view.windows.DialogText;
|
import org.gcube.portlets.user.workspace.client.view.windows.DialogText;
|
||||||
import org.gcube.portlets.user.workspace.client.view.windows.DialogWebDavUrl;
|
|
||||||
import org.gcube.portlets.user.workspace.client.view.windows.ImagesPreviewController;
|
import org.gcube.portlets.user.workspace.client.view.windows.ImagesPreviewController;
|
||||||
import org.gcube.portlets.user.workspace.client.view.windows.InfoDisplayMessage;
|
import org.gcube.portlets.user.workspace.client.view.windows.InfoDisplayMessage;
|
||||||
import org.gcube.portlets.user.workspace.client.view.windows.MessageBoxAlert;
|
import org.gcube.portlets.user.workspace.client.view.windows.MessageBoxAlert;
|
||||||
|
@ -191,11 +185,11 @@ import com.google.gwt.user.client.ui.HasWidgets;
|
||||||
/**
|
/**
|
||||||
* The Class AppControllerExplorer.
|
* The Class AppControllerExplorer.
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it May 15, 2017
|
||||||
* May 15, 2017
|
|
||||||
*/
|
*/
|
||||||
public class AppControllerExplorer implements EventHandler, TreeAppControllerInterface {
|
public class AppControllerExplorer implements EventHandler, TreeAppControllerInterface {
|
||||||
|
|
||||||
|
private static final String METHOD_IS_NO_LONGER_USED = "method is no longer used";
|
||||||
public static final GWTWorkspaceServiceAsync rpcWorkspaceService = (GWTWorkspaceServiceAsync) GWT
|
public static final GWTWorkspaceServiceAsync rpcWorkspaceService = (GWTWorkspaceServiceAsync) GWT
|
||||||
.create(GWTWorkspaceService.class);
|
.create(GWTWorkspaceService.class);
|
||||||
private ExplorerPanel explorerPanel;
|
private ExplorerPanel explorerPanel;
|
||||||
|
@ -540,7 +534,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
// IF NOT CANCELLED
|
// IF NOT CANCELLED
|
||||||
String clickedButton = be.getButtonClicked().getItemId();
|
String clickedButton = be.getButtonClicked().getItemId();
|
||||||
if (clickedButton.equals(Dialog.YES)) {
|
if (clickedButton.equals(Dialog.YES)) {
|
||||||
GWT.log("Calling unSharedFolderByFolderSharedId for id: " + folderIdentification);
|
GWT.log("Calling unSharedFolderByFolderSharedId for id: "+folderIdentification);
|
||||||
explorerPanel.getAsycTreePanel().mask(ConstantsExplorer.UNSHARING,
|
explorerPanel.getAsycTreePanel().mask(ConstantsExplorer.UNSHARING,
|
||||||
ConstantsExplorer.LOADINGSTYLE);
|
ConstantsExplorer.LOADINGSTYLE);
|
||||||
WorkspaceSharingServiceAsync.INSTANCE.unSharedFolderByFolderSharedId(
|
WorkspaceSharingServiceAsync.INSTANCE.unSharedFolderByFolderSharedId(
|
||||||
|
@ -887,40 +881,6 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
eventBus.addHandler(WebDavUrlEvent.TYPE, new WebDavUrlEventHandler() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClickWebDavUrl(WebDavUrlEvent webDavUrlEvent) {
|
|
||||||
|
|
||||||
String itemIdentifier = webDavUrlEvent.getItemIdentifier();
|
|
||||||
if (itemIdentifier == null)
|
|
||||||
itemIdentifier = explorerPanel.getAsycTreePanel().getRootItem().getIdentifier();
|
|
||||||
|
|
||||||
rpcWorkspaceService.getUrlWebDav(itemIdentifier, new AsyncCallback<String>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {
|
|
||||||
new MessageBoxAlert("Error",
|
|
||||||
ConstantsExplorer.SERVER_ERROR + " viewing WebDAV url" + ConstantsExplorer.TRY_AGAIN,
|
|
||||||
null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSuccess(String url) {
|
|
||||||
// new MessageBoxInfo(ConstantsExplorer.URL_WEBDAV,
|
|
||||||
// url);
|
|
||||||
DialogWebDavUrl diag = new DialogWebDavUrl(
|
|
||||||
ConstantsExplorer.URL_WEBDAV + ": " + ConstantsExplorer.TITLEACCESSWEBDAV, "", url);
|
|
||||||
diag.selectTxt();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
eventBus.addHandler(GetShareLinkEvent.TYPE, new GetSharedLinkEventHandler() {
|
eventBus.addHandler(GetShareLinkEvent.TYPE, new GetSharedLinkEventHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1009,15 +969,6 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// eventBus.addHandler(CopyItemsEvent.TYPE, new CopyItemsEventHandler()
|
|
||||||
// {
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onCopyItems(CopyItemsEvent copytemEvent) {
|
|
||||||
// notifySubscriber(copytemEvent);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
eventBus.addHandler(CopyItemsEvent.TYPE, new CopyItemsEventHandler() {
|
eventBus.addHandler(CopyItemsEvent.TYPE, new CopyItemsEventHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1164,11 +1115,6 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
eventBus.fireEvent(new RefreshFolderEvent(folderDestionationInTree, true,
|
eventBus.fireEvent(new RefreshFolderEvent(folderDestionationInTree, true,
|
||||||
false, false));
|
false, false));
|
||||||
|
|
||||||
// if(folderDestionationInTree!=null)
|
|
||||||
// moveItemsEvent.setTreeRefreshable(true);
|
|
||||||
// else
|
|
||||||
// moveItemsEvent.setTreeRefreshable(false);
|
|
||||||
|
|
||||||
moveItemsEvent.setTreeRefreshable(false); // forcing
|
moveItemsEvent.setTreeRefreshable(false); // forcing
|
||||||
// grid
|
// grid
|
||||||
// refresh
|
// refresh
|
||||||
|
@ -1202,56 +1148,6 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
navigator.addWorkspaceExplorerSelectNotificationListener(listener);
|
navigator.addWorkspaceExplorerSelectNotificationListener(listener);
|
||||||
navigator.show();
|
navigator.show();
|
||||||
|
|
||||||
// break;
|
|
||||||
|
|
||||||
// case COPY:
|
|
||||||
//
|
|
||||||
// rpcWorkspaceService.copyItems(pasteItemEvent.getIds(),
|
|
||||||
// pasteItemEvent.getFolderDestinationId(), new
|
|
||||||
// AsyncCallback<Boolean>() {
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onFailure(Throwable caught) {
|
|
||||||
//
|
|
||||||
// if(caught instanceof SessionExpiredException){
|
|
||||||
// GWT.log("Session expired");
|
|
||||||
// eventBus.fireEvent(new SessionExpiredEvent());
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// new MessageBoxAlert("Error", caught.getMessage(), null);
|
|
||||||
//
|
|
||||||
// eventBus.fireEvent(new
|
|
||||||
// RefreshFolderEvent(explorerPanel.getAsycTreePanel().getFileModelByIdentifier(pasteItemEvent.getFolderDestinationId()),
|
|
||||||
// false, true, false));
|
|
||||||
//
|
|
||||||
// notifySubscriber(pasteItemEvent);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onSuccess(Boolean result) {
|
|
||||||
//
|
|
||||||
// FileModel fileInTree =
|
|
||||||
// explorerPanel.getAsycTreePanel().getFileModelByIdentifier(pasteItemEvent.getFolderDestinationId());
|
|
||||||
// if(result)
|
|
||||||
// eventBus.fireEvent(new RefreshFolderEvent(fileInTree, false,
|
|
||||||
// false, false));
|
|
||||||
//
|
|
||||||
// if(fileInTree!=null)
|
|
||||||
// pasteItemEvent.setTreeRefreshable(true);
|
|
||||||
// else
|
|
||||||
// pasteItemEvent.setTreeRefreshable(false);
|
|
||||||
//
|
|
||||||
// notifySubscriber(pasteItemEvent);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// });
|
|
||||||
|
|
||||||
// break;
|
|
||||||
|
|
||||||
// default:
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1263,28 +1159,19 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
eventBus.addHandler(FilterScopeEvent.TYPE, new FilterScopeEventHandler() {
|
eventBus.addHandler(LoadTreeEvent.TYPE, new LoadTreeEventHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClickScopeFilter(FilterScopeEvent filterScopeEvent) {
|
public void doLoadTree(LoadTreeEvent loadtreeEvent) {
|
||||||
|
selectRootItem = loadtreeEvent.isSelectRoot();
|
||||||
explorerPanel.getAsycTreePanel().setSearch(false); // SET IS
|
//SET IS SEARCH TO FALSE
|
||||||
// SEARCH
|
explorerPanel.getAsycTreePanel().setSearch(false);
|
||||||
// FALSE
|
// RELOAD TREE ROOT
|
||||||
|
explorerPanel.getAsycTreePanel().loadRootItem(selectRootItem);
|
||||||
doChangeScope(filterScopeEvent.getScopeId());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void doChangeScope(String scopeId) {
|
|
||||||
|
|
||||||
explorerPanel.getAsycTreePanel().loadRootItem(selectRootItem); // RELOAD
|
|
||||||
// ROOT
|
|
||||||
// BY
|
|
||||||
// SCOPE
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
eventBus.addHandler(AccountingHistoryEvent.TYPE, new AccountingHistoryEventHandler() {
|
eventBus.addHandler(AccountingHistoryEvent.TYPE, new AccountingHistoryEventHandler() {
|
||||||
|
|
||||||
|
@ -1545,42 +1432,8 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doDeleteSmartFolder(DeleteSmartFolderEvent deleteSmartFolderEvent) {
|
private void doDeleteSmartFolder(DeleteSmartFolderEvent deleteSmartFolderEvent) {
|
||||||
final String smartIdentifier = deleteSmartFolderEvent.getSmartIdentifier();
|
|
||||||
final String smartName = deleteSmartFolderEvent.getSmartName();
|
Window.alert("The method 'doDeleteSmartFolder' " +METHOD_IS_NO_LONGER_USED);
|
||||||
|
|
||||||
MessageBoxConfirm mbc = new MessageBoxConfirm(ConstantsExplorer.MESSAGE_DELETE,
|
|
||||||
ConstantsExplorer.MESSAGE_CONFIRM_DELETE_SMART_FOLDER + " " + smartName + "?");
|
|
||||||
mbc.getMessageBoxConfirm().addCallback(new Listener<MessageBoxEvent>() {
|
|
||||||
|
|
||||||
public void handleEvent(MessageBoxEvent be) {
|
|
||||||
|
|
||||||
// eventBus.fireEvent(new DeleteItemEvent(sel));
|
|
||||||
|
|
||||||
// IF NOT CANCELLED
|
|
||||||
String clickedButton = be.getButtonClicked().getItemId();
|
|
||||||
if (clickedButton.equals(Dialog.YES)) {
|
|
||||||
|
|
||||||
rpcWorkspaceService.removeSmartFolder(smartIdentifier, smartName,
|
|
||||||
new AsyncCallback<Boolean>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSuccess(Boolean result) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {
|
|
||||||
// explorerPanel.getAsycTreePanel().unmask();
|
|
||||||
new MessageBoxAlert("Error",
|
|
||||||
ConstantsExplorer.SERVER_ERROR + " deleting smart folder.", null);
|
|
||||||
explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot();
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1593,46 +1446,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doSaveSmartFolder(final AddSmartFolderEvent saveSmartFolderEvent) {
|
private void doSaveSmartFolder(final AddSmartFolderEvent saveSmartFolderEvent) {
|
||||||
|
Window.alert("The method 'doSaveSmartFolder' " +METHOD_IS_NO_LONGER_USED);
|
||||||
final String query = saveSmartFolderEvent.getSearchText();
|
|
||||||
final String parentId = saveSmartFolderEvent.getParentId();
|
|
||||||
|
|
||||||
final DialogAddFolderAndSmart dialogAddSmartFolder = new DialogAddFolderAndSmart("",
|
|
||||||
AddType.SMARTFOLDER);
|
|
||||||
|
|
||||||
dialogAddSmartFolder.getButtonById(Dialog.OK).addListener(Events.Select, new Listener<BaseEvent>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleEvent(BaseEvent be) {
|
|
||||||
|
|
||||||
if (dialogAddSmartFolder.isValidForm())
|
|
||||||
|
|
||||||
rpcWorkspaceService.createSmartFolder(dialogAddSmartFolder.getName(),
|
|
||||||
dialogAddSmartFolder.getDescription(), query, parentId,
|
|
||||||
new AsyncCallback<SmartFolderModel>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {
|
|
||||||
explorerPanel.getAsycTreePanel().unmask();
|
|
||||||
if (caught instanceof SessionExpiredException) {
|
|
||||||
GWT.log("Session expired");
|
|
||||||
eventBus.fireEvent(new SessionExpiredEvent());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
new MessageBoxAlert("Error",
|
|
||||||
ConstantsExplorer.SERVER_ERROR + " saving smart folder.", null);
|
|
||||||
explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSuccess(SmartFolderModel smart) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1686,11 +1500,10 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
eventBus.fireEvent(new SessionExpiredEvent());
|
eventBus.fireEvent(new SessionExpiredEvent());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (caught instanceof SHUBOperationNotAllowedException) {
|
if(caught instanceof SHUBOperationNotAllowedException) {
|
||||||
MessageBox.info("Operation not allowed...", caught.getMessage(), null)
|
MessageBox.info("Operation not allowed...", caught.getMessage(), null).show();
|
||||||
.show();
|
}else {
|
||||||
} else {
|
|
||||||
new MessageBoxAlert("Error", caught.getMessage(), null);
|
new MessageBoxAlert("Error", caught.getMessage(), null);
|
||||||
}
|
}
|
||||||
explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot();
|
explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot();
|
||||||
|
@ -1750,16 +1563,15 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
|
|
||||||
explorerPanel.getAsycTreePanel().unmask();
|
explorerPanel.getAsycTreePanel().unmask();
|
||||||
|
|
||||||
if (caught instanceof SHUBOperationNotAllowedException) {
|
if(caught instanceof SHUBOperationNotAllowedException) {
|
||||||
MessageBox.info("Operation not allowed...", caught.getMessage(), null)
|
MessageBox.info("Operation not allowed...", caught.getMessage(), null).show();
|
||||||
.show();
|
}else {
|
||||||
} else {
|
|
||||||
new MessageBoxAlert("Error", caught.getMessage(), null);
|
new MessageBoxAlert("Error", caught.getMessage(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot();
|
explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1945,16 +1757,14 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
}
|
}
|
||||||
|
|
||||||
new MessageBoxAlert("Error", caught.getMessage() + ".", null);
|
new MessageBoxAlert("Error", caught.getMessage() + ".", null);
|
||||||
|
|
||||||
// System.out.println(caught.getMessage());
|
// System.out.println(caught.getMessage());
|
||||||
// explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(
|
// explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(
|
||||||
// event.getTargetParentFileModel().getIdentifier(),
|
// event.getTargetParentFileModel().getIdentifier(), false);
|
||||||
// false);
|
// explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(
|
||||||
// explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(
|
// event.getFileSourceModel().getParentFileModel().getIdentifier(), true);
|
||||||
// event.getFileSourceModel().getParentFileModel().getIdentifier(),
|
|
||||||
// true);
|
//FXING THE ISSUE #16665
|
||||||
|
|
||||||
// FXING THE ISSUE #16665
|
|
||||||
explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot();
|
explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1965,7 +1775,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
|
|
||||||
if (result.getError() != null) {
|
if (result.getError() != null) {
|
||||||
new MessageBoxAlert("Error", result.getError(), null);
|
new MessageBoxAlert("Error", result.getError(), null);
|
||||||
// FXING THE ISSUE #16665
|
//FXING THE ISSUE #16665
|
||||||
explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot();
|
explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2121,97 +1931,6 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
eventBus.addHandler(OpenReportsEvent.TYPE, new OpenReportsEventHandler() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClickOpenReports(OpenReportsEvent openReportsEvent) {
|
|
||||||
|
|
||||||
if (openReportsEvent.getSourceFileModel().getGXTFolderItemType()
|
|
||||||
.equals(GXTFolderItemTypeEnum.REPORT_TEMPLATE))
|
|
||||||
doClickOpenReportTemplate(openReportsEvent);
|
|
||||||
else
|
|
||||||
doClickOpenReport(openReportsEvent);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void doClickOpenReport(OpenReportsEvent openReportsEvent) {
|
|
||||||
|
|
||||||
final NewBrowserWindow newBrowserWindow = NewBrowserWindow.open("", "_self", "");
|
|
||||||
|
|
||||||
rpcWorkspaceService.getURLFromApplicationProfile(openReportsEvent.getSourceFileModel().getIdentifier(),
|
|
||||||
new AsyncCallback<String>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {
|
|
||||||
new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR
|
|
||||||
+ " getting application profile - attribute idreport", null);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSuccess(String url) {
|
|
||||||
|
|
||||||
if (url == null || url.isEmpty()) {
|
|
||||||
String currentUrl = portalURL();
|
|
||||||
int last = currentUrl.lastIndexOf("/");
|
|
||||||
String reportUrl = currentUrl.substring(0, last + 1)
|
|
||||||
+ ConstantsExplorer.REPORTGENERATION;
|
|
||||||
// new WindowOpenUrl(reportUrl, "_self",
|
|
||||||
// "");
|
|
||||||
newBrowserWindow.setUrl(reportUrl);
|
|
||||||
} else {
|
|
||||||
String reportUrl = url;
|
|
||||||
// new WindowOpenUrl(reportUrl, "_self",
|
|
||||||
// "");
|
|
||||||
newBrowserWindow.setUrl(reportUrl);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void doClickOpenReportTemplate(OpenReportsEvent openReportTemplateEvent) {
|
|
||||||
|
|
||||||
final NewBrowserWindow newBrowserWindow = NewBrowserWindow.open("", "_self", "");
|
|
||||||
|
|
||||||
rpcWorkspaceService.getURLFromApplicationProfile(
|
|
||||||
openReportTemplateEvent.getSourceFileModel().getIdentifier(), new AsyncCallback<String>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {
|
|
||||||
new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR
|
|
||||||
+ " getting application profile - attribute idreport", null);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSuccess(String url) {
|
|
||||||
|
|
||||||
if (url == null || url.isEmpty()) {
|
|
||||||
String currentUrl = portalURL();
|
|
||||||
int last = currentUrl.lastIndexOf("/");
|
|
||||||
String templateUrl = currentUrl.substring(0, last + 1)
|
|
||||||
+ ConstantsExplorer.TEMPLATECREATION;
|
|
||||||
// Log.trace("Url: "+templateUrl);
|
|
||||||
GWT.log("currentUrl " + currentUrl);
|
|
||||||
GWT.log("reportUrl " + templateUrl);
|
|
||||||
newBrowserWindow.setUrl(templateUrl);
|
|
||||||
// new WindowOpenUrl(templateUrl, "_self",
|
|
||||||
// "");
|
|
||||||
} else {
|
|
||||||
|
|
||||||
String templateUrl = url;
|
|
||||||
newBrowserWindow.setUrl(templateUrl);
|
|
||||||
// new WindowOpenUrl(templateUrl, "_self",
|
|
||||||
// "");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2733,7 +2452,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
MultiDragConstants.SHARE_WITH_RIGHT_LIST = "New Administrator/s";
|
MultiDragConstants.SHARE_WITH_RIGHT_LIST = "New Administrator/s";
|
||||||
|
|
||||||
final MultiDragWorkspaceContactAdmin multiDragContactAdmin = new MultiDragWorkspaceContactAdmin(
|
final MultiDragWorkspaceContactAdmin multiDragContactAdmin = new MultiDragWorkspaceContactAdmin(
|
||||||
file.getIdentifier());
|
file.getIdentifier());
|
||||||
final Dialog multidrag = multiDragContactAdmin.getDialogMultiDragContact();
|
final Dialog multidrag = multiDragContactAdmin.getDialogMultiDragContact();
|
||||||
|
|
||||||
multidrag.getButtonById(Dialog.OK).addListener(Events.Select, new Listener<BaseEvent>() {
|
multidrag.getButtonById(Dialog.OK).addListener(Events.Select, new Listener<BaseEvent>() {
|
||||||
|
@ -3145,17 +2864,18 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
@Override
|
@Override
|
||||||
public void findItemAndSelectItemInTree(String itemIdentifier) {
|
public void findItemAndSelectItemInTree(String itemIdentifier) {
|
||||||
|
|
||||||
FileModel fileModel = this.explorerPanel.getAsycTreePanel().getFileModelByIdentifier(itemIdentifier);
|
// FileModel fileModel = this.explorerPanel.getAsycTreePanel().getFileModelByIdentifier(itemIdentifier);
|
||||||
|
//
|
||||||
if (fileModel == null) { // Loading item by RPC
|
// if (fileModel == null) { // Loading item by RPC
|
||||||
|
//
|
||||||
loadItemFromWorkspace(itemIdentifier);
|
// loadItemFromWorkspace(itemIdentifier);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
else {
|
// else {
|
||||||
|
//
|
||||||
selectItemInTree(itemIdentifier);
|
// selectItemInTree(itemIdentifier);
|
||||||
}
|
// }
|
||||||
|
Window.alert("the method findItemAndSelectItemInTree is no longer used");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
package org.gcube.portlets.user.workspace.client.event;
|
|
||||||
|
|
||||||
import com.google.gwt.event.shared.GwtEvent;
|
|
||||||
|
|
||||||
public class FilterScopeEvent extends GwtEvent<FilterScopeEventHandler> {
|
|
||||||
public static Type<FilterScopeEventHandler> TYPE = new Type<FilterScopeEventHandler>();
|
|
||||||
private String scopeId;
|
|
||||||
|
|
||||||
|
|
||||||
public FilterScopeEvent(String scopeId) {
|
|
||||||
this.scopeId = scopeId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Type<FilterScopeEventHandler> getAssociatedType() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void dispatch(FilterScopeEventHandler handler) {
|
|
||||||
handler.onClickScopeFilter(this);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getScopeId() {
|
|
||||||
return scopeId;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
package org.gcube.portlets.user.workspace.client.event;
|
|
||||||
|
|
||||||
import com.google.gwt.event.shared.EventHandler;
|
|
||||||
|
|
||||||
public interface FilterScopeEventHandler extends EventHandler {
|
|
||||||
void onClickScopeFilter(FilterScopeEvent filterScopeEvent);
|
|
||||||
}
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
package org.gcube.portlets.user.workspace.client.event;
|
||||||
|
|
||||||
|
import com.google.gwt.event.shared.GwtEvent;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class LoadTreeEvent.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
|
*
|
||||||
|
* Jul 31, 2019
|
||||||
|
*/
|
||||||
|
public class LoadTreeEvent extends GwtEvent<LoadTreeEventHandler> {
|
||||||
|
public static Type<LoadTreeEventHandler> TYPE = new Type<LoadTreeEventHandler>();
|
||||||
|
private boolean selectRoot;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new load tree event.
|
||||||
|
*
|
||||||
|
* @param selectRoot the select root
|
||||||
|
*/
|
||||||
|
public LoadTreeEvent(boolean selectRoot) {
|
||||||
|
this.selectRoot = selectRoot;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see com.google.gwt.event.shared.GwtEvent#getAssociatedType()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Type<LoadTreeEventHandler> getAssociatedType() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.EventHandler)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void dispatch(LoadTreeEventHandler handler) {
|
||||||
|
handler.doLoadTree(this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if is select root.
|
||||||
|
*
|
||||||
|
* @return true, if is select root
|
||||||
|
*/
|
||||||
|
public boolean isSelectRoot() {
|
||||||
|
return selectRoot;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package org.gcube.portlets.user.workspace.client.event;
|
||||||
|
|
||||||
|
import com.google.gwt.event.shared.EventHandler;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Interface LoadTreeEventHandler.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
|
*
|
||||||
|
* Jul 31, 2019
|
||||||
|
*/
|
||||||
|
public interface LoadTreeEventHandler extends EventHandler {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do load tree.
|
||||||
|
*
|
||||||
|
* @param loadTreeEvent the load tree event
|
||||||
|
*/
|
||||||
|
void doLoadTree(LoadTreeEvent loadTreeEvent);
|
||||||
|
}
|
|
@ -1,35 +0,0 @@
|
||||||
package org.gcube.portlets.user.workspace.client.event;
|
|
||||||
|
|
||||||
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
|
||||||
|
|
||||||
import com.google.gwt.event.shared.GwtEvent;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class OpenReportsEvent extends GwtEvent<OpenReportsEventHandler> {
|
|
||||||
public static Type<OpenReportsEventHandler> TYPE = new Type<OpenReportsEventHandler>();
|
|
||||||
|
|
||||||
private FileModel sourceFileModel = null; //Report template
|
|
||||||
|
|
||||||
public OpenReportsEvent(FileModel fileSourceModel) {
|
|
||||||
this.sourceFileModel = fileSourceModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Type<OpenReportsEventHandler> getAssociatedType() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void dispatch(OpenReportsEventHandler handler) {
|
|
||||||
handler.onClickOpenReports(this);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public FileModel getSourceFileModel() {
|
|
||||||
return sourceFileModel;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
package org.gcube.portlets.user.workspace.client.event;
|
|
||||||
|
|
||||||
import com.google.gwt.event.shared.EventHandler;
|
|
||||||
|
|
||||||
public interface OpenReportsEventHandler extends EventHandler {
|
|
||||||
void onClickOpenReports(OpenReportsEvent openReportTemplateEvent);
|
|
||||||
}
|
|
|
@ -12,9 +12,9 @@ public enum GXTFolderItemTypeEnum implements Serializable {
|
||||||
EXTERNAL_PDF_FILE("External PDF File"),
|
EXTERNAL_PDF_FILE("External PDF File"),
|
||||||
EXTERNAL_URL("External Url"),
|
EXTERNAL_URL("External Url"),
|
||||||
EXTERNAL_RESOURCE_LINK("Exteranl Resource Link"),
|
EXTERNAL_RESOURCE_LINK("Exteranl Resource Link"),
|
||||||
QUERY("Query"),
|
// QUERY("Query"),
|
||||||
REPORT("Report"),
|
// REPORT("Report"),
|
||||||
REPORT_TEMPLATE("Report Template"),
|
// REPORT_TEMPLATE("Report Template"),
|
||||||
TIME_SERIES("Time Series"),
|
TIME_SERIES("Time Series"),
|
||||||
DOCUMENT("Document"),
|
DOCUMENT("Document"),
|
||||||
IMAGE_DOCUMENT("Image Document"),
|
IMAGE_DOCUMENT("Image Document"),
|
||||||
|
|
|
@ -22,7 +22,9 @@ public interface TreeAppControllerInterface {
|
||||||
boolean reloadFolderChildren(String itemIdentifier);
|
boolean reloadFolderChildren(String itemIdentifier);
|
||||||
List<FileModel> getListParentsByIdentifierFromTree(String itemIdentifier);
|
List<FileModel> getListParentsByIdentifierFromTree(String itemIdentifier);
|
||||||
void setVisualizationType(VisualizationType type);
|
void setVisualizationType(VisualizationType type);
|
||||||
void findItemAndSelectItemInTree(String itemIdentifier);
|
|
||||||
|
void findItemAndSelectItemInTree(String itemIdentifier); //this method is no longer used
|
||||||
|
|
||||||
void expandFolder(String itemIdentifier);
|
void expandFolder(String itemIdentifier);
|
||||||
void searching(boolean isSearch);
|
void searching(boolean isSearch);
|
||||||
void selectRootItem();
|
void selectRootItem();
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class ExtendedInfoContactModel extends InfoContactModel {
|
||||||
|
|
||||||
public ExtendedInfoContactModel() {}
|
public ExtendedInfoContactModel() {}
|
||||||
|
|
||||||
public ExtendedInfoContactModel(String id, String login, String fullName, String emailDomain,boolean isGroup) {
|
public ExtendedInfoContactModel(String id, String login, String fullName, String emailDomain, boolean isGroup) {
|
||||||
super(id, login, fullName, emailDomain, isGroup);
|
super(id, login, fullName, emailDomain, isGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1455,10 +1455,6 @@ public class Resources {
|
||||||
// return Resources.getIconTable();
|
// return Resources.getIconTable();
|
||||||
}else if(itemType.equals(GXTFolderItemTypeEnum.TIME_SERIES)){
|
}else if(itemType.equals(GXTFolderItemTypeEnum.TIME_SERIES)){
|
||||||
return Resources.getIconTimeSeries();
|
return Resources.getIconTimeSeries();
|
||||||
}else if(itemType.equals(GXTFolderItemTypeEnum.REPORT)){
|
|
||||||
return Resources.getIconReport();
|
|
||||||
}else if(itemType.equals(GXTFolderItemTypeEnum.REPORT_TEMPLATE)){
|
|
||||||
return Resources.getIconReportTemplate();
|
|
||||||
}else if(itemType.equals(GXTFolderItemTypeEnum.URL_DOCUMENT)){
|
}else if(itemType.equals(GXTFolderItemTypeEnum.URL_DOCUMENT)){
|
||||||
return Resources.getIconLink();
|
return Resources.getIconLink();
|
||||||
}else if(itemType.equals(GXTFolderItemTypeEnum.EXTERNAL_RESOURCE_LINK)){
|
}else if(itemType.equals(GXTFolderItemTypeEnum.EXTERNAL_RESOURCE_LINK)){
|
||||||
|
|
|
@ -5,15 +5,12 @@ import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.gcube.portlets.user.workspace.client.interfaces.GXTCategorySmartFolder;
|
|
||||||
import org.gcube.portlets.user.workspace.client.model.FileGridModel;
|
import org.gcube.portlets.user.workspace.client.model.FileGridModel;
|
||||||
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||||||
import org.gcube.portlets.user.workspace.client.model.FileTrashedModel;
|
import org.gcube.portlets.user.workspace.client.model.FileTrashedModel;
|
||||||
import org.gcube.portlets.user.workspace.client.model.FileVersionModel;
|
import org.gcube.portlets.user.workspace.client.model.FileVersionModel;
|
||||||
import org.gcube.portlets.user.workspace.client.model.FolderModel;
|
import org.gcube.portlets.user.workspace.client.model.FolderModel;
|
||||||
import org.gcube.portlets.user.workspace.client.model.GcubeVRE;
|
import org.gcube.portlets.user.workspace.client.model.GcubeVRE;
|
||||||
import org.gcube.portlets.user.workspace.client.model.ScopeModel;
|
|
||||||
import org.gcube.portlets.user.workspace.client.model.SmartFolderModel;
|
|
||||||
import org.gcube.portlets.user.workspace.client.model.SubTree;
|
import org.gcube.portlets.user.workspace.client.model.SubTree;
|
||||||
import org.gcube.portlets.user.workspace.client.workspace.GWTWorkspaceItem;
|
import org.gcube.portlets.user.workspace.client.workspace.GWTWorkspaceItem;
|
||||||
import org.gcube.portlets.user.workspace.shared.GarbageItem;
|
import org.gcube.portlets.user.workspace.shared.GarbageItem;
|
||||||
|
@ -77,15 +74,6 @@ public interface GWTWorkspaceService extends RemoteService {
|
||||||
*/
|
*/
|
||||||
public FolderModel getRootForTree() throws Exception;
|
public FolderModel getRootForTree() throws Exception;
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the all scope.
|
|
||||||
*
|
|
||||||
* @return the all scope
|
|
||||||
* @throws Exception
|
|
||||||
* the exception
|
|
||||||
*/
|
|
||||||
public List<ScopeModel> getAllScope() throws Exception;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the folder children.
|
* Gets the folder children.
|
||||||
*
|
*
|
||||||
|
@ -139,53 +127,53 @@ public interface GWTWorkspaceService extends RemoteService {
|
||||||
*/
|
*/
|
||||||
public ArrayList<SubTree> getChildrenSubTreeToRootByIdentifier(String itemIdentifier) throws Exception;
|
public ArrayList<SubTree> getChildrenSubTreeToRootByIdentifier(String itemIdentifier) throws Exception;
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* Gets the smart folder results by category.
|
// * Gets the smart folder results by category.
|
||||||
*
|
// *
|
||||||
* @param category
|
// * @param category
|
||||||
* the category
|
// * the category
|
||||||
* @return the smart folder results by category
|
// * @return the smart folder results by category
|
||||||
* @throws Exception
|
// * @throws Exception
|
||||||
* the exception
|
// * the exception
|
||||||
*/
|
// */
|
||||||
List<FileGridModel> getSmartFolderResultsByCategory(GXTCategorySmartFolder category) throws Exception;
|
// List<FileGridModel> getSmartFolderResultsByCategory(GXTCategorySmartFolder category) throws Exception;
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* Creates the smart folder.
|
// * Creates the smart folder.
|
||||||
*
|
// *
|
||||||
* @param name
|
// * @param name
|
||||||
* the name
|
// * the name
|
||||||
* @param description
|
// * @param description
|
||||||
* the description
|
// * the description
|
||||||
* @param query
|
// * @param query
|
||||||
* the query
|
// * the query
|
||||||
* @param parentId
|
// * @param parentId
|
||||||
* the parent id
|
// * the parent id
|
||||||
* @return the smart folder model
|
// * @return the smart folder model
|
||||||
* @throws Exception
|
// * @throws Exception
|
||||||
* the exception
|
// * the exception
|
||||||
*/
|
// */
|
||||||
SmartFolderModel createSmartFolder(String name, String description, String query, String parentId) throws Exception;
|
// SmartFolderModel createSmartFolder(String name, String description, String query, String parentId) throws Exception;
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* Gets the smart folder results by id.
|
// * Gets the smart folder results by id.
|
||||||
*
|
// *
|
||||||
* @param folderId
|
// * @param folderId
|
||||||
* the folder id
|
// * the folder id
|
||||||
* @return the smart folder results by id
|
// * @return the smart folder results by id
|
||||||
* @throws Exception
|
// * @throws Exception
|
||||||
* the exception
|
// * the exception
|
||||||
*/
|
// */
|
||||||
public List<FileGridModel> getSmartFolderResultsById(String folderId) throws Exception;
|
// public List<FileGridModel> getSmartFolderResultsById(String folderId) throws Exception;
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* Gets the all smart folders.
|
// * Gets the all smart folders.
|
||||||
*
|
// *
|
||||||
* @return the all smart folders
|
// * @return the all smart folders
|
||||||
* @throws Exception
|
// * @throws Exception
|
||||||
* the exception
|
// * the exception
|
||||||
*/
|
// */
|
||||||
public List<SmartFolderModel> getAllSmartFolders() throws Exception;
|
// public List<SmartFolderModel> getAllSmartFolders() throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the image by id.
|
* Gets the image by id.
|
||||||
|
@ -285,60 +273,6 @@ public interface GWTWorkspaceService extends RemoteService {
|
||||||
* the exception
|
* the exception
|
||||||
*/
|
*/
|
||||||
public Boolean renameItem(String itemId, String newName, String oldName) throws Exception;
|
public Boolean renameItem(String itemId, String newName, String oldName) throws Exception;
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes the smart folder.
|
|
||||||
*
|
|
||||||
* @param itemId
|
|
||||||
* the item id
|
|
||||||
* @param name
|
|
||||||
* the name
|
|
||||||
* @return the boolean
|
|
||||||
* @throws Exception
|
|
||||||
* the exception
|
|
||||||
*/
|
|
||||||
public Boolean removeSmartFolder(String itemId, String name) throws Exception;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the url web dav.
|
|
||||||
*
|
|
||||||
* @param itemId
|
|
||||||
* the item id
|
|
||||||
* @return the url web dav
|
|
||||||
* @throws Exception
|
|
||||||
* the exception
|
|
||||||
*/
|
|
||||||
public String getUrlWebDav(String itemId) throws Exception;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send to by id.
|
|
||||||
*
|
|
||||||
* @param listContactsId
|
|
||||||
* the list contacts id
|
|
||||||
* @param listAttachmentsId
|
|
||||||
* the list attachments id
|
|
||||||
* @param subject
|
|
||||||
* the subject
|
|
||||||
* @param text
|
|
||||||
* the text
|
|
||||||
* @return true, if successful
|
|
||||||
* @throws Exception
|
|
||||||
* the exception
|
|
||||||
*/
|
|
||||||
public boolean sendToById(List<String> listContactsId, List<String> listAttachmentsId, String subject, String text)
|
|
||||||
throws Exception;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the time series by id.
|
|
||||||
*
|
|
||||||
* @param identifier
|
|
||||||
* the identifier
|
|
||||||
* @return the time series by id
|
|
||||||
* @throws Exception
|
|
||||||
* the exception
|
|
||||||
*/
|
|
||||||
public GWTWorkspaceItem getTimeSeriesById(String identifier) throws Exception;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
|
@ -355,16 +289,6 @@ public interface GWTWorkspaceService extends RemoteService {
|
||||||
public List<FileModel> getListParentsByItemIdentifier(String itemIdentifier, boolean includeItemAsParent)
|
public List<FileModel> getListParentsByItemIdentifier(String itemIdentifier, boolean includeItemAsParent)
|
||||||
throws Exception;
|
throws Exception;
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the URL from application profile.
|
|
||||||
*
|
|
||||||
* @param oid
|
|
||||||
* the oid
|
|
||||||
* @return the URL from application profile
|
|
||||||
* @throws Exception
|
|
||||||
* the exception
|
|
||||||
*/
|
|
||||||
public String getURLFromApplicationProfile(String oid) throws Exception;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Item exists in workpace folder.
|
* Item exists in workpace folder.
|
||||||
|
|
|
@ -8,15 +8,12 @@ import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.gcube.portlets.user.workspace.client.interfaces.GXTCategorySmartFolder;
|
|
||||||
import org.gcube.portlets.user.workspace.client.model.FileGridModel;
|
import org.gcube.portlets.user.workspace.client.model.FileGridModel;
|
||||||
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||||||
import org.gcube.portlets.user.workspace.client.model.FileTrashedModel;
|
import org.gcube.portlets.user.workspace.client.model.FileTrashedModel;
|
||||||
import org.gcube.portlets.user.workspace.client.model.FileVersionModel;
|
import org.gcube.portlets.user.workspace.client.model.FileVersionModel;
|
||||||
import org.gcube.portlets.user.workspace.client.model.FolderModel;
|
import org.gcube.portlets.user.workspace.client.model.FolderModel;
|
||||||
import org.gcube.portlets.user.workspace.client.model.GcubeVRE;
|
import org.gcube.portlets.user.workspace.client.model.GcubeVRE;
|
||||||
import org.gcube.portlets.user.workspace.client.model.ScopeModel;
|
|
||||||
import org.gcube.portlets.user.workspace.client.model.SmartFolderModel;
|
|
||||||
import org.gcube.portlets.user.workspace.client.model.SubTree;
|
import org.gcube.portlets.user.workspace.client.model.SubTree;
|
||||||
import org.gcube.portlets.user.workspace.client.workspace.GWTWorkspaceItem;
|
import org.gcube.portlets.user.workspace.client.workspace.GWTWorkspaceItem;
|
||||||
import org.gcube.portlets.user.workspace.shared.GarbageItem;
|
import org.gcube.portlets.user.workspace.shared.GarbageItem;
|
||||||
|
@ -135,50 +132,50 @@ public interface GWTWorkspaceServiceAsync {
|
||||||
*/
|
*/
|
||||||
void getItemsBySearchName(String text, String folderId, AsyncCallback<List<FileGridModel>> callback);
|
void getItemsBySearchName(String text, String folderId, AsyncCallback<List<FileGridModel>> callback);
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* Gets the smart folder results by category.
|
// * Gets the smart folder results by category.
|
||||||
*
|
// *
|
||||||
* @param category
|
// * @param category
|
||||||
* the category
|
// * the category
|
||||||
* @param callback
|
// * @param callback
|
||||||
* the callback
|
// * the callback
|
||||||
*/
|
// */
|
||||||
void getSmartFolderResultsByCategory(GXTCategorySmartFolder category, AsyncCallback<List<FileGridModel>> callback);
|
// void getSmartFolderResultsByCategory(GXTCategorySmartFolder category, AsyncCallback<List<FileGridModel>> callback);
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* Creates the smart folder.
|
// * Creates the smart folder.
|
||||||
*
|
// *
|
||||||
* @param name
|
// * @param name
|
||||||
* the name
|
// * the name
|
||||||
* @param description
|
// * @param description
|
||||||
* the description
|
// * the description
|
||||||
* @param query
|
// * @param query
|
||||||
* the query
|
// * the query
|
||||||
* @param parentId
|
// * @param parentId
|
||||||
* the parent id
|
// * the parent id
|
||||||
* @param callback
|
// * @param callback
|
||||||
* the callback
|
// * the callback
|
||||||
*/
|
// */
|
||||||
void createSmartFolder(String name, String description, String query, String parentId,
|
// void createSmartFolder(String name, String description, String query, String parentId,
|
||||||
AsyncCallback<SmartFolderModel> callback);
|
// AsyncCallback<SmartFolderModel> callback);
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* Gets the smart folder results by id.
|
// * Gets the smart folder results by id.
|
||||||
*
|
// *
|
||||||
* @param folderId
|
// * @param folderId
|
||||||
* the folder id
|
// * the folder id
|
||||||
* @param callback
|
// * @param callback
|
||||||
* the callback
|
// * the callback
|
||||||
*/
|
// */
|
||||||
void getSmartFolderResultsById(String folderId, AsyncCallback<List<FileGridModel>> callback);
|
// void getSmartFolderResultsById(String folderId, AsyncCallback<List<FileGridModel>> callback);
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* Gets the all smart folders.
|
// * Gets the all smart folders.
|
||||||
*
|
// *
|
||||||
* @param callback
|
// * @param callback
|
||||||
* the callback
|
// * the callback
|
||||||
*/
|
// */
|
||||||
void getAllSmartFolders(AsyncCallback<List<SmartFolderModel>> callback);
|
// void getAllSmartFolders(AsyncCallback<List<SmartFolderModel>> callback);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the image by id.
|
* Gets the image by id.
|
||||||
|
@ -239,62 +236,25 @@ public interface GWTWorkspaceServiceAsync {
|
||||||
*/
|
*/
|
||||||
void setValueInSession(String name, String value, AsyncCallback<Void> callback);
|
void setValueInSession(String name, String value, AsyncCallback<Void> callback);
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* Removes the smart folder.
|
// * Removes the smart folder.
|
||||||
*
|
// *
|
||||||
* @param itemId
|
// * @param itemId
|
||||||
* the item id
|
// * the item id
|
||||||
* @param name
|
// * @param name
|
||||||
* the name
|
// * the name
|
||||||
* @param callback
|
// * @param callback
|
||||||
* the callback
|
// * the callback
|
||||||
*/
|
// */
|
||||||
void removeSmartFolder(String itemId, String name, AsyncCallback<Boolean> callback);
|
// void removeSmartFolder(String itemId, String name, AsyncCallback<Boolean> callback);
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* Gets the all scope.
|
// * Gets the all scope.
|
||||||
*
|
// *
|
||||||
* @param callback
|
// * @param callback
|
||||||
* the callback
|
// * the callback
|
||||||
*/
|
// */
|
||||||
void getAllScope(AsyncCallback<List<ScopeModel>> callback);
|
// void getAllScope(AsyncCallback<List<ScopeModel>> callback);
|
||||||
|
|
||||||
/**
|
|
||||||
* Send to by id.
|
|
||||||
*
|
|
||||||
* @param listContactsId
|
|
||||||
* the list contacts id
|
|
||||||
* @param listAttachmentsId
|
|
||||||
* the list attachments id
|
|
||||||
* @param subject
|
|
||||||
* the subject
|
|
||||||
* @param text
|
|
||||||
* the text
|
|
||||||
* @param callback
|
|
||||||
* the callback
|
|
||||||
*/
|
|
||||||
void sendToById(List<String> listContactsId, List<String> listAttachmentsId, String subject, String text,
|
|
||||||
AsyncCallback<Boolean> callback);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the url web dav.
|
|
||||||
*
|
|
||||||
* @param itemId
|
|
||||||
* the item id
|
|
||||||
* @param callback
|
|
||||||
* the callback
|
|
||||||
*/
|
|
||||||
void getUrlWebDav(String itemId, AsyncCallback<String> callback);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the time series by id.
|
|
||||||
*
|
|
||||||
* @param identifier
|
|
||||||
* the identifier
|
|
||||||
* @param callback
|
|
||||||
* the callback
|
|
||||||
*/
|
|
||||||
void getTimeSeriesById(String identifier, AsyncCallback<GWTWorkspaceItem> callback);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the list parents by item identifier.
|
* Gets the list parents by item identifier.
|
||||||
|
@ -309,16 +269,6 @@ public interface GWTWorkspaceServiceAsync {
|
||||||
void getListParentsByItemIdentifier(String itemIdentifier, boolean includeItemAsParent,
|
void getListParentsByItemIdentifier(String itemIdentifier, boolean includeItemAsParent,
|
||||||
AsyncCallback<List<FileModel>> callback);
|
AsyncCallback<List<FileModel>> callback);
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the URL from application profile.
|
|
||||||
*
|
|
||||||
* @param oid
|
|
||||||
* the oid
|
|
||||||
* @param callback
|
|
||||||
* the callback
|
|
||||||
*/
|
|
||||||
void getURLFromApplicationProfile(String oid, AsyncCallback<String> callback);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Item exists in workpace folder.
|
* Item exists in workpace folder.
|
||||||
*
|
*
|
||||||
|
|
|
@ -6,7 +6,6 @@ import org.gcube.portlets.user.workspace.client.AppControllerExplorer;
|
||||||
import org.gcube.portlets.user.workspace.client.event.UpdatedVREPermissionEvent;
|
import org.gcube.portlets.user.workspace.client.event.UpdatedVREPermissionEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||||||
import org.gcube.portlets.user.workspace.client.resources.Resources;
|
import org.gcube.portlets.user.workspace.client.resources.Resources;
|
||||||
|
|
||||||
import org.gcube.portlets.user.workspace.client.view.windows.InfoDisplay;
|
import org.gcube.portlets.user.workspace.client.view.windows.InfoDisplay;
|
||||||
import org.gcube.portlets.user.workspace.client.view.windows.MessageBoxAlert;
|
import org.gcube.portlets.user.workspace.client.view.windows.MessageBoxAlert;
|
||||||
import org.gcube.portlets.widgets.workspacesharingwidget.client.permissions.PanelTogglePermission;
|
import org.gcube.portlets.widgets.workspacesharingwidget.client.permissions.PanelTogglePermission;
|
||||||
|
|
|
@ -6,7 +6,6 @@ import org.gcube.portlets.user.workspace.client.AppControllerExplorer;
|
||||||
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
||||||
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||||||
import org.gcube.portlets.user.workspace.client.resources.Resources;
|
import org.gcube.portlets.user.workspace.client.resources.Resources;
|
||||||
|
|
||||||
import org.gcube.portlets.user.workspace.client.view.windows.MessageBoxAlert;
|
import org.gcube.portlets.user.workspace.client.view.windows.MessageBoxAlert;
|
||||||
import org.gcube.portlets.widgets.workspacesharingwidget.client.permissions.PanelTogglePermission;
|
import org.gcube.portlets.widgets.workspacesharingwidget.client.permissions.PanelTogglePermission;
|
||||||
import org.gcube.portlets.widgets.workspacesharingwidget.client.rpc.WorkspaceSharingServiceAsync;
|
import org.gcube.portlets.widgets.workspacesharingwidget.client.rpc.WorkspaceSharingServiceAsync;
|
||||||
|
|
|
@ -1,142 +0,0 @@
|
||||||
package org.gcube.portlets.user.workspace.client.view.smartfolder;
|
|
||||||
|
|
||||||
import org.gcube.portlets.user.workspace.client.AppControllerExplorer;
|
|
||||||
import org.gcube.portlets.user.workspace.client.event.DeleteSmartFolderEvent;
|
|
||||||
import org.gcube.portlets.user.workspace.client.resources.Resources;
|
|
||||||
|
|
||||||
import com.extjs.gxt.ui.client.widget.Composite;
|
|
||||||
import com.extjs.gxt.ui.client.widget.HorizontalPanel;
|
|
||||||
import com.google.gwt.event.dom.client.ClickEvent;
|
|
||||||
import com.google.gwt.event.dom.client.ClickHandler;
|
|
||||||
import com.google.gwt.event.dom.client.MouseOutEvent;
|
|
||||||
import com.google.gwt.event.dom.client.MouseOutHandler;
|
|
||||||
import com.google.gwt.event.dom.client.MouseOverEvent;
|
|
||||||
import com.google.gwt.event.dom.client.MouseOverHandler;
|
|
||||||
import com.google.gwt.user.client.Command;
|
|
||||||
import com.google.gwt.user.client.ui.AbstractImagePrototype;
|
|
||||||
import com.google.gwt.user.client.ui.HTML;
|
|
||||||
import com.google.gwt.user.client.ui.Image;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Massimiliano Assante ISTI-CNR
|
|
||||||
*
|
|
||||||
* @version 1.0 May 14th 2012
|
|
||||||
*/
|
|
||||||
public class SmartButton extends Composite {
|
|
||||||
|
|
||||||
private final static String BASE_STYLE = "smartButton";
|
|
||||||
|
|
||||||
private boolean selected;
|
|
||||||
|
|
||||||
private String caption;
|
|
||||||
|
|
||||||
private HorizontalPanel myPanel = new HorizontalPanel();
|
|
||||||
|
|
||||||
private HTML text = new HTML();
|
|
||||||
|
|
||||||
private Command myCommand = null;
|
|
||||||
|
|
||||||
private SmartFolderPanel caller;
|
|
||||||
|
|
||||||
private Image delete = new Image(Resources.ICONS.close());
|
|
||||||
|
|
||||||
public SmartButton(String caption, AbstractImagePrototype img, SmartFolderPanel caller) {
|
|
||||||
super();
|
|
||||||
selected = false;
|
|
||||||
this.caption = caption;
|
|
||||||
this.caller = caller;
|
|
||||||
super.setWidth(300);
|
|
||||||
text.setPixelSize(300, 30);
|
|
||||||
myPanel.setWidth("100%");
|
|
||||||
|
|
||||||
text.setHTML("<div style=\"width: 100%; height: 30px; line-height: 32px; text-align:left; padding-left: 20px;\">" +
|
|
||||||
"<span style=\"display:inline-block; vertical-align:middle;\" >" + img.getHTML() + "</span>" +
|
|
||||||
"<span style=\"padding-left: 20px;\">"+ caption+"</span></div>");
|
|
||||||
|
|
||||||
myPanel.add(text);
|
|
||||||
|
|
||||||
myPanel.setStyleName(BASE_STYLE);
|
|
||||||
initComponent(myPanel);
|
|
||||||
|
|
||||||
text.addClickHandler(new ClickHandler() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(ClickEvent event) {
|
|
||||||
selected = selected? false : true;
|
|
||||||
if (selected) {
|
|
||||||
myPanel.addStyleName(BASE_STYLE + "-selected");
|
|
||||||
} else {
|
|
||||||
myPanel.removeStyleName(BASE_STYLE + "-selected");
|
|
||||||
}
|
|
||||||
deselectOthers();
|
|
||||||
if (myCommand != null)
|
|
||||||
myCommand.execute();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public SmartButton(String caption, AbstractImagePrototype img, SmartFolderPanel caller, boolean isDeletable) {
|
|
||||||
this(caption, img, caller);
|
|
||||||
|
|
||||||
delete.getElement().getStyle().setOpacity(0.6);
|
|
||||||
delete.getElement().getStyle().setMarginTop(3, com.google.gwt.dom.client.Style.Unit.PX);
|
|
||||||
myPanel.add(delete);
|
|
||||||
delete.addClickHandler(new ClickHandler() {
|
|
||||||
@Override
|
|
||||||
public void onClick(ClickEvent event) {
|
|
||||||
deleteFolder();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
delete.addMouseOutHandler(new MouseOutHandler() {
|
|
||||||
@Override
|
|
||||||
public void onMouseOut(MouseOutEvent event) {
|
|
||||||
delete.getElement().getStyle().setOpacity(0.6);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
delete.addMouseOverHandler(new MouseOverHandler() {
|
|
||||||
@Override
|
|
||||||
public void onMouseOver(MouseOverEvent event) {
|
|
||||||
delete.getElement().getStyle().setOpacity(0.9);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void deleteFolder() {
|
|
||||||
AppControllerExplorer.getEventBus().fireEvent(new DeleteSmartFolderEvent(this.getId(), caption));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void deselectOthers() {
|
|
||||||
caller.toggleOthers(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCommand(Command cmd) {
|
|
||||||
myCommand = cmd;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if the button is pressed.
|
|
||||||
*
|
|
||||||
* @return the pressed state
|
|
||||||
*/
|
|
||||||
public boolean isSelected() {
|
|
||||||
return selected;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the current selected state.
|
|
||||||
*
|
|
||||||
* @param state true to set selected state
|
|
||||||
*/
|
|
||||||
protected void toggle(boolean state) {
|
|
||||||
this.selected = state;
|
|
||||||
if (selected) {
|
|
||||||
myPanel.addStyleName(BASE_STYLE + "-selected");
|
|
||||||
} else {
|
|
||||||
myPanel.removeStyleName(BASE_STYLE + "-selected");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,203 +0,0 @@
|
||||||
package org.gcube.portlets.user.workspace.client.view.smartfolder;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.gcube.portlets.user.workspace.client.AppControllerExplorer;
|
|
||||||
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
|
||||||
import org.gcube.portlets.user.workspace.client.event.SmartFolderSelectedEvent;
|
|
||||||
import org.gcube.portlets.user.workspace.client.interfaces.GXTCategorySmartFolder;
|
|
||||||
import org.gcube.portlets.user.workspace.client.model.SmartFolderModel;
|
|
||||||
import org.gcube.portlets.user.workspace.client.resources.Resources;
|
|
||||||
import org.gcube.portlets.user.workspace.client.view.windows.MessageBoxAlert;
|
|
||||||
|
|
||||||
import com.extjs.gxt.ui.client.Style.Scroll;
|
|
||||||
import com.extjs.gxt.ui.client.widget.ContentPanel;
|
|
||||||
import com.extjs.gxt.ui.client.widget.LayoutContainer;
|
|
||||||
import com.google.gwt.core.client.GWT;
|
|
||||||
import com.google.gwt.user.client.Command;
|
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Class SmartFolderPanel.
|
|
||||||
*
|
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
|
||||||
* @author Massimiliano Assante ISTI-CNR
|
|
||||||
* @version 1.0 May 14th 2012
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class SmartFolderPanel extends LayoutContainer {
|
|
||||||
|
|
||||||
private ContentPanel cp;
|
|
||||||
private SmartButton buttDocuments = new SmartButton(GXTCategorySmartFolder.SMF_DOCUMENTS.getValue(), Resources.getIconDocuments(), this);
|
|
||||||
private SmartButton buttImages = new SmartButton(GXTCategorySmartFolder.SMF_IMAGES.getValue(), Resources.getIconImages(), this);
|
|
||||||
private SmartButton buttLinks = new SmartButton(GXTCategorySmartFolder.SMF_LINKS.getValue(), Resources.getIconLinks(), this);
|
|
||||||
private SmartButton buttPublicFolder = new SmartButton(GXTCategorySmartFolder.SMF_PUBLIC_FOLDERS.getValue(), Resources.getIconFolderPublic(), this);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Instantiates a new smart folder panel.
|
|
||||||
*/
|
|
||||||
public SmartFolderPanel() {
|
|
||||||
this.cp = new ContentPanel();
|
|
||||||
cp.setBodyBorder(false);
|
|
||||||
cp.setHeaderVisible(false);
|
|
||||||
cp.setScrollMode(Scroll.AUTO);
|
|
||||||
addListeners();
|
|
||||||
add(cp);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reload panel smart folder.
|
|
||||||
*/
|
|
||||||
public void reloadPanelSmartFolder(){
|
|
||||||
cp.removeAll();
|
|
||||||
cp.add(buttDocuments);
|
|
||||||
cp.add(buttImages);
|
|
||||||
cp.add(buttLinks);
|
|
||||||
cp.add(buttPublicFolder);
|
|
||||||
cp.layout();
|
|
||||||
addUserSmartFolder();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deselect all.
|
|
||||||
*/
|
|
||||||
public void deselectAll(){
|
|
||||||
for (int i = 0; i < cp.getItemCount(); i++ )
|
|
||||||
if (cp.getItem(i) instanceof SmartButton) {
|
|
||||||
SmartButton b = (SmartButton) cp.getItem(i);
|
|
||||||
b.toggle(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds the user smart folder.
|
|
||||||
*/
|
|
||||||
private void addUserSmartFolder() {
|
|
||||||
AppControllerExplorer.rpcWorkspaceService.getAllSmartFolders(new AsyncCallback<List<SmartFolderModel>>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(List<SmartFolderModel> result) {
|
|
||||||
loadSmartFolders(result);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {
|
|
||||||
new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " getting User's Smart Folders. " +ConstantsExplorer.TRY_AGAIN, null);
|
|
||||||
GWT.log("Error in load smart folder " + caught.getMessage());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds the listeners.
|
|
||||||
*/
|
|
||||||
private void addListeners() {
|
|
||||||
|
|
||||||
buttImages.setCommand(new Command() {
|
|
||||||
@Override
|
|
||||||
public void execute() {
|
|
||||||
AppControllerExplorer.getEventBus().fireEvent(new SmartFolderSelectedEvent(GXTCategorySmartFolder.SMF_IMAGES));
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
buttLinks.setCommand(new Command() {
|
|
||||||
@Override
|
|
||||||
public void execute() {
|
|
||||||
AppControllerExplorer.getEventBus().fireEvent(new SmartFolderSelectedEvent(GXTCategorySmartFolder.SMF_LINKS));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
buttDocuments.setCommand(new Command() {
|
|
||||||
@Override
|
|
||||||
public void execute() {
|
|
||||||
AppControllerExplorer.getEventBus().fireEvent(new SmartFolderSelectedEvent(GXTCategorySmartFolder.SMF_DOCUMENTS));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
buttPublicFolder.setCommand(new Command() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute() {
|
|
||||||
|
|
||||||
AppControllerExplorer.getEventBus().fireEvent(new SmartFolderSelectedEvent(GXTCategorySmartFolder.SMF_PUBLIC_FOLDERS));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load smart folders.
|
|
||||||
*
|
|
||||||
* @param result the result
|
|
||||||
*/
|
|
||||||
public void loadSmartFolders(List<SmartFolderModel> result) {
|
|
||||||
if (result != null && result.size() > 0) {
|
|
||||||
for (SmartFolderModel smart : result) {
|
|
||||||
loadSmartFolder(smart);
|
|
||||||
}
|
|
||||||
cp.layout();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load smart folder.
|
|
||||||
*
|
|
||||||
* @param smart the smart
|
|
||||||
*/
|
|
||||||
public void loadSmartFolder(final SmartFolderModel smart) {
|
|
||||||
|
|
||||||
SmartButton userSmartFolder = new SmartButton(smart.getName(), Resources.getIconStar(), this, true);
|
|
||||||
userSmartFolder.setId(smart.getIdentifier());
|
|
||||||
userSmartFolder.setCommand(new Command() {
|
|
||||||
@Override
|
|
||||||
public void execute() {
|
|
||||||
AppControllerExplorer.getEventBus().fireEvent(new SmartFolderSelectedEvent(smart.getIdentifier(), smart.getName(), null));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
cp.add(userSmartFolder);
|
|
||||||
cp.layout();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the size smart panel.
|
|
||||||
*
|
|
||||||
* @param width the width
|
|
||||||
* @param height the height
|
|
||||||
*/
|
|
||||||
public void setSizeSmartPanel(int width, int height) {
|
|
||||||
cp.setSize(width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes the smart folder.
|
|
||||||
*
|
|
||||||
* @param smartIdentifier the smart identifier
|
|
||||||
*/
|
|
||||||
public void removeSmartFolder(String smartIdentifier) {
|
|
||||||
cp.remove(cp.getItemByItemId(smartIdentifier));
|
|
||||||
cp.layout(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Un pressed all toogle.
|
|
||||||
*/
|
|
||||||
public void unPressedAllToogle(){
|
|
||||||
deselectAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Toggle others.
|
|
||||||
*
|
|
||||||
* @param button the button
|
|
||||||
*/
|
|
||||||
public void toggleOthers(SmartButton button){
|
|
||||||
for (int i = 0; i < cp.getItemCount(); i++ )
|
|
||||||
if (cp.getItem(i) instanceof SmartButton) {
|
|
||||||
SmartButton b = (SmartButton) cp.getItem(i);
|
|
||||||
if (! b.equals(button))
|
|
||||||
b.toggle(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -941,14 +941,6 @@ public class ContextMenuTree {
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.PUBLISH_ON_DATA_CATALOGUE.getId()).setVisible(true);
|
contextMenu.getItemByItemId(WorkspaceOperation.PUBLISH_ON_DATA_CATALOGUE.getId()).setVisible(true);
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.COPY.getId()).setVisible(true);
|
contextMenu.getItemByItemId(WorkspaceOperation.COPY.getId()).setVisible(true);
|
||||||
break;
|
break;
|
||||||
case REPORT_TEMPLATE:
|
|
||||||
//contextMenu.getItemByItemId(WorkspaceOperation.OPEN_REPORT_TEMPLATE.getId()).setVisible(true);
|
|
||||||
break;
|
|
||||||
case REPORT:
|
|
||||||
//contextMenu.getItemByItemId(WorkspaceOperation.OPEN_REPORT.getId()).setVisible(true);
|
|
||||||
break;
|
|
||||||
case QUERY:
|
|
||||||
break;
|
|
||||||
case TIME_SERIES:
|
case TIME_SERIES:
|
||||||
break;
|
break;
|
||||||
// case AQUAMAPS_ITEM:
|
// case AQUAMAPS_ITEM:
|
||||||
|
|
|
@ -12,8 +12,11 @@ import com.google.gwt.user.client.rpc.IsSerializable;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Federico De Faveri defaveriAtisti.cnr.it
|
* The Class GWTWorkspaceFolder.
|
||||||
*
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
|
*
|
||||||
|
* Jul 17, 2019
|
||||||
*/
|
*/
|
||||||
public class GWTWorkspaceFolder extends GWTWorkspaceItem implements IsSerializable {
|
public class GWTWorkspaceFolder extends GWTWorkspaceItem implements IsSerializable {
|
||||||
|
|
||||||
|
@ -25,9 +28,26 @@ public class GWTWorkspaceFolder extends GWTWorkspaceItem implements IsSerializab
|
||||||
|
|
||||||
protected boolean isShared = false;
|
protected boolean isShared = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new GWT workspace folder.
|
||||||
|
*/
|
||||||
protected GWTWorkspaceFolder() {
|
protected GWTWorkspaceFolder() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new GWT workspace folder.
|
||||||
|
*
|
||||||
|
* @param id the id
|
||||||
|
* @param name the name
|
||||||
|
* @param description the description
|
||||||
|
* @param owner the owner
|
||||||
|
* @param creationTime the creation time
|
||||||
|
* @param properties the properties
|
||||||
|
* @param lastModificationTime the last modification time
|
||||||
|
* @param lastAction the last action
|
||||||
|
* @param parent the parent
|
||||||
|
* @param children the children
|
||||||
|
*/
|
||||||
public GWTWorkspaceFolder(String id, String name, String description, String owner, Date creationTime,
|
public GWTWorkspaceFolder(String id, String name, String description, String owner, Date creationTime,
|
||||||
GWTProperties properties, Date lastModificationTime, GWTWorkspaceItemAction lastAction,
|
GWTProperties properties, Date lastModificationTime, GWTWorkspaceItemAction lastAction,
|
||||||
GWTWorkspaceFolder parent, List<GWTWorkspaceItem> children) {
|
GWTWorkspaceFolder parent, List<GWTWorkspaceItem> children) {
|
||||||
|
@ -37,21 +57,33 @@ public class GWTWorkspaceFolder extends GWTWorkspaceItem implements IsSerializab
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.gcube.portlets.user.workspace.client.workspace.GWTWorkspaceItem#getChildren()
|
||||||
|
*/
|
||||||
public List<GWTWorkspaceItem> getChildren(){
|
public List<GWTWorkspaceItem> getChildren(){
|
||||||
return children;
|
return children;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.gcube.portlets.user.workspace.client.workspace.GWTWorkspaceItem#getType()
|
||||||
|
*/
|
||||||
public GWTWorkspaceItemType getType() {
|
public GWTWorkspaceItemType getType() {
|
||||||
return GWTWorkspaceItemType.FOLDER;
|
return GWTWorkspaceItemType.FOLDER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.gcube.portlets.user.workspace.client.workspace.GWTWorkspaceItem#getItemDescription()
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public GWTItemDescription getItemDescription() {
|
public GWTItemDescription getItemDescription() {
|
||||||
return getType();
|
return getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.gcube.portlets.user.workspace.client.workspace.GWTWorkspaceItem#getIconClass()
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getIconClass()
|
public String getIconClass()
|
||||||
{
|
{
|
||||||
|
@ -62,21 +94,39 @@ public class GWTWorkspaceFolder extends GWTWorkspaceItem implements IsSerializab
|
||||||
else return TREE_ROOT_ICON;
|
else return TREE_ROOT_ICON;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the enabled operations.
|
||||||
|
*
|
||||||
|
* @return the enabled operations
|
||||||
|
*/
|
||||||
public List<GWTWorkspaceOperation> getEnabledOperations(){
|
public List<GWTWorkspaceOperation> getEnabledOperations(){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the child.
|
||||||
|
*
|
||||||
|
* @param child the child
|
||||||
|
* @throws WrongItemTypeException the wrong item type exception
|
||||||
|
*/
|
||||||
protected void addChild(GWTWorkspaceItem child) throws WrongItemTypeException
|
protected void addChild(GWTWorkspaceItem child) throws WrongItemTypeException
|
||||||
{
|
{
|
||||||
children.add( child);
|
children.add( child);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the child.
|
||||||
|
*
|
||||||
|
* @param child the child
|
||||||
|
*/
|
||||||
protected void removeChild(GWTWorkspaceItem child) {
|
protected void removeChild(GWTWorkspaceItem child) {
|
||||||
children.remove(child);
|
children.remove(child);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Checks if is shared.
|
||||||
|
*
|
||||||
* @return the isShared
|
* @return the isShared
|
||||||
*/
|
*/
|
||||||
public boolean isShared() {
|
public boolean isShared() {
|
||||||
|
@ -85,6 +135,8 @@ public class GWTWorkspaceFolder extends GWTWorkspaceItem implements IsSerializab
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Sets the shared.
|
||||||
|
*
|
||||||
* @param isShared the isShared to set
|
* @param isShared the isShared to set
|
||||||
*/
|
*/
|
||||||
public void setShared(boolean isShared) {
|
public void setShared(boolean isShared) {
|
||||||
|
|
|
@ -10,9 +10,10 @@ import javax.servlet.http.HttpServlet;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.gcube.portlets.user.workspace.server.property.PortalUrlGroupGatewayProperty;
|
import org.gcube.portlets.user.workspace.server.property.PortalUrlGroupGatewayProperty;
|
||||||
import org.gcube.portlets.user.workspace.shared.HandlerResultMessage;
|
import org.gcube.portlets.user.workspace.shared.HandlerResultMessage;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,7 +27,7 @@ public class DownloadPublicLinkServlet extends HttpServlet{
|
||||||
|
|
||||||
private static final long serialVersionUID = -8423345575690165644L;
|
private static final long serialVersionUID = -8423345575690165644L;
|
||||||
|
|
||||||
protected static Logger logger = Logger.getLogger(DownloadPublicLinkServlet.class);
|
protected static Logger logger = LoggerFactory.getLogger(DownloadPublicLinkServlet.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
|
|
|
@ -3,10 +3,13 @@
|
||||||
*/
|
*/
|
||||||
package org.gcube.portlets.user.workspace.server;
|
package org.gcube.portlets.user.workspace.server;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
|
@ -16,7 +19,6 @@ import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.gcube.common.portal.PortalContext;
|
import org.gcube.common.portal.PortalContext;
|
||||||
import org.gcube.common.storagehubwrapper.server.StorageHubWrapper;
|
import org.gcube.common.storagehubwrapper.server.StorageHubWrapper;
|
||||||
import org.gcube.common.storagehubwrapper.server.tohl.Workspace;
|
import org.gcube.common.storagehubwrapper.server.tohl.Workspace;
|
||||||
|
@ -27,6 +29,7 @@ import org.gcube.common.storagehubwrapper.shared.tohl.items.ImageFileItem;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.items.ItemStreamDescriptor;
|
import org.gcube.common.storagehubwrapper.shared.tohl.items.ItemStreamDescriptor;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.items.PDFFileItem;
|
import org.gcube.common.storagehubwrapper.shared.tohl.items.PDFFileItem;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.items.URLFileItem;
|
import org.gcube.common.storagehubwrapper.shared.tohl.items.URLFileItem;
|
||||||
|
import org.gcube.common.storagehubwrapper.shared.tohl.items.URLItem;
|
||||||
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
||||||
import org.gcube.portlets.user.workspace.server.property.PortalUrlGroupGatewayProperty;
|
import org.gcube.portlets.user.workspace.server.property.PortalUrlGroupGatewayProperty;
|
||||||
import org.gcube.portlets.user.workspace.server.util.AllowedMimeTypeToInline;
|
import org.gcube.portlets.user.workspace.server.util.AllowedMimeTypeToInline;
|
||||||
|
@ -35,6 +38,8 @@ import org.gcube.portlets.user.workspace.server.util.WsUtil;
|
||||||
import org.gcube.portlets.user.workspace.shared.HandlerResultMessage;
|
import org.gcube.portlets.user.workspace.shared.HandlerResultMessage;
|
||||||
import org.gcube.portlets.user.workspace.shared.SessionExpiredException;
|
import org.gcube.portlets.user.workspace.shared.SessionExpiredException;
|
||||||
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,7 +53,7 @@ public class DownloadServlet extends HttpServlet{
|
||||||
|
|
||||||
private static final long serialVersionUID = -8423345575690165644L;
|
private static final long serialVersionUID = -8423345575690165644L;
|
||||||
|
|
||||||
protected static Logger logger = Logger.getLogger(DownloadServlet.class);
|
protected static Logger logger = LoggerFactory.getLogger(DownloadServlet.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
|
@ -130,12 +135,43 @@ public class DownloadServlet extends HttpServlet{
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (item.getType()) {
|
switch (item.getType()) {
|
||||||
|
case URL_ITEM: {
|
||||||
|
try{
|
||||||
|
logger.info("Downloading "+item.getType());
|
||||||
|
String urlValue = "URL not found";
|
||||||
|
if(item instanceof URLItem) {
|
||||||
|
URLItem theURL = (URLItem) item;
|
||||||
|
urlValue = theURL.getValue()==null?"URL not found":theURL.getValue().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder build = new StringBuilder();
|
||||||
|
build.append("#URL downloaded from D4Science, source filename: "+item.getName());
|
||||||
|
build.append("\n");
|
||||||
|
build.append(urlValue);
|
||||||
|
String fileContent = build.toString();
|
||||||
|
logger.info("Writing file content: \n"+fileContent);
|
||||||
|
ByteArrayInputStream is = new ByteArrayInputStream(fileContent.getBytes());
|
||||||
|
String contentDisposition = viewContent?"inline":"attachment";
|
||||||
|
String urlMimeType = "text/uri-list";
|
||||||
|
String itemName = MimeTypeUtility.getNameWithExtension(item.getName(), urlMimeType);
|
||||||
|
resp.setHeader("Content-Disposition", contentDisposition+"; filename=\"" + itemName + "\"" );
|
||||||
|
resp.setContentType(urlMimeType);
|
||||||
|
|
||||||
|
OutputStream out = resp.getOutputStream();
|
||||||
|
IOUtils.copy(is, out);
|
||||||
|
is.close();
|
||||||
|
out.close();
|
||||||
|
return;
|
||||||
|
}catch (Exception e) {
|
||||||
|
logger.error("Error during downloading the item "+itemId,e);
|
||||||
|
handleError(urlRedirectOnError, req, resp, itemId, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Error during data downloading: "+e.getMessage());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
case FOLDER:
|
case FOLDER:
|
||||||
case SHARED_FOLDER:
|
case SHARED_FOLDER:
|
||||||
case VRE_FOLDER:
|
case VRE_FOLDER:
|
||||||
case SMART_FOLDER:{
|
case SMART_FOLDER: {
|
||||||
|
|
||||||
WorkspaceFolder workspaceFolder = (WorkspaceFolder) item;
|
WorkspaceFolder workspaceFolder = (WorkspaceFolder) item;
|
||||||
ItemStreamDescriptor descr;
|
ItemStreamDescriptor descr;
|
||||||
|
@ -160,7 +196,7 @@ public class DownloadServlet extends HttpServlet{
|
||||||
|
|
||||||
OutputStream out = resp.getOutputStream();
|
OutputStream out = resp.getOutputStream();
|
||||||
InputStream is = descr.getStream();
|
InputStream is = descr.getStream();
|
||||||
IOUtils.copy(descr.getStream(), out);
|
IOUtils.copy(is, out);
|
||||||
|
|
||||||
is.close();
|
is.close();
|
||||||
out.close();
|
out.close();
|
||||||
|
@ -251,7 +287,7 @@ public class DownloadServlet extends HttpServlet{
|
||||||
String contentDisposition = viewContent?"inline":"attachment";
|
String contentDisposition = viewContent?"inline":"attachment";
|
||||||
resp.setHeader("Content-Disposition", contentDisposition+"; filename=\"" + itemName + "\"" );
|
resp.setHeader("Content-Disposition", contentDisposition+"; filename=\"" + itemName + "\"" );
|
||||||
resp.setContentType(urlMimeType);
|
resp.setContentType(urlMimeType);
|
||||||
resp = setContentLength(resp, externalUrl.getSize());
|
//resp = setContentLength(resp, externalUrl.getSize());
|
||||||
|
|
||||||
//MODIFIED 22-05-2013 CLOSE STREAM
|
//MODIFIED 22-05-2013 CLOSE STREAM
|
||||||
OutputStream out = resp.getOutputStream();
|
OutputStream out = resp.getOutputStream();
|
||||||
|
@ -509,6 +545,25 @@ public class DownloadServlet extends HttpServlet{
|
||||||
response.sendRedirect(response.encodeRedirectURL(requestUrl));
|
response.sendRedirect(response.encodeRedirectURL(requestUrl));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the temp file.
|
||||||
|
*
|
||||||
|
* @param fileName the file name
|
||||||
|
* @param extension the extension
|
||||||
|
* @param data the data
|
||||||
|
* @return the file
|
||||||
|
* @throws IOException Signals that an I/O exception has occurred.
|
||||||
|
*/
|
||||||
|
public static File createTempFile(String fileName, String extension, byte[] data) throws IOException {
|
||||||
|
// Since Java 1.7 Files and Path API simplify operations on files
|
||||||
|
java.nio.file.Path path = Files.createTempFile(fileName, extension);
|
||||||
|
File file = path.toFile();
|
||||||
|
// writing sample data
|
||||||
|
Files.write(path, data);
|
||||||
|
logger.info("Created the Temp File: "+file.getAbsolutePath());
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the request url.
|
* Gets the request url.
|
||||||
|
|
|
@ -12,13 +12,8 @@ package org.gcube.portlets.user.workspace.server;
|
||||||
*/
|
*/
|
||||||
public class FileNotVersionedException extends Exception {
|
public class FileNotVersionedException extends Exception {
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = -954314398414781437L;
|
private static final long serialVersionUID = -954314398414781437L;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new file not versioned exception.
|
* Instantiates a new file not versioned exception.
|
||||||
*/
|
*/
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -3,23 +3,26 @@
|
||||||
*/
|
*/
|
||||||
package org.gcube.portlets.user.workspace.server;
|
package org.gcube.portlets.user.workspace.server;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
|
||||||
|
import javax.activation.MimetypesFileTypeMap;
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServlet;
|
import javax.servlet.http.HttpServlet;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.gcube.common.portal.PortalContext;
|
import org.gcube.common.portal.PortalContext;
|
||||||
import org.gcube.common.storagehubwrapper.server.StorageHubWrapper;
|
import org.gcube.common.storagehubwrapper.server.StorageHubWrapper;
|
||||||
import org.gcube.common.storagehubwrapper.server.tohl.Workspace;
|
import org.gcube.common.storagehubwrapper.server.tohl.Workspace;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
|
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.ItemNotFoundException;
|
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.ItemNotFoundException;
|
||||||
|
import org.gcube.common.storagehubwrapper.shared.tohl.impl.StreamDescriptor;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.items.FileItem;
|
import org.gcube.common.storagehubwrapper.shared.tohl.items.FileItem;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.items.FileItemType;
|
import org.gcube.common.storagehubwrapper.shared.tohl.items.FileItemType;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.items.ImageFileItem;
|
import org.gcube.common.storagehubwrapper.shared.tohl.items.ImageFileItem;
|
||||||
|
@ -30,6 +33,8 @@ import org.gcube.portlets.user.workspace.server.util.ThumbnailGenerator;
|
||||||
import org.gcube.portlets.user.workspace.server.util.WsUtil;
|
import org.gcube.portlets.user.workspace.server.util.WsUtil;
|
||||||
import org.gcube.portlets.user.workspace.shared.SessionExpiredException;
|
import org.gcube.portlets.user.workspace.shared.SessionExpiredException;
|
||||||
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,10 +49,9 @@ public class ImageServlet extends HttpServlet{
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final int THUMB_MAX_SIZE = 300;
|
private static final int THUMB_MAX_SIZE = 300;
|
||||||
|
|
||||||
private static final long serialVersionUID = -8423345575690165644L;
|
private static final long serialVersionUID = -8423345575690165644L;
|
||||||
|
|
||||||
protected static Logger logger = Logger.getLogger(ImageServlet.class);
|
protected static Logger logger = LoggerFactory.getLogger(ImageServlet.class);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -141,11 +145,23 @@ public class ImageServlet extends HttpServlet{
|
||||||
|
|
||||||
try{
|
try{
|
||||||
streamDescr = wa.getThumbnailData(image.getId());
|
streamDescr = wa.getThumbnailData(image.getId());
|
||||||
|
|
||||||
|
/*TODO
|
||||||
|
* UNCOMMENT THIS IF YOU WANT TO ADD MORE CONTROLS
|
||||||
|
ReusableInputStream ris = new ReusableInputStream(streamDescr.getStream());
|
||||||
|
boolean isAvalidImage = isAnImage(ris, image.getName());
|
||||||
|
if(!isAvalidImage)
|
||||||
|
//CREATING THE THUMBNAIL
|
||||||
|
streamDescr = createThumbnailForImage(wa, image);
|
||||||
|
else {
|
||||||
|
//ASSIGNING THE REUSABLE STREAM
|
||||||
|
streamDescr = new org.gcube.common.storagehubwrapper.shared.tohl.impl.StreamDescriptor(ris, image.getName(), null, image.getMimeType());
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
logger.warn("Thumbnail data not available from StorageHub, creating it by the "+ThumbnailGenerator.class.getSimpleName() +" provided by the "+ImageServlet.class.getSimpleName());
|
//silent
|
||||||
streamDescr = wa.downloadFile(image.getId(), image.getName(), null, null);
|
streamDescr = createThumbnailForImage(wa, image);
|
||||||
InputStream thumbIs = ThumbnailGenerator.generateThumbnail(streamDescr.getStream(), image.getName(), THUMB_MAX_SIZE, THUMB_MAX_SIZE);
|
|
||||||
streamDescr = new org.gcube.common.storagehubwrapper.shared.tohl.impl.StreamDescriptor(thumbIs, image.getName(), null, image.getMimeType());
|
|
||||||
}
|
}
|
||||||
mimeType = streamDescr.getMimeType()!=null?streamDescr.getMimeType():image.getMimeType();
|
mimeType = streamDescr.getMimeType()!=null?streamDescr.getMimeType():image.getMimeType();
|
||||||
size = streamDescr.getSize()==null?0:streamDescr.getSize(); //reading size from byte.lenght
|
size = streamDescr.getSize()==null?0:streamDescr.getSize(); //reading size from byte.lenght
|
||||||
|
@ -190,8 +206,62 @@ public class ImageServlet extends HttpServlet{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the thumbnail for image.
|
||||||
|
*
|
||||||
|
* @param wa the wa
|
||||||
|
* @param image the image
|
||||||
|
* @return the stream descriptor
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
|
public static StreamDescriptor createThumbnailForImage(Workspace wa, ImageFileItem image) throws Exception {
|
||||||
|
logger.warn("Thumbnail data not available from StorageHub, creating it by the "+ThumbnailGenerator.class.getSimpleName() +" provided by the "+ImageServlet.class.getSimpleName());
|
||||||
|
ItemStreamDescriptor streamDescr = wa.downloadFile(image.getId(), image.getName(), null, null);
|
||||||
|
InputStream thumbIs = ThumbnailGenerator.generateThumbnail(streamDescr.getStream(), image.getName(), THUMB_MAX_SIZE, THUMB_MAX_SIZE);
|
||||||
|
return new org.gcube.common.storagehubwrapper.shared.tohl.impl.StreamDescriptor(thumbIs, image.getName(), null, image.getMimeType());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if is an image.
|
||||||
|
*
|
||||||
|
* @param image the image
|
||||||
|
* @param fileName the file name
|
||||||
|
* @return true, if is an image
|
||||||
|
*/
|
||||||
|
private boolean isAnImage(InputStream image, String fileName) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
logger.debug("Recognizing image type by "+ImageIO.class.getName());
|
||||||
|
// It's an image
|
||||||
|
//Only BMP, GIF, JPG and PNG are recognized).
|
||||||
|
ImageIO.read(image);
|
||||||
|
logger.debug(ImageIO.class.getName()+ " recognized the image: "+fileName+" as an Image");
|
||||||
|
return true;
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
//Silent. It's not an image.
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
logger.debug("Recognizing image type by "+MimetypesFileTypeMap.class.getName());
|
||||||
|
File f = ThumbnailGenerator.stream2file(image, fileName, ".tmp");
|
||||||
|
String mimetype = new MimetypesFileTypeMap().getContentType(f);
|
||||||
|
String type = mimetype.split("/")[0];
|
||||||
|
boolean isAnImage = type.equals("image")?true:false;
|
||||||
|
logger.debug(MimetypesFileTypeMap.class.getName()+ " is recognized the filename: "+fileName+" as an Image? "+isAnImage);
|
||||||
|
return isAnImage;
|
||||||
|
|
||||||
|
}catch (Exception e) {
|
||||||
|
//Silent. It's not an image.
|
||||||
|
}
|
||||||
|
logger.debug("The filename "+fileName+" seems not to be an Image");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the request type.
|
* Gets the request type.
|
||||||
|
|
|
@ -21,6 +21,4 @@ public class NoGcubeItemTypeException extends Exception{
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,94 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.gcube.portlets.user.workspace.server;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class ReusableInputStream.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
|
*
|
||||||
|
* Jul 30, 2019
|
||||||
|
*/
|
||||||
|
public class ReusableInputStream extends InputStream {
|
||||||
|
|
||||||
|
private InputStream input;
|
||||||
|
private ByteArrayOutputStream output;
|
||||||
|
private ByteBuffer buffer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new reusable input stream.
|
||||||
|
*
|
||||||
|
* @param input the input
|
||||||
|
* @throws IOException Signals that an I/O exception has occurred.
|
||||||
|
*/
|
||||||
|
public ReusableInputStream(InputStream input) throws IOException {
|
||||||
|
|
||||||
|
this.input = input;
|
||||||
|
// Note: it's resizable anyway.
|
||||||
|
this.output = new ByteArrayOutputStream(input.available());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see java.io.InputStream#read()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int read() throws IOException {
|
||||||
|
|
||||||
|
byte[] b = new byte[1];
|
||||||
|
read(b, 0, 1);
|
||||||
|
return b[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see java.io.InputStream#read(byte[])
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int read(byte[] bytes) throws IOException {
|
||||||
|
|
||||||
|
return read(bytes, 0, bytes.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see java.io.InputStream#read(byte[], int, int)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int read(byte[] bytes, int offset, int length) throws IOException {
|
||||||
|
|
||||||
|
if (buffer == null) {
|
||||||
|
int read = input.read(bytes, offset, length);
|
||||||
|
if (read <= 0) {
|
||||||
|
input.close();
|
||||||
|
input = null;
|
||||||
|
buffer = ByteBuffer.wrap(output.toByteArray());
|
||||||
|
output = null;
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
output.write(bytes, offset, read);
|
||||||
|
return read;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
int read = Math.min(length, buffer.remaining());
|
||||||
|
if (read <= 0) {
|
||||||
|
buffer.flip();
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
buffer.get(bytes, offset, read);
|
||||||
|
return read;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// You might want to @Override flush(), close(), etc to delegate to input.
|
||||||
|
}
|
|
@ -1,695 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package org.gcube.portlets.user.workspace.server.notifications;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpSession;
|
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.gcube.applicationsupportlayer.social.NotificationsManager;
|
|
||||||
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceSharedFolder;
|
|
||||||
import org.gcube.common.scope.impl.ScopeBean;
|
|
||||||
import org.gcube.portlets.user.workspace.server.util.DifferenceBetweenInfoContactModel;
|
|
||||||
import org.gcube.portlets.user.workspace.server.util.PortalContextInfo;
|
|
||||||
import org.gcube.portlets.user.workspace.server.util.UserUtil;
|
|
||||||
import org.gcube.portlets.user.workspace.server.util.WsUtil;
|
|
||||||
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Class NotificationsProducer.
|
|
||||||
*
|
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
|
||||||
*/
|
|
||||||
public class NotificationsProducer {
|
|
||||||
|
|
||||||
protected ScopeBean scope;
|
|
||||||
|
|
||||||
protected static Logger logger = Logger.getLogger(NotificationsProducer.class);
|
|
||||||
|
|
||||||
protected NotificationsManager notificationsMng;
|
|
||||||
protected HttpSession httpSession;
|
|
||||||
protected String userId;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Instantiates a new notifications producer.
|
|
||||||
*
|
|
||||||
* @param httpServletRequest the http servlet request
|
|
||||||
*/
|
|
||||||
public NotificationsProducer(HttpServletRequest httpServletRequest) {
|
|
||||||
PortalContextInfo info = WsUtil.getPortalContext(httpServletRequest);
|
|
||||||
this.notificationsMng = WsUtil.getNotificationManager(httpServletRequest);
|
|
||||||
this.userId = info.getUsername();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the notifications mng.
|
|
||||||
*
|
|
||||||
* @return the notifications mng
|
|
||||||
*/
|
|
||||||
public NotificationsManager getNotificationsMng() {
|
|
||||||
return notificationsMng;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the notification mng.
|
|
||||||
*
|
|
||||||
* @param notificationMng the new notification mng
|
|
||||||
*/
|
|
||||||
public void setNotificationMng(NotificationsManager notificationMng) {
|
|
||||||
this.notificationsMng = notificationMng;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Runs a new thread to notify the contacts passed in input.
|
|
||||||
*
|
|
||||||
* @param listContacts the list contacts
|
|
||||||
* @param sharedFolder the shared folder
|
|
||||||
*/
|
|
||||||
public void notifyFolderSharing(final List<InfoContactModel> listContacts, final WorkspaceSharedFolder sharedFolder) {
|
|
||||||
|
|
||||||
new Thread(){
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
|
|
||||||
logger.trace("Send notifies folder sharing is running...");
|
|
||||||
|
|
||||||
for (InfoContactModel infoContactModel : listContacts) {
|
|
||||||
try{
|
|
||||||
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
|
|
||||||
if(infoContactModel.getLogin().compareTo(userId)!=0){
|
|
||||||
|
|
||||||
logger.debug("Sending notification new share folder "+sharedFolder.getName()+" for user "+infoContactModel.getLogin());
|
|
||||||
|
|
||||||
//DEBUG
|
|
||||||
// System.out.println("Sending notification new share folder "+sharedFolder.getName()+" for user "+infoContactModel.getLogin());
|
|
||||||
|
|
||||||
boolean notify = notificationsMng.notifyFolderSharing(infoContactModel.getLogin(), sharedFolder);
|
|
||||||
|
|
||||||
|
|
||||||
if(!notify)
|
|
||||||
logger.error("An error occured when notify user: "+infoContactModel.getLogin());
|
|
||||||
}
|
|
||||||
}catch (Exception e) {
|
|
||||||
logger.error("An error occured in notifyFolderSharing ", e);
|
|
||||||
// e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.trace("notifies share folder is completed");
|
|
||||||
}
|
|
||||||
}.start();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Runs a new thread to notify the updated (add/remove) contacts to sharing.
|
|
||||||
*
|
|
||||||
* @param listSharedContact - list of contacts already shared
|
|
||||||
* @param listSharingContact - list of "new" contacts to share
|
|
||||||
* @param sharedFolder - the shared folder
|
|
||||||
*/
|
|
||||||
public void notifyUpdatedUsersToSharing(final List<InfoContactModel> listSharedContact, final List<InfoContactModel> listSharingContact, final WorkspaceSharedFolder sharedFolder) {
|
|
||||||
|
|
||||||
new Thread() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
|
|
||||||
try{
|
|
||||||
|
|
||||||
//NEW USER SHARED
|
|
||||||
DifferenceBetweenInfoContactModel diff = new DifferenceBetweenInfoContactModel(listSharingContact, listSharedContact);
|
|
||||||
|
|
||||||
List<InfoContactModel> listNewContactsShared = diff.getDifferentsContacts();
|
|
||||||
|
|
||||||
logger.info("list new contacts shared: "+listNewContactsShared.size());
|
|
||||||
|
|
||||||
if(listNewContactsShared.size()>0){
|
|
||||||
|
|
||||||
if(listNewContactsShared.size()==1){ //CASE ONLY ONE CONTACS WAS ADDED
|
|
||||||
|
|
||||||
InfoContactModel infoContactModel = listNewContactsShared.get(0);
|
|
||||||
|
|
||||||
for (InfoContactModel contact : listSharedContact) { //NOTIFIES ALREADY SHARED CONTACTS THAT A NEW USER WAS ADDED
|
|
||||||
|
|
||||||
try{
|
|
||||||
|
|
||||||
logger.trace("Sending notification to user "+contact.getLogin()+", added user "+ infoContactModel.getLogin() +" to share folder "+sharedFolder.getName());
|
|
||||||
|
|
||||||
//DEBUG
|
|
||||||
// System.out.println("Sending notification added user "+ infoContactModel.getLogin() +" to share folder "+sharedFolder.getName() + " for user "+contact.getLogin());
|
|
||||||
|
|
||||||
boolean notify = notificationsMng.notifyFolderAddedUser(contact.getLogin(), sharedFolder, infoContactModel.getLogin());
|
|
||||||
|
|
||||||
if(!notify)
|
|
||||||
logger.error("An error occured when notifies user: "+contact.getLogin());
|
|
||||||
|
|
||||||
}catch (Exception e) {
|
|
||||||
logger.error("An error occured in notifyFolderAddedUser ", e);
|
|
||||||
// e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
List<InfoContactModel> listCts = new ArrayList<InfoContactModel>();
|
|
||||||
listCts.add(infoContactModel);
|
|
||||||
notifyFolderSharing(listCts, sharedFolder); //NOTIFIER NEW USER OF SHARING FOLDER
|
|
||||||
|
|
||||||
}else{ //CASE MORE THEN ONE CONTACT WAS ADDED
|
|
||||||
|
|
||||||
List<String> listLogins = UserUtil.getListLoginByInfoContactModel(listNewContactsShared);
|
|
||||||
|
|
||||||
for (InfoContactModel contact : listSharedContact) { //NOTIFIES ALREADY SHARED CONTACTS THATH A NEW USER WAS ADDED
|
|
||||||
|
|
||||||
try{
|
|
||||||
|
|
||||||
logger.trace("Sending notification to user "+contact.getLogin()+", added "+listLogins.size()+" users to share folder "+sharedFolder.getName());
|
|
||||||
|
|
||||||
//DEBUG
|
|
||||||
// System.out.println("Sending notification added user "+ infoContactModel.getLogin() +" to share folder "+sharedFolder.getName() + " for user "+contact.getLogin());
|
|
||||||
|
|
||||||
boolean notify = notificationsMng.notifyFolderAddedUsers(contact.getLogin(), sharedFolder, listLogins);
|
|
||||||
|
|
||||||
if(!notify)
|
|
||||||
logger.error("An error occured when notifies user: "+contact.getLogin());
|
|
||||||
|
|
||||||
}catch (Exception e) {
|
|
||||||
logger.error("An error occured in notifyFolderAddedUser ", e);
|
|
||||||
// e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
notifyFolderSharing(listNewContactsShared, sharedFolder); //NOTIFIER NEW USER OF SHARING FOLDER
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//USER REMOVED FROM SHARE
|
|
||||||
DifferenceBetweenInfoContactModel diff2 = new DifferenceBetweenInfoContactModel(listSharedContact, listSharingContact);
|
|
||||||
|
|
||||||
List<InfoContactModel> listRemovedUsersFromShare = diff2.getDifferentsContacts();
|
|
||||||
|
|
||||||
logger.info("list removed contacts from share: "+listRemovedUsersFromShare.size());
|
|
||||||
|
|
||||||
if(listRemovedUsersFromShare.size()>0){
|
|
||||||
|
|
||||||
for (InfoContactModel contact : listRemovedUsersFromShare)
|
|
||||||
notifyFolderRemovedUser(contact, sharedFolder);
|
|
||||||
}
|
|
||||||
|
|
||||||
}catch (Exception e) {
|
|
||||||
logger.error("An error occured in notifyAddedUserToSharing ", e);
|
|
||||||
// e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}.start();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Runs a new thread to notify the contacts passed in input.
|
|
||||||
*
|
|
||||||
* @param listContacts the list contacts
|
|
||||||
* @param unShareFolderId the un share folder id
|
|
||||||
* @param unSharedFolderName the un shared folder name
|
|
||||||
*/
|
|
||||||
public void notifyFolderUnSharing(final List<InfoContactModel> listContacts, final String unShareFolderId, final String unSharedFolderName) {
|
|
||||||
|
|
||||||
|
|
||||||
new Thread() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
|
|
||||||
// printContacts(listContacts);
|
|
||||||
logger.trace("Send notifies folder un share is running...");
|
|
||||||
|
|
||||||
for (InfoContactModel infoContactModel : listContacts) {
|
|
||||||
try{
|
|
||||||
|
|
||||||
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
|
|
||||||
if(infoContactModel.getLogin().compareTo(userId)!=0){
|
|
||||||
|
|
||||||
logger.trace("Sending notification to user "+infoContactModel.getLogin() +" unshare folder "+unSharedFolderName);
|
|
||||||
|
|
||||||
//DEBUG
|
|
||||||
// System.out.println("Sending notification to user "+infoContactModel.getLogin() +" un shared folder "+unSharedFolder.getName());
|
|
||||||
// boolean notify = notificationsMng.notifyFolderRemovedUser(infoContactModel.getLogin(), (WorkspaceSharedFolder) unSharedFolder);
|
|
||||||
|
|
||||||
boolean notify = notificationsMng.notifyFolderUnsharing(infoContactModel.getLogin(), unShareFolderId, unSharedFolderName);
|
|
||||||
if(!notify)
|
|
||||||
logger.error("An error occured when notifies user: "+infoContactModel.getLogin());
|
|
||||||
}
|
|
||||||
}catch (Exception e) {
|
|
||||||
logger.error("An error occured in notifyFolderUnSharing ", e);
|
|
||||||
// e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.trace("notifies of un share notifications is completed");
|
|
||||||
}
|
|
||||||
|
|
||||||
}.start();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Notify folder removed user.
|
|
||||||
*
|
|
||||||
* @param userUnShared the user un shared
|
|
||||||
* @param shareFolder the share folder
|
|
||||||
*/
|
|
||||||
public void notifyFolderRemovedUser(final InfoContactModel userUnShared, final WorkspaceSharedFolder shareFolder) {
|
|
||||||
|
|
||||||
new Thread() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
|
|
||||||
logger.trace("Send notifies removed user from shared folder is running...");
|
|
||||||
try{
|
|
||||||
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
|
|
||||||
if(userUnShared.getLogin().compareTo(userId)!=0){
|
|
||||||
|
|
||||||
logger.debug("Sending notification to user "+userUnShared.getLogin() +" unshared from folder "+shareFolder.getName());
|
|
||||||
boolean notify = notificationsMng.notifyFolderRemovedUser(userUnShared.getLogin(), shareFolder);
|
|
||||||
|
|
||||||
if(!notify)
|
|
||||||
logger.error("An error occured when notifies user: "+userUnShared.getLogin());
|
|
||||||
}
|
|
||||||
|
|
||||||
}catch (Exception e) {
|
|
||||||
logger.error("An error occured in notifyFolderRemovedUser ", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.trace("notifies of un unshare user is completed");
|
|
||||||
}
|
|
||||||
|
|
||||||
}.start();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Runs a new thread to notify the contacts passed in input.
|
|
||||||
*
|
|
||||||
* @param listContacts the list contacts
|
|
||||||
* @param workspaceItem the workspace item
|
|
||||||
* @param sharedFolder the shared folder
|
|
||||||
*/
|
|
||||||
public void notifyAddedItemToSharing(final List<InfoContactModel> listContacts, final WorkspaceItem workspaceItem, final WorkspaceSharedFolder sharedFolder) {
|
|
||||||
|
|
||||||
new Thread() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
|
|
||||||
// printContacts(listContacts);
|
|
||||||
logger.trace("Send notifies added item in sharedfolder is running...");
|
|
||||||
|
|
||||||
//DEBUG
|
|
||||||
System.out.println("Send notifies added item in sharedfolder is running...");
|
|
||||||
|
|
||||||
for (InfoContactModel infoContactModel : listContacts) {
|
|
||||||
try{
|
|
||||||
|
|
||||||
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
|
|
||||||
if(infoContactModel.getLogin().compareTo(userId)!=0){
|
|
||||||
|
|
||||||
logger.info("Sending notification to user "+infoContactModel.getLogin() +" added item [id: "+workspaceItem.getId() +"] name: "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName());
|
|
||||||
|
|
||||||
//DEBUG
|
|
||||||
// System.out.println("Send notify folder un share user "+infoContactModel.getLogin());
|
|
||||||
|
|
||||||
boolean notify = notificationsMng.notifyAddedItem(infoContactModel.getLogin(), workspaceItem, sharedFolder);
|
|
||||||
|
|
||||||
if(!notify){
|
|
||||||
logger.error("An error occured when notify user: "+infoContactModel.getLogin());
|
|
||||||
//DEBUG
|
|
||||||
// System.out.println("An error occured when notify user: "+infoContactModel.getLogin());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}catch (Exception e) {
|
|
||||||
logger.error("An error occured in notifyAddedItemToSharing ", e);
|
|
||||||
// e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.trace("notifies of added item in shared folder is completed");
|
|
||||||
|
|
||||||
//DEBUG
|
|
||||||
// System.out.println("notifies of added item in shared folder is completed");
|
|
||||||
}
|
|
||||||
|
|
||||||
}.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Runs a new thread to notify the contacts passed in input.
|
|
||||||
*
|
|
||||||
* @param listContacts the list contacts
|
|
||||||
* @param workspaceItem the workspace item
|
|
||||||
* @param sharedFolder the shared folder
|
|
||||||
*/
|
|
||||||
public void notifyUpdatedItemToSharing(final List<InfoContactModel> listContacts, final WorkspaceItem workspaceItem, final WorkspaceSharedFolder sharedFolder) {
|
|
||||||
|
|
||||||
new Thread() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
|
|
||||||
// printContacts(listContacts);
|
|
||||||
logger.trace("Send notifies updated item in shared folder is running...");
|
|
||||||
|
|
||||||
//DEBUG
|
|
||||||
// System.out.println("Send notifies updated item in shared folder is running...");
|
|
||||||
|
|
||||||
for (InfoContactModel infoContactModel : listContacts) {
|
|
||||||
try{
|
|
||||||
|
|
||||||
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
|
|
||||||
if(infoContactModel.getLogin().compareTo(userId)!=0){
|
|
||||||
|
|
||||||
logger.trace("Sending notification to user "+infoContactModel.getLogin() +" updated item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName());
|
|
||||||
|
|
||||||
//DEBUG
|
|
||||||
// System.out.println("Sending notification to user "+infoContactModel.getLogin() +" updated item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName());
|
|
||||||
|
|
||||||
//DEBUG
|
|
||||||
// System.out.println("Send notify folder un share user "+infoContactModel.getLogin());
|
|
||||||
|
|
||||||
boolean notify = notificationsMng.notifyUpdatedItem(infoContactModel.getLogin(), workspaceItem, sharedFolder);
|
|
||||||
|
|
||||||
if(!notify){
|
|
||||||
logger.error("An error updated when notify user: "+infoContactModel.getLogin());
|
|
||||||
//DEBUG
|
|
||||||
// System.out.println("An error updated when notify user: "+infoContactModel.getLogin());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}catch (Exception e) {
|
|
||||||
logger.error("An error updated in notifyAddedItemToSharing ", e);
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.trace("notifies of updated item in shared folder is completed");
|
|
||||||
|
|
||||||
//DEBUG
|
|
||||||
// System.out.println("notifies of updated item in shared folder is completed");
|
|
||||||
}
|
|
||||||
|
|
||||||
}.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Runs a new thread to notify the contacts passed in input.
|
|
||||||
*
|
|
||||||
* @param listContacts the list contacts
|
|
||||||
* @param workspaceItem the workspace item
|
|
||||||
* @param sharedFolder the shared folder
|
|
||||||
*/
|
|
||||||
public void notifyMovedItemToSharing(final List<InfoContactModel> listContacts, final WorkspaceItem workspaceItem, final WorkspaceSharedFolder sharedFolder) {
|
|
||||||
|
|
||||||
|
|
||||||
new Thread() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
|
|
||||||
logger.trace("Sending notification remove item in shared folder is running...");
|
|
||||||
// printContacts(listContacts);
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
if(NotificationsUtil.checkIsRootFolderShared(workspaceItem.getId(), sharedFolder.getId())){
|
|
||||||
logger.trace("Notification isn't sent because the event is on root shared folder");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (InternalErrorException e1) {
|
|
||||||
logger.error("An error occurred in checkIsRootFolderShared ", e1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.trace("Sending notification moved item in shared folder is running...");
|
|
||||||
|
|
||||||
// System.out.println("Sending notification moved item in shared folder is running...");
|
|
||||||
|
|
||||||
for (InfoContactModel infoContactModel : listContacts) {
|
|
||||||
try{
|
|
||||||
|
|
||||||
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
|
|
||||||
if(infoContactModel.getLogin().compareTo(userId)!=0){
|
|
||||||
|
|
||||||
logger.trace("Sending notification to user "+infoContactModel.getLogin() +" moved item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName());
|
|
||||||
|
|
||||||
//DEBUG
|
|
||||||
// System.out.println("Sending notification to user "+infoContactModel.getLogin() +" moved item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName());
|
|
||||||
|
|
||||||
boolean notify = notificationsMng.notifyMovedItem(infoContactModel.getLogin(), workspaceItem, sharedFolder);
|
|
||||||
|
|
||||||
if(!notify){
|
|
||||||
logger.error("An error occured when notify user: "+infoContactModel.getLogin());
|
|
||||||
|
|
||||||
//DEBUG
|
|
||||||
// System.out.println("An error occured when notify user: "+infoContactModel.getLogin());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}catch (Exception e) {
|
|
||||||
logger.error("An error occurred in notifyMovedItemToSharing ", e);
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.trace("notifies of moved item in shared folder is completed");
|
|
||||||
|
|
||||||
//DEBUG
|
|
||||||
// System.out.println("notifies of moved item in shared folder is completed");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}.start();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Runs a new thread to notify the contacts passed in input.
|
|
||||||
*
|
|
||||||
* @param listContacts the list contacts
|
|
||||||
* @param itemName the item name
|
|
||||||
* @param sharedFolder the shared folder
|
|
||||||
*/
|
|
||||||
public void notifyRemovedItemToSharing(final List<InfoContactModel> listContacts, final String itemName, final WorkspaceSharedFolder sharedFolder) {
|
|
||||||
|
|
||||||
|
|
||||||
new Thread() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
|
|
||||||
logger.trace("Sending notification remove item in shared folder is running...");
|
|
||||||
// printContacts(listContacts);
|
|
||||||
|
|
||||||
if(itemName==null || itemName.isEmpty()){
|
|
||||||
logger.trace("Notification isn't sent - itemName is null or empty");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(sharedFolder==null){
|
|
||||||
logger.trace("Notification isn't sent - sharedFolder is null");
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.trace("Sending notification removed item in shared folder is running...");
|
|
||||||
|
|
||||||
// System.out.println("Sending notification removed item in shared folder is running...");
|
|
||||||
|
|
||||||
for (InfoContactModel infoContactModel : listContacts) {
|
|
||||||
try{
|
|
||||||
|
|
||||||
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
|
|
||||||
if(infoContactModel.getLogin().compareTo(userId)!=0){
|
|
||||||
|
|
||||||
logger.trace("Sending notification to user "+infoContactModel.getLogin() +" removed item "+itemName+" in shared folder "+sharedFolder.getName());
|
|
||||||
|
|
||||||
//DEBUG
|
|
||||||
// System.out.println("Sending notification to user "+infoContactModel.getLogin() +" removed item "+itemName+" in shared folder "+sharedFolder.getName());
|
|
||||||
|
|
||||||
boolean notify = notificationsMng.notifyRemovedItem(infoContactModel.getLogin(), itemName, sharedFolder);
|
|
||||||
|
|
||||||
if(!notify){
|
|
||||||
logger.error("An error occured when notify user: "+infoContactModel.getLogin());
|
|
||||||
|
|
||||||
//DEBUG
|
|
||||||
// System.out.println("An error occured when notify user: "+infoContactModel.getLogin());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}catch (Exception e) {
|
|
||||||
logger.error("An error occurred in notifyRemovedItemToSharing ", e);
|
|
||||||
// e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.trace("notifies of moved item in shared folder is completed");
|
|
||||||
|
|
||||||
//DEBUG
|
|
||||||
// System.out.println("notifies of moved item in shared folder is completed");
|
|
||||||
}
|
|
||||||
}.start();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Runs a new thread to notify the contacts passed in input.
|
|
||||||
*
|
|
||||||
* @param listContacts the list contacts
|
|
||||||
* @param folderNameDeleted the folder name deleted
|
|
||||||
*/
|
|
||||||
public void notifySharedFolderDeleted(final List<InfoContactModel> listContacts, final String folderNameDeleted) {
|
|
||||||
|
|
||||||
|
|
||||||
new Thread() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
|
|
||||||
// printContacts(listContacts);
|
|
||||||
logger.trace("Send notifies shared folder deleted is running...");
|
|
||||||
|
|
||||||
for (InfoContactModel infoContactModel : listContacts) {
|
|
||||||
try{
|
|
||||||
|
|
||||||
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
|
|
||||||
if(infoContactModel.getLogin().compareTo(userId)!=0){
|
|
||||||
|
|
||||||
logger.trace("Sending notification to user "+infoContactModel.getLogin() +" deleted shared folder "+folderNameDeleted);
|
|
||||||
|
|
||||||
//DEBUG
|
|
||||||
System.out.println("Sending notification to user "+infoContactModel.getLogin() +" deleted shared folder "+folderNameDeleted);
|
|
||||||
|
|
||||||
//TODO
|
|
||||||
// boolean notify = notificationsMng.
|
|
||||||
|
|
||||||
// if(!notify)
|
|
||||||
// logger.error("An error occured when notifies user: "+infoContactModel.getLogin());
|
|
||||||
}
|
|
||||||
}catch (Exception e) {
|
|
||||||
logger.error("An error occured in notifySharedFolderDeleted ", e);
|
|
||||||
// e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.trace("notifies of deleted shared foder is completed");
|
|
||||||
}
|
|
||||||
|
|
||||||
}.start();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Runs a new thread to notify the contacts passed in input.
|
|
||||||
*
|
|
||||||
* @param userToNotify the user to notify
|
|
||||||
* @param sharedFolder the shared folder
|
|
||||||
*/
|
|
||||||
public void notifyAdministratorUpgrade(final InfoContactModel userToNotify, final WorkspaceSharedFolder sharedFolder){
|
|
||||||
|
|
||||||
new Thread() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
|
|
||||||
// printContacts(listContacts);
|
|
||||||
logger.trace("Send notifies administrator upgrade is running...");
|
|
||||||
if(userToNotify==null || userToNotify.getLogin()==null){
|
|
||||||
logger.warn("Notification abort user to notify is null...");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(sharedFolder==null){
|
|
||||||
logger.warn("Notification abort sharedFolder to notify is null...");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try{
|
|
||||||
String login = userToNotify.getLogin();
|
|
||||||
logger.trace("Send notifies administrator upgrade for login: "+login);
|
|
||||||
|
|
||||||
boolean notify = notificationsMng.notifyAdministratorUpgrade(login, sharedFolder);
|
|
||||||
logger.trace("Notification sent correctly? "+notify);
|
|
||||||
}catch (Exception e) {
|
|
||||||
logger.error("An error occured in notifyAdministratorUpgrade ", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
logger.trace("notifies of administrator upgrade completed");
|
|
||||||
}
|
|
||||||
|
|
||||||
}.start();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Runs a new thread to notify the contacts passed in input.
|
|
||||||
*
|
|
||||||
* @param userToNotify the user to notify
|
|
||||||
* @param sharedFolder the shared folder
|
|
||||||
*/
|
|
||||||
public void notifyAdministratorDowngrade(final InfoContactModel userToNotify, final WorkspaceSharedFolder sharedFolder){
|
|
||||||
|
|
||||||
new Thread() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
|
|
||||||
// printContacts(listContacts);
|
|
||||||
logger.trace("Send notifies administrator Downgrade is running...");
|
|
||||||
if(userToNotify==null || userToNotify.getLogin()==null){
|
|
||||||
logger.warn("Notification abort user to notify is null...");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(sharedFolder==null){
|
|
||||||
logger.warn("Notification abort sharedFolder to notify is null...");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try{
|
|
||||||
String login = userToNotify.getLogin();
|
|
||||||
logger.trace("Send notifies administrator Downgrade for login: "+login);
|
|
||||||
|
|
||||||
boolean notify = notificationsMng.notifyAdministratorDowngrade(login, sharedFolder);
|
|
||||||
logger.trace("Notification sent correctly? "+notify);
|
|
||||||
}catch (Exception e) {
|
|
||||||
logger.error("An error occured in notifyAdministratorDowngrade ", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
logger.trace("notifies of administrator Downgrade completed");
|
|
||||||
}
|
|
||||||
|
|
||||||
}.start();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//DEBUG
|
|
||||||
/**
|
|
||||||
* Prints the contacts.
|
|
||||||
*
|
|
||||||
* @param listContacts the list contacts
|
|
||||||
*/
|
|
||||||
private void printContacts(List<InfoContactModel> listContacts){
|
|
||||||
|
|
||||||
System.out.println("Print contacts");
|
|
||||||
for (InfoContactModel infoContactModel : listContacts) {
|
|
||||||
System.out.println(infoContactModel);
|
|
||||||
}
|
|
||||||
System.out.println("End print contacts");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,252 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package org.gcube.portlets.user.workspace.server.notifications;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpSession;
|
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.gcube.common.homelibary.model.items.type.WorkspaceItemType;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceSharedFolder;
|
|
||||||
import org.gcube.portlets.user.workspace.server.GWTWorkspaceBuilder;
|
|
||||||
import org.gcube.portlets.user.workspace.server.util.WsUtil;
|
|
||||||
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Class NotificationsUtil.
|
|
||||||
*
|
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
|
||||||
* May 27, 2013
|
|
||||||
*/
|
|
||||||
public class NotificationsUtil {
|
|
||||||
|
|
||||||
|
|
||||||
protected static Logger logger = Logger.getLogger(NotificationsUtil.class);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send a notification if an item is added or updated to sharing folder.
|
|
||||||
*
|
|
||||||
* @param request the request
|
|
||||||
* @param httpSession the http session
|
|
||||||
* @param sourceItem the source item
|
|
||||||
* @param sourceSharedId the source shared id
|
|
||||||
* @param folderDestinationItem the folder destination item
|
|
||||||
* @param isOverwrite the is overwrite
|
|
||||||
*/
|
|
||||||
public static void checkSendNotifyChangedItemToShare(HttpServletRequest request, HttpSession httpSession, final WorkspaceItem sourceItem, final String sourceSharedId, final WorkspaceItem folderDestinationItem, boolean isOverwrite) {
|
|
||||||
|
|
||||||
logger.trace("checkSendNotifyAddItemToShare");
|
|
||||||
|
|
||||||
if(folderDestinationItem!=null){
|
|
||||||
|
|
||||||
try{
|
|
||||||
if(folderDestinationItem.isShared()){ //Notify Added Item To Sharing?
|
|
||||||
|
|
||||||
logger.trace("checkNotifyAddItemToShare source item: "+sourceItem.getName()+" sourceSharedId: "+sourceSharedId + " folder destination: "+folderDestinationItem.getName() + " folder destination shared folder id: "+folderDestinationItem.getIdSharedFolder());
|
|
||||||
//share condition is true if source shared folder is not null
|
|
||||||
boolean shareChangeCondition = sourceSharedId==null?false:true;
|
|
||||||
//System.out.println("shareChangeCondition add item: "+ shareChangeCondition);
|
|
||||||
logger.trace("shareChangeCondition add item: "+shareChangeCondition);
|
|
||||||
|
|
||||||
//if shareChangeCondition is true.. notifies added item to sharing
|
|
||||||
if(shareChangeCondition){
|
|
||||||
|
|
||||||
Workspace workspace = WsUtil.getWorkspace(request);
|
|
||||||
List<InfoContactModel> listContacts = getListUsersSharedByFolderSharedId(workspace, folderDestinationItem.getIdSharedFolder());
|
|
||||||
WorkspaceItem destinationSharedFolder = workspace.getItem(folderDestinationItem.getIdSharedFolder());
|
|
||||||
NotificationsProducer np = new NotificationsProducer(request);
|
|
||||||
|
|
||||||
if(destinationSharedFolder instanceof WorkspaceSharedFolder){
|
|
||||||
|
|
||||||
//SWITCH BEETWEEN ADDED OR UPDATED
|
|
||||||
if(!isOverwrite)
|
|
||||||
np.notifyAddedItemToSharing(listContacts, sourceItem, (WorkspaceSharedFolder) destinationSharedFolder);
|
|
||||||
else
|
|
||||||
np.notifyUpdatedItemToSharing(listContacts, sourceItem, (WorkspaceSharedFolder) destinationSharedFolder);
|
|
||||||
|
|
||||||
logger.trace("The notifies was sent correctly");
|
|
||||||
}else
|
|
||||||
logger.trace("The notifies doesn't sent because "+destinationSharedFolder+ " is not instance of WorkspaceSharedFolder");
|
|
||||||
// np.notifyAddedItemToSharing(listContacts, (WorkspaceFolder) folderDestinationItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
logger.trace("folder destination is not shared");
|
|
||||||
|
|
||||||
}catch (Exception e) {
|
|
||||||
logger.error("An error occurred in checkSendNotifyAddItemToShare ",e);
|
|
||||||
}
|
|
||||||
}else
|
|
||||||
logger.warn("The notifies is failure in checkSendNotifyAddItemToShare because folder destination item is null");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the list users shared by folder shared id.
|
|
||||||
*
|
|
||||||
* @param workspace the workspace
|
|
||||||
* @param idSharedFolder the id shared folder
|
|
||||||
* @return the list users shared by folder shared id
|
|
||||||
* @throws Exception the exception
|
|
||||||
*/
|
|
||||||
public static List<InfoContactModel> getListUsersSharedByFolderSharedId(Workspace workspace, String idSharedFolder) throws Exception {
|
|
||||||
|
|
||||||
logger.trace("getListUsersSharedByFolderSharedId "+ idSharedFolder);
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
WorkspaceItem wsItem = workspace.getItem(idSharedFolder);
|
|
||||||
|
|
||||||
if(isASharedFolder(wsItem)){
|
|
||||||
|
|
||||||
WorkspaceSharedFolder wsFolder = (WorkspaceSharedFolder) wsItem;
|
|
||||||
GWTWorkspaceBuilder builder = new GWTWorkspaceBuilder();
|
|
||||||
List<String> listPortalLogin = wsFolder.getUsers();
|
|
||||||
logger.trace("getListUserSharedByFolderSharedId return "+ listPortalLogin.size() + " user");
|
|
||||||
return builder.buildGxtInfoContactsFromPortalLogins(listPortalLogin);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
logger.trace("the item with id: "+idSharedFolder+ " is not "+WorkspaceItemType.SHARED_FOLDER);
|
|
||||||
|
|
||||||
//DEBUG
|
|
||||||
//System.out.println("the item with id: "+folderSharedId+ " is not "+WorkspaceItemType.SHARED_FOLDER);
|
|
||||||
}
|
|
||||||
return new ArrayList<InfoContactModel>();
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("Error in getListUserSharedByItemId ", e);
|
|
||||||
throw new Exception(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check send notify remove item to share.
|
|
||||||
*
|
|
||||||
* @param request the request
|
|
||||||
* @param sourceItemIsShared the source item is shared
|
|
||||||
* @param oldItemName the old item name
|
|
||||||
* @param oldItemId the old item id
|
|
||||||
* @param sourceFolderSharedId the source folder shared id
|
|
||||||
*/
|
|
||||||
public static void checkSendNotifyRemoveItemToShare(HttpServletRequest request, final boolean sourceItemIsShared, final String oldItemName, String oldItemId, final String sourceFolderSharedId) {
|
|
||||||
|
|
||||||
logger.trace("checkNotifyRemoveItemToShare:");
|
|
||||||
|
|
||||||
try{
|
|
||||||
|
|
||||||
if(!sourceItemIsShared){
|
|
||||||
logger.trace("checkSendNotifyRemoveItemToShare returned, source item is not shared");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String idSharedFolder = sourceFolderSharedId!=null?sourceFolderSharedId:"";
|
|
||||||
boolean isRootFolderShared = checkIsRootFolderShared(oldItemId, idSharedFolder);
|
|
||||||
logger.trace("isRootFolderShared is: "+ isRootFolderShared);
|
|
||||||
/*
|
|
||||||
if(isRootFolderShared){
|
|
||||||
logger.trace("Notification doesn't sent because the event is on root shared folder");
|
|
||||||
return;
|
|
||||||
}*/
|
|
||||||
boolean isSharedFolder = isASharedFolderForId(request,idSharedFolder);
|
|
||||||
if(isSharedFolder){
|
|
||||||
|
|
||||||
logger.trace("idSharedFolder is: "+ idSharedFolder +" is shared folder: "+isSharedFolder);
|
|
||||||
Workspace workspace = WsUtil.getWorkspace(request);
|
|
||||||
//get contacts
|
|
||||||
List<InfoContactModel> listContacts = getListUsersSharedByFolderSharedId(workspace, idSharedFolder);
|
|
||||||
WorkspaceItem sourceSharedFolder = workspace.getItem(idSharedFolder);
|
|
||||||
//System.out.println(" name sourceSharedFolder: "+ sourceSharedFolder.getName());
|
|
||||||
NotificationsProducer np = new NotificationsProducer(request);
|
|
||||||
|
|
||||||
//Notify Removed Item To Sharing?
|
|
||||||
if(!isRootFolderShared){
|
|
||||||
if(sourceSharedFolder instanceof WorkspaceSharedFolder){
|
|
||||||
np.notifyRemovedItemToSharing(listContacts, oldItemName, (WorkspaceSharedFolder) sourceSharedFolder);
|
|
||||||
logger.trace("The notifies was sent correctly");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
logger.trace("The notifies doesn't sent because "+sourceSharedFolder+ " is not instance of WorkspaceSharedFolder");
|
|
||||||
|
|
||||||
}else{
|
|
||||||
//Case removed shared folder
|
|
||||||
np.notifySharedFolderDeleted(listContacts, oldItemName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}catch (Exception e) {
|
|
||||||
logger.error("An error occurred in checkSendNotifyRemoveItemToShare ",e);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if is a shared folder.
|
|
||||||
*
|
|
||||||
* @param wsItem the ws item
|
|
||||||
* @return true, if is a shared folder
|
|
||||||
*/
|
|
||||||
public static boolean isASharedFolder(WorkspaceItem wsItem){
|
|
||||||
if(wsItem!=null)
|
|
||||||
return wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if is a shared folder for id.
|
|
||||||
*
|
|
||||||
* @param request the request
|
|
||||||
* @param itemId the item id
|
|
||||||
* @return true, if is a shared folder for id
|
|
||||||
*/
|
|
||||||
public static boolean isASharedFolderForId(HttpServletRequest request, String itemId){
|
|
||||||
|
|
||||||
if(itemId==null || itemId.isEmpty())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
Workspace workspace = WsUtil.getWorkspace(request);
|
|
||||||
|
|
||||||
WorkspaceItem wsItem = workspace.getItem(itemId);
|
|
||||||
|
|
||||||
if(wsItem!=null)
|
|
||||||
return wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER);
|
|
||||||
return false;
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("An errror occurred in isASharedFolderForId", e);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check is root folder shared.
|
|
||||||
*
|
|
||||||
* @param itemId the item id
|
|
||||||
* @param rootFolderSharedId the root folder shared id
|
|
||||||
* @return true, if successful
|
|
||||||
*/
|
|
||||||
public static boolean checkIsRootFolderShared(String itemId, String rootFolderSharedId) {
|
|
||||||
|
|
||||||
logger.trace("checkIsRootFolderShared between [itemid: "+itemId +", rootFolderSharedId: "+rootFolderSharedId+"]");
|
|
||||||
if(itemId==null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if(rootFolderSharedId==null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if(itemId.compareTo(rootFolderSharedId)==0)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -3,25 +3,22 @@
|
||||||
*/
|
*/
|
||||||
package org.gcube.portlets.user.workspace.server.notifications.tostoragehub;
|
package org.gcube.portlets.user.workspace.server.notifications.tostoragehub;
|
||||||
|
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.gcube.applicationsupportlayer.social.shared.SocialFileItem;
|
import org.gcube.applicationsupportlayer.social.shared.SocialFileItem;
|
||||||
import org.gcube.applicationsupportlayer.social.shared.SocialSharedFolder;
|
import org.gcube.applicationsupportlayer.social.shared.SocialSharedFolder;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder;
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class NotificationMapper.
|
* The Class NotificationMapper.
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
||||||
* Oct 2, 2018
|
* Oct 2, 2018
|
||||||
*/
|
*/
|
||||||
public class NotificationMapperToStorageHub {
|
public class NotificationMapperToStorageHub {
|
||||||
|
|
||||||
protected static Logger logger = Logger.getLogger(NotificationMapperToStorageHub.class);
|
protected static Logger logger = LoggerFactory.getLogger(NotificationMapperToStorageHub.class);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To social shared folder.
|
* To social shared folder.
|
||||||
|
@ -29,39 +26,33 @@ public class NotificationMapperToStorageHub {
|
||||||
* @param sharedFolder the shared folder
|
* @param sharedFolder the shared folder
|
||||||
* @return the social shared folder
|
* @return the social shared folder
|
||||||
*/
|
*/
|
||||||
public static SocialSharedFolder toSocialSharedFolder(WorkspaceSharedFolder sharedFolder){
|
public static SocialSharedFolder toSocialSharedFolder(WorkspaceSharedFolder sharedFolder) {
|
||||||
|
|
||||||
return new SocialSharedFolder(sharedFolder.getId(),
|
return new SocialSharedFolder(sharedFolder.getId(), sharedFolder.getName(), sharedFolder.getTitle(),
|
||||||
sharedFolder.getName(),
|
sharedFolder.getName(), sharedFolder.getPath(), sharedFolder.getParentId(), sharedFolder.isVreFolder());
|
||||||
sharedFolder.getTitle(),
|
|
||||||
sharedFolder.getName(),
|
|
||||||
sharedFolder.getPath(),
|
|
||||||
sharedFolder.getParentId(),
|
|
||||||
sharedFolder.isVreFolder());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To social item.
|
* To social item.
|
||||||
*
|
*
|
||||||
* @param workspace the workspace
|
* @param workspace the workspace
|
||||||
* @param item the item
|
* @param item the item
|
||||||
* @return the social file item
|
* @return the social file item
|
||||||
*/
|
*/
|
||||||
public static SocialFileItem toSocialItem(org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace, WorkspaceItem item){
|
public static SocialFileItem toSocialItem(org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace,
|
||||||
|
WorkspaceItem item) {
|
||||||
|
|
||||||
WorkspaceItem theParentFolder = null;
|
WorkspaceItem theParentFolder = null;
|
||||||
try {
|
try {
|
||||||
theParentFolder = workspace.getItem(item.getParentId());
|
theParentFolder = workspace.getItem(item.getParentId());
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e) {
|
logger.warn("Impossible the item using the parent id: " + item.getParentId());
|
||||||
logger.warn("Impossible the item using the parent id: "+item.getParentId());
|
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
SocialSharedFolder parent = null;
|
SocialSharedFolder parent = null;
|
||||||
if(theParentFolder!=null && theParentFolder instanceof WorkspaceSharedFolder)
|
if (theParentFolder != null && theParentFolder instanceof WorkspaceSharedFolder)
|
||||||
parent = toSocialSharedFolder((WorkspaceSharedFolder) theParentFolder);
|
parent = toSocialSharedFolder((WorkspaceSharedFolder) theParentFolder);
|
||||||
//
|
//
|
||||||
return new SocialFileItem(item.getId(), item.getName(), item.getTitle(), item.getPath(), parent);
|
return new SocialFileItem(item.getId(), item.getName(), item.getTitle(), item.getPath(), parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,42 +6,46 @@ package org.gcube.portlets.user.workspace.server.notifications.tostoragehub;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import org.gcube.common.storagehub.model.types.WorkspaceItemType;
|
import org.gcube.common.storagehub.model.types.WorkspaceItemType;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder;
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder;
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder;
|
||||||
import org.gcube.portlets.user.workspace.server.GWTWorkspaceBuilder;
|
import org.gcube.portlets.user.workspace.server.tostoragehub.StorageHubToWorkpaceConverter;
|
||||||
import org.gcube.portlets.user.workspace.server.util.WsUtil;
|
import org.gcube.portlets.user.workspace.server.util.WsUtil;
|
||||||
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
|
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class NotificationFromStorageHub.
|
* The Class NotificationStorageHubUtil.
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
* Oct 2, 2018
|
*
|
||||||
|
* Jul 31, 2019
|
||||||
*/
|
*/
|
||||||
public class NotificationStorageHubUtil {
|
public class NotificationStorageHubUtil {
|
||||||
|
|
||||||
private static Logger logger = Logger.getLogger(NotificationStorageHubUtil.class);
|
private static Logger logger = LoggerFactory.getLogger(NotificationStorageHubUtil.class);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check notify add item to share.
|
* Check notify add item to share.
|
||||||
*
|
*
|
||||||
* @param workspaceItem the workspace item
|
* @param workspaceItem the workspace item
|
||||||
* @param sourceRootSharedFolderId the source shared id
|
* @param sourceRootSharedFolderId the source root shared folder id
|
||||||
* @param parentFolderItem the parent folder item
|
* @param parentFolderItem the parent folder item
|
||||||
* @param workspace the workspace
|
* @param workspace the workspace
|
||||||
* @param np the NotificationsProducerToStorageHub
|
* @param np the np
|
||||||
*/
|
*/
|
||||||
public static void checkNotifyAddItemToShare(final WorkspaceItem workspaceItem, final String sourceRootSharedFolderId, final WorkspaceFolder parentFolderItem, org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace, NotificationsProducerToStorageHub np) {
|
public static void checkNotifyAddItemToShare(final WorkspaceItem workspaceItem, final String sourceRootSharedFolderId, final WorkspaceFolder parentFolderItem, org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace, NotificationsProducerToStorageHub np) {
|
||||||
|
|
||||||
logger.trace("checkNotifyAddItemToShare");
|
|
||||||
|
|
||||||
if(parentFolderItem!=null){
|
if(parentFolderItem!=null){
|
||||||
|
|
||||||
|
logger.debug("Sending notification added item to share is running...");
|
||||||
try{
|
try{
|
||||||
//if folder destination is shared folder
|
//if folder destination is shared folder
|
||||||
if(parentFolderItem.isShared()){ //Notify Added Item To Sharing?
|
if(parentFolderItem.isShared()){ //Notify Added Item To Sharing?
|
||||||
|
@ -97,7 +101,8 @@ public class NotificationStorageHubUtil {
|
||||||
org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder folderDestination, org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace, NotificationsProducerToStorageHub np) {
|
org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder folderDestination, org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace, NotificationsProducerToStorageHub np) {
|
||||||
|
|
||||||
try{
|
try{
|
||||||
|
logger.debug("Sending notification moved item from share is running...");
|
||||||
|
|
||||||
String rootDestSharedFolderId = null;
|
String rootDestSharedFolderId = null;
|
||||||
WorkspaceItem rootDestSharedFolder = null;
|
WorkspaceItem rootDestSharedFolder = null;
|
||||||
|
|
||||||
|
@ -148,7 +153,7 @@ public class NotificationStorageHubUtil {
|
||||||
*/
|
*/
|
||||||
public static List<InfoContactModel> getListUserSharedByFolderSharedId(WorkspaceItem rootSharedFolder, org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace) throws Exception{
|
public static List<InfoContactModel> getListUserSharedByFolderSharedId(WorkspaceItem rootSharedFolder, org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace) throws Exception{
|
||||||
|
|
||||||
logger.debug("getListUserSharedByFolderSharedId "+ rootSharedFolder);
|
logger.debug("called getListUserSharedByFolderSharedId on: "+ rootSharedFolder);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
@ -158,9 +163,14 @@ public class NotificationStorageHubUtil {
|
||||||
logger.debug("StorageHub returned "+ listPortalLogin.size() + " user/s");
|
logger.debug("StorageHub returned "+ listPortalLogin.size() + " user/s");
|
||||||
|
|
||||||
if(!WsUtil.isWithinPortal())
|
if(!WsUtil.isWithinPortal())
|
||||||
return GWTWorkspaceBuilder.buildGxtInfoContactFromPortalLoginTestMode(listPortalLogin);
|
return StorageHubToWorkpaceConverter.buildGxtInfoContactFromPortalLoginTestMode(listPortalLogin);
|
||||||
|
|
||||||
return GWTWorkspaceBuilder.buildGxtInfoContactsFromPortalLogins(listPortalLogin);
|
List<InfoContactModel> listContacts = new ArrayList<InfoContactModel>(listPortalLogin.size());
|
||||||
|
for (String login : listPortalLogin) {
|
||||||
|
listContacts.add(StorageHubToWorkpaceConverter.buildGxtInfoContactFromPortalLogin(login));
|
||||||
|
}
|
||||||
|
|
||||||
|
return listContacts;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
logger.debug("the item with id: "+rootSharedFolder.getId()+ " is not "+WorkspaceItemType.SHARED_FOLDER);
|
logger.debug("the item with id: "+rootSharedFolder.getId()+ " is not "+WorkspaceItemType.SHARED_FOLDER);
|
||||||
|
@ -172,6 +182,94 @@ public class NotificationStorageHubUtil {
|
||||||
throw new Exception(e.getMessage());
|
throw new Exception(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check send notify removed item from share.
|
||||||
|
*
|
||||||
|
* @param request the request
|
||||||
|
* @param sourceItemIsShared the source item is shared
|
||||||
|
* @param oldItemName the old item name
|
||||||
|
* @param oldItemId the old item id
|
||||||
|
* @param sourceFolderSharedId the source folder shared id
|
||||||
|
* @param workspace the workspace
|
||||||
|
* @param np the np
|
||||||
|
*/
|
||||||
|
public static void checkSendNotifyRemovedItemFromShare(HttpServletRequest request, final boolean sourceItemIsShared, final String oldItemName, String oldItemId, final String sourceFolderSharedId, org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace, NotificationsProducerToStorageHub np) {
|
||||||
|
|
||||||
|
try{
|
||||||
|
logger.debug("Sending notification removed item from share is running...");
|
||||||
|
if(!sourceItemIsShared){
|
||||||
|
logger.trace("checkSendNotifyRemoveItemToShare returned, source item is not shared");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String idSharedFolder = sourceFolderSharedId!=null?sourceFolderSharedId:"";
|
||||||
|
boolean isRootFolderShared = checkIsRootFolderShared(oldItemId, idSharedFolder);
|
||||||
|
logger.trace("isRootFolderShared is: "+ isRootFolderShared);
|
||||||
|
|
||||||
|
WorkspaceItem sourceSharedFolder = workspace.getItem(idSharedFolder);
|
||||||
|
boolean isSharedFolder = isASharedFolder(sourceSharedFolder);
|
||||||
|
if(isSharedFolder){
|
||||||
|
|
||||||
|
logger.trace("idSharedFolder is: "+ idSharedFolder +" is shared folder: "+isSharedFolder);
|
||||||
|
//get contacts
|
||||||
|
List<InfoContactModel> listContacts = getListUserSharedByFolderSharedId(sourceSharedFolder, workspace);
|
||||||
|
|
||||||
|
//Notify Removed Item To Sharing?
|
||||||
|
if(!isRootFolderShared){
|
||||||
|
if(sourceSharedFolder instanceof org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder){
|
||||||
|
np.notifyRemovedItemToSharing(listContacts, oldItemName, (org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder) sourceSharedFolder);
|
||||||
|
logger.debug("Notification was sent correctly");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
logger.debug("The notifies doesn't sent because "+sourceSharedFolder+ " is not instance of WorkspaceSharedFolder");
|
||||||
|
|
||||||
|
}else{
|
||||||
|
//Case removed shared folder
|
||||||
|
np.notifySharedFolderDeleted(listContacts, oldItemName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}catch (Exception e) {
|
||||||
|
logger.error("An error occurred in checkSendNotifyRemoveItemToShare ",e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify shared folder deleted.
|
||||||
|
*
|
||||||
|
* @param listContacts the list contacts
|
||||||
|
* @param folderNameDeleted the folder name deleted
|
||||||
|
* @param userId the user id
|
||||||
|
*/
|
||||||
|
public void notifySharedFolderDeleted(final List<InfoContactModel> listContacts, final String folderNameDeleted, final String userId) {
|
||||||
|
|
||||||
|
|
||||||
|
new Thread() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
logger.trace("Send notification shared folder deleted is running...");
|
||||||
|
for (InfoContactModel infoContactModel : listContacts) {
|
||||||
|
try{
|
||||||
|
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
|
||||||
|
if(infoContactModel.getLogin().compareTo(userId)!=0){
|
||||||
|
logger.debug("Notification to user "+infoContactModel.getLogin() +" deleted shared folder "+folderNameDeleted +" HAS BEEN REMOVED!");
|
||||||
|
}
|
||||||
|
}catch (Exception e) {
|
||||||
|
logger.error("An error occured in notifySharedFolderDeleted ", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
logger.trace("notifies of deleted shared foder is completed");
|
||||||
|
}
|
||||||
|
|
||||||
|
}.start();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if is a shared folder.
|
* Checks if is a shared folder.
|
||||||
|
|
|
@ -8,14 +8,17 @@ import java.util.List;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.gcube.applicationsupportlayer.social.NotificationsManager;
|
import org.gcube.applicationsupportlayer.social.NotificationsManager;
|
||||||
|
import org.gcube.applicationsupportlayer.social.shared.SocialFileItem;
|
||||||
|
import org.gcube.applicationsupportlayer.social.shared.SocialSharedFolder;
|
||||||
import org.gcube.common.scope.impl.ScopeBean;
|
import org.gcube.common.scope.impl.ScopeBean;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder;
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder;
|
||||||
import org.gcube.portlets.user.workspace.server.util.PortalContextInfo;
|
import org.gcube.portlets.user.workspace.server.util.PortalContextInfo;
|
||||||
import org.gcube.portlets.user.workspace.server.util.WsUtil;
|
import org.gcube.portlets.user.workspace.server.util.WsUtil;
|
||||||
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
|
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,7 +31,7 @@ public class NotificationsProducerToStorageHub {
|
||||||
|
|
||||||
protected ScopeBean scope;
|
protected ScopeBean scope;
|
||||||
|
|
||||||
protected static Logger logger = Logger.getLogger(NotificationsProducerToStorageHub.class);
|
protected static Logger logger = LoggerFactory.getLogger(NotificationsProducerToStorageHub.class);
|
||||||
|
|
||||||
protected NotificationsManager notificationsMng;
|
protected NotificationsManager notificationsMng;
|
||||||
protected HttpSession httpSession;
|
protected HttpSession httpSession;
|
||||||
|
@ -71,7 +74,10 @@ public class NotificationsProducerToStorageHub {
|
||||||
if(infoContactModel.getLogin().compareTo(userId)!=0){
|
if(infoContactModel.getLogin().compareTo(userId)!=0){
|
||||||
|
|
||||||
logger.debug("Sending notification to user "+infoContactModel.getLogin() +" added item [id: "+workspaceItem.getId() +"] name: "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName());
|
logger.debug("Sending notification to user "+infoContactModel.getLogin() +" added item [id: "+workspaceItem.getId() +"] name: "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName());
|
||||||
boolean notify = notificationsMng.notifyAddedItem(infoContactModel.getLogin(), NotificationMapperToStorageHub.toSocialItem(workspace, workspaceItem), NotificationMapperToStorageHub.toSocialSharedFolder(sharedFolder));
|
//boolean notify = notificationsMng.notifyAddedItem(infoContactModel.getLogin(), NotificationMapperToStorageHub.toSocialItem(workspace, workspaceItem), NotificationMapperToStorageHub.toSocialSharedFolder(sharedFolder));
|
||||||
|
SocialFileItem toSocialItem = NotificationMapperToStorageHub.toSocialItem(workspace, workspaceItem);
|
||||||
|
SocialSharedFolder toSocialFolder = NotificationMapperToStorageHub.toSocialSharedFolder(sharedFolder);
|
||||||
|
boolean notify = notificationsMng.notifyAddedItem(infoContactModel.getLogin(), toSocialItem, toSocialFolder);
|
||||||
|
|
||||||
if(!notify){
|
if(!notify){
|
||||||
logger.error("An error occured when notify user: "+infoContactModel.getLogin());
|
logger.error("An error occured when notify user: "+infoContactModel.getLogin());
|
||||||
|
@ -224,5 +230,88 @@ public class NotificationsProducerToStorageHub {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify removed item to sharing.
|
||||||
|
*
|
||||||
|
* @param listContacts the list contacts
|
||||||
|
* @param itemName the item name
|
||||||
|
* @param sharedFolder the shared folder
|
||||||
|
*/
|
||||||
|
public void notifyRemovedItemToSharing(final List<InfoContactModel> listContacts, final String itemName, final WorkspaceSharedFolder sharedFolder) {
|
||||||
|
|
||||||
|
|
||||||
|
new Thread() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
|
||||||
|
logger.trace("Sending notification removed item in shared folder is running...");
|
||||||
|
if(itemName==null || itemName.isEmpty()){
|
||||||
|
logger.trace("Notification isn't sent - itemName is null or empty");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(sharedFolder==null){
|
||||||
|
logger.debug("Impossible to send notification - sharedFolder is null");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (InfoContactModel infoContactModel : listContacts) {
|
||||||
|
try{
|
||||||
|
|
||||||
|
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
|
||||||
|
if(infoContactModel.getLogin().compareTo(userId)!=0){
|
||||||
|
|
||||||
|
logger.debug("Sending notification to user "+infoContactModel.getLogin() +" removed item "+itemName+" in the shared folder "+sharedFolder.getName());
|
||||||
|
//DEBUG
|
||||||
|
// System.out.println("Sending notification to user "+infoContactModel.getLogin() +" removed item "+itemName+" in shared folder "+sharedFolder.getName());
|
||||||
|
boolean notify = notificationsMng.notifyRemovedItem(infoContactModel.getLogin(), itemName, NotificationMapperToStorageHub.toSocialSharedFolder(sharedFolder));
|
||||||
|
if(!notify){
|
||||||
|
logger.error("An error occured when notify user: "+infoContactModel.getLogin());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch (Exception e) {
|
||||||
|
logger.error("An error occurred in notifyRemovedItemToSharing ", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.debug("notifies of moved item in shared folder is completed");
|
||||||
|
}
|
||||||
|
}.start();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runs a new thread to notify the contacts passed in input.
|
||||||
|
*
|
||||||
|
* @param listContacts the list contacts
|
||||||
|
* @param folderNameDeleted the folder name deleted
|
||||||
|
*/
|
||||||
|
public void notifySharedFolderDeleted(final List<InfoContactModel> listContacts, final String folderNameDeleted) {
|
||||||
|
|
||||||
|
|
||||||
|
new Thread() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
// printContacts(listContacts);
|
||||||
|
logger.trace("Sending notification shared folder deleted is running...");
|
||||||
|
for (InfoContactModel infoContactModel : listContacts) {
|
||||||
|
try{
|
||||||
|
|
||||||
|
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
|
||||||
|
if(infoContactModel.getLogin().compareTo(userId)!=0){
|
||||||
|
logger.trace("Sending notification to user "+infoContactModel.getLogin() +" deleted shared folder "+folderNameDeleted);
|
||||||
|
//THIS NOTIFCATION HAS BEEN REMOVED
|
||||||
|
}
|
||||||
|
}catch (Exception e) {
|
||||||
|
logger.error("An error occured in notifySharedFolderDeleted ", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.debug("notifies of deleted shared foder is completed");
|
||||||
|
}
|
||||||
|
|
||||||
|
}.start();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,8 @@ package org.gcube.portlets.user.workspace.server.property;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
||||||
|
@ -18,7 +19,7 @@ public class PortalUrlGroupGatewayProperty {
|
||||||
*/
|
*/
|
||||||
protected static final String PORTALURL_PROPERTIES = "portalurl.properties";
|
protected static final String PORTALURL_PROPERTIES = "portalurl.properties";
|
||||||
|
|
||||||
protected static Logger log = Logger.getLogger(PortalUrlGroupGatewayProperty.class);
|
protected static Logger log = LoggerFactory.getLogger(PortalUrlGroupGatewayProperty.class);
|
||||||
|
|
||||||
private String server = "";
|
private String server = "";
|
||||||
private String path = "";
|
private String path = "";
|
||||||
|
|
|
@ -10,4 +10,13 @@ package org.gcube.portlets.user.workspace.server.property;
|
||||||
*/
|
*/
|
||||||
public class PropertyFileNotFoundException extends Exception {
|
public class PropertyFileNotFoundException extends Exception {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = -3220297615560720000L;
|
||||||
|
|
||||||
|
public PropertyFileNotFoundException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,13 +8,14 @@ import java.util.List;
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.gcube.common.resources.gcore.utils.XPathHelper;
|
import org.gcube.common.resources.gcore.utils.XPathHelper;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
import org.gcube.portlets.user.workspace.server.util.WsUtil;
|
||||||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||||
import org.gcube.resources.discovery.client.queries.api.Query;
|
import org.gcube.resources.discovery.client.queries.api.Query;
|
||||||
import org.gcube.resources.discovery.client.queries.impl.QueryBox;
|
import org.gcube.resources.discovery.client.queries.impl.QueryBox;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
import org.xml.sax.InputSource;
|
import org.xml.sax.InputSource;
|
||||||
|
|
||||||
|
@ -41,7 +42,7 @@ public class ApplicationProfileReader {
|
||||||
protected static final String RESOURCE_PROFILE_DESCRIPTION_TEXT = "/Resource/Profile/Description/text()";
|
protected static final String RESOURCE_PROFILE_DESCRIPTION_TEXT = "/Resource/Profile/Description/text()";
|
||||||
protected static final String RESOURCE_PROFILE_NAME_TEXT = "/Resource/Profile/Name/text()";
|
protected static final String RESOURCE_PROFILE_NAME_TEXT = "/Resource/Profile/Name/text()";
|
||||||
|
|
||||||
private Logger logger = Logger.getLogger(ApplicationProfileReader.class);
|
private Logger logger = LoggerFactory.getLogger(ApplicationProfileReader.class);
|
||||||
private String secondaryType;
|
private String secondaryType;
|
||||||
private String scope;
|
private String scope;
|
||||||
private String resourceName;
|
private String resourceName;
|
||||||
|
@ -131,9 +132,12 @@ public class ApplicationProfileReader {
|
||||||
List<String> scopes = currValue;
|
List<String> scopes = currValue;
|
||||||
String currentScope = scopes.get(0);
|
String currentScope = scopes.get(0);
|
||||||
|
|
||||||
int slashCount = StringUtils.countMatches(currentScope, "/");
|
//int slashCount = StringUtils.countMatches(currentScope, "/");
|
||||||
|
|
||||||
|
boolean isVRE = WsUtil.isVRE(currentScope);
|
||||||
|
|
||||||
if(slashCount < 3){//CASE not VRE - set session scope
|
//if(slashCount < 3){//CASE not VRE - set session scope
|
||||||
|
if(!isVRE){//CASE not VRE - set session scope
|
||||||
logger.info("Scope "+ scope.toString() + " is not a VRE");
|
logger.info("Scope "+ scope.toString() + " is not a VRE");
|
||||||
|
|
||||||
List<String> listSessionScope = helper.evaluate("/Resource/Profile/Body/EndPoint[Scope='"+scope.toString()+"']/Sessionscope/text()"); //get session scope of i+1-mo scope
|
List<String> listSessionScope = helper.evaluate("/Resource/Profile/Body/EndPoint[Scope='"+scope.toString()+"']/Sessionscope/text()"); //get session scope of i+1-mo scope
|
||||||
|
|
|
@ -13,7 +13,6 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
||||||
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
|
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
@ -21,6 +20,8 @@ import org.gcube.portlets.user.workspace.server.util.UrlEncoderUtil;
|
||||||
import org.gcube.portlets.user.workspace.server.util.scope.ScopeUtilFilter;
|
import org.gcube.portlets.user.workspace.server.util.scope.ScopeUtilFilter;
|
||||||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||||
import org.gcube.resources.discovery.client.queries.impl.XQuery;
|
import org.gcube.resources.discovery.client.queries.impl.XQuery;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -43,7 +44,7 @@ public class UriResolverReaderParameterForResolverIndex {
|
||||||
private String contentTypeParameter = "";
|
private String contentTypeParameter = "";
|
||||||
private String query = "";
|
private String query = "";
|
||||||
private boolean isAvailable = false;
|
private boolean isAvailable = false;
|
||||||
public static Logger logger = Logger.getLogger(UriResolverReaderParameterForResolverIndex.class);
|
public static Logger logger = LoggerFactory.getLogger(UriResolverReaderParameterForResolverIndex.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Enum RESOLVER_TYPE.
|
* The Enum RESOLVER_TYPE.
|
||||||
|
|
|
@ -0,0 +1,74 @@
|
||||||
|
package org.gcube.portlets.user.workspace.server.tostoragehub;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
||||||
|
import org.gcube.portlets.user.workspace.client.util.ImageRequestType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class BuildServiceURLUtil.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
|
*
|
||||||
|
* Jul 17, 2019
|
||||||
|
*/
|
||||||
|
public class BuildServiceURLUtil {
|
||||||
|
|
||||||
|
|
||||||
|
protected static final String IMAGE_SERVICE_URL = "ImageService";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds the image url.
|
||||||
|
*
|
||||||
|
* @param id the id
|
||||||
|
* @param currentGroupId the current group id
|
||||||
|
* @param currUserId the curr user id
|
||||||
|
* @return the string
|
||||||
|
*/
|
||||||
|
protected static String buildImageUrl(String id, String currentGroupId, String currUserId)
|
||||||
|
{
|
||||||
|
return buildImageServiceUrl(id, ImageRequestType.IMAGE, currentGroupId, currUserId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds the thumbnail url.
|
||||||
|
*
|
||||||
|
* @param id the id
|
||||||
|
* @param currentGroupId the current group id
|
||||||
|
* @param currUserId the curr user id
|
||||||
|
* @return the string
|
||||||
|
*/
|
||||||
|
protected static String buildThumbnailUrl(String id, String currentGroupId, String currUserId)
|
||||||
|
{
|
||||||
|
return buildImageServiceUrl(id, ImageRequestType.THUMBNAIL, currentGroupId, currUserId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds the image service url.
|
||||||
|
*
|
||||||
|
* @param id the id
|
||||||
|
* @param requestType the request type
|
||||||
|
* @param currentGroupId the current group id read from PortalContext
|
||||||
|
* @param currUserId the curr user id
|
||||||
|
* @return the string
|
||||||
|
*/
|
||||||
|
protected static String buildImageServiceUrl(String id, ImageRequestType requestType, String currentGroupId, String currUserId){
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append(IMAGE_SERVICE_URL);
|
||||||
|
sb.append("?id=");
|
||||||
|
sb.append(id);
|
||||||
|
sb.append("&type=");
|
||||||
|
sb.append(requestType.toString());
|
||||||
|
sb.append("&"+ConstantsExplorer.CURRENT_CONTEXT_ID+"=");
|
||||||
|
sb.append(currentGroupId);
|
||||||
|
// sb.append("&"+ConstantsExplorer.CURRENT_USER_ID+"=");
|
||||||
|
// sb.append(currUserId);
|
||||||
|
sb.append("&random=");
|
||||||
|
sb.append(UUID.randomUUID().toString());
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,118 @@
|
||||||
|
package org.gcube.portlets.user.workspace.server.tostoragehub;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class FormatterUtil.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
|
*
|
||||||
|
* Jul 17, 2019
|
||||||
|
*/
|
||||||
|
public class FormatterUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To date.
|
||||||
|
*
|
||||||
|
* @param calendar the calendar
|
||||||
|
* @return the date
|
||||||
|
*/
|
||||||
|
public static Date toDate(Calendar calendar){
|
||||||
|
if (calendar == null) return new Date(0);
|
||||||
|
return calendar.getTime();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To date format to string.
|
||||||
|
*
|
||||||
|
* @param calendar the calendar
|
||||||
|
* @return the string
|
||||||
|
*/
|
||||||
|
protected String toDateFormatToString(Calendar calendar){
|
||||||
|
|
||||||
|
SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM, yyyy HH:mm:ss z");
|
||||||
|
Date resultdate = getDate(calendar);
|
||||||
|
return dateFormat.format(resultdate);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To date format.
|
||||||
|
*
|
||||||
|
* @param calendar
|
||||||
|
* the calendar
|
||||||
|
* @return the date
|
||||||
|
*/
|
||||||
|
protected Date toDateFormat(Calendar calendar) {
|
||||||
|
|
||||||
|
SimpleDateFormat dateFormat =
|
||||||
|
new SimpleDateFormat("dd-MM, yyyy HH:mm:ss z");
|
||||||
|
Date resultdate = getDate(calendar);
|
||||||
|
try {
|
||||||
|
resultdate = dateFormat.parse(dateFormat.format(resultdate));
|
||||||
|
}
|
||||||
|
catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
resultdate = new Date(0);
|
||||||
|
}
|
||||||
|
return resultdate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the date.
|
||||||
|
*
|
||||||
|
* @param calendar the calendar
|
||||||
|
* @return the date
|
||||||
|
*/
|
||||||
|
private Date getDate(Calendar calendar) {
|
||||||
|
|
||||||
|
Date resultdate = null;
|
||||||
|
|
||||||
|
if (calendar == null)
|
||||||
|
resultdate = new Date(0);
|
||||||
|
else
|
||||||
|
resultdate = new Date(calendar.getTimeInMillis());
|
||||||
|
|
||||||
|
return resultdate;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format file size.
|
||||||
|
*
|
||||||
|
* @param size the size
|
||||||
|
* @return the string
|
||||||
|
*/
|
||||||
|
public static String formatFileSize(long size) {
|
||||||
|
String formattedSize = null;
|
||||||
|
|
||||||
|
double b = size;
|
||||||
|
double k = size/1024.0;
|
||||||
|
double m = size/1024.0/1024.0;
|
||||||
|
double g = size/1024.0/1024.0/1024.0;
|
||||||
|
double t = size/1024.0/1024.0/1024.0/1024.0;
|
||||||
|
|
||||||
|
DecimalFormat dec = new DecimalFormat("0.00");
|
||||||
|
|
||||||
|
if ( t>1 ) {
|
||||||
|
formattedSize = dec.format(t).concat(" TB");
|
||||||
|
} else if ( g>1 ) {
|
||||||
|
formattedSize = dec.format(g).concat(" GB");
|
||||||
|
} else if ( m>1 ) {
|
||||||
|
formattedSize = dec.format(m).concat(" MB");
|
||||||
|
} else if ( k>1 ) {
|
||||||
|
formattedSize = dec.format(k).concat(" KB");
|
||||||
|
} else {
|
||||||
|
formattedSize = dec.format(b).concat(" Bytes");
|
||||||
|
}
|
||||||
|
|
||||||
|
return formattedSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -4,8 +4,14 @@
|
||||||
package org.gcube.portlets.user.workspace.server.tostoragehub;
|
package org.gcube.portlets.user.workspace.server.tostoragehub;
|
||||||
|
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
|
||||||
|
import org.gcube.common.storagehubwrapper.server.tohl.Workspace;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
|
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
|
||||||
|
import org.gcube.common.storagehubwrapper.shared.tohl.impl.URLFile;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.impl.WorkspaceSharedFolder;
|
import org.gcube.common.storagehubwrapper.shared.tohl.impl.WorkspaceSharedFolder;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.items.FileItem;
|
import org.gcube.common.storagehubwrapper.shared.tohl.items.FileItem;
|
||||||
import org.gcube.portlets.user.workspace.client.interfaces.GXTCategorySmartFolder;
|
import org.gcube.portlets.user.workspace.client.interfaces.GXTCategorySmartFolder;
|
||||||
|
@ -14,22 +20,29 @@ import org.gcube.portlets.user.workspace.client.model.FileGridModel;
|
||||||
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||||||
import org.gcube.portlets.user.workspace.client.model.FolderGridModel;
|
import org.gcube.portlets.user.workspace.client.model.FolderGridModel;
|
||||||
import org.gcube.portlets.user.workspace.client.model.FolderModel;
|
import org.gcube.portlets.user.workspace.client.model.FolderModel;
|
||||||
import org.gcube.portlets.user.workspace.server.GWTWorkspaceBuilder;
|
import org.gcube.portlets.user.workspace.client.workspace.GWTProperties;
|
||||||
|
import org.gcube.portlets.user.workspace.client.workspace.GWTWorkspaceFolder;
|
||||||
|
import org.gcube.portlets.user.workspace.client.workspace.GWTWorkspaceItem;
|
||||||
|
import org.gcube.portlets.user.workspace.client.workspace.GWTWorkspaceItemAction;
|
||||||
|
import org.gcube.portlets.user.workspace.client.workspace.folder.item.GWTExternalImage;
|
||||||
|
import org.gcube.portlets.user.workspace.client.workspace.folder.item.GWTExternalUrl;
|
||||||
import org.gcube.portlets.user.workspace.server.util.UserUtil;
|
import org.gcube.portlets.user.workspace.server.util.UserUtil;
|
||||||
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class StorageHubToWorkpaceConveter.
|
* The Class ObjectStorageHubToWorkpaceMapper.
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
* Sep 20, 2018
|
*
|
||||||
|
* Jul 17, 2019
|
||||||
*/
|
*/
|
||||||
public class ObjectStorageHubToWorkpaceMapper {
|
public class ObjectStorageHubToWorkpaceMapper {
|
||||||
|
|
||||||
|
|
||||||
protected static Logger logger = Logger.getLogger(ObjectStorageHubToWorkpaceMapper.class);
|
protected static Logger logger = LoggerFactory.getLogger(ObjectStorageHubToWorkpaceMapper.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To root folder.
|
* To root folder.
|
||||||
|
@ -162,7 +175,7 @@ public class ObjectStorageHubToWorkpaceMapper {
|
||||||
|
|
||||||
case FOLDER:
|
case FOLDER:
|
||||||
boolean isPublicFolder = ((org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder) wrappedItem).isPublicFolder(); //TODO
|
boolean isPublicFolder = ((org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder) wrappedItem).isPublicFolder(); //TODO
|
||||||
fileGridModel = new FolderGridModel(wrappedItem.getId(), wrappedItem.getName(), GWTWorkspaceBuilder.toDate(wrappedItem.getLastModificationTime()), parentFolderModel, -1, true, false,false, isPublicFolder);
|
fileGridModel = new FolderGridModel(wrappedItem.getId(), wrappedItem.getName(), FormatterUtil.toDate(wrappedItem.getLastModificationTime()), parentFolderModel, -1, true, false,false, isPublicFolder);
|
||||||
if(isPublicFolder)
|
if(isPublicFolder)
|
||||||
fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER_PUBLIC.getLabel().toString());
|
fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER_PUBLIC.getLabel().toString());
|
||||||
else
|
else
|
||||||
|
@ -177,7 +190,7 @@ public class ObjectStorageHubToWorkpaceMapper {
|
||||||
FileItem fileItem = (FileItem) wrappedItem;
|
FileItem fileItem = (FileItem) wrappedItem;
|
||||||
fileGridModel = new FileGridModel(fileItem.getId(),
|
fileGridModel = new FileGridModel(fileItem.getId(),
|
||||||
fileItem.getName(),
|
fileItem.getName(),
|
||||||
GWTWorkspaceBuilder.
|
FormatterUtil.
|
||||||
toDate(fileItem.getLastModificationTime()),
|
toDate(fileItem.getLastModificationTime()),
|
||||||
parentFolderModel,
|
parentFolderModel,
|
||||||
fileItem.getSize()==null?0:fileItem.getSize(),
|
fileItem.getSize()==null?0:fileItem.getSize(),
|
||||||
|
@ -187,7 +200,7 @@ public class ObjectStorageHubToWorkpaceMapper {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VRE_FOLDER:
|
case VRE_FOLDER:
|
||||||
fileGridModel = new FolderGridModel(wrappedItem.getId(), wrappedItem.getName(), GWTWorkspaceBuilder.toDate(wrappedItem.getLastModificationTime()), parentFolderModel, -1, true, false,true, false);
|
fileGridModel = new FolderGridModel(wrappedItem.getId(), wrappedItem.getName(), FormatterUtil.toDate(wrappedItem.getLastModificationTime()), parentFolderModel, -1, true, false,true, false);
|
||||||
fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER_SHARED.toString());
|
fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER_SHARED.toString());
|
||||||
fileGridModel.setShareable(true);
|
fileGridModel.setShareable(true);
|
||||||
fileGridModel.setDescription(wrappedItem.getDescription());
|
fileGridModel.setDescription(wrappedItem.getDescription());
|
||||||
|
@ -197,7 +210,7 @@ public class ObjectStorageHubToWorkpaceMapper {
|
||||||
WorkspaceSharedFolder shared = (WorkspaceSharedFolder) wrappedItem;
|
WorkspaceSharedFolder shared = (WorkspaceSharedFolder) wrappedItem;
|
||||||
boolean isPublicDir = ((org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder) wrappedItem).isPublicFolder(); //TODO
|
boolean isPublicDir = ((org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder) wrappedItem).isPublicFolder(); //TODO
|
||||||
//String name = shared.isVreFolder()?shared.getTitle():shared.getName();
|
//String name = shared.isVreFolder()?shared.getTitle():shared.getName();
|
||||||
fileGridModel = new FolderGridModel(wrappedItem.getId(), wrappedItem.getName(), GWTWorkspaceBuilder.toDate(wrappedItem.getLastModificationTime()), parentFolderModel, -1, true, true, shared.isVreFolder(), isPublicDir);
|
fileGridModel = new FolderGridModel(wrappedItem.getId(), wrappedItem.getName(), FormatterUtil.toDate(wrappedItem.getLastModificationTime()), parentFolderModel, -1, true, true, shared.isVreFolder(), isPublicDir);
|
||||||
|
|
||||||
if(isPublicDir)
|
if(isPublicDir)
|
||||||
fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER_SHARED_PUBLIC.getLabel().toString());
|
fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER_SHARED_PUBLIC.getLabel().toString());
|
||||||
|
@ -208,6 +221,21 @@ public class ObjectStorageHubToWorkpaceMapper {
|
||||||
fileGridModel.setShareable(true);
|
fileGridModel.setShareable(true);
|
||||||
fileGridModel.setDescription(wrappedItem.getDescription());
|
fileGridModel.setDescription(wrappedItem.getDescription());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case URL_ITEM:
|
||||||
|
URLFile urlItem = (URLFile) wrappedItem;
|
||||||
|
fileGridModel = new FileGridModel(urlItem.getId(),
|
||||||
|
urlItem.getName(),
|
||||||
|
FormatterUtil.
|
||||||
|
toDate(urlItem.getLastModificationTime()),
|
||||||
|
parentFolderModel,
|
||||||
|
-1,
|
||||||
|
false,
|
||||||
|
false);
|
||||||
|
//fileGridModel.setType("URL");
|
||||||
|
fileGridModel.setFolderItemType(GXTFolderItemTypeEnum.EXTERNAL_URL);
|
||||||
|
fileGridModel.setShortcutCategory(GXTCategorySmartFolder.SMF_DOCUMENTS);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
logger.error("gxt conversion return null for item "+wrappedItem.getName());
|
logger.error("gxt conversion return null for item "+wrappedItem.getName());
|
||||||
|
@ -296,5 +324,160 @@ public class ObjectStorageHubToWorkpaceMapper {
|
||||||
|
|
||||||
return fileModel;
|
return fileModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds the GWT workspace image.
|
||||||
|
*
|
||||||
|
* @param wrappedImage the wrapped image
|
||||||
|
* @param isInteralImage the is interal image
|
||||||
|
* @param fullDetails the full details
|
||||||
|
* @param currentGroupId the current group id
|
||||||
|
* @param currentUserId the current user id
|
||||||
|
* @return the GWT workspace item
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static GWTWorkspaceItem buildGWTWorkspaceImage(org.gcube.common.storagehubwrapper.shared.tohl.items.ImageFileItem wrappedImage, boolean isInteralImage, boolean fullDetails, String currentGroupId, String currentUserId)
|
||||||
|
{
|
||||||
|
|
||||||
|
GWTWorkspaceItem gwtImage;
|
||||||
|
GWTProperties gwtProperties = null;
|
||||||
|
GWTWorkspaceItemAction lastAction = null;
|
||||||
|
GWTWorkspaceFolder parent = null;
|
||||||
|
|
||||||
|
if(fullDetails){
|
||||||
|
|
||||||
|
gwtImage = new GWTExternalImage(
|
||||||
|
FormatterUtil.toDate(wrappedImage.getCreationTime()),
|
||||||
|
wrappedImage.getId(),
|
||||||
|
gwtProperties,
|
||||||
|
wrappedImage.getName(),
|
||||||
|
wrappedImage.getOwner(),
|
||||||
|
wrappedImage.getDescription(),
|
||||||
|
FormatterUtil.toDate(wrappedImage.getLastModificationTime()),
|
||||||
|
lastAction,
|
||||||
|
parent, //parent
|
||||||
|
BuildServiceURLUtil.buildImageUrl(wrappedImage.getId(), currentGroupId, currentUserId),
|
||||||
|
BuildServiceURLUtil.buildThumbnailUrl(wrappedImage.getId(), currentGroupId, currentUserId),
|
||||||
|
toValidInt(wrappedImage.getWidth()),
|
||||||
|
toValidInt(wrappedImage.getHeight()),
|
||||||
|
wrappedImage.getSize(),
|
||||||
|
toValidInt(wrappedImage.getThumbnailWidth()),
|
||||||
|
toValidInt(wrappedImage.getThumbnailHeight()),
|
||||||
|
-1,
|
||||||
|
wrappedImage.getMimeType());
|
||||||
|
}else{
|
||||||
|
gwtImage = new GWTExternalImage(wrappedImage.getId(), wrappedImage.getName(),
|
||||||
|
BuildServiceURLUtil.buildImageUrl(wrappedImage.getId(), currentGroupId, currentUserId),
|
||||||
|
BuildServiceURLUtil.buildThumbnailUrl(wrappedImage.getId(), currentGroupId, currentUserId),
|
||||||
|
toValidInt(wrappedImage.getWidth()),
|
||||||
|
toValidInt(wrappedImage.getHeight()),
|
||||||
|
toValidInt(wrappedImage.getSize()),
|
||||||
|
toValidInt(wrappedImage.getThumbnailWidth()),
|
||||||
|
toValidInt(wrappedImage.getThumbnailHeight()),
|
||||||
|
-1,
|
||||||
|
wrappedImage.getMimeType());
|
||||||
|
}
|
||||||
|
return gwtImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To valid int.
|
||||||
|
*
|
||||||
|
* @param aLong the a long
|
||||||
|
* @return the int
|
||||||
|
*/
|
||||||
|
public static int toValidInt(Long aLong){
|
||||||
|
|
||||||
|
if(aLong==null)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
try {
|
||||||
|
return Integer.parseInt(aLong.toString());
|
||||||
|
}catch (Exception e) {
|
||||||
|
logger.warn("Exception on parsing the value "+aLong+" as long");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds the GWT worspace url.
|
||||||
|
*
|
||||||
|
* @param workspace the workspace
|
||||||
|
* @param fileItem the file item
|
||||||
|
* @param isInternalUrl the is internal url
|
||||||
|
* @param fullDetails the full details
|
||||||
|
* @return the GWT workspace item
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static GWTWorkspaceItem buildGWTWorspaceUrl(Workspace workspace, FileItem fileItem, boolean isInternalUrl, boolean fullDetails) throws Exception
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
//TODO EXTRACT THE URL FROM THE FILE
|
||||||
|
GWTWorkspaceItem gwtUrl = null;
|
||||||
|
GWTProperties gwtProperties = null;
|
||||||
|
GWTWorkspaceItemAction lastAction = null;
|
||||||
|
|
||||||
|
if(fullDetails){
|
||||||
|
gwtUrl = new GWTExternalUrl(
|
||||||
|
FormatterUtil.toDate(fileItem.getCreationTime()),
|
||||||
|
fileItem.getId(),
|
||||||
|
gwtProperties,
|
||||||
|
fileItem.getName(),
|
||||||
|
fileItem.getOwner(),
|
||||||
|
fileItem.getDescription(),
|
||||||
|
FormatterUtil.toDate(fileItem.getLastModificationTime()),
|
||||||
|
lastAction,
|
||||||
|
null,
|
||||||
|
fileItem.getSize(),
|
||||||
|
getUrl(workspace, fileItem));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
gwtUrl = new GWTExternalUrl(getUrl(workspace, fileItem));
|
||||||
|
|
||||||
|
return gwtUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the url.
|
||||||
|
*
|
||||||
|
* @param workspace the workspace
|
||||||
|
* @param fileItem the file item
|
||||||
|
* @return the url
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
|
public static String getUrl(Workspace workspace, org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem fileItem) throws Exception {
|
||||||
|
try {
|
||||||
|
return readStreamAsString(workspace.downloadFile(fileItem.getId(), fileItem.getName(), null, null).getStream());
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.error("GET URL error for file: " +fileItem, e);
|
||||||
|
throw new InternalErrorException(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read the entire input stream as string. The system encoding is used.
|
||||||
|
*
|
||||||
|
* @param is the input stream.
|
||||||
|
* @return the read string.
|
||||||
|
* @throws IOException Signals that an I/O exception has occurred.
|
||||||
|
*/
|
||||||
|
public static String readStreamAsString(InputStream is) throws java.io.IOException{
|
||||||
|
StringBuilder sb = new StringBuilder(1000);
|
||||||
|
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
|
||||||
|
char[] buf = new char[1024];
|
||||||
|
int numRead=0;
|
||||||
|
while((numRead=reader.read(buf)) != -1){
|
||||||
|
sb.append(buf, 0, numRead);
|
||||||
|
}
|
||||||
|
reader.close();
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,14 +6,32 @@ package org.gcube.portlets.user.workspace.server.tostoragehub;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.gcube.common.storagehub.model.items.nodes.accounting.AccountEntry;
|
||||||
|
import org.gcube.common.storagehub.model.items.nodes.accounting.AccountEntryCreate;
|
||||||
|
import org.gcube.common.storagehub.model.items.nodes.accounting.AccountEntryDisabledPublicAccess;
|
||||||
|
import org.gcube.common.storagehub.model.items.nodes.accounting.AccountEntryEnabledPublicAccess;
|
||||||
|
import org.gcube.common.storagehub.model.items.nodes.accounting.AccountEntryPaste;
|
||||||
|
import org.gcube.common.storagehub.model.items.nodes.accounting.AccountEntryRead;
|
||||||
|
import org.gcube.common.storagehub.model.items.nodes.accounting.AccountEntryRestore;
|
||||||
|
import org.gcube.common.storagehub.model.items.nodes.accounting.AccountEntryShare;
|
||||||
|
import org.gcube.common.storagehub.model.items.nodes.accounting.AccountEntryUnshare;
|
||||||
|
import org.gcube.common.storagehub.model.items.nodes.accounting.AccountEntryUpdate;
|
||||||
|
import org.gcube.common.storagehub.model.items.nodes.accounting.AccountFolderEntryAdd;
|
||||||
|
import org.gcube.common.storagehub.model.items.nodes.accounting.AccountFolderEntryCut;
|
||||||
|
import org.gcube.common.storagehub.model.items.nodes.accounting.AccountFolderEntryRemoval;
|
||||||
|
import org.gcube.common.storagehub.model.items.nodes.accounting.AccountFolderEntryRenaming;
|
||||||
|
import org.gcube.common.storagehub.model.items.nodes.accounting.AccountingEntryType;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItemType;
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItemType;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder;
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
|
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.impl.WorkspaceFileVersion;
|
import org.gcube.common.storagehubwrapper.shared.tohl.impl.WorkspaceFileVersion;
|
||||||
|
import org.gcube.common.storagehubwrapper.shared.tohl.items.GCubeItem;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.items.PropertyMap;
|
import org.gcube.common.storagehubwrapper.shared.tohl.items.PropertyMap;
|
||||||
import org.gcube.portal.wssynclibrary.shared.thredds.Sync_Status;
|
import org.gcube.portal.wssynclibrary.shared.thredds.Sync_Status;
|
||||||
import org.gcube.portal.wssynclibrary.thredds.WorkspaceThreddsSynchronize;
|
import org.gcube.portal.wssynclibrary.thredds.WorkspaceThreddsSynchronize;
|
||||||
|
@ -23,10 +41,13 @@ import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||||||
import org.gcube.portlets.user.workspace.client.model.FileTrashedModel;
|
import org.gcube.portlets.user.workspace.client.model.FileTrashedModel;
|
||||||
import org.gcube.portlets.user.workspace.client.model.FileVersionModel;
|
import org.gcube.portlets.user.workspace.client.model.FileVersionModel;
|
||||||
import org.gcube.portlets.user.workspace.client.model.FolderModel;
|
import org.gcube.portlets.user.workspace.client.model.FolderModel;
|
||||||
import org.gcube.portlets.user.workspace.server.GWTWorkspaceBuilder;
|
|
||||||
import org.gcube.portlets.user.workspace.server.util.UserUtil;
|
import org.gcube.portlets.user.workspace.server.util.UserUtil;
|
||||||
|
import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingEntryType;
|
||||||
|
import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingField;
|
||||||
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
|
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
|
||||||
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,7 +66,7 @@ public class StorageHubToWorkpaceConverter implements Serializable{
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 6935303928299846569L;
|
private static final long serialVersionUID = 6935303928299846569L;
|
||||||
|
|
||||||
protected static Logger logger = Logger.getLogger(StorageHubToWorkpaceConverter.class);
|
protected static Logger logger = LoggerFactory.getLogger(StorageHubToWorkpaceConverter.class);
|
||||||
private String scope;
|
private String scope;
|
||||||
private GCubeUser loggedUser;
|
private GCubeUser loggedUser;
|
||||||
private String workspaceRootId;
|
private String workspaceRootId;
|
||||||
|
@ -58,6 +79,67 @@ public class StorageHubToWorkpaceConverter implements Serializable{
|
||||||
public StorageHubToWorkpaceConverter() {
|
public StorageHubToWorkpaceConverter() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**********************************************************************************************************************************************
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* TESTING MODE METHODS
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************************************************************************************/
|
||||||
|
protected static HashMap<String, InfoContactModel> hashTestUser = null;
|
||||||
|
/**
|
||||||
|
* Used in test mode.
|
||||||
|
*
|
||||||
|
* @return the hash test users
|
||||||
|
*/
|
||||||
|
public static HashMap<String, InfoContactModel> getHashTestUsers(){
|
||||||
|
|
||||||
|
if(hashTestUser==null){
|
||||||
|
hashTestUser = new HashMap<String, InfoContactModel>();
|
||||||
|
|
||||||
|
//USERS
|
||||||
|
hashTestUser.put("federico.defaveri", new InfoContactModel("federico.defaveri", "federico.defaveri", "Federico de Faveri",null, false));
|
||||||
|
hashTestUser.put("antonio.gioia", new InfoContactModel("antonio.gioia", "antonio.gioia", "Antonio Gioia",null, false));
|
||||||
|
hashTestUser.put("fabio.sinibaldi", new InfoContactModel("fabio.sinibaldi", "fabio.sinibaldi", "Fabio Sinibaldi",null, false));
|
||||||
|
hashTestUser.put("pasquale.pagano", new InfoContactModel("pasquale.pagano", "pasquale.pagano", "Pasquale Pagano",null, false));
|
||||||
|
hashTestUser.put("valentina.marioli", new InfoContactModel("valentina.marioli", "valentina.marioli", "Valentina Marioli",null, false));
|
||||||
|
hashTestUser.put("roberto.cirillo", new InfoContactModel("roberto.cirillo", "roberto.cirillo", "Roberto Cirillo",null, false));
|
||||||
|
hashTestUser.put("francesco.mangiacrapa", new InfoContactModel("francesco.mangiacrapa", "francesco.mangiacrapa", "Francesco Mangiacrapa",null, false));
|
||||||
|
hashTestUser.put("massimiliano.assante", new InfoContactModel("massimiliano.assante", "massimiliano.assante", "Massimiliano Assante",null, false));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return hashTestUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static List<InfoContactModel> buildGxtInfoContactFromPortalLoginTestMode(List<String> listPortalLogin){
|
||||||
|
|
||||||
|
List<InfoContactModel> listContact = new ArrayList<InfoContactModel>();
|
||||||
|
|
||||||
|
for (String portalLogin : listPortalLogin)
|
||||||
|
listContact.add(getHashTestUsers().get(portalLogin));
|
||||||
|
|
||||||
|
return listContact;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**********************************************************************************************************************************************
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* END TESTING MODE
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -76,7 +158,7 @@ public class StorageHubToWorkpaceConverter implements Serializable{
|
||||||
List<FileVersionModel> listVersions = new ArrayList<FileVersionModel>(versions.size());
|
List<FileVersionModel> listVersions = new ArrayList<FileVersionModel>(versions.size());
|
||||||
for (WorkspaceFileVersion wsVersion : versions) {
|
for (WorkspaceFileVersion wsVersion : versions) {
|
||||||
String user = UserUtil.getUserFullName(wsVersion.getOwner());
|
String user = UserUtil.getUserFullName(wsVersion.getOwner());
|
||||||
FileVersionModel file = new FileVersionModel(wsVersion.getId(), wsVersion.getName(), wsVersion.getRemotePath(), user, GWTWorkspaceBuilder.toDate(wsVersion.getCreated()), wsVersion.isCurrentVersion());
|
FileVersionModel file = new FileVersionModel(wsVersion.getId(), wsVersion.getName(), wsVersion.getRemotePath(), user, FormatterUtil.toDate(wsVersion.getCreated()), wsVersion.isCurrentVersion());
|
||||||
listVersions.add(file);
|
listVersions.add(file);
|
||||||
}
|
}
|
||||||
return listVersions;
|
return listVersions;
|
||||||
|
@ -215,7 +297,7 @@ public class StorageHubToWorkpaceConverter implements Serializable{
|
||||||
fileTrashModel.setIsDirectory(trashItem.isFolder());
|
fileTrashModel.setIsDirectory(trashItem.isFolder());
|
||||||
|
|
||||||
//SETTING DELETE DATE
|
//SETTING DELETE DATE
|
||||||
fileTrashModel.setDeleteDate(GWTWorkspaceBuilder.toDate(trashItem.getDeletedTime()));
|
fileTrashModel.setDeleteDate(FormatterUtil.toDate(trashItem.getDeletedTime()));
|
||||||
|
|
||||||
fileTrashModel.setShared(trashItem.isShared());
|
fileTrashModel.setShared(trashItem.isShared());
|
||||||
|
|
||||||
|
@ -233,21 +315,33 @@ public class StorageHubToWorkpaceConverter implements Serializable{
|
||||||
return fileTrashModel;
|
return fileTrashModel;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds the gxt info contact from portal login.
|
* Builds the gxt info contact from portal login.
|
||||||
*
|
*
|
||||||
* @param portalLogin the portal login
|
* @param portalLogin the portal login
|
||||||
* @return the info contact model
|
* @return the info contact model
|
||||||
*/
|
*/
|
||||||
protected InfoContactModel buildGxtInfoContactFromPortalLogin(String portalLogin){
|
public static InfoContactModel buildGxtInfoContactFromPortalLogin(String portalLogin){
|
||||||
|
|
||||||
if(portalLogin==null){
|
if(portalLogin==null){
|
||||||
logger.warn("portal login is null, return empty");
|
logger.warn("portal login is null, return empty");
|
||||||
portalLogin = "";
|
portalLogin = "";
|
||||||
}
|
}
|
||||||
|
GCubeUser theUser = null;
|
||||||
return new InfoContactModel(portalLogin, portalLogin, UserUtil.getUserFullName(portalLogin), "",false);
|
try {
|
||||||
|
theUser = UserUtil.getUserByUsername(portalLogin);
|
||||||
|
}catch (Exception e) {
|
||||||
|
logger.warn("Error on retrieving user information, so using the portal login");
|
||||||
|
}
|
||||||
|
String fullName = null;
|
||||||
|
String emailDomain = null;
|
||||||
|
if(theUser!=null) {
|
||||||
|
fullName = theUser.getFullname();
|
||||||
|
emailDomain = theUser.getEmail();
|
||||||
|
}
|
||||||
|
return new InfoContactModel(portalLogin, portalLogin, fullName, emailDomain,false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -309,7 +403,6 @@ public class StorageHubToWorkpaceConverter implements Serializable{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the workspace root id.
|
* Gets the workspace root id.
|
||||||
*
|
*
|
||||||
|
@ -321,7 +414,6 @@ public class StorageHubToWorkpaceConverter implements Serializable{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the workspace root id.
|
* Sets the workspace root id.
|
||||||
*
|
*
|
||||||
|
@ -331,5 +423,386 @@ public class StorageHubToWorkpaceConverter implements Serializable{
|
||||||
|
|
||||||
this.workspaceRootId = workspaceRootId;
|
this.workspaceRootId = workspaceRootId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To simple map.
|
||||||
|
*
|
||||||
|
* @param propertyMap the property map
|
||||||
|
* @return the map
|
||||||
|
*/
|
||||||
|
public Map<String, String> toSimpleMap(PropertyMap propertyMap) {
|
||||||
|
|
||||||
|
if (propertyMap == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
Map<String, String> properties = null;
|
||||||
|
Map<String, Object> map = propertyMap.getValues();
|
||||||
|
|
||||||
|
if (map != null) {
|
||||||
|
properties = new HashMap<String, String>(map.size());
|
||||||
|
for (String key : map.keySet()) {
|
||||||
|
Object theValue = map.get(key);
|
||||||
|
properties.put(key, (String) theValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(properties!=null)
|
||||||
|
logger.error("Converted: "+properties.size()+" property/properties");
|
||||||
|
|
||||||
|
return properties;
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Error on converting a PropertyMap to simple Map<String,String>: ", e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds the GXT accounting item.
|
||||||
|
*
|
||||||
|
* @param accoutings the accoutings
|
||||||
|
* @param gxtEntryType the gxt entry type
|
||||||
|
* @return the list
|
||||||
|
*/
|
||||||
|
public List<GxtAccountingField> buildGXTAccountingItem(List<AccountEntry> accoutings, GxtAccountingEntryType gxtEntryType) {
|
||||||
|
|
||||||
|
List<GxtAccountingField> listAccFields = new ArrayList<GxtAccountingField>();
|
||||||
|
|
||||||
|
if(accoutings!=null){
|
||||||
|
logger.trace("accouting entry/entrie is/are "+accoutings.size()+ ", converting it/them...");
|
||||||
|
|
||||||
|
for (AccountEntry shubAccEntry : accoutings) {
|
||||||
|
|
||||||
|
GxtAccountingField af = new GxtAccountingField();
|
||||||
|
InfoContactModel user = buildGxtInfoContactFromPortalLogin(shubAccEntry.getUser());
|
||||||
|
af.setUser(user);
|
||||||
|
af.setDate(FormatterUtil.toDate(shubAccEntry.getDate()));
|
||||||
|
|
||||||
|
switch (shubAccEntry.getType()) {
|
||||||
|
|
||||||
|
case CREATE:
|
||||||
|
|
||||||
|
if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.CREATE)){
|
||||||
|
AccountEntryCreate create = (AccountEntryCreate) shubAccEntry;
|
||||||
|
af.setOperation(GxtAccountingEntryType.CREATE);
|
||||||
|
|
||||||
|
// af.setDescription(GxtAccountingEntryType.CREATE.getName() + " by "+user.getName());
|
||||||
|
String msg = "";
|
||||||
|
if(create.getItemName()==null || create.getItemName().isEmpty())
|
||||||
|
msg = GxtAccountingEntryType.CREATE.getId() + " by "+user.getName();
|
||||||
|
else{
|
||||||
|
|
||||||
|
if(create.getVersion()==null)
|
||||||
|
msg = create.getItemName() + " " + GxtAccountingEntryType.CREATE.getName() + " by "+user.getName();
|
||||||
|
else
|
||||||
|
msg = create.getItemName() + " v. "+create.getVersion()+" "+ GxtAccountingEntryType.CREATE.getName() + " by "+user.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
af.setDescription(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case READ:
|
||||||
|
|
||||||
|
if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.READ)){
|
||||||
|
|
||||||
|
AccountEntryRead read = (AccountEntryRead) shubAccEntry;
|
||||||
|
af.setOperation(GxtAccountingEntryType.READ);
|
||||||
|
af.setDescription(read.getItemName() + " " + GxtAccountingEntryType.READ.getName() + " by "+user.getName());
|
||||||
|
|
||||||
|
String msg = "";
|
||||||
|
if(read.getItemName()==null || read.getItemName().isEmpty())
|
||||||
|
msg = GxtAccountingEntryType.READ.getId() + " by "+user.getName();
|
||||||
|
else{
|
||||||
|
|
||||||
|
if(read.getVersion()==null)
|
||||||
|
msg = read.getItemName() + " " + GxtAccountingEntryType.READ.getName() + " by "+user.getName();
|
||||||
|
else
|
||||||
|
msg = read.getItemName() + " v."+read.getVersion() +" "+ GxtAccountingEntryType.READ.getName() + " by "+user.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
af.setDescription(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CUT:
|
||||||
|
|
||||||
|
if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.CUT)){
|
||||||
|
|
||||||
|
af.setOperation(GxtAccountingEntryType.CUT);
|
||||||
|
|
||||||
|
if(shubAccEntry instanceof AccountFolderEntryCut) {
|
||||||
|
|
||||||
|
AccountFolderEntryCut cut = (AccountFolderEntryCut) shubAccEntry;
|
||||||
|
|
||||||
|
String msg = "";
|
||||||
|
if(cut.getItemName()==null || cut.getItemName().isEmpty())
|
||||||
|
msg = GxtAccountingEntryType.CUT.getName() +" by "+user.getName();
|
||||||
|
else{
|
||||||
|
if(cut.getVersion()==null)
|
||||||
|
msg = cut.getItemName()+" "+GxtAccountingEntryType.CUT.getName() +" by "+user.getName();
|
||||||
|
else
|
||||||
|
msg = cut.getItemName()+" v."+cut.getVersion()+" "+GxtAccountingEntryType.CUT.getName() +" by "+user.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
af.setDescription(msg);
|
||||||
|
}else {
|
||||||
|
logger.warn("Found an "+AccountingEntryType.class.getSimpleName()+" of kind "+shubAccEntry.getType()+ " not castable to (instance of) "+AccountFolderEntryCut.class.getSimpleName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PASTE:
|
||||||
|
|
||||||
|
if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.PASTE)){
|
||||||
|
|
||||||
|
af.setOperation(GxtAccountingEntryType.PASTE);
|
||||||
|
AccountEntryPaste paste = (AccountEntryPaste) shubAccEntry;
|
||||||
|
|
||||||
|
if(paste.getVersion()==null)
|
||||||
|
af.setDescription(GxtAccountingEntryType.PASTE.getName() + " from "+paste.getFromPath()+" by "+user.getName());
|
||||||
|
else
|
||||||
|
af.setDescription(GxtAccountingEntryType.PASTE.getName() + " v. "+paste.getVersion()+" from "+paste.getFromPath()+" by "+user.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case REMOVAL:
|
||||||
|
|
||||||
|
if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.REMOVE)){
|
||||||
|
|
||||||
|
if(shubAccEntry instanceof AccountFolderEntryRemoval) {
|
||||||
|
af.setOperation(GxtAccountingEntryType.REMOVE);
|
||||||
|
AccountFolderEntryRemoval rem = (AccountFolderEntryRemoval) shubAccEntry;
|
||||||
|
String msg = rem.getItemName()==null || rem.getItemName().isEmpty()?"":rem.getItemName()+" ";
|
||||||
|
|
||||||
|
if(rem.getVersion()==null)
|
||||||
|
msg+= GxtAccountingEntryType.REMOVE.getName() +" by "+user.getName();
|
||||||
|
else
|
||||||
|
msg+= GxtAccountingEntryType.REMOVE.getName() +" v."+rem.getVersion()+" by "+user.getName();
|
||||||
|
|
||||||
|
af.setDescription(msg);
|
||||||
|
}else {
|
||||||
|
logger.warn("Found an "+AccountingEntryType.class.getSimpleName()+" of kind "+shubAccEntry.getType()+ " not castable to (instance of) "+AccountFolderEntryRemoval.class.getSimpleName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RENAMING:
|
||||||
|
|
||||||
|
if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.RENAME)){
|
||||||
|
|
||||||
|
if(shubAccEntry instanceof AccountFolderEntryRenaming) {
|
||||||
|
af.setOperation(GxtAccountingEntryType.RENAME);
|
||||||
|
AccountFolderEntryRenaming ren = (AccountFolderEntryRenaming) shubAccEntry;
|
||||||
|
String msg = ren.getOldItemName()==null || ren.getOldItemName().isEmpty()?"":ren.getOldItemName()+" ";
|
||||||
|
if(ren.getVersion()==null)
|
||||||
|
msg+= GxtAccountingEntryType.RENAME.getName() +" to "+ ren.getNewItemName()+ " by "+user.getName();
|
||||||
|
else
|
||||||
|
msg+= " v."+ren.getVersion() +" "+GxtAccountingEntryType.RENAME.getName() +" to "+ ren.getNewItemName()+ " by "+user.getName();
|
||||||
|
|
||||||
|
af.setDescription(msg);
|
||||||
|
}else {
|
||||||
|
logger.warn("Found an "+AccountingEntryType.class.getSimpleName()+" of kind "+shubAccEntry.getType()+ " not castable to (instance of) "+AccountFolderEntryRenaming.class.getSimpleName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ADD:
|
||||||
|
|
||||||
|
if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.ADD)){
|
||||||
|
|
||||||
|
if(shubAccEntry instanceof AccountFolderEntryAdd) {
|
||||||
|
af.setOperation(GxtAccountingEntryType.ADD);
|
||||||
|
AccountFolderEntryAdd acc = (AccountFolderEntryAdd) shubAccEntry;
|
||||||
|
String msg = acc.getItemName()==null || acc.getItemName().isEmpty()?"":acc.getItemName()+" ";
|
||||||
|
if(acc.getVersion()==null)
|
||||||
|
msg+=GxtAccountingEntryType.ADD.getName()+ " by "+user.getName();
|
||||||
|
else
|
||||||
|
msg+=" v."+acc.getVersion()+ " "+GxtAccountingEntryType.ADD.getName()+ " by "+user.getName();
|
||||||
|
|
||||||
|
af.setDescription(msg);
|
||||||
|
}else {
|
||||||
|
logger.warn("Found an "+AccountingEntryType.class.getSimpleName()+" of kind "+shubAccEntry.getType()+ " not castable to (instance of) "+AccountFolderEntryAdd.class.getSimpleName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case UPDATE:
|
||||||
|
|
||||||
|
if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.UPDATE)){
|
||||||
|
|
||||||
|
af.setOperation(GxtAccountingEntryType.UPDATE);
|
||||||
|
AccountEntryUpdate upd = (AccountEntryUpdate) shubAccEntry;
|
||||||
|
String msg = upd.getItemName()==null || upd.getItemName().isEmpty()?"":upd.getItemName()+" ";
|
||||||
|
if(upd.getVersion()==null)
|
||||||
|
msg+=GxtAccountingEntryType.UPDATE.getName()+" by "+user.getName();
|
||||||
|
else
|
||||||
|
msg+=" v."+upd.getVersion()+" "+GxtAccountingEntryType.UPDATE.getName()+" by "+user.getName();
|
||||||
|
|
||||||
|
af.setDescription(msg);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SHARE:
|
||||||
|
|
||||||
|
if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.SHARE)){
|
||||||
|
|
||||||
|
af.setOperation(GxtAccountingEntryType.SHARE);
|
||||||
|
|
||||||
|
AccountEntryShare acc = (AccountEntryShare) shubAccEntry;
|
||||||
|
|
||||||
|
String msg = "";
|
||||||
|
if(acc.getItemName()==null || acc.getItemName().isEmpty())
|
||||||
|
msg = user.getName() + " "+GxtAccountingEntryType.SHARE.getName()+ " workspace folder";
|
||||||
|
else
|
||||||
|
msg = user.getName() + " "+GxtAccountingEntryType.SHARE.getName()+ " workspace folder "+acc.getItemName();
|
||||||
|
|
||||||
|
if(acc.getMembers()!=null && acc.getMembers().length>0)
|
||||||
|
msg+=" with "+UserUtil.separateFullNameToCommaForPortalLogin(Arrays.asList(acc.getMembers()));
|
||||||
|
|
||||||
|
af.setDescription(msg);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case UNSHARE:
|
||||||
|
|
||||||
|
if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.UNSHARE)){
|
||||||
|
|
||||||
|
af.setOperation(GxtAccountingEntryType.UNSHARE);
|
||||||
|
AccountEntryUnshare uns = (AccountEntryUnshare) shubAccEntry;
|
||||||
|
String msg = uns.getItemName()==null || uns.getItemName().isEmpty()?"":uns.getItemName()+" ";
|
||||||
|
msg+=GxtAccountingEntryType.UNSHARE.getName()+" by "+user.getName();
|
||||||
|
af.setDescription(msg);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RESTORE:
|
||||||
|
|
||||||
|
if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.RESTORE)){
|
||||||
|
|
||||||
|
af.setOperation(GxtAccountingEntryType.RESTORE);
|
||||||
|
AccountEntryRestore acc = (AccountEntryRestore) shubAccEntry;
|
||||||
|
String msg = acc.getItemName()==null || acc.getItemName().isEmpty()?"":acc.getItemName()+" ";
|
||||||
|
|
||||||
|
if(acc.getVersion()==null)
|
||||||
|
msg+=GxtAccountingEntryType.RESTORE.getName()+" by "+user.getName();
|
||||||
|
else
|
||||||
|
msg+=" v."+acc.getVersion()+" "+GxtAccountingEntryType.RESTORE.getName() +" by "+user.getName();
|
||||||
|
|
||||||
|
af.setDescription(msg);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DISABLED_PUBLIC_ACCESS:
|
||||||
|
|
||||||
|
if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.DISABLED_PUBLIC_ACCESS)){
|
||||||
|
|
||||||
|
af.setOperation(GxtAccountingEntryType.DISABLED_PUBLIC_ACCESS);
|
||||||
|
AccountEntryDisabledPublicAccess acc = (AccountEntryDisabledPublicAccess) shubAccEntry;
|
||||||
|
//TODO acc.getItemName() is missing in SHUB
|
||||||
|
//String msg = acc.getItemName()==null || acc.getItemName().isEmpty()?"":acc.getItemName()+" ";
|
||||||
|
String msg=GxtAccountingEntryType.DISABLED_PUBLIC_ACCESS.getName()+" by "+user.getName();
|
||||||
|
af.setDescription(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ENABLED_PUBLIC_ACCESS:
|
||||||
|
|
||||||
|
if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.ENABLED_PUBLIC_ACCESS)){
|
||||||
|
|
||||||
|
af.setOperation(GxtAccountingEntryType.ENABLED_PUBLIC_ACCESS);
|
||||||
|
AccountEntryEnabledPublicAccess acc = (AccountEntryEnabledPublicAccess) shubAccEntry;
|
||||||
|
//TODO acc.getItemName() is missing in SHUB
|
||||||
|
//String msg = acc.getItemName()==null || acc.getItemName().isEmpty()?"":acc.getItemName()+" ";
|
||||||
|
String msg=GxtAccountingEntryType.ENABLED_PUBLIC_ACCESS.getName()+" by "+user.getName();
|
||||||
|
af.setDescription(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
listAccFields.add(af);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
logger.debug("get accounting readers converting completed - returning size "+listAccFields.size());
|
||||||
|
|
||||||
|
return listAccFields;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the gcube item properties for gcube item as HTML.
|
||||||
|
*
|
||||||
|
* @param wsItem the ws item
|
||||||
|
* @return the gcube item properties for gcube item as HTML
|
||||||
|
*/
|
||||||
|
public String getGcubeItemPropertiesForGcubeItemAsHTML(WorkspaceItem wsItem) {
|
||||||
|
|
||||||
|
|
||||||
|
Map<String, String> properties = getGcubeItemProperties(wsItem);
|
||||||
|
|
||||||
|
if(properties!=null){
|
||||||
|
|
||||||
|
if(properties.size()==0){
|
||||||
|
logger.warn("Map of Gcube Item Properties is empty for item: "+wsItem.getId());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
String html = "<div style=\"width: 100%; text-align:left; font-size: 10px;\">";
|
||||||
|
|
||||||
|
for (String key : properties.keySet()) {
|
||||||
|
String value = properties.get(key);
|
||||||
|
logger.trace("Getting property: ["+key+","+properties.get(key)+"]");
|
||||||
|
html+="<span style=\"font-weight:bold; padding-top: 5px;\">"+key+": </span>";
|
||||||
|
html+="<span style=\"font-weight:normal;\">";
|
||||||
|
html+=value;
|
||||||
|
html+="</span><br/>";
|
||||||
|
}
|
||||||
|
|
||||||
|
html+="</div>";
|
||||||
|
|
||||||
|
return html;
|
||||||
|
}else {
|
||||||
|
logger.warn("Gcube Item Properties not found for item: "+wsItem.getId());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the gcube item properties.
|
||||||
|
*
|
||||||
|
* @param wsItem the ws item
|
||||||
|
* @return the gcube item properties
|
||||||
|
*/
|
||||||
|
public Map<String, String> getGcubeItemProperties(WorkspaceItem wsItem) {
|
||||||
|
|
||||||
|
if(wsItem instanceof org.gcube.common.storagehubwrapper.shared.tohl.items.GCubeItem){
|
||||||
|
GCubeItem gItem = (GCubeItem) wsItem;
|
||||||
|
try {
|
||||||
|
if(gItem.getProperties()!=null){
|
||||||
|
PropertyMap map = gItem.getProperty();
|
||||||
|
return toSimpleMap(map);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Error on reading getProperty: ", e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,106 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package org.gcube.portlets.user.workspace.server.util;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.accessmanager.ACLType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Class AclTypeComparator.
|
|
||||||
*
|
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
|
||||||
* Mar 5, 2015
|
|
||||||
*/
|
|
||||||
public class AclTypeComparator implements Comparator<ACLType>{
|
|
||||||
|
|
||||||
|
|
||||||
public static final Map<ACLType, Integer> aclTypeOrder;
|
|
||||||
static
|
|
||||||
{
|
|
||||||
aclTypeOrder = new LinkedHashMap<ACLType, Integer>();
|
|
||||||
aclTypeOrder.put(ACLType.READ_ONLY, 0);
|
|
||||||
aclTypeOrder.put(ACLType.WRITE_OWNER, 1);
|
|
||||||
aclTypeOrder.put(ACLType.WRITE_ALL, 2);
|
|
||||||
// aclTypeOrder.put(ACLType.ADMINISTRATOR, 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int compare(ACLType o1, ACLType o2) {
|
|
||||||
if(o1==null)
|
|
||||||
return -1;
|
|
||||||
if(o2==null)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
Integer order1 = aclTypeOrder.get(o1);
|
|
||||||
Integer order2 = aclTypeOrder.get(o2);
|
|
||||||
|
|
||||||
if(order1==null)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if(order2==null)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if(order1==order2)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return order1<order2?-1:1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the allowed.
|
|
||||||
*
|
|
||||||
* @param aclType the acl type to compare
|
|
||||||
* @param includeEqual if true include equal ACLType, no otherwise
|
|
||||||
* @return the allowed
|
|
||||||
*/
|
|
||||||
public List<ACLType> getAllowed(ACLType aclType, boolean includeEqual) {
|
|
||||||
|
|
||||||
List<ACLType> allowed = new ArrayList<ACLType>();
|
|
||||||
|
|
||||||
if(aclType==null)
|
|
||||||
return allowed;
|
|
||||||
|
|
||||||
//IF MAP DOES NOT CONTAINS ACT TYPE IT IS NOT COMPARABLE
|
|
||||||
if(aclTypeOrder.get(aclType)==null)
|
|
||||||
return allowed;
|
|
||||||
|
|
||||||
for (ACLType aMap : aclTypeOrder.keySet()) {
|
|
||||||
int comparator = compare(aMap, aclType);
|
|
||||||
if(comparator==1)
|
|
||||||
allowed.add(aMap);
|
|
||||||
else if(includeEqual && comparator==0)
|
|
||||||
allowed.add(aMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
return allowed;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The main method.
|
|
||||||
*
|
|
||||||
* @param args the arguments
|
|
||||||
*/
|
|
||||||
public static void main(String[] args) {
|
|
||||||
|
|
||||||
AclTypeComparator comparator = new AclTypeComparator();
|
|
||||||
|
|
||||||
List<ACLType> allowed = comparator.getAllowed(ACLType.WRITE_ALL, false);
|
|
||||||
|
|
||||||
System.out.println(allowed);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -6,7 +6,8 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,7 +21,7 @@ public class AllowedMimeTypeToInline {
|
||||||
|
|
||||||
public static final String filename = "MimeTypePrefixToInline.properties";
|
public static final String filename = "MimeTypePrefixToInline.properties";
|
||||||
|
|
||||||
protected static Logger logger = Logger.getLogger(WsUtil.class);
|
protected static Logger logger = LoggerFactory.getLogger(WsUtil.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load mime type prefix.
|
* Load mime type prefix.
|
||||||
|
|
|
@ -6,10 +6,6 @@ import java.util.List;
|
||||||
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
|
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class DifferenceBetweenInfoContactModel.
|
* The Class DifferenceBetweenInfoContactModel.
|
||||||
*
|
*
|
||||||
|
|
|
@ -7,7 +7,8 @@ import java.net.SocketTimeoutException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,7 +19,7 @@ import org.apache.log4j.Logger;
|
||||||
public class HttpRequestUtil {
|
public class HttpRequestUtil {
|
||||||
|
|
||||||
private static final int CONNECTION_TIMEOUT = 1000;
|
private static final int CONNECTION_TIMEOUT = 1000;
|
||||||
public static Logger logger = Logger.getLogger(HttpRequestUtil.class);
|
public static Logger logger = LoggerFactory.getLogger(HttpRequestUtil.class);
|
||||||
|
|
||||||
public static boolean urlExists(String urlConn) throws Exception {
|
public static boolean urlExists(String urlConn) throws Exception {
|
||||||
|
|
||||||
|
|
|
@ -14,12 +14,13 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.apache.tika.config.TikaConfig;
|
import org.apache.tika.config.TikaConfig;
|
||||||
import org.apache.tika.detect.Detector;
|
import org.apache.tika.detect.Detector;
|
||||||
import org.apache.tika.io.TikaInputStream;
|
import org.apache.tika.io.TikaInputStream;
|
||||||
import org.apache.tika.metadata.Metadata;
|
import org.apache.tika.metadata.Metadata;
|
||||||
import org.apache.tika.mime.MediaType;
|
import org.apache.tika.mime.MediaType;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class MimeTypeUtil.
|
* The Class MimeTypeUtil.
|
||||||
|
@ -35,7 +36,7 @@ public class MimeTypeUtility {
|
||||||
|
|
||||||
private static final String DOT_STRING = ".";
|
private static final String DOT_STRING = ".";
|
||||||
|
|
||||||
protected static Logger logger = Logger.getLogger(MimeTypeUtility.class);
|
protected static Logger logger = LoggerFactory.getLogger(MimeTypeUtility.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -7,7 +7,8 @@ package org.gcube.portlets.user.workspace.server.util;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
|
|
||||||
import org.apache.commons.codec.binary.Base64;
|
import org.apache.commons.codec.binary.Base64;
|
||||||
import org.apache.log4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class StringUtil.
|
* The Class StringUtil.
|
||||||
|
@ -20,7 +21,7 @@ public class StringUtil {
|
||||||
/** The Constant UTF_8. */
|
/** The Constant UTF_8. */
|
||||||
public static final String UTF_8 = "UTF-8";
|
public static final String UTF_8 = "UTF-8";
|
||||||
public static String regx = ",@+^'?!\"%&$£/#()";
|
public static String regx = ",@+^'?!\"%&$£/#()";
|
||||||
protected static Logger logger = Logger.getLogger(StringUtil.class);
|
protected static Logger logger = LoggerFactory.getLogger(StringUtil.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the special characters.
|
* Removes the special characters.
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.gcube.portlets.user.workspace.server.util;
|
package org.gcube.portlets.user.workspace.server.util;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
@ -21,11 +17,13 @@ import javax.imageio.ImageIO;
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class ThumbnailGenerator.
|
* The Class ThumbnailGenerator.
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
* Oct 18, 2018
|
*
|
||||||
|
* Aug 1, 2019
|
||||||
*/
|
*/
|
||||||
public class ThumbnailGenerator {
|
public class ThumbnailGenerator {
|
||||||
|
|
||||||
|
@ -138,7 +136,7 @@ public class ThumbnailGenerator {
|
||||||
|
|
||||||
extension = extension.startsWith(".") ? extension : "." + extension;
|
extension = extension.startsWith(".") ? extension : "." + extension;
|
||||||
final File tempFile = File.createTempFile(filename, extension);
|
final File tempFile = File.createTempFile(filename, extension);
|
||||||
// tempFile.deleteOnExit();
|
//tempFile.deleteOnExit();
|
||||||
try (FileOutputStream out = new FileOutputStream(tempFile)) {
|
try (FileOutputStream out = new FileOutputStream(tempFile)) {
|
||||||
IOUtils.copy(in, out);
|
IOUtils.copy(in, out);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,8 @@ import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class UrlEncoderUtil.
|
* The Class UrlEncoderUtil.
|
||||||
|
@ -18,7 +19,7 @@ import org.apache.log4j.Logger;
|
||||||
public class UrlEncoderUtil {
|
public class UrlEncoderUtil {
|
||||||
|
|
||||||
public static String charset = "UTF-8";
|
public static String charset = "UTF-8";
|
||||||
public static Logger logger = Logger.getLogger(UrlEncoderUtil.class);
|
public static Logger logger = LoggerFactory.getLogger(UrlEncoderUtil.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encode query.
|
* Encode query.
|
||||||
|
@ -33,7 +34,7 @@ public class UrlEncoderUtil {
|
||||||
try {
|
try {
|
||||||
query+=URLEncoder.encode(string, charset)+"&";
|
query+=URLEncoder.encode(string, charset)+"&";
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
logger.error(e);
|
logger.error("Error: ",e);
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +57,7 @@ public class UrlEncoderUtil {
|
||||||
return URLEncoder.encode(value, charset);
|
return URLEncoder.encode(value, charset);
|
||||||
}
|
}
|
||||||
catch (UnsupportedEncodingException e) {
|
catch (UnsupportedEncodingException e) {
|
||||||
logger.error(e);
|
logger.error("Error: ",e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,7 +80,7 @@ public class UrlEncoderUtil {
|
||||||
try {
|
try {
|
||||||
query+=String.format(key+"=%s", URLEncoder.encode(parameters.get(key), charset))+"&";
|
query+=String.format(key+"=%s", URLEncoder.encode(parameters.get(key), charset))+"&";
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
logger.error(e);
|
logger.error("Error: ",e);
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,13 +3,14 @@ package org.gcube.portlets.user.workspace.server.util;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
|
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
|
||||||
import org.gcube.vomanagement.usermanagement.UserManager;
|
import org.gcube.vomanagement.usermanagement.UserManager;
|
||||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
|
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
|
||||||
import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault;
|
import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault;
|
||||||
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
|
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
|
||||||
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,7 +23,47 @@ import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||||
public class UserUtil {
|
public class UserUtil {
|
||||||
|
|
||||||
static UserManager um = new LiferayUserManager();
|
static UserManager um = new LiferayUserManager();
|
||||||
protected static Logger logger = Logger.getLogger(UserUtil.class);
|
protected static Logger logger = LoggerFactory.getLogger(UserUtil.class);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the user by username.
|
||||||
|
*
|
||||||
|
* @param portalLogin the portal login
|
||||||
|
* @return the user by username
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static GCubeUser getUserByUsername(String portalLogin) throws Exception{
|
||||||
|
|
||||||
|
if(portalLogin==null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
if (WsUtil.isWithinPortal()) { //INTO PORTAL
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
return um.getUserByUsername(portalLogin);
|
||||||
|
|
||||||
|
} catch (UserManagementSystemException e) {
|
||||||
|
logger.error("Error on getting user for: "+portalLogin, e);
|
||||||
|
throw new Exception("Error on reading the user info for login: "+portalLogin);
|
||||||
|
} catch (UserRetrievalFault e) {
|
||||||
|
logger.error("Error on getting user for: "+portalLogin, e);
|
||||||
|
throw new Exception("Error on reading the user info for login: "+portalLogin);
|
||||||
|
}catch (Exception e) {
|
||||||
|
logger.error("Error on getting user for: "+portalLogin, e);
|
||||||
|
//logger.warn("Return portal login "+portalLogin);
|
||||||
|
throw new Exception("Error on reading the user info for login: "+portalLogin);
|
||||||
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
logger.trace("DEVELOPEMENT MODE ON");
|
||||||
|
GCubeUser fakeUser = new GCubeUser(1, portalLogin, "mail","","","", portalLogin, 0, null, true, "", "", null);
|
||||||
|
logger.trace("Returning fake USER: "+fakeUser);
|
||||||
|
return fakeUser;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -42,7 +83,7 @@ public class UserUtil {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
curr = um.getUserByScreenName(portalLogin);
|
curr = um.getUserByUsername(portalLogin);
|
||||||
|
|
||||||
} catch (UserManagementSystemException e) {
|
} catch (UserManagementSystemException e) {
|
||||||
logger.error("UserManagementSystemException, during getting fullname for: "+portalLogin);
|
logger.error("UserManagementSystemException, during getting fullname for: "+portalLogin);
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
///**
|
|
||||||
// *
|
|
||||||
// */
|
|
||||||
//package org.gcube.portlets.user.workspace.server.util;
|
|
||||||
//
|
|
||||||
//import java.util.concurrent.BlockingQueue;
|
|
||||||
//import java.util.concurrent.LinkedBlockingQueue;
|
|
||||||
//
|
|
||||||
//import org.apache.log4j.Logger;
|
|
||||||
//import org.gcube.common.homelibrary.home.workspace.events.WorkspaceEvent;
|
|
||||||
//import org.gcube.common.homelibrary.home.workspace.events.WorkspaceListener;
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * @author Federico De Faveri defaveriAtisti.cnr.it
|
|
||||||
// *
|
|
||||||
// */
|
|
||||||
//public class WorkspaceEventCollector implements WorkspaceListener {
|
|
||||||
//
|
|
||||||
// protected static Logger logger = Logger.getLogger(WorkspaceEventCollector.class);
|
|
||||||
//
|
|
||||||
// protected BlockingQueue<WorkspaceEvent> eventsQueue = new LinkedBlockingQueue<WorkspaceEvent>();
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * @param logger
|
|
||||||
// */
|
|
||||||
// public WorkspaceEventCollector() {
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * {@inheritDoc}
|
|
||||||
// */
|
|
||||||
// public void workspaceEvent(WorkspaceEvent event) {
|
|
||||||
// try {
|
|
||||||
// logger.trace("EventCollector workspaceEvent"+event);
|
|
||||||
// eventsQueue.put(event);
|
|
||||||
// } catch (InterruptedException e) {
|
|
||||||
// logger.warn("Error adding a new event", e);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public WorkspaceEvent getEvent() throws InterruptedException
|
|
||||||
// {
|
|
||||||
// logger.trace("getEvent");
|
|
||||||
// return eventsQueue.take();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//}
|
|
|
@ -6,46 +6,40 @@ package org.gcube.portlets.user.workspace.server.util;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.gcube.applicationsupportlayer.social.ApplicationNotificationsManager;
|
import org.gcube.applicationsupportlayer.social.ApplicationNotificationsManager;
|
||||||
import org.gcube.applicationsupportlayer.social.NotificationsManager;
|
import org.gcube.applicationsupportlayer.social.NotificationsManager;
|
||||||
import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingSite;
|
import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingSite;
|
||||||
import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingUser;
|
import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingUser;
|
||||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
|
||||||
import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
|
||||||
import org.gcube.common.portal.PortalContext;
|
import org.gcube.common.portal.PortalContext;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
|
||||||
import org.gcube.common.storagehubwrapper.server.StorageHubWrapper;
|
import org.gcube.common.storagehubwrapper.server.StorageHubWrapper;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
|
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.WorkspaceFolderNotFoundException;
|
|
||||||
import org.gcube.portlets.user.urlshortener.UrlShortener;
|
import org.gcube.portlets.user.urlshortener.UrlShortener;
|
||||||
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||||||
import org.gcube.portlets.user.workspace.server.GWTWorkspaceBuilder;
|
|
||||||
import org.gcube.portlets.user.workspace.server.notifications.NotificationsProducer;
|
|
||||||
import org.gcube.portlets.user.workspace.server.notifications.tostoragehub.NotificationsProducerToStorageHub;
|
import org.gcube.portlets.user.workspace.server.notifications.tostoragehub.NotificationsProducerToStorageHub;
|
||||||
import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParameterForResolverIndex;
|
import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParameterForResolverIndex;
|
||||||
import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParameterForResolverIndex.RESOLVER_TYPE;
|
import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParameterForResolverIndex.RESOLVER_TYPE;
|
||||||
import org.gcube.portlets.user.workspace.server.tostoragehub.StorageHubToWorkpaceConverter;
|
import org.gcube.portlets.user.workspace.server.tostoragehub.StorageHubToWorkpaceConverter;
|
||||||
import org.gcube.portlets.user.workspace.server.util.resource.PropertySpecialFolderReader;
|
import org.gcube.portlets.user.workspace.server.util.resource.PropertySpecialFolderReader;
|
||||||
import org.gcube.portlets.user.workspace.server.util.scope.ScopeUtilFilter;
|
import org.gcube.portlets.user.workspace.server.util.scope.ScopeUtilFilter;
|
||||||
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
|
import org.gcube.portlets.widgets.workspacesharingwidget.server.notifications.NotificationsProducer;
|
||||||
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.liferay.portal.service.UserLocalServiceUtil;
|
import com.liferay.portal.service.UserLocalServiceUtil;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class WsUtil.
|
* The Class WsUtil.
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
* Nov 25, 2016
|
*
|
||||||
|
* Aug 1, 2019
|
||||||
*/
|
*/
|
||||||
public class WsUtil {
|
public class WsUtil {
|
||||||
|
|
||||||
public static final String FOLDER_PUBLISHING_ON_THREDDS = "FolderPublishingOnThredds";
|
public static final String FOLDER_PUBLISHING_ON_THREDDS = "FolderPublishingOnThredds";
|
||||||
|
|
||||||
protected static Logger logger = Logger.getLogger(WsUtil.class);
|
protected static Logger logger = LoggerFactory.getLogger(WsUtil.class);
|
||||||
|
|
||||||
public static final String FOLDERIMPORTER_ATTRIBUTE = "FOLDER_IMPORTER";
|
public static final String FOLDERIMPORTER_ATTRIBUTE = "FOLDER_IMPORTER";
|
||||||
public static final String METADATACONVERTER_ATTRIBUTE = "METADATA_CONVERTER";
|
public static final String METADATACONVERTER_ATTRIBUTE = "METADATA_CONVERTER";
|
||||||
|
@ -134,136 +128,6 @@ public class WsUtil {
|
||||||
return PortalContext.getConfiguration().getCurrentUser(httpServletRequest) == null;
|
return PortalContext.getConfiguration().getCurrentUser(httpServletRequest) == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the workspace.
|
|
||||||
*
|
|
||||||
* @param httpServletRequest
|
|
||||||
* Servlet request
|
|
||||||
* @return Workspace
|
|
||||||
* @throws org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException
|
|
||||||
* Folder not found error
|
|
||||||
* @throws org.gcube.common.homelibrary.home.exceptions.InternalErrorException
|
|
||||||
* Internal error
|
|
||||||
* @throws HomeNotFoundException
|
|
||||||
* Home not found error
|
|
||||||
*/
|
|
||||||
public static Workspace getWorkspace(HttpServletRequest httpServletRequest)
|
|
||||||
throws org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException,
|
|
||||||
org.gcube.common.homelibrary.home.exceptions.InternalErrorException, HomeNotFoundException {
|
|
||||||
|
|
||||||
logger.trace("Get Workspace");
|
|
||||||
PortalContextInfo info = getPortalContext(httpServletRequest);
|
|
||||||
logger.trace("PortalContextInfo: " + info);
|
|
||||||
|
|
||||||
ScopeProvider.instance.set(info.getCurrentScope());
|
|
||||||
logger.trace("Scope provider instancied");
|
|
||||||
|
|
||||||
Workspace workspace = HomeLibrary.getUserWorkspace(info.getUsername());
|
|
||||||
return workspace;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the workspace.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param httpServletRequest
|
|
||||||
* Workspace
|
|
||||||
* @param contextID
|
|
||||||
* contexId
|
|
||||||
* @param user
|
|
||||||
* user
|
|
||||||
* @return Workspace
|
|
||||||
* @throws InternalErrorException
|
|
||||||
* Internal error
|
|
||||||
* @throws HomeNotFoundException
|
|
||||||
* Home not found error
|
|
||||||
* @throws WorkspaceFolderNotFoundException
|
|
||||||
* Folder not found error
|
|
||||||
* @throws org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException
|
|
||||||
* folder not found error
|
|
||||||
* @throws org.gcube.common.homelibrary.home.exceptions.InternalErrorException
|
|
||||||
* internal error
|
|
||||||
*/
|
|
||||||
public static Workspace getWorkspace(HttpServletRequest httpServletRequest, String contextID, GCubeUser user)
|
|
||||||
throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException,
|
|
||||||
org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException,
|
|
||||||
org.gcube.common.homelibrary.home.exceptions.InternalErrorException {
|
|
||||||
logger.info("Get workspace using contextID: " + contextID + ", current user: " + user.getUsername());
|
|
||||||
String currentScope;
|
|
||||||
|
|
||||||
if (isWithinPortal())
|
|
||||||
currentScope = PortalContext.getConfiguration().getCurrentScope(contextID);
|
|
||||||
else {
|
|
||||||
currentScope = PortalContext.getConfiguration().getCurrentScope(httpServletRequest);
|
|
||||||
logger.warn("STARTING IN TEST MODE!!!! USING SCOPE: " + currentScope);
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.info("For ContextID: " + contextID + ", read scope from Portal Context: " + currentScope);
|
|
||||||
PortalContextInfo info = getPortalContext(httpServletRequest, currentScope);
|
|
||||||
logger.trace("PortalContextInfo: " + info);
|
|
||||||
|
|
||||||
ScopeProvider.instance.set(info.getCurrentScope());
|
|
||||||
logger.trace("Scope provider instancied");
|
|
||||||
|
|
||||||
String username = null;
|
|
||||||
try {
|
|
||||||
if (user.getUsername().compareTo(info.getUsername()) != 0) {
|
|
||||||
logger.debug("Gcube user read from Portal Context " + user.getUsername()
|
|
||||||
+ " is different by GCubeUser passed, using the second one: " + info.getUsername());
|
|
||||||
username = user.getUsername();
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("Error comparing username read from input parameter and Portal context");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (username != null)
|
|
||||||
info.setUsername(username);
|
|
||||||
|
|
||||||
Workspace workspace = HomeLibrary.getUserWorkspace(info.getUsername());
|
|
||||||
return workspace;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* utility method extract the @domain.com from an email address
|
|
||||||
* return @unknown-domain in case of no emails
|
|
||||||
*/
|
|
||||||
private String extractDomainFromEmail(String email) {
|
|
||||||
int index = email.indexOf('@');
|
|
||||||
if (index > 0)
|
|
||||||
return email.substring(index);
|
|
||||||
else
|
|
||||||
return "@unknown-domain";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the GWT workspace builder.
|
|
||||||
*
|
|
||||||
* @param httpServletRequest
|
|
||||||
* the http servlet request
|
|
||||||
* @return the GWT workspace builder
|
|
||||||
*/
|
|
||||||
public static GWTWorkspaceBuilder getGWTWorkspaceBuilder(HttpServletRequest httpServletRequest) {
|
|
||||||
PortalContextInfo info = getPortalContext(httpServletRequest);
|
|
||||||
logger.trace("PortalContextInfo: " + info);
|
|
||||||
|
|
||||||
HttpSession session = httpServletRequest.getSession();
|
|
||||||
|
|
||||||
GWTWorkspaceBuilder builder = (GWTWorkspaceBuilder) session.getAttribute(WORKSPACEBUILDER_ATTRIBUTE);
|
|
||||||
if (builder == null) {
|
|
||||||
logger.info("Initializing the workspace area builder");
|
|
||||||
builder = new GWTWorkspaceBuilder();
|
|
||||||
// ADDED 03/09/2013
|
|
||||||
builder.setContexInfo(
|
|
||||||
new InfoContactModel(info.getUsername(), info.getUsername(), info.getUserFullName(), "", false),
|
|
||||||
info.getCurrentScope());
|
|
||||||
session.setAttribute(WORKSPACEBUILDER_ATTRIBUTE, builder);
|
|
||||||
}
|
|
||||||
|
|
||||||
return builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the notification manager.
|
* Gets the notification manager.
|
||||||
*
|
*
|
||||||
|
@ -338,19 +202,24 @@ public class WsUtil {
|
||||||
* @return true, if is vre
|
* @return true, if is vre
|
||||||
*/
|
*/
|
||||||
public static boolean isVRE(String scope) {
|
public static boolean isVRE(String scope) {
|
||||||
|
|
||||||
int slashCount = StringUtils.countMatches(scope, "/");
|
if(scope==null || scope.isEmpty())
|
||||||
|
|
||||||
if (slashCount < 3) {
|
|
||||||
logger.trace("currentScope is not VRE");
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
String[] splitted = scope.split("/");
|
||||||
|
logger.trace("scope splitted: "+splitted.length);
|
||||||
|
|
||||||
|
if(splitted.length==4) {
|
||||||
|
logger.trace("currentScope is VRE");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.trace("currentScope is VRE");
|
logger.trace("currentScope is not VRE");
|
||||||
return true;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the scope util filter.
|
* Gets the scope util filter.
|
||||||
*
|
*
|
||||||
|
@ -566,42 +435,6 @@ public class WsUtil {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
|
||||||
// * Gets the notification manager to storage hub.
|
|
||||||
// *
|
|
||||||
// * @param httpServletRequest the http servlet request
|
|
||||||
// * @return the notification manager to storage hub
|
|
||||||
// */
|
|
||||||
// public static NotificationsManager
|
|
||||||
// getNotificationManagerToStorageHub(HttpServletRequest httpServletRequest)
|
|
||||||
// {
|
|
||||||
// PortalContextInfo info = getPortalContext(httpServletRequest);
|
|
||||||
// HttpSession session = httpServletRequest.getSession();
|
|
||||||
// NotificationsManager notifMng = (NotificationsManager)
|
|
||||||
// session.getAttribute(NOTIFICATION_MANAGER_TO_STORAGEHUB);
|
|
||||||
//
|
|
||||||
// if (notifMng == null) {
|
|
||||||
// try{
|
|
||||||
// logger.trace("Create new NotificationsManager for user:
|
|
||||||
// "+info.getUsername());
|
|
||||||
// logger.trace("New ApplicationNotificationsManager with portlet class
|
|
||||||
// name: "+NOTIFICATION_PORTLET_CLASS_ID);
|
|
||||||
// SocialNetworkingSite site = new SocialNetworkingSite(httpServletRequest);
|
|
||||||
// SocialNetworkingUser curser = new
|
|
||||||
// SocialNetworkingUser(info.getUsername(), info.getUserEmail(),
|
|
||||||
// info.getUserFullName(), info.getUserAvatarID());
|
|
||||||
// notifMng = new ApplicationNotificationsManager(site,
|
|
||||||
// info.getCurrentScope(), curser, NOTIFICATION_PORTLET_CLASS_ID);
|
|
||||||
// session.setAttribute(NOTIFICATION_MANAGER_TO_STORAGEHUB, notifMng);
|
|
||||||
// }catch (Exception e) {
|
|
||||||
// logger.error("An error occurred instancing
|
|
||||||
// ApplicationNotificationsManager for user: "+info.getUsername(),e);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return notifMng;
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the notification producer to storage hub.
|
* Gets the notification producer to storage hub.
|
||||||
*
|
*
|
||||||
|
|
|
@ -7,8 +7,9 @@ import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
||||||
|
@ -18,7 +19,7 @@ import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
||||||
public class PropertySpecialFolderReader {
|
public class PropertySpecialFolderReader {
|
||||||
|
|
||||||
|
|
||||||
protected static Logger logger = Logger.getLogger(PropertySpecialFolderReader.class);
|
protected static Logger logger = LoggerFactory.getLogger(PropertySpecialFolderReader.class);
|
||||||
protected String specialFolderName = "";
|
protected String specialFolderName = "";
|
||||||
|
|
||||||
public PropertySpecialFolderReader(String absolutePath) throws PropertyFileReadingErrorException {
|
public PropertySpecialFolderReader(String absolutePath) throws PropertyFileReadingErrorException {
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
package org.gcube.portlets.user.workspace.server.util.scope;
|
package org.gcube.portlets.user.workspace.server.util.scope;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public class ScopeUtilFilter {
|
public class ScopeUtilFilter {
|
||||||
|
|
||||||
private static final String SCOPE_SEPARATOR = "/";
|
private static final String SCOPE_SEPARATOR = "/";
|
||||||
private String scopeRoot = null;
|
private String scopeRoot = null;
|
||||||
public static Logger logger = Logger.getLogger(ScopeUtilFilter.class);
|
public static Logger logger = LoggerFactory.getLogger(ScopeUtilFilter.class);
|
||||||
public Map<String, String> hashScopesFiltered = new HashMap<String, String>();
|
public Map<String, String> hashScopesFiltered = new HashMap<String, String>();
|
||||||
|
|
||||||
public static final String ALLSCOPE = "All spaces";
|
public static final String ALLSCOPE = "All spaces";
|
||||||
|
@ -20,10 +20,9 @@ public class ScopeUtilFilter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param scopeName
|
* @param scopeName scope name
|
||||||
* scope name
|
* @param addIdAllSpaces if true add "ID All spaces" - "All spaces" pair into
|
||||||
* @param addIdAllSpaces
|
* map
|
||||||
* if true add "ID All spaces" - "All spaces" pair into map
|
|
||||||
*/
|
*/
|
||||||
public ScopeUtilFilter(String scopeName, boolean addIdAllSpaces) {
|
public ScopeUtilFilter(String scopeName, boolean addIdAllSpaces) {
|
||||||
|
|
||||||
|
@ -48,7 +47,6 @@ public class ScopeUtilFilter {
|
||||||
public List<String> convertListScopeToPortlet(List<String> listScopes) {
|
public List<String> convertListScopeToPortlet(List<String> listScopes) {
|
||||||
|
|
||||||
logger.trace("List Scope converting..." + listScopes);
|
logger.trace("List Scope converting..." + listScopes);
|
||||||
|
|
||||||
List<String> scopesConverted = new ArrayList<String>();
|
List<String> scopesConverted = new ArrayList<String>();
|
||||||
scopesConverted.add(ALLSCOPE);
|
scopesConverted.add(ALLSCOPE);
|
||||||
|
|
||||||
|
@ -128,23 +126,15 @@ public class ScopeUtilFilter {
|
||||||
public String getScopeRoot() {
|
public String getScopeRoot() {
|
||||||
return scopeRoot;
|
return scopeRoot;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
public static void main(String[] args) {
|
* public static void main(String[] args) { String scope = "/gcube";
|
||||||
String scope = "/gcube";
|
* List<String> listTest = Arrays.asList(new String[] { "/gcube/devsec/devre",
|
||||||
|
* "/gcube/devsec", "/gcube/devsec/devNEXT", "/", "/gcub", "/gcube" });
|
||||||
List<String> listTest = Arrays.asList(new String[] { "/gcube/devsec/devre", "/gcube/devsec",
|
* ScopeUtilFilter filter = new ScopeUtilFilter(scope, false);
|
||||||
"/gcube/devsec/devNEXT", "/", "/gcub", "/gcube" });
|
* System.out.println("scope root is: " + filter.getScopeRoot());
|
||||||
|
* filter.convertListScopeToPortlet(listTest);
|
||||||
ScopeUtilFilter filter = new ScopeUtilFilter(scope, false);
|
* System.out.println("get portal scope for /devsec: " +
|
||||||
|
* filter.getPortalScopeFromFilteredScope("/devsec")); filter.printScopes(); }
|
||||||
System.out.println("scope root is: " + filter.getScopeRoot());
|
*/
|
||||||
|
|
||||||
filter.convertListScopeToPortlet(listTest);
|
|
||||||
|
|
||||||
System.out.println("get portal scope for /devsec: " + filter.getPortalScopeFromFilteredScope("/devsec"));
|
|
||||||
|
|
||||||
filter.printScopes();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.workspace.shared;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
||||||
|
* Nov 4, 2015
|
||||||
|
*/
|
||||||
|
public class ListContact<T extends InfoContactModel> extends ArrayList<T> implements Serializable{
|
||||||
|
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 544202687567940083L;
|
||||||
|
|
||||||
|
public ListContact() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean contains(InfoContactModel infoContactModel) {
|
||||||
|
|
||||||
|
if(infoContactModel==null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
|
||||||
|
if(infoContactModel.getLogin()==null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
|
||||||
|
for (int i = 0; i < this.size(); i++){
|
||||||
|
|
||||||
|
InfoContactModel log = get(i);
|
||||||
|
if (log.getLogin()!=null && log.getLogin().compareTo(infoContactModel.getLogin())==0)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -185,6 +185,7 @@ text/plain=txt
|
||||||
text/richtext=rtx
|
text/richtext=rtx
|
||||||
text/scriptlet=sct
|
text/scriptlet=sct
|
||||||
text/tab-separated-values=tsv
|
text/tab-separated-values=tsv
|
||||||
|
text/uri-list=txt
|
||||||
text/webviewhtml=htt
|
text/webviewhtml=htt
|
||||||
text/x-component=htc
|
text/x-component=htc
|
||||||
text/x-setext=etx
|
text/x-setext=etx
|
||||||
|
|
|
@ -153,6 +153,7 @@ text/plain=txt
|
||||||
text/richtext=rtx
|
text/richtext=rtx
|
||||||
text/scriptlet=sct
|
text/scriptlet=sct
|
||||||
text/tab-separated-values=tsv
|
text/tab-separated-values=tsv
|
||||||
|
text/uri-list=txt
|
||||||
text/webviewhtml=htt
|
text/webviewhtml=htt
|
||||||
text/x-component=htc
|
text/x-component=htc
|
||||||
text/x-setext=etx
|
text/x-setext=etx
|
||||||
|
|
|
@ -1,86 +1,88 @@
|
||||||
/**
|
//TODO IT MUST BE MOVED TO SHUB
|
||||||
*
|
|
||||||
*/
|
|
||||||
package org.gcube.portlets.user.workspace;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
///**
|
||||||
import java.util.List;
|
// *
|
||||||
|
// */
|
||||||
import org.apache.log4j.Logger;
|
//package org.gcube.portlets.user.workspace;
|
||||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
//
|
||||||
import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
|
//import java.util.ArrayList;
|
||||||
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
//import java.util.List;
|
||||||
import org.gcube.common.homelibrary.home.exceptions.UserNotFoundException;
|
//
|
||||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
//import org.apache.log4j.Logger;
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceSharedFolder;
|
//import org.gcube.common.homelibrary.home.HomeLibrary;
|
||||||
import org.gcube.common.homelibrary.home.workspace.exceptions.InsufficientPrivilegesException;
|
//import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
|
||||||
import org.gcube.common.homelibrary.home.workspace.exceptions.ItemAlreadyExistException;
|
//import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
||||||
import org.gcube.common.homelibrary.home.workspace.exceptions.ItemNotFoundException;
|
//import org.gcube.common.homelibrary.home.exceptions.UserNotFoundException;
|
||||||
import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
|
//import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||||
import org.gcube.common.homelibrary.home.workspace.exceptions.WrongDestinationException;
|
//import org.gcube.common.homelibrary.home.workspace.WorkspaceSharedFolder;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
//import org.gcube.common.homelibrary.home.workspace.exceptions.InsufficientPrivilegesException;
|
||||||
import org.gcube.common.scope.impl.ScopeBean;
|
//import org.gcube.common.homelibrary.home.workspace.exceptions.ItemAlreadyExistException;
|
||||||
|
//import org.gcube.common.homelibrary.home.workspace.exceptions.ItemNotFoundException;
|
||||||
/**
|
//import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
|
||||||
*
|
//import org.gcube.common.homelibrary.home.workspace.exceptions.WrongDestinationException;
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it Jul 14, 2015
|
//import org.gcube.common.scope.api.ScopeProvider;
|
||||||
*/
|
//import org.gcube.common.scope.impl.ScopeBean;
|
||||||
public class CreateSharedFolder {
|
//
|
||||||
|
///**
|
||||||
protected static Logger logger = Logger.getLogger(CreateSharedFolder.class);
|
// *
|
||||||
// public static String DEFAULT_SCOPE = "/d4science.research-infrastructures.eu/gCubeApps/EcologicalModelling"; //PRODUCTION
|
// * @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it Jul 14, 2015
|
||||||
public static String DEFAULT_SCOPE = "/gcube/devsec"; //DEV
|
// */
|
||||||
|
//public class CreateSharedFolder {
|
||||||
public static String USER = "francesco.mangiacrapa"; //PRODUCTION
|
//
|
||||||
|
// protected static Logger logger = Logger.getLogger(CreateSharedFolder.class);
|
||||||
public static void main(String[] args) {
|
//// public static String DEFAULT_SCOPE = "/d4science.research-infrastructures.eu/gCubeApps/EcologicalModelling"; //PRODUCTION
|
||||||
|
// public static String DEFAULT_SCOPE = "/gcube/devsec"; //DEV
|
||||||
try {
|
//
|
||||||
ScopeBean scope = new ScopeBean(DEFAULT_SCOPE);
|
// public static String USER = "francesco.mangiacrapa"; //PRODUCTION
|
||||||
ScopeProvider.instance.set(scope.toString());
|
//
|
||||||
Workspace workspace = HomeLibrary.getHomeManagerFactory()
|
// public static void main(String[] args) {
|
||||||
.getHomeManager().getHome(USER)
|
//
|
||||||
.getWorkspace();
|
// try {
|
||||||
|
// ScopeBean scope = new ScopeBean(DEFAULT_SCOPE);
|
||||||
String folderName = "Test Folder";
|
// ScopeProvider.instance.set(scope.toString());
|
||||||
String desc = "descr";
|
// Workspace workspace = HomeLibrary.getHomeManagerFactory()
|
||||||
List<String> listLogin = new ArrayList<String>();
|
// .getHomeManager().getHome(USER)
|
||||||
|
// .getWorkspace();
|
||||||
listLogin.add("valentina.marioli");
|
//
|
||||||
listLogin.add("massimiliano.assante");
|
// String folderName = "Test Folder";
|
||||||
|
// String desc = "descr";
|
||||||
WorkspaceSharedFolder sharedFolder = workspace.createSharedFolder(
|
// List<String> listLogin = new ArrayList<String>();
|
||||||
folderName, desc, listLogin, workspace.getRoot().getId());
|
//
|
||||||
|
// listLogin.add("valentina.marioli");
|
||||||
if (sharedFolder == null)
|
// listLogin.add("massimiliano.assante");
|
||||||
System.out.println("shared folder is null");
|
//
|
||||||
|
// WorkspaceSharedFolder sharedFolder = workspace.createSharedFolder(
|
||||||
System.out
|
// folderName, desc, listLogin, workspace.getRoot().getId());
|
||||||
.println("Shared folder created: " + sharedFolder.getId());
|
//
|
||||||
} catch (InsufficientPrivilegesException e) {
|
// if (sharedFolder == null)
|
||||||
// TODO Auto-generated catch block
|
// System.out.println("shared folder is null");
|
||||||
e.printStackTrace();
|
//
|
||||||
} catch (ItemAlreadyExistException e) {
|
// System.out
|
||||||
// TODO Auto-generated catch block
|
// .println("Shared folder created: " + sharedFolder.getId());
|
||||||
e.printStackTrace();
|
// } catch (InsufficientPrivilegesException e) {
|
||||||
} catch (WrongDestinationException e) {
|
// // TODO Auto-generated catch block
|
||||||
// TODO Auto-generated catch block
|
// e.printStackTrace();
|
||||||
e.printStackTrace();
|
// } catch (ItemAlreadyExistException e) {
|
||||||
} catch (ItemNotFoundException e) {
|
// // TODO Auto-generated catch block
|
||||||
// TODO Auto-generated catch block
|
// e.printStackTrace();
|
||||||
e.printStackTrace();
|
// } catch (WrongDestinationException e) {
|
||||||
} catch (WorkspaceFolderNotFoundException e) {
|
// // TODO Auto-generated catch block
|
||||||
// TODO Auto-generated catch block
|
// e.printStackTrace();
|
||||||
e.printStackTrace();
|
// } catch (ItemNotFoundException e) {
|
||||||
} catch (InternalErrorException e) {
|
// // TODO Auto-generated catch block
|
||||||
// TODO Auto-generated catch block
|
// e.printStackTrace();
|
||||||
e.printStackTrace();
|
// } catch (WorkspaceFolderNotFoundException e) {
|
||||||
} catch (HomeNotFoundException e) {
|
// // TODO Auto-generated catch block
|
||||||
// TODO Auto-generated catch block
|
// e.printStackTrace();
|
||||||
e.printStackTrace();
|
// } catch (InternalErrorException e) {
|
||||||
} catch (UserNotFoundException e) {
|
// // TODO Auto-generated catch block
|
||||||
// TODO Auto-generated catch block
|
// e.printStackTrace();
|
||||||
e.printStackTrace();
|
// } catch (HomeNotFoundException e) {
|
||||||
}
|
// // TODO Auto-generated catch block
|
||||||
}
|
// e.printStackTrace();
|
||||||
}
|
// } catch (UserNotFoundException e) {
|
||||||
|
// // TODO Auto-generated catch block
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
|
@ -1,229 +1,238 @@
|
||||||
/**
|
//TODO IT MUST BE MOVED TO SHUB
|
||||||
*
|
///**
|
||||||
*/
|
// *
|
||||||
package org.gcube.portlets.user.workspace;
|
// */
|
||||||
|
//package org.gcube.portlets.user.workspace;
|
||||||
import java.util.ArrayList;
|
//
|
||||||
import java.util.List;
|
//import java.util.ArrayList;
|
||||||
|
//import java.util.List;
|
||||||
import org.gcube.common.homelibary.model.items.type.WorkspaceItemType;
|
//
|
||||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
//import org.gcube.common.homelibary.model.items.type.WorkspaceItemType;
|
||||||
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
//import org.gcube.common.homelibrary.home.HomeLibrary;
|
||||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
//import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
//import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
//import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
||||||
import org.gcube.common.homelibrary.home.workspace.exceptions.InsufficientPrivilegesException;
|
//import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
||||||
import org.gcube.common.homelibrary.home.workspace.exceptions.ItemNotFoundException;
|
//import org.gcube.common.homelibrary.home.workspace.exceptions.InsufficientPrivilegesException;
|
||||||
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
|
//import org.gcube.common.homelibrary.home.workspace.exceptions.ItemNotFoundException;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
//import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
|
||||||
import org.gcube.common.scope.impl.ScopeBean;
|
//import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.portlets.user.workspace.client.model.FileGridModel;
|
//import org.gcube.common.scope.impl.ScopeBean;
|
||||||
import org.gcube.portlets.user.workspace.server.GWTWorkspaceBuilder;
|
//import org.gcube.portlets.user.workspace.client.model.FileGridModel;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
*
|
// *
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
// * @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
||||||
* Oct 28, 2015
|
// * Oct 28, 2015
|
||||||
*/
|
// */
|
||||||
public class DeleteTest {
|
///*
|
||||||
|
// *
|
||||||
|
// *
|
||||||
public static String DEFAULT_SCOPE = "/gcube/devsec"; //DEV
|
// * IT MUST BE MOVED TO SHUB
|
||||||
// public static String DEFAULT_SCOPE = "/d4science.research-infrastructures.eu/gCubeApps/DESCRAMBLE";
|
// *
|
||||||
public static String TEST_USER = "francesco.mangiacrapa";
|
// *
|
||||||
|
// *
|
||||||
public static String PARENT_ID = "a9ead58c-d645-4699-addd-5c6e5f1aff06";
|
//public class DeleteTest {
|
||||||
private static Workspace ws;
|
//
|
||||||
|
//
|
||||||
private static GWTWorkspaceBuilder builder = new GWTWorkspaceBuilder();
|
// public static String DEFAULT_SCOPE = "/gcube/devsec"; //DEV
|
||||||
|
//// public static String DEFAULT_SCOPE = "/d4science.research-infrastructures.eu/gCubeApps/DESCRAMBLE";
|
||||||
public static void main(String[] args) {
|
// public static String TEST_USER = "francesco.mangiacrapa";
|
||||||
|
//
|
||||||
try {
|
// public static String PARENT_ID = "a9ead58c-d645-4699-addd-5c6e5f1aff06";
|
||||||
|
// private static Workspace ws;
|
||||||
ScopeBean scope = new ScopeBean(DEFAULT_SCOPE);
|
//
|
||||||
ScopeProvider.instance.set(scope.toString());
|
// private static GWTWorkspaceBuilder builder = new GWTWorkspaceBuilder();
|
||||||
|
//
|
||||||
ws = HomeLibrary
|
// public static void main(String[] args) {
|
||||||
.getHomeManagerFactory()
|
//
|
||||||
.getHomeManager()
|
// try {
|
||||||
.getHome(TEST_USER)
|
//
|
||||||
.getWorkspace();
|
// ScopeBean scope = new ScopeBean(DEFAULT_SCOPE);
|
||||||
//
|
// ScopeProvider.instance.set(scope.toString());
|
||||||
|
//
|
||||||
final List<String> children = getIdsOnlyFolderForID(PARENT_ID);
|
// ws = HomeLibrary
|
||||||
|
// .getHomeManagerFactory()
|
||||||
|
// .getHomeManager()
|
||||||
if(children.size()<2){
|
// .getHome(TEST_USER)
|
||||||
System.err.println("children size < 2, add others children");
|
// .getWorkspace();
|
||||||
return;
|
// //
|
||||||
}
|
//
|
||||||
|
// final List<String> children = getIdsOnlyFolderForID(PARENT_ID);
|
||||||
final int medium = children.size()/2;
|
//
|
||||||
|
//
|
||||||
Thread t1 = new Thread("T1"){
|
// if(children.size()<2){
|
||||||
public void run() {
|
// System.err.println("children size < 2, add others children");
|
||||||
System.out.println("T1 start...");
|
// return;
|
||||||
removeRange(children, 0, medium);
|
// }
|
||||||
System.out.println("T1 end");
|
//
|
||||||
|
// final int medium = children.size()/2;
|
||||||
};
|
//
|
||||||
};
|
// Thread t1 = new Thread("T1"){
|
||||||
|
// public void run() {
|
||||||
t1.start();
|
// System.out.println("T1 start...");
|
||||||
t1.join();
|
// removeRange(children, 0, medium);
|
||||||
|
// System.out.println("T1 end");
|
||||||
List<? extends WorkspaceItem> childrenNEW = getChildrenForID(PARENT_ID);
|
//
|
||||||
|
// };
|
||||||
print(childrenNEW);
|
// };
|
||||||
|
//
|
||||||
|
// t1.start();
|
||||||
Thread t2 = new Thread("T2"){
|
// t1.join();
|
||||||
public void run() {
|
//
|
||||||
System.out.println("T2 start...");
|
// List<? extends WorkspaceItem> childrenNEW = getChildrenForID(PARENT_ID);
|
||||||
removeRange(children, medium, children.size());
|
//
|
||||||
System.out.println("T2 end");
|
// print(childrenNEW);
|
||||||
};
|
//
|
||||||
};
|
//
|
||||||
|
// Thread t2 = new Thread("T2"){
|
||||||
t2.start();
|
// public void run() {
|
||||||
t2.join();
|
// System.out.println("T2 start...");
|
||||||
|
// removeRange(children, medium, children.size());
|
||||||
childrenNEW = getChildrenForID(PARENT_ID);
|
// System.out.println("T2 end");
|
||||||
print(childrenNEW);
|
// };
|
||||||
|
// };
|
||||||
|
//
|
||||||
System.out.println("\n\nDONE!");
|
// t2.start();
|
||||||
} catch (Exception e) {
|
// t2.join();
|
||||||
e.printStackTrace();
|
//
|
||||||
}
|
// childrenNEW = getChildrenForID(PARENT_ID);
|
||||||
}
|
// print(childrenNEW);
|
||||||
|
//
|
||||||
|
//
|
||||||
private static void print(final List<? extends WorkspaceItem> children){
|
// System.out.println("\n\nDONE!");
|
||||||
int i=0;
|
// } catch (Exception e) {
|
||||||
System.out.println("\n\n");
|
// e.printStackTrace();
|
||||||
for (WorkspaceItem workspaceItem : children) {
|
// }
|
||||||
|
// }
|
||||||
if(workspaceItem.getType().equals(WorkspaceItemType.FOLDER) || workspaceItem.getType().equals(WorkspaceItemType.SHARED_FOLDER)){
|
//
|
||||||
|
//
|
||||||
WorkspaceFolder folder = (WorkspaceFolder) workspaceItem;
|
// private static void print(final List<? extends WorkspaceItem> children){
|
||||||
|
// int i=0;
|
||||||
try {
|
// System.out.println("\n\n");
|
||||||
System.err.println(++i+") folder id: "+folder.getId() +", folder name: "+folder.getName());
|
// for (WorkspaceItem workspaceItem : children) {
|
||||||
} catch (InternalErrorException e) {
|
//
|
||||||
// TODO Auto-generated catch block
|
// if(workspaceItem.getType().equals(WorkspaceItemType.FOLDER) || workspaceItem.getType().equals(WorkspaceItemType.SHARED_FOLDER)){
|
||||||
e.printStackTrace();
|
//
|
||||||
}
|
// WorkspaceFolder folder = (WorkspaceFolder) workspaceItem;
|
||||||
}else{
|
//
|
||||||
|
// try {
|
||||||
|
// System.err.println(++i+") folder id: "+folder.getId() +", folder name: "+folder.getName());
|
||||||
if(workspaceItem.getType().equals(WorkspaceItemType.FOLDER_ITEM)){
|
// } catch (InternalErrorException e) {
|
||||||
|
// // TODO Auto-generated catch block
|
||||||
FolderItem folderItem = (FolderItem) workspaceItem;
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
try {
|
// }else{
|
||||||
System.err.println(++i+") folderItem id: "+folderItem.getId() +", name: "+folderItem.getName() + ", size: "+folderItem.getLength());
|
//
|
||||||
} catch (InternalErrorException e) {
|
//
|
||||||
// TODO Auto-generated catch block
|
// if(workspaceItem.getType().equals(WorkspaceItemType.FOLDER_ITEM)){
|
||||||
e.printStackTrace();
|
//
|
||||||
}
|
// FolderItem folderItem = (FolderItem) workspaceItem;
|
||||||
}
|
//
|
||||||
|
// try {
|
||||||
}
|
// System.err.println(++i+") folderItem id: "+folderItem.getId() +", name: "+folderItem.getName() + ", size: "+folderItem.getLength());
|
||||||
}
|
// } catch (InternalErrorException e) {
|
||||||
|
// // TODO Auto-generated catch block
|
||||||
System.out.println("\n\n");
|
// e.printStackTrace();
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
private static List<? extends WorkspaceItem> getChildrenForID(String id){
|
//
|
||||||
|
// }
|
||||||
WorkspaceFolder folder;
|
// }
|
||||||
try {
|
//
|
||||||
System.out.println("start getItem on id "+id);
|
// System.out.println("\n\n");
|
||||||
folder = (WorkspaceFolder) ws.getItem(id);
|
// }
|
||||||
System.out.println("start get children on folder "+folder.getName());
|
//
|
||||||
final List<? extends WorkspaceItem> children = folder.getChildren();
|
// private static List<? extends WorkspaceItem> getChildrenForID(String id){
|
||||||
|
//
|
||||||
builder.buildGXTListFileGridModelItem(folder.getChildren(), null);
|
// WorkspaceFolder folder;
|
||||||
|
// try {
|
||||||
// builder.buildGXTFileGridModelItem(folder, null);
|
// System.out.println("start getItem on id "+id);
|
||||||
|
// folder = (WorkspaceFolder) ws.getItem(id);
|
||||||
System.out.println("children size: "+children.size());
|
// System.out.println("start get children on folder "+folder.getName());
|
||||||
return children;
|
// final List<? extends WorkspaceItem> children = folder.getChildren();
|
||||||
} catch (ItemNotFoundException | InternalErrorException e) {
|
//
|
||||||
// TODO Auto-generated catch block
|
// builder.buildGXTListFileGridModelItem(folder.getChildren(), null);
|
||||||
e.printStackTrace();
|
//
|
||||||
return null;
|
//// builder.buildGXTFileGridModelItem(folder, null);
|
||||||
}
|
//
|
||||||
}
|
// System.out.println("children size: "+children.size());
|
||||||
|
// return children;
|
||||||
private static List<String> getIdsForID(String id){
|
// } catch (ItemNotFoundException | InternalErrorException e) {
|
||||||
|
// // TODO Auto-generated catch block
|
||||||
|
// e.printStackTrace();
|
||||||
try {
|
// return null;
|
||||||
List<? extends WorkspaceItem> children = getChildrenForID(id);
|
// }
|
||||||
List<String> ids = new ArrayList<String>(children.size());
|
// }
|
||||||
for (WorkspaceItem workspaceItem : children) {
|
//
|
||||||
ids.add(workspaceItem.getId());
|
// private static List<String> getIdsForID(String id){
|
||||||
}
|
//
|
||||||
return ids;
|
//
|
||||||
} catch (InternalErrorException e) {
|
// try {
|
||||||
// TODO Auto-generated catch block
|
// List<? extends WorkspaceItem> children = getChildrenForID(id);
|
||||||
e.printStackTrace();
|
// List<String> ids = new ArrayList<String>(children.size());
|
||||||
return null;
|
// for (WorkspaceItem workspaceItem : children) {
|
||||||
}
|
// ids.add(workspaceItem.getId());
|
||||||
}
|
// }
|
||||||
|
// return ids;
|
||||||
private static List<String> getIdsOnlyFolderForID(String id){
|
// } catch (InternalErrorException e) {
|
||||||
|
// // TODO Auto-generated catch block
|
||||||
|
// e.printStackTrace();
|
||||||
try {
|
// return null;
|
||||||
List<? extends WorkspaceItem> children = getChildrenForID(id);
|
// }
|
||||||
List<String> ids = new ArrayList<String>(children.size());
|
// }
|
||||||
for (WorkspaceItem workspaceItem : children) {
|
//
|
||||||
if(workspaceItem.isFolder())
|
// private static List<String> getIdsOnlyFolderForID(String id){
|
||||||
ids.add(workspaceItem.getId());
|
//
|
||||||
}
|
//
|
||||||
return ids;
|
// try {
|
||||||
} catch (InternalErrorException e) {
|
// List<? extends WorkspaceItem> children = getChildrenForID(id);
|
||||||
// TODO Auto-generated catch block
|
// List<String> ids = new ArrayList<String>(children.size());
|
||||||
e.printStackTrace();
|
// for (WorkspaceItem workspaceItem : children) {
|
||||||
return null;
|
// if(workspaceItem.isFolder())
|
||||||
}
|
// ids.add(workspaceItem.getId());
|
||||||
}
|
// }
|
||||||
|
// return ids;
|
||||||
|
// } catch (InternalErrorException e) {
|
||||||
|
// // TODO Auto-generated catch block
|
||||||
private static void removeRange(List<String> children, int start, int end) {
|
// e.printStackTrace();
|
||||||
|
// return null;
|
||||||
System.out.println("start "+start);
|
// }
|
||||||
System.out.println("end "+end);
|
// }
|
||||||
// System.out.println("(end - start)"+(end - start));
|
//
|
||||||
|
//
|
||||||
List<String> sub = children.subList(start, end);
|
//
|
||||||
String[] array = new String[sub.size()];
|
// private static void removeRange(List<String> children, int start, int end) {
|
||||||
array = sub.toArray(array);
|
//
|
||||||
|
// System.out.println("start "+start);
|
||||||
System.out.println("array lenght: "+array.length);
|
// System.out.println("end "+end);
|
||||||
|
//// System.out.println("(end - start)"+(end - start));
|
||||||
for (String id : array)
|
//
|
||||||
System.out.println("Removing "+id);
|
// List<String> sub = children.subList(start, end);
|
||||||
|
// String[] array = new String[sub.size()];
|
||||||
try {
|
// array = sub.toArray(array);
|
||||||
ws.removeItems(array);
|
//
|
||||||
|
// System.out.println("array lenght: "+array.length);
|
||||||
System.out.println("Remove OK ");
|
//
|
||||||
} catch (ItemNotFoundException e) {
|
// for (String id : array)
|
||||||
// TODO Auto-generated catch block
|
// System.out.println("Removing "+id);
|
||||||
e.printStackTrace();
|
//
|
||||||
} catch (InsufficientPrivilegesException e) {
|
// try {
|
||||||
// TODO Auto-generated catch block
|
// ws.removeItems(array);
|
||||||
e.printStackTrace();
|
//
|
||||||
} catch (InternalErrorException e) {
|
// System.out.println("Remove OK ");
|
||||||
// TODO Auto-generated catch block
|
// } catch (ItemNotFoundException e) {
|
||||||
e.printStackTrace();
|
// // TODO Auto-generated catch block
|
||||||
}
|
// e.printStackTrace();
|
||||||
}
|
// } catch (InsufficientPrivilegesException e) {
|
||||||
|
// // TODO Auto-generated catch block
|
||||||
}
|
// e.printStackTrace();
|
||||||
|
// } catch (InternalErrorException e) {
|
||||||
|
// // TODO Auto-generated catch block
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//*/
|
||||||
|
|
|
@ -1,199 +1,209 @@
|
||||||
/**
|
////TODO IT MUST BE MOVED TO SHUB
|
||||||
*
|
///**
|
||||||
*/
|
// *
|
||||||
package org.gcube.portlets.user.workspace;
|
// */
|
||||||
|
//package org.gcube.portlets.user.workspace;
|
||||||
import java.io.BufferedWriter;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.OutputStreamWriter;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.gcube.common.homelibary.model.items.type.FolderItemType;
|
|
||||||
import org.gcube.common.homelibary.model.items.type.WorkspaceItemType;
|
|
||||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
|
||||||
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalFile;
|
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
|
||||||
import org.gcube.common.scope.impl.ScopeBean;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
|
||||||
* @Dec 17, 2013
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class DephtVisitDonwloadFilesTester {
|
|
||||||
|
|
||||||
|
|
||||||
protected static Logger logger = Logger.getLogger(SearchTextTest.class);
|
|
||||||
// public static String DEFAULT_SCOPE = "/d4science.research-infrastructures.eu/gCubeApps/EcologicalModelling"; //PRODUCTION
|
|
||||||
public static String DEFAULT_SCOPE = "/gcube/devsec"; //DEV
|
|
||||||
|
|
||||||
public static String USER = "francesco.mangiacrapa"; //PRODUCTION
|
|
||||||
|
|
||||||
private static BufferedWriter writer;
|
|
||||||
private static OutputStreamWriter out;
|
|
||||||
|
|
||||||
static final String itemID = "165ba18a-a08a-42c6-ade5-9b93d1f844ac";
|
|
||||||
static WorkspaceItem root;
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
ScopeBean scope = new ScopeBean(DEFAULT_SCOPE);
|
|
||||||
ScopeProvider.instance.set(scope.toString());
|
|
||||||
|
|
||||||
Workspace ws = HomeLibrary.getHomeManagerFactory().getHomeManager().getHome(USER).getWorkspace();
|
|
||||||
out = new OutputStreamWriter(new FileOutputStream("Csv-error-file.csv"), "UTF-8");
|
|
||||||
writer = new BufferedWriter(out);
|
|
||||||
|
|
||||||
writer.write("Id;Name;Path;Parent");
|
|
||||||
|
|
||||||
|
|
||||||
System.out.println("Start");
|
|
||||||
// WorkspaceItem root = ws.getRoot();
|
|
||||||
|
|
||||||
root = ws.getItem(itemID);
|
|
||||||
|
|
||||||
depthVisit(root);
|
|
||||||
|
|
||||||
// new Thread(){
|
|
||||||
// public void run() {
|
|
||||||
// try {
|
|
||||||
//
|
|
||||||
// depthVisit(root);
|
|
||||||
//
|
|
||||||
// } catch (InternalErrorException e) {
|
|
||||||
// // TODO Auto-generated catch block
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
//
|
|
||||||
// }.start();
|
|
||||||
|
|
||||||
System.out.println("waiting 10 sec..");
|
|
||||||
Thread.sleep(10000);
|
|
||||||
|
|
||||||
|
|
||||||
System.out.println("End");
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}finally{
|
|
||||||
System.out.println("writer close");
|
|
||||||
try {writer.close();} catch (Exception ex) {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void depthVisit(WorkspaceItem item) throws InternalErrorException {
|
|
||||||
|
|
||||||
if (item.getType().equals(WorkspaceItemType.FOLDER) || item.getType().equals(WorkspaceItemType.SHARED_FOLDER)) {
|
|
||||||
|
|
||||||
WorkspaceFolder folder = (WorkspaceFolder) item;
|
|
||||||
System.out.println("\nVisit Folder: " + folder.getName() +"; Folder is shared: "+folder.isShared());
|
|
||||||
List<? extends WorkspaceItem> children = folder.getChildren();
|
|
||||||
|
|
||||||
for (WorkspaceItem workspaceItem : children) {
|
|
||||||
depthVisit(workspaceItem);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
|
|
||||||
System.out.println("Item name: " + item.getName() +"; Parent Folder: "+item.getParent().getName());
|
|
||||||
|
|
||||||
if(item.getType().equals(WorkspaceItemType.FOLDER_ITEM)){
|
|
||||||
|
|
||||||
FolderItem folderItem = (FolderItem) item;
|
|
||||||
|
|
||||||
if(folderItem.getFolderItemType().equals(FolderItemType.EXTERNAL_FILE)){
|
|
||||||
|
|
||||||
System.out.println("Item is external file: " + item.getName());
|
|
||||||
|
|
||||||
final ExternalFile f = (ExternalFile) folderItem;
|
|
||||||
|
|
||||||
try{
|
|
||||||
|
|
||||||
Thread t = new Thread(){
|
|
||||||
|
|
||||||
public void run() {
|
|
||||||
|
|
||||||
try {
|
|
||||||
tryGetPayload(f);
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
try {
|
|
||||||
System.out.println("Item name: "+f.getName() + "not exists into storage");
|
|
||||||
erroFile(f);
|
|
||||||
} catch (InternalErrorException e1) {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
t.start();
|
|
||||||
|
|
||||||
// System.out.println("join 3 sec");
|
|
||||||
// t.join(1000);
|
|
||||||
//
|
//
|
||||||
// System.out.println("join 1 sec terminated");
|
//import java.io.BufferedWriter;
|
||||||
// if(is==null)
|
//import java.io.FileOutputStream;
|
||||||
// throw new Exception("is is null");
|
//import java.io.IOException;
|
||||||
|
//import java.io.InputStream;
|
||||||
}catch (Exception e) {
|
//import java.io.OutputStreamWriter;
|
||||||
System.out.println("Item name: "+f.getName() + "not exists into storage");
|
//import java.util.List;
|
||||||
erroFile(f);
|
//
|
||||||
}
|
//import org.apache.log4j.Logger;
|
||||||
|
//import org.gcube.common.homelibary.model.items.type.FolderItemType;
|
||||||
}
|
//import org.gcube.common.homelibary.model.items.type.WorkspaceItemType;
|
||||||
}
|
//import org.gcube.common.homelibrary.home.HomeLibrary;
|
||||||
|
//import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
||||||
}
|
//import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||||
}
|
//import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
||||||
|
//import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
||||||
public static void tryGetPayload(ExternalFile f) throws Exception{
|
//import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
|
||||||
|
//import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalFile;
|
||||||
try {
|
//import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
//import org.gcube.common.scope.impl.ScopeBean;
|
||||||
InputStream is = f.getData();
|
//
|
||||||
System.out.println("Get payload for file : "+f.getName() +" terminated");
|
///**
|
||||||
|
// * @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
||||||
if(is==null)
|
// * @Dec 17, 2013
|
||||||
throw new Exception("is is null");
|
// *
|
||||||
|
// */
|
||||||
} catch (InternalErrorException e1) {
|
///*
|
||||||
System.out.println("Error on :"+f.getName());
|
// *
|
||||||
throw new Exception("is is null");
|
// *
|
||||||
}
|
// * IT MUST BE MOVED TO SHUB
|
||||||
|
// *
|
||||||
}
|
// *
|
||||||
|
// *
|
||||||
public synchronized static void erroFile(WorkspaceItem item) throws InternalErrorException{
|
//public class DephtVisitDonwloadFilesTester {
|
||||||
|
//
|
||||||
try{
|
//
|
||||||
|
// protected static Logger logger = Logger.getLogger(SearchTextTest.class);
|
||||||
try {
|
//// public static String DEFAULT_SCOPE = "/d4science.research-infrastructures.eu/gCubeApps/EcologicalModelling"; //PRODUCTION
|
||||||
|
// public static String DEFAULT_SCOPE = "/gcube/devsec"; //DEV
|
||||||
String parentName="";
|
//
|
||||||
|
// public static String USER = "francesco.mangiacrapa"; //PRODUCTION
|
||||||
if(item.getParent()!=null)
|
//
|
||||||
parentName = item.getParent().getName();
|
// private static BufferedWriter writer;
|
||||||
|
// private static OutputStreamWriter out;
|
||||||
writer.write("\n "+item.getId()+";"+item.getName()+";"+item.getPath()+";"+parentName);
|
//
|
||||||
|
// static final String itemID = "165ba18a-a08a-42c6-ade5-9b93d1f844ac";
|
||||||
} catch (IOException ex) {
|
// static WorkspaceItem root;
|
||||||
ex.printStackTrace();
|
//
|
||||||
}
|
// public static void main(String[] args) {
|
||||||
|
//
|
||||||
|
// try {
|
||||||
} catch (Exception e) {
|
//
|
||||||
e.printStackTrace();
|
// ScopeBean scope = new ScopeBean(DEFAULT_SCOPE);
|
||||||
}
|
// ScopeProvider.instance.set(scope.toString());
|
||||||
}
|
//
|
||||||
|
// Workspace ws = HomeLibrary.getHomeManagerFactory().getHomeManager().getHome(USER).getWorkspace();
|
||||||
}
|
// out = new OutputStreamWriter(new FileOutputStream("Csv-error-file.csv"), "UTF-8");
|
||||||
|
// writer = new BufferedWriter(out);
|
||||||
|
//
|
||||||
|
// writer.write("Id;Name;Path;Parent");
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// System.out.println("Start");
|
||||||
|
//// WorkspaceItem root = ws.getRoot();
|
||||||
|
//
|
||||||
|
// root = ws.getItem(itemID);
|
||||||
|
//
|
||||||
|
// depthVisit(root);
|
||||||
|
//
|
||||||
|
//// new Thread(){
|
||||||
|
//// public void run() {
|
||||||
|
//// try {
|
||||||
|
////
|
||||||
|
//// depthVisit(root);
|
||||||
|
////
|
||||||
|
//// } catch (InternalErrorException e) {
|
||||||
|
//// // TODO Auto-generated catch block
|
||||||
|
//// e.printStackTrace();
|
||||||
|
//// }
|
||||||
|
//// };
|
||||||
|
////
|
||||||
|
//// }.start();
|
||||||
|
//
|
||||||
|
// System.out.println("waiting 10 sec..");
|
||||||
|
// Thread.sleep(10000);
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// System.out.println("End");
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }finally{
|
||||||
|
// System.out.println("writer close");
|
||||||
|
// try {writer.close();} catch (Exception ex) {}
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public static void depthVisit(WorkspaceItem item) throws InternalErrorException {
|
||||||
|
//
|
||||||
|
// if (item.getType().equals(WorkspaceItemType.FOLDER) || item.getType().equals(WorkspaceItemType.SHARED_FOLDER)) {
|
||||||
|
//
|
||||||
|
// WorkspaceFolder folder = (WorkspaceFolder) item;
|
||||||
|
// System.out.println("\nVisit Folder: " + folder.getName() +"; Folder is shared: "+folder.isShared());
|
||||||
|
// List<? extends WorkspaceItem> children = folder.getChildren();
|
||||||
|
//
|
||||||
|
// for (WorkspaceItem workspaceItem : children) {
|
||||||
|
// depthVisit(workspaceItem);
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
//
|
||||||
|
// System.out.println("Item name: " + item.getName() +"; Parent Folder: "+item.getParent().getName());
|
||||||
|
//
|
||||||
|
// if(item.getType().equals(WorkspaceItemType.FOLDER_ITEM)){
|
||||||
|
//
|
||||||
|
// FolderItem folderItem = (FolderItem) item;
|
||||||
|
//
|
||||||
|
// if(folderItem.getFolderItemType().equals(FolderItemType.EXTERNAL_FILE)){
|
||||||
|
//
|
||||||
|
// System.out.println("Item is external file: " + item.getName());
|
||||||
|
//
|
||||||
|
// final ExternalFile f = (ExternalFile) folderItem;
|
||||||
|
//
|
||||||
|
// try{
|
||||||
|
//
|
||||||
|
// Thread t = new Thread(){
|
||||||
|
//
|
||||||
|
// public void run() {
|
||||||
|
//
|
||||||
|
// try {
|
||||||
|
// tryGetPayload(f);
|
||||||
|
//
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// try {
|
||||||
|
// System.out.println("Item name: "+f.getName() + "not exists into storage");
|
||||||
|
// erroFile(f);
|
||||||
|
// } catch (InternalErrorException e1) {
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// t.start();
|
||||||
|
//
|
||||||
|
//// System.out.println("join 3 sec");
|
||||||
|
//// t.join(1000);
|
||||||
|
////
|
||||||
|
//// System.out.println("join 1 sec terminated");
|
||||||
|
//// if(is==null)
|
||||||
|
//// throw new Exception("is is null");
|
||||||
|
//
|
||||||
|
// }catch (Exception e) {
|
||||||
|
// System.out.println("Item name: "+f.getName() + "not exists into storage");
|
||||||
|
// erroFile(f);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public static void tryGetPayload(ExternalFile f) throws Exception{
|
||||||
|
//
|
||||||
|
// try {
|
||||||
|
//
|
||||||
|
// InputStream is = f.getData();
|
||||||
|
// System.out.println("Get payload for file : "+f.getName() +" terminated");
|
||||||
|
//
|
||||||
|
// if(is==null)
|
||||||
|
// throw new Exception("is is null");
|
||||||
|
//
|
||||||
|
// } catch (InternalErrorException e1) {
|
||||||
|
// System.out.println("Error on :"+f.getName());
|
||||||
|
// throw new Exception("is is null");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public synchronized static void erroFile(WorkspaceItem item) throws InternalErrorException{
|
||||||
|
//
|
||||||
|
// try{
|
||||||
|
//
|
||||||
|
// try {
|
||||||
|
//
|
||||||
|
// String parentName="";
|
||||||
|
//
|
||||||
|
// if(item.getParent()!=null)
|
||||||
|
// parentName = item.getParent().getName();
|
||||||
|
//
|
||||||
|
// writer.write("\n "+item.getId()+";"+item.getName()+";"+item.getPath()+";"+parentName);
|
||||||
|
//
|
||||||
|
// } catch (IOException ex) {
|
||||||
|
// ex.printStackTrace();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//*/
|
||||||
|
|
|
@ -1,119 +1,121 @@
|
||||||
/**
|
//TODO IT MUST BE MOVED TO SHUB
|
||||||
*
|
///**
|
||||||
*/
|
|
||||||
package org.gcube.portlets.user.workspace;
|
|
||||||
|
|
||||||
import java.util.List;
|
// *
|
||||||
|
// */
|
||||||
import org.gcube.common.homelibary.model.items.type.FolderItemType;
|
//package org.gcube.portlets.user.workspace;
|
||||||
import org.gcube.common.homelibary.model.items.type.WorkspaceItemType;
|
|
||||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
|
||||||
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalFile;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
|
||||||
* Jun 18, 2013
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class DonwloadServletTest {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
|
|
||||||
// InputStream is = null;
|
|
||||||
//
|
//
|
||||||
// System.out.println("start");
|
//import java.util.List;
|
||||||
//
|
//
|
||||||
// is = GCUBEStorage.getRemoteFile("/Home/francesco.mangiacrapa/Workspace284ee688-e6fb-4080-bbcb-cc7c8cc5c381");
|
//import org.gcube.common.homelibary.model.items.type.FolderItemType;
|
||||||
|
//import org.gcube.common.homelibary.model.items.type.WorkspaceItemType;
|
||||||
try {
|
//import org.gcube.common.homelibrary.home.HomeLibrary;
|
||||||
|
//import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
||||||
Workspace ws = HomeLibrary
|
//import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||||
.getHomeManagerFactory()
|
//import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
||||||
.getHomeManager()
|
//import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
||||||
.getHome("francesco.mangiacrapa")
|
//import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
|
||||||
.getWorkspace();
|
//import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalFile;
|
||||||
//
|
//
|
||||||
|
///**
|
||||||
WorkspaceItem root = ws.getRoot();
|
// * @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
||||||
|
// * Jun 18, 2013
|
||||||
List<? extends WorkspaceItem> children = root.getChildren();
|
// *
|
||||||
|
// */
|
||||||
|
//public class DonwloadServletTest {
|
||||||
for (WorkspaceItem workspaceItem : children) {
|
//
|
||||||
|
// public static void main(String[] args) {
|
||||||
if(workspaceItem.getType().equals(WorkspaceItemType.FOLDER_ITEM)){
|
//
|
||||||
|
//// InputStream is = null;
|
||||||
FolderItem folderItem = (FolderItem) workspaceItem;
|
////
|
||||||
|
//// System.out.println("start");
|
||||||
if(folderItem.getFolderItemType().equals(FolderItemType.EXTERNAL_FILE)){
|
////
|
||||||
|
//// is = GCUBEStorage.getRemoteFile("/Home/francesco.mangiacrapa/Workspace284ee688-e6fb-4080-bbcb-cc7c8cc5c381");
|
||||||
ExternalFile f = (ExternalFile) folderItem;
|
//
|
||||||
|
// try {
|
||||||
System.out.println("folderItem name: "+f.getName() + ", public link: "+f.getPublicLink());
|
//
|
||||||
}
|
// Workspace ws = HomeLibrary
|
||||||
|
// .getHomeManagerFactory()
|
||||||
}
|
// .getHomeManager()
|
||||||
|
// .getHome("francesco.mangiacrapa")
|
||||||
|
// .getWorkspace();
|
||||||
}
|
// //
|
||||||
|
//
|
||||||
|
// WorkspaceItem root = ws.getRoot();
|
||||||
// WorkspaceItem item = ws.getItem("8ad4e104-0f34-413e-a88c-e754a81104e7");
|
//
|
||||||
|
// List<? extends WorkspaceItem> children = root.getChildren();
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// ExternalFile f = (ExternalFile) item;
|
// for (WorkspaceItem workspaceItem : children) {
|
||||||
|
//
|
||||||
|
// if(workspaceItem.getType().equals(WorkspaceItemType.FOLDER_ITEM)){
|
||||||
|
//
|
||||||
|
// FolderItem folderItem = (FolderItem) workspaceItem;
|
||||||
|
//
|
||||||
|
// if(folderItem.getFolderItemType().equals(FolderItemType.EXTERNAL_FILE)){
|
||||||
|
//
|
||||||
|
// ExternalFile f = (ExternalFile) folderItem;
|
||||||
|
//
|
||||||
|
// System.out.println("folderItem name: "+f.getName() + ", public link: "+f.getPublicLink());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// System.out.println("Public link: "+f.getPublicLink());
|
// }
|
||||||
// FileOutputStream out = new FileOutputStream(new File("/tmp/bla"));
|
|
||||||
// // byte[] buffer = new byte[1024];
|
|
||||||
// // int len;
|
|
||||||
// // while ((len = is.read(buffer)) != -1) {
|
|
||||||
// // out.write(buffer, 0, len);
|
|
||||||
// // }
|
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
// is = f.getData();
|
|
||||||
|
|
||||||
|
|
||||||
// IOUtils.copy(is, out);
|
|
||||||
// is.close();
|
|
||||||
//
|
//
|
||||||
// out.close();
|
//// WorkspaceItem item = ws.getItem("8ad4e104-0f34-413e-a88c-e754a81104e7");
|
||||||
|
////
|
||||||
// System.out.println("Sleeping");
|
////
|
||||||
// Thread.sleep(20000);
|
//// ExternalFile f = (ExternalFile) item;
|
||||||
// System.out.println("Alive");
|
////
|
||||||
|
////
|
||||||
System.out.println("end");
|
//// System.out.println("Public link: "+f.getPublicLink());
|
||||||
} catch (Exception e) {
|
//// FileOutputStream out = new FileOutputStream(new File("/tmp/bla"));
|
||||||
e.printStackTrace();
|
//// // byte[] buffer = new byte[1024];
|
||||||
}
|
//// // int len;
|
||||||
}
|
//// // while ((len = is.read(buffer)) != -1) {
|
||||||
|
//// // out.write(buffer, 0, len);
|
||||||
public void depthVisit(WorkspaceItem item) throws InternalErrorException{
|
//// // }
|
||||||
|
////
|
||||||
|
//
|
||||||
if(item.getType().equals(WorkspaceItemType.FOLDER_ITEM)){
|
//
|
||||||
|
//// is = f.getData();
|
||||||
WorkspaceFolder folder = (WorkspaceFolder) item;
|
//
|
||||||
System.out.println("Visit Folder: "+folder.getName());
|
//
|
||||||
List<? extends WorkspaceItem> children = folder.getChildren();
|
//// IOUtils.copy(is, out);
|
||||||
|
//// is.close();
|
||||||
for (WorkspaceItem workspaceItem : children) {
|
////
|
||||||
depthVisit(workspaceItem);
|
//// out.close();
|
||||||
}
|
//
|
||||||
}else{
|
// // System.out.println("Sleeping");
|
||||||
|
// // Thread.sleep(20000);
|
||||||
System.out.println("Item name: "+item.getName());
|
// // System.out.println("Alive");
|
||||||
|
//
|
||||||
}
|
// System.out.println("end");
|
||||||
}
|
// } catch (Exception e) {
|
||||||
|
// e.printStackTrace();
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public void depthVisit(WorkspaceItem item) throws InternalErrorException{
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// if(item.getType().equals(WorkspaceItemType.FOLDER_ITEM)){
|
||||||
|
//
|
||||||
|
// WorkspaceFolder folder = (WorkspaceFolder) item;
|
||||||
|
// System.out.println("Visit Folder: "+folder.getName());
|
||||||
|
// List<? extends WorkspaceItem> children = folder.getChildren();
|
||||||
|
//
|
||||||
|
// for (WorkspaceItem workspaceItem : children) {
|
||||||
|
// depthVisit(workspaceItem);
|
||||||
|
// }
|
||||||
|
// }else{
|
||||||
|
//
|
||||||
|
// System.out.println("Item name: "+item.getName());
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
|
|
@ -1,53 +1,54 @@
|
||||||
/**
|
////TODO IT MUST BE MOVED TO SHUB
|
||||||
*
|
///**
|
||||||
*/
|
// *
|
||||||
package org.gcube.portlets.user.workspace;
|
// */
|
||||||
|
//package org.gcube.portlets.user.workspace;
|
||||||
import org.apache.log4j.Logger;
|
//
|
||||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
//import org.apache.log4j.Logger;
|
||||||
import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
|
//import org.gcube.common.homelibrary.home.HomeLibrary;
|
||||||
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
//import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
|
||||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
//import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
||||||
import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
|
//import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||||
import org.gcube.common.homelibrary.home.workspace.folder.items.GCubeItem;
|
//import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
//import org.gcube.common.homelibrary.home.workspace.folder.items.GCubeItem;
|
||||||
import org.gcube.common.scope.impl.ScopeBean;
|
//import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
//import org.gcube.common.scope.impl.ScopeBean;
|
||||||
/**
|
//
|
||||||
*
|
///**
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
// *
|
||||||
* Jun 12, 2015
|
// * @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
||||||
*/
|
// * Jun 12, 2015
|
||||||
public class GcubeProperties {
|
// */
|
||||||
public static Logger logger = Logger.getLogger(GcubeProperties.class);
|
//public class GcubeProperties {
|
||||||
public static String DEFAULT_SCOPE = "/gcube/devsec"; //DEV
|
// public static Logger logger = Logger.getLogger(GcubeProperties.class);
|
||||||
public static String TEST_USER = "francesco.mangiacrapa";
|
// public static String DEFAULT_SCOPE = "/gcube/devsec"; //DEV
|
||||||
|
// public static String TEST_USER = "francesco.mangiacrapa";
|
||||||
public static void main(String[] args) {
|
//
|
||||||
|
// public static void main(String[] args) {
|
||||||
try{
|
//
|
||||||
ScopeBean scope = new ScopeBean(DEFAULT_SCOPE);
|
// try{
|
||||||
ScopeProvider.instance.set(scope.toString());
|
// ScopeBean scope = new ScopeBean(DEFAULT_SCOPE);
|
||||||
Workspace ws = getWorkspace();
|
// ScopeProvider.instance.set(scope.toString());
|
||||||
GCubeItem item = (GCubeItem) ws.getItem("7d5fd78a-6543-4d20-b6e7-9ae490fa1ad8");
|
// Workspace ws = getWorkspace();
|
||||||
// Properties props = item.getProperties();
|
// GCubeItem item = (GCubeItem) ws.getItem("7d5fd78a-6543-4d20-b6e7-9ae490fa1ad8");
|
||||||
// item.getProperties().addProperty("key06", "value0006");
|
// // Properties props = item.getProperties();
|
||||||
// item.getProperties().addProperty("key05", "value0005");
|
//// item.getProperties().addProperty("key06", "value0006");
|
||||||
// item.getProperties().update();
|
//// item.getProperties().addProperty("key05", "value0005");
|
||||||
|
//// item.getProperties().update();
|
||||||
|
////
|
||||||
|
//
|
||||||
|
// System.out.println(item.getProperties().getProperties());
|
||||||
//
|
//
|
||||||
|
// }catch (Exception e) {
|
||||||
System.out.println(item.getProperties().getProperties());
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
}catch (Exception e) {
|
// }
|
||||||
e.printStackTrace();
|
//
|
||||||
}
|
// public static Workspace getWorkspace() throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException{
|
||||||
}
|
// logger.trace("Get Workspace scope: "+DEFAULT_SCOPE + " username: "+TEST_USER);
|
||||||
|
// ScopeProvider.instance.set(DEFAULT_SCOPE);
|
||||||
public static Workspace getWorkspace() throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException{
|
// logger.trace("Scope provider instancied");
|
||||||
logger.trace("Get Workspace scope: "+DEFAULT_SCOPE + " username: "+TEST_USER);
|
// Workspace workspace = HomeLibrary.getUserWorkspace(TEST_USER);
|
||||||
ScopeProvider.instance.set(DEFAULT_SCOPE);
|
// return workspace;
|
||||||
logger.trace("Scope provider instancied");
|
// }
|
||||||
Workspace workspace = HomeLibrary.getUserWorkspace(TEST_USER);
|
//}
|
||||||
return workspace;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,242 +1,243 @@
|
||||||
/**
|
//TODO IT MUST BE MOVED TO SHUB
|
||||||
*
|
///**
|
||||||
*/
|
// *
|
||||||
package org.gcube.portlets.user.workspace;
|
// */
|
||||||
|
//package org.gcube.portlets.user.workspace;
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
|
||||||
import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
|
|
||||||
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
|
||||||
import org.gcube.common.homelibrary.home.exceptions.UserNotFoundException;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceSharedFolder;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.exceptions.ItemNotFoundException;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
|
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
|
||||||
import org.gcube.common.scope.impl.ScopeBean;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
|
||||||
* Jan 29, 2014
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class ItemCreate {
|
|
||||||
|
|
||||||
|
|
||||||
// public static String DEFAULT_SCOPE = "/d4science.research-infrastructures.eu/gCubeApps"; //PRODUCTION
|
|
||||||
public static String DEFAULT_SCOPE = "/gcube/devsec"; //DEV
|
|
||||||
public static String TEST_USER = "costantino.perciante";
|
|
||||||
// public static String ITEMID = "63832213-098d-42d1-8774-89b6349764c0"; //Activity T3.4 working drafts/T2-EC-IMAR-HO-14-015 iMarine Sustainability WP - Business Model tools.pdf
|
|
||||||
public static String ITEMID = "ce4866ee-8079-4acf-bcd6-1c9dd786eb73";
|
|
||||||
// d81d3a64-603f-4907-ae74-be8353211807
|
|
||||||
protected static Logger logger = Logger.getLogger(ItemCreate.class);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
|
|
||||||
ScopeBean scope = new ScopeBean(DEFAULT_SCOPE);
|
|
||||||
ScopeProvider.instance.set(scope.toString());
|
|
||||||
|
|
||||||
System.out.println("init HL");
|
|
||||||
try {
|
|
||||||
Workspace ws = getWorkspace();
|
|
||||||
|
|
||||||
String rootId = ws.getRoot().getId();
|
|
||||||
System.out.println("Root ID: "+rootId);
|
|
||||||
|
|
||||||
//[]/\
|
|
||||||
|
|
||||||
//CREATO ^<>?*%$:*$
|
|
||||||
// //String folderNameSpecialChars = "[^.]<>|?*%$:*$\\/";
|
|
||||||
String folderNameSpecialChars = "‘";
|
|
||||||
|
|
||||||
|
|
||||||
WorkspaceFolder folder = null;
|
|
||||||
String folderName = null;
|
|
||||||
for (int i = 1; i < folderNameSpecialChars.length(); i++) {
|
|
||||||
folderName = folderNameSpecialChars.substring(0,i);
|
|
||||||
try{
|
|
||||||
folder = ws.createFolder(folderName, "", rootId);
|
|
||||||
System.out.println("Created folder: "+folder.getName() +" with id: "+folder.getId());
|
|
||||||
}catch(Exception e){
|
|
||||||
System.err.println("Folder with name: "+folderName +" not created");
|
|
||||||
e.printStackTrace();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try{
|
|
||||||
if (folder!=null){
|
|
||||||
ws.renameItem(folder.getId(), folder.getName()+"_renamed");
|
|
||||||
System.out.println("Renamed folder: "+folder.getName() +" with id: "+folder.getId());
|
|
||||||
}
|
|
||||||
}catch (Exception e) {
|
|
||||||
System.err.println("Folder with name: "+folderName +" not renamed");
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
try{
|
|
||||||
if (folder!=null){
|
|
||||||
ws.removeItem(folder.getId());
|
|
||||||
System.out.println("Removed folder: "+folder.getName() +" with id: "+folder.getId());
|
|
||||||
try{
|
|
||||||
ws.getItem(folder.getId());
|
|
||||||
}catch(ItemNotFoundException e){
|
|
||||||
System.out.println("Folder Id folder: "+folder.getId() +" removed correctly");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}catch (Exception e) {
|
|
||||||
System.err.println("Folder with name: "+folderName +" not removed");
|
|
||||||
e.printStackTrace();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
retrieveFirstLevel(ws, null);
|
|
||||||
//
|
//
|
||||||
// retrieveFirstLevel(ws, ITEMID);
|
//import java.util.List;
|
||||||
|
//import java.util.concurrent.TimeUnit;
|
||||||
//
|
//
|
||||||
// System.out.println("get workspace -> OK");
|
//import org.apache.log4j.Logger;
|
||||||
//WorkspaceItem item = ws.getItem(ITEMID);
|
//import org.gcube.common.homelibrary.home.HomeLibrary;
|
||||||
//System.out.println("get item id: "+item.getId()+", name: "+item.getName() +", parent: "+item.getParent().getId() +", parent name: "+item.getParent().getName()+", path :"+item.getPath());
|
//import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
|
||||||
//System.out.println(item);
|
//import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
||||||
}catch(Exception e){
|
//import org.gcube.common.homelibrary.home.exceptions.UserNotFoundException;
|
||||||
e.printStackTrace();
|
//import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||||
}
|
//import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
||||||
|
//import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
||||||
// } catch (WorkspaceFolderNotFoundException e) {
|
//import org.gcube.common.homelibrary.home.workspace.WorkspaceSharedFolder;
|
||||||
// // TODO Auto-generated catch block
|
//import org.gcube.common.homelibrary.home.workspace.exceptions.ItemNotFoundException;
|
||||||
// e.printStackTrace();
|
//import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
|
||||||
// } catch (InternalErrorException e) {
|
//import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
|
||||||
// // TODO Auto-generated catch block
|
//import org.gcube.common.scope.api.ScopeProvider;
|
||||||
// e.printStackTrace();
|
//import org.gcube.common.scope.impl.ScopeBean;
|
||||||
// } catch (HomeNotFoundException e) {
|
//
|
||||||
// // TODO Auto-generated catch block
|
///**
|
||||||
// e.printStackTrace();
|
// *
|
||||||
// } catch (UserNotFoundException e) {
|
// * @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
||||||
// // TODO Auto-generated catch block
|
// * Jan 29, 2014
|
||||||
|
// *
|
||||||
|
// */
|
||||||
|
//public class ItemCreate {
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//// public static String DEFAULT_SCOPE = "/d4science.research-infrastructures.eu/gCubeApps"; //PRODUCTION
|
||||||
|
// public static String DEFAULT_SCOPE = "/gcube/devsec"; //DEV
|
||||||
|
// public static String TEST_USER = "costantino.perciante";
|
||||||
|
//// public static String ITEMID = "63832213-098d-42d1-8774-89b6349764c0"; //Activity T3.4 working drafts/T2-EC-IMAR-HO-14-015 iMarine Sustainability WP - Business Model tools.pdf
|
||||||
|
// public static String ITEMID = "ce4866ee-8079-4acf-bcd6-1c9dd786eb73";
|
||||||
|
//// d81d3a64-603f-4907-ae74-be8353211807
|
||||||
|
// protected static Logger logger = Logger.getLogger(ItemCreate.class);
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// public static void main(String[] args) {
|
||||||
|
//
|
||||||
|
// ScopeBean scope = new ScopeBean(DEFAULT_SCOPE);
|
||||||
|
// ScopeProvider.instance.set(scope.toString());
|
||||||
|
//
|
||||||
|
// System.out.println("init HL");
|
||||||
|
// try {
|
||||||
|
// Workspace ws = getWorkspace();
|
||||||
|
//
|
||||||
|
// String rootId = ws.getRoot().getId();
|
||||||
|
// System.out.println("Root ID: "+rootId);
|
||||||
|
//
|
||||||
|
// //[]/\
|
||||||
|
//
|
||||||
|
// //CREATO ^<>?*%$:*$
|
||||||
|
//// //String folderNameSpecialChars = "[^.]<>|?*%$:*$\\/";
|
||||||
|
// String folderNameSpecialChars = "‘";
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// WorkspaceFolder folder = null;
|
||||||
|
// String folderName = null;
|
||||||
|
// for (int i = 1; i < folderNameSpecialChars.length(); i++) {
|
||||||
|
// folderName = folderNameSpecialChars.substring(0,i);
|
||||||
|
// try{
|
||||||
|
// folder = ws.createFolder(folderName, "", rootId);
|
||||||
|
// System.out.println("Created folder: "+folder.getName() +" with id: "+folder.getId());
|
||||||
|
// }catch(Exception e){
|
||||||
|
// System.err.println("Folder with name: "+folderName +" not created");
|
||||||
|
// e.printStackTrace();
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// try{
|
||||||
|
// if (folder!=null){
|
||||||
|
// ws.renameItem(folder.getId(), folder.getName()+"_renamed");
|
||||||
|
// System.out.println("Renamed folder: "+folder.getName() +" with id: "+folder.getId());
|
||||||
|
// }
|
||||||
|
// }catch (Exception e) {
|
||||||
|
// System.err.println("Folder with name: "+folderName +" not renamed");
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// try{
|
||||||
|
// if (folder!=null){
|
||||||
|
// ws.removeItem(folder.getId());
|
||||||
|
// System.out.println("Removed folder: "+folder.getName() +" with id: "+folder.getId());
|
||||||
|
// try{
|
||||||
|
// ws.getItem(folder.getId());
|
||||||
|
// }catch(ItemNotFoundException e){
|
||||||
|
// System.out.println("Folder Id folder: "+folder.getId() +" removed correctly");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// }catch (Exception e) {
|
||||||
|
// System.err.println("Folder with name: "+folderName +" not removed");
|
||||||
|
// e.printStackTrace();
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// retrieveFirstLevel(ws, null);
|
||||||
|
////
|
||||||
|
//// retrieveFirstLevel(ws, ITEMID);
|
||||||
|
////
|
||||||
|
//// System.out.println("get workspace -> OK");
|
||||||
|
// //WorkspaceItem item = ws.getItem(ITEMID);
|
||||||
|
// //System.out.println("get item id: "+item.getId()+", name: "+item.getName() +", parent: "+item.getParent().getId() +", parent name: "+item.getParent().getName()+", path :"+item.getPath());
|
||||||
|
// //System.out.println(item);
|
||||||
|
// }catch(Exception e){
|
||||||
// e.printStackTrace();
|
// e.printStackTrace();
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
}
|
//// } catch (WorkspaceFolderNotFoundException e) {
|
||||||
|
//// // TODO Auto-generated catch block
|
||||||
public static Workspace getWorkspace() throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException, UserNotFoundException
|
//// e.printStackTrace();
|
||||||
{
|
//// } catch (InternalErrorException e) {
|
||||||
|
//// // TODO Auto-generated catch block
|
||||||
logger.trace("Get Workspace scope: "+DEFAULT_SCOPE + " username: "+TEST_USER);
|
//// e.printStackTrace();
|
||||||
ScopeProvider.instance.set(DEFAULT_SCOPE);
|
//// } catch (HomeNotFoundException e) {
|
||||||
logger.trace("Scope provider instancied");
|
//// // TODO Auto-generated catch block
|
||||||
|
//// e.printStackTrace();
|
||||||
// return HomeLibrary.getUserWorkspace(TEST_USER);
|
//// } catch (UserNotFoundException e) {
|
||||||
return HomeLibrary.getHomeManagerFactory().getHomeManager().getHome(TEST_USER).getWorkspace();
|
//// // TODO Auto-generated catch block
|
||||||
}
|
//// e.printStackTrace();
|
||||||
|
//// }
|
||||||
|
////
|
||||||
private static void retrieveFirstLevel(Workspace ws, String foundFolder){
|
// }
|
||||||
|
//
|
||||||
try {
|
// public static Workspace getWorkspace() throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException, UserNotFoundException
|
||||||
|
// {
|
||||||
//TEST TIME
|
//
|
||||||
Long startTime = System.currentTimeMillis();
|
// logger.trace("Get Workspace scope: "+DEFAULT_SCOPE + " username: "+TEST_USER);
|
||||||
Long endTime = System.currentTimeMillis() - startTime;
|
// ScopeProvider.instance.set(DEFAULT_SCOPE);
|
||||||
String time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime));
|
// logger.trace("Scope provider instancied");
|
||||||
|
//
|
||||||
startTime = System.currentTimeMillis();
|
//// return HomeLibrary.getUserWorkspace(TEST_USER);
|
||||||
System.out.println("Start foundFolder at time: "+startTime);
|
// return HomeLibrary.getHomeManagerFactory().getHomeManager().getHome(TEST_USER).getWorkspace();
|
||||||
// WorkspaceItem root = ws.getItem(ITEMID);
|
// }
|
||||||
WorkspaceItem fd;
|
//
|
||||||
if(foundFolder!=null){
|
//
|
||||||
fd = ws.getItem(foundFolder);
|
// private static void retrieveFirstLevel(Workspace ws, String foundFolder){
|
||||||
System.out.println("foundFolder id: "+foundFolder);
|
//
|
||||||
System.out.println("start get children");
|
// try {
|
||||||
}else
|
//
|
||||||
fd = ws.getRoot();
|
// //TEST TIME
|
||||||
|
// Long startTime = System.currentTimeMillis();
|
||||||
List<? extends WorkspaceItem> children = fd.getChildren();
|
// Long endTime = System.currentTimeMillis() - startTime;
|
||||||
System.out.println("tree getChildren() returning "+children.size()+" elements in " + time);
|
// String time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime));
|
||||||
|
//
|
||||||
System.out.println("children size: "+children.size());
|
// startTime = System.currentTimeMillis();
|
||||||
|
// System.out.println("Start foundFolder at time: "+startTime);
|
||||||
int i=0;
|
//// WorkspaceItem root = ws.getItem(ITEMID);
|
||||||
int foldersCounter = 0;
|
// WorkspaceItem fd;
|
||||||
int sharedFoldersCounter = 0;
|
// if(foundFolder!=null){
|
||||||
int folderItemCounter = 0;
|
// fd = ws.getItem(foundFolder);
|
||||||
int othersCounter = 0;
|
// System.out.println("foundFolder id: "+foundFolder);
|
||||||
for (WorkspaceItem workspaceItem : children) {
|
// System.out.println("start get children");
|
||||||
try{
|
// }else
|
||||||
|
// fd = ws.getRoot();
|
||||||
/*if(foundFolder!=null && !foundFolder.isEmpty()){
|
//
|
||||||
if(workspaceItem.getId().compareTo(foundFolder)==0){
|
// List<? extends WorkspaceItem> children = fd.getChildren();
|
||||||
System.out.println("ITEM FOUND id: "+workspaceItem.getId()+", name: "+workspaceItem.getName());
|
// System.out.println("tree getChildren() returning "+children.size()+" elements in " + time);
|
||||||
return;
|
//
|
||||||
}
|
// System.out.println("children size: "+children.size());
|
||||||
}*/
|
//
|
||||||
|
// int i=0;
|
||||||
switch (workspaceItem.getType()) {
|
// int foldersCounter = 0;
|
||||||
|
// int sharedFoldersCounter = 0;
|
||||||
case FOLDER:
|
// int folderItemCounter = 0;
|
||||||
|
// int othersCounter = 0;
|
||||||
WorkspaceFolder folder = (WorkspaceFolder) workspaceItem;
|
// for (WorkspaceItem workspaceItem : children) {
|
||||||
|
// try{
|
||||||
// System.out.println(++i+") "+folder.getId() +" folder name: "+folder.getName() + " owner "+folder.getOwner() +" path: "+folder.getPath());
|
//
|
||||||
System.out.println(++i+") "+folder.getId() +" folder name: "+folder.getName() + " owner "+folder.getOwner());
|
// /*if(foundFolder!=null && !foundFolder.isEmpty()){
|
||||||
foldersCounter++;
|
// if(workspaceItem.getId().compareTo(foundFolder)==0){
|
||||||
|
// System.out.println("ITEM FOUND id: "+workspaceItem.getId()+", name: "+workspaceItem.getName());
|
||||||
break;
|
// return;
|
||||||
|
// }
|
||||||
case SHARED_FOLDER:
|
// }*/
|
||||||
|
//
|
||||||
WorkspaceSharedFolder shared = (WorkspaceSharedFolder) workspaceItem;
|
// switch (workspaceItem.getType()) {
|
||||||
|
//
|
||||||
// System.out.println(++i+") "+shared.getId() +" shared folder name: "+shared.getName() + " owner "+shared.getOwner()+" isVRE "+shared.isVreFolder() +" ACLOwner: "+shared.getACLOwner()+" AclUser: "+shared.getACLUser() +" path: "+shared.getPath());
|
// case FOLDER:
|
||||||
System.out.println(++i+") "+shared.getId() +" shared folder name: "+shared.getName());
|
//
|
||||||
|
// WorkspaceFolder folder = (WorkspaceFolder) workspaceItem;
|
||||||
// System.out.println(++i+") shared folder name: "+shared.getName() + " owner "+shared.getOwner().getPortalLogin());
|
//
|
||||||
sharedFoldersCounter++;
|
//// System.out.println(++i+") "+folder.getId() +" folder name: "+folder.getName() + " owner "+folder.getOwner() +" path: "+folder.getPath());
|
||||||
|
// System.out.println(++i+") "+folder.getId() +" folder name: "+folder.getName() + " owner "+folder.getOwner());
|
||||||
break;
|
// foldersCounter++;
|
||||||
|
//
|
||||||
case FOLDER_ITEM:
|
// break;
|
||||||
|
//
|
||||||
FolderItem folderItem = (FolderItem) workspaceItem;
|
// case SHARED_FOLDER:
|
||||||
|
//
|
||||||
// System.out.println(++i+") folderItem id: "+folderItem.getId() +", name: "+folderItem.getName() + ", own: "+folderItem.getOwner() +" path: "+folderItem.getPath());
|
// WorkspaceSharedFolder shared = (WorkspaceSharedFolder) workspaceItem;
|
||||||
System.out.println(++i+") folderItem id: "+folderItem.getId() +", name: "+folderItem.getName() + ", own: "+folderItem.getOwner());
|
//
|
||||||
folderItemCounter++;
|
//// System.out.println(++i+") "+shared.getId() +" shared folder name: "+shared.getName() + " owner "+shared.getOwner()+" isVRE "+shared.isVreFolder() +" ACLOwner: "+shared.getACLOwner()+" AclUser: "+shared.getACLUser() +" path: "+shared.getPath());
|
||||||
|
// System.out.println(++i+") "+shared.getId() +" shared folder name: "+shared.getName());
|
||||||
break;
|
//
|
||||||
default:
|
// // System.out.println(++i+") shared folder name: "+shared.getName() + " owner "+shared.getOwner().getPortalLogin());
|
||||||
// System.out.println(++i+") DEFAULT - item id: "+workspaceItem.getId() +", name: "+workspaceItem.getName() + ", own: "+workspaceItem.getOwner());
|
// sharedFoldersCounter++;
|
||||||
// othersCounter++;
|
//
|
||||||
break;
|
// break;
|
||||||
}
|
//
|
||||||
}catch (Exception e) {
|
// case FOLDER_ITEM:
|
||||||
// TODO: handle exception
|
//
|
||||||
}
|
// FolderItem folderItem = (FolderItem) workspaceItem;
|
||||||
|
//
|
||||||
}
|
//// System.out.println(++i+") folderItem id: "+folderItem.getId() +", name: "+folderItem.getName() + ", own: "+folderItem.getOwner() +" path: "+folderItem.getPath());
|
||||||
|
// System.out.println(++i+") folderItem id: "+folderItem.getId() +", name: "+folderItem.getName() + ", own: "+folderItem.getOwner());
|
||||||
//TEST TIME
|
// folderItemCounter++;
|
||||||
endTime = System.currentTimeMillis();
|
//
|
||||||
long difference = endTime - startTime;
|
// break;
|
||||||
time = String.format("%d msc %d sec", difference, TimeUnit.MILLISECONDS.toSeconds(difference));
|
// default:
|
||||||
System.out.println("End time is "+endTime+ " difference is "+time);
|
// // System.out.println(++i+") DEFAULT - item id: "+workspaceItem.getId() +", name: "+workspaceItem.getName() + ", own: "+workspaceItem.getOwner());
|
||||||
System.out.println("Folders are: "+foldersCounter);
|
// // othersCounter++;
|
||||||
System.out.println("Shared Folders are: "+sharedFoldersCounter);
|
// break;
|
||||||
System.out.println("Folder Item are: "+folderItemCounter);
|
// }
|
||||||
System.out.println("Others are: "+othersCounter);
|
// }catch (Exception e) {
|
||||||
} catch (Exception e) {
|
// // TODO: handle exception
|
||||||
e.printStackTrace();
|
// }
|
||||||
}
|
//
|
||||||
}
|
// }
|
||||||
}
|
//
|
||||||
|
// //TEST TIME
|
||||||
|
// endTime = System.currentTimeMillis();
|
||||||
|
// long difference = endTime - startTime;
|
||||||
|
// time = String.format("%d msc %d sec", difference, TimeUnit.MILLISECONDS.toSeconds(difference));
|
||||||
|
// System.out.println("End time is "+endTime+ " difference is "+time);
|
||||||
|
// System.out.println("Folders are: "+foldersCounter);
|
||||||
|
// System.out.println("Shared Folders are: "+sharedFoldersCounter);
|
||||||
|
// System.out.println("Folder Item are: "+folderItemCounter);
|
||||||
|
// System.out.println("Others are: "+othersCounter);
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
|
@ -1,188 +1,189 @@
|
||||||
/**
|
////TODO IT MUST BE MOVED TO SHUB
|
||||||
*
|
///**
|
||||||
*/
|
// *
|
||||||
package org.gcube.portlets.user.workspace;
|
// */
|
||||||
|
//package org.gcube.portlets.user.workspace;
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
|
||||||
import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
|
|
||||||
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
|
||||||
import org.gcube.common.homelibrary.home.exceptions.UserNotFoundException;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceSharedFolder;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
|
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
|
||||||
import org.gcube.common.scope.impl.ScopeBean;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
|
||||||
* Jan 29, 2014
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class ItemRetrieve {
|
|
||||||
|
|
||||||
|
|
||||||
// public static String DEFAULT_SCOPE = "/d4science.research-infrastructures.eu/gCubeApps"; //PRODUCTION
|
|
||||||
public static String DEFAULT_SCOPE = "/gcube/devsec"; //DEV
|
|
||||||
public static String TEST_USER = "francesco.mangiacrapa";
|
|
||||||
// public static String ITEMID = "63832213-098d-42d1-8774-89b6349764c0"; //Activity T3.4 working drafts/T2-EC-IMAR-HO-14-015 iMarine Sustainability WP - Business Model tools.pdf
|
|
||||||
public static String ITEMID = "ce4866ee-8079-4acf-bcd6-1c9dd786eb73";
|
|
||||||
// d81d3a64-603f-4907-ae74-be8353211807
|
|
||||||
protected static Logger logger = Logger.getLogger(ItemRetrieve.class);
|
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
|
|
||||||
ScopeBean scope = new ScopeBean(DEFAULT_SCOPE);
|
|
||||||
ScopeProvider.instance.set(scope.toString());
|
|
||||||
|
|
||||||
System.out.println("init HL");
|
|
||||||
try {
|
|
||||||
Workspace ws = getWorkspace();
|
|
||||||
|
|
||||||
System.out.println(ws.getRoot().getId());
|
|
||||||
retrieveFirstLevel(ws, null);
|
|
||||||
//
|
//
|
||||||
// retrieveFirstLevel(ws, ITEMID);
|
//import java.util.List;
|
||||||
|
//import java.util.concurrent.TimeUnit;
|
||||||
//
|
//
|
||||||
// System.out.println("get workspace -> OK");
|
//import org.apache.log4j.Logger;
|
||||||
WorkspaceItem item = ws.getItem(ITEMID);
|
//import org.gcube.common.homelibrary.home.HomeLibrary;
|
||||||
System.out.println("get item id: "+item.getId()+", name: "+item.getName() +", parent: "+item.getParent().getId() +", parent name: "+item.getParent().getName()+", path :"+item.getPath());
|
//import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
|
||||||
System.out.println(item);
|
//import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
||||||
}catch(Exception e){
|
//import org.gcube.common.homelibrary.home.exceptions.UserNotFoundException;
|
||||||
e.printStackTrace();
|
//import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||||
}
|
//import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
||||||
|
//import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
||||||
// } catch (WorkspaceFolderNotFoundException e) {
|
//import org.gcube.common.homelibrary.home.workspace.WorkspaceSharedFolder;
|
||||||
// // TODO Auto-generated catch block
|
//import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
|
||||||
// e.printStackTrace();
|
//import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
|
||||||
// } catch (InternalErrorException e) {
|
//import org.gcube.common.scope.api.ScopeProvider;
|
||||||
// // TODO Auto-generated catch block
|
//import org.gcube.common.scope.impl.ScopeBean;
|
||||||
// e.printStackTrace();
|
//
|
||||||
// } catch (HomeNotFoundException e) {
|
///**
|
||||||
// // TODO Auto-generated catch block
|
// *
|
||||||
// e.printStackTrace();
|
// * @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
||||||
// } catch (UserNotFoundException e) {
|
// * Jan 29, 2014
|
||||||
// // TODO Auto-generated catch block
|
// *
|
||||||
|
// */
|
||||||
|
//public class ItemRetrieve {
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//// public static String DEFAULT_SCOPE = "/d4science.research-infrastructures.eu/gCubeApps"; //PRODUCTION
|
||||||
|
// public static String DEFAULT_SCOPE = "/gcube/devsec"; //DEV
|
||||||
|
// public static String TEST_USER = "francesco.mangiacrapa";
|
||||||
|
//// public static String ITEMID = "63832213-098d-42d1-8774-89b6349764c0"; //Activity T3.4 working drafts/T2-EC-IMAR-HO-14-015 iMarine Sustainability WP - Business Model tools.pdf
|
||||||
|
// public static String ITEMID = "ce4866ee-8079-4acf-bcd6-1c9dd786eb73";
|
||||||
|
//// d81d3a64-603f-4907-ae74-be8353211807
|
||||||
|
// protected static Logger logger = Logger.getLogger(ItemRetrieve.class);
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// public static void main(String[] args) {
|
||||||
|
//
|
||||||
|
// ScopeBean scope = new ScopeBean(DEFAULT_SCOPE);
|
||||||
|
// ScopeProvider.instance.set(scope.toString());
|
||||||
|
//
|
||||||
|
// System.out.println("init HL");
|
||||||
|
// try {
|
||||||
|
// Workspace ws = getWorkspace();
|
||||||
|
//
|
||||||
|
// System.out.println(ws.getRoot().getId());
|
||||||
|
// retrieveFirstLevel(ws, null);
|
||||||
|
////
|
||||||
|
//// retrieveFirstLevel(ws, ITEMID);
|
||||||
|
////
|
||||||
|
//// System.out.println("get workspace -> OK");
|
||||||
|
// WorkspaceItem item = ws.getItem(ITEMID);
|
||||||
|
// System.out.println("get item id: "+item.getId()+", name: "+item.getName() +", parent: "+item.getParent().getId() +", parent name: "+item.getParent().getName()+", path :"+item.getPath());
|
||||||
|
// System.out.println(item);
|
||||||
|
// }catch(Exception e){
|
||||||
// e.printStackTrace();
|
// e.printStackTrace();
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
}
|
//// } catch (WorkspaceFolderNotFoundException e) {
|
||||||
|
//// // TODO Auto-generated catch block
|
||||||
public static Workspace getWorkspace() throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException, UserNotFoundException
|
//// e.printStackTrace();
|
||||||
{
|
//// } catch (InternalErrorException e) {
|
||||||
|
//// // TODO Auto-generated catch block
|
||||||
logger.trace("Get Workspace scope: "+DEFAULT_SCOPE + " username: "+TEST_USER);
|
//// e.printStackTrace();
|
||||||
ScopeProvider.instance.set(DEFAULT_SCOPE);
|
//// } catch (HomeNotFoundException e) {
|
||||||
logger.trace("Scope provider instancied");
|
//// // TODO Auto-generated catch block
|
||||||
|
//// e.printStackTrace();
|
||||||
// return HomeLibrary.getUserWorkspace(TEST_USER);
|
//// } catch (UserNotFoundException e) {
|
||||||
return HomeLibrary.getHomeManagerFactory().getHomeManager().getHome(TEST_USER).getWorkspace();
|
//// // TODO Auto-generated catch block
|
||||||
}
|
//// e.printStackTrace();
|
||||||
|
//// }
|
||||||
|
////
|
||||||
private static void retrieveFirstLevel(Workspace ws, String foundFolder){
|
// }
|
||||||
|
//
|
||||||
try {
|
// public static Workspace getWorkspace() throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException, UserNotFoundException
|
||||||
|
// {
|
||||||
//TEST TIME
|
//
|
||||||
Long startTime = System.currentTimeMillis();
|
// logger.trace("Get Workspace scope: "+DEFAULT_SCOPE + " username: "+TEST_USER);
|
||||||
Long endTime = System.currentTimeMillis() - startTime;
|
// ScopeProvider.instance.set(DEFAULT_SCOPE);
|
||||||
String time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime));
|
// logger.trace("Scope provider instancied");
|
||||||
|
//
|
||||||
startTime = System.currentTimeMillis();
|
//// return HomeLibrary.getUserWorkspace(TEST_USER);
|
||||||
System.out.println("Start foundFolder at time: "+startTime);
|
// return HomeLibrary.getHomeManagerFactory().getHomeManager().getHome(TEST_USER).getWorkspace();
|
||||||
// WorkspaceItem root = ws.getItem(ITEMID);
|
// }
|
||||||
WorkspaceItem fd;
|
//
|
||||||
if(foundFolder!=null){
|
//
|
||||||
fd = ws.getItem(foundFolder);
|
// private static void retrieveFirstLevel(Workspace ws, String foundFolder){
|
||||||
System.out.println("foundFolder id: "+foundFolder);
|
//
|
||||||
System.out.println("start get children");
|
// try {
|
||||||
}else
|
//
|
||||||
fd = ws.getRoot();
|
// //TEST TIME
|
||||||
|
// Long startTime = System.currentTimeMillis();
|
||||||
List<? extends WorkspaceItem> children = fd.getChildren();
|
// Long endTime = System.currentTimeMillis() - startTime;
|
||||||
System.out.println("tree getChildren() returning "+children.size()+" elements in " + time);
|
// String time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime));
|
||||||
|
//
|
||||||
System.out.println("children size: "+children.size());
|
// startTime = System.currentTimeMillis();
|
||||||
|
// System.out.println("Start foundFolder at time: "+startTime);
|
||||||
int i=0;
|
//// WorkspaceItem root = ws.getItem(ITEMID);
|
||||||
int foldersCounter = 0;
|
// WorkspaceItem fd;
|
||||||
int sharedFoldersCounter = 0;
|
// if(foundFolder!=null){
|
||||||
int folderItemCounter = 0;
|
// fd = ws.getItem(foundFolder);
|
||||||
int othersCounter = 0;
|
// System.out.println("foundFolder id: "+foundFolder);
|
||||||
for (WorkspaceItem workspaceItem : children) {
|
// System.out.println("start get children");
|
||||||
try{
|
// }else
|
||||||
|
// fd = ws.getRoot();
|
||||||
/*if(foundFolder!=null && !foundFolder.isEmpty()){
|
//
|
||||||
if(workspaceItem.getId().compareTo(foundFolder)==0){
|
// List<? extends WorkspaceItem> children = fd.getChildren();
|
||||||
System.out.println("ITEM FOUND id: "+workspaceItem.getId()+", name: "+workspaceItem.getName());
|
// System.out.println("tree getChildren() returning "+children.size()+" elements in " + time);
|
||||||
return;
|
//
|
||||||
}
|
// System.out.println("children size: "+children.size());
|
||||||
}*/
|
//
|
||||||
|
// int i=0;
|
||||||
switch (workspaceItem.getType()) {
|
// int foldersCounter = 0;
|
||||||
|
// int sharedFoldersCounter = 0;
|
||||||
case FOLDER:
|
// int folderItemCounter = 0;
|
||||||
|
// int othersCounter = 0;
|
||||||
WorkspaceFolder folder = (WorkspaceFolder) workspaceItem;
|
// for (WorkspaceItem workspaceItem : children) {
|
||||||
|
// try{
|
||||||
// System.out.println(++i+") "+folder.getId() +" folder name: "+folder.getName() + " owner "+folder.getOwner() +" path: "+folder.getPath());
|
//
|
||||||
System.out.println(++i+") "+folder.getId() +" folder name: "+folder.getName() + " owner "+folder.getOwner());
|
// /*if(foundFolder!=null && !foundFolder.isEmpty()){
|
||||||
foldersCounter++;
|
// if(workspaceItem.getId().compareTo(foundFolder)==0){
|
||||||
|
// System.out.println("ITEM FOUND id: "+workspaceItem.getId()+", name: "+workspaceItem.getName());
|
||||||
break;
|
// return;
|
||||||
|
// }
|
||||||
case SHARED_FOLDER:
|
// }*/
|
||||||
|
//
|
||||||
WorkspaceSharedFolder shared = (WorkspaceSharedFolder) workspaceItem;
|
// switch (workspaceItem.getType()) {
|
||||||
|
//
|
||||||
// System.out.println(++i+") "+shared.getId() +" shared folder name: "+shared.getName() + " owner "+shared.getOwner()+" isVRE "+shared.isVreFolder() +" ACLOwner: "+shared.getACLOwner()+" AclUser: "+shared.getACLUser() +" path: "+shared.getPath());
|
// case FOLDER:
|
||||||
System.out.println(++i+") "+shared.getId() +" shared folder name: "+shared.getName());
|
//
|
||||||
|
// WorkspaceFolder folder = (WorkspaceFolder) workspaceItem;
|
||||||
// System.out.println(++i+") shared folder name: "+shared.getName() + " owner "+shared.getOwner().getPortalLogin());
|
//
|
||||||
sharedFoldersCounter++;
|
//// System.out.println(++i+") "+folder.getId() +" folder name: "+folder.getName() + " owner "+folder.getOwner() +" path: "+folder.getPath());
|
||||||
|
// System.out.println(++i+") "+folder.getId() +" folder name: "+folder.getName() + " owner "+folder.getOwner());
|
||||||
break;
|
// foldersCounter++;
|
||||||
|
//
|
||||||
case FOLDER_ITEM:
|
// break;
|
||||||
|
//
|
||||||
FolderItem folderItem = (FolderItem) workspaceItem;
|
// case SHARED_FOLDER:
|
||||||
|
//
|
||||||
// System.out.println(++i+") folderItem id: "+folderItem.getId() +", name: "+folderItem.getName() + ", own: "+folderItem.getOwner() +" path: "+folderItem.getPath());
|
// WorkspaceSharedFolder shared = (WorkspaceSharedFolder) workspaceItem;
|
||||||
System.out.println(++i+") folderItem id: "+folderItem.getId() +", name: "+folderItem.getName() + ", own: "+folderItem.getOwner());
|
//
|
||||||
folderItemCounter++;
|
//// System.out.println(++i+") "+shared.getId() +" shared folder name: "+shared.getName() + " owner "+shared.getOwner()+" isVRE "+shared.isVreFolder() +" ACLOwner: "+shared.getACLOwner()+" AclUser: "+shared.getACLUser() +" path: "+shared.getPath());
|
||||||
|
// System.out.println(++i+") "+shared.getId() +" shared folder name: "+shared.getName());
|
||||||
break;
|
//
|
||||||
default:
|
// // System.out.println(++i+") shared folder name: "+shared.getName() + " owner "+shared.getOwner().getPortalLogin());
|
||||||
// System.out.println(++i+") DEFAULT - item id: "+workspaceItem.getId() +", name: "+workspaceItem.getName() + ", own: "+workspaceItem.getOwner());
|
// sharedFoldersCounter++;
|
||||||
// othersCounter++;
|
//
|
||||||
break;
|
// break;
|
||||||
}
|
//
|
||||||
}catch (Exception e) {
|
// case FOLDER_ITEM:
|
||||||
// TODO: handle exception
|
//
|
||||||
}
|
// FolderItem folderItem = (FolderItem) workspaceItem;
|
||||||
|
//
|
||||||
}
|
//// System.out.println(++i+") folderItem id: "+folderItem.getId() +", name: "+folderItem.getName() + ", own: "+folderItem.getOwner() +" path: "+folderItem.getPath());
|
||||||
|
// System.out.println(++i+") folderItem id: "+folderItem.getId() +", name: "+folderItem.getName() + ", own: "+folderItem.getOwner());
|
||||||
//TEST TIME
|
// folderItemCounter++;
|
||||||
endTime = System.currentTimeMillis();
|
//
|
||||||
long difference = endTime - startTime;
|
// break;
|
||||||
time = String.format("%d msc %d sec", difference, TimeUnit.MILLISECONDS.toSeconds(difference));
|
// default:
|
||||||
System.out.println("End time is "+endTime+ " difference is "+time);
|
// // System.out.println(++i+") DEFAULT - item id: "+workspaceItem.getId() +", name: "+workspaceItem.getName() + ", own: "+workspaceItem.getOwner());
|
||||||
System.out.println("Folders are: "+foldersCounter);
|
// // othersCounter++;
|
||||||
System.out.println("Shared Folders are: "+sharedFoldersCounter);
|
// break;
|
||||||
System.out.println("Folder Item are: "+folderItemCounter);
|
// }
|
||||||
System.out.println("Others are: "+othersCounter);
|
// }catch (Exception e) {
|
||||||
} catch (Exception e) {
|
// // TODO: handle exception
|
||||||
e.printStackTrace();
|
// }
|
||||||
}
|
//
|
||||||
}
|
// }
|
||||||
}
|
//
|
||||||
|
// //TEST TIME
|
||||||
|
// endTime = System.currentTimeMillis();
|
||||||
|
// long difference = endTime - startTime;
|
||||||
|
// time = String.format("%d msc %d sec", difference, TimeUnit.MILLISECONDS.toSeconds(difference));
|
||||||
|
// System.out.println("End time is "+endTime+ " difference is "+time);
|
||||||
|
// System.out.println("Folders are: "+foldersCounter);
|
||||||
|
// System.out.println("Shared Folders are: "+sharedFoldersCounter);
|
||||||
|
// System.out.println("Folder Item are: "+folderItemCounter);
|
||||||
|
// System.out.println("Others are: "+othersCounter);
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
|
@ -1,138 +1,139 @@
|
||||||
/**
|
////TODO IT MUST BE MOVED TO SHUB
|
||||||
*
|
///**
|
||||||
*/
|
// *
|
||||||
package org.gcube.portlets.user.workspace;
|
// */
|
||||||
|
//package org.gcube.portlets.user.workspace;
|
||||||
import java.util.List;
|
//
|
||||||
|
//import java.util.List;
|
||||||
import org.apache.log4j.Logger;
|
//
|
||||||
import org.gcube.common.homelibary.model.items.type.WorkspaceItemType;
|
//import org.apache.log4j.Logger;
|
||||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
//import org.gcube.common.homelibary.model.items.type.WorkspaceItemType;
|
||||||
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
//import org.gcube.common.homelibrary.home.HomeLibrary;
|
||||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
//import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
//import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
//import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
||||||
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
|
//import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
||||||
import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalFile;
|
//import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
|
||||||
import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalImage;
|
//import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalFile;
|
||||||
import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalPDFFile;
|
//import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalImage;
|
||||||
import org.gcube.common.homelibrary.home.workspace.folder.items.GCubeItem;
|
//import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalPDFFile;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
//import org.gcube.common.homelibrary.home.workspace.folder.items.GCubeItem;
|
||||||
import org.gcube.common.scope.impl.ScopeBean;
|
//import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
//import org.gcube.common.scope.impl.ScopeBean;
|
||||||
/**
|
//
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
///**
|
||||||
* Jul 3, 2013
|
// * @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
||||||
*
|
// * Jul 3, 2013
|
||||||
*/
|
// *
|
||||||
public class PublicLinkTest {
|
// */
|
||||||
|
//public class PublicLinkTest {
|
||||||
|
//
|
||||||
protected static Logger logger = Logger.getLogger(PublicLinkTest.class);
|
//
|
||||||
|
// protected static Logger logger = Logger.getLogger(PublicLinkTest.class);
|
||||||
public static String DEFAULT_SCOPE = "/d4science.research-infrastructures.eu/gCubeApps/EcologicalModelling"; //PRODUCTION
|
//
|
||||||
// public static String DEFAULT_SCOPE = "/gcube/devsec"; //DEV
|
// public static String DEFAULT_SCOPE = "/d4science.research-infrastructures.eu/gCubeApps/EcologicalModelling"; //PRODUCTION
|
||||||
|
//// public static String DEFAULT_SCOPE = "/gcube/devsec"; //DEV
|
||||||
public static void main(String[] args) {
|
//
|
||||||
|
// public static void main(String[] args) {
|
||||||
try {
|
//
|
||||||
|
// try {
|
||||||
ScopeBean scope = new ScopeBean(DEFAULT_SCOPE);
|
//
|
||||||
ScopeProvider.instance.set(scope.toString());
|
// ScopeBean scope = new ScopeBean(DEFAULT_SCOPE);
|
||||||
|
// ScopeProvider.instance.set(scope.toString());
|
||||||
Workspace ws = HomeLibrary
|
//
|
||||||
.getHomeManagerFactory()
|
// Workspace ws = HomeLibrary
|
||||||
.getHomeManager()
|
// .getHomeManagerFactory()
|
||||||
.getHome("leonardo.candela")
|
// .getHomeManager()
|
||||||
.getWorkspace();
|
// .getHome("leonardo.candela")
|
||||||
//
|
// .getWorkspace();
|
||||||
|
// //
|
||||||
System.out.println("start get root");
|
//
|
||||||
WorkspaceItem root = ws.getRoot();
|
// System.out.println("start get root");
|
||||||
|
// WorkspaceItem root = ws.getRoot();
|
||||||
System.out.println("start get children");
|
//
|
||||||
List<? extends WorkspaceItem> children = root.getChildren();
|
// System.out.println("start get children");
|
||||||
|
// List<? extends WorkspaceItem> children = root.getChildren();
|
||||||
|
//
|
||||||
System.out.println("children size: "+children.size());
|
//
|
||||||
|
// System.out.println("children size: "+children.size());
|
||||||
int i=0;
|
//
|
||||||
for (WorkspaceItem workspaceItem : children) {
|
// int i=0;
|
||||||
|
// for (WorkspaceItem workspaceItem : children) {
|
||||||
|
//
|
||||||
if(workspaceItem.getType().equals(WorkspaceItemType.FOLDER) || workspaceItem.getType().equals(WorkspaceItemType.SHARED_FOLDER)){
|
//
|
||||||
|
// if(workspaceItem.getType().equals(WorkspaceItemType.FOLDER) || workspaceItem.getType().equals(WorkspaceItemType.SHARED_FOLDER)){
|
||||||
WorkspaceFolder folder = (WorkspaceFolder) workspaceItem;
|
//
|
||||||
|
// WorkspaceFolder folder = (WorkspaceFolder) workspaceItem;
|
||||||
System.out.println(++i+") folder name: "+folder.getName() + " is shared: "+folder.isShared());
|
//
|
||||||
}else{
|
// System.out.println(++i+") folder name: "+folder.getName() + " is shared: "+folder.isShared());
|
||||||
|
// }else{
|
||||||
|
//
|
||||||
if(workspaceItem.getType().equals(WorkspaceItemType.FOLDER_ITEM)){
|
//
|
||||||
|
// if(workspaceItem.getType().equals(WorkspaceItemType.FOLDER_ITEM)){
|
||||||
FolderItem folderItem = (FolderItem) workspaceItem;
|
//
|
||||||
|
// FolderItem folderItem = (FolderItem) workspaceItem;
|
||||||
String publicLink = getPubliLinkForFolderItem(folderItem);
|
//
|
||||||
|
// String publicLink = getPubliLinkForFolderItem(folderItem);
|
||||||
System.out.println(++i+") folderItem id: "+folderItem.getId() +", name: "+folderItem.getName() + ", ### Public link: "+publicLink);
|
//
|
||||||
}
|
// System.out.println(++i+") folderItem id: "+folderItem.getId() +", name: "+folderItem.getName() + ", ### Public link: "+publicLink);
|
||||||
|
// }
|
||||||
}
|
//
|
||||||
}
|
// }
|
||||||
System.out.println("end");
|
// }
|
||||||
} catch (Exception e) {
|
// System.out.println("end");
|
||||||
e.printStackTrace();
|
// } catch (Exception e) {
|
||||||
}
|
// e.printStackTrace();
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
protected static String getPubliLinkForFolderItem(FolderItem worspaceFolderItem) throws InternalErrorException{
|
//
|
||||||
|
// protected static String getPubliLinkForFolderItem(FolderItem worspaceFolderItem) throws InternalErrorException{
|
||||||
if(worspaceFolderItem==null)
|
//
|
||||||
return "";
|
// if(worspaceFolderItem==null)
|
||||||
|
// return "";
|
||||||
try{
|
//
|
||||||
|
// try{
|
||||||
switch(worspaceFolderItem.getFolderItemType())
|
//
|
||||||
{
|
// switch(worspaceFolderItem.getFolderItemType())
|
||||||
case EXTERNAL_IMAGE:
|
// {
|
||||||
return ((ExternalImage) worspaceFolderItem).getPublicLink();
|
// case EXTERNAL_IMAGE:
|
||||||
case EXTERNAL_FILE:
|
// return ((ExternalImage) worspaceFolderItem).getPublicLink();
|
||||||
return ((ExternalFile) worspaceFolderItem).getPublicLink();
|
// case EXTERNAL_FILE:
|
||||||
case EXTERNAL_PDF_FILE:
|
// return ((ExternalFile) worspaceFolderItem).getPublicLink();
|
||||||
return ((ExternalPDFFile) worspaceFolderItem).getPublicLink();
|
// case EXTERNAL_PDF_FILE:
|
||||||
case EXTERNAL_URL:
|
// return ((ExternalPDFFile) worspaceFolderItem).getPublicLink();
|
||||||
break;
|
// case EXTERNAL_URL:
|
||||||
case REPORT_TEMPLATE:
|
// break;
|
||||||
break;
|
// case REPORT_TEMPLATE:
|
||||||
case REPORT:
|
// break;
|
||||||
break;
|
// case REPORT:
|
||||||
case QUERY:
|
// break;
|
||||||
break;
|
// case QUERY:
|
||||||
case TIME_SERIES:
|
// break;
|
||||||
break;
|
// case TIME_SERIES:
|
||||||
// case AQUAMAPS_ITEM:
|
// break;
|
||||||
// break;
|
// // case AQUAMAPS_ITEM:
|
||||||
case PDF_DOCUMENT:
|
// // break;
|
||||||
break;
|
// case PDF_DOCUMENT:
|
||||||
case IMAGE_DOCUMENT:
|
// break;
|
||||||
GCubeItem imgDoc = (GCubeItem) worspaceFolderItem; //Cast GCubeItem
|
// case IMAGE_DOCUMENT:
|
||||||
return imgDoc.getPublicLink(false);
|
// GCubeItem imgDoc = (GCubeItem) worspaceFolderItem; //Cast GCubeItem
|
||||||
case DOCUMENT:
|
// return imgDoc.getPublicLink(false);
|
||||||
break;
|
// case DOCUMENT:
|
||||||
case URL_DOCUMENT:
|
// break;
|
||||||
break;
|
// case URL_DOCUMENT:
|
||||||
case METADATA:
|
// break;
|
||||||
break;
|
// case METADATA:
|
||||||
default:
|
// break;
|
||||||
return "";
|
// default:
|
||||||
}
|
// return "";
|
||||||
|
// }
|
||||||
}catch (Exception e) {
|
//
|
||||||
logger.error("an error occurred when get public link for item: "+worspaceFolderItem.getName());
|
// }catch (Exception e) {
|
||||||
return "";
|
// logger.error("an error occurred when get public link for item: "+worspaceFolderItem.getName());
|
||||||
}
|
// return "";
|
||||||
|
// }
|
||||||
return "";
|
//
|
||||||
}
|
// return "";
|
||||||
|
// }
|
||||||
}
|
//
|
||||||
|
//}
|
||||||
|
|
|
@ -1,72 +1,83 @@
|
||||||
/**
|
//TODO IT MUST BE MOVED TO SHUB
|
||||||
*
|
///**
|
||||||
*/
|
// *
|
||||||
package org.gcube.portlets.user.workspace;
|
// */
|
||||||
|
//package org.gcube.portlets.user.workspace;
|
||||||
import java.util.List;
|
//
|
||||||
|
//import java.util.List;
|
||||||
import org.apache.log4j.Logger;
|
//
|
||||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
//import org.apache.log4j.Logger;
|
||||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
//import org.gcube.common.homelibrary.home.HomeLibrary;
|
||||||
import org.gcube.common.homelibrary.home.workspace.search.SearchItem;
|
//import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
//import org.gcube.common.homelibrary.home.workspace.search.SearchItem;
|
||||||
import org.gcube.common.scope.impl.ScopeBean;
|
//import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.portlets.user.workspace.client.model.FileGridModel;
|
//import org.gcube.common.scope.impl.ScopeBean;
|
||||||
import org.gcube.portlets.user.workspace.server.GWTWorkspaceBuilder;
|
//import org.gcube.portlets.user.workspace.client.model.FileGridModel;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
// * @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
||||||
* Jul 3, 2013
|
// * Jul 3, 2013
|
||||||
*
|
// *
|
||||||
*/
|
// */
|
||||||
public class SearchTextTest {
|
//
|
||||||
|
//
|
||||||
|
///*
|
||||||
protected static Logger logger = Logger.getLogger(SearchTextTest.class);
|
// *
|
||||||
private static String text = "1_Networking Activities";
|
// *
|
||||||
public static String DEFAULT_SCOPE = "/gcube/devsec/devVRE"; //PRODUCTION
|
// * IT MUST BE MOVED TO SHUB
|
||||||
|
// *
|
||||||
public static String USER = "francesco.mangiacrapa"; //PRODUCTION
|
// *
|
||||||
|
// *
|
||||||
static GWTWorkspaceBuilder builder = new GWTWorkspaceBuilder();
|
//public class SearchTextTest {
|
||||||
static Workspace workspace;
|
//
|
||||||
|
//
|
||||||
public static void main(String[] args) {
|
// protected static Logger logger = Logger.getLogger(SearchTextTest.class);
|
||||||
|
// private static String text = "1_Networking Activities";
|
||||||
try {
|
// public static String DEFAULT_SCOPE = "/gcube/devsec/devVRE"; //PRODUCTION
|
||||||
// DEFAULT_SCOPE = "/gcube/devsec";
|
//
|
||||||
|
// public static String USER = "francesco.mangiacrapa"; //PRODUCTION
|
||||||
|
//
|
||||||
ScopeBean scope = new ScopeBean(DEFAULT_SCOPE);
|
// static GWTWorkspaceBuilder builder = new GWTWorkspaceBuilder();
|
||||||
ScopeProvider.instance.set(scope.toString());
|
// static Workspace workspace;
|
||||||
|
//
|
||||||
System.out.println("start get workspace\n");
|
// public static void main(String[] args) {
|
||||||
|
//
|
||||||
workspace = HomeLibrary
|
// try {
|
||||||
.getHomeManagerFactory()
|
//// DEFAULT_SCOPE = "/gcube/devsec";
|
||||||
.getHomeManager()
|
//
|
||||||
.getHome(USER)
|
//
|
||||||
.getWorkspace();
|
// ScopeBean scope = new ScopeBean(DEFAULT_SCOPE);
|
||||||
//
|
// ScopeProvider.instance.set(scope.toString());
|
||||||
|
//
|
||||||
// List<SearchItem> listSearchItems = ws.searchByName(text);
|
// System.out.println("start get workspace\n");
|
||||||
|
//
|
||||||
logger.info("Calling search HL..");
|
// workspace = HomeLibrary
|
||||||
List<SearchItem> listSearchItems = workspace.searchByName(text, workspace.getRoot().getId());
|
// .getHomeManagerFactory()
|
||||||
logger.info("HL search returning "+listSearchItems.size()+" items");
|
// .getHomeManager()
|
||||||
|
// .getHome(USER)
|
||||||
logger.info("Converting "+listSearchItems.size()+" items");
|
// .getWorkspace();
|
||||||
|
// //
|
||||||
List<FileGridModel> listFileGridModels = builder.buildGXTListFileGridModelItemForSearch(listSearchItems);
|
//
|
||||||
logger.info("Search objects converted, returning");
|
//// List<SearchItem> listSearchItems = ws.searchByName(text);
|
||||||
|
//
|
||||||
for (FileGridModel fileGridModel : listFileGridModels) {
|
// logger.info("Calling search HL..");
|
||||||
logger.info(fileGridModel);
|
// List<SearchItem> listSearchItems = workspace.searchByName(text, workspace.getRoot().getId());
|
||||||
}
|
// logger.info("HL search returning "+listSearchItems.size()+" items");
|
||||||
|
//
|
||||||
}catch(Exception e){
|
// logger.info("Converting "+listSearchItems.size()+" items");
|
||||||
e.printStackTrace();
|
//
|
||||||
}
|
// List<FileGridModel> listFileGridModels = builder.buildGXTListFileGridModelItemForSearch(listSearchItems);
|
||||||
}
|
// logger.info("Search objects converted, returning");
|
||||||
|
//
|
||||||
}
|
// for (FileGridModel fileGridModel : listFileGridModels) {
|
||||||
|
// logger.info(fileGridModel);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }catch(Exception e){
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//*/
|
||||||
|
|
|
@ -1,78 +1,79 @@
|
||||||
package org.gcube.portlets.user.workspace;
|
////TODO IT MUST BE MOVED TO SHUB
|
||||||
|
//package org.gcube.portlets.user.workspace;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.gcube.common.homelibary.model.items.type.WorkspaceItemType;
|
|
||||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceSharedFolder;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.accessmanager.ACLType;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
|
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
|
||||||
import org.gcube.common.scope.impl.ScopeBean;
|
|
||||||
|
|
||||||
public class ShareFolder {
|
|
||||||
|
|
||||||
private static final String SUB_FOLDER_NAME = "subfoldermycourse";
|
|
||||||
private static final String FOLDER_NAME = "_mycourse";
|
|
||||||
public static String DEFAULT_SCOPE = "/gcube/devsec"; //DEV
|
|
||||||
// public static String DEFAULT_SCOPE = "/d4science.research-infrastructures.eu/gCubeApps";
|
|
||||||
public static String TEST_USER = "francesco.mangiacrapa";
|
|
||||||
// public static String FOLDER_ID = "4f0ff79d-3c1e-4d2a-bc74-6f731edcac98";
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
// System.out.println("start");
|
|
||||||
// ScopeBean scope = new ScopeBean(DEFAULT_SCOPE);
|
|
||||||
ScopeProvider.instance.set(DEFAULT_SCOPE);
|
|
||||||
|
|
||||||
Workspace workspace = HomeLibrary
|
|
||||||
.getHomeManagerFactory()
|
|
||||||
.getHomeManager()
|
|
||||||
.getHome(TEST_USER)
|
|
||||||
.getWorkspace();
|
|
||||||
//
|
|
||||||
|
|
||||||
System.out.println("start get root");
|
|
||||||
WorkspaceItem theRoot = workspace.getRoot();
|
|
||||||
|
|
||||||
System.out.println("\n\n CREATING folder: "+FOLDER_NAME + "\n\n");
|
|
||||||
|
|
||||||
WorkspaceFolder myCourseFolder = workspace.createFolder(FOLDER_NAME, "", theRoot.getId());
|
|
||||||
|
|
||||||
System.out.println("\n\n FOLDER id: "+myCourseFolder.getId() +"\n\n");
|
|
||||||
|
|
||||||
System.out.println("\n\n CREATING sub folder: "+SUB_FOLDER_NAME+"\n\n");
|
|
||||||
|
|
||||||
WorkspaceFolder subFolderMyCourse = workspace.createFolder(SUB_FOLDER_NAME, "", myCourseFolder.getId());
|
|
||||||
|
|
||||||
System.out.println("\n\n SUB_FOLDER id: "+subFolderMyCourse.getId() +"\n\n");
|
|
||||||
|
|
||||||
List<String> users = new ArrayList<String>();
|
|
||||||
users.add("costantino.perciante");
|
|
||||||
WorkspaceSharedFolder subShareFolder = workspace.shareFolder(users, subFolderMyCourse.getId());
|
|
||||||
subShareFolder.setACL(users, ACLType.READ_ONLY);
|
|
||||||
System.out.println("\n\n SHARED SUB_FOLDER id: "+subShareFolder.getId() +"\n\n");
|
|
||||||
|
|
||||||
// WorkspaceSharedFolder sharedFolder = subFolderMyCourse.share(users);
|
|
||||||
|
|
||||||
|
|
||||||
// System.out.println("\n\n SHARED subFolderMyCourse id: "+sharedFolder.getId());
|
|
||||||
//
|
|
||||||
//
|
//
|
||||||
// WorkspaceFolder folder = (WorkspaceFolder) workspace.getItem(sharedFolder.getId());
|
//import java.util.ArrayList;
|
||||||
|
//import java.util.List;
|
||||||
|
//
|
||||||
|
//import org.gcube.common.homelibary.model.items.type.WorkspaceItemType;
|
||||||
|
//import org.gcube.common.homelibrary.home.HomeLibrary;
|
||||||
|
//import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||||
|
//import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
||||||
|
//import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
||||||
|
//import org.gcube.common.homelibrary.home.workspace.WorkspaceSharedFolder;
|
||||||
|
//import org.gcube.common.homelibrary.home.workspace.accessmanager.ACLType;
|
||||||
|
//import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
|
||||||
|
//import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
//import org.gcube.common.scope.impl.ScopeBean;
|
||||||
|
//
|
||||||
|
//public class ShareFolder {
|
||||||
|
//
|
||||||
|
// private static final String SUB_FOLDER_NAME = "subfoldermycourse";
|
||||||
|
// private static final String FOLDER_NAME = "_mycourse";
|
||||||
|
// public static String DEFAULT_SCOPE = "/gcube/devsec"; //DEV
|
||||||
|
//// public static String DEFAULT_SCOPE = "/d4science.research-infrastructures.eu/gCubeApps";
|
||||||
|
// public static String TEST_USER = "francesco.mangiacrapa";
|
||||||
|
//// public static String FOLDER_ID = "4f0ff79d-3c1e-4d2a-bc74-6f731edcac98";
|
||||||
|
//
|
||||||
|
// public static void main(String[] args) {
|
||||||
|
//
|
||||||
|
// try {
|
||||||
|
//
|
||||||
|
//// System.out.println("start");
|
||||||
|
//// ScopeBean scope = new ScopeBean(DEFAULT_SCOPE);
|
||||||
|
// ScopeProvider.instance.set(DEFAULT_SCOPE);
|
||||||
//
|
//
|
||||||
// System.out.println("\n\n FINAL id: "+folder.getId());
|
// Workspace workspace = HomeLibrary
|
||||||
|
// .getHomeManagerFactory()
|
||||||
System.out.println("end");
|
// .getHomeManager()
|
||||||
} catch (Exception e) {
|
// .getHome(TEST_USER)
|
||||||
e.printStackTrace();
|
// .getWorkspace();
|
||||||
}
|
// //
|
||||||
}
|
//
|
||||||
|
// System.out.println("start get root");
|
||||||
}
|
// WorkspaceItem theRoot = workspace.getRoot();
|
||||||
|
//
|
||||||
|
// System.out.println("\n\n CREATING folder: "+FOLDER_NAME + "\n\n");
|
||||||
|
//
|
||||||
|
// WorkspaceFolder myCourseFolder = workspace.createFolder(FOLDER_NAME, "", theRoot.getId());
|
||||||
|
//
|
||||||
|
// System.out.println("\n\n FOLDER id: "+myCourseFolder.getId() +"\n\n");
|
||||||
|
//
|
||||||
|
// System.out.println("\n\n CREATING sub folder: "+SUB_FOLDER_NAME+"\n\n");
|
||||||
|
//
|
||||||
|
// WorkspaceFolder subFolderMyCourse = workspace.createFolder(SUB_FOLDER_NAME, "", myCourseFolder.getId());
|
||||||
|
//
|
||||||
|
// System.out.println("\n\n SUB_FOLDER id: "+subFolderMyCourse.getId() +"\n\n");
|
||||||
|
//
|
||||||
|
// List<String> users = new ArrayList<String>();
|
||||||
|
// users.add("costantino.perciante");
|
||||||
|
// WorkspaceSharedFolder subShareFolder = workspace.shareFolder(users, subFolderMyCourse.getId());
|
||||||
|
// subShareFolder.setACL(users, ACLType.READ_ONLY);
|
||||||
|
// System.out.println("\n\n SHARED SUB_FOLDER id: "+subShareFolder.getId() +"\n\n");
|
||||||
|
//
|
||||||
|
//// WorkspaceSharedFolder sharedFolder = subFolderMyCourse.share(users);
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//// System.out.println("\n\n SHARED subFolderMyCourse id: "+sharedFolder.getId());
|
||||||
|
////
|
||||||
|
////
|
||||||
|
//// WorkspaceFolder folder = (WorkspaceFolder) workspace.getItem(sharedFolder.getId());
|
||||||
|
////
|
||||||
|
//// System.out.println("\n\n FINAL id: "+folder.getId());
|
||||||
|
//
|
||||||
|
// System.out.println("end");
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
|
|
@ -1,208 +1,217 @@
|
||||||
/**
|
////TODO IT MUST BE MOVED TO SHUB
|
||||||
*
|
///**
|
||||||
*/
|
// *
|
||||||
package org.gcube.portlets.user.workspace;
|
// */
|
||||||
|
//package org.gcube.portlets.user.workspace;
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.gcube.common.homelibary.model.items.type.WorkspaceItemType;
|
|
||||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
|
||||||
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalFile;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalImage;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalPDFFile;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.folder.items.GCubeItem;
|
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
|
||||||
import org.gcube.common.scope.impl.ScopeBean;
|
|
||||||
import org.gcube.portlets.user.workspace.server.GWTWorkspaceBuilder;
|
|
||||||
import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParameterForResolverIndex;
|
|
||||||
import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParameterForResolverIndex.RESOLVER_TYPE;
|
|
||||||
import org.gcube.portlets.user.workspace.server.util.HttpRequestUtil;
|
|
||||||
import org.gcube.portlets.user.workspace.server.util.StringUtil;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
|
||||||
* Jul 3, 2013
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class SinglePublicLinkTest {
|
|
||||||
|
|
||||||
|
|
||||||
protected static Logger logger = Logger.getLogger(SinglePublicLinkTest.class);
|
|
||||||
|
|
||||||
// public static String DEFAULT_SCOPE = "/d4science.research-infrastructures.eu/gCubeApps"; //PRODUCTION
|
|
||||||
public static String DEFAULT_SCOPE = "/gcube/devsec"; //DEV
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
ScopeBean scope = new ScopeBean(DEFAULT_SCOPE);
|
|
||||||
ScopeProvider.instance.set(scope.toString());
|
|
||||||
|
|
||||||
Workspace ws = HomeLibrary
|
|
||||||
.getHomeManagerFactory()
|
|
||||||
.getHomeManager()
|
|
||||||
.getHome("francesco.mangiacrapa")
|
|
||||||
.getWorkspace();
|
|
||||||
//
|
|
||||||
|
|
||||||
System.out.println("start get root");
|
|
||||||
WorkspaceItem root = ws.getRoot();
|
|
||||||
|
|
||||||
|
|
||||||
for (WorkspaceItem wsi : root.getChildren()) {
|
|
||||||
if(wsi.getType().equals(WorkspaceItemType.FOLDER_ITEM)){
|
|
||||||
try{
|
|
||||||
String publicLink = getPublicLinkForFolderItemId(wsi.getId(), true, ws);
|
|
||||||
System.out.println("\nITEM: "+wsi.getName());
|
|
||||||
System.out.println(publicLink);
|
|
||||||
// break;
|
|
||||||
}catch(Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// System.out.println("start get children");
|
|
||||||
// List<? extends WorkspaceItem> children = root.getChildren();
|
|
||||||
//
|
//
|
||||||
|
//import org.apache.log4j.Logger;
|
||||||
|
//import org.gcube.common.homelibary.model.items.type.WorkspaceItemType;
|
||||||
|
//import org.gcube.common.homelibrary.home.HomeLibrary;
|
||||||
|
//import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
||||||
|
//import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||||
|
//import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
||||||
|
//import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
|
||||||
|
//import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalFile;
|
||||||
|
//import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalImage;
|
||||||
|
//import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalPDFFile;
|
||||||
|
//import org.gcube.common.homelibrary.home.workspace.folder.items.GCubeItem;
|
||||||
|
//import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
//import org.gcube.common.scope.impl.ScopeBean;
|
||||||
|
//import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParameterForResolverIndex;
|
||||||
|
//import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParameterForResolverIndex.RESOLVER_TYPE;
|
||||||
|
//import org.gcube.portlets.user.workspace.server.util.HttpRequestUtil;
|
||||||
|
//import org.gcube.portlets.user.workspace.server.util.StringUtil;
|
||||||
|
//
|
||||||
|
///**
|
||||||
|
// * @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
||||||
|
// * Jul 3, 2013
|
||||||
|
// *
|
||||||
|
// */
|
||||||
|
///*
|
||||||
|
// *
|
||||||
|
// *
|
||||||
|
// * IT MUST BE MOVED TO SHUB
|
||||||
|
// *
|
||||||
|
// *
|
||||||
|
// *
|
||||||
|
//public class SinglePublicLinkTest {
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// protected static Logger logger = Logger.getLogger(SinglePublicLinkTest.class);
|
||||||
|
//
|
||||||
|
//// public static String DEFAULT_SCOPE = "/d4science.research-infrastructures.eu/gCubeApps"; //PRODUCTION
|
||||||
|
// public static String DEFAULT_SCOPE = "/gcube/devsec"; //DEV
|
||||||
|
//
|
||||||
|
// public static void main(String[] args) {
|
||||||
|
//
|
||||||
|
// try {
|
||||||
|
//
|
||||||
|
// ScopeBean scope = new ScopeBean(DEFAULT_SCOPE);
|
||||||
|
// ScopeProvider.instance.set(scope.toString());
|
||||||
//
|
//
|
||||||
// System.out.println("children size: "+children.size());
|
// Workspace ws = HomeLibrary
|
||||||
|
// .getHomeManagerFactory()
|
||||||
|
// .getHomeManager()
|
||||||
|
// .getHome("francesco.mangiacrapa")
|
||||||
|
// .getWorkspace();
|
||||||
|
// //
|
||||||
//
|
//
|
||||||
// int i=0;
|
// System.out.println("start get root");
|
||||||
// for (WorkspaceItem workspaceItem : children) {
|
// WorkspaceItem root = ws.getRoot();
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// if(workspaceItem.getType().equals(WorkspaceItemType.FOLDER) || workspaceItem.getType().equals(WorkspaceItemType.SHARED_FOLDER)){
|
// for (WorkspaceItem wsi : root.getChildren()) {
|
||||||
//
|
// if(wsi.getType().equals(WorkspaceItemType.FOLDER_ITEM)){
|
||||||
// WorkspaceFolder folder = (WorkspaceFolder) workspaceItem;
|
// try{
|
||||||
//
|
// String publicLink = getPublicLinkForFolderItemId(wsi.getId(), true, ws);
|
||||||
// System.out.println(++i+") folder name: "+folder.getName() + " is shared: "+folder.isShared());
|
// System.out.println("\nITEM: "+wsi.getName());
|
||||||
// }else{
|
// System.out.println(publicLink);
|
||||||
//
|
//// break;
|
||||||
//
|
// }catch(Exception e){
|
||||||
// if(workspaceItem.getType().equals(WorkspaceItemType.FOLDER_ITEM)){
|
// e.printStackTrace();
|
||||||
//
|
|
||||||
// FolderItem folderItem = (FolderItem) workspaceItem;
|
|
||||||
//
|
|
||||||
// String publicLink = getPubliLinkForFolderItem(folderItem);
|
|
||||||
//
|
|
||||||
// System.out.println(++i+") folderItem id: "+folderItem.getId() +", name: "+folderItem.getName() + ", ### Public link: "+publicLink);
|
|
||||||
// }
|
// }
|
||||||
//
|
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
System.out.println("end");
|
//
|
||||||
} catch (Exception e) {
|
//
|
||||||
e.printStackTrace();
|
//// System.out.println("start get children");
|
||||||
}
|
//// List<? extends WorkspaceItem> children = root.getChildren();
|
||||||
}
|
////
|
||||||
|
////
|
||||||
|
//// System.out.println("children size: "+children.size());
|
||||||
public static String getPublicLinkForFolderItemId(String itemId, boolean shortenUrl, Workspace workspace) throws Exception{
|
////
|
||||||
|
//// int i=0;
|
||||||
logger.trace("get Public Link For ItemId: "+ itemId);
|
//// for (WorkspaceItem workspaceItem : children) {
|
||||||
|
////
|
||||||
GWTWorkspaceBuilder builder = new GWTWorkspaceBuilder();
|
////
|
||||||
|
//// if(workspaceItem.getType().equals(WorkspaceItemType.FOLDER) || workspaceItem.getType().equals(WorkspaceItemType.SHARED_FOLDER)){
|
||||||
try{
|
////
|
||||||
|
//// WorkspaceFolder folder = (WorkspaceFolder) workspaceItem;
|
||||||
WorkspaceItem wsItem = workspace.getItem(itemId);
|
////
|
||||||
|
//// System.out.println(++i+") folder name: "+folder.getName() + " is shared: "+folder.isShared());
|
||||||
if(wsItem.getType().equals(WorkspaceItemType.FOLDER_ITEM)){
|
//// }else{
|
||||||
|
////
|
||||||
FolderItem folderItem = (FolderItem) wsItem;
|
////
|
||||||
String storageID = builder.getStorageIDForFolderItem(folderItem);
|
//// if(workspaceItem.getType().equals(WorkspaceItemType.FOLDER_ITEM)){
|
||||||
|
////
|
||||||
if(storageID==null || storageID.isEmpty())
|
//// FolderItem folderItem = (FolderItem) workspaceItem;
|
||||||
throw new Exception("Sorry, public link on "+wsItem.getName() +" is not available");
|
////
|
||||||
|
//// String publicLink = getPubliLinkForFolderItem(folderItem);
|
||||||
UriResolverReaderParameterForResolverIndex uriResolver = new UriResolverReaderParameterForResolverIndex(DEFAULT_SCOPE, RESOLVER_TYPE.SMP_ID);
|
////
|
||||||
|
//// System.out.println(++i+") folderItem id: "+folderItem.getId() +", name: "+folderItem.getName() + ", ### Public link: "+publicLink);
|
||||||
String uriRequest = "";
|
//// }
|
||||||
|
////
|
||||||
if(uriResolver!=null && uriResolver.isAvailable()){
|
//// }
|
||||||
|
//// }
|
||||||
String itemName = StringUtil.removeSpecialCharacters(folderItem.getName());
|
// System.out.println("end");
|
||||||
itemName = StringUtil.replaceAllWhiteSpace(itemName, "_");
|
// } catch (Exception e) {
|
||||||
uriRequest = uriResolver.resolveAsUriRequest(storageID, itemName, folderItem.getMimeType(), true);
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
//VALIDATE CONNECTION
|
// }
|
||||||
if(!HttpRequestUtil.urlExists(uriRequest+"&validation=true"))
|
//
|
||||||
throw new Exception("Sorry, The Public Link for selected file is unavailable");
|
//
|
||||||
|
// public static String getPublicLinkForFolderItemId(String itemId, boolean shortenUrl, Workspace workspace) throws Exception{
|
||||||
// if(shortenUrl)
|
//
|
||||||
// uriRequest = getShortUrl(uriRequest);
|
// logger.trace("get Public Link For ItemId: "+ itemId);
|
||||||
|
//
|
||||||
return uriRequest;
|
// GWTWorkspaceBuilder builder = new GWTWorkspaceBuilder();
|
||||||
}
|
//
|
||||||
else
|
// try{
|
||||||
throw new Exception("Sorry, The Uri resolver service is temporarily unavailable. Please try again later");
|
//
|
||||||
|
// WorkspaceItem wsItem = workspace.getItem(itemId);
|
||||||
}else{
|
//
|
||||||
logger.warn("ItemId: "+ itemId +" is not a folder item, sent exception Public Link unavailable");
|
// if(wsItem.getType().equals(WorkspaceItemType.FOLDER_ITEM)){
|
||||||
throw new Exception("Sorry, The Public Link for selected file is unavailable");
|
//
|
||||||
}
|
// FolderItem folderItem = (FolderItem) wsItem;
|
||||||
|
// String storageID = builder.getStorageIDForFolderItem(folderItem);
|
||||||
}catch (Exception e) {
|
//
|
||||||
logger.error("Error getPublicLinkForFolderItemId for item: "+itemId, e);
|
// if(storageID==null || storageID.isEmpty())
|
||||||
e.printStackTrace();
|
// throw new Exception("Sorry, public link on "+wsItem.getName() +" is not available");
|
||||||
throw new Exception(e.getMessage());
|
//
|
||||||
}
|
// UriResolverReaderParameterForResolverIndex uriResolver = new UriResolverReaderParameterForResolverIndex(DEFAULT_SCOPE, RESOLVER_TYPE.SMP_ID);
|
||||||
|
//
|
||||||
}
|
// String uriRequest = "";
|
||||||
protected static String getPubliLinkForFolderItem(FolderItem worspaceFolderItem) throws InternalErrorException{
|
//
|
||||||
|
// if(uriResolver!=null && uriResolver.isAvailable()){
|
||||||
if(worspaceFolderItem==null)
|
//
|
||||||
return "";
|
// String itemName = StringUtil.removeSpecialCharacters(folderItem.getName());
|
||||||
|
// itemName = StringUtil.replaceAllWhiteSpace(itemName, "_");
|
||||||
try{
|
// uriRequest = uriResolver.resolveAsUriRequest(storageID, itemName, folderItem.getMimeType(), true);
|
||||||
|
//
|
||||||
switch(worspaceFolderItem.getFolderItemType())
|
// //VALIDATE CONNECTION
|
||||||
{
|
// if(!HttpRequestUtil.urlExists(uriRequest+"&validation=true"))
|
||||||
case EXTERNAL_IMAGE:
|
// throw new Exception("Sorry, The Public Link for selected file is unavailable");
|
||||||
return ((ExternalImage) worspaceFolderItem).getPublicLink();
|
//
|
||||||
case EXTERNAL_FILE:
|
//// if(shortenUrl)
|
||||||
return ((ExternalFile) worspaceFolderItem).getPublicLink();
|
//// uriRequest = getShortUrl(uriRequest);
|
||||||
case EXTERNAL_PDF_FILE:
|
//
|
||||||
return ((ExternalPDFFile) worspaceFolderItem).getPublicLink();
|
// return uriRequest;
|
||||||
case EXTERNAL_URL:
|
// }
|
||||||
break;
|
// else
|
||||||
case REPORT_TEMPLATE:
|
// throw new Exception("Sorry, The Uri resolver service is temporarily unavailable. Please try again later");
|
||||||
break;
|
//
|
||||||
case REPORT:
|
// }else{
|
||||||
break;
|
// logger.warn("ItemId: "+ itemId +" is not a folder item, sent exception Public Link unavailable");
|
||||||
case QUERY:
|
// throw new Exception("Sorry, The Public Link for selected file is unavailable");
|
||||||
break;
|
// }
|
||||||
case TIME_SERIES:
|
//
|
||||||
break;
|
// }catch (Exception e) {
|
||||||
// case AQUAMAPS_ITEM:
|
// logger.error("Error getPublicLinkForFolderItemId for item: "+itemId, e);
|
||||||
// break;
|
// e.printStackTrace();
|
||||||
case PDF_DOCUMENT:
|
// throw new Exception(e.getMessage());
|
||||||
break;
|
// }
|
||||||
case IMAGE_DOCUMENT:
|
//
|
||||||
GCubeItem imgDoc = (GCubeItem) worspaceFolderItem; //Cast GCubeItem
|
// }
|
||||||
return imgDoc.getPublicLink(false);
|
// protected static String getPubliLinkForFolderItem(FolderItem worspaceFolderItem) throws InternalErrorException{
|
||||||
case DOCUMENT:
|
//
|
||||||
break;
|
// if(worspaceFolderItem==null)
|
||||||
case URL_DOCUMENT:
|
// return "";
|
||||||
break;
|
//
|
||||||
case METADATA:
|
// try{
|
||||||
break;
|
//
|
||||||
default:
|
// switch(worspaceFolderItem.getFolderItemType())
|
||||||
return "";
|
// {
|
||||||
}
|
// case EXTERNAL_IMAGE:
|
||||||
|
// return ((ExternalImage) worspaceFolderItem).getPublicLink();
|
||||||
}catch (Exception e) {
|
// case EXTERNAL_FILE:
|
||||||
logger.error("an error occurred when get public link for item: "+worspaceFolderItem.getName());
|
// return ((ExternalFile) worspaceFolderItem).getPublicLink();
|
||||||
return "";
|
// case EXTERNAL_PDF_FILE:
|
||||||
}
|
// return ((ExternalPDFFile) worspaceFolderItem).getPublicLink();
|
||||||
|
// case EXTERNAL_URL:
|
||||||
return "";
|
// break;
|
||||||
}
|
// case REPORT_TEMPLATE:
|
||||||
|
// break;
|
||||||
}
|
// case REPORT:
|
||||||
|
// break;
|
||||||
|
// case QUERY:
|
||||||
|
// break;
|
||||||
|
// case TIME_SERIES:
|
||||||
|
// break;
|
||||||
|
// // case AQUAMAPS_ITEM:
|
||||||
|
// // break;
|
||||||
|
// case PDF_DOCUMENT:
|
||||||
|
// break;
|
||||||
|
// case IMAGE_DOCUMENT:
|
||||||
|
// GCubeItem imgDoc = (GCubeItem) worspaceFolderItem; //Cast GCubeItem
|
||||||
|
// return imgDoc.getPublicLink(false);
|
||||||
|
// case DOCUMENT:
|
||||||
|
// break;
|
||||||
|
// case URL_DOCUMENT:
|
||||||
|
// break;
|
||||||
|
// case METADATA:
|
||||||
|
// break;
|
||||||
|
// default:
|
||||||
|
// return "";
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }catch (Exception e) {
|
||||||
|
// logger.error("an error occurred when get public link for item: "+worspaceFolderItem.getName());
|
||||||
|
// return "";
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return "";
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//*/
|
|
@ -1,92 +1,101 @@
|
||||||
/**
|
////TODO IT MUST BE MOVED TO SHUB
|
||||||
*
|
///**
|
||||||
*/
|
// *
|
||||||
package org.gcube.portlets.user.workspace;
|
// */
|
||||||
|
//package org.gcube.portlets.user.workspace;
|
||||||
import java.util.List;
|
//
|
||||||
|
//import java.util.List;
|
||||||
import org.gcube.common.homelibary.model.items.type.WorkspaceItemType;
|
//
|
||||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
//import org.gcube.common.homelibary.model.items.type.WorkspaceItemType;
|
||||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
//import org.gcube.common.homelibrary.home.HomeLibrary;
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
//import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
//import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
||||||
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
|
//import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
//import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
|
||||||
import org.gcube.common.scope.impl.ScopeBean;
|
//import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.portlets.user.workspace.server.GWTWorkspaceBuilder;
|
//import org.gcube.common.scope.impl.ScopeBean;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
*
|
// *
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
// * @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
||||||
* Jan 29, 2014
|
// * Jan 29, 2014
|
||||||
*
|
// *
|
||||||
*/
|
// */
|
||||||
public class SizeRetrieving {
|
///*
|
||||||
|
// *
|
||||||
|
// *
|
||||||
public static String DEFAULT_SCOPE = "/gcube/devsec"; //DEV
|
// * IT MUST BE MOVED TO SHUB
|
||||||
// public static String DEFAULT_SCOPE = "/d4science.research-infrastructures.eu/gCubeApps";
|
// *
|
||||||
public static String TEST_USER = "francesco.mangiacrapa";
|
// *
|
||||||
// public static String FOLDER_ID = "4f0ff79d-3c1e-4d2a-bc74-6f731edcac98";
|
// *
|
||||||
|
//public class SizeRetrieving {
|
||||||
public static void main(String[] args) {
|
//
|
||||||
|
//
|
||||||
try {
|
// public static String DEFAULT_SCOPE = "/gcube/devsec"; //DEV
|
||||||
|
//// public static String DEFAULT_SCOPE = "/d4science.research-infrastructures.eu/gCubeApps";
|
||||||
ScopeBean scope = new ScopeBean(DEFAULT_SCOPE);
|
// public static String TEST_USER = "francesco.mangiacrapa";
|
||||||
ScopeProvider.instance.set(scope.toString());
|
//// public static String FOLDER_ID = "4f0ff79d-3c1e-4d2a-bc74-6f731edcac98";
|
||||||
|
//
|
||||||
Workspace ws = HomeLibrary
|
// public static void main(String[] args) {
|
||||||
.getHomeManagerFactory()
|
//
|
||||||
.getHomeManager()
|
// try {
|
||||||
.getHome(TEST_USER)
|
//
|
||||||
.getWorkspace();
|
// ScopeBean scope = new ScopeBean(DEFAULT_SCOPE);
|
||||||
//
|
// ScopeProvider.instance.set(scope.toString());
|
||||||
|
|
||||||
// System.out.println("start get root");
|
|
||||||
WorkspaceItem folder = ws.getRoot();
|
|
||||||
// List<WorkspaceItem> children = (List<WorkspaceItem>) root.getChildren();
|
|
||||||
|
|
||||||
System.out.println("start get children");
|
|
||||||
|
|
||||||
// WorkspaceFolder folder = (WorkspaceFolder) ws.getItem(FOLDER_ID);
|
|
||||||
List<WorkspaceItem> children = (List<WorkspaceItem>) folder.getChildren();
|
|
||||||
// List<? extends WorkspaceItem> children = root.getChildren();
|
|
||||||
|
|
||||||
System.out.println("children size: "+children.size());
|
|
||||||
|
|
||||||
// GWTWorkspaceBuilder builder = new GWTWorkspaceBuilder();
|
|
||||||
//
|
//
|
||||||
// builder.buildGXTListFileGridModelItem(children, null);
|
// Workspace ws = HomeLibrary
|
||||||
|
// .getHomeManagerFactory()
|
||||||
|
// .getHomeManager()
|
||||||
|
// .getHome(TEST_USER)
|
||||||
int i=0;
|
// .getWorkspace();
|
||||||
for (WorkspaceItem workspaceItem : children) {
|
// //
|
||||||
|
//
|
||||||
|
//// System.out.println("start get root");
|
||||||
if(workspaceItem.getType().equals(WorkspaceItemType.FOLDER) || workspaceItem.getType().equals(WorkspaceItemType.SHARED_FOLDER)){
|
// WorkspaceItem folder = ws.getRoot();
|
||||||
|
//// List<WorkspaceItem> children = (List<WorkspaceItem>) root.getChildren();
|
||||||
folder = (WorkspaceFolder) workspaceItem;
|
//
|
||||||
|
// System.out.println("start get children");
|
||||||
|
//
|
||||||
System.out.println(++i+") folder name: "+folder.getName() +", id: "+folder.getId());
|
//// WorkspaceFolder folder = (WorkspaceFolder) ws.getItem(FOLDER_ID);
|
||||||
}else{
|
// List<WorkspaceItem> children = (List<WorkspaceItem>) folder.getChildren();
|
||||||
|
//// List<? extends WorkspaceItem> children = root.getChildren();
|
||||||
|
//
|
||||||
if(workspaceItem.getType().equals(WorkspaceItemType.FOLDER_ITEM)){
|
// System.out.println("children size: "+children.size());
|
||||||
|
//
|
||||||
FolderItem folderItem = (FolderItem) workspaceItem;
|
//// GWTWorkspaceBuilder builder = new GWTWorkspaceBuilder();
|
||||||
|
////
|
||||||
System.out.println(++i+") folderItem id: "+folderItem.getId() +", name: "+folderItem.getName() + ", size: "+folderItem.getLength());
|
//// builder.buildGXTListFileGridModelItem(children, null);
|
||||||
}
|
//
|
||||||
|
//
|
||||||
}
|
//
|
||||||
}
|
// int i=0;
|
||||||
System.out.println("end");
|
// for (WorkspaceItem workspaceItem : children) {
|
||||||
} catch (Exception e) {
|
//
|
||||||
e.printStackTrace();
|
//
|
||||||
}
|
// if(workspaceItem.getType().equals(WorkspaceItemType.FOLDER) || workspaceItem.getType().equals(WorkspaceItemType.SHARED_FOLDER)){
|
||||||
}
|
//
|
||||||
|
// folder = (WorkspaceFolder) workspaceItem;
|
||||||
}
|
//
|
||||||
|
//
|
||||||
|
// System.out.println(++i+") folder name: "+folder.getName() +", id: "+folder.getId());
|
||||||
|
// }else{
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// if(workspaceItem.getType().equals(WorkspaceItemType.FOLDER_ITEM)){
|
||||||
|
//
|
||||||
|
// FolderItem folderItem = (FolderItem) workspaceItem;
|
||||||
|
//
|
||||||
|
// System.out.println(++i+") folderItem id: "+folderItem.getId() +", name: "+folderItem.getName() + ", size: "+folderItem.getLength());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// System.out.println("end");
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//*/
|
|
@ -1,138 +1,137 @@
|
||||||
/**
|
//TODO IT MUST BE MOVED TO SHUB
|
||||||
*
|
///**
|
||||||
*/
|
// *
|
||||||
package org.gcube.portlets.user.workspace;
|
// */
|
||||||
|
//package org.gcube.portlets.user.workspace;
|
||||||
import java.util.ArrayList;
|
//
|
||||||
import java.util.List;
|
//import java.util.ArrayList;
|
||||||
|
//import java.util.List;
|
||||||
import org.apache.log4j.Logger;
|
//
|
||||||
import org.gcube.common.homelibary.model.items.type.FolderItemType;
|
//import org.apache.log4j.Logger;
|
||||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
//import org.gcube.common.homelibary.model.items.type.FolderItemType;
|
||||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
//import org.gcube.common.homelibrary.home.HomeLibrary;
|
||||||
import org.gcube.common.homelibrary.home.workspace.search.SearchItem;
|
//import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
//import org.gcube.common.homelibrary.home.workspace.search.SearchItem;
|
||||||
import org.gcube.common.scope.impl.ScopeBean;
|
//import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.portlets.user.workspace.client.interfaces.GXTCategorySmartFolder;
|
//import org.gcube.common.scope.impl.ScopeBean;
|
||||||
import org.gcube.portlets.user.workspace.client.model.FileGridModel;
|
//import org.gcube.portlets.user.workspace.client.interfaces.GXTCategorySmartFolder;
|
||||||
import org.gcube.portlets.user.workspace.server.GWTWorkspaceBuilder;
|
//import org.gcube.portlets.user.workspace.client.model.FileGridModel;
|
||||||
|
//
|
||||||
/**
|
//
|
||||||
* The Class SmartFolderTest.
|
///**
|
||||||
*
|
// * The Class SmartFolderTest.
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
// *
|
||||||
* Sep 29, 2016
|
// * @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
||||||
*/
|
// * Sep 29, 2016
|
||||||
public class SmartFolderTest {
|
// */
|
||||||
|
///*
|
||||||
|
// *
|
||||||
protected static Logger logger = Logger.getLogger(SmartFolderTest.class);
|
// *
|
||||||
|
// * IT MUST BE MOVED TO SHUB
|
||||||
// public static String DEFAULT_SCOPE = "/d4science.research-infrastructures.eu/gCubeApps/EcologicalModelling"; //PRODUCTION
|
// *
|
||||||
public static String DEFAULT_SCOPE = "/gcube/devsec"; //DEV
|
// *
|
||||||
|
// *
|
||||||
private static Workspace workspace;
|
//public class SmartFolderTest {
|
||||||
|
//
|
||||||
/**
|
//
|
||||||
* The main method.
|
// protected static Logger logger = Logger.getLogger(SmartFolderTest.class);
|
||||||
*
|
//
|
||||||
* @param args the arguments
|
//// public static String DEFAULT_SCOPE = "/d4science.research-infrastructures.eu/gCubeApps/EcologicalModelling"; //PRODUCTION
|
||||||
*/
|
// public static String DEFAULT_SCOPE = "/gcube/devsec"; //DEV
|
||||||
public static void main(String[] args) {
|
//
|
||||||
|
// private static Workspace workspace;
|
||||||
try {
|
//
|
||||||
|
// public static void main(String[] args) {
|
||||||
ScopeBean scope = new ScopeBean(DEFAULT_SCOPE);
|
//
|
||||||
ScopeProvider.instance.set(scope.toString());
|
// try {
|
||||||
|
//
|
||||||
System.out.println("instancing workspace");
|
// ScopeBean scope = new ScopeBean(DEFAULT_SCOPE);
|
||||||
workspace = HomeLibrary
|
// ScopeProvider.instance.set(scope.toString());
|
||||||
.getHomeManagerFactory()
|
//
|
||||||
.getHomeManager()
|
// System.out.println("instancing workspace");
|
||||||
.getHome("francesco.mangiacrapa")
|
// workspace = HomeLibrary
|
||||||
.getWorkspace();
|
// .getHomeManagerFactory()
|
||||||
//
|
// .getHomeManager()
|
||||||
System.out.println("start");
|
// .getHome("francesco.mangiacrapa")
|
||||||
List<FileGridModel> smarts = getSmartFolderResultsByCategory(GXTCategorySmartFolder.SMF_IMAGES);
|
// .getWorkspace();
|
||||||
|
// //
|
||||||
for (FileGridModel fileGridModel : smarts) {
|
// System.out.println("start");
|
||||||
System.out.println(fileGridModel.toString());
|
// List<FileGridModel> smarts = getSmartFolderResultsByCategory(GXTCategorySmartFolder.SMF_IMAGES);
|
||||||
}
|
//
|
||||||
System.out.println("end");
|
// for (FileGridModel fileGridModel : smarts) {
|
||||||
} catch (Exception e) {
|
// System.out.println(fileGridModel.toString());
|
||||||
e.printStackTrace();
|
// }
|
||||||
}
|
// System.out.println("end");
|
||||||
}
|
// } catch (Exception e) {
|
||||||
|
// e.printStackTrace();
|
||||||
/**
|
// }
|
||||||
* Gets the smart folder results by category.
|
// }
|
||||||
*
|
//
|
||||||
* @param category the category
|
//
|
||||||
* @return the smart folder results by category
|
// public static List<FileGridModel> getSmartFolderResultsByCategory(GXTCategorySmartFolder category) throws Exception {
|
||||||
* @throws Exception the exception
|
//
|
||||||
*/
|
// try {
|
||||||
public static List<FileGridModel> getSmartFolderResultsByCategory(GXTCategorySmartFolder category) throws Exception {
|
//
|
||||||
|
//
|
||||||
try {
|
// GWTWorkspaceBuilder builder = new GWTWorkspaceBuilder();
|
||||||
|
//
|
||||||
|
// List<SearchItem> listWorkspaceItems = new ArrayList<SearchItem>();
|
||||||
GWTWorkspaceBuilder builder = new GWTWorkspaceBuilder();
|
//
|
||||||
|
// //Category IMAGES
|
||||||
List<SearchItem> listWorkspaceItems = new ArrayList<SearchItem>();
|
// if(category.equals(GXTCategorySmartFolder.SMF_IMAGES.toString())){
|
||||||
|
//
|
||||||
//Category IMAGES
|
// listWorkspaceItems = workspace.getFolderItems(FolderItemType.IMAGE_DOCUMENT, FolderItemType.EXTERNAL_IMAGE);
|
||||||
if(category.equals(GXTCategorySmartFolder.SMF_IMAGES.toString())){
|
//
|
||||||
|
// //Category BIODIVERSITY
|
||||||
listWorkspaceItems = workspace.getFolderItems(FolderItemType.IMAGE_DOCUMENT, FolderItemType.EXTERNAL_IMAGE);
|
// }else if(category.equals(GXTCategorySmartFolder.SMF_BIODIVERSITY.toString())){
|
||||||
|
//
|
||||||
//Category BIODIVERSITY
|
//// listWorkspaceItems = workspace.getFolderItems(FolderItemType.AQUAMAPS_ITEM);
|
||||||
}else if(category.equals(GXTCategorySmartFolder.SMF_BIODIVERSITY.toString())){
|
//
|
||||||
|
// //Category DOCUMENTS
|
||||||
// listWorkspaceItems = workspace.getFolderItems(FolderItemType.AQUAMAPS_ITEM);
|
// }else if(category.equals(GXTCategorySmartFolder.SMF_DOCUMENTS.toString())){
|
||||||
|
//
|
||||||
//Category DOCUMENTS
|
// listWorkspaceItems = workspace.getFolderItems(
|
||||||
}else if(category.equals(GXTCategorySmartFolder.SMF_DOCUMENTS.toString())){
|
// FolderItemType.EXTERNAL_FILE,
|
||||||
|
// FolderItemType.EXTERNAL_PDF_FILE,
|
||||||
listWorkspaceItems = workspace.getFolderItems(
|
// FolderItemType.QUERY,
|
||||||
FolderItemType.EXTERNAL_FILE,
|
// FolderItemType.PDF_DOCUMENT,
|
||||||
FolderItemType.EXTERNAL_PDF_FILE,
|
// FolderItemType.METADATA,
|
||||||
FolderItemType.QUERY,
|
//// FolderItemType.WORKFLOW_REPORT,
|
||||||
FolderItemType.PDF_DOCUMENT,
|
//// FolderItemType.WORKFLOW_TEMPLATE,
|
||||||
FolderItemType.METADATA,
|
//// FolderItemType.URL_DOCUMENT,
|
||||||
// FolderItemType.WORKFLOW_REPORT,
|
// FolderItemType.DOCUMENT
|
||||||
// FolderItemType.WORKFLOW_TEMPLATE,
|
// );
|
||||||
// FolderItemType.URL_DOCUMENT,
|
//
|
||||||
FolderItemType.DOCUMENT
|
// //Category LINKS
|
||||||
);
|
// }else if(category.equals(GXTCategorySmartFolder.SMF_LINKS.toString())){
|
||||||
|
//
|
||||||
//Category LINKS
|
//// listWorkspaceItems = workspace.getFolderItems(FolderItemType.EXTERNAL_URL, FolderItemType.URL_DOCUMENT, FolderItemType.EXTERNAL_RESOURCE_LINK);
|
||||||
}else if(category.equals(GXTCategorySmartFolder.SMF_LINKS.toString())){
|
//
|
||||||
|
// //Category REPORTS
|
||||||
// listWorkspaceItems = workspace.getFolderItems(FolderItemType.EXTERNAL_URL, FolderItemType.URL_DOCUMENT, FolderItemType.EXTERNAL_RESOURCE_LINK);
|
// }else if(category.equals(GXTCategorySmartFolder.SMF_REPORTS.toString())){
|
||||||
|
//
|
||||||
//Category REPORTS
|
// listWorkspaceItems = workspace.getFolderItems(FolderItemType.REPORT_TEMPLATE, FolderItemType.REPORT);
|
||||||
}else if(category.equals(GXTCategorySmartFolder.SMF_REPORTS.toString())){
|
//
|
||||||
|
// //Category TIME SERIES
|
||||||
listWorkspaceItems = workspace.getFolderItems(FolderItemType.REPORT_TEMPLATE, FolderItemType.REPORT);
|
// }else if(category.equals(GXTCategorySmartFolder.SMF_TIMESERIES.toString())){
|
||||||
|
//
|
||||||
//Category TIME SERIES
|
// listWorkspaceItems = workspace.getFolderItems(FolderItemType.TIME_SERIES);
|
||||||
}else if(category.equals(GXTCategorySmartFolder.SMF_TIMESERIES.toString())){
|
// }
|
||||||
|
// else
|
||||||
listWorkspaceItems = workspace.getFolderItems(FolderItemType.TIME_SERIES);
|
// new Exception("Smart folder category unknown");
|
||||||
}
|
//
|
||||||
else
|
//
|
||||||
new Exception("Smart folder category unknown");
|
// return builder.filterListFileGridModelItemByCategory(listWorkspaceItems, category);
|
||||||
|
//
|
||||||
|
//
|
||||||
return builder.filterListFileGridModelItemByCategory(listWorkspaceItems, category);
|
// } catch (Exception e) {
|
||||||
|
// System.out.println("Error in server get smart folder by category");
|
||||||
|
// e.printStackTrace();
|
||||||
} catch (Exception e) {
|
// throw new Exception(e.getMessage());
|
||||||
System.out.println("Error in server get smart folder by category");
|
// }
|
||||||
e.printStackTrace();
|
//
|
||||||
throw new Exception(e.getMessage());
|
// }
|
||||||
}
|
//
|
||||||
|
//}
|
||||||
}
|
//
|
||||||
|
//*/
|
||||||
}
|
|
||||||
|
|
|
@ -1,207 +1,208 @@
|
||||||
/**
|
//TODO IT MUST BE MOVED TO SHUB
|
||||||
*
|
///**
|
||||||
*/
|
// *
|
||||||
package org.gcube.portlets.user.workspace;
|
// */
|
||||||
|
//package org.gcube.portlets.user.workspace;
|
||||||
import java.util.List;
|
//
|
||||||
import java.util.concurrent.TimeUnit;
|
//import java.util.List;
|
||||||
|
//import java.util.concurrent.TimeUnit;
|
||||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
//
|
||||||
import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
|
//import org.gcube.common.homelibrary.home.HomeLibrary;
|
||||||
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
//import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
|
||||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
//import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
//import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
//import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceSharedFolder;
|
//import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
||||||
import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
|
//import org.gcube.common.homelibrary.home.workspace.WorkspaceSharedFolder;
|
||||||
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
|
//import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
//import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
|
||||||
import org.gcube.common.scope.impl.ScopeBean;
|
//import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
//import org.gcube.common.scope.impl.ScopeBean;
|
||||||
/**
|
//
|
||||||
*
|
///**
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
// *
|
||||||
* Jan 29, 2014
|
// * @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
||||||
*
|
// * Jan 29, 2014
|
||||||
*/
|
// *
|
||||||
public class TestSync {
|
// */
|
||||||
|
//public class TestSync {
|
||||||
public static String DEFAULT_SCOPE = "/gcube/devsec"; //DEV
|
//
|
||||||
public static String TEST_USER = "francesco.mangiacrapa";
|
// public static String DEFAULT_SCOPE = "/gcube/devsec"; //DEV
|
||||||
public static String FOLDER_SYNC = "d6dae663-91d1-4da7-b13d-959de6fb2f86"; //TestSync is root Folder
|
// public static String TEST_USER = "francesco.mangiacrapa";
|
||||||
|
// public static String FOLDER_SYNC = "d6dae663-91d1-4da7-b13d-959de6fb2f86"; //TestSync is root Folder
|
||||||
public static String FOLDER_A = "983d4ab9-e8fd-4c6d-869e-734a730e3e50";
|
//
|
||||||
public static String FOLDER_B = "94995b10-6fcb-4ed8-a3ea-4a6dd7d33a7a";
|
// public static String FOLDER_A = "983d4ab9-e8fd-4c6d-869e-734a730e3e50";
|
||||||
public static String FOLDER_C = "e945fcfd-9da9-45a0-98a9-d1940d1720bb";
|
// public static String FOLDER_B = "94995b10-6fcb-4ed8-a3ea-4a6dd7d33a7a";
|
||||||
|
// public static String FOLDER_C = "e945fcfd-9da9-45a0-98a9-d1940d1720bb";
|
||||||
protected static int i=0;
|
//
|
||||||
protected static int foldersCounter = 0;
|
// protected static int i=0;
|
||||||
protected static int sharedFoldersCounter = 0;
|
// protected static int foldersCounter = 0;
|
||||||
protected static int folderItemCounter = 0;
|
// protected static int sharedFoldersCounter = 0;
|
||||||
protected static int othersCounter = 0;
|
// protected static int folderItemCounter = 0;
|
||||||
|
// protected static int othersCounter = 0;
|
||||||
public static void main(String[] args) {
|
//
|
||||||
|
// public static void main(String[] args) {
|
||||||
ScopeBean scope = new ScopeBean(DEFAULT_SCOPE);
|
//
|
||||||
ScopeProvider.instance.set(scope.toString());
|
// ScopeBean scope = new ScopeBean(DEFAULT_SCOPE);
|
||||||
|
// ScopeProvider.instance.set(scope.toString());
|
||||||
System.out.println("init HL");
|
//
|
||||||
try {
|
// System.out.println("init HL");
|
||||||
|
// try {
|
||||||
Workspace ws = getWorkspace();
|
//
|
||||||
// List<? extends WorkspaceItem> children = ws.getItem(FOLDER_A).getChildren();
|
// Workspace ws = getWorkspace();
|
||||||
|
//// List<? extends WorkspaceItem> children = ws.getItem(FOLDER_A).getChildren();
|
||||||
|
//// for (WorkspaceItem workspaceItem : children) {
|
||||||
|
//// printItem(workspaceItem);
|
||||||
|
//// }
|
||||||
|
// WorkspaceItem item_40MB = ws.getItem(FOLDER_A).getChildren().get(0);
|
||||||
|
// threadCopy(ws, item_40MB, FOLDER_B);
|
||||||
|
//
|
||||||
|
// System.out.println("THREAD MAIN SLEEPING 10 sec.");
|
||||||
|
// Thread.sleep(10000);
|
||||||
|
// System.out.println("THREAD MAIN ACTIVE..");
|
||||||
|
//// WorkspaceItem cp_item_260MB = ws.getItem(FOLDER_B).getChildren().get(0);
|
||||||
|
//
|
||||||
|
// List<? extends WorkspaceItem> children = ws.getItem(FOLDER_B).getChildren();
|
||||||
|
// System.out.println("FOLDER_B children..");
|
||||||
// for (WorkspaceItem workspaceItem : children) {
|
// for (WorkspaceItem workspaceItem : children) {
|
||||||
// printItem(workspaceItem);
|
// printItem(workspaceItem);
|
||||||
// }
|
// }
|
||||||
WorkspaceItem item_40MB = ws.getItem(FOLDER_A).getChildren().get(0);
|
//
|
||||||
threadCopy(ws, item_40MB, FOLDER_B);
|
// threadMove(ws, children.get(0), FOLDER_C);
|
||||||
|
//
|
||||||
System.out.println("THREAD MAIN SLEEPING 10 sec.");
|
// Thread.sleep(60000);
|
||||||
Thread.sleep(10000);
|
// System.out.println("THREAD MAIN TERMINATED");
|
||||||
System.out.println("THREAD MAIN ACTIVE..");
|
//// retrieveFirstLevel(ws);
|
||||||
// WorkspaceItem cp_item_260MB = ws.getItem(FOLDER_B).getChildren().get(0);
|
// }catch(Exception e){
|
||||||
|
// e.printStackTrace();
|
||||||
List<? extends WorkspaceItem> children = ws.getItem(FOLDER_B).getChildren();
|
// }
|
||||||
System.out.println("FOLDER_B children..");
|
// }
|
||||||
for (WorkspaceItem workspaceItem : children) {
|
//
|
||||||
printItem(workspaceItem);
|
// public static void threadCopy(final Workspace ws, final WorkspaceItem item, final String destinationFolderId){
|
||||||
}
|
//
|
||||||
|
// new Thread(){
|
||||||
threadMove(ws, children.get(0), FOLDER_C);
|
// @Override
|
||||||
|
// public void run() {
|
||||||
Thread.sleep(60000);
|
// try {
|
||||||
System.out.println("THREAD MAIN TERMINATED");
|
// long time = System.currentTimeMillis();
|
||||||
// retrieveFirstLevel(ws);
|
// long diff;
|
||||||
}catch(Exception e){
|
// System.out.println("Starting copy "+item.getName()+", time: "+time);
|
||||||
e.printStackTrace();
|
// ws.copy(item.getId(), destinationFolderId);
|
||||||
}
|
// diff = (System.currentTimeMillis()-time)/1000;
|
||||||
}
|
// System.out.println("End copy! [time diff: "+diff+" sec.]");
|
||||||
|
// } catch (Exception e) {
|
||||||
public static void threadCopy(final Workspace ws, final WorkspaceItem item, final String destinationFolderId){
|
// System.out.println("Copy Exception: "+e.getMessage());
|
||||||
|
// }
|
||||||
new Thread(){
|
// }
|
||||||
@Override
|
// }.start();
|
||||||
public void run() {
|
// }
|
||||||
try {
|
//
|
||||||
long time = System.currentTimeMillis();
|
//
|
||||||
long diff;
|
// public static void threadMove(final Workspace ws, final WorkspaceItem item, final String destinationFolderId){
|
||||||
System.out.println("Starting copy "+item.getName()+", time: "+time);
|
//
|
||||||
ws.copy(item.getId(), destinationFolderId);
|
// new Thread(){
|
||||||
diff = (System.currentTimeMillis()-time)/1000;
|
// @Override
|
||||||
System.out.println("End copy! [time diff: "+diff+" sec.]");
|
// public void run() {
|
||||||
} catch (Exception e) {
|
// try {
|
||||||
System.out.println("Copy Exception: "+e.getMessage());
|
// long time = System.currentTimeMillis();
|
||||||
}
|
// long diff;
|
||||||
}
|
// System.out.println("Starting move "+item.getName()+", time: "+time);
|
||||||
}.start();
|
// ws.moveItem(item.getId(), destinationFolderId);
|
||||||
}
|
// diff = (System.currentTimeMillis()-time)/1000;
|
||||||
|
// System.out.println("End move! [time diff: "+diff+" sec.]");
|
||||||
|
// } catch (Exception e) {
|
||||||
public static void threadMove(final Workspace ws, final WorkspaceItem item, final String destinationFolderId){
|
// System.out.println("Move Exception: "+e.getMessage());
|
||||||
|
// }
|
||||||
new Thread(){
|
// }
|
||||||
@Override
|
// }.start();
|
||||||
public void run() {
|
// }
|
||||||
try {
|
//
|
||||||
long time = System.currentTimeMillis();
|
// public static Workspace getWorkspace() throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException
|
||||||
long diff;
|
// {
|
||||||
System.out.println("Starting move "+item.getName()+", time: "+time);
|
//
|
||||||
ws.moveItem(item.getId(), destinationFolderId);
|
// System.out.println("Get Workspace scope: "+DEFAULT_SCOPE + " username: "+TEST_USER);
|
||||||
diff = (System.currentTimeMillis()-time)/1000;
|
// ScopeProvider.instance.set(DEFAULT_SCOPE);
|
||||||
System.out.println("End move! [time diff: "+diff+" sec.]");
|
// Workspace workspace = HomeLibrary.getUserWorkspace(TEST_USER);
|
||||||
} catch (Exception e) {
|
// return workspace;
|
||||||
System.out.println("Move Exception: "+e.getMessage());
|
// }
|
||||||
}
|
//
|
||||||
}
|
//
|
||||||
}.start();
|
// private static void retrieveFirstLevel(Workspace ws){
|
||||||
}
|
//
|
||||||
|
// try {
|
||||||
public static Workspace getWorkspace() throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException
|
//
|
||||||
{
|
// //TEST TIME
|
||||||
|
// Long startTime = System.currentTimeMillis();
|
||||||
System.out.println("Get Workspace scope: "+DEFAULT_SCOPE + " username: "+TEST_USER);
|
// Long endTime = System.currentTimeMillis() - startTime;
|
||||||
ScopeProvider.instance.set(DEFAULT_SCOPE);
|
// String time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime));
|
||||||
Workspace workspace = HomeLibrary.getUserWorkspace(TEST_USER);
|
//
|
||||||
return workspace;
|
// startTime = System.currentTimeMillis();
|
||||||
}
|
// System.out.println("Start get root at time: "+startTime);
|
||||||
|
//// WorkspaceItem root = ws.getItem(ITEMID);
|
||||||
|
// WorkspaceItem root = ws.getRoot();
|
||||||
private static void retrieveFirstLevel(Workspace ws){
|
//
|
||||||
|
// System.out.println("start get children");
|
||||||
try {
|
// List<? extends WorkspaceItem> children = root.getChildren();
|
||||||
|
// System.out.println("tree getChildren() returning "+children.size()+" elements in " + time);
|
||||||
//TEST TIME
|
//
|
||||||
Long startTime = System.currentTimeMillis();
|
// System.out.println("children size: "+children.size());
|
||||||
Long endTime = System.currentTimeMillis() - startTime;
|
//
|
||||||
String time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime));
|
//
|
||||||
|
// for (WorkspaceItem workspaceItem : children) {
|
||||||
startTime = System.currentTimeMillis();
|
// printItem(workspaceItem);
|
||||||
System.out.println("Start get root at time: "+startTime);
|
// }
|
||||||
// WorkspaceItem root = ws.getItem(ITEMID);
|
//
|
||||||
WorkspaceItem root = ws.getRoot();
|
// //TEST TIME
|
||||||
|
// endTime = System.currentTimeMillis();
|
||||||
System.out.println("start get children");
|
// long difference = endTime - startTime;
|
||||||
List<? extends WorkspaceItem> children = root.getChildren();
|
// time = String.format("%d msc %d sec", difference, TimeUnit.MILLISECONDS.toSeconds(difference));
|
||||||
System.out.println("tree getChildren() returning "+children.size()+" elements in " + time);
|
// System.out.println("End time is "+endTime+ " difference is "+time);
|
||||||
|
// System.out.println("Folders are: "+foldersCounter);
|
||||||
System.out.println("children size: "+children.size());
|
// System.out.println("Shared Folders are: "+sharedFoldersCounter);
|
||||||
|
// System.out.println("Folder Item are: "+folderItemCounter);
|
||||||
|
// System.out.println("Others are: "+othersCounter);
|
||||||
for (WorkspaceItem workspaceItem : children) {
|
// } catch (Exception e) {
|
||||||
printItem(workspaceItem);
|
// e.printStackTrace();
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
//TEST TIME
|
//
|
||||||
endTime = System.currentTimeMillis();
|
// public static void printItem(WorkspaceItem workspaceItem) throws InternalErrorException{
|
||||||
long difference = endTime - startTime;
|
//
|
||||||
time = String.format("%d msc %d sec", difference, TimeUnit.MILLISECONDS.toSeconds(difference));
|
// switch (workspaceItem.getType()) {
|
||||||
System.out.println("End time is "+endTime+ " difference is "+time);
|
//
|
||||||
System.out.println("Folders are: "+foldersCounter);
|
// case FOLDER:
|
||||||
System.out.println("Shared Folders are: "+sharedFoldersCounter);
|
//
|
||||||
System.out.println("Folder Item are: "+folderItemCounter);
|
// WorkspaceFolder folder = (WorkspaceFolder) workspaceItem;
|
||||||
System.out.println("Others are: "+othersCounter);
|
//
|
||||||
} catch (Exception e) {
|
// System.out.println(++i+") "+folder.getId() +" folder name: "+folder.getName() + " owner "+folder.getOwner());
|
||||||
e.printStackTrace();
|
// foldersCounter++;
|
||||||
}
|
//
|
||||||
}
|
// break;
|
||||||
|
//
|
||||||
public static void printItem(WorkspaceItem workspaceItem) throws InternalErrorException{
|
// case SHARED_FOLDER:
|
||||||
|
//
|
||||||
switch (workspaceItem.getType()) {
|
// WorkspaceSharedFolder shared = (WorkspaceSharedFolder) workspaceItem;
|
||||||
|
//
|
||||||
case FOLDER:
|
// System.out.println(++i+") "+shared.getId() +" shared folder name: "+shared.getName() + " owner "+shared.getOwner()+" isVRE "+shared.isVreFolder() +" ACLOwner: "+shared.getACLOwner()+" AclUser: "+shared.getACLUser());
|
||||||
|
//
|
||||||
WorkspaceFolder folder = (WorkspaceFolder) workspaceItem;
|
//// System.out.println(++i+") shared folder name: "+shared.getName() + " owner "+shared.getOwner().getPortalLogin());
|
||||||
|
// sharedFoldersCounter++;
|
||||||
System.out.println(++i+") "+folder.getId() +" folder name: "+folder.getName() + " owner "+folder.getOwner());
|
//
|
||||||
foldersCounter++;
|
// break;
|
||||||
|
//
|
||||||
break;
|
// case FOLDER_ITEM:
|
||||||
|
//
|
||||||
case SHARED_FOLDER:
|
// FolderItem folderItem = (FolderItem) workspaceItem;
|
||||||
|
//
|
||||||
WorkspaceSharedFolder shared = (WorkspaceSharedFolder) workspaceItem;
|
// System.out.println(++i+") folderItem id: "+folderItem.getId() +", name: "+folderItem.getName() + ", own: "+folderItem.getOwner());
|
||||||
|
// folderItemCounter++;
|
||||||
System.out.println(++i+") "+shared.getId() +" shared folder name: "+shared.getName() + " owner "+shared.getOwner()+" isVRE "+shared.isVreFolder() +" ACLOwner: "+shared.getACLOwner()+" AclUser: "+shared.getACLUser());
|
//
|
||||||
|
// break;
|
||||||
// System.out.println(++i+") shared folder name: "+shared.getName() + " owner "+shared.getOwner().getPortalLogin());
|
// default:
|
||||||
sharedFoldersCounter++;
|
// System.out.println(++i+") DEFAULT - item id: "+workspaceItem.getId() +", name: "+workspaceItem.getName() + ", own: "+workspaceItem.getOwner());
|
||||||
|
// othersCounter++;
|
||||||
break;
|
// break;
|
||||||
|
// }
|
||||||
case FOLDER_ITEM:
|
//
|
||||||
|
// }
|
||||||
FolderItem folderItem = (FolderItem) workspaceItem;
|
//}
|
||||||
|
|
||||||
System.out.println(++i+") folderItem id: "+folderItem.getId() +", name: "+folderItem.getName() + ", own: "+folderItem.getOwner());
|
|
||||||
folderItemCounter++;
|
|
||||||
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
System.out.println(++i+") DEFAULT - item id: "+workspaceItem.getId() +", name: "+workspaceItem.getName() + ", own: "+workspaceItem.getOwner());
|
|
||||||
othersCounter++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,76 +1,77 @@
|
||||||
/**
|
////TODO IT MUST BE MOVED TO SHUB
|
||||||
*
|
///**
|
||||||
*/
|
// *
|
||||||
package org.gcube.portlets.user.workspace;
|
// */
|
||||||
|
//package org.gcube.portlets.user.workspace;
|
||||||
import java.util.List;
|
//
|
||||||
|
//import java.util.List;
|
||||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
//
|
||||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
//import org.gcube.common.homelibrary.home.HomeLibrary;
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
//import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
//import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
//import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
||||||
import org.junit.Test;
|
//import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
//import org.junit.Test;
|
||||||
/**
|
//
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
///**
|
||||||
* May 15, 2014
|
// * @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
||||||
*
|
// * May 15, 2014
|
||||||
*/
|
// *
|
||||||
public class TestWithTime {
|
// */
|
||||||
|
//public class TestWithTime {
|
||||||
public static String DEFAULT_SCOPE = "/gcube/devsec"; //DEV
|
//
|
||||||
public static String TEST_USER = "fabio.simeoni";
|
// public static String DEFAULT_SCOPE = "/gcube/devsec"; //DEV
|
||||||
|
// public static String TEST_USER = "fabio.simeoni";
|
||||||
@Test
|
//
|
||||||
public void accessTest() throws Exception {
|
// @Test
|
||||||
|
// public void accessTest() throws Exception {
|
||||||
ScopeProvider.instance.set(DEFAULT_SCOPE);
|
//
|
||||||
System.out.println("Start Test Simeoni");
|
// ScopeProvider.instance.set(DEFAULT_SCOPE);
|
||||||
long time = System.currentTimeMillis();
|
// System.out.println("Start Test Simeoni");
|
||||||
|
// long time = System.currentTimeMillis();
|
||||||
Workspace ws = HomeLibrary.getUserWorkspace(TEST_USER);
|
//
|
||||||
|
// Workspace ws = HomeLibrary.getUserWorkspace(TEST_USER);
|
||||||
for (WorkspaceItem item : ws.getRoot().getChildren())
|
//
|
||||||
item.getProperties().getProperties().keySet();
|
// for (WorkspaceItem item : ws.getRoot().getChildren())
|
||||||
|
// item.getProperties().getProperties().keySet();
|
||||||
long diff = System.currentTimeMillis()-time;
|
//
|
||||||
System.out.println("End Test Simeoni: "+diff);
|
// long diff = System.currentTimeMillis()-time;
|
||||||
}
|
// System.out.println("End Test Simeoni: "+diff);
|
||||||
|
// }
|
||||||
@Test
|
//
|
||||||
public void accessTest1() throws Exception {
|
// @Test
|
||||||
|
// public void accessTest1() throws Exception {
|
||||||
ScopeProvider.instance.set(DEFAULT_SCOPE);
|
//
|
||||||
|
// ScopeProvider.instance.set(DEFAULT_SCOPE);
|
||||||
System.out.println("Start Test");
|
//
|
||||||
long time = System.currentTimeMillis();
|
// System.out.println("Start Test");
|
||||||
long diff;
|
// long time = System.currentTimeMillis();
|
||||||
|
// long diff;
|
||||||
System.out.println("Get worskpace");
|
//
|
||||||
Workspace ws = HomeLibrary.getUserWorkspace(TEST_USER);
|
// System.out.println("Get worskpace");
|
||||||
diff = System.currentTimeMillis()-time;
|
// Workspace ws = HomeLibrary.getUserWorkspace(TEST_USER);
|
||||||
System.out.println("Worskapce returned in: "+diff);
|
// diff = System.currentTimeMillis()-time;
|
||||||
|
// System.out.println("Worskapce returned in: "+diff);
|
||||||
System.out.println("Get Root");
|
//
|
||||||
WorkspaceFolder root = ws.getRoot();
|
// System.out.println("Get Root");
|
||||||
diff = System.currentTimeMillis()-time;
|
// WorkspaceFolder root = ws.getRoot();
|
||||||
System.out.println("Root returned in: "+diff);
|
// diff = System.currentTimeMillis()-time;
|
||||||
|
// System.out.println("Root returned in: "+diff);
|
||||||
System.out.println("Get Children");
|
//
|
||||||
List<WorkspaceItem> children = root.getChildren();
|
// System.out.println("Get Children");
|
||||||
diff = System.currentTimeMillis()-time;
|
// List<WorkspaceItem> children = root.getChildren();
|
||||||
System.out.println("Get Children returned in: "+diff);
|
// diff = System.currentTimeMillis()-time;
|
||||||
|
// System.out.println("Get Children returned in: "+diff);
|
||||||
System.out.println("Children size is: "+children.size());
|
//
|
||||||
for (WorkspaceItem item : children){
|
// System.out.println("Children size is: "+children.size());
|
||||||
diff = System.currentTimeMillis()-time;
|
// for (WorkspaceItem item : children){
|
||||||
System.out.println("Item: +"+item.getId()+", keyset: "+item.getProperties().getProperties().keySet() + ", Diff is: "+diff);
|
// diff = System.currentTimeMillis()-time;
|
||||||
}
|
// System.out.println("Item: +"+item.getId()+", keyset: "+item.getProperties().getProperties().keySet() + ", Diff is: "+diff);
|
||||||
diff = System.currentTimeMillis()-time;
|
// }
|
||||||
System.out.println("Children properties returned in: "+diff);
|
// diff = System.currentTimeMillis()-time;
|
||||||
|
// System.out.println("Children properties returned in: "+diff);
|
||||||
diff = System.currentTimeMillis()-time;
|
//
|
||||||
System.out.println("End test: "+diff);
|
// diff = System.currentTimeMillis()-time;
|
||||||
}
|
// System.out.println("End test: "+diff);
|
||||||
}
|
// }
|
||||||
|
//}
|
||||||
|
|
|
@ -1,137 +1,138 @@
|
||||||
/**
|
//TODO IT MUST BE MOVED TO SHUB
|
||||||
*
|
///**
|
||||||
*/
|
// *
|
||||||
package org.gcube.portlets.user.workspace;
|
// */
|
||||||
|
//package org.gcube.portlets.user.workspace;
|
||||||
import java.io.File;
|
//
|
||||||
import java.io.FileInputStream;
|
//import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
//import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
//import java.io.FileOutputStream;
|
||||||
import java.io.InputStream;
|
//import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
//import java.io.InputStream;
|
||||||
|
//import java.io.OutputStream;
|
||||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
//
|
||||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
//import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||||
import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
|
//import org.gcube.common.homelibrary.home.HomeLibrary;
|
||||||
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
//import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
|
||||||
import org.gcube.common.homelibrary.home.exceptions.UserNotFoundException;
|
//import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
||||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
//import org.gcube.common.homelibrary.home.exceptions.UserNotFoundException;
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
//import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||||
import org.gcube.common.homelibrary.home.workspace.exceptions.InsufficientPrivilegesException;
|
//import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
||||||
import org.gcube.common.homelibrary.home.workspace.exceptions.ItemAlreadyExistException;
|
//import org.gcube.common.homelibrary.home.workspace.exceptions.InsufficientPrivilegesException;
|
||||||
import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
|
//import org.gcube.common.homelibrary.home.workspace.exceptions.ItemAlreadyExistException;
|
||||||
import org.gcube.common.homelibrary.home.workspace.exceptions.WrongDestinationException;
|
//import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
|
||||||
import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalFile;
|
//import org.gcube.common.homelibrary.home.workspace.exceptions.WrongDestinationException;
|
||||||
import org.gcube.common.homelibrary.util.WorkspaceUtil;
|
//import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalFile;
|
||||||
import org.gcube.common.scope.impl.ScopeBean;
|
//import org.gcube.common.homelibrary.util.WorkspaceUtil;
|
||||||
|
//import org.gcube.common.scope.impl.ScopeBean;
|
||||||
|
//
|
||||||
/**
|
//
|
||||||
* The Class UploadServletTest.
|
///**
|
||||||
*
|
// * The Class UploadServletTest.
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
// *
|
||||||
* Jul 23, 2018
|
// * @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
||||||
*/
|
// * Jul 23, 2018
|
||||||
public class UploadServletTest {
|
// */
|
||||||
|
//public class UploadServletTest {
|
||||||
|
//
|
||||||
public static String YOUR_TOKEN = "YOUR TOKEN";
|
//
|
||||||
public static String YOUR_USERNAME = "name.surname";
|
// public static String YOUR_TOKEN = "YOUR TOKEN";
|
||||||
|
// public static String YOUR_USERNAME = "name.surname";
|
||||||
/**
|
//
|
||||||
* The main method.
|
// /**
|
||||||
*
|
// * The main method.
|
||||||
* @param args the arguments
|
// *
|
||||||
* @throws InternalErrorException the internal error exception
|
// * @param args the arguments
|
||||||
* @throws WorkspaceFolderNotFoundException the workspace folder not found exception
|
// * @throws InternalErrorException the internal error exception
|
||||||
* @throws HomeNotFoundException the home not found exception
|
// * @throws WorkspaceFolderNotFoundException the workspace folder not found exception
|
||||||
* @throws UserNotFoundException the user not found exception
|
// * @throws HomeNotFoundException the home not found exception
|
||||||
* @throws InsufficientPrivilegesException the insufficient privileges exception
|
// * @throws UserNotFoundException the user not found exception
|
||||||
* @throws ItemAlreadyExistException the item already exist exception
|
// * @throws InsufficientPrivilegesException the insufficient privileges exception
|
||||||
* @throws WrongDestinationException the wrong destination exception
|
// * @throws ItemAlreadyExistException the item already exist exception
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
// * @throws WrongDestinationException the wrong destination exception
|
||||||
*/
|
// * @throws IOException Signals that an I/O exception has occurred.
|
||||||
public static void main(String[] args) throws InternalErrorException,
|
// */
|
||||||
WorkspaceFolderNotFoundException, HomeNotFoundException,
|
// public static void main(String[] args) throws InternalErrorException,
|
||||||
UserNotFoundException, InsufficientPrivilegesException,
|
// WorkspaceFolderNotFoundException, HomeNotFoundException,
|
||||||
ItemAlreadyExistException, WrongDestinationException, IOException {
|
// UserNotFoundException, InsufficientPrivilegesException,
|
||||||
|
// ItemAlreadyExistException, WrongDestinationException, IOException {
|
||||||
ScopeBean scope = new ScopeBean("/gcube/devsec");
|
//
|
||||||
|
// ScopeBean scope = new ScopeBean("/gcube/devsec");
|
||||||
|
//
|
||||||
SecurityTokenProvider.instance.set("YOUR TOKEN");
|
//
|
||||||
|
// SecurityTokenProvider.instance.set("YOUR TOKEN");
|
||||||
Workspace workspace = HomeLibrary.getHomeManagerFactory()
|
//
|
||||||
.getHomeManager().getHome(YOUR_USERNAME)
|
// Workspace workspace = HomeLibrary.getHomeManagerFactory()
|
||||||
.getWorkspace();
|
// .getHomeManager().getHome(YOUR_USERNAME)
|
||||||
|
// .getWorkspace();
|
||||||
String filePath = "/home/francesco-mangiacrapa";
|
//
|
||||||
|
// String filePath = "/home/francesco-mangiacrapa";
|
||||||
String fileName = "Geo Explorer 2016-01-15 18-51-51.png";
|
//
|
||||||
|
// String fileName = "Geo Explorer 2016-01-15 18-51-51.png";
|
||||||
String fullPath = filePath + "/" + fileName;
|
//
|
||||||
|
// String fullPath = filePath + "/" + fileName;
|
||||||
// String newFilePath =
|
//
|
||||||
// "/home/francesco-mangiacrapa/Desktop/icongeoexplorer/testupload.txt";
|
// // String newFilePath =
|
||||||
|
// // "/home/francesco-mangiacrapa/Desktop/icongeoexplorer/testupload.txt";
|
||||||
// String name = "TestReplaceContentImage";
|
//
|
||||||
|
// // String name = "TestReplaceContentImage";
|
||||||
// ExternalPDFFile file = workspace.createExternalPDFFile(name, "",
|
//
|
||||||
// null, new FileInputStream(new File(filePath)),
|
// // ExternalPDFFile file = workspace.createExternalPDFFile(name, "",
|
||||||
// workspace.getRoot().getId());
|
// // null, new FileInputStream(new File(filePath)),
|
||||||
|
// // workspace.getRoot().getId());
|
||||||
WorkspaceFolder root = workspace.getRoot();
|
//
|
||||||
// ExternalImage file = (ExternalImage) root.find(name);
|
// WorkspaceFolder root = workspace.getRoot();
|
||||||
|
// // ExternalImage file = (ExternalImage) root.find(name);
|
||||||
// UPLOAD FILE
|
//
|
||||||
// String contentType = MimeTypeUtil.getMimeType(fileName, new BufferedInputStream(
|
// // UPLOAD FILE
|
||||||
// new FileInputStream(new File(fullPath))));
|
//// String contentType = MimeTypeUtil.getMimeType(fileName, new BufferedInputStream(
|
||||||
|
//// new FileInputStream(new File(fullPath))));
|
||||||
String itemName = WorkspaceUtil.getUniqueName(fileName, root);
|
//
|
||||||
System.out.println("Storing data....");
|
// String itemName = WorkspaceUtil.getUniqueName(fileName, root);
|
||||||
System.out.println("content type " + null);
|
// System.out.println("Storing data....");
|
||||||
System.out.println("itemName " + itemName);
|
// System.out.println("content type " + null);
|
||||||
|
// System.out.println("itemName " + itemName);
|
||||||
ExternalFile file = (ExternalFile) WorkspaceUtil.createExternalFile(
|
//
|
||||||
root, itemName, "", null, new FileInputStream(new File(
|
// ExternalFile file = (ExternalFile) WorkspaceUtil.createExternalFile(
|
||||||
fullPath)));
|
// root, itemName, "", null, new FileInputStream(new File(
|
||||||
|
// fullPath)));
|
||||||
System.out.println("Storing data - OK" + "File [id: " + file.getId()
|
//
|
||||||
+ ", name: " + file.getName() + "]");
|
// System.out.println("Storing data - OK" + "File [id: " + file.getId()
|
||||||
//
|
// + ", name: " + file.getName() + "]");
|
||||||
// System.out.println("File mimeType" + file.getMimeType());
|
// //
|
||||||
// System.out.println("File size" + file.getLength());
|
// // System.out.println("File mimeType" + file.getMimeType());
|
||||||
//
|
// // System.out.println("File size" + file.getLength());
|
||||||
|
// //
|
||||||
//
|
//
|
||||||
// file.setData(new FileInputStream(new File(newFilePath)));
|
// //
|
||||||
// System.out.println("New File mimeType" + file.getMimeType());
|
// // file.setData(new FileInputStream(new File(newFilePath)));
|
||||||
// System.out.println("New File size" + file.getLength());
|
// // System.out.println("New File mimeType" + file.getMimeType());
|
||||||
|
// // System.out.println("New File size" + file.getLength());
|
||||||
//
|
//
|
||||||
|
// //
|
||||||
System.out.println("Recovering data");
|
//
|
||||||
InputStream inputStream = file.getData();
|
// System.out.println("Recovering data");
|
||||||
// write the inputStream to a FileOutputStream
|
// InputStream inputStream = file.getData();
|
||||||
OutputStream out = new FileOutputStream(new File(
|
// // write the inputStream to a FileOutputStream
|
||||||
"/home/francesco-mangiacrapa/Desktop/download/"+fileName));
|
// OutputStream out = new FileOutputStream(new File(
|
||||||
|
// "/home/francesco-mangiacrapa/Desktop/download/"+fileName));
|
||||||
int read = 0;
|
//
|
||||||
byte[] bytes = new byte[1024];
|
// int read = 0;
|
||||||
|
// byte[] bytes = new byte[1024];
|
||||||
while ((read = inputStream.read(bytes)) != -1) {
|
//
|
||||||
out.write(bytes, 0, read);
|
// while ((read = inputStream.read(bytes)) != -1) {
|
||||||
}
|
// out.write(bytes, 0, read);
|
||||||
|
// }
|
||||||
inputStream.close();
|
//
|
||||||
out.flush();
|
// inputStream.close();
|
||||||
out.close();
|
// out.flush();
|
||||||
|
// out.close();
|
||||||
System.out.println("Recovering data - OK");
|
//
|
||||||
|
// System.out.println("Recovering data - OK");
|
||||||
// File file = new File("/home/gioia/Desktop/test");
|
//
|
||||||
// InputStream is = new FileInputStream(file);
|
// // File file = new File("/home/gioia/Desktop/test");
|
||||||
|
// // InputStream is = new FileInputStream(file);
|
||||||
}
|
//
|
||||||
|
// }
|
||||||
}
|
//
|
||||||
|
//}
|
||||||
|
|
|
@ -1,116 +1,117 @@
|
||||||
/**
|
////TODO IT MUST BE MOVED TO SHUB
|
||||||
*
|
///**
|
||||||
*/
|
// *
|
||||||
package org.gcube.portlets.user.workspace;
|
// */
|
||||||
|
//package org.gcube.portlets.user.workspace;
|
||||||
import java.io.File;
|
//
|
||||||
import java.io.FileInputStream;
|
//import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
//import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
//import java.io.FileOutputStream;
|
||||||
import java.io.InputStream;
|
//import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
//import java.io.InputStream;
|
||||||
|
//import java.io.OutputStream;
|
||||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
//
|
||||||
import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
|
//import org.gcube.common.homelibrary.home.HomeLibrary;
|
||||||
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
//import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
|
||||||
import org.gcube.common.homelibrary.home.exceptions.UserNotFoundException;
|
//import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
||||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
//import org.gcube.common.homelibrary.home.exceptions.UserNotFoundException;
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
//import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||||
import org.gcube.common.homelibrary.home.workspace.exceptions.InsufficientPrivilegesException;
|
//import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
||||||
import org.gcube.common.homelibrary.home.workspace.exceptions.ItemAlreadyExistException;
|
//import org.gcube.common.homelibrary.home.workspace.exceptions.InsufficientPrivilegesException;
|
||||||
import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
|
//import org.gcube.common.homelibrary.home.workspace.exceptions.ItemAlreadyExistException;
|
||||||
import org.gcube.common.homelibrary.home.workspace.exceptions.WrongDestinationException;
|
//import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
|
||||||
import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalFile;
|
//import org.gcube.common.homelibrary.home.workspace.exceptions.WrongDestinationException;
|
||||||
import org.gcube.common.homelibrary.util.WorkspaceUtil;
|
//import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalFile;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
//import org.gcube.common.homelibrary.util.WorkspaceUtil;
|
||||||
import org.gcube.common.scope.impl.ScopeBean;
|
//import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
//import org.gcube.common.scope.impl.ScopeBean;
|
||||||
/**
|
//
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
///**
|
||||||
* Jun 20, 2013
|
// * @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
||||||
*
|
// * Jun 20, 2013
|
||||||
*/
|
// *
|
||||||
public class UploadServletTestToken {
|
// */
|
||||||
|
//public class UploadServletTestToken {
|
||||||
public static void main(String[] args) throws InternalErrorException,
|
//
|
||||||
WorkspaceFolderNotFoundException, HomeNotFoundException,
|
// public static void main(String[] args) throws InternalErrorException,
|
||||||
UserNotFoundException, InsufficientPrivilegesException,
|
// WorkspaceFolderNotFoundException, HomeNotFoundException,
|
||||||
ItemAlreadyExistException, WrongDestinationException, IOException {
|
// UserNotFoundException, InsufficientPrivilegesException,
|
||||||
|
// ItemAlreadyExistException, WrongDestinationException, IOException {
|
||||||
ScopeBean scope = new ScopeBean("/gcube/devsec");
|
//
|
||||||
ScopeProvider.instance.set(scope.toString());
|
// ScopeBean scope = new ScopeBean("/gcube/devsec");
|
||||||
|
// ScopeProvider.instance.set(scope.toString());
|
||||||
Workspace workspace = HomeLibrary.getHomeManagerFactory()
|
//
|
||||||
.getHomeManager().getHome("francesco.mangiacrapa")
|
// Workspace workspace = HomeLibrary.getHomeManagerFactory()
|
||||||
.getWorkspace();
|
// .getHomeManager().getHome("francesco.mangiacrapa")
|
||||||
|
// .getWorkspace();
|
||||||
String filePath = "/home/francesco-mangiacrapa";
|
//
|
||||||
|
// String filePath = "/home/francesco-mangiacrapa";
|
||||||
String fileName = "Geo Explorer 2016-01-15 18-51-51.png";
|
//
|
||||||
|
// String fileName = "Geo Explorer 2016-01-15 18-51-51.png";
|
||||||
String fullPath = filePath + "/" + fileName;
|
//
|
||||||
|
// String fullPath = filePath + "/" + fileName;
|
||||||
// String newFilePath =
|
//
|
||||||
// "/home/francesco-mangiacrapa/Desktop/icongeoexplorer/testupload.txt";
|
// // String newFilePath =
|
||||||
|
// // "/home/francesco-mangiacrapa/Desktop/icongeoexplorer/testupload.txt";
|
||||||
// String name = "TestReplaceContentImage";
|
//
|
||||||
|
// // String name = "TestReplaceContentImage";
|
||||||
// ExternalPDFFile file = workspace.createExternalPDFFile(name, "",
|
//
|
||||||
// null, new FileInputStream(new File(filePath)),
|
// // ExternalPDFFile file = workspace.createExternalPDFFile(name, "",
|
||||||
// workspace.getRoot().getId());
|
// // null, new FileInputStream(new File(filePath)),
|
||||||
|
// // workspace.getRoot().getId());
|
||||||
WorkspaceFolder root = workspace.getRoot();
|
//
|
||||||
// ExternalImage file = (ExternalImage) root.find(name);
|
// WorkspaceFolder root = workspace.getRoot();
|
||||||
|
// // ExternalImage file = (ExternalImage) root.find(name);
|
||||||
// UPLOAD FILE
|
//
|
||||||
// String contentType = MimeTypeUtil.getMimeType(fileName, new BufferedInputStream(
|
// // UPLOAD FILE
|
||||||
// new FileInputStream(new File(fullPath))));
|
//// String contentType = MimeTypeUtil.getMimeType(fileName, new BufferedInputStream(
|
||||||
|
//// new FileInputStream(new File(fullPath))));
|
||||||
String itemName = WorkspaceUtil.getUniqueName(fileName, root);
|
//
|
||||||
System.out.println("Storing data....");
|
// String itemName = WorkspaceUtil.getUniqueName(fileName, root);
|
||||||
System.out.println("content type " + null);
|
// System.out.println("Storing data....");
|
||||||
System.out.println("itemName " + itemName);
|
// System.out.println("content type " + null);
|
||||||
|
// System.out.println("itemName " + itemName);
|
||||||
ExternalFile file = (ExternalFile) WorkspaceUtil.createExternalFile(
|
//
|
||||||
root, itemName, "", null, new FileInputStream(new File(
|
// ExternalFile file = (ExternalFile) WorkspaceUtil.createExternalFile(
|
||||||
fullPath)));
|
// root, itemName, "", null, new FileInputStream(new File(
|
||||||
|
// fullPath)));
|
||||||
System.out.println("Storing data - OK" + "File [id: " + file.getId()
|
//
|
||||||
+ ", name: " + file.getName() + "]");
|
// System.out.println("Storing data - OK" + "File [id: " + file.getId()
|
||||||
//
|
// + ", name: " + file.getName() + "]");
|
||||||
// System.out.println("File mimeType" + file.getMimeType());
|
// //
|
||||||
// System.out.println("File size" + file.getLength());
|
// // System.out.println("File mimeType" + file.getMimeType());
|
||||||
//
|
// // System.out.println("File size" + file.getLength());
|
||||||
|
// //
|
||||||
//
|
//
|
||||||
// file.setData(new FileInputStream(new File(newFilePath)));
|
// //
|
||||||
// System.out.println("New File mimeType" + file.getMimeType());
|
// // file.setData(new FileInputStream(new File(newFilePath)));
|
||||||
// System.out.println("New File size" + file.getLength());
|
// // System.out.println("New File mimeType" + file.getMimeType());
|
||||||
|
// // System.out.println("New File size" + file.getLength());
|
||||||
//
|
//
|
||||||
|
// //
|
||||||
System.out.println("Recovering data");
|
//
|
||||||
InputStream inputStream = file.getData();
|
// System.out.println("Recovering data");
|
||||||
// write the inputStream to a FileOutputStream
|
// InputStream inputStream = file.getData();
|
||||||
OutputStream out = new FileOutputStream(new File(
|
// // write the inputStream to a FileOutputStream
|
||||||
"/home/francesco-mangiacrapa/Desktop/download/"+fileName));
|
// OutputStream out = new FileOutputStream(new File(
|
||||||
|
// "/home/francesco-mangiacrapa/Desktop/download/"+fileName));
|
||||||
int read = 0;
|
//
|
||||||
byte[] bytes = new byte[1024];
|
// int read = 0;
|
||||||
|
// byte[] bytes = new byte[1024];
|
||||||
while ((read = inputStream.read(bytes)) != -1) {
|
//
|
||||||
out.write(bytes, 0, read);
|
// while ((read = inputStream.read(bytes)) != -1) {
|
||||||
}
|
// out.write(bytes, 0, read);
|
||||||
|
// }
|
||||||
inputStream.close();
|
//
|
||||||
out.flush();
|
// inputStream.close();
|
||||||
out.close();
|
// out.flush();
|
||||||
|
// out.close();
|
||||||
System.out.println("Recovering data - OK");
|
//
|
||||||
|
// System.out.println("Recovering data - OK");
|
||||||
// File file = new File("/home/gioia/Desktop/test");
|
//
|
||||||
// InputStream is = new FileInputStream(file);
|
// // File file = new File("/home/gioia/Desktop/test");
|
||||||
|
// // InputStream is = new FileInputStream(file);
|
||||||
}
|
//
|
||||||
|
// }
|
||||||
}
|
//
|
||||||
|
//}
|
||||||
|
|
|
@ -1,248 +1,242 @@
|
||||||
/**
|
//TODO IT MUST BE MOVED TO SHUB
|
||||||
*
|
///**
|
||||||
*/
|
// *
|
||||||
package org.gcube.portlets.user.workspace;
|
// */
|
||||||
|
//package org.gcube.portlets.user.workspace;
|
||||||
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
|
|
||||||
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.gcube.common.homelibary.model.items.type.WorkspaceItemType;
|
|
||||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
|
|
||||||
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
|
||||||
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
|
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
|
||||||
import org.gcube.portlets.user.workspace.server.GWTWorkspaceBuilder;
|
|
||||||
import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParameterForResolverIndex;
|
|
||||||
import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParameterForResolverIndex.RESOLVER_TYPE;
|
|
||||||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
|
||||||
import org.gcube.resources.discovery.client.queries.impl.XQuery;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
|
||||||
* Jun 26, 2013
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class UriResolverReaderRR {
|
|
||||||
|
|
||||||
//Base Address
|
|
||||||
String uri = "";
|
|
||||||
//Query URL parameter
|
|
||||||
String parameter = "";
|
|
||||||
private String uriRequest = "";
|
|
||||||
public static String DEFAULT_SCOPE = "/d4science.research-infrastructures.eu/gCubeApps"; //PRODUCTION
|
|
||||||
// public static String DEFAULT_SCOPE = "/gcube/devsec"; //PRODUCTION
|
|
||||||
|
|
||||||
public static Logger log = Logger.getLogger(UriResolverReaderRR.class);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws Exception
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public UriResolverReaderRR(String scope) throws Exception {
|
|
||||||
|
|
||||||
ScopeProvider.instance.set(scope);
|
|
||||||
|
|
||||||
XQuery query = queryFor(ServiceEndpoint.class);
|
|
||||||
|
|
||||||
query.addCondition("$resource/Profile/Name/text() eq 'HTTP-URI-Resolver'").setResult("$resource/Profile/AccessPoint");
|
|
||||||
|
|
||||||
DiscoveryClient<AccessPoint> client = clientFor(AccessPoint.class);
|
|
||||||
|
|
||||||
List<AccessPoint> endpoints = client.submit(query);
|
|
||||||
|
|
||||||
if (endpoints.size() == 0)
|
|
||||||
throw new Exception("No Resolver available");
|
|
||||||
|
|
||||||
//Base Address
|
|
||||||
// System.out.println(endpoints.get(0).address());
|
|
||||||
|
|
||||||
uri = endpoints.get(0)!=null?endpoints.get(0).address():"";
|
|
||||||
|
|
||||||
if(endpoints.get(0)!=null){
|
|
||||||
|
|
||||||
parameter = endpoints.get(0).propertyMap()!=null?endpoints.get(0).propertyMap().get("parameter").value():"";
|
|
||||||
}
|
|
||||||
|
|
||||||
uriRequest = uri+"?"+parameter;
|
|
||||||
|
|
||||||
|
|
||||||
//Query URL parameter
|
|
||||||
// System.out.println(endpoints.get(0).propertyMap().get("parameter").value());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public InputStream resolve(String smp) throws IOException{
|
|
||||||
String query = uriRequest + "="+smp;
|
|
||||||
|
|
||||||
URL url = new URL(query);
|
|
||||||
|
|
||||||
return url.openStream();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return Base Address of Uri Resolver
|
|
||||||
*/
|
|
||||||
public String getUri() {
|
|
||||||
return uri;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return Query URL parameter of Uri Resolver
|
|
||||||
*/
|
|
||||||
public String getParameter() {
|
|
||||||
return parameter;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
builder.append("UriResolverReaderParameter [uri=");
|
|
||||||
builder.append(uri);
|
|
||||||
builder.append(", parameter=");
|
|
||||||
builder.append(parameter);
|
|
||||||
builder.append("]");
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
|
||||||
|
|
||||||
|
|
||||||
// log.trace(new UriResolverReaderRR());
|
|
||||||
//
|
//
|
||||||
// UriResolverReaderRR uriResolver = new UriResolverReaderRR();
|
//import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
|
||||||
// InputStream is = uriResolver.resolve("smp://Wikipedia_logo_silver.png?5ezvFfBOLqaqBlwCEtAvz4ch5BUu1ag3yftpCvV+gayz9bAtSsnO1/sX6pemTKbDe0qbchLexXeWgGcJlskYE8td9QSDXSZj5VSl9kdN9SN0/LRYaWUZuP4Q1J7lEiwkU4GKPsiD6PDRVcT4QAqTEy5hSIbr6o4Y");
|
//import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
|
||||||
//
|
//
|
||||||
// File file = new File("test.png");
|
//import java.io.File;
|
||||||
|
//import java.io.FileOutputStream;
|
||||||
|
//import java.io.IOException;
|
||||||
|
//import java.io.InputStream;
|
||||||
|
//import java.net.URL;
|
||||||
|
//import java.util.List;
|
||||||
//
|
//
|
||||||
// FileOutputStream out = new FileOutputStream(file);
|
//import org.apache.commons.io.IOUtils;
|
||||||
|
//import org.apache.log4j.Logger;
|
||||||
|
//import org.gcube.common.homelibary.model.items.type.WorkspaceItemType;
|
||||||
|
//import org.gcube.common.homelibrary.home.HomeLibrary;
|
||||||
|
//import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||||
|
//import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
||||||
|
//import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
|
||||||
|
//import org.gcube.common.resources.gcore.ServiceEndpoint;
|
||||||
|
//import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
|
||||||
|
//import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
//import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParameterForResolverIndex;
|
||||||
|
//import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParameterForResolverIndex.RESOLVER_TYPE;
|
||||||
|
//import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||||
|
//import org.gcube.resources.discovery.client.queries.impl.XQuery;
|
||||||
|
//
|
||||||
|
///**
|
||||||
|
// * @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
||||||
|
// * Jun 26, 2013
|
||||||
|
// *
|
||||||
|
// */
|
||||||
|
///*
|
||||||
|
// *
|
||||||
|
// *
|
||||||
|
// * IT MUST BE MOVED TO SHUB
|
||||||
|
// *
|
||||||
|
// *
|
||||||
|
// *
|
||||||
|
//public class UriResolverReaderRR {
|
||||||
|
//
|
||||||
|
// //Base Address
|
||||||
|
// String uri = "";
|
||||||
|
// //Query URL parameter
|
||||||
|
// String parameter = "";
|
||||||
|
// private String uriRequest = "";
|
||||||
|
// public static String DEFAULT_SCOPE = "/d4science.research-infrastructures.eu/gCubeApps"; //PRODUCTION
|
||||||
|
//// public static String DEFAULT_SCOPE = "/gcube/devsec"; //PRODUCTION
|
||||||
|
//
|
||||||
|
// public static Logger log = Logger.getLogger(UriResolverReaderRR.class);
|
||||||
|
//
|
||||||
|
// public UriResolverReaderRR(String scope) throws Exception {
|
||||||
|
//
|
||||||
|
// ScopeProvider.instance.set(scope);
|
||||||
|
//
|
||||||
|
// XQuery query = queryFor(ServiceEndpoint.class);
|
||||||
|
//
|
||||||
|
// query.addCondition("$resource/Profile/Name/text() eq 'HTTP-URI-Resolver'").setResult("$resource/Profile/AccessPoint");
|
||||||
|
//
|
||||||
|
// DiscoveryClient<AccessPoint> client = clientFor(AccessPoint.class);
|
||||||
|
//
|
||||||
|
// List<AccessPoint> endpoints = client.submit(query);
|
||||||
|
//
|
||||||
|
// if (endpoints.size() == 0)
|
||||||
|
// throw new Exception("No Resolver available");
|
||||||
|
//
|
||||||
|
// //Base Address
|
||||||
|
//// System.out.println(endpoints.get(0).address());
|
||||||
|
//
|
||||||
|
// uri = endpoints.get(0)!=null?endpoints.get(0).address():"";
|
||||||
|
//
|
||||||
|
// if(endpoints.get(0)!=null){
|
||||||
|
//
|
||||||
|
// parameter = endpoints.get(0).propertyMap()!=null?endpoints.get(0).propertyMap().get("parameter").value():"";
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// uriRequest = uri+"?"+parameter;
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// IOUtils.copy(is, out);
|
// //Query URL parameter
|
||||||
// is.close();
|
//// System.out.println(endpoints.get(0).propertyMap().get("parameter").value());
|
||||||
//
|
//
|
||||||
// out.close();
|
// }
|
||||||
|
|
||||||
// 066086bc-5db1-48fc-b365-2ee821db2fb7
|
|
||||||
// 370dc1cc-2e5e-4321-bc6f-ad860414db97
|
|
||||||
|
|
||||||
// id: f70f01f9-5a06-4123-b6ec-bd121c1af82f, name: testResponse.html, ### Public link: smp://Home/francesco.mangiacrapa/Workspace41e79e40-ec82-416b-ba83-29b54bb43426?5ezvFfBOLqb3YESyI/kesN4T+ZD0mtmc/4sZ0vGMrl0lgx7k85j8o2Q1vF0ezJi/xIGDhncO9jOkV1T8u6Db7GZ/4ePgMws8Jxu8ierJajHBd20bUotElPG3BVG0ODMHf1ztm6rKJIAeb9R/0FEIDQ==
|
|
||||||
// id: 35a0298e-da69-464f-9170-3dc764da564d, name: wiki ws backup, ### Public link: smp://Home/francesco.mangiacrapa/Workspaceb7c9bf85-b0e0-47ac-87e5-eba34048f7ab?5ezvFfBOLqb3YESyI/kesN4T+ZD0mtmc/4sZ0vGMrl0lgx7k85j8o2Q1vF0ezJi/xIGDhncO9jOkV1T8u6Db7GZ/4ePgMws8Jxu8ierJajHBd20bUotElPG3BVG0ODMHf1ztm6rKJIAeb9R/0FEIDQ==
|
|
||||||
|
|
||||||
|
|
||||||
// id: 370dc1cc-2e5e-4321-bc6f-ad860414db97, name: testupload.txt, ### Public link: smp://Home/francesco.mangiacrapa/Workspace284ee688-e6fb-4080-bbcb-cc7c8cc5c381?5ezvFfBOLqb3YESyI/kesN4T+ZD0mtmc/4sZ0vGMrl0lgx7k85j8o2Q1vF0ezJi/xIGDhncO9jOkV1T8u6Db7GZ/4ePgMws8Jxu8ierJajHBd20bUotElPG3BVG0ODMHf1ztm6rKJIAeb9R/0FEIDQ==
|
|
||||||
|
|
||||||
String itemId = "0e875263-f6bc-4945-9435-bfb8774027ca";
|
|
||||||
// itemId = "f70f01f9-5a06-4123-b6ec-bd121c1af82f";
|
|
||||||
System.out.println("uri is: "+getPublicLinkForFolderItemId(itemId));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
|
// public InputStream resolve(String smp) throws IOException{
|
||||||
|
// String query = uriRequest + "="+smp;
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getPublicLinkForFolderItemId(String itemId){
|
|
||||||
|
|
||||||
try{
|
|
||||||
|
|
||||||
ScopeProvider.instance.set(DEFAULT_SCOPE);
|
|
||||||
|
|
||||||
Workspace workspace = HomeLibrary
|
|
||||||
.getHomeManagerFactory()
|
|
||||||
.getHomeManager()
|
|
||||||
.getHome("leonardo.candela")
|
|
||||||
.getWorkspace();
|
|
||||||
|
|
||||||
GWTWorkspaceBuilder builder = new GWTWorkspaceBuilder();
|
|
||||||
|
|
||||||
System.out.println("get item...");
|
|
||||||
WorkspaceItem wsItem = workspace.getItem(itemId);
|
|
||||||
|
|
||||||
if(wsItem.getType().equals(WorkspaceItemType.FOLDER_ITEM)){
|
|
||||||
|
|
||||||
FolderItem folderItem = (FolderItem) wsItem;
|
|
||||||
System.out.println("get public link...");
|
|
||||||
String smpUri = builder.getPublicLinkForFolderItem(folderItem);
|
|
||||||
System.out.println("smpUri "+smpUri);
|
|
||||||
|
|
||||||
System.out.println("get uriResolver...");
|
|
||||||
UriResolverReaderParameterForResolverIndex uriResolver = new UriResolverReaderParameterForResolverIndex(DEFAULT_SCOPE, RESOLVER_TYPE.SMP_ID);
|
|
||||||
|
|
||||||
// String url = uriResolver.resolveAsUriRequest(smpUri, "testResponse!@#$$%^^&&.html", folderItem.getMimeType(), true);
|
|
||||||
String url = uriResolver.resolveAsUriRequest(smpUri, folderItem.getName(), folderItem.getMimeType(), true);
|
|
||||||
System.out.println("url econded: "+url);
|
|
||||||
//
|
//
|
||||||
// url = uriResolver.resolveAsUriRequest(smpUri, folderItem.getName(), folderItem.getMimeType(), false);
|
// URL url = new URL(query);
|
||||||
// System.out.println("url doesn't econded: "+url);
|
//
|
||||||
|
// return url.openStream();
|
||||||
|
// }
|
||||||
// uriResolver.getHashParemeters(smpUri, folderItem.getName(), folderItem.getMimeType());
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
// HttpCallerUtil callerUtil = new HttpCallerUtil(uriResolver.getBaseUri(), "", "");
|
// public String getUri() {
|
||||||
// String query = uriResolver.getQuery();
|
// return uri;
|
||||||
// callerUtil.callPost("", query, "application/x-www-form-urlencoded");
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
// String smpUri = "smp://Home/test.user/Workspace/bla8200ceb0-c525-40e6-bad1-a63f83811d3d?5ezvFfBOLqb3YESyI/kesN4T+ZD0mtmc/4sZ0vGMrl0lgx7k85j8o2Q1vF0ezJi/xIGDhncO9jOkV1T8u6Db7GZ/4ePgMws8Jxu8ierJajHBd20bUotElPG3BVG0ODMHf1ztm6rKJIAeb9R/0FEIDQ==";
|
// public String getParameter() {
|
||||||
|
// return parameter;
|
||||||
|
// }
|
||||||
UrlShortener urlShortner = new UrlShortener(DEFAULT_SCOPE);
|
//
|
||||||
|
// @Override
|
||||||
String shortUrl = urlShortner.shorten(url);
|
// public String toString() {
|
||||||
System.out.println("url shortUrl: "+shortUrl);
|
// StringBuilder builder = new StringBuilder();
|
||||||
|
// builder.append("UriResolverReaderParameter [uri=");
|
||||||
|
// builder.append(uri);
|
||||||
|
// builder.append(", parameter=");
|
||||||
InputStream is = uriResolver.resolveAsInputStream(smpUri, folderItem.getName(), folderItem.getMimeType());
|
// builder.append(parameter);
|
||||||
|
// builder.append("]");
|
||||||
File file = new File(folderItem.getName());
|
// return builder.toString();
|
||||||
|
// }
|
||||||
FileOutputStream out = new FileOutputStream(file);
|
//
|
||||||
|
//
|
||||||
|
// public static void main(String[] args) throws Exception {
|
||||||
IOUtils.copy(is, out);
|
//
|
||||||
is.close();
|
//
|
||||||
|
//// log.trace(new UriResolverReaderRR());
|
||||||
out.close();
|
////
|
||||||
|
//// UriResolverReaderRR uriResolver = new UriResolverReaderRR();
|
||||||
if(uriResolver!=null && uriResolver.isAvailable()){
|
//// InputStream is = uriResolver.resolve("smp://Wikipedia_logo_silver.png?5ezvFfBOLqaqBlwCEtAvz4ch5BUu1ag3yftpCvV+gayz9bAtSsnO1/sX6pemTKbDe0qbchLexXeWgGcJlskYE8td9QSDXSZj5VSl9kdN9SN0/LRYaWUZuP4Q1J7lEiwkU4GKPsiD6PDRVcT4QAqTEy5hSIbr6o4Y");
|
||||||
return uriResolver.resolveAsUriRequest(smpUri, folderItem.getName(), folderItem.getMimeType(), true);
|
////
|
||||||
}
|
//// File file = new File("test.png");
|
||||||
|
////
|
||||||
}
|
//// FileOutputStream out = new FileOutputStream(file);
|
||||||
|
////
|
||||||
|
////
|
||||||
return "";
|
//// IOUtils.copy(is, out);
|
||||||
|
//// is.close();
|
||||||
}catch (Exception e) {
|
////
|
||||||
System.out.println("Error getPublicLinkForFolderItemId url for");
|
//// out.close();
|
||||||
e.printStackTrace();
|
//
|
||||||
return "";
|
//// 066086bc-5db1-48fc-b365-2ee821db2fb7
|
||||||
}
|
//// 370dc1cc-2e5e-4321-bc6f-ad860414db97
|
||||||
|
//
|
||||||
}
|
//// id: f70f01f9-5a06-4123-b6ec-bd121c1af82f, name: testResponse.html, ### Public link: smp://Home/francesco.mangiacrapa/Workspace41e79e40-ec82-416b-ba83-29b54bb43426?5ezvFfBOLqb3YESyI/kesN4T+ZD0mtmc/4sZ0vGMrl0lgx7k85j8o2Q1vF0ezJi/xIGDhncO9jOkV1T8u6Db7GZ/4ePgMws8Jxu8ierJajHBd20bUotElPG3BVG0ODMHf1ztm6rKJIAeb9R/0FEIDQ==
|
||||||
|
//// id: 35a0298e-da69-464f-9170-3dc764da564d, name: wiki ws backup, ### Public link: smp://Home/francesco.mangiacrapa/Workspaceb7c9bf85-b0e0-47ac-87e5-eba34048f7ab?5ezvFfBOLqb3YESyI/kesN4T+ZD0mtmc/4sZ0vGMrl0lgx7k85j8o2Q1vF0ezJi/xIGDhncO9jOkV1T8u6Db7GZ/4ePgMws8Jxu8ierJajHBd20bUotElPG3BVG0ODMHf1ztm6rKJIAeb9R/0FEIDQ==
|
||||||
|
//
|
||||||
|
//
|
||||||
}
|
//// id: 370dc1cc-2e5e-4321-bc6f-ad860414db97, name: testupload.txt, ### Public link: smp://Home/francesco.mangiacrapa/Workspace284ee688-e6fb-4080-bbcb-cc7c8cc5c381?5ezvFfBOLqb3YESyI/kesN4T+ZD0mtmc/4sZ0vGMrl0lgx7k85j8o2Q1vF0ezJi/xIGDhncO9jOkV1T8u6Db7GZ/4ePgMws8Jxu8ierJajHBd20bUotElPG3BVG0ODMHf1ztm6rKJIAeb9R/0FEIDQ==
|
||||||
|
//
|
||||||
|
// String itemId = "0e875263-f6bc-4945-9435-bfb8774027ca";
|
||||||
|
//// itemId = "f70f01f9-5a06-4123-b6ec-bd121c1af82f";
|
||||||
|
// System.out.println("uri is: "+getPublicLinkForFolderItemId(itemId));
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
////
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public static String getPublicLinkForFolderItemId(String itemId){
|
||||||
|
//
|
||||||
|
// try{
|
||||||
|
//
|
||||||
|
// ScopeProvider.instance.set(DEFAULT_SCOPE);
|
||||||
|
//
|
||||||
|
// Workspace workspace = HomeLibrary
|
||||||
|
// .getHomeManagerFactory()
|
||||||
|
// .getHomeManager()
|
||||||
|
// .getHome("leonardo.candela")
|
||||||
|
// .getWorkspace();
|
||||||
|
//
|
||||||
|
// GWTWorkspaceBuilder builder = new GWTWorkspaceBuilder();
|
||||||
|
//
|
||||||
|
// System.out.println("get item...");
|
||||||
|
// WorkspaceItem wsItem = workspace.getItem(itemId);
|
||||||
|
//
|
||||||
|
// if(wsItem.getType().equals(WorkspaceItemType.FOLDER_ITEM)){
|
||||||
|
//
|
||||||
|
// FolderItem folderItem = (FolderItem) wsItem;
|
||||||
|
// System.out.println("get public link...");
|
||||||
|
// String smpUri = builder.getPublicLinkForFolderItem(folderItem);
|
||||||
|
// System.out.println("smpUri "+smpUri);
|
||||||
|
//
|
||||||
|
// System.out.println("get uriResolver...");
|
||||||
|
// UriResolverReaderParameterForResolverIndex uriResolver = new UriResolverReaderParameterForResolverIndex(DEFAULT_SCOPE, RESOLVER_TYPE.SMP_ID);
|
||||||
|
//
|
||||||
|
//// String url = uriResolver.resolveAsUriRequest(smpUri, "testResponse!@#$$%^^&&.html", folderItem.getMimeType(), true);
|
||||||
|
// String url = uriResolver.resolveAsUriRequest(smpUri, folderItem.getName(), folderItem.getMimeType(), true);
|
||||||
|
// System.out.println("url econded: "+url);
|
||||||
|
////
|
||||||
|
//// url = uriResolver.resolveAsUriRequest(smpUri, folderItem.getName(), folderItem.getMimeType(), false);
|
||||||
|
//// System.out.println("url doesn't econded: "+url);
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//// uriResolver.getHashParemeters(smpUri, folderItem.getName(), folderItem.getMimeType());
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//// HttpCallerUtil callerUtil = new HttpCallerUtil(uriResolver.getBaseUri(), "", "");
|
||||||
|
//// String query = uriResolver.getQuery();
|
||||||
|
//// callerUtil.callPost("", query, "application/x-www-form-urlencoded");
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//// String smpUri = "smp://Home/test.user/Workspace/bla8200ceb0-c525-40e6-bad1-a63f83811d3d?5ezvFfBOLqb3YESyI/kesN4T+ZD0mtmc/4sZ0vGMrl0lgx7k85j8o2Q1vF0ezJi/xIGDhncO9jOkV1T8u6Db7GZ/4ePgMws8Jxu8ierJajHBd20bUotElPG3BVG0ODMHf1ztm6rKJIAeb9R/0FEIDQ==";
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// UrlShortener urlShortner = new UrlShortener(DEFAULT_SCOPE);
|
||||||
|
//
|
||||||
|
// String shortUrl = urlShortner.shorten(url);
|
||||||
|
// System.out.println("url shortUrl: "+shortUrl);
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// InputStream is = uriResolver.resolveAsInputStream(smpUri, folderItem.getName(), folderItem.getMimeType());
|
||||||
|
//
|
||||||
|
// File file = new File(folderItem.getName());
|
||||||
|
//
|
||||||
|
// FileOutputStream out = new FileOutputStream(file);
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// IOUtils.copy(is, out);
|
||||||
|
// is.close();
|
||||||
|
//
|
||||||
|
// out.close();
|
||||||
|
//
|
||||||
|
// if(uriResolver!=null && uriResolver.isAvailable()){
|
||||||
|
// return uriResolver.resolveAsUriRequest(smpUri, folderItem.getName(), folderItem.getMimeType(), true);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// return "";
|
||||||
|
//
|
||||||
|
// }catch (Exception e) {
|
||||||
|
// System.out.println("Error getPublicLinkForFolderItemId url for");
|
||||||
|
// e.printStackTrace();
|
||||||
|
// return "";
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//*/
|
||||||
|
|
Loading…
Reference in New Issue