LP#1680566 Deprecate permacrud WIP user/berick/lp1680566-deprecate-permacrud
authorBill Erickson <berickxx@gmail.com>
Tue, 7 Nov 2017 18:02:09 +0000 (13:02 -0500)
committerBill Erickson <berickxx@gmail.com>
Tue, 7 Nov 2017 19:07:09 +0000 (14:07 -0500)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/examples/opensrf.xml.example
Open-ILS/examples/opensrf_core.xml.example
Open-ILS/src/perlmods/MANIFEST
Open-ILS/src/perlmods/lib/OpenILS/Application/PermaCrud.pm [deleted file]
Open-ILS/web/js/dojo/openils/widget/TranslatorPopup.js
Open-ILS/web/js/ui/default/vandelay/vandelay.js
Open-ILS/xul/staff_client/chrome/content/cat/opac.js
docs/development/intro_opensrf.adoc

index 156562b..3c8d774 100644 (file)
@@ -1144,24 +1144,6 @@ vim:et:ts=4:sw=4:
             </open-ils.resolver>
 -->
 
-            <open-ils.permacrud>
-               <keepalive>3</keepalive>
-               <stateless>1</stateless>
-               <language>perl</language>
-               <implementation>OpenILS::Application::PermaCrud</implementation>
-               <max_requests>17</max_requests>
-               <unix_config>
-                  <unix_sock>open-ils.permacrud_unix.sock</unix_sock>
-                  <unix_pid>open-ils.permacrud_unix.pid</unix_pid>
-                  <max_requests>1000</max_requests>
-                  <unix_log>open-ils.permacrud_unix.log</unix_log>
-                  <min_children>5</min_children>
-                  <max_children>15</max_children>
-                  <min_spare_children>3</min_spare_children>
-                  <max_spare_children>5</max_spare_children>
-               </unix_config>
-            </open-ils.permacrud>
-
             <open-ils.fielder>
                <keepalive>3</keepalive>
                <stateless>1</stateless>
index 45e5f5a..2ed449e 100644 (file)
@@ -29,7 +29,6 @@ Example OpenSRF bootstrap configuration file for Evergreen
           <service>open-ils.collections</service>
           <service>open-ils.fielder</service>
           <service>open-ils.pcrud</service>
-          <service>open-ils.permacrud</service>
           <service>open-ils.reporter</service>
           <service>open-ils.resolver</service>
           <service>open-ils.search</service>
index cb980a6..1d5750e 100644 (file)
@@ -44,7 +44,6 @@ lib/OpenILS/Application/EbookAPI/Test.pm
 lib/OpenILS/Application/EbookAPI/OverDrive.pm
 lib/OpenILS/Application/EbookAPI/OneClickdigital.pm
 lib/OpenILS/Application/Fielder.pm
