Code

* Updated utf-8 handling
[gosa.git] / gosa-si / modules / GosaPackages.pm
index b4b37bb9ba81e5de69723d93dd58a87153a46bc6..d5a0a6b4b1f4f8abdef8c2a278e15df2c1948ba0 100644 (file)
@@ -264,7 +264,7 @@ sub process_incoming_msg {
     my @msg_l;
     my @out_msg_l;
 
-    &main::daemon_log("DEBUG: GosaPackages: receive '$header'", 8);
+    &main::daemon_log("DEBUG: GosaPackages: msg to process '$header'", 7);
     
     if ($header =~ /^job_/) {
         @msg_l = &process_job_msg($msg, $msg_hash, $session_id);
@@ -303,23 +303,36 @@ sub process_incoming_msg {
 sub process_gosa_msg {
     my ($msg, $msg_hash, $session_id) = @_ ;
     my $out_msg;
-    my @out_msg_l = ();
+    my @out_msg_l = ('nohandler');
     
     my $header = @{$msg_hash->{'header'}}[0];
     $header =~ s/gosa_//;
 
     if( exists $event_hash->{$header} ) {
         # a event exists with the header as name
-        &main::daemon_log("found event '$header' at event-module '".$event_hash->{$header}."'", 5);
+        &main::daemon_log("INFO: found event '$header' at event-module '".$event_hash->{$header}."'", 5);
         no strict 'refs';
         @out_msg_l = &{$event_hash->{$header}."::$header"}($msg, $msg_hash, $session_id);
     }
 
+    # if incoming 'gosa_'-msg is scheduled from job_queue, than it contains xml-tag 'jobdb_id'
+    # after procesing this msg, set status of this job in job_queue to done
+    if ($msg =~ /<jobdb_id>(\d+)<\/jobdb_id>/) {
+        my $sql_statement = "UPDATE $main::job_queue_tn ".
+            "SET status='done' ".
+            "WHERE id='$1'";
+        &main::daemon_log("DEBUG: $sql_statement", 7);         
+        my $res = $main::job_db->update_dbentry($sql_statement);
+        &main::daemon_log("INFO: set job '$1' to status processed", 5); 
+    }
+
     # if delivery not possible raise error and return 
-    if( not @out_msg_l ) {
+    if( not defined $out_msg_l[0] ) {
         &main::daemon_log("WARNING: GosaPackages got no answer from event handler '$header'", 3);
-    } elsif( 0 == @out_msg_l) {
+        @out_msg_l = ();
+    } elsif( $out_msg_l[0] eq 'nohandler') {
         &main::daemon_log("ERROR: GosaPackages: no event handler or core function defined for '$header'", 1);
+        @out_msg_l = ();
     } 
 
     return @out_msg_l;
@@ -344,6 +357,8 @@ sub process_job_msg {
     my $macaddress;
     if( exists $msg_hash->{'macaddress'} ) {
         $macaddress = @{$msg_hash->{'macaddress'}}[0];
+    } elsif (@{$msg_hash->{'target'}}[0] =~ /^([0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2})$/i ) {
+        $macaddress = $1;
     } else {
         $error ++;
         $out_msg = "<xml>".
@@ -351,7 +366,7 @@ sub process_job_msg {
             "<source>$server_address</source>".
             "<target>GOSA</target>".
             "<answer1>1</answer1>".
-            "<error_string>no mac address specified</error_string>".
+            "<error_string>no mac address specified, neither in target-tag nor in macaddres-tag</error_string>".
             "</xml>";
     }