File Coverage

lib/Clearcase/View.pm
Criterion Covered Total %
statement 45 215 20.9
branch 26 114 22.8
condition 2 12 16.6
subroutine 10 52 19.2
pod 39 49 79.5
total 122 442 27.6


line stmt bran cond sub pod time code
1              
2             =pod
3              
4             =head1 NAME View.pm
5              
6             Object oriented interface to a Clearcase View
7              
8             =head1 VERSION
9              
10             =over
11              
12             =item Author
13              
14             Andrew DeFaria
15              
16             =item Revision
17              
18             $Revision: 1.18 $
19              
20             =item Created
21              
22             Thu Dec 29 12:07:59 PST 2005
23              
24             =item Modified
25              
26             $Date: 2011/11/16 19:46:13 $
27              
28             =back
29              
30             =head1 SYNOPSIS
31              
32             Provides access to information about a Clearcase View. Note that some
33             information about a view is not populated into the view object at
34             object instantiation. This is because members such as labels can be
35             very long and time consuming to acquire. When the caller request such
36             fields they are expanded.
37              
38             # Create View object
39             my $view = new Clearcase::View (tag => 'test');
40              
41             # Access member variables...
42             print "View:\t\t \t" . $view->tag . "\n";
43             print "Accessed by:\t\t" . $view->accessed_by . "\n";
44             print "Accessed date:\t\t" . $view->accessed_date . "\n";
45             print "Access path:\t\t" . $view->access_path . "\n";
46             print "Active:\t\t\t" . $view->active . "\n";
47              
48             print "Additional groups:\t";
49              
50             for ($view->additional_groups) {
51             print "$_ ";
52             } # for
53              
54             print "\n";
55              
56             print "Created by:\t\t" . $view->created_by . "\n";
57             print "Created date:\t\t" . $view->created_date . "\n";
58             print "CS updated by:\t\t" . $view->cs_updated_by . "\n";
59             print "CS updated date:\t" . $view->cs_updated_date . "\n";
60             print "Global path:\t\t" . $view->gpath . "\n";
61             print "Group:\t\t\t" . $view->group . "\n";
62             print "Group mode:\t\t" . $view->group_mode . "\n";
63             print "Host:\t\t\t" . $view->host . "\n";
64             print "Mode:\t\t\t" . $view->mode . "\n";
65             print "Modified by:\t\t" . $view->modified_by . "\n";
66             print "Modified date:\t\t" . $view->modified_date . "\n";
67             print "Other mode:\t\t" . $view->other_mode . "\n";
68             print "Owner:\t\t\t" . $view->owner . "\n";
69             print "Owner mode:\t\t" . $view->owner_mode . "\n";
70             print "Properties:\t\t" . $view->properties . "\n";
71             print "Region:\t\t\t" . $view->region . "\n";
72             print "Server host:\t\t" . $view->shost . "\n";
73             print "Text mode:\t\t" . $view->text_mode . "\n";
74             print "UUID:\t\t\t" . $view->uuid . "\n";
75              
76             print "Type:\t\t\t";
77              
78             if ($view->snapshot) {
79             print 'snapshot';
80             } else {
81             print 'dynamic';
82             } # if
83              
84             if ($view->ucm) {
85             print ',ucm';
86             } # if
87              
88             print "\n";
89              
90             # View manipulation
91             my $new_view = new Clearcase::View ($ENV{USER} . '_testview');
92              
93             $new_view->create;
94              
95             # Start new view
96             $new_view->start;
97              
98             # Set to view
99             $new_view->set;
100              
101             # Stop view
102             $new_view->stop;
103              
104             # Stop view server process
105             $new_view->kill;
106              
107             # Remove view
108             if ($new_view->exists) {
109             $new_view->remove;
110             } # if
111              
112             =head1 DESCRIPTION
113              
114             This module implements an object oriented interface to a Clearcase
115             view.
116              
117             =head1 ROUTINES
118              
119             The following routines are exported:
120              
121             =cut
122              
123             package Clearcase::View;
124              
125 2     2   3113 use strict;
  2         7  
  2         88  
126 2     2   7 use warnings;
  2         3  
  2         191  
127              
128 2     2   11 use Clearcase;
  2         6  
  2         7683  
