[yast-commit] r48636 - in /trunk/ldap-server/src: LdapServer.pm agent/SlapdConfigAgent.cc tree_structure.ycp
Author: rhafer Date: Fri Jun 27 15:59:45 2008 New Revision: 48636 URL: http://svn.opensuse.org/viewcvs/yast?rev=48636&view=rev Log: Some error handling for Schemas Modified: trunk/ldap-server/src/LdapServer.pm trunk/ldap-server/src/agent/SlapdConfigAgent.cc trunk/ldap-server/src/tree_structure.ycp Modified: trunk/ldap-server/src/LdapServer.pm URL: http://svn.opensuse.org/viewcvs/yast/trunk/ldap-server/src/LdapServer.pm?rev... ============================================================================== --- trunk/ldap-server/src/LdapServer.pm (original) +++ trunk/ldap-server/src/LdapServer.pm Fri Jun 27 15:59:45 2008 @@ -347,6 +347,7 @@ { my $self = shift; my ( $msg, $details ) = @_; + y2milestone("Error: $msg, $details"); $error{'msg'} = $msg; $error{'details'} = $details; } @@ -610,7 +611,10 @@ my ($self, $file) = @_; my $rc = SCR->Write(".ldapserver.schema.addFromLdif", $file); - + if ( ! $rc ) { + my $err = SCR->Error(".ldapserver"); + $self->SetError( $err->{'summary'}, $err->{'description'} ); + } return $rc; } Modified: trunk/ldap-server/src/agent/SlapdConfigAgent.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/ldap-server/src/agent/SlapdConfig... ============================================================================== --- trunk/ldap-server/src/agent/SlapdConfigAgent.cc (original) +++ trunk/ldap-server/src/agent/SlapdConfigAgent.cc Fri Jun 27 15:59:45 2008 @@ -5,6 +5,7 @@ #include <LdifWriter.h> #include <LDAPEntry.h> #include <SaslInteraction.h> +#include <exception> #include <sstream> #include <fstream> @@ -695,14 +696,22 @@ std::string filename = arg->asString()->value_cstr(); y2milestone("adding Ldif File: %s", filename.c_str()); std::ifstream ldifFile(filename.c_str()); - LdifReader ldif(ldifFile); - if ( ldif.readNextRecord() ) - { - LDAPEntry entry, oldEntry; - entry = ldif.getEntryRecord(); - schema.push_back( boost::shared_ptr<OlcSchemaConfig>(new OlcSchemaConfig(oldEntry, entry)) ); + try { + LdifReader ldif(ldifFile); + if ( ldif.readNextRecord() ) + { + LDAPEntry entry, oldEntry; + entry = ldif.getEntryRecord(); + schema.push_back( boost::shared_ptr<OlcSchemaConfig>(new OlcSchemaConfig(oldEntry, entry)) ); + } + return YCPBoolean(true); + } catch ( std::runtime_error e ) { + lastError->add(YCPString("summary"), + YCPString("Error while parsing LDIF file") ); + lastError->add(YCPString("description"), + YCPString(std::string( e.what() ) ) ); + return YCPBoolean(false); } - return YCPBoolean(true); } if ( subpath == "remove" ) { Modified: trunk/ldap-server/src/tree_structure.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/ldap-server/src/tree_structure.yc... ============================================================================== --- trunk/ldap-server/src/tree_structure.ycp (original) +++ trunk/ldap-server/src/tree_structure.ycp Fri Jun 27 15:59:45 2008 @@ -74,16 +74,12 @@ ** global schema handlers *****************************/ -void update_schemalist( list<string> l, string select_item ) +void update_schemalist( list<string> l ) { if( l == nil ) l = []; //widget_map["g_schema","inclist"] = l; UI::ChangeWidget( `sb_schemalist, `Items, l ); UI::ChangeWidget( `pb_delete, `Enabled, false ); - if( select_item != nil ) - { - UI::ChangeWidget( `sb_schemalist, `CurrentItem, select_item ); - } } define boolean cb_read_schema() @@ -91,7 +87,7 @@ y2milestone( "calling schema read handler" ); list<string> inclist = LdapServer::GetSchemaList(); // //store current include list for later order changes - update_schemalist( inclist, nil ); + update_schemalist( inclist ); return true; } @@ -152,17 +148,27 @@ callback_error = _("The schema file is already in the list."); return false; } - - LdapServer::AddLdifToSchemaList(new_item); - list<string> inclist = LdapServer::GetSchemaList(); - update_schemalist( inclist, new_item ); + if ( regexpmatch( new_item, ".*\.schema$" ) ) + { + callback_error = _(".schema Files not supported yet"); + return false; + } + else if (! LdapServer::AddLdifToSchemaList(new_item) ) + { + map<string, string> err = LdapServer::GetError(); + callback_error = err["msg"]:"" + "\n" + err["details"]:""; + return false; + } else { + list<string> inclist = LdapServer::GetSchemaList(); + update_schemalist( inclist ); + } } else if( handler_cmd == `pb_delete ) { if( current_item == nil ) return true; LdapServer::RemoveFromSchemaList(current_item); list<string> inclist = LdapServer::GetSchemaList(); - update_schemalist( inclist, nil ); + update_schemalist( inclist ); } return true; } -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
rhafer@svn.opensuse.org