Admin API

The Admin API permit to perform the following activities:

1. User connection information inspection via OData protocol
2. User Synchronization
3. Products deletion

User connection information inspection via OData protocol

The procedure shows in detail all steps needed to visualize the information about users and their connections through OData.

STEP 1:
Stop DHuS
Add to the server.xml file the following lines:
< Valve className="fr.gael.dhus.server.http.valve.AccessValve" pattern=".* useLogger="true" enable="true"/>
Start DHuS

STEP 2:
Log in as administrator (root)

STEP 3:
Access the following link:
https://DHuS_URL/odata/v1/Users?$orderby=Username
Verify that the list of users is visible and it is sorted depending on the username
The following information relative to each user is visualized:

<m:properties>
<d:Username> 
<d:Email>
<d:FirstName>
<:LastName>
<d:Country>
<d:Phone/>
<d:Address/>
<d:Domain>
<d:SubDomain>
<d:Usage>
<d:SubUsage>unknown</d:SubUsage>
</m:properties>
</content>;

The users are sorted depending on the username.
STEP 4:
Verify that the number returned by the URL:
https:// DHuS_URL /odata/v1/Users/$count?
Is equal to the total number of users registered to the Hub (The total number of users is visible from the GUI under management->Users) The number of users is the same.

STEP 5:
Log in with as a general user (search, download) and access the following URL:
https://DHuS_URL/odata/v1/Users?$filter= $filter=Username eq ‘Username’
The User information about the user are visualised. When refreshing the page pushing the F5 button, the field “updated” is updated with the current time.

STEP 6:
Access the Node:
https://DHuS_URL/odata/v1/Users(‘Username’)/Connections
All the URL accessed by the user are listed. For each connection the following info are displayed:


<entry>
<id>
<title 
<updated>
<m:properties>
<d:Id>
<d:Date>
<d:RemoteIp>
<d:Request>
<d:Duration>

STEP 7:
Once logged in as administrator, access the URL:
https://DHuS_URL/odata/v1/Users(‘root’)/SystemRoles
to visualize the user roles of the administrator user
The administrator has everyrole available on the Hub:
- Search;
- Upload;
- Archive manager;
- Statistics;
- System manager;
- Data manager;
- Download

STEP 8:
Access the URL:
https://DHuS_URL/odata/v1/Networks(0L)/NetworkStatistic
To visualize the statistics associated to the network.
The NetworkStatistics reports the informations related to the statistics of the network (activity period in ms, number of connection within this period).

<id> https://scihub-test.esa.int/dhus/odata/v1/Networks(0L)/NetworkStatistics(0L)



<title type="text">0
<updated> 2016-02-25T15:32:12.613Z </updated>
<category term="DHuS.NetworkStatistic"  <scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/gt;
<link href="NetworkStatistics(0L)" rel="edit" title="NetworkStatistic"/>
<content type="application/xml">
<m:properties>
<d:Id>0 </d:Id>
<d:ActivityPeriod>
<d:ConnectionNumber></m:properties>
</content>
</entry>

STEP 9:
Access the URL:
https://[dhus]/dhus/odata/v1/Connections?$filter=substringof(Request,'odata/v1')
to visualize all the odata queries performed by the users.All the odata queries performed by the users are visualized

STEP 10:
Launch a product download via GUI.Access the URL:
https://[dhus]/odata/v1/Connections?$filter=Status eq 'PENDING'

User Synchronization via API

STEP 1: Log in the machine where the Front End (FE) DHuS is installed. This DHuS instance shall be filled with users registered in the Back End (BE).
STEP 2:On the DHuS acting as FE, set the environment variables to connect to the syncing instance of the DHuS.
Example:


export DHOST=localhost:8080
export DLOGIN=root
export DPASS=a
	
Doing the commands:

echo $DHOST
echo DLOGIN
echo DPASS
the correspondent values are displayed

STEP 3:
Create a working folder containing the following scripts and auxiliary files:
- ./getSynchronizer
- ./createSynchronizer
- Body.txt
- ./updateSynchronizer
- ./deleteSynchronizer
Available on https://github.com/jobayle/dhus_user_sync_scripts

STEP 4:
Use the command: ./getSynchronizer [id] (if no user synchronizer is available, launchr this command with no id in input) The information regarding the currently available user synchronizer are displayed.

STEP 5: Create the user synchronizer use the command:


./createSynchronizer <-D_SCHEDULE=...> <-D_REQUEST=start|stop> <-D_SERVICEURL=...> [-D_LABEL=...] [-D_SERVICELOGIN=...] [-D_SERVICEPASSWORD=...]

Example:
. /createSynchronizer -D_SCHEDULE="0 */3 * * * ?" -D_REQUEST=stop -D_SERVICEURL="http://192.168.0.105:8080/odata/v1" -D_LABEL=my_user_syncer -D_SERVICELOGIN=root -D_SERVICEPASSWORD=a)

Performing again the command in step 4 of this procedure, the characteristic of the user sync are displayed.

Update the user synchronizer through the following commands:

STEP 6:
./updateSynchronizer <id> [-D_SCHEDULE=...] [-D_REQUEST=start|stop] [-D_SERVICEURL=...] [-D_LABEL=...] [-D_SERVICELOGIN=...] [-D_SERVICEPASSWORD=...] (e.g. ./updateSynchronizer 0 -D_SCHEDULE='0 24 * * * ?')
Performing again the command in step 4 of this procedure, the characteristic of the user sync are displayed updated as requested.

STEP 7:
Delete the synchronizer using the following command: ./deleteSynchronizer <id> Performing again the command in step 4 of this procedure, the characteristic of the user sync are no longer available.

Products Deletion

The following scripts permit massive products deletion via API.
getID.sh: it produces the UUID of products retrieving this information from the specified product names
delete_mod.sh: it performs the deletion of the products listed in the getID.sh script.
The script getID.sh has 3 input parameter:
1) original file containing names of products to be deleted;
2) number N of files in which you want to split the original file (used when the number of products is high)
3) folder containing DB (in-operation DB copy) on which will be performed the query, that get the UUID of products by their names
For each i-th file (i=1,2,3,.....,N) the query, related to the products names of the i-th file, is built and performed.
The split operation allows to delete a big number of products by more scripts (i=1,2,3,......,N) launched in parallel, one for each i-th UUID file.

The output main files produced by getID.sh are:
1) UUID_
{i}.txt i=1,2,3,....,N; file containing the UUID of products of i-th block of names 2) PRODUCTSNOTFOUND_{i} .txt i=1,2,3,....,N; file containing the names of products not found by i-th query on DB
Each UUID_ {i}.txt file is the input parameter of the script delete_mod.sh that performs the deletion of UUID on Virtual machine where it is launched.
The input parameter of the script delete_mod.sh are:
1) number of deletions in parallel
2) file containing the UUID to be deleted (UUID_{i} .txt)
The deletion of single UUID product (CURL command) and the related log is produced by del_prod_mod.sh that is a script present in delete_mod.sh. If the log produces, for a specific UUID, the string "in XXX s return code 20..." the product is deleted. See Scripts section