xref: /aoo41x/main/solenv/bin/modules/Cws.pm (revision 998b778a)
1#**************************************************************
2#
3#  Licensed to the Apache Software Foundation (ASF) under one
4#  or more contributor license agreements.  See the NOTICE file
5#  distributed with this work for additional information
6#  regarding copyright ownership.  The ASF licenses this file
7#  to you under the Apache License, Version 2.0 (the
8#  "License"); you may not use this file except in compliance
9#  with the License.  You may obtain a copy of the License at
10#
11#    http://www.apache.org/licenses/LICENSE-2.0
12#
13#  Unless required by applicable law or agreed to in writing,
14#  software distributed under the License is distributed on an
15#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16#  KIND, either express or implied.  See the License for the
17#  specific language governing permissions and limitations
18#  under the License.
19#
20#**************************************************************
21
22
23
24
25#
26# Cws.pm - package for accessing/manipulating child workspaces
27#
28
29# TODO: needs some cleanup
30
31package Cws;
32use strict;
33
34use Eis;
35use CwsConfig;
36use Carp;
37use URI::Escape;
38
39my $config = CwsConfig::get_config();
40
41##### class data #####
42
43my %CwsClassData = (
44    # EIS database connectivity
45    EIS_URI        => 'urn:ChildWorkspaceDataService',
46    EIS_PROXY_LIST => $config->cws_db_url_list_ref(),
47    NET_PROXY      => $config->net_proxy(),
48    EIS            => undef
49);
50
51##### ctor #####
52
53sub new
54{
55    my $invocant = shift;
56    my $class = ref($invocant) || $invocant;
57    my $self = {};
58    # instance data
59    # initialize CWS name from environment
60    $self->{CHILD}        = undef;    # name of child workspace
61    $self->{MASTER}       = undef;    # name of master workspace
62    $self->{EIS_ID}       = undef;    # id of child workspace in EIS
63    $self->{FILES}        = undef;    # list of files registered with child
64                                      # any file can be registered multiple times
65    $self->{PATCH_FILES}  = undef     # list of product patch files registered with
66                                      # child, each file can be added only once
67    $self->{MILESTONE}    = undef;    # master milestone to which child is related
68    $self->{MODULES}      = undef;    # list of modules belonging to child
69    $self->{INCOMPATIBLE_MODULES}      = undef;    # list of modules belonging to child
70    $self->{NEW_MODULES}      = undef; # list of public new modules belonging to child
71    $self->{NEW_MODULES_PRIV}      = undef; # list of private new modules belonging to child
72    $self->{TASKIDS}      = undef;    # list of tasks registered with child
73    $self->{_CACHED_TAGS} = undef;    # list of cached tags (tags are looked up frequently)
74    bless($self, $class);
75    return $self;
76}
77
78#### methods to access instance data ####
79
80# Get the EIS ID for child workspace,
81# return value: undef => not yet asked EIS for ID
82#                        or connection failed
83#               0     => queried EIS but didn't find such
84#                        a child workspace for this master
85# silently ignore any parameter, only the EIS database,
86# hands out EIS IDs.
87sub eis_id
88{
89    my $self = shift;
90    if ( !defined($self->{EIS_ID} ) ) {
91            $self->{EIS_ID} = $self->get_eis_id();
92    }
93    return $self->{EIS_ID};
94}
95
96# Generate remaining instance data accessor methods;
97# if this looks strange see 'perldoc perltootc'
98
99# Accessor methods for single value instance data
100for my $datum (qw(master milestone)) {
101    no strict "refs";
102    *$datum = sub {
103        my $self = shift;
104        my $ucdatum = uc($datum);
105        if ( @_ ) {
106            # set item in database
107            my $item = shift;
108            # if we already have a valid EIS registered CWS then reset EIS value
109            # otherwise just set member to the given value
110            if ( !$self->{uc($datum)} # keep order of evaluation
111                || !$self->eis_id()
112                || $self->set_item_in_eis($datum, $item) )
113            {
114               $self->{uc($datum)} = $item;
115
116            }
117        }
118        else {
119            if ( !defined($self->{$ucdatum} ) ) {
120                # fetch item from database
121                $self->{$ucdatum} = $self->fetch_item_from_eis($datum);
122            }
123        }
124        return $self->{uc($datum)};
125    }
126}
127
128# Accessor methods for instance data consisting of item lists
129# like modules and taskids
130for my $datum (qw(files patch_files modules incompatible_modules new_modules new_modules_priv taskids)) {
131    no strict "refs";
132    *$datum = sub {
133        # get current item list
134        # fetch list from EIS database if called the first time
135        my $self = shift;
136        my $ucdatum = uc($datum);
137        if ( !defined($self->{$ucdatum}) ) {
138            # fetch item list from databse
139            $self->{$ucdatum} = $self->fetch_items_from_eis($datum);
140            return undef if !defined($self->{$ucdatum});
141        }
142        return wantarray ? @{$self->{$ucdatum}} : $self->{$ucdatum}
143    }
144}
145
146for my $datum (qw(child)) {
147    no strict "refs";
148    *$datum = sub {
149        my $self = shift;
150        $self->{uc($datum)} = shift if @_;
151        return $self->{uc($datum)};
152    }
153}
154
155
156#### additional public methods ####
157
158# For resync: Sets master and milestone simultaneously
159# In case of a cross master resync it does not make sense to
160# change both items separately
161sub set_master_and_milestone
162{
163    my $self      = shift;
164    my $master    = shift or return undef;
165    my $milestone = shift or return undef;
166
167    # if we do not yet have a valid EIS registered CWS use the above more basic methods
168    if ( !$self->master()
169         || !$self->milestone()
170         || !$self->eis_id() )
171    {
172        $self->master($master);
173        $self->milestone($milestone);
174    } else {
175        if ( $self->set_master_and_milestone_in_eis($master, $milestone) ) {
176            $self->{'MASTER'} = $self->fetch_item_from_eis('master');
177            $self->{'MILESTONE'} = $self->fetch_item_from_eis('milestone');
178        }
179    }
180    my @retarray = ($self->{'MASTER'}, $self->{'MILESTONE'});
181    return wantarray ? @retarray : \@retarray;
182}
183
184# Query if CWS name is still available. Does not yet register
185# anything with EIS.
186sub is_cws_name_available
187{
188    my $self     = shift;
189
190    my $is_available = $self->is_cws_name_available_in_eis();
191    return $is_available;
192}
193
194# Register new child workspace with the EIS database.
195sub register
196{
197    my $self     = shift;
198    my $vcsid    = shift;
199    my $location = shift;
200
201    my $child_id = $self->register_child_with_eis($vcsid, $location);
202    return $child_id;
203}
204
205# Promote a child workspace with status 'planned' to a full CWS
206sub promote
207{
208    my $self     = shift;
209    my $vcsid    = shift;
210    my $location = shift;
211
212    my $rc = $self->promote_child_in_eis($vcsid, $location);
213    return $rc;
214}
215
216# New style add_module method. Takes an additional bool indicating if
217# a module is public or private. Obsoletes add_modules()
218sub add_module
219{
220    my $self   = shift;
221    my $module = shift;
222    my $public = shift;
223
224    my $items_ref =  $self->add_items('modules', $public, $module);
225    if (defined ($items_ref->[0]) &&  ($items_ref->[0] eq $module)) {
226        return 1;  # module has been added
227    }
228    elsif ( defined($items_ref) ) {
229        return 0;  # module was already add
230    }
231    return undef;  # something went wrong
232}
233
234# Add module to modules list.
235sub add_modules
236{
237    my $self   = shift;
238
239    my $items_ref =  $self->add_items('modules', undef, @_);
240    return undef unless defined($items_ref);
241    return wantarray ? @{$items_ref} : $items_ref;
242}
243
244# Add tasksids to taskids list.
245sub add_taskids
246{
247    my $self   = shift;
248    my $vcsid  = shift;
249
250    my $items_ref = $self->add_items('taskids', $vcsid, @_);
251    return undef unless defined($items_ref);
252    return wantarray ? @{$items_ref} : $items_ref;
253}
254
255# Add a file to the files list.
256sub add_file
257{
258    my $self         = shift;
259    my $module       = shift;
260    my $file         = shift;
261    my $revision     = shift;
262    my $authors_ref  = shift;
263    my $taskids_ref  = shift;
264    my $archive_path = shift;
265
266    my $files_ref = $self->files();
267
268    if ( $self->add_file_to_eis($module, $file, $revision,
269            $authors_ref, $taskids_ref, $archive_path) )
270    {
271        push(@{$files_ref}, $file);
272        return 1;
273    }
274    return 0;
275}
276
277# Add a file to the patch file list.
278sub add_patch_file
279{
280    my $self         = shift;
281    my $file         = shift;
282
283    my $patch_files_ref = $self->patch_files();
284
285    foreach (@{$patch_files_ref}) {
286        return 0 if $file eq $_;
287    }
288
289    if ( $self->add_patch_file_to_eis($file) )
290    {
291        push(@{$patch_files_ref}, $file);
292        return 1;
293    }
294    return 0;
295}
296
297#
298# Procedure retrieves the workspace which
299# is based on cvs head (not branch)
300#
301sub get_cvs_head {
302    my $eis = Cws::eis();
303    my $result;
304    eval { $result = $eis->getCVSHead() };
305    if ( $@ ) {
306        carp("ERROR: get_eis_id(): EIS database transaction failed. Reason:\n$@\n");
307    }
308    return $result;
309};
310
311#### public class methods ####
312
313sub get_master_tag {
314    my ($self, $master, $milestone) = @_;
315    $master = $self->master() if (!defined $master);
316    $milestone = $self->milestone() if (!defined $milestone);
317    return uc($master) . '_' . lc($milestone);
318};
319
320sub get_master_branch_tag {
321    my ($self, $master) = @_;
322    $master = $self->master() if (!defined $master);
323    # check in environment if master is on the the HEAD branch
324    my $cvs_head = get_cvs_head();
325    if ( $master eq $cvs_head ) {
326        return undef;
327    }
328    else {
329        return 'mws_' . lc($master);
330    }
331};
332
333sub get_mws {
334    my $self = shift;
335    my $eis = Cws::eis();
336    my $masters;
337    my $child  = Eis::to_string($self->child());
338    eval { $masters = $eis->getMastersForCWS($child) };
339    if ( $@ ) {
340        carp("ERROR: get_eis_id(): EIS database transaction failed. Reason:\n$@\n");
341    }
342    return $$masters[0];
343};
344
345# Returns the branch and root tags for child workspace.
346sub get_tags
347{
348    my $self = shift;
349
350    # look up if tags have already been retrieved
351    if ( defined($self->{_CACHED_TAGS}) ) {
352        return @{$self->{_CACHED_TAGS}};
353    }
354
355    # check if child workspace is valid
356    my $id = $self->eis_id();
357    if ( !$id ) {
358        carp("ERROR: Childworkspace not (yet) registered with EIS.\n");
359        return undef;
360    }
361
362    my $childws = $self->child();
363    # check if child workspace is a clone,
364    if ( $childws =~ /(\w+)_[[:upper:]]{3}\d{3}/ ) {
365        $childws = $1;
366    }
367
368    # check in environment if master is on the the HEAD branch
369    my $cvs_head = get_cvs_head();
370    my $current_master = $self->master();
371    my $creation_master = $self->get_creation_master();
372    if ( !$creation_master ) {
373        carp("ERROR: Can't determine creation MWS.\n");
374        return undef;
375    }
376    my $milestone = $self->milestone();
377
378    my $master_branch_tag
379        = (lc($current_master) eq lc($cvs_head)) ? '' : 'mws_' . lc($current_master);
380    my $cws_branch_tag = 'cws_' . lc($creation_master) . '_' . lc($childws);
381    my $cws_root_tag   = uc($cws_branch_tag) . "_ANCHOR";
382    my $master_milestone_tag = uc($current_master) . "_" . $milestone;
383
384    $self->{_CACHED_TAGS} = [$master_branch_tag, $cws_branch_tag, $cws_root_tag, $master_milestone_tag];
385    return @{$self->{_CACHED_TAGS}};
386}
387
388# Get childworkspace owner
389sub get_owner
390{
391    my $self = shift;
392
393    return $self->get_owner_from_eis();
394}
395
396# get childworkspace qarep
397sub get_qarep
398{
399    my $self = shift;
400
401    return $self->get_qarep_from_eis();
402}
403
404# store an Attachment to a given CWS
405sub save_attachment
406{
407    my $self = shift;
408    my $name = shift;
409    my $mediatype = shift;
410    my $data = shift;
411
412    return $self->save_attachment_in_eis($name, $mediatype, $data);
413}
414
415# Get child workspace approval status,
416# return values can be:
417# 'planned', 'new', 'nominated', 'integrated'
418# and undef in case of error.
419sub get_approval
420{
421    my $self = shift;
422
423    return $self->get_status_from_eis();
424}
425
426# Set child workspace approval status
427# to 'integrated'. Return true if successful
428# or undef in case of error
429sub set_integrated
430{
431    my $self = shift;
432
433    return $self->set_status_in_eis();
434}
435
436# Set child workspace integration milestone
437# Return true if successful or undef in case of error
438sub set_integration_milestone
439{
440    my $self      = shift;
441    my $milestone = shift;
442    my $buildid   = shift;
443
444    return $self->set_integration_milestone_in_eis($milestone, $buildid);
445}
446
447# Get the MWS on which a CWS was created
448sub get_creation_master
449{
450    my $self = shift;
451
452    return $self->get_creation_master_from_eis();
453}
454
455# Get the 'public' flag indicating whether a CWS is visible on OOo
456sub get_public_flag
457{
458    my $self = shift;
459
460    return $self->get_public_flag_from_eis();
461}
462
463
464# Get the 'publicmaster' flag indicating whether a MWS is visible on OOo
465sub get_publicmaster_flag
466{
467    my $self = shift;
468
469    return $self->get_publicmaster_flag_from_eis();
470}
471
472
473sub get_subversion_flag {
474
475    my $self      = shift;
476
477    return $self->get_subversion_flag_from_eis();
478}
479
480sub set_subversion_flag {
481
482    my $self      = shift;
483    my $value	  = shift;
484
485    return $self->set_subversion_flag_in_eis($value);
486}
487
488sub get_scm {
489    my $self  = shift;
490
491    return $self->get_scm_from_eis();
492}
493
494sub set_scm {
495    my $self     = shift;
496    my $scm_name = shift;
497
498    return $self->set_scm_in_eis($scm_name);
499}
500
501
502# Check if milestone exists
503sub is_milestone
504{
505    my $self      = shift;
506    my $master    = shift;
507    my $milestone = shift;
508
509    return $self->is_milestone_registered_with_eis($master, $milestone);
510}
511
512# Check if this cws contains new ui
513sub is_uirelevant
514{
515    my $self      = shift;
516
517    return $self->is_uirelevant_from_eis();
518}
519
520# Check if this cws contains new online help
521sub is_helprelevant
522{
523    my $self      = shift;
524
525    return $self->is_helprelevant_from_eis();
526}
527
528# Set the l10n status
529sub set_l10n_status
530{
531    my $self        = shift;
532    my $status      = shift;
533
534    return $self->set_l10n_status_in_eis( $status );
535}
536
537# Get the l10n status
538sub get_l10n_status
539{
540    my $self        = shift;
541
542    return $self->get_l10n_status_from_eis();
543}
544sub set_word_count
545{
546    my $self        = shift;
547    my $language    = shift;
548    my $wordcount   = shift;
549
550    return $self->set_word_count_in_eis( $language , $wordcount );
551}
552
553
554# Get target release for CWS
555sub get_release
556{
557    my $self        = shift;
558
559    return $self->get_release_from_eis();
560}
561
562# Get due date
563sub get_due_date
564{
565    my $self        = shift;
566
567    return $self->get_due_date_from_eis();
568}
569
570# Get due date QA
571sub get_due_date_qa
572{
573    my $self        = shift;
574
575    return $self->get_due_date_qa_from_eis();
576}
577
578# Query master milestone combination for being used by an
579# active CWS
580sub is_milestone_used
581{
582    my $self      = shift;
583    my $master    = shift;
584    my $milestone = shift;
585
586    return $self->get_is_milestone_used_from_eis($master, $milestone);
587}
588
589# Set current milestone for MWS.
590sub set_current_milestone
591{
592    my $self      = shift;
593    my $master    = shift;
594    my $milestone = shift;
595
596    return $self->set_current_milestone_in_eis($master, $milestone);
597}
598
599# Get current milestone for MWS.
600sub get_current_milestone
601{
602    my $self      = shift;
603    my $master    = shift;
604
605    return $self->get_current_milestone_from_eis($master);
606}
607
608sub get_milestone_integrated
609{
610    my $self      = shift;
611
612    return $self->get_milestone_integrated_from_eis();
613}
614
615# Get masters
616sub get_masters
617{
618
619    my $self      = shift;
620
621    return $self->get_masters_from_eis();
622}
623
624# Get milestones for MWS.
625sub get_milestones
626{
627    my $self      = shift;
628    my $master    = shift;
629
630    return $self->get_milestones_from_eis($master);
631}
632# get build string for CWS
633
634sub get_build
635{
636    my $self      = shift;
637    my $master = $self->master();
638    my $milestone = $self->milestone();
639    if ( ! defined($milestone) ) {
640        return undef;
641    }
642    my $bid=$self->get_buildid($master,$milestone);
643    if ( ! defined($bid) ) {
644        return undef;
645    }
646    return $self->expand_buildid($bid);
647}
648
649
650
651# expand build for given cwsname
652sub expand_buildid
653{
654    my $self      = shift;
655    my $bid    = shift;
656    return $self->expand_buildid_in_eis($bid);
657}
658
659
660# Set BuildID of milestone
661sub set_milestone_buildid
662{
663    my $self         = shift;
664    my $master      = shift;
665    my $milestone   = shift;
666    my $buildid     = shift;
667
668    return $self->set_milestone_buildid_in_eis($master, $milestone, $buildid);
669}
670
671# Declare milestone 'removed'
672# This triggers EIS to send emails to all (SO-internal) CWS owners
673# with living CWSs based on that milestone.
674sub milestone_removed
675{
676    my $self      = shift;
677    my $master    = shift;
678    my $milestone = shift;
679
680    return $self->set_milestone_removed_in_eis($master, $milestone);
681}
682
683
684# Get all child workspaces which have been integrated on a
685# given master and milestone.
686sub get_integrated_cws
687{
688    my $self      = shift;
689    my $master    = shift;
690    my $milestone = shift;
691
692    my $childworkspaces_arrref = $self->get_childworkspaces_for_milestone($master, $milestone);
693    if ( !$childworkspaces_arrref ) {
694        $childworkspaces_arrref = [];
695    }
696    return wantarray ? @$childworkspaces_arrref : $childworkspaces_arrref;
697}
698
699
700# Get builid for given master and milestone.
701sub get_buildid
702{
703    my $self      = shift;
704    my $master    = shift;
705    my $milestone = shift;
706
707    return $self->get_buildid_for_milestone($master, $milestone);
708}
709
710#
711# Get all cws' with a status passed
712#
713sub get_cws_with_state
714{
715    my $self = shift;
716    my $mws = shift;
717    my $status = shift;
718
719    return wantarray ? @{$self->get_cws_with_state_from_eis($mws, $status)}
720                    :   $self->get_cws_with_state_from_eis($mws, $status);
721}
722
723sub get_task_prio_cws
724{
725    my $self        = shift;
726    my $ref_taskids = shift;
727    return @{$self->get_task_prios_of_tasks($ref_taskids)};
728}
729
730# Check is CWS is cloneable for specified master
731sub is_cws_cloneable
732{
733    my $self      = shift;
734    my $master    = shift;
735
736    return $self->get_is_cws_cloneable_from_eis($master);
737}
738
739# Clone CWS for specified master
740sub clone_cws
741{
742    my $self      = shift;
743    my $master    = shift;
744
745    return $self->clone_cws_in_eis($master);
746}
747
748sub set_log_entry
749{
750	my $self      	= shift;
751    my $commandline = shift;
752	my $vcsid		= shift;
753	my $start		= shift;
754	my $stop		= shift;
755	my $comment		= shift;
756    return $self->set_log_entry_in_eis($commandline, $vcsid, $start, $stop, $comment);
757}
758
759sub set_log_entry_extended
760{
761	my $self      	= shift;
762    my $commandname = shift;
763	my $parameter	= shift;
764	my $vcsid		= shift;
765	my $start		= shift;
766	my $stop		= shift;
767	my $comment		= shift;
768	my $mastername  = shift;
769	my $childname	= shift;
770#set_log_entry_extended_in_eis($commandname, $parameter, $vcsid, $start, $stop, $comment, $mastername, $childname);
771    return $self->set_log_entry_extended_in_eis($commandname, $parameter, $vcsid, $start, $stop, $comment, $mastername, $childname);
772}
773
774
775#### private ####
776
777# class data accessor methods
778sub eis
779{
780    shift; # ignore calling class/object
781    $CwsClassData{EIS} = shift if @_;
782    if ( !defined($CwsClassData{EIS}) ) {
783        $CwsClassData{EIS} = init_eis_connector();
784    }
785    return $CwsClassData{EIS};
786}
787
788# generate remaining class data accessor methods
789# if this looks strange see 'perldoc perltootc'
790for my $datum (qw(eis_uri eis_proxy_list net_proxy)) {
791    no strict "refs";
792    *$datum = sub {
793        shift; # ignore calling class/object
794        return $CwsClassData{uc($datum)};
795    }
796}
797
798#### helper methods ####
799
800# instance methods
801
802# Add item to items list,
803# update eis database,
804# returns a list of newly added items,
805# specifying an existing item is not an
806# error, but it want appear in the return list.
807sub add_items
808{
809    my $self          = shift;
810    my $type          = shift;
811    my $optional_data = shift;
812
813    my $items_ref;
814    if ( $type eq 'modules' ) {
815        $items_ref   = $self->modules();
816    }
817    elsif ( $type eq 'taskids' ) {
818        $items_ref   = $self->taskids();
819    }
820    else {
821        # fall through, can't happen
822        carp("ERROR: wrong item type\n");
823        return undef;
824    }
825
826    my $item;
827    my @new_items = ();
828    return undef if !defined($items_ref);
829    # find which items which are not already in items list
830    ITEM: while ( $item = shift ) {
831        foreach ( @{$items_ref} ) {
832            next ITEM if $_ eq $item;
833        }
834        push(@new_items, $item);
835    }
836    if ( $#new_items > -1 ) {
837        # add items to database
838        if ( $self->add_items_to_eis($type, $optional_data, \@new_items) ) {
839            push(@{$items_ref}, @new_items);
840        }
841        else {
842            # something went wrong
843            return undef;
844        }
845    }
846    return \@new_items;
847}
848
849# Get EIS id for workspace from EIS database
850sub get_eis_id
851{
852    my $self = shift;
853    my $eis = Cws::eis();
854
855    # It's not an error if one of these is unset, so don't carp().
856    if ( !$self->master() || !$self->child() ) {
857        return undef;
858    }
859
860    my $master = Eis::to_string($self->master());
861    my $child  = Eis::to_string($self->child());
862
863    my $result;
864    eval { $result = int($eis->getChildWorkspaceId($master, $child)) };
865    if ( $@ ) {
866        carp("ERROR: get_eis_id(): EIS database transaction failed. Reason:\n$@\n");
867    }
868    return $result;
869}
870
871sub fetch_item_from_eis
872{
873    my $self = shift;
874    my $type = shift;
875
876    my $eis = Cws::eis();
877    my $id = $self->eis_id();
878
879    if ( !$id ) {
880        carp("ERROR: Childworkspace not (yet) registered with EIS.\n");
881        return undef;
882    }
883
884    my $result;
885    if ( $type eq 'milestone' ) {
886        eval { $result = $eis->getMilestone($id) };
887    }
888    elsif ( $type eq 'master' ) {
889        # master can't be queried from the EIS database,
890        # just return what already in member
891        return $self->{MASTER}
892    }
893    else {
894        # fall through, can't happen
895        carp("ERROR: wrong item type\n");
896        return undef;
897    }
898    if ( $@ ) {
899        carp("ERROR: fetch_item(): EIS database transaction failed. Reason:\n$@\n");
900    }
901    return $result;
902}
903
904sub set_item_in_eis
905{
906    my $self     = shift;
907    my $type     = shift;
908    my $item     = shift;
909
910    my $eis = Cws::eis();
911    my $id = $self->eis_id();
912
913    if ( !$id ) {
914        carp("ERROR: Childworkspace not (yet) registered with EIS.\n");
915        return undef;
916    }
917
918    # make certain that the item is a string, otherwise
919    # autotyping will occasionally choose the wrong type
920    $item = Eis::to_string($item);
921
922    my $result;
923    if ( $type eq 'milestone' ) {
924        # this operation invalidates the cached tags list
925        $self->{_CACHED_TAGS} = undef;
926        eval { $result = $eis->setMilestone($id, $item) };
927    }
928    elsif ( $type eq 'master' ) {
929        # this operation invalidates the cached tags list
930        $self->{_CACHED_TAGS} = undef;
931        eval { $result = $eis->setMasterWorkspace($id, $item) };
932    }
933    else {
934        # fall through, can't happen
935        carp("ERROR: wrong item type\n");
936        return 0;
937    }
938
939    if ( $@ ) {
940        carp("ERROR: set_item(): EIS database transaction failed. Reason:\n$@\n");
941        return undef;
942    }
943    return 1 if $result;
944    return 0;
945}
946
947sub set_master_and_milestone_in_eis
948{
949    my $self      = shift;
950    my $master    = shift;
951    my $milestone = shift;
952
953    my $eis = Cws::eis();
954    my $id = $self->eis_id();
955
956    if ( !$id ) {
957        carp("ERROR: Childworkspace not (yet) registered with EIS.\n");
958        return undef;
959    }
960
961    # make certain that the item is a string, otherwise
962    # autotyping will occasionally choose the wrong type
963    $master = Eis::to_string($master);
964    $milestone = Eis::to_string($milestone);
965
966    my $result;
967    # this operation invalidates the cached tags list
968    $self->{_CACHED_TAGS} = undef;
969    eval { $result = $eis->setMasterWorkspaceAndMilestone($id, $master, $milestone) };
970
971    if ( $@ ) {
972        carp("ERROR: set_master_and_milestone(): EIS database transaction failed. Reason:\n$@\n");
973        return undef;
974    }
975    return 1 if $result;
976    return 0;
977}
978
979sub fetch_items_from_eis
980{
981    my $self = shift;
982    my $type = shift;
983
984    my $eis = Cws::eis();
985    my $id = $self->eis_id();
986
987    if ( !$id ) {
988        carp("ERROR: Childworkspace not (yet) registered with EIS.\n");
989        return undef;
990    }
991
992    my $result;
993    if ( $type eq 'modules' ) {
994        eval { $result = $eis->getModules($id) };
995    }
996    elsif ( $type eq 'incompatible_modules' ) {
997        eval { $result = $eis->getIncompatibleModules($id) };
998    }
999    elsif ( $type eq 'new_modules' ) {
1000        eval { $result = $eis->getNewModules($id) };
1001    }
1002    elsif ( $type eq 'new_modules_priv' ) {
1003        eval { $result = $eis->getNewModulesPriv($id) };
1004    }
1005    elsif ( $type eq 'taskids' ) {
1006        eval { $result = $eis->getTaskIds($id) };
1007    }
1008    elsif ( $type eq 'files' ) {
1009        eval { $result = $eis->getFiles($id) };
1010    }
1011    elsif ( $type eq 'patch_files' ) {
1012        eval { $result = $eis->getOutputFiles($id) };
1013    }
1014    else {
1015        # fall through, can't happen
1016        carp("ERROR: wrong item type\n");
1017        return undef;
1018    }
1019    if ( $@ ) {
1020        carp("ERROR: fetch_item(): EIS database transaction failed. Reason:\n$@\n");
1021    }
1022    return $result;
1023}
1024
1025sub add_items_to_eis
1026{
1027    my $self          = shift;
1028    my $type          = shift;
1029    my $optional_data = shift;
1030    my $item_ref      = shift;
1031
1032    my $eis = Cws::eis();
1033    my $id = $self->eis_id();
1034
1035    if ( !$id ) {
1036        carp("ERROR: Childworkspace not (yet) registered with EIS.\n");
1037        return undef;
1038    }
1039
1040    # make certain that all items are strings, otherwise
1041    # autotyping will occasionally choose the wrong type
1042    my @items = ();
1043    foreach ( @{$item_ref} ) {
1044        push(@items, Eis::to_string($_));
1045    }
1046
1047    my $result;
1048    if ( $type eq 'modules' ) {
1049        if ( defined($optional_data) ) {
1050            # add a module new style, with public attribute
1051            eval { $result = $eis->addModule($id, $items[0], $optional_data) };
1052        }
1053        else {
1054            # old style, add a list of modules
1055            eval { $result = $eis->addModules($id, \@items) };
1056        }
1057    }
1058    elsif ( $type eq 'taskids' ) {
1059        eval { $result = $eis->addTaskIds($id, \@items, $optional_data) };
1060    }
1061    else {
1062        # fall through, can't happen
1063        carp("ERROR: wrong item type\n");
1064        return 0;
1065    }
1066
1067    if ( $@ ) {
1068        carp("ERROR: add_item(): EIS database transaction failed. Reason:\n$@\n");
1069        return undef;
1070    }
1071    return 1 if $result;
1072    return 0;
1073}
1074
1075sub add_file_to_eis
1076{
1077    my $self         = shift;
1078    my $module       = shift;
1079    my $file         = shift;
1080    my $revision     = shift;
1081    my $authors_ref  = shift;
1082    my $taskids_ref  = shift;
1083    my $archive_path = shift;
1084
1085
1086    my $eis = Cws::eis();
1087    my $id = $self->eis_id();
1088
1089    if ( !$id ) {
1090        carp("ERROR: Childworkspace not (yet) registered with EIS.\n");
1091        return undef;
1092    }
1093
1094    # make certain that all task_ids are strings, otherwise
1095    # autotyping will choose the wrong type
1096    # Note: I think typing just the first element should suffice, but ...
1097    my @taskids = ();
1098    foreach ( @{$taskids_ref} ) {
1099        push(@taskids, Eis::to_string($_));
1100    }
1101    # HACK Its possible that we get no valid taskid.
1102    # Autotyping will fail for a list without elements;
1103    if ( !@taskids ) {
1104        push(@taskids, Eis::to_string(''));
1105    }
1106
1107    # same for revision
1108    $revision = Eis::to_string($revision);
1109
1110    if ( !$archive_path ) {
1111        $archive_path = Eis::to_string('');
1112    }
1113
1114    my $result;
1115    eval {
1116        $result = $eis->addFile($id, $module, $file, $archive_path,
1117                                $revision, $authors_ref, \@taskids)
1118    };
1119    if ( $@ ) {
1120        carp("ERROR: add_file(): EIS database transaction failed. Reason:\n$@\n");
1121        return undef;
1122    }
1123    return 1 if $result;
1124    return 0;
1125}
1126
1127sub add_patch_file_to_eis
1128{
1129    my $self         = shift;
1130    my $file         = shift;
1131
1132    my $eis = Cws::eis();
1133    my $id = $self->eis_id();
1134
1135    if ( !$id ) {
1136        carp("ERROR: Childworkspace not (yet) registered with EIS.\n");
1137        return undef;
1138    }
1139
1140    my $result;
1141    eval { $result = $eis->addOutputFile($id, $file) };
1142    if ( $@ ) {
1143        carp("ERROR: add_patch_file(): EIS database transaction failed. Reason:\n$@\n");
1144        return undef;
1145    }
1146    return $1;# appOutputFile has void as return value ...
1147}
1148
1149sub is_cws_name_available_in_eis
1150{
1151    my $self     = shift;
1152
1153    if ( !$self->master() ) {
1154        carp("ERROR: master workspace name not set\n");
1155        return undef;
1156    }
1157
1158    if ( !$self->child() ) {
1159        carp("ERROR: child workspace name not set\n");
1160        return undef;
1161    }
1162
1163    my $eis = Cws::eis();
1164    my $master    = Eis::to_string($self->master());
1165    my $child     = Eis::to_string($self->child());
1166
1167    my $result;
1168    eval { $result = $eis->isChildWorkspaceUnique($master, $child) };
1169    if ( $@ ) {
1170        carp("ERROR: is_cws_name_available(): EIS database transaction failed. Reason:\n$@\n");
1171    }
1172    return $result;
1173}
1174
1175sub register_child_with_eis
1176{
1177    my $self     = shift;
1178    my $vcsid    = shift;
1179    my $location = shift;
1180
1181    if ( !$self->master() ) {
1182        carp("ERROR: master workspace name not set\n");
1183        return undef;
1184    }
1185
1186    if ( !$self->milestone() ) {
1187        carp("ERROR: master milestone not set\n");
1188        return undef;
1189    }
1190
1191    if ( !$self->child() ) {
1192        carp("ERROR: child workspace name not set\n");
1193        return undef;
1194    }
1195
1196    $vcsid    = '' unless $vcsid;
1197    $location = '' unless $location;
1198
1199    my $eis = Cws::eis();
1200    my $master    = Eis::to_string($self->master());
1201    my $milestone = Eis::to_string($self->milestone());
1202    my $child     = Eis::to_string($self->child());
1203
1204    $vcsid        = Eis::to_string($vcsid);
1205    $location     = Eis::to_string($location);
1206
1207    my $result;
1208    eval {
1209        $result = $eis->createChildWorkspace($master, $milestone, $child,
1210                                                 $vcsid, $location)
1211    };
1212
1213    if ( $@ ) {
1214        carp("ERROR: create_child_workspace(): EIS database transaction failed. Reason:\n$@\n");
1215        return undef;
1216    }
1217    # set EIS_ID directly, since $self->eis_id() is not
1218    # supposed to take parameters.
1219    $self->{EIS_ID} = $result;
1220    return $result;
1221}
1222
1223sub promote_child_in_eis
1224{
1225    my $self     = shift;
1226    my $vcsid    = shift;
1227    my $location = shift;
1228
1229    my $eis = Cws::eis();
1230    my $id = $self->eis_id();
1231
1232    if ( !$id ) {
1233        carp("ERROR: Childworkspace not (yet) registered with EIS.\n");
1234        return undef;
1235    }
1236
1237    if ( !$self->milestone() ) {
1238        carp("ERROR: master milestone not set\n");
1239        return undef;
1240    }
1241
1242    my $milestone = Eis::to_string($self->milestone());
1243
1244    $vcsid    = '' unless $vcsid;
1245    $location = '' unless $location;
1246
1247    $vcsid        = Eis::to_string($vcsid);
1248    $location     = Eis::to_string($location);
1249
1250    my $result;
1251    eval {
1252        $result = $eis->initializeChildWorkspace($id, $milestone, $vcsid, $location)
1253    };
1254
1255    eval { $result = $eis->getStatus($id) };
1256    if ( $@ ) {
1257        carp("ERROR: promote(): EIS database transaction failed. Reason:\n$@\n");
1258        return 0;
1259    }
1260    return 1;
1261}
1262
1263# Get child workspace owner from EIS,
1264# return undef in case of error.
1265sub get_owner_from_eis
1266{
1267    my $self = shift;
1268
1269    # check if child workspace is valid
1270    my $id = $self->eis_id();
1271    if ( !$id ) {
1272        carp("ERROR: Childworkspace not (yet) registered with EIS.\n");
1273        return undef;
1274    }
1275
1276    my $eis = Cws::eis();
1277    my $result;
1278    eval { $result = $eis->getOwnerEmail($id) };
1279    if ( $@ ) {
1280        carp("ERROR: get_OwnerEmail(): EIS database transaction failed. Reason:\n$@\n");
1281    }
1282    return $result;
1283}
1284
1285# Get child workspace qarep from EIS,
1286# return undef in case of error.
1287sub get_qarep_from_eis
1288{
1289    my $self = shift;
1290
1291    # check if child workspace is valid
1292    my $id = $self->eis_id();
1293    if ( !$id ) {
1294        carp("ERROR: Childworkspace not (yet) registered with EIS.\n");
1295        return undef;
1296    }
1297
1298    my $eis = Cws::eis();
1299    my $result;
1300    eval { $result = $eis->getQARepresentativeEmail($id) };
1301    if ( $@ ) {
1302        carp("ERROR: get_qarep(): EIS database transaction failed. Reason:\n$@\n");
1303    }
1304    return $result;
1305}
1306
1307# store an attachment to a given CWS
1308# return undef in case of error.
1309sub save_attachment_in_eis
1310{
1311    my $self      = shift;
1312    my $name      = shift;
1313    my $mediatype = shift;
1314    my $text      = shift;
1315
1316    # check if child workspace is valid
1317    my $eisid = $self->eis_id();
1318    if ( !$eisid )
1319    {
1320        carp("ERROR: Childworkspace not (yet) registered with EIS.\n");
1321        return undef;
1322    }
1323
1324    my $eisname =      Eis::to_string($name);
1325    my $eismediatype = Eis::to_string($mediatype);
1326    my $eistextstring = Eis::to_string($text);
1327
1328    my $eis = Cws::eis();
1329    my $result;
1330
1331    eval { $result = $eis->saveAttachment($eisid, $eisname, $eismediatype, $eistextstring ) };
1332    if ( $@ ) {
1333        carp("ERROR: save_attachment_in_eis(): EIS database transaction failed. Reason:\n$@\n");
1334    }
1335    return $result;
1336}
1337
1338# Get child workspace approval status from EIS,
1339# return undef in case of error.
1340sub get_status_from_eis
1341{
1342    my $self = shift;
1343
1344    # check if child workspace is valid
1345    my $id = $self->eis_id();
1346    if ( !$id ) {
1347        carp("ERROR: Childworkspace not (yet) registered with EIS.\n");
1348        return undef;
1349    }
1350
1351    my $eis = Cws::eis();
1352    my $result;
1353    eval { $result = $eis->getStatus($id) };
1354    if ( $@ ) {
1355        carp("ERROR: get_status(): EIS database transaction failed. Reason:\n$@\n");
1356    }
1357    return $result;
1358}
1359
1360# Get child workspace approval status from EIS,
1361# return undef in case of error.
1362sub set_status_in_eis
1363{
1364    my $self = shift;
1365    my $status = shift;
1366    my $method = 'set';
1367    $method .= (defined $status) ? $status : 'Integrated';
1368
1369    # check if child workspace is valid
1370    my $id = $self->eis_id();
1371    if ( !$id ) {
1372        carp("ERROR: Childworkspace not (yet) registered with EIS.\n");
1373        return undef;
1374    }
1375    my $eis = Cws::eis();
1376    my $result;
1377    if (defined $status) {
1378        eval { $result = $eis->setFixedOnMaster($id) };
1379    } else {
1380        eval { $result = $eis->setIntegrated($id) };
1381    }
1382    if ( $@ ) {
1383        carp("ERROR: $method(): EIS database transaction failed. Reason:\n$@\n");
1384    }
1385    return $result;
1386}
1387
1388# Get child workspace approval status from EIS,
1389# return undef in case of error.
1390sub set_integration_milestone_in_eis
1391{
1392    my $self      = shift;
1393    my $milestone = shift;
1394    my $buildid   = shift;
1395
1396    # check if child workspace is valid
1397    my $id = $self->eis_id();
1398    if ( !$id ) {
1399        carp("ERROR: Childworkspace not (yet) registered with EIS.\n");
1400        return undef;
1401    }
1402
1403    my $eis = Cws::eis();
1404
1405    # just in case ...
1406    if ( !defined($milestone) ) {
1407        $milestone = Eis::to_string('');
1408    }
1409    # $buildid must be transfered as string
1410    if ( !defined($buildid) ) {
1411        $buildid = Eis::to_string('');
1412    }
1413    else {
1414        $buildid = Eis::to_string($buildid);
1415    }
1416
1417    my $result;
1418    eval { $result = $eis->setIntegrationMilestone($id, $milestone, $buildid) };
1419    if ( $@ ) {
1420        carp("ERROR: set_integration_milestone(): EIS database transaction failed. Reason:\n$@\n");
1421    }
1422    return $result;
1423}
1424
1425sub set_milestone_buildid_in_eis
1426{
1427    my $self      = shift;
1428    my $master    = shift;
1429    my $milestone = shift;
1430    my $buildid   = shift;
1431
1432    $master    = Eis::to_string($master);
1433    $milestone = Eis::to_string($milestone);
1434    $buildid   = Eis::to_string($buildid);
1435
1436    my $eis = Cws::eis();
1437    my $result;
1438    eval { $result = $eis->setMilestoneBuild( $master, $milestone, $buildid ) };
1439    if ( $@ ) {
1440        carp("ERROR: set_milestone_buildid(): EIS database transaction failed. Reason:\n$@\n");
1441    }
1442    return $result;
1443}
1444
1445sub set_current_milestone_in_eis
1446{
1447    my $self      = shift;
1448    my $master    = shift;
1449    my $milestone = shift;
1450
1451    $master    = Eis::to_string($master);
1452    $milestone = Eis::to_string($milestone);
1453
1454    my $eis = Cws::eis();
1455    my $result;
1456    eval { $result = $eis->setCurrentMilestone( $master, $milestone ) };
1457    if ( $@ ) {
1458        carp("ERROR: set_current_milestone(): EIS database transaction failed. Reason:\n$@\n");
1459    }
1460    return $result;
1461}
1462
1463sub get_current_milestone_from_eis
1464{
1465    my $self      = shift;
1466    my $master    = shift;
1467
1468    $master    = Eis::to_string($master);
1469
1470    my $eis = Cws::eis();
1471    my $result;
1472    eval { $result = $eis->getCurrentMilestone( $master ) };
1473    if ( $@ ) {
1474        carp("ERROR: get_current_milestone(): EIS database transaction failed. Reason:\n$@\n");
1475    }
1476    return $result;
1477}
1478
1479sub get_masters_from_eis
1480{
1481    my $self      = shift;
1482
1483    my $eis = Cws::eis();
1484    my @result;
1485    eval { @result = $eis->getMasterWorkspaces() };
1486    if ( $@ ) {
1487        carp("ERROR: get_masters(): EIS database transaction failed. Reason:\n$@\n");
1488    }
1489
1490    my @result2=();
1491    my $i=0;
1492    while ( defined($result[0][$i]) ) {
1493        push @result2,$result[0][$i];
1494        $i++;
1495    }
1496    return @result2;
1497}
1498
1499
1500sub get_milestones_from_eis
1501{
1502    my $self      = shift;
1503    my $master    = shift;
1504
1505    $master    = Eis::to_string($master);
1506
1507    my $eis = Cws::eis();
1508    my @result;
1509    eval { @result = $eis->getMilestones( $master ) };
1510    if ( $@ ) {
1511        carp("ERROR: get_milestones(): EIS database transaction failed. Reason:\n$@\n");
1512    }
1513    my @result2=();
1514    my $i=0;
1515    while ( defined($result[0][$i]) ) {
1516        push @result2,$result[0][$i];
1517        $i++;
1518    }
1519    return @result2;
1520}
1521
1522# Get child workspace owner from EIS,
1523# return undef in case of error.
1524sub expand_buildid_in_eis
1525{
1526    my $self = shift;
1527    my $bid = shift;
1528
1529    # check if child workspace is valid
1530    my $id = $self->eis_id();
1531    if ( !$id ) {
1532        carp("ERROR: Childworkspace not (yet) registered with EIS.\n");
1533        return undef;
1534    }
1535
1536    my $name = $self->child();
1537
1538    my $eis = Cws::eis();
1539    my $result;
1540    eval { $result = $eis->expandBuildId($bid, $name) };
1541    if ( $@ ) {
1542        carp("ERROR: expand_builid(): EIS database transaction failed. Reason:\n$@\n");
1543    }
1544    return $result;
1545}
1546
1547sub set_milestone_removed_in_eis
1548{
1549    my $self      = shift;
1550    my $master    = shift;
1551    my $milestone = shift;
1552
1553    $master    = Eis::to_string($master);
1554    $milestone = Eis::to_string($milestone);
1555
1556    my $eis = Cws::eis();
1557    eval { $eis->minorRemoved( $master, $milestone ) };
1558    if ( $@ ) {
1559        carp("ERROR: set_current_milestone(): EIS database transaction failed. Reason:\n$@\n");
1560    }
1561    return;
1562}
1563
1564sub is_milestone_registered_with_eis
1565{
1566    my $self      = shift;
1567    my $master    = shift;
1568    my $milestone = shift;
1569
1570    $master    = Eis::to_string($master);
1571    $milestone = Eis::to_string($milestone);
1572
1573    my $eis = Cws::eis();
1574    my $result;
1575    eval { $result = $eis->isMilestoneValid($master, $milestone) };
1576    if ( $@ ) {
1577        carp("ERROR: is_milestone(): EIS database transaction failed. Reason:\n$@\n");
1578    }
1579    return $result;
1580}
1581
1582sub get_is_milestone_used_from_eis
1583{
1584    my $self      = shift;
1585    my $master    = shift;
1586    my $milestone = shift;
1587
1588    $master    = Eis::to_string($master);
1589    $milestone = Eis::to_string($milestone);
1590
1591    my $eis = Cws::eis();
1592    my $result;
1593    eval { $result = $eis->isMilestoneInUse($master, $milestone) };
1594    if ( $@ ) {
1595        carp("ERROR: is_milestone_used(): EIS database transaction failed. Reason:\n$@\n");
1596    }
1597    return $result;
1598}
1599
1600sub get_buildid_for_milestone
1601{
1602    my $self      = shift;
1603    my $master    = shift;
1604    my $milestone = shift;
1605
1606    $master    = Eis::to_string($master);
1607    $milestone = Eis::to_string($milestone);
1608
1609    my $eis = Cws::eis();
1610    my $result;
1611    eval { $result = $eis->getMilestoneBuild($master, $milestone) };
1612    if ( $@ ) {
1613        carp("ERROR: get_buildid_for_milestone(): EIS database transaction failed. Reason:\n$@\n");
1614    }
1615    return $result;
1616}
1617
1618sub get_childworkspaces_for_milestone
1619{
1620    my $self      = shift;
1621    my $master    = shift;
1622    my $milestone = shift;
1623
1624    $master    = Eis::to_string($master);
1625    $milestone = Eis::to_string($milestone);
1626
1627    my $eis = Cws::eis();
1628    my $result;
1629    eval { $result = $eis->searchChildWorkspacesForMilestone($master, $milestone) };
1630    if ( $@ ) {
1631        carp("ERROR: get_childworkspaces_for_milestone(): EIS database transaction failed. Reason:\n$@\n");
1632    }
1633    return $result;
1634}
1635
1636sub get_cws_with_state_from_eis {
1637    my $self = shift;
1638    my $mws = shift;
1639    my $status = shift;
1640
1641    my $eis = Cws::eis();
1642    my $result;
1643    eval { $result = $eis->getCWSWithState($mws, $status) };
1644    if ( $@ ) {
1645        carp("ERROR: get_cws_with_state_from_eis(): EIS database transaction failed. Reason:\n$@\n");
1646    }
1647    return $result;
1648}
1649
1650sub get_task_prios_of_tasks
1651{
1652    my $self        = shift;
1653    my $ref_taskids = shift;
1654
1655    my $eis = Cws::eis();
1656    my $result;
1657    my @items = ();
1658    foreach ( @{$ref_taskids} ) {
1659        push(@items, Eis::to_string($_));
1660    }
1661
1662    eval { $result = $eis->getTasksPriorities( \@items ) };
1663    if ( $@ ) {
1664        carp("ERROR: get_task_prios_of_tasks(): EIS database transaction failed. Reason:\n$@\n");
1665    }
1666    return $result;
1667}
1668
1669sub get_creation_master_from_eis
1670{
1671    my $self      = shift;
1672
1673    # check if child workspace is valid
1674    my $id = $self->eis_id();
1675    if ( !$id ) {
1676        carp("ERROR: Childworkspace not (yet) registered with EIS.\n");
1677        return undef;
1678    }
1679
1680    my $eis = Cws::eis();
1681    my $result;
1682    eval { $result = $eis->getCreationMasterWorkspace($id) };
1683    if ( $@ ) {
1684        carp("ERROR: get_creation_master(): EIS database transaction failed. Reason:\n$@\n");
1685    }
1686    return $result;
1687
1688}
1689
1690sub get_milestone_integrated_from_eis
1691{
1692    my $self      = shift;
1693
1694    # check if child workspace is valid
1695    my $id = $self->eis_id();
1696    if ( !$id ) {
1697        carp("ERROR: Childworkspace not (yet) registered with EIS.\n");
1698        return undef;
1699    }
1700
1701    my $eis = Cws::eis();
1702    my $result;
1703    eval { $result = $eis->getMilestoneIntegrated($id) };
1704    if ( $@ ) {
1705        carp("ERROR: get_milestone_integrated(): EIS database transaction failed. Reason:\n$@\n");
1706    }
1707    return $result;
1708
1709}
1710
1711# get isPublic flag from eis
1712sub get_public_flag_from_eis
1713{
1714    my $self      = shift;
1715
1716    # check if child workspace is valid
1717    my $id = $self->eis_id();
1718    if ( !$id ) {
1719        carp("ERROR: Childworkspace not (yet) registered with EIS.\n");
1720        return undef;
1721    }
1722
1723    my $eis = Cws::eis();
1724    my $result;
1725    eval { $result = $eis->isPublic($id) };
1726    if ( $@ ) {
1727        carp("ERROR: get_public_flag(): EIS database transaction failed. Reason:\n$@\n");
1728    }
1729    return $result;
1730}
1731
1732# get isPublicMaster flag from eis
1733sub get_publicmaster_flag_from_eis
1734{
1735    my $self      = shift;
1736
1737    # check if child workspace is valid
1738    my $master = $self->master();
1739    if ( !$master ) {
1740        carp("ERROR: MasterWorkspace not defined.\n");
1741        return undef;
1742    }
1743
1744    my $eis = Cws::eis();
1745    my $result;
1746    eval { $result = $eis->isPublicMaster($master) };
1747    if ( $@ ) {
1748        carp("ERROR: get_publicmaster_flag(): EIS database transaction failed. Reason:\n$@\n");
1749    }
1750    return $result;
1751}
1752
1753# get isSubVersion flag from eis
1754sub get_subversion_flag_from_eis
1755{
1756    my $self = shift;
1757
1758    # check if child workspace is valid
1759    my $id = $self->eis_id();
1760    if ( !$id ) {
1761        carp("ERROR: Childworkspace not (yet) registered with EIS.\n");
1762        return undef;
1763    }
1764
1765    my $eis = Cws::eis();
1766    my $result;
1767    eval { $result = $eis->isSubVersion($id) };
1768    if ( $@ ) {
1769        carp("ERROR: get_subversion_flag(): EIS database transaction failed. Reason:\n$@\n");
1770    }
1771    return $result;
1772}
1773
1774# set isSubVersion flag in eis
1775sub set_subversion_flag_in_eis
1776{
1777    my $self=shift;
1778    my $status=shift;
1779
1780    my $bool_status=SOAP::Data->type(boolean => $status);
1781
1782    # check if child workspace is valid
1783    my $id = $self->eis_id();
1784    if ( !$id ) {
1785        carp("ERROR: Childworkspace not (yet) registered with EIS.\n");
1786        return undef;
1787    }
1788
1789    my $eis = Cws::eis();
1790    my $result;
1791    eval { $result = $eis->setSubVersion($id,$bool_status) };
1792    if ( $@ ) {
1793        carp("ERROR: get_subversion_flag(): EIS database transaction failed. Reason:\n$@\n");
1794    }
1795    return $result;
1796}
1797
1798sub get_scm_from_eis
1799{
1800    my $self = shift;
1801
1802    # check if child workspace is valid
1803    my $id = $self->eis_id();
1804    if ( !$id ) {
1805        carp("ERROR: Childworkspace not (yet) registered with EIS.\n");
1806        return undef;
1807    }
1808
1809    my $eis = Cws::eis();
1810    my $result;
1811    eval { $result = $eis->getSCMName($id) };
1812    if ( $@ ) {
1813        carp("ERROR: get_scm_from_eis(): EIS database transaction failed. Reason:\n$@\n");
1814    }
1815    return $result;
1816}
1817
1818sub set_scm_in_eis
1819{
1820    my $self     = shift;
1821    my $scm_name = shift;
1822
1823    $scm_name = Eis::to_string($scm_name);
1824    # check if child workspace is valid
1825    my $id = $self->eis_id();
1826    if ( !$id ) {
1827        carp("ERROR: Childworkspace not (yet) registered with EIS.\n");
1828        return undef;
1829    }
1830
1831    my $eis = Cws::eis();
1832    eval { $eis->setSCMName($id, $scm_name) };
1833    if ( $@ ) {
1834        carp("ERROR: set_scm_in_eis(): EIS database transaction failed. Reason:\n$@\n");
1835        return 0;
1836    }
1837    return 1;
1838}
1839
1840sub is_uirelevant_from_eis
1841{
1842    my $self        = shift;
1843
1844    # check if child workspace is valid
1845    my $id = $self->eis_id();
1846    if ( !$id ) {
1847        carp("ERROR: Childworkspace not (yet) registered with EIS.\n");
1848        return undef;
1849    }
1850
1851    my $eis = Cws::eis();
1852    my $result;
1853    eval { $result = $eis->isUIRelevant($id) };
1854    if ( $@ ) {
1855        carp("ERROR: is_uirelevant_from_eis(): EIS database transaction failed. Reason:\n$@\n");
1856    }
1857
1858    return $result;
1859}
1860
1861sub is_helprelevant_from_eis
1862{
1863    my $self        = shift;
1864
1865    # check if child workspace is valid
1866    my $id = $self->eis_id();
1867    if ( !$id ) {
1868        carp("ERROR: Childworkspace not (yet) registered with EIS.\n");
1869        return undef;
1870    }
1871
1872    my $eis = Cws::eis();
1873    my $result;
1874    eval { $result = $eis->isHelpRelevant( $id ) };
1875    if ( $@ ) {
1876        carp("ERROR: is_helprelevant_from_eis(): EIS database transaction failed. Reason:\n$@\n");
1877    }
1878
1879    return $result;
1880}
1881sub set_word_count_in_eis
1882{
1883    my $self        = shift;
1884    my $language    = shift;
1885    my $wordcount   = shift;
1886
1887    # check if child workspace is valid
1888    my $id = $self->eis_id();
1889    if ( !$id ) {
1890        carp("ERROR: Childworkspace not (yet) registered with EIS.\n");
1891        return undef;
1892    }
1893
1894    my $eis = Cws::eis();
1895    my $result;
1896    eval { $result = $eis->setWordCount( $id , $language , $wordcount ) };
1897    if ( $@ ) {
1898        carp("ERROR: set_word_count_from_eis(): EIS database transaction failed. Reason:\n$@\n");
1899    }
1900
1901    return $result;
1902}
1903
1904
1905sub get_l10n_status_from_eis
1906{
1907    my $self        = shift;
1908
1909    # check if child workspace is valid
1910    my $id = $self->eis_id();
1911    if ( !$id ) {
1912        carp("ERROR: Childworkspace not (yet) registered with EIS.\n");
1913        return undef;
1914    }
1915
1916    my $eis = Cws::eis();
1917    my $result;
1918    eval { $result = $eis->getL10n( $id ) };
1919    if ( $@ ) {
1920        carp("ERROR: get_l10n_status_from_eis(): EIS database transaction failed. Reason:\n$@\n");
1921    }
1922
1923    return $result;
1924}
1925
1926sub set_l10n_status_in_eis
1927{
1928    my $self        = shift;
1929    my $status      = Eis::to_string( shift );
1930
1931    # check if child workspace is valid
1932    my $id = $self->eis_id();
1933    if ( !$id ) {
1934        carp("ERROR: Childworkspace not (yet) registered with EIS.\n");
1935        return undef;
1936    }
1937
1938    my $eis = Cws::eis();
1939    my $result;
1940
1941    eval { $result = $eis->setL10n( $id , $status ) };
1942    if ( $@ ) {
1943        carp("ERROR: set_l10n_status_in_eis(): EIS database transaction failed. Reason:\n$@\n");
1944    }
1945
1946    return $result;
1947}
1948
1949sub get_is_cws_cloneable_from_eis
1950{
1951    my $self   = shift;
1952    my $master = Eis::to_string( shift );
1953
1954    # check if child workspace is valid
1955    my $id = $self->eis_id();
1956    if ( !$id ) {
1957        carp("ERROR: Childworkspace not (yet) registered with EIS.\n");
1958        return undef;
1959    }
1960
1961    my $eis = Cws::eis();
1962    my $result;
1963
1964    eval { $result = $eis->isClonableForMaster($id, $master) };
1965    if ( $@ ) {
1966        carp("ERROR:  get_is_cws_cloneable_from_eis(): EIS database transaction failed. Reason:\n$@\n");
1967    }
1968
1969    return $result;
1970}
1971
1972sub clone_cws_in_eis
1973{
1974    my $self   = shift;
1975    my $master = Eis::to_string( shift );
1976
1977    # check if child workspace is valid
1978    my $id = $self->eis_id();
1979    if ( !$id ) {
1980        carp("ERROR: Childworkspace not (yet) registered with EIS.\n");
1981        return undef;
1982    }
1983
1984    my $eis = Cws::eis();
1985    my $result;
1986
1987    eval { $eis->cloneForMaster($id, $master) };
1988    if ( $@ ) {
1989        carp("ERROR:  clone_cws_in_eis(): EIS database transaction failed. Reason:\n$@\n");
1990        return 0;
1991    }
1992
1993    return 1;
1994}
1995
1996sub get_release_from_eis
1997{
1998    my $self   = shift;
1999    my $master = Eis::to_string( shift );
2000
2001    # check if child workspace is valid
2002    my $id = $self->eis_id();
2003    if ( !$id ) {
2004        carp("ERROR: Childworkspace not (yet) registered with EIS.\n");
2005        return undef;
2006    }
2007
2008    my $eis = Cws::eis();
2009    my $result;
2010
2011    eval { $result = $eis->getRelease($id) };
2012    if ( $@ ) {
2013        carp("ERROR:  get_release_from_eis(): EIS database transaction failed. Reason:\n$@\n");
2014    }
2015
2016    return $result;
2017}
2018
2019sub get_due_date_from_eis
2020{
2021    my $self   = shift;
2022    my $master = Eis::to_string( shift );
2023
2024    # check if child workspace is valid
2025    my $id = $self->eis_id();
2026    if ( !$id ) {
2027        carp("ERROR: Childworkspace not (yet) registered with EIS.\n");
2028        return undef;
2029    }
2030
2031    my $eis = Cws::eis();
2032    my $result;
2033
2034    eval { $result = $eis->getDueDate($id) };
2035    if ( $@ ) {
2036        carp("ERROR:  get_due_date_from_eis(): EIS database transaction failed. Reason:\n$@\n");
2037    }
2038
2039    return $result;
2040}
2041
2042sub get_due_date_qa_from_eis
2043{
2044    my $self   = shift;
2045    my $master = Eis::to_string( shift );
2046
2047    # check if child workspace is valid
2048    my $id = $self->eis_id();
2049    if ( !$id ) {
2050        carp("ERROR: Childworkspace not (yet) registered with EIS.\n");
2051        return undef;
2052    }
2053
2054    my $eis = Cws::eis();
2055    my $result;
2056
2057    eval { $result = $eis->getDueDateQA($id) };
2058    if ( $@ ) {
2059        carp("ERROR:  get_due_date_qa_from_eis(): EIS database transaction failed. Reason:\n$@\n");
2060    }
2061
2062    return $result;
2063}
2064
2065
2066#logging
2067sub set_log_entry_in_eis
2068{
2069    my $self     	= shift;
2070    my $commandline = shift;
2071	my $vcsid		= shift;
2072    my $start 		= shift;
2073    my $end	   		= shift;
2074	my $comment		= shift;
2075
2076    $commandline    = SOAP::Data->type(string => $commandline);
2077    $comment	    = SOAP::Data->type(string => $comment);
2078
2079	# *format* for  $start and $end = "2003-05-28 12:34:59";
2080
2081#=====================================================
2082	#TO DO:
2083	#experimenell f�r saubere schnittstelle
2084	#$start = SOAP::Data->type(dateTime => $start);
2085	#$end = SOAP::Data->type(dateTime => $end);
2086#=====================================================
2087
2088    my $eis = Cws::eis();
2089	my $result;
2090    eval { $result = $eis->storeCommandLogEntry( $commandline, $vcsid, $start, $end, $comment ) };
2091    if ( $@ ) {
2092        carp("ERROR: set_log_entry(): Logging failed. Reason:\n$@\n");
2093    }
2094    return $result;
2095}
2096
2097#set_log_entry_extended_in_eis($commandname, $parameter, $vcsid, $start, $stop, $comment, $mastername, $childname);
2098sub set_log_entry_extended_in_eis
2099{
2100    my $self     	= shift;
2101    my $commandname = shift;
2102	my $parameter	= shift;
2103	my $vcsid		= shift;
2104    my $start 		= shift;
2105    my $end	   		= shift;
2106	my $comment		= shift;
2107	my $mastername	= shift;
2108	my $childname	= shift;
2109
2110    $commandname    = SOAP::Data->type(string => $commandname);
2111    $parameter	    = SOAP::Data->type(string => $parameter);
2112    $comment	    = SOAP::Data->type(string => $comment);
2113	$mastername		= SOAP::Data->type(string => $mastername);
2114	$childname      = SOAP::Data->type(string => $childname);
2115
2116	# *format* for  $start and $end = "2003-05-28 12:34:59";
2117
2118#=====================================================
2119	#TO DO:
2120	#experimenell f�r saubere schnittstelle
2121	#$start = SOAP::Data->type(dateTime => $start);
2122	#$end = SOAP::Data->type(dateTime => $end);
2123#=====================================================
2124
2125    my $eis = Cws::eis();
2126	my $result;
2127    eval { $result = $eis->storeCommandLogEntry($commandname, $parameter, $vcsid, $start, $end, $comment, $mastername, $childname) };
2128    if ( $@ ) {
2129        carp("ERROR: set_log_entry_extended(): Logging failed. Reason:\n$@\n");
2130    }
2131    return $result;
2132}
2133
2134
2135#### class methods ####
2136
2137sub init_eis_connector
2138{
2139    my $eis = Eis->new( uri => Cws::eis_uri(),
2140                        proxy_list => Cws::eis_proxy_list(),
2141                        net_proxy => Cws::net_proxy()
2142                      );
2143    return $eis;
2144}
2145
2146####
2147
21481; # needed by "use" or "require"
2149# vim: set ts=4 shiftwidth=4 expandtab syntax=perl:
2150