CVS edit link for gourley

MY CONTRIBUTION:

My motivation for requesting a drupal.org CVS account is to contribute a module for building custom interfaces to Fedora Commons repositories (http://www.fedora-commons.org/). The Fedora REST API module provides a programming interface to invoke Fedora Commons REST methods. By itself, the module can be used to create a simple presentation layer for a collection of objects in the repository, without any module development or PHP coding. But its real power is as a rapid application development tool to code custom modules for creating, managing and publishing collections of complex digital objects.

The module provides a programming interface to invoke Fedora Commons REST methods, including a PHP class that encapsulates all the REST API methods so they can be easily invoked from other Drupal modules. It also defines a type of node ("fedora_object") that represents a digital object in the repository. This content-type can be extended by defining a new content-type in a custom module and invoking my module's hook implementations to add the Fedora object attributes to the node. A template .module file is included to simplify the process of creating modules that extend the "fedora_object" content-type.

This module is based on work I did for the Digital Humanities Observatory which is described here: http://www.slideshare.net/gourley/integrating-drupal-fedora.

RELATED WORK:

Islandora (http://www.fedora-commons.org/confluence/display/ISLANDORA/Islandora) is the only other module that integrates Drupal with Fedora Commons repository software that I am aware of. Islandora is hosted at the Fedora Commons site rather than drupal.org. Moreover, there are differences in purpose and approach between Islandora and my Fedora REST API that justify their co-existence. My module is intended as a basic API and a tool for developing modules to meet local requirements and idiosyncrasies. Islandora is a complete, almost turn-key, application for viewing and managing digital objects stored in Fedora, and does not expose a Fedora Commons web services API for extension. Another important difference is that my module has a flexible mechanism for mapping Fedora object structure and description to Drupal nodes, so it can work with the numerous core and contributed modules that operate on nodes, such as search, taxonomy, CCK, workflow, and the like. Islandora, on the other hand, provides an interface to Fedora Commons functionality for searching and browsing rather than storing structural or descriptive metadata in the Drupal database, so Fedora-linked nodes cannot be used in standard Drupal ways.

STATUS:

The Fedora REST API module is fully functional. Earlier versions of it have been used to create Drupal web sites for the Digital Humanities Observatory, for example: http://dho.ie/doegen/. However, I would like to share it with other repository projects so we can get sense of (and improve) how well it works with different kinds of digital content and use cases, and to get additional maintainers from other institutions to share in its ongoing development.

The module has not yet been migrated and tested for Drupal 7, but if my application is accepted I will have a Drupal 7 release as soon as Drupal 7 is released.

CommentFileSizeAuthor
#1 fedora_rest-6.x-1.0-beta1.tar_.gz23.82 KBgourley

Comments

gourley’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new23.82 KB

I have attached a tarball of my fedora_rest module.

avpaderno’s picture

Issue tags: +Module review

Hello, and thanks for applying for a CVS account. I am adding the review tags, and some volunteers will review your code, pointing out what needs to be changed.

avpaderno’s picture

Status: Needs review » Needs work
  1. See http://drupal.org/coding-standards to understand how a module should be written. In particular, see how the code should be formatted (which includes the character used to indent the code), and how the constant should be written. The coding standards also report which names to use for constants, functions, and classes defined from the module.
  2.     $result = db_query("SELECT name FROM {users} ORDER BY name");
        while ($u = db_fetch_object($result)) {
            $users[$u->name] = $u->name;
        }
    

    The query doesn't filter out the user accounts that have been blocked, depending on the case, this can be a security issue.

  3.     if (module_exists('taxonomy')) {
            foreach(taxonomy_get_vocabularies( ) as $v) {
                $vocabs[$v->name] = $v->name;
            }
        }
    

    The code should probably use db_rewrite_sql().

  4.             drupal_set_message("WARNING: user '$nuser' not found; nodes will be owned by 'admin'.",'warning');
    

    Strings used in the user interface should be passed to t() (with the exception of when that is already done by Drupal code).

  5.     try {
            $client = new FedoraClient( $server, NULL, NULL, $version );
        } catch (Exception $e) {
            $exception = '<pre>'.print_r($e, true).'</pre>';
            drupal_set_message( "Exception Object:: $exception\n", 'error');
            fedora_rest_save_messages();
            return FALSE;
        }
    

    Exceptions are only present in PHP 5, but the module doesn't declare its dependency from that version. Drupal 6 is still compatible with PHP 4.

  6.     $coll = db_fetch_object( db_query("SELECT * FROM {fedora_rest_collection} WHERE uri='%s' AND server='%s' AND version='%s'", check_plain($collection),check_plain($server),check_plain($version)) );
    

    The query can return more than a row. If you want to get only the first row, you should call db_query_range().

  7. version = "6.x-1.0-beta1"
    

    The line is added by the packaging script, and it should not be manually added.

  8.     db_query("DELETE FROM {variable} WHERE name like 'fedora_rest_%'");
    

    The query could delete variables defined from a module with a name starting with fedora_rest_ (someone could create a module called fedora_rest_extension, and the module would delete also those variables). The preferred way to delete variables is to delete them singularly with variable_del().

  9. function fedora_rest_update_1() {}
    

    The module has never been hosted on Drupal.org. The update functions should be removed.

  10. define('FEDORA_REST_CREATE', 'create Fedora Object node');
    define('FEDORA_REST_UPDATE_OWN', 'update own FO node');
    define('FEDORA_REST_UPDATE_ANY', 'update any FO node');
    define('FEDORA_REST_DELETE_OWN', 'delete own FO node');
    define('FEDORA_REST_DELETE_ANY', 'delete any FO node');
    

    Using constants for the permissions would probably cause problems for the translation script, which is not able to extract the permission strings to put them in the translation template file (this means the permission strings will not be translated).
    It is also better to keep the permission strings consistent (if the first permission makes reference to Fedora object node, also the other permission strings should use the same term).

  11.     fedora_rest_trace("fedora_rest_node_info()");
    

    Remove any calls to debugging functions.

  12.         $form['show_pid'] = array(
                '#value' => t('<strong>Identifier:</strong> ')
                            . "<pre>$node->persistent_id</pre>\n",
                '#weight'=> -20
            );
    

    Use the t()-placeholders, instead of concatenating strings. This gives more context to who translates strings.

  13.         $form['persistent_id'] = array(
                '#type' => 'hidden',
                '#default_value' => $node->persistent_id,
            );
    

    Why isn't the code using '#type' => 'value'?

  14.             '#title' => t('Repository Collection'),
    

    Strings used in the user interface should be in sentence case.

  15.     if (isset($node->format)) {
            $format = $node->format;
        } else {
            $format = variable_get('fedora_rest_format', 0);
        }
    

    Why isn't the code using the default format set by Drupal?

  16. /**
     * Implements hook_alter()
     *
     */
    function fedora_rest_form_alter(&$form, $form_state, $form_id,
                                    $my_form='fedora_object_node_form')
    {
    

    The hook is an implementation of hook_form_alter(), not hook_alter(). The last parameter is not passed to the function from Drupal. The code should use a local variable, or simply a literal string.

gourley’s picture

Title: gourley [gourley] » CVS request for fedora_rest module [gourley]
Status: Needs work » Postponed

Thanks for the feedback. I am working on bringing it up to standards, but I'm not sure I can conform to drupal usage in all cases right now. So I'm posting the module on github and see if there is enough community interest to rewrite for contributing it to drupal.org.

If anyone is interested in using (or helping develop) this module, see http://github.com/dongourley/fedora_rest

avpaderno’s picture

Title: CVS request for fedora_rest module [gourley] » gourley [gourley]
avpaderno’s picture

Status: Postponed » Needs work

There is already an application for a similar module (#771670: alxp [alxp]).

gourley’s picture

Status: Needs work » Closed (duplicate)

Thanks.

avpaderno’s picture

Status: Closed (duplicate) » Closed (won't fix)
gabidrg’s picture

Status: Closed (won't fix) » Active

Hi Don and Alberto,

I've just had a presentation on Fedora Commons and Drupal at DrupalCamp Timisoara 2010 (http://drupalcamp.ro) this weekend. I included Don's module in a comparison vs Islandora and not Alexander's O'Neill work (http://drupal.org/node/771670) since Don's implementation of Fedora REST Api is complete: it includes both REST API's of FC, API-A for access, and API-M for management. As far as I've seen in the other project (alxp), only API-A is implemented there.

I followed Gabor Hojsty's suggestion to give some feedback on this issue, after presenting Fedora Commons and Drupal at our camp, so here it is. I suggest we have a merge between projects, maybe Don and Alex can agree. I think Don's module is more complete now. More, Don already has live sites running based on his contribution, so we have a broader base for starting and expanding the module. I've already contacted Don and I am volunteering to help solve the code standards issues. I already have a CVS account, so we can make a team of three working on this integration.

All the best,
Gabriel Dragomir
Drupal Romania Association

avpaderno’s picture

Status: Active » Needs review

Let's see what gourley thinks.

gourley’s picture

I think its a great idea, and I am very happy to get Gabriel's help with this. I would like to work with Alex also but am not sure what would be involved in merging our work.

gabidrg’s picture

Alexander O'Neill is one of the developers of Islandora, at UPEI. I am not sure where he intends to head with development on his API module and what's next on Islandora's plate, but as long as we get along having a Fedora REST API project released, we can think about what should be done next. For sure, a complete rewrite will be needed for Drupal 7 to accomodate the fields-instance-bundle paradigm and new database abstraction layer in D7.

When thinking about merging, I was more thinking about deciding which of the projects should get promoted into Drupal.org, since they really implement the same functionality, maybe with slightly different programming approaches. I will try to compare what we have in both projects. So far, I've seen Don's project as being more complete.

boris mann’s picture

Status: Needs review » Active

Please grant CVS access as a co-maintainer for Fedora Commons API #862262: Grant CVS access to gourley and alxp as co-maintainers

avpaderno’s picture

Status: Active » Fixed

Thank you for your contribution! I am going to update your account.

These are some recommended readings to help with excellent maintainership:

You can find more contributors chatting on the IRC #drupal-contribute channel. So, come hang out and stay involved.
Thank you, also, for your patience with the review process.
Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

I thank all the dedicated reviewers as well.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Yorkaev’s picture

Component: Miscellaneous » miscellaneous

Hi EveryBody,

First of all, thanks for your module. Im trying to use your module but I dont know how to configure Fedora API settings. What should I have to put in the field "Collection URI"??

I have a fedora in http://localhost:8080/fedora with this information:

Base URL: http://localhost:8080/fedora
Version: 3.4.2
PID Namespace: changeme
PID Delimiter: :
Sample PID: changeme:100
Retain PID Namespace: *
OAI Namespace: example.org
OAI Delimiter: :
Sample OAI Identifier: oai:example.org:changeme:100
Sample Search URL: http://localhost:8080/fedora/objects
Sample Access URL: http://localhost:8080/fedora/objects/demo:5
Sample OAI URL: http://localhost:8080/fedora/oai?verb=Identify
Admin Email: bob@example.org
Admin Email: sally@example.org

The problem, is that when I try to create a fedora object, the combo "Repository Collection" is not filled.

Thanks in advance

avpaderno’s picture

Component: miscellaneous » co-maintainer application
Issue summary: View changes
Status: Closed (fixed) » Fixed

I am giving credits to the users who participated in this issue.

avpaderno’s picture

Assigned: Unassigned » avpaderno

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.