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