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