-lib/OpenILS/Application/PermaCrud.pm
 lib/OpenILS/Application/Proxy.pm
 lib/OpenILS/Application/Reporter.pm
 lib/OpenILS/Application/ResolverResolver.pm
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/PermaCrud.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/PermaCrud.pm
deleted file mode 100644 (file)
index f2e90fc..0000000
+++ /dev/null
@@ -1,281 +0,0 @@
-# vim:et:ts=4:sw=4:
-
-package OpenILS::Application::PermaCrud;
-use OpenILS::Application;
-use base qw/OpenILS::Application/;
-use strict; use warnings;
-
-use Unicode::Normalize;
-use OpenSRF::EX qw/:try/;
-
-use OpenSRF::AppSession;
-use OpenSRF::Utils::SettingsClient;
-use OpenSRF::Utils::Logger qw/:level/;
-
-use OpenILS::Utils::Fieldmapper;
-use OpenSRF::Utils::JSON;
-
-use OpenILS::Utils::CStoreEditor qw/:funcs/;
-
-use XML::LibXML;
-use XML::LibXML::XPathContext;
-use XML::LibXSLT;
-use OpenILS::Event;
-
-our %namespace_map = (
-    oils_persist=> {ns => 'http://open-ils.org/spec/opensrf/IDL/persistence/v1'},
-    oils_obj    => {ns => 'http://open-ils.org/spec/opensrf/IDL/objects/v1'},
-    idl         => {ns => 'http://opensrf.org/spec/IDL/base/v1'},
-    reporter    => {ns => 'http://open-ils.org/spec/opensrf/IDL/reporter/v1'},
-    perm        => {ns => 'http://open-ils.org/spec/opensrf/IDL/permacrud/v1'},
-);
-
-
-my $log = 'OpenSRF::Utils::Logger';
-
-my $parser = XML::LibXML->new();
-my $xslt = XML::LibXSLT->new();
-
-my $xpc = XML::LibXML::XPathContext->new();
-$xpc->registerNs($_, $namespace_map{$_}{ns}) for ( keys %namespace_map );
-
-my $idl;
-
-sub initialize {
-
-    my $conf = OpenSRF::Utils::SettingsClient->new;
-    my $idl_file = $conf->config_value( 'IDL' );
-
-    $idl = $parser->parse_file( $idl_file );
-
-    $log->debug( 'IDL XML file loaded' );
-
-    generate_methods();
-
-}
-sub child_init {}
-
-sub CRUD_action_object_permcheck {
-    my $self = shift;
-    my $client = shift;
-    my $auth = shift;
-    my $obj = shift;
-
-    my $e = shift || new_editor(authtoken => $auth, xact => 1);
-    return $e->event unless $e->checkauth;
-
-    if (ref($obj) && $obj->json_hint ne $self->{class_hint}) {
-        throw OpenSRF::DomainObject::oilsException->new(
-            statusCode => 500,
-            status => "Class missmatch: $self->{class_hint} method called with " . $obj->json_hint,
-        );
-    }
-
-    my $class_node;
-    my $error = '';
-    try {
-        ($class_node) = $xpc->findnodes( "//idl:class[\@id='$self->{class_hint}']", $idl->documentElement );
-    } catch Error with {
-        $error = shift;
-        $log->error("Error finding class node: $error [//idl:class[\@id='$self->{class_hint}']]");
-        throw OpenSRF::DomainObject::oilsException->new(
-            statusCode => 500,
-            status => "Error finding class node: $error [//idl:class[\@id='$self->{class_hint}']]"
-        );
-    };
-
-    if (!$class_node) {
-        $log->error("Error finding class node: $error [//idl:class[\@id='$self->{class_hint}']]");
-        throw OpenSRF::DomainObject::oilsException->new(
-            statusCode => 500,
-            status => "Error finding class node: $error [//idl:class[\@id='$self->{class_hint}']]"
-        );
-    }
-
-    my $action_node;
-    try {
-        ($action_node) = $xpc->findnodes( "perm:permacrud/perm:actions/perm:$self->{action}", $class_node );
-    } catch Error with {
-        $error = shift;
-        $log->error("Error finding action node: $error [perm:permacrud/perm:actions/perm:$self->{action}]");
-        throw OpenSRF::DomainObject::oilsException->new(
-            statusCode => 500,
-            status => "Error finding action node: $error [perm:permacrud/perm:actions/perm:$self->{action}]"
-        );
-    };
-
-    if (!$action_node) {
-        $log->error("Error finding action node: $error [perm:permacrud/perm:actions/perm:$self->{action}]");
-        throw OpenSRF::DomainObject::oilsException->new(
-            statusCode => 500,
-            status => "Error finding action node: $error [perm:permacrud/perm:actions/perm:$self->{action}]"
-        );
-    }
-
-    my $all_perms = $action_node->getAttribute( 'all_perms' );
-
-    my $fm_class = $xpc->findvalue( '@oils_obj:fieldmapper', $class_node );
-    if (!ref($obj)) {
-        my $retrieve_method = 'retrieve_' . $fm_class;
-        $retrieve_method =~ s/::/_/go;
-        $obj = $e->$retrieve_method( $obj ) or return $e->die_event;
-    }
-
-    (my $o_type = $fm_class) =~ s/::/./go;
-
-    my $perm_field_value = $action_node->getAttribute('permission');
-
-    if ($perm_field_value) {
-        my @perms = split ' ', $perm_field_value;
-
-        my @context_ous;
-        if ($action_node->getAttribute('global_required')) {
-            push @context_ous, $e->search_actor_org_unit( { parent_ou => undef } )->[0]->id;
-
-        } else {
-            my $context_field_value = $action_node->getAttribute('context_field');
-
-            if ($context_field_value) {
-                push @context_ous, $obj->$_ for ( split ' ', $context_field_value );
-            } else {  
-                for my $context_node ( $xpc->findnodes( "perm:context", $action_node ) ) {
-                    my $context_field = $context_node->getAttribute('field');
-                    my $link_field = $context_node->getAttribute('link');
-
-                    if ($link_field) {
-
-                        my ($link_node) = $xpc->findnodes( "idl:links/idl:link[\@field='$link_field']", $class_node );
-                        my $link_class_hint = $link_node->getAttribute('class');
-                        my $remote_field = $link_node->getAttribute('key');
-
-                        my ($remote_class_node) = $xpc->findnodes( "//idl:class[\@id='$link_class_hint']", $idl->documentElement );
-                        my $search_method = 'search_' . $xpc->findvalue( '@oils_obj:fieldmapper', $remote_class_node );
-                        $search_method =~ s/::/_/go;
-
-                        for my $remote_object ( @{$e->$search_method( { $remote_field => $obj->$link_field } )} ) {
-                            push @context_ous, $remote_object->$context_field;
-                        }
-                    } else {
-                        push @context_ous, $obj->$_ for ( split ' ', $context_field );
-                    }
-                }
-            }
-        }
-
-        my $pok = 0;
-        for my $perm (@perms) {
-            if (@context_ous) {
-                for my $c_ou (@context_ous) {
-                    if ($e->allowed($perm => $c_ou => $obj)) {
-                        $pok++;
-                        last;
-                    }
-                }
-            } else {
-                $pok++ if ($e->allowed($perm => undef => $obj));
-            }
-        }
-
-        if ((lc($all_perms) eq 'true' && @perms != $pok) or !$pok) {
-            return OpenILS::Event->new('PERM_FAILURE', 
-                ilsperm => "", # XXX add logic to report which perm failed
-                ilspermloc => "",
-                payload => "Perm failure -- action: $self->{action}, object type: $self->{json_hint}",
-            );
-        }
-    }
-
-    if ($self->{action} eq 'retrieve') {
-        $e->rollback;
-        return $obj;
-    }
-
-    $o_type =~ s/\./_/og;
-    my $method = $self->{action} . "_$o_type";
-    my $val = $e->$method($obj) or return $e->die_event;
-    $e->commit;
-
-    return $val;
-}
-
-sub search_permacrud {
-    my $self = shift;
-    my $client = shift;
-    my $auth = shift;
-    my @args = @_;
-
-    if (@args > 1) {
-        delete $args[1]{flesh};
-        delete $args[1]{flesh_fields};
-    }
-
-    my $e = new_editor(authtoken => $auth, xact => 1);
-    return $e->event unless $e->checkauth;
-    my $class_node;
-    try {
-        ($class_node) = $xpc->findnodes( "//idl:class[\@id='$self->{class_hint}']", $idl->documentElement );
-    } catch Error with {
-        my $error = shift;
-        $log->error("Error finding class node: $error [//idl:class[\@id='$self->{class_hint}']]");
-        throw OpenSRF::DomainObject::oilsException->new(
-            statusCode => 500,
-            status => "Error finding class node: $error [//idl:class[\@id='$self->{class_hint}']]"
-        );
-    };
-
-    my $search_method = 'search_' . $xpc->findvalue( '@oils_obj:fieldmapper', $class_node );
-    $search_method =~ s/::/_/go;
-
-    $log->debug("Calling CStoreEditor search method: $search_method");
-
-    my $obj_list = $e->$search_method( \@args );
-
-    my $retriever = $self->method_lookup( $self->{retriever} );
-    for my $o ( @$obj_list ) {
-        try {
-            ($o) = $retriever->run( $auth, $o, $e );
-            $client->respond( $o ) if ($o);
-        };
-    }
-
-    return undef;
-}
-
-sub generate_methods {
-    try {
-        for my $class_node ( $xpc->findnodes( '//idl:class[perm:permacrud]', $idl->documentElement ) ) {
-            my $hint = $class_node->getAttribute('id');
-            $log->debug("permacrud class_node $hint");
-        
-            for my $action_node ( $xpc->findnodes( "perm:permacrud/perm:actions/perm:*", $class_node ) ) {
-                (my $method = $action_node->localname) =~ s/^.+:(.+)$/$1/o;
-                $log->internal("permacrud method = $method");
-        
-                __PACKAGE__->register_method(
-                    method          => 'CRUD_action_object_permcheck',
-                    api_name        => 'open-ils.permacrud.' . $method . '.' . $hint,
-                    class_hint      => $hint,
-                    action          => $method,
-                );
-        
-                if ($method eq 'retrieve') {
-                    __PACKAGE__->register_method(
-                        method          => 'search_permacrud',
-                        api_name        => 'open-ils.permacrud.search.' . $hint,
-                        class_hint      => $hint,
-                        retriever       => 'open-ils.permacrud.retrieve.' . $hint,
-                        stream          => 1
-                    );
-                }
-            }
-        }
-    } catch Error with {
-        my $e = shift;
-        $log->error("error generating permacrud methods: $e");
-    };
-}
-
-
-1;
-
index e301746..6f1599c 100644 (file)
@@ -220,8 +220,8 @@ if(!dojo._hasResource["openils.widget.TranslatorPopup"]) {
                     }
                 }
 
