[otrs-cvs] ITSMConfigurationManagement/Kernel/System/ImportExport/ObjectBackend ITSMConfigItem.pm, 1.24, 1.25
"CVS commits notifications of OTRS.org" <[email protected]>
| Newsgroups | gmane.comp.otrs.cvs |
|---|---|
| Message-ID | <[email protected]> |
Comments:
Update of /home/cvs/ITSMConfigurationManagement/Kernel/System/ImportExport/ObjectBackend
In directory lancelot:/tmp/cvs-serv32293/Kernel/System/ImportExport/ObjectBackend
Modified Files:
ITSMConfigItem.pm
Log Message:
Added new optional sysconfig option to check if config item names are unique.
Author: ub
Index: ITSMConfigItem.pm
===================================================================
RCS file: /home/cvs/ITSMConfigurationManagement/Kernel/System/ImportExport/ObjectBackend/ITSMConfigItem.pm,v
retrieving revision 1.24
retrieving revision 1.25
diff -2 -u -d -r1.24 -r1.25
--- ITSMConfigItem.pm 13 Nov 2012 21:39:23 -0000 1.24
+++ ITSMConfigItem.pm 30 Nov 2012 19:49:09 -0000 1.25
@@ -20,4 +20,5 @@
use Kernel::System::ITSMConfigItem;
use Kernel::System::Time;
+use Kernel::System::VariableCheck qw(:all);
use vars qw($VERSION);
@@ -1104,4 +1105,47 @@
my $RetCode = $ConfigItemID ? 'Changed' : 'Created';
+
+ # check if the feature to check for a unique name is enabled
+ if (
+ IsStringWithData( $VersionData->{Name} )
+ && $Self->{ConfigObject}->Get('UniqueCIName::EnableUniquenessCheck')
+ )
+ {
+
+ if ( $Self->{ConfigObject}->{Debug} > 0 ) {
+ $Self->{LogObject}->Log(
+ Priority => 'debug',
+ Message => "Checking for duplicate names (ClassID: $ObjectData->{ClassID}, "
+ . "Name: $VersionData->{Name}, ConfigItemID: " . $ConfigItemID || 'NEW' . ')',
+ );
+ }
+
+ my $NameDuplicates = $Self->{ConfigItemObject}->UniqueNameCheck(
+ ConfigItemID => $ConfigItemID || 'NEW',
+ ClassID => $ObjectData->{ClassID},
+ Name => $VersionData->{Name},
+ );
+
+ # stop processing if the name is not unique
+ if ( IsArrayRefWithData($NameDuplicates) ) {
+
+ # build a string of all duplicate IDs
+ my $NameDuplicatesString = join ', ', @{$NameDuplicates};
+
+ $Self->{LogObject}->Log(
+ Priority => 'error',
+ Message =>
+ "The name $VersionData->{Name} is already in use by the ConfigItemID(s): "
+ . $NameDuplicatesString,
+ );
+
+ # set the return code to also include the duplicate name
+ $RetCode = "DuplicateName '$VersionData->{Name}'";
+
+ # return undef for the config item id so it will be counted as 'Failed'
+ return undef, $RetCode;
+ }
+ }
+
my $LatestVersionID = 0;
if ($ConfigItemID) {
---------------------------------------------------------------------
OTRS mailing list: cvs-log - Webpage: http://otrs.org/
Archive: http://lists.otrs.org/pipermail/cvs-log
To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/cvs-log