Skip to content

Commit

Permalink
added ability to display file checksums in the listings table
Browse files Browse the repository at this point in the history
  • Loading branch information
billyfish committed Jul 17, 2020
1 parent e6f3d91 commit d2ecf3c
Show file tree
Hide file tree
Showing 9 changed files with 394 additions and 152 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ LIBS += \
irods_common \
irods_plugin_dependencies
LIB_PATHS += \
$(IRODS_EXTERNALS)/boost1.60.0-0/lib \
$(IRODS_EXTERNALS)/jansson2.7-0/lib
$(IRODS_EXTERNALS)/boost1.67.0-0/lib \
/home/billy/Applications/grassroots/extras/jansson/lib
MACROS += IRODS_4_2
else
LIBS += \
Expand Down
22 changes: 20 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ searching and linking is available at the [Designing Future Wheat Data Portal](h

## Changelog

### 1.5.1 (15 Jul 2020)
- Added ability to show the data object checksums in the listings table. See the documentation on the
**DavRodsShowChecksum** and **DavRodsChecksumHeading** directives for more information.

### 1.5 (1 Aug 2018)

- REST API now accepts POST requests.
Expand Down Expand Up @@ -286,7 +290,7 @@ The directory listings can be customised using a variety of configuration
directives.

* **DavRodsHTMLListingClass**:
The list of collections and data objects displayed by Davrods are within
The list of collections and data objects displayed by Eirods-dav are within
an HTML table. If you wish to specify CSS classes for this table, you can
use this directive. For instance, if you wish to use the CSS classes
called *table* and *table-striped*, then you could use the following
Expand All @@ -304,6 +308,7 @@ The listings table defaults to displaying five columns:
* Date
* Properties


Each of these headings can be changed to one of your choice using the
following configuration directives. If you would like a column to
be hidden then set the value of any of these directives to **!**.
Expand Down Expand Up @@ -351,7 +356,20 @@ then you can use this directive. For instance to change it to *Metadata*
DavRodsPropertiesHeading Metadata
```

* **DavRodsShowChecksum**: If you wish to add a column for displaying the file checksums, set this
directive to true. By default it is *false* and checksums will not be displayed.

```
DavRodsShowChecksum true
```

* **DavRodsChecksumHeading**: If you want to change the column heading for the *Checksum* column
then you can use this directive. For instance to change it to *MD5*

```
DavRodsChecksumHeading MD5
```

* **DavRodsHTMLCollectionIcon**:
If you wish to use a custom image to denote collections, you can use this
directive. This can be superseded by a matching call to the `DavRodsAddIcon`
Expand Down Expand Up @@ -685,7 +703,7 @@ directly or via the [Earlham Institute](http://www.earlham.ac.uk/contact-us/) pa

## License ##

Copyright (c) 2017-18, Earlham Institute and (c) 2016 Utrecht University.
Copyright (c) 2017-20, Earlham Institute and (c) 2016 Utrecht University.

EIrods-dav is licensed under the GNU Lesser General Public License version
3 or higher (LGPLv3+). See the COPYING.LESSER file for details.
Expand Down
11 changes: 11 additions & 0 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,11 @@ const command_rec davrods_directives[] = {
),


AP_INIT_TAKE1(
DAVRODS_CONFIG_PREFIX "ShowChecksum", SetShowChecksum,
NULL, ACCESS_CONF, "Show the checksums for each data object, default is false"
),

AP_INIT_RAW_ARGS(
DAVRODS_CONFIG_PREFIX "SelectedResources", SetShowSelectedResourcesOnly,
NULL, ACCESS_CONF, "List of resources to show with each entry separated by spaces"
Expand Down Expand Up @@ -597,6 +602,12 @@ const command_rec davrods_directives[] = {
NULL, ACCESS_CONF, "Set the heading for the Properties column in directory listings"
),

AP_INIT_TAKE1(
DAVRODS_CONFIG_PREFIX "ChecksumHeading", SetChecksumHeading,
NULL, ACCESS_CONF, "Set the heading for the Checksum column in directory listings"
),


AP_INIT_TAKE1(
DAVRODS_CONFIG_PREFIX "ZoneLabel", SetZoneLabel,
NULL, ACCESS_CONF, "Set the value to display instead of the zone name"
Expand Down
2 changes: 1 addition & 1 deletion config.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* \file
* \brief Davrods configuration.
* \author Chris Smeele
* \author Chris Smeele, Simon Tyrrell
* \copyright Copyright (c) 2016, Utrecht University
*
* This file is part of Davrods.
Expand Down
110 changes: 98 additions & 12 deletions listing.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ apr_status_t SetIRodsConfig (IRodsConfig *config_p, const char *exposed_root_s,
apr_status_t SetIRodsObjectFromIdString (IRodsObject *obj_p, const char *id_s, rcComm_t *connection_p, apr_pool_t *pool_p)
{
apr_status_t status = APR_EGENERAL;
int select_columns_p [7] = { COL_DATA_NAME, COL_D_OWNER_NAME, COL_COLL_NAME, COL_D_MODIFY_TIME, COL_DATA_SIZE, COL_D_RESC_NAME, -1 };
int select_columns_p [8] = { COL_DATA_NAME, COL_D_OWNER_NAME, COL_COLL_NAME, COL_D_MODIFY_TIME, COL_DATA_SIZE, COL_D_RESC_NAME, COL_D_DATA_CHECKSUM, -1 };
int where_columns_p [1] = { COL_D_DATA_ID };
const char *where_values_ss [1];
genQueryOut_t *results_p = NULL;
Expand Down Expand Up @@ -114,9 +114,19 @@ apr_status_t SetIRodsObjectFromIdString (IRodsObject *obj_p, const char *id_s, r

if (resource_s)
{
rodsLong_t size = atoi (size_s);
char *checksum_s = apr_pstrdup (pool_p, results_p -> sqlResult [6].value);

if (resource_s)
{
rodsLong_t size = atoi (size_s);

status = SetIRodsObject (obj_p, DATA_OBJ_T, id_s, name_s, coll_s, owner_s, resource_s, modify_s, size, checksum_s, pool_p);
}
else
{
ap_log_perror (APLOG_MARK, APLOG_ERR, APR_EGENERAL, pool_p, "Failed to copy resource \"%s\"", results_p -> sqlResult [5].value);
}

status = SetIRodsObject (obj_p, DATA_OBJ_T, id_s, name_s, coll_s, owner_s, resource_s, modify_s, size, pool_p);
} /* if (resource_s) */
else
{
Expand Down Expand Up @@ -205,7 +215,7 @@ apr_status_t SetIRodsObjectFromIdString (IRodsObject *obj_p, const char *id_s, r

if (modify_s)
{
status = SetIRodsObject (obj_p, COLL_OBJ_T, id_s, name_s, parent_s, owner_s, NULL, modify_s, 0, pool_p);
status = SetIRodsObject (obj_p, COLL_OBJ_T, id_s, name_s, parent_s, owner_s, NULL, modify_s, 0, NULL, pool_p);
} /* if (modify_s) */
else
{
Expand Down Expand Up @@ -240,7 +250,7 @@ apr_status_t SetIRodsObjectFromIdString (IRodsObject *obj_p, const char *id_s, r
}


IRodsObjectNode *AllocateIRodsObjectNode (const objType_t obj_type, const char *id_s, const char *data_s, const char *collection_s, const char *owner_name_s, const char *resource_s, const char *last_modified_time_s, const rodsLong_t size, apr_pool_t *pool_p)
IRodsObjectNode *AllocateIRodsObjectNode (const objType_t obj_type, const char *id_s, const char *data_s, const char *collection_s, const char *owner_name_s, const char *resource_s, const char *last_modified_time_s, const rodsLong_t size, const char *checksum_s, apr_pool_t *pool_p)
{
IRodsObject *obj_p = (IRodsObject *) malloc (sizeof (IRodsObject));

Expand All @@ -250,7 +260,7 @@ IRodsObjectNode *AllocateIRodsObjectNode (const objType_t obj_type, const char *

if (node_p)
{
if (SetIRodsObject (obj_p, obj_type, id_s, data_s, collection_s, owner_name_s, resource_s, last_modified_time_s, size, pool_p) == APR_SUCCESS)
if (SetIRodsObject (obj_p, obj_type, id_s, data_s, collection_s, owner_name_s, resource_s, last_modified_time_s, size, checksum_s, pool_p) == APR_SUCCESS)
{
node_p -> ion_object_p = obj_p;
node_p -> ion_next_p = NULL;
Expand Down Expand Up @@ -403,7 +413,7 @@ static json_t *GetIRodsObjectAsJSON (const IRodsObject *irods_obj_p, const IRods
}


apr_status_t SetIRodsObject (IRodsObject *obj_p, const objType_t obj_type, const char *id_s, const char *data_s, const char *collection_s, const char *owner_name_s, const char *resource_s, const char *last_modified_time_s, const rodsLong_t size, apr_pool_t *pool_p)
apr_status_t SetIRodsObject (IRodsObject *obj_p, const objType_t obj_type, const char *id_s, const char *data_s, const char *collection_s, const char *owner_name_s, const char *resource_s, const char *last_modified_time_s, const rodsLong_t size, const char *md5_s, apr_pool_t *pool_p)
{
apr_status_t status = APR_ENOMEM;
bool done_id_flag = false;
Expand Down Expand Up @@ -446,10 +456,14 @@ apr_status_t SetIRodsObject (IRodsObject *obj_p, const objType_t obj_type, const
{
if (SetStringValue (last_modified_time_s, & (obj_p -> io_last_modified_time_s), pool_p))
{
obj_p -> io_obj_type = obj_type;
obj_p -> io_size = size;
if (SetStringValue (md5_s, & (obj_p -> io_checksum_s), pool_p))
{
obj_p -> io_obj_type = obj_type;
obj_p -> io_size = size;

status = APR_SUCCESS;
} /* if (SetStringValue (md5_s, & (obj_p -> io_md5_s), pool_p)) */

status = APR_SUCCESS;
} /* if (SetStringValue (last_modified_time_s, & (obj_p -> io_last_modified_time_s), pool_p)) */

} /* if (SetStringValue (resource_s, & (obj_p -> io_resource_s), pool_p)) */
Expand Down Expand Up @@ -482,11 +496,11 @@ apr_status_t SetIRodsObjectFromCollEntry (IRodsObject *obj_p, const collEnt_t *c
{
const char *id_s = GetCollectionId (coll_entry_p -> collName, connection_p, pool_p);

status = SetIRodsObject (obj_p, coll_entry_p -> objType, id_s, coll_entry_p -> dataName, coll_entry_p -> collName, coll_entry_p -> ownerName, coll_entry_p -> resource, coll_entry_p -> modifyTime, coll_entry_p -> dataSize, pool_p);
status = SetIRodsObject (obj_p, coll_entry_p -> objType, id_s, coll_entry_p -> dataName, coll_entry_p -> collName, coll_entry_p -> ownerName, coll_entry_p -> resource, coll_entry_p -> modifyTime, coll_entry_p -> dataSize, coll_entry_p -> chksum, pool_p);
}
else
{
status = SetIRodsObject (obj_p, coll_entry_p -> objType, coll_entry_p -> dataId, coll_entry_p -> dataName, coll_entry_p -> collName, coll_entry_p -> ownerName, coll_entry_p -> resource, coll_entry_p -> modifyTime, coll_entry_p -> dataSize, pool_p);
status = SetIRodsObject (obj_p, coll_entry_p -> objType, coll_entry_p -> dataId, coll_entry_p -> dataName, coll_entry_p -> collName, coll_entry_p -> ownerName, coll_entry_p -> resource, coll_entry_p -> modifyTime, coll_entry_p -> dataSize, coll_entry_p -> chksum, pool_p);
}

return status;
Expand Down Expand Up @@ -549,6 +563,78 @@ const char *GetIRodsObjectDisplayName (const IRodsObject *obj_p)
}



const char *GetIRodsObjectChecksum (const IRodsObject *irods_obj_p)
{
if (! (irods_obj_p -> io_checksum_s))
{
/*
char *full_path_s = GetIRodsObjectFullPath (irods_obj_p, pool_p);
if (full_path_s)
{
char *checksum_s = NULL;
dataObjInp_t obj_inp;
int status;
size_t length = strlen (full_path_s);
memset (&obj_inp, 0, sizeof (dataObjInp_t));
if (length >= MAX_NAME_LEN)
{
length = MAX_NAME_LEN - 1;
}
strncpy (obj_inp.objPath, full_path_s, length);
addKeyVal (& (obj_inp.condInput), VERIFY_CHKSUM_KW, "");
//addKeyVal( &collInp->condInput, VERIFY_CHKSUM_KW, "" );
// status = rcDataObjChksum (conn, &ob_innp, &checksum_s);
if (status >= 0)
{
return checksum_s;
}
} // if (full_path_s)
*/
}

return (irods_obj_p -> io_checksum_s);

/*
Example Usage:
Chksum the data object /myZone/home/john/myfile if one does not already exist in iCAT.
dataObjInp_t dataObjInp;
char *outChksum = NULL;
bzero (&dataObjInp, sizeof (dataObjInp));
rstrcpy (dataObjInp.objPath, "/myZone/home/john/myfile", MAX_NAME_LEN);
status = rcDataObjChksum (conn, &dataObjInp, &outChksum);
if (status < 0) {
.... handle the error
}
Parameters
[in] conn - A rcComm_t connection handle to the server.
[in] dataObjChksumInp - Elements of dataObjInp_t used :
char objPath[MAX_NAME_LEN] - full path of the data object.
keyValPair_t condInput - keyword/value pair input. Valid keywords:
VERIFY_CHKSUM_KW - verify the checksum value in iCAT. If the checksum value does not exist, compute and register one. This keyWd has no value.
FORCE_CHKSUM_KW - checksum the data-object even if a checksum already exists in iCAT. This keyWd has no value.
CHKSUM_ALL_KW - checksum all replicas. This keyWd has no value.
REPL_NUM_KW - The replica number of the replica to delete.
RESC_NAME_KW - delete replica stored in this resource.
[out] outChksum - a string containing the md5 checksum value.
*/

return NULL;
}



const char *GetIRodsObjectIcon (const IRodsObject *irods_obj_p, const struct HtmlTheme * const theme_p)
{
const char *icon_s = NULL;
Expand Down
8 changes: 6 additions & 2 deletions listing.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ typedef struct IRodsObject
char *io_owner_name_s;
char *io_resource_s;
char *io_last_modified_time_s;
char *io_checksum_s;
rodsLong_t io_size;
} IRodsObject;

Expand Down Expand Up @@ -94,10 +95,10 @@ void InitIRodsObject (IRodsObject *obj_p);
apr_status_t SetIRodsConfig (IRodsConfig *config_p, const char *exposed_root_s, const char *root_path_s, const char *metadata_root_link_s);


apr_status_t SetIRodsObject (IRodsObject *obj_p, const objType_t obj_type, const char *id_s, const char *data_s, const char *collection_s, const char *owner_name_s, const char *resource_s, const char *last_modified_time_s, const rodsLong_t size, apr_pool_t *pool_p);
apr_status_t SetIRodsObject (IRodsObject *obj_p, const objType_t obj_type, const char *id_s, const char *data_s, const char *collection_s, const char *owner_name_s, const char *resource_s, const char *last_modified_time_s, const rodsLong_t size, const char *md5_s, apr_pool_t *pool_p);


IRodsObjectNode *AllocateIRodsObjectNode (const objType_t obj_type, const char *id_s, const char *data_s, const char *collection_s, const char *owner_name_s, const char *resource_s, const char *last_modified_time_s, const rodsLong_t size, apr_pool_t *pool_p);
IRodsObjectNode *AllocateIRodsObjectNode (const objType_t obj_type, const char *id_s, const char *data_s, const char *collection_s, const char *owner_name_s, const char *resource_s, const char *last_modified_time_s, const rodsLong_t size, const char *checksum_s, apr_pool_t *pool_p);

void FreeIRodsObjectNode (IRodsObjectNode *node_p);

Expand Down Expand Up @@ -176,6 +177,9 @@ char *GetIRodsObjectSizeAsString (const IRodsObject *irods_obj_p, apr_pool_t *po
char *GetIRodsObjectLastModifiedTime (const IRodsObject *irods_obj_p, apr_pool_t *pool_p);


const char *GetIRodsObjectChecksum (const IRodsObject *irods_obj_p);


apr_status_t GetAndPrintMetadataForIRodsObject (const IRodsObject *irods_obj_p, const char * const link_s, const char *zone_s, const struct HtmlTheme * const theme_p, apr_bucket_brigade *bb_p, rcComm_t *connection_p, request_rec *req_p, apr_pool_t *pool_p);


Expand Down
8 changes: 4 additions & 4 deletions meta.c
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ IRodsObjectNode *GetIRodsObjectNodeForId (const char *id_s, rcComm_t *rods_conne

if (stat_p)
{
node_p = AllocateIRodsObjectNode (COLL_OBJ_T, id_s, NULL, collection_s, stat_p -> ownerName, NULL, stat_p -> modifyTime, stat_p -> objSize, pool_p);
node_p = AllocateIRodsObjectNode (COLL_OBJ_T, id_s, NULL, collection_s, stat_p -> ownerName, NULL, stat_p -> modifyTime, stat_p -> objSize, stat_p -> chksum, pool_p);

if (node_p)
{
Expand Down Expand Up @@ -781,7 +781,7 @@ IRodsObjectNode *GetIRodsObjectNodeForId (const char *id_s, rcComm_t *rods_conne

if (stat_p)
{
node_p = AllocateIRodsObjectNode (DATA_OBJ_T, id_s, data_name_s, collection_s, stat_p -> ownerName, stat_p -> rescHier, stat_p -> modifyTime, stat_p -> objSize, pool_p);
node_p = AllocateIRodsObjectNode (DATA_OBJ_T, id_s, data_name_s, collection_s, stat_p -> ownerName, stat_p -> rescHier, stat_p -> modifyTime, stat_p -> objSize, stat_p -> chksum, pool_p);

if (node_p)
{
Expand Down Expand Up @@ -927,7 +927,7 @@ IRodsObjectNode *GetMatchingMetadataHits (const char * const key_s, const char *

if (stat_p)
{
IRodsObjectNode *node_p = AllocateIRodsObjectNode (COLL_OBJ_T, id_s, NULL, collection_s, stat_p -> ownerName, NULL, stat_p -> modifyTime, stat_p -> objSize, pool_p);
IRodsObjectNode *node_p = AllocateIRodsObjectNode (COLL_OBJ_T, id_s, NULL, collection_s, stat_p -> ownerName, NULL, stat_p -> modifyTime, stat_p -> objSize, stat_p -> chksum, pool_p);

if (node_p)
{
Expand Down Expand Up @@ -1048,7 +1048,7 @@ IRodsObjectNode *GetMatchingMetadataHits (const char * const key_s, const char *

if (stat_p)
{
IRodsObjectNode *node_p = AllocateIRodsObjectNode (DATA_OBJ_T, id_s, data_name_s, collection_s, stat_p -> ownerName, stat_p -> rescHier, stat_p -> modifyTime, stat_p -> objSize, pool_p);
IRodsObjectNode *node_p = AllocateIRodsObjectNode (DATA_OBJ_T, id_s, data_name_s, collection_s, stat_p -> ownerName, stat_p -> rescHier, stat_p -> modifyTime, stat_p -> objSize, stat_p -> chksum, pool_p);

if (node_p)
{
Expand Down
Loading

0 comments on commit d2ecf3c

Please sign in to comment.