-                               OpenSRF.CachedClientSession('open-ils.permacrud').request({
-                                       method : 'open-ils.permacrud.' + method + '.i18n',
+                               OpenSRF.CachedClientSession('open-ils.pcrud').request({
+                                       method : 'open-ils.pcrud.' + method + '.i18n',
                                        timeout: 10,
                                        params : [ ses, trans_obj ],
                                        onerror: function (r) {
index b60cab0..9d4bbae 100644 (file)
@@ -172,7 +172,7 @@ function vlInit() {
     );
 
     fieldmapper.standardRequest(
-        ['open-ils.permacrud', 'open-ils.permacrud.search.cbs.atomic'],
+        ['open-ils.pcrud', 'open-ils.pcrud.search.cbs.atomic'],
         {   async: true,
             params: [authtoken, {id:{"!=":null}}, {order_by:{cbs:'id'}}],
             oncomplete : function(r) {
@@ -285,7 +285,7 @@ openils.Util.addOnLoad(vlInit);
 function vlFetchBibAttrDefs(postcomplete) {
     bibAttrDefs = [];
     fieldmapper.standardRequest(
-        ['open-ils.permacrud', 'open-ils.permacrud.search.vqbrad'],
+        ['open-ils.pcrud', 'open-ils.pcrud.search.vqbrad'],
         {   async: true,
             params: [authtoken, {id:{'!=':null}}],
             onresponse: function(r) {
@@ -311,7 +311,7 @@ function vlFetchBibAttrDefs(postcomplete) {
 function vlFetchAuthAttrDefs(postcomplete) {
     authAttrDefs = [];
     fieldmapper.standardRequest(
-        ['open-ils.permacrud', 'open-ils.permacrud.search.vqarad'],
+        ['open-ils.pcrud', 'open-ils.pcrud.search.vqarad'],
         {   async: true,
             params: [authtoken, {id:{'!=':null}}],
             onresponse: function(r) {
@@ -1765,10 +1765,10 @@ function vlOpenMarcEditWindow(rec, postReloadHTMLHandler) {
         save : {
             label: dojo.byId('vl-marc-edit-save-label').innerHTML,
             func: function(xmlString) {
-                var method = 'open-ils.permacrud.update.' + rec.classname;
+                var method = 'open-ils.pcrud.update.' + rec.classname;
                 rec.marc(xmlString);
                 fieldmapper.standardRequest(
-                    ['open-ils.permacrud', method],
+                    ['open-ils.pcrud', method],
                     {   async: true,
                         params: [authtoken, rec],
                         oncomplete: onsave
@@ -1782,12 +1782,12 @@ function vlOpenMarcEditWindow(rec, postReloadHTMLHandler) {
 }
 
 function vlLoadMarcEditor(type, recId, postReloadHTMLHandler) {
-    var method = 'open-ils.permacrud.search.vqbr';
+    var method = 'open-ils.pcrud.search.vqbr';
     if(currentType != 'bib')
         method = method.replace(/vqbr/,'vqar');
 
     fieldmapper.standardRequest(
-        ['open-ils.permacrud', method],
+        ['open-ils.pcrud', method],
         {   async: true, 
             params: [authtoken, {id : recId}],
             oncomplete: function(r) {
@@ -1915,14 +1915,14 @@ function vlSaveAttrDefinition(data) {
     var isAuth   = (ATTR_EDIT_GROUP == 'auth');
     var isCreate = (ATTR_EDIT_ID == null);
     var rad      = isAuth ? new vqarad() : new vqbrad() ;
-    var method   = 'open-ils.permacrud' + (isCreate ? '.create.' : '.update.') 
+    var method   = 'open-ils.pcrud' + (isCreate ? '.create.' : '.update.') 
        + (isAuth ? 'vqarad' : 'vqbrad');
     var _data    = rad.fromStoreItem(data);
 
     _data.ischanged(1);
 
     fieldmapper.standardRequest(
-        ['open-ils.permacrud', method],
+        ['open-ils.pcrud', method],
         {   async: true,
             params: [authtoken, _data ],
            onresponse: function(r) { },
@@ -1947,10 +1947,10 @@ function vlAttrDelete() {
     idShow('vl-generic-progress');
 
     var isAuth = (ATTR_EDIT_GROUP == 'auth');
-    var method = 'open-ils.permacrud.delete.' + (isAuth ? 'vqarad' : 'vqbrad');
+    var method = 'open-ils.pcrud.delete.' + (isAuth ? 'vqarad' : 'vqbrad');
     var rad    = isAuth ? new vqarad() : new vqbrad() ;
     fieldmapper.standardRequest(
-        ['open-ils.permacrud', method],
+        ['open-ils.pcrud', method],
         {   async: true,
            params: [authtoken, rad.fromHash({ id : ATTR_EDIT_ID }), ],
            oncomplete: function() {
index 673eede..b0726d4 100644 (file)
@@ -708,8 +708,8 @@ function delete_mfhd(sre_id) {
         null,
         document.getElementById('offlineStrings').getString('cat.opac.record_deleted.confirm')) == 0) {
         var robj = g.network.request(
-                'open-ils.permacrud',
-                'open-ils.permacrud.delete.sre',
+                'open-ils.pcrud',
+                'open-ils.pcrud.delete.sre',
                 [ses(),sre_id]);
         if (typeof robj.ilsevent != 'undefined') {
             alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_deleted.error',  [docid, robj.textcode, robj.desc]) + '\n');
@@ -747,10 +747,10 @@ function open_marc_editor(rec, label) {
         save : {
             label: 'Save ' + label,
             func: function(xmlString) {  // TODO: switch to pcrud, or define an sre update method in Serial.pm?
-                var method = 'open-ils.permacrud.update.' + rec.classname;
+                var method = 'open-ils.pcrud.update.' + rec.classname;
                 rec.marc(xmlString);
                 g.network.request(
-                    'open-ils.permacrud', method,
+                    'open-ils.pcrud', method,
                     [ses(), rec]
                 );
                 xulG.reload_opac();
index 2bce37b..51583bc 100644 (file)
@@ -1194,8 +1194,6 @@ set of OpenSRF services:
   * `open-ils.pcrud`: Supports access to Evergreen fieldmapper objects,
   restricted by staff user permissions. This is a private service.
     objects.
-  * `open-ils.permacrud`: Supports access to Evergreen fieldmapper objects,
-  restricted by staff user permissions. This is a private service.
   * `open-ils.reporter`: Supports the creation and scheduling of reports.
   * `open-ils.reporter-store`: Supports access to Evergreen fieldmapper objects
     for the reporting service. This is a private service.