129              
130             sub new($;$) {
131 1     1 1 1012 my ($class, $tag, $region) = @_;
132              
133             =pod
134              
135             =head2 new (tag)
136              
137             Construct a new Clearcase View object. Note that not all members are
138             initially populated because doing so would be time consuming. Such
139             member variables will be expanded when accessed.
140              
141             Parameters:
142              
143             =for html
144              
145             =over
146              
147             =item tag
148              
149             View tag to be instantiated. You can use either an object oriented call
150             (i.e. my $view = new Clearcase::View (tag => 'my_new_view')) or the
151             normal call (i.e. my $vob = new Clearcase::View ('my_new_view')). You
152             can also instantiate a new view by supplying a tag and then later
153             calling the create method.
154              
155             =back
156              
157             =for html
158              
159             Returns:
160              
161             =for html
162              
163             =over
164              
165             =item Clearcase View object
166              
167             =back
168              
169             =for html
170              
171             =cut
172              
173 1   33     7 $region ||= $Clearcase::CC->region;
174              
175 1         4 my $self = bless {
176             tag => $tag,
177             region => $region
178             }, $class;
179              
180 1         7 $self->updateViewInfo;
181              
182 1         2 return $self;
183             } # new
184              
185             sub accessed_by() {
186 0     0 1 0 my ($self) = @_;
187              
188             =pod
189              
190             =head2 accessed_by
191              
192             Returns the user name of the last user to access the view.
193              
194             Parameters:
195              
196             =for html
197              
198             =over
199              
200             =item none
201              
202             =back
203              
204             =for html
205              
206             Returns:
207              
208             =for html
209              
210             =over
211              
212             =item user name
213              
214             =back
215              
216             =for html
217              
218             =cut
219              
220 0         0 return $self->{accessed_by};
221             } # accessed_by
222              
223             sub accessed_date() {
224 0     0 1 0 my ($self) = @_;
225              
226             =pod
227              
228             =head2 accessed_date
229              
230             Returns the date the view was last accessed.
231              
232             Parameters:
233              
234             =for html
235              
236             =over
237              
238             =item none
239              
240             =back
241              
242             =for html
243              
244             Returns:
245              
246             =for html
247              
248             =over
249              
250             =item access date
251              
252             =back
253              
254             =for html
255              
256             =cut
257              
258 0         0 return $self->{accessed_date};
259             } # accessed_date
260              
261             sub access_path() {
262 0     0 1 0 my ($self) = @_;
263              
264             =pod
265              
266             =head2 access_path
267              
268             Returns the access path of the view.
269              
270             Parameters:
271              
272             =for html
273              
274             =over
275              
276             =item none
277              
278             =back
279              
280             =for html
281              
282             Returns:
283              
284             =for html
285              
286             =over
287              
288             =item access path
289              
290             =back
291              
292             =for html
293              
294             =cut
295              
296 0         0 return $self->{access_path};
297             } # access_path
298              
299             sub active() {
300 0     0 1 0 my ($self) = @_;
301              
302             =pod
303              
304             =head2 active
305              
306             Returns true if the view is active
307              
308             Parameters:
309              
310             =for html
311              
312             =over
313              
314             =item none
315              
316             =back
317              
318             =for html
319              
320             Returns:
321              
322             =for html
323              
324             =over
325              
326             =item boolean
327              
328             =back
329              
330             =for html
331              
332             =cut
333              
334 0         0 return $self->{active};
335             } # active
336              
337             sub additional_groups() {
338 0     0 1 0 my ($self) = @_;
339              
340             =pod
341              
342             =head2 additional_groups
343              
344             Returns the additional groups that have permission to access this
345             view.
346              
347             Parameters:
348              
349             =for html
350              
351             =over
352              
353             =item none
354              
355             =back
356              
357             =for html
358              
359             Returns:
360              
361             =for html
362              
363             =over
364              
365             =item An array of additional groups
366              
367             =back
368              
369             =for html
370              
371             =cut
372              
373 0 0       0 if ($self->{additional_groups}) {
374 0         0 return @{$self->{additional_groups}};
  0         0  
375             } else {
376 0         0 return ();
377             } # if
378             } # additional_groups
379              
380             sub created_by() {
381 0     0 1 0 my ($self) = @_;
382              
383             =pod
384              
385             =head2 created_by
386              
387             Returns the user name who created the view
388              
389             Parameters:
390              
391             =for html
392              
393             =over
394              
395             =item none
396              
397             =back
398              
399             =for html
400              
401             Returns:
402              
403             =for html
404              
405             =over
406              
407             =item user name
408              
409             =back
410              
411             =for html
412              
413             =cut
414              
415 0         0 return $self->{created_by};
416             } # created_by
417              
418             sub created_date() {
419 0     0 1 0 my ($self) = @_;
420              
421             =pod
422              
423             =head2 created_date
424              
425             Returns the date the view was created.
426              
427             Parameters:
428              
429             =for html
430              
431             =over
432              
433             =item none
434              
435             =back
436              
437             =for html
438              
439             Returns:
440              
441             =for html
442              
443             =over
444              
445             =item date
446              
447             =back
448              
449             =for html
450              
451             =cut
452              
453 0         0 return $self->{created_date};
454             } # created_date
455              
456             sub cs_updated_by() {
457 0     0 0 0 my ($self) = @_;
458              
459             =pod
460              
461             =head2 cs_updated_date
462              
463             Returns the user name of the last user to access the view.
464              
465             Parameters:
466              
467             =for html
468              
469             =over
470              
471             =item none
472              
473             =back
474              
475             =for html
476              
477             Returns:
478              
479             =for html
480              
481             =over
482              
483             =item date
484              
485             =back
486              
487             =for html
488              
489             =cut
490              
491 0         0 return $self->{cs_updated_by};
492             } # cs_updated_by
493              
494             sub cs_updated_date() {
495 0     0 1 0 my ($self) = @_;
496              
497             =pod
498              
499             =head2 dynamic
500              
501             Returns the date the config spec for this view was updated.
502              
503             Parameters:
504              
505             =for html
506              
507             =over
508              
509             =item none
510              
511             =back
512              
513             =for html
514              
515             Returns:
516              
517             =for html
518              
519             =over
520              
521             =item date
522              
523             =back
524              
525             =for html
526              
527             =cut
528              
529 0         0 return $self->{cs_updated_date};
530             } # cs_updated_date
531              
532             sub dynamic() {
533 1     1 1 2 my ($self) = @_;
534              
535             =pod
536              
537             =head2 dynamic
538              
539             Returns true if the view is a dynamic view - false otherwise.
540              
541             Parameters:
542              
543             =for html
544              
545             =over
546              
547             =item none
548              
549             =back
550              
551             =for html
552              
553             Returns:
554              
555             =for html
556              
557             =over
558              
559             =item boolean
560              
561             =back
562              
563             =for html
564              
565             =cut
566              
567 1 50       3 return unless $self->{type};
568 1         3 return $self->type eq 'dynamic';
569             } # dynamic
570              
571             sub gpath() {
572 0     0 1 0 my ($self) = @_;
573              
574             =pod
575              
576             =head2 gpath
577              
578             Returns the global path to the view
579              
580             Parameters:
581              
582             =for html
583              
584             =over
585              
586             =item none
587              
588             =back
589              
590             =for html
591              
592             Returns:
593              
594             =for html
595              
596             =over
597              
598             =item global path
599              
600             =back
601              
602             =for html
603              
604             =cut
605              
606 0         0 return $self->{gpath};
607             } # gpath
608              
609             sub group() {
610 0     0 1 0 my ($self) = @_;
611              
612             =pod
613              
614             =head2 group
615              
616             Returns the group of the user who created the view.
617              
618             Parameters:
619              
620             =for html
621              
622             =over
623              
624             =item none
625              
626             =back
627              
628             =for html
629              
630             Returns:
631              
632             =for html
633              
634             =over
635              
636             =item group name
637              
638             =back
639              
640             =for html
641              
642             =cut
643              
644 0         0 return $self->{group};
645             } # group
646              
647             sub group_mode() {
648 0     0 1 0 my ($self) = @_;
649              
650             =pod
651              
652             =head2 group_mode
653              
654             Returns the group mode of the view.
655              
656             Parameters:
657              
658             =for html
659              
660             =over
661              
662             =item none
663              
664             =back
665              
666             =for html
667              
668             Returns:
669              
670             =for html
671              
672             =over
673              
674             =item A string representing the group mode
675              
676             =back
677              
678             =for html
679              
680             =cut
681              
682 0         0 return $self->{group_mode};
683             } # group_mode
684              
685             sub host() {
686 0     0 1 0 my ($self) = @_;
687              
688             =pod
689              
690             =head2 host
691              
692             Returns the host that the view resides on
693              
694             Parameters:
695              
696             =for html
697              
698             =over
699              
700             =item none
701              
702             =back
703              
704             =for html
705              
706             Returns:
707              
708             =for html
709              
710             =over
711              
712             =item host
713              
714             =back
715              
716             =for html
717              
718             =cut
719              
720 0         0 return $self->{host};
721             } # host
722              
723             sub mode() {
724 0     0 1 0 my ($self) = @_;
725              
726             =pod
727              
728             =head2 mode
729              
730             Returns the numeric mode representing the view's access mode
731              
732             Parameters:
733              
734             =for html
735              
736             =over
737              
738             =item none
739              
740             =back
741              
742             =for html
743              
744             Returns:
745              
746             =for html
747              
748             =over
749              
750             =item numeric mode
751              
752             =back
753              
754             =for html
755              
756             =cut
757              
758 0         0 return $self->{mode};
759             } # mode
760              
761             sub modified_by() {
762 0     0 1 0 my ($self) = @_;
763              
764             =pod
765              
766             =head2 modified_by
767              
768             Returns the user name of the last user to modify the view.
769              
770             Parameters:
771              
772             =for html
773              
774             =over
775              
776             =item none
777              
778             =back
779              
780             =for html
781              
782             Returns:
783              
784             =for html
785              
786             =over
787              
788             =item user name
789              
790             =back
791              
792             =for html
793              
794             =cut
795              
796 0         0 return $self->{modified_by};
797             } # modified_by
798              
799             sub modified_date() {
800 0     0 1 0 my ($self) = @_;
801              
802             =pod
803              
804             =head2 modified_date
805              
806             Returns the date the view was last modified.
807              
808             Parameters:
809              
810             =for html
811              
812             =over
813              
814             =item none
815              
816             =back
817              
818             =for html
819              
820             Returns:
821              
822             =for html
823              
824             =over
825              
826             =item date
827              
828             =back
829              
830             =for html
831              
832             =cut
833              
834 0         0 return $self->{modified_date};
835             } # modified_date
836              
837             sub other_mode() {
838 0     0 1 0 my ($self) = @_;
839              
840             =pod
841              
842             =head2 other_mode
843              
844             Returns the mode for other for the view.
845              
846             Parameters:
847              
848             =for html
849              
850             =over
851              
852             =item none
853              
854             =back
855              
856             =for html
857              
858             Returns:
859              
860             =for html
861              
862             =over
863              
864             =item A string repesenting the other mode
865              
866             =back
867              
868             =for html
869              
870             =cut
871              
872 0         0 return $self->{other_mode};
873             } # other_mode
874              
875             sub owner() {
876 0     0 1 0 my ($self) = @_;
877              
878             =pod
879              
880             =head2 owner
881              
882             Returns the user name of the owner of the view.
883              
884             Parameters:
885              
886             =for html
887              
888             =over
889              
890             =item none
891              
892             =back
893              
894             =for html
895              
896             Returns:
897              
898             =for html
899              
900             =over
901              
902             =item user name
903              
904             =back
905              
906             =for html
907              
908             =cut
909              
910 0         0 return $self->{owner};
911             } # owner
912              
913             sub owner_mode() {
914 0     0 1 0 my ($self) = @_;
915              
916             =pod
917              
918             =head2 owner_mode
919              
920             Returns the mode for the owner for the view.
921              
922             Parameters:
923              
924             =for html
925              
926             =over
927              
928             =item none
929              
930             =back
931              
932             =for html
933              
934             Returns:
935              
936             =for html
937              
938             =over
939              
940             =item A string repesenting the other mode
941              
942             =back
943              
944             =for html
945              
946             =cut
947              
948 0         0 return $self->{owner_mode};
949             } # owner_mode
950              
951             sub properties() {
952 0     0 1 0 my ($self) = @_;
953              
954             =pod
955              
956             =head2 properties
957              
958             Returns the properties of the view.
959              
960             Parameters:
961              
962             =for html
963              
964             =over
965              
966             =item none
967              
968             =back
969              
970             =for html
971              
972             Returns:
973              
974             =for html
975              
976             =over
977              
978             =item properties
979              
980             =back
981              
982             =for html
983              
984             =cut
985              
986 0         0 return $self->{properties};
987             } # properties
988              
989             sub region() {
990 0     0 1 0 my ($self) = @_;
991              
992             =pod
993              
994             =head2 region
995              
996             Returns the region of the view
997              
998             Parameters:
999              
1000             =for html
1001              
1002             =over
1003              
1004             =item none
1005              
1006             =back
1007              
1008             =for html
1009              
1010             Returns:
1011              
1012             =for html
1013              
1014             =over
1015              
1016             =item region
1017              
1018             =back
1019              
1020             =for html
1021              
1022             =cut
1023              
1024 0         0 return $self->{region};
1025             } # region
1026              
1027             sub shost() {
1028 0     0 1 0 my ($self) = @_;
1029              
1030             =pod
1031              
1032             =head2 shost
1033              
1034             Returns the server host of the view
1035              
1036             Parameters:
1037              
1038             =for html
1039              
1040             =over
1041              
1042             =item none
1043              
1044             =back
1045              
1046             =for html
1047              
1048             Returns:
1049              
1050             =for html
1051              
1052             =over
1053              
1054             =item server host
1055              
1056             =back
1057              
1058             =for html
1059              
1060             =cut
1061              
1062 0         0 return $self->{shost};
1063             } # shost
1064              
1065             sub snapshot() {
1066 0     0 1 0 my ($self) = @_;
1067              
1068             =pod
1069              
1070             =head2 snapshot
1071              
1072             Returns true if the view is a snapshot view - false otherwise.
1073              
1074             Parameters:
1075              
1076             =for html
1077              
1078             =over
1079              
1080             =item none
1081              
1082             =back
1083              
1084             =for html
1085              
1086             Returns:
1087              
1088             =for html
1089              
1090             =over
1091              
1092             =item boolean
1093              
1094             =back
1095              
1096             =for html
1097              
1098             =cut
1099              
1100 0 0       0 return unless $self->{type};
1101 0         0 return $self->type eq 'snapshot';
1102             } # snapshot
1103              
1104             sub webview() {
1105 0     0 1 0 my ($self) = @_;
1106              
1107             =pod
1108              
1109             =head2 webview
1110              
1111             Returns true if the view is a webview - false otherwise.
1112              
1113             Parameters:
1114              
1115             =for html
1116              
1117             =over
1118              
1119             =item none
1120              
1121             =back
1122              
1123             =for html
1124              
1125             Returns:
1126              
1127             =for html
1128              
1129             =over
1130              
1131             =item boolean
1132              
1133             =back
1134              
1135             =for html
1136              
1137             =cut
1138              
1139 0 0       0 return unless $self->{type};
1140 0         0 return $self->{type} eq 'webview';
1141             } # webview
1142              
1143             sub tag() {
1144 0     0 1 0 my ($self) = @_;
1145              
1146             =pod
1147              
1148             =head1 tag
1149              
1150             Returns the tag for this view.
1151              
1152             Parameters:
1153              
1154             =for html
1155              
1156             =over
1157              
1158             =item none
1159              
1160             =back
1161              
1162             =for html
1163              
1164             Returns:
1165              
1166             =for html
1167              
1168             =over
1169              
1170             =item tag
1171              
1172             =back
1173              
1174             =for html
1175              
1176             =cut
1177              
1178 0         0 return $self->{tag};
1179             } # tag
1180              
1181             sub text_mode() {
1182 0     0 1 0 my ($self) = @_;
1183              
1184             =pod
1185              
1186             =head2 text_mode
1187              
1188             Returns the text_mode of the view
1189              
1190             Parameters:
1191              
1192             =for html
1193              
1194             =over
1195              
1196             =item none
1197              
1198             =back
1199              
1200             =for html
1201              
1202             Returns:
1203              
1204             =for html
1205              
1206             =over
1207              
1208             =item text mode
1209              
1210             =back
1211              
1212             =for html
1213              
1214             =cut
1215              
1216 0         0 return $self->{text_mode};
1217             } # tag
1218              
1219             sub type() {
1220 1     1 1 3 my ($self) = @_;
1221              
1222             =pod
1223              
1224             =head2 type
1225              
1226             Returns the type of the view.
1227              
1228             Parameters:
1229              
1230             =for html
1231              
1232             =over
1233              
1234             =item none
1235              
1236             =back
1237              
1238             =for html
1239              
1240             Returns:
1241              
1242             =for html
1243              
1244             =over
1245              
1246             =item type
1247              
1248             =back
1249              
1250             =for html
1251              
1252             =cut
1253              
1254 1         4 return $self->{type};
1255             } # type
1256              
1257             sub ucm() {
1258 0     0 1 0 my ($self) = @_;
1259              
1260             =pod
1261              
1262             =head2 ucm
1263              
1264             Returns true if the view is a UCM view.
1265              
1266             Parameters:
1267              
1268             =for html
1269              
1270             =over
1271              
1272             =item none
1273              
1274             =back
1275              
1276             =for html
1277              
1278             Returns:
1279              
1280             =for html
1281              
1282             =over
1283              
1284             =item boolean
1285              
1286             =back
1287              
1288             =for html
1289              
1290             =cut
1291              
1292 0         0 return $self->{ucm};
1293             } # ucm
1294              
1295             sub uuid() {
1296 0     0 1 0 my ($self) = @_;
1297              
1298             =pod
1299              
1300             =head2 uuid
1301              
1302             Returns the uuid for the view.
1303              
1304             Parameters:
1305              
1306             =for html
1307              
1308             =over
1309              
1310             =item none
1311              
1312             =back
1313              
1314             =for html
1315              
1316             Returns:
1317              
1318             =for html
1319              
1320             =over
1321              
1322             =item uuid
1323              
1324             =back
1325              
1326             =for html
1327              
1328             =cut
1329              
1330 0         0 return $self->{uuid};
1331             } # uuid
1332              
1333             sub exists() {
1334 3     3 1 809 my ($self) = @_;
1335              
1336             =pod
1337              
1338             =head3 exists
1339              
1340             Returns true if the view exists - false otherwise.
1341              
1342             Parameters:
1343              
1344             =for html
1345              
1346             =over
1347              
1348             =item none
1349              
1350             =back
1351              
1352             =for html
1353              
1354             Returns:
1355              
1356             =for html
1357              
1358             =over
1359              
1360             =item boolean
1361              
1362             =back
1363              
1364             =for html
1365              
1366             =cut
1367              
1368 3         14 my ($status, @output) =
1369             $Clearcase::CC->execute ("lsview -region $self->{region} $self->{tag}");
1370              
1371 3         39 return !$status;
1372             } # exists
1373              
1374             sub create(;$$$) {
1375 1     1 1 323 my ($self, $host, $vws, $region) = @_;
1376              
1377             =pod
1378              
1379             =head2 create
1380              
1381             Creates a view
1382              
1383             Parameters:
1384              
1385             =for html
1386              
1387             =over
1388              
1389             =item host
1390              
1391             Host to create the view on. Default is to use -stgloc -auto.
1392              
1393             =item vws
1394              
1395             View working storage directory to use. Default is to use -stgloc -auto.
1396              
1397             =back
1398              
1399             =for html
1400              
1401             Returns:
1402              
1403             =for html
1404              
1405             =over
1406              
1407             =item $status
1408              
1409             Status from cleartool
1410              
1411             =item @output
1412              
1413             Ouput from cleartool
1414              
1415             =back
1416              
1417             =for html
1418              
1419             =cut
1420              
1421 1   33     10 $region ||= $Clearcase::CC->region;
1422              
1423 1 50       3 if ($self->exists) {
1424 1         3 $self->updateViewInfo;
1425              
1426 1         3 return (0, ());
1427             } # if
1428              
1429 0         0 my ($status, @output);
1430              
1431 0 0 0     0 if ($host && $vws) {
1432 0         0 ($status, @output) =
1433             $Clearcase::CC->execute ("mkview -tag $self->{tag} -region $region "
1434             . "-host $host -hpath $vws -gpath $vws $vws");
1435             } else {
1436              
1437             # Note this requires that -stgloc's work and that using -auto is not a
1438             # problem.
1439 0         0 ($status, @output) =
1440             $Clearcase::CC->execute ("mkview -tag $self->{tag} -stgloc -auto");
1441             } # if
1442              
1443 0         0 $self->updateViewInfo;
1444              
1445 0         0 return ($status, @output);
1446             } # create
1447              
1448             sub createUCM($$) {
1449 0     0 1 0 my ($self, $stream, $pvob, $region) = @_;
1450              
1451             =pod
1452              
1453             =head2 createUCM
1454              
1455             Create a UCM view
1456              
1457             Parameters:
1458              
1459             =for html
1460              
1461             =over
1462              
1463             =item streamName
1464              
1465             Name of stream to attach new view to
1466              
1467             =item pvob
1468              
1469             Name of project vob
1470              
1471             =back
1472              
1473             =for html
1474              
1475             Returns:
1476              
1477             =for html
1478              
1479             =over
1480              
1481             =item status
1482              
1483             Integer status
1484              
1485             =item output
1486              
1487             Array of output
1488              
1489             =back
1490              
1491             =for html
1492              
1493             =cut
1494              
1495 0   0     0 $region ||= $Clearcase::CC->region;
1496              
1497 0 0       0 return (0, ())
1498             if $self->exists;
1499              
1500             # Update object members
1501 0         0 $self->{stream} = $stream;
1502 0         0 $self->{pvob} = $pvob;
1503              
1504             # Need to create the view
1505 0         0 my ($status, @output) =
1506             $Clearcase::CC->execute ("mkview -tag $self->{tag} -stream "
1507             . "$self->{stream}\@$self->{pvob} -stgloc -auto");
1508              
1509 0 0       0 return ($status, @output)
1510             if $status;
1511              
1512 0         0 $self->updateViewInfo;
1513              
1514 0         0 return ($status, @output);
1515             } # createUCM
1516              
1517             sub remove() {
1518 1     1 1 7 my ($self) = @_;
1519              
1520             =pod
1521              
1522             =head3 remove
1523              
1524             Removes the view.
1525              
1526             Parameters:
1527              
1528             =for html
1529              
1530             =over
1531              
1532             =item none
1533              
1534             =back
1535              
1536             =for html
1537              
1538             Returns:
1539              
1540             =for html
1541              
1542             =over
1543              
1544             =item $status
1545              
1546             Status from cleartool
1547              
1548             =item @output
1549              
1550             Ouput from cleartool
1551              
1552             =back
1553              
1554             =for html
1555              
1556             =cut
1557              
1558 1 50       2 return (0, ())
1559             unless $self->exists;
1560              
1561 1         2 my ($status, @output);
1562              
1563 1 50       5 if ($self->dynamic) {
1564 1         3 ($status, @output) =
1565             $Clearcase::CC->execute ("rmview -force -tag $self->{tag}");
1566             } else {
1567 0         0 die 'Removal of snapshot views not implemented yet';
1568              
1569             #($status, @output) = $Clearcase::CC->execute(
1570             # "rmview -force $self->{snapshot_view_pname}"
1571             #);
1572             } # if
1573              
1574 1         10 return ($status, @output);
1575             } # remove
1576              
1577             sub start() {
1578 0     0 1 0 my ($self) = @_;
1579              
1580             =pod
1581              
1582             =head2 start
1583              
1584             Starts the view.
1585              
1586             Parameters:
1587              
1588             =for html
1589              
1590             =over
1591              
1592             =item none
1593              
1594             =back
1595              
1596             =for html
1597              
1598             Returns:
1599              
1600             =for html
1601              
1602             =over
1603              
1604             =item $status
1605              
1606             Status from cleartool
1607              
1608             =item @output
1609              
1610             Ouput from cleartool
1611              
1612             =back
1613              
1614             =for html
1615              
1616             =cut
1617              
1618 0         0 return $Clearcase::CC->execute ("startview $self->{tag}");
1619             } # start
1620              
1621             sub stop() {
1622 0     0 1 0 my ($self) = @_;
1623              
1624             =pod
1625              
1626             =head2 stop
1627              
1628             Stops the view.
1629              
1630             Parameters:
1631              
1632             =for html
1633              
1634             =over
1635              
1636             =item none
1637              
1638             =back
1639              
1640             =for html
1641              
1642             Returns:
1643              
1644             =for html
1645              
1646             =over
1647              
1648             =item $status
1649              
1650             Status from cleartool
1651              
1652             =item @output
1653              
1654             Ouput from cleartool
1655              
1656             =back
1657              
1658             =for html
1659              
1660             =cut
1661              
1662 0         0 return $Clearcase::CC->execute ("endview $self->{tag}");
1663             } # stop
1664              
1665             sub kill() {
1666 0     0 1 0 my ($self) = @_;
1667              
1668             =pod
1669              
1670             =head2 kill
1671              
1672             Stops the view at the view_server process if nobody else is accessing the view.
1673              
1674             Parameters:
1675              
1676             =for html
1677              
1678             =over
1679              
1680             =item none
1681              
1682             =back
1683              
1684             =for html
1685              
1686             Returns:
1687              
1688             =for html
1689              
1690             =over
1691              
1692             =item $status
1693              
1694             Status from cleartool
1695              
1696             =item @output
1697              
1698             Ouput from cleartool
1699              
1700             =back
1701              
1702             =for html
1703              
1704             =cut
1705              
1706 0         0 return $Clearcase::CC->execute ("endview -server $self->{tag}");
1707             } # kill
1708              
1709             sub set() {
1710 0     0 1 0 my ($self) = @_;
1711              
1712             =pod
1713              
1714             =head3 set
1715              
1716             Starts the view then changes directory the to view's root.
1717              
1718             Parameters:
1719              
1720             =for html
1721              
1722             =over
1723              
1724             =item none
1725              
1726             =back
1727              
1728             =for html
1729              
1730             Returns:
1731              
1732             =for html
1733              
1734             =over
1735              
1736             =item $status
1737              
1738             Status from cleartool
1739              
1740             =item @output
1741              
1742             Ouput from cleartool
1743              
1744             =back
1745              
1746             =for html
1747              
1748             =cut
1749              
1750 0         0 my ($status, @output) = $self->start;
1751              
1752 0         0 chdir "$Clearcase::VIEWTAG_PREFIX/$self->{tag}";
1753              
1754 0         0 return ($status, @output);
1755             } # set
1756              
1757             =pod
1758              
1759             =head2 updateViewInfo ($view)
1760              
1761             Updates the view info from cleartool lsview
1762              
1763             Parameters:
1764              
1765             =for html
1766              
1767             =over
1768              
1769             =item $view
1770              
1771             The view tag to update info for
1772              
1773             =back
1774              
1775             =for html
1776              
1777             Returns:
1778              
1779             =for html
1780              
1781             =over
1782              
1783             =item nothing
1784              
1785             =back
1786              
1787             =for html
1788              
1789             =cut
1790              
1791             =pod
1792              
1793             =head2 updateViewInfo ($view)
1794              
1795             Updates the view info from cleartool lsview
1796              
1797             Parameters:
1798              
1799             =for html
1800              
1801             =over
1802              
1803             =item $view
1804              
1805             The view tag to update info for
1806              
1807             =back
1808              
1809             =for html
1810              
1811             Returns:
1812              
1813             =for html
1814              
1815             =over
1816              
1817             =item nothing
1818              
1819             =back
1820              
1821             =for html
1822              
1823             =cut
1824              
1825             sub updateViewInfo($$) {
1826 2     2 1 4 my ($self) = @_;
1827              
1828 2 50       10 my $region_opt = $self->{region} ? "-region $self->{region}" : "";
1829              
1830 2         9 my ($status, @output) = $Clearcase::CC->execute (
1831             "lsview $region_opt -long -properties -full $self->{tag}");
1832              
1833 2 50       25 return if $status;
1834              
1835             # Assuming this view is an empty shell of an object that the user may possibly
1836             # use the create method on, return our blessings...
1837              
1838             # No longer assume that. Could equally be the case where the view server
1839             # failed to respond. Carry on then...return if $status != 0;
1840              
1841             # Defaults
1842 2         3 $self->{type} = 'dynamic';
1843 2         4 $self->{ucm} = 0;
1844 2         3 $self->{additional_groups} = '';
1845              
1846 2         4 for (@output) {
1847 2 50       62 if (/Global path: (.*)/) {
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
1848 0         0 $self->{gpath} = $1;
1849             } elsif (/Server host: (.*)/) {
1850 0         0 $self->{shost} = $1;
1851             } elsif (/Region: (.*)/) {
1852 0         0 $self->{region} = $1;
1853             } elsif (/Active: (.*)/) {
1854 0 0       0 $self->{active} = ($1 eq 'YES') ? 1 : 0;
1855             } elsif (/View uuid: (.*)/) {
1856 0         0 $self->{uuid} = $1;
1857             } elsif (/View on host: (.*)/) {
1858 0         0 $self->{host} = $1;
1859             } elsif (/View server access path: (.*)/) {
1860 0         0 $self->{access_path} = $1;
1861             } elsif (/View attributes: (.*)/) {
1862 0         0 my $view_attributes = $1;
1863             $self->{type} =
1864 0 0       0 $view_attributes =~ /webview/ ? 'webview'
    0          
1865             : $view_attributes =~ /snapshot/ ? 'snapshot'
1866             : 'dynamic';
1867             $self->{ucm} =
1868 0 0       0 $view_attributes =~ /ucmview/
1869             ? 1
1870             : 0;
1871             } elsif (/Created (\S+) by (.+)/) {
1872 0         0 $self->{created_date} = $1;
1873 0         0 $self->{created_by} = $2;
1874             } elsif (/Last modified (\S+) by (.+)/) {
1875 0         0 $self->{modified_date} = $1;
1876 0         0 $self->{modified_by} = $2;
1877             } elsif (/Last accessed (\S+) by (.+)/) {
1878 0         0 $self->{accessed_date} = $1;
1879 0         0 $self->{accessed_by} = $2;
1880             } elsif (/Last config spec update (\S+) by (.+)/) {
1881 0         0 $self->{cs_updated_date} = $1;
1882 0         0 $self->{cs_updated_by} = $2;
1883             } elsif (/Text mode: (\S+)/) {
1884 0         0 $self->{text_mode} = $1;
1885             } elsif (/Properties: (.*)/) {
1886 0         0 $self->{properties} = $1;
1887             } elsif (/View owner: (\S+)$/) {
1888              
1889             # It is possible that there may be problems enumerating
1890             # -properties and -full when listing views due to servers
1891             # no longer being available. Still the "View owner" line
1892             # denotes the view's owner.
1893 0         0 $self->{owner} = $1;
1894 0         0 $self->{owner_mode} = '';
1895             } elsif (/Owner: (\S+)\s+: (\S+)/) {
1896 0         0 $self->{owner} = $1;
1897 0         0 $self->{owner_mode} = $2;
1898             } elsif (/Group: (.+)\s+:\s+(\S+)\s+/) {
1899 0         0 $self->{group} = $1;
1900 0         0 $self->{group_mode} = $2;
1901             } elsif (/Other:\s+: (\S+)/) {
1902 0         0 $self->{other_mode} = $1;
1903             } elsif (/Additional groups: (.*)/) {
1904 0         0 my @additional_groups = split /\s+/, $1;
1905 0         0 $self->{additional_groups} = \@additional_groups;
1906             } # if
1907             } # for
1908              
1909             # Change modes to numeric
1910 2         4 $self->{mode} = 0;
1911              
1912 2 50       7 if ($self->{owner_mode}) {
1913 0 0       0 $self->{mode} += 400 if $self->{owner_mode} =~ /r/;
1914 0 0       0 $self->{mode} += 200 if $self->{owner_mode} =~ /w/;
1915 0 0       0 $self->{mode} += 100 if $self->{owner_mode} =~ /x/;
1916 0 0       0 $self->{mode} += 40 if $self->{group_mode} =~ /r/;
1917 0 0       0 $self->{mode} += 20 if $self->{group_mode} =~ /w/;
1918 0 0       0 $self->{mode} += 10 if $self->{group_mode} =~ /x/;
1919 0 0       0 $self->{mode} += 4 if $self->{other_mode} =~ /r/;
1920 0 0       0 $self->{mode} += 2 if $self->{other_mode} =~ /w/;
1921 0 0       0 $self->{mode} += 1 if $self->{other_mode} =~ /x/;
1922             } # if
1923              
1924 2         4 return;
1925             } # updateViewInfo
1926              
1927             sub viewPrivateStorage() {
1928 0     0 0   my ($self) = @_;
1929              
1930             =pod
1931              
1932             =head1 viewPrivateStorage
1933              
1934             Returns the view private storage size for this view.
1935              
1936             Parameters:
1937              
1938             =for html
1939              
1940             =over
1941              
1942             =item none
1943              
1944             =back
1945              
1946             =for html
1947              
1948             Returns:
1949              
1950             =for html
1951              
1952             =over
1953              
1954             =item view private storage
1955              
1956             =back
1957              
1958             =for html
1959              
1960             =cut
1961              
1962 0 0         $self->updateViewSpace unless ($self->{viewPrivateStorage});
1963              
1964 0           return $self->{viewPrivateStorage};
1965             } # viewPrivateStorage
1966              
1967             sub viewPrivateStoragePct() {
1968 0     0 0   my ($self) = @_;
1969              
1970             =pod
1971              
1972             =head1 viewPrivateStoragePct
1973              
1974             Returns the view private storage percent for this view.
1975              
1976             Parameters:
1977              
1978             =for html
1979              
1980             =over
1981              
1982             =item none
1983              
1984             =back
1985              
1986             =for html
1987              
1988             Returns:
1989              
1990             =for html
1991              
1992             =over
1993              
1994             =item view private storage
1995              
1996             =back
1997              
1998             =for html
1999              
2000             =cut
2001              
2002 0 0         $self->updateViewSpace unless ($self->{viewPrivateStoragePct});
2003              
2004 0           return $self->{viewPrivateStoragePct};
2005             } # viewPrivateStoragePct
2006              
2007             sub viewDatabase() {
2008 0     0 0   my ($self) = @_;
2009              
2010             =pod
2011              
2012             =head1 viewDatabase
2013              
2014             Returns the view database size for this view.
2015              
2016             Parameters:
2017              
2018             =for html
2019              
2020             =over
2021              
2022             =item none
2023              
2024             =back
2025              
2026             =for html
2027              
2028             Returns:
2029              
2030             =for html
2031              
2032             =over
2033              
2034             =item view database size
2035              
2036             =back
2037              
2038             =for html
2039              
2040             =cut
2041              
2042 0 0         $self->updateViewSpace unless ($self->{viewDatabase});
2043              
2044 0           return $self->{viewDatabase};
2045             } # viewDatabase
2046              
2047             sub viewDatabasePct() {
2048 0     0 0   my ($self) = @_;
2049              
2050             =pod
2051              
2052             =head1 viewDatabasePct
2053              
2054             Returns the view database percent for this view.
2055              
2056             Parameters:
2057              
2058             =for html
2059              
2060             =over
2061              
2062             =item none
2063              
2064             =back
2065              
2066             =for html
2067              
2068             Returns:
2069              
2070             =for html
2071              
2072             =over
2073              
2074             =item view database percent
2075              
2076             =back
2077              
2078             =for html
2079              
2080             =cut
2081              
2082 0 0         $self->updateViewSpace unless ($self->{viewDatabasePct});
2083              
2084 0           return $self->{viewDatabasePct};
2085             } # viewDatabasePct
2086              
2087             sub viewAdmin() {
2088 0     0 0   my ($self) = @_;
2089              
2090             =pod
2091              
2092             =head1 viewAdmin
2093              
2094             Returns the view admin size for this view.
2095              
2096             Parameters:
2097              
2098             =for html
2099              
2100             =over
2101              
2102             =item none
2103              
2104             =back
2105              
2106             =for html
2107              
2108             Returns:
2109              
2110             =for html
2111              
2112             =over
2113              
2114             =item view admin size
2115              
2116             =back
2117              
2118             =for html
2119              
2120             =cut
2121              
2122 0 0         $self->updateViewSpace unless ($self->{viewAdmin});
2123              
2124 0           return $self->{viewAdmin};
2125             } # viewAdmin
2126              
2127             sub viewAdminPct() {
2128 0     0 0   my ($self) = @_;
2129              
2130             =pod
2131              
2132             =head1 viewAdminPct
2133              
2134             Returns the view admin percent for this view.
2135              
2136             Parameters:
2137              
2138             =for html
2139              
2140             =over
2141              
2142             =item none
2143              
2144             =back
2145              
2146             =for html
2147              
2148             Returns:
2149              
2150             =for html
2151              
2152             =over
2153              
2154             =item view admin percent
2155              
2156             =back
2157              
2158             =for html
2159              
2160             =cut
2161              
2162 0 0         $self->updateViewSpace unless ($self->{viewAdminPct});
2163              
2164 0           return $self->{viewAdminPct};
2165             } # viewAdminPct
2166              
2167             sub viewSpace() {
2168 0     0 0   my ($self) = @_;
2169              
2170             =pod
2171              
2172             =head1 viewSpace
2173              
2174             Returns the view total size for this view.
2175              
2176             Parameters:
2177              
2178             =for html
2179              
2180             =over
2181              
2182             =item none
2183              
2184             =back
2185              
2186             =for html
2187              
2188             Returns:
2189              
2190             =for html
2191              
2192             =over
2193              
2194             =item view space
2195              
2196             =back
2197              
2198             =for html
2199              
2200             =cut
2201              
2202 0 0         $self->updateViewSpace unless ($self->{viewSpace});
2203              
2204 0           return $self->{viewSpace};
2205             } # viewSpace
2206              
2207             sub viewSpacePct() {
2208 0     0 0   my ($self) = @_;
2209              
2210             =pod
2211              
2212             =head1 viewSpacePct
2213              
2214             Returns the view database percent for this view.
2215              
2216             Parameters:
2217              
2218             =for html
2219              
2220             =over
2221              
2222             =item none
2223              
2224             =back
2225              
2226             =for html
2227              
2228             Returns:
2229              
2230             =for html
2231              
2232             =over
2233              
2234             =item view space percent
2235              
2236             =back
2237              
2238             =for html
2239              
2240             =cut
2241              
2242 0 0         $self->updateViewSpace unless ($self->{viewSpacePct});
2243              
2244 0           return $self->{viewSpacePct};
2245             } # viewSpacePct
2246              
2247             sub updateViewSpace() {
2248 0     0 0   my ($self) = @_;
2249              
2250 0           my ($status, @output) = $Clearcase::CC->execute (
2251             "space -region $self->{region} -view $self->{tag}");
2252              
2253 0           $self->{viewPrivateStorage} = 0.0;
2254 0           $self->{viewPrivateStoragePct} = '0%';
2255 0           $self->{viewAdmin} = 0.0;
2256 0           $self->{viewAdminPct} = '0%';
2257 0           $self->{viewDatabase} = 0.0;
2258 0           $self->{viewDatabasePct} = '0%';
2259 0           $self->{viewSpace} = 0.0;
2260 0           $self->{viewSpacePct} = '0%';
2261              
2262 0           for (@output) {
2263 0 0         if (/\s*(\S+)\s*(\S+)\s*View private storage/) {
    0          
    0          
    0          
2264 0           $self->{viewPrivateStorage} = $1;
2265 0           $self->{viewPrivateStoragePct} = $2;
2266             } elsif (/\s*(\S+)\s*(\S+)\s*View database/) {
2267 0           $self->{viewDatabase} = $1;
2268 0           $self->{viewDatabasePct} = $2;
2269             } elsif (/\s*(\S+)\s*(\S+)\s*View administration/) {
2270 0           $self->{viewAdmin} = $1;
2271 0           $self->{viewAdminPct} = $2;
2272             } elsif (/\s*(\S+)\s*(\S+)\s*Subtotal/) {
2273 0           $self->{viewSpace} = $1;
2274 0           $self->{viewSpacePct} = $2;
2275             } # if
2276             } # for
2277              
2278 0           return;
2279             } # updateViewSpace
2280              
2281             1;
2282              
2283             =pod
2284              
2285             =head2 DEPENDENCIES
2286              
2287             =head2 Modules
2288              
2289             =over
2290              
2291             =item L
2292              
2293             =back
2294              
2295             =head2 INCOMPATABILITIES
2296              
2297             None
2298              
2299             =head2 BUGS AND LIMITATIONS
2300              
2301             There are no known bugs in this module.
2302              
2303             Please report problems to Andrew DeFaria .
2304              
2305             =head1 COPYRIGHT AND LICENSE
2306              
2307             Copyright (C) 2020 by Andrew@DeFaria.com
2308              
2309             This library is free software; you can redistribute it and/or modify
2310             it under the same terms as Perl itself, either Perl version 5.38.0 or,
2311             at your option, any later version of Perl 5 you may have available.
2312              
2313             =cut