Various changes and additions for UCM and testing things
[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  foreach ($view->additional_groups) {
50    display_nolf "$_ ";
51  } # foreach
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) = @_;
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   my $self = bless { tag => $tag }, $class;
174
175   $self->updateViewInfo;
176
177   return $self;
178 } # new
179   
180 sub accessed_by () {
181   my ($self) = @_;
182    
183 =pod
184
185 =head2 accessed_by
186
187 Returns the user name of the last user to access the view.
188
189 Parameters:
190
191 =for html <blockquote>
192
193 =over
194
195 =item none
196
197 =back
198
199 =for html </blockquote>
200
201 Returns:
202
203 =for html <blockquote>
204
205 =over
206
207 =item user name
208
209 =back
210
211 =for html </blockquote>
212
213 =cut
214
215   return $self->{accessed_by};
216 } # accessed_by
217
218 sub accessed_date () {
219   my ($self) = @_;
220      
221 =pod
222
223 =head2 accessed_date
224
225 Returns the date the view was last accessed.
226
227 Parameters:
228
229 =for html <blockquote>
230
231 =over
232
233 =item none
234
235 =back
236
237 =for html </blockquote>
238
239 Returns:
240
241 =for html <blockquote>
242
243 =over
244
245 =item access date
246
247 =back
248
249 =for html </blockquote>
250
251 =cut
252
253   return $self->{accessed_date};
254 } # accessed_date
255
256 sub access_path () {
257   my ($self) = @_;
258    
259 =pod
260
261 =head2 access_path
262
263 Returns the access path of the view.
264
265 Parameters:
266
267 =for html <blockquote>
268
269 =over
270
271 =item none
272
273 =back
274
275 =for html </blockquote>
276
277 Returns:
278
279 =for html <blockquote>
280
281 =over
282
283 =item access path
284
285 =back
286
287 =for html </blockquote>
288
289 =cut
290
291   return $self->{access_path};
292 } # access_path
293
294 sub active () {
295   my ($self) = @_;
296   
297 =pod
298
299 =head2 active
300
301 Returns true if the view is active
302
303 Parameters:
304
305 =for html <blockquote>
306
307 =over
308
309 =item none
310
311 =back
312
313 =for html </blockquote>
314
315 Returns:
316
317 =for html <blockquote>
318
319 =over
320
321 =item boolean
322
323 =back
324
325 =for html </blockquote>
326
327 =cut
328
329   return $self->{active};
330 } # active
331
332 sub additional_groups () {
333   my ($self) = @_;
334   
335 =pod
336
337 =head2 additional_groups
338
339 Returns the additional groups that have permission to access this
340 view.
341
342 Parameters:
343
344 =for html <blockquote>
345
346 =over
347
348 =item none
349
350 =back
351
352 =for html </blockquote>
353
354 Returns:
355
356 =for html <blockquote>
357
358 =over
359
360 =item An array of additional groups
361
362 =back
363
364 =for html </blockquote>
365
366 =cut
367
368   if ($self->{additional_groups}) {
369     return @{$self->{additional_groups}};
370   } else {
371     return ();
372   } # if
373 } # additional_groups
374
375 sub created_by () {
376   my ($self) = @_;
377   
378 =pod
379
380 =head2 created_by
381
382 Returns the user name who created the view
383
384 Parameters:
385
386 =for html <blockquote>
387
388 =over
389
390 =item none
391
392 =back
393
394 =for html </blockquote>
395
396 Returns:
397
398 =for html <blockquote>
399
400 =over
401
402 =item user name
403
404 =back
405
406 =for html </blockquote>
407
408 =cut
409
410   return $self->{created_by};
411 } # created_by
412
413 sub created_date () {
414    my ($self) = @_;
415    
416 =pod
417
418 =head2 created_date
419
420 Returns the date the view was created.
421
422 Parameters:
423
424 =for html <blockquote>
425
426 =over
427
428 =item none
429
430 =back
431
432 =for html </blockquote>
433
434 Returns:
435
436 =for html <blockquote>
437
438 =over
439
440 =item date
441
442 =back
443
444 =for html </blockquote>
445
446 =cut
447
448   return $self->{created_date};
449 } # created_date
450
451 sub cs_updated_by () {
452   my ($self) = @_;
453   
454 =pod
455
456 =head2 cs_updated_date
457
458 Returns the user name of the last user to access the view.
459
460 Parameters:
461
462 =for html <blockquote>
463
464 =over
465
466 =item none
467
468 =back
469
470 =for html </blockquote>
471
472 Returns:
473
474 =for html <blockquote>
475
476 =over
477
478 =item date
479
480 =back
481
482 =for html </blockquote>
483
484 =cut
485
486   return $self->{cs_updated_by};
487 } # cs_updated_by
488
489 sub cs_updated_date () {
490   my ($self) = @_;
491
492 =pod
493
494 =head2 dynamic
495
496 Returns the date the config spec for this view was updated.
497
498 Parameters:
499
500 =for html <blockquote>
501
502 =over
503
504 =item none
505
506 =back
507
508 =for html </blockquote>
509
510 Returns:
511
512 =for html <blockquote>
513
514 =over
515
516 =item date
517
518 =back
519
520 =for html </blockquote>
521
522 =cut
523
524   return $self->{cs_updated_date};
525 } # cs_updated_date
526
527 sub dynamic () {
528   my ($self) = @_;
529   
530 =pod
531
532 =head2 dynamic
533
534 Returns true if the view is a dynamic view - false otherwise.
535
536 Parameters:
537
538 =for html <blockquote>
539
540 =over
541
542 =item none
543
544 =back
545
546 =for html </blockquote>
547
548 Returns:
549
550 =for html <blockquote>
551
552 =over
553
554 =item boolean
555
556 =back
557
558 =for html </blockquote>
559
560 =cut
561
562   return $self->type eq 'dynamic';
563 } # dynamic
564
565 sub gpath () {
566   my ($self) = @_;
567   
568 =pod
569
570 =head2 gpath
571
572 Returns the global path to the view
573
574 Parameters:
575
576 =for html <blockquote>
577
578 =over
579
580 =item none
581
582 =back
583
584 =for html </blockquote>
585
586 Returns:
587
588 =for html <blockquote>
589
590 =over
591
592 =item global path
593
594 =back
595
596 =for html </blockquote>
597
598 =cut
599   
600   return $self->{gpath};
601 } # gpath
602
603 sub group () {
604   my ($self) = @_;
605   
606 =pod
607
608 =head2 group
609
610 Returns the group of the user who created the view.
611
612 Parameters:
613
614 =for html <blockquote>
615
616 =over
617
618 =item none
619
620 =back
621
622 =for html </blockquote>
623
624 Returns:
625
626 =for html <blockquote>
627
628 =over
629
630 =item group name
631
632 =back
633
634 =for html </blockquote>
635
636 =cut
637
638   return $self->{group};
639 } # group
640
641 sub group_mode () {
642   my ($self) = @_;
643   
644 =pod
645
646 =head2 group_mode
647
648 Returns the group mode of the view.
649
650 Parameters:
651
652 =for html <blockquote>
653
654 =over
655
656 =item none
657
658 =back
659
660 =for html </blockquote>
661
662 Returns:
663
664 =for html <blockquote>
665
666 =over
667
668 =item A string representing the group mode
669
670 =back
671
672 =for html </blockquote>
673
674 =cut
675
676   return $self->{group_mode};
677 } # group_mode
678
679 sub host () {
680   my ($self) = @_;
681   
682 =pod
683
684 =head2 host
685
686 Returns the host that the view resides on
687
688 Parameters:
689
690 =for html <blockquote>
691
692 =over
693
694 =item none
695
696 =back
697
698 =for html </blockquote>
699
700 Returns:
701
702 =for html <blockquote>
703
704 =over
705
706 =item host
707
708 =back
709
710 =for html </blockquote>
711
712 =cut
713
714   return $self->{host};
715 } # host
716
717 sub mode () {
718   my ($self) = @_;
719   
720 =pod
721
722 =head2 mode
723
724 Returns the numeric mode representing the view's access mode
725
726 Parameters:
727
728 =for html <blockquote>
729
730 =over
731
732 =item none
733
734 =back
735
736 =for html </blockquote>
737
738 Returns:
739
740 =for html <blockquote>
741
742 =over
743
744 =item numeric mode
745
746 =back
747
748 =for html </blockquote>
749
750 =cut
751
752   return $self->{mode};
753 } # mode
754
755 sub modified_by () {
756   my ($self) = @_;
757   
758 =pod
759
760 =head2 modified_by
761
762 Returns the user name of the last user to modify the view.
763
764 Parameters:
765
766 =for html <blockquote>
767
768 =over
769
770 =item none
771
772 =back
773
774 =for html </blockquote>
775
776 Returns:
777
778 =for html <blockquote>
779
780 =over
781
782 =item user name
783
784 =back
785
786 =for html </blockquote>
787
788 =cut
789
790   return $self->{modified_by};
791 } # modified_by
792
793 sub modified_date () {
794   my ($self) = @_;
795   
796 =pod
797
798 =head2 modified_date
799
800 Returns the date the view was last modified.
801
802 Parameters:
803
804 =for html <blockquote>
805
806 =over
807
808 =item none
809
810 =back
811
812 =for html </blockquote>
813
814 Returns:
815
816 =for html <blockquote>
817
818 =over
819
820 =item date
821
822 =back
823
824 =for html </blockquote>
825
826 =cut
827
828   return $self->{modified_date};
829 } # modified_date
830
831 sub other_mode () {
832   my ($self) = @_;
833   
834 =pod
835
836 =head2 other_mode
837
838 Returns the mode for other for the view.
839
840 Parameters:
841
842 =for html <blockquote>
843
844 =over
845
846 =item none
847
848 =back
849
850 =for html </blockquote>
851
852 Returns:
853
854 =for html <blockquote>
855
856 =over
857
858 =item A string repesenting the other mode
859
860 =back
861
862 =for html </blockquote>
863
864 =cut
865
866   return $self->{other_mode};
867 } # other_mode
868
869 sub owner () {
870   my ($self) = @_;
871   
872 =pod
873
874 =head2 owner
875
876 Returns the user name of the owner of the view.
877
878 Parameters:
879
880 =for html <blockquote>
881
882 =over
883
884 =item none
885
886 =back
887
888 =for html </blockquote>
889
890 Returns:
891
892 =for html <blockquote>
893
894 =over
895
896 =item user name
897
898 =back
899
900 =for html </blockquote>
901
902 =cut
903
904   return $self->{owner}
905 } # owner
906
907 sub owner_mode () {
908   my ($self) = @_;
909   
910 =pod
911
912 =head2 owner_mode
913
914 Returns the mode for the owner for the view.
915
916 Parameters:
917
918 =for html <blockquote>
919
920 =over
921
922 =item none
923
924 =back
925
926 =for html </blockquote>
927
928 Returns:
929
930 =for html <blockquote>
931
932 =over
933
934 =item A string repesenting the other mode
935
936 =back
937
938 =for html </blockquote>
939
940 =cut
941
942   return $self->{owner_mode}
943 } # owner_mode
944
945 sub properties () {
946   my ($self) = @_;
947   
948 =pod
949
950 =head2 properties
951
952 Returns the properties of the view.
953
954 Parameters:
955
956 =for html <blockquote>
957
958 =over
959
960 =item none
961
962 =back
963
964 =for html </blockquote>
965
966 Returns:
967
968 =for html <blockquote>
969
970 =over
971
972 =item properties
973
974 =back
975
976 =for html </blockquote>
977
978 =cut
979
980   return $self->{properties};
981 } # properties
982
983 sub region () {
984   my ($self) = @_;
985   
986 =pod
987
988 =head2 region
989
990 Returns the region of the view
991
992 Parameters:
993
994 =for html <blockquote>
995
996 =over
997
998 =item none
999
1000 =back
1001
1002 =for html </blockquote>
1003
1004 Returns:
1005
1006 =for html <blockquote>
1007
1008 =over
1009
1010 =item region
1011
1012 =back
1013
1014 =for html </blockquote>
1015
1016 =cut
1017
1018   return $self->{region};
1019 } # region
1020
1021 sub shost () {
1022   my ($self) = @_;
1023   
1024 =pod
1025
1026 =head2 shost
1027
1028 Returns the server host of the view
1029
1030 Parameters:
1031
1032 =for html <blockquote>
1033
1034 =over
1035
1036 =item none
1037
1038 =back
1039
1040 =for html </blockquote>
1041
1042 Returns:
1043
1044 =for html <blockquote>
1045
1046 =over
1047
1048 =item server host
1049
1050 =back
1051
1052 =for html </blockquote>
1053
1054 =cut
1055
1056   return $self->{shost};
1057 } # shost
1058
1059 sub snapshot () {
1060   my ($self) = @_;
1061   
1062 =pod
1063
1064 =head2 snapshot
1065
1066 Returns true if the view is a snapshot view - false otherwise.
1067
1068 Parameters:
1069
1070 =for html <blockquote>
1071
1072 =over
1073
1074 =item none
1075
1076 =back
1077
1078 =for html </blockquote>
1079
1080 Returns:
1081
1082 =for html <blockquote>
1083
1084 =over
1085
1086 =item boolean
1087
1088 =back
1089
1090 =for html </blockquote>
1091
1092 =cut
1093
1094   return $self->type eq 'snapshot';
1095 } # snapshot
1096
1097 sub webview () {
1098   my ($self) = @_;
1099   
1100 =pod
1101
1102 =head2 webview
1103
1104 Returns true if the view is a webview - false otherwise.
1105
1106 Parameters:
1107
1108 =for html <blockquote>
1109
1110 =over
1111
1112 =item none
1113
1114 =back
1115
1116 =for html </blockquote>
1117
1118 Returns:
1119
1120 =for html <blockquote>
1121
1122 =over
1123
1124 =item boolean
1125
1126 =back
1127
1128 =for html </blockquote>
1129
1130 =cut
1131
1132   return $self->type eq 'webview';
1133 } # webview
1134
1135 sub tag () {
1136   my ($self) = @_;
1137   
1138 =pod
1139
1140 =head1 tag
1141
1142 Returns the tag for this view.
1143
1144 Parameters:
1145
1146 =for html <blockquote>
1147
1148 =over
1149
1150 =item none
1151
1152 =back
1153
1154 =for html </blockquote>
1155
1156 Returns:
1157
1158 =for html <blockquote>
1159
1160 =over
1161
1162 =item tag
1163
1164 =back
1165
1166 =for html </blockquote>
1167
1168 =cut
1169
1170   return $self->{tag};
1171  } # tag
1172
1173 # Alias name to tag
1174 sub name() {
1175   goto &tag;
1176 } # name
1177
1178 sub text_mode () {
1179   my ($self) = @_;
1180   
1181 =pod
1182
1183 =head2 text_mode
1184
1185 Returns the text_mode of the view
1186
1187 Parameters:
1188
1189 =for html <blockquote>
1190
1191 =over
1192
1193 =item none
1194
1195 =back
1196
1197 =for html </blockquote>
1198
1199 Returns:
1200
1201 =for html <blockquote>
1202
1203 =over
1204
1205 =item text mode
1206
1207 =back
1208
1209 =for html </blockquote>
1210
1211 =cut
1212
1213   return $self->{text_mode};
1214 } # tag
1215
1216 sub type () {
1217   my ($self) = @_;
1218   
1219 =pod
1220
1221 =head2 type
1222
1223 Returns the type of the view.
1224
1225 Parameters:
1226
1227 =for html <blockquote>
1228
1229 =over
1230
1231 =item none
1232
1233 =back
1234
1235 =for html </blockquote>
1236
1237 Returns:
1238
1239 =for html <blockquote>
1240
1241 =over
1242
1243 =item type
1244
1245 =back
1246
1247 =for html </blockquote>
1248
1249 =cut
1250
1251   return $self->{type} ? $self->{type} : 'Unknown';
1252 } # type
1253
1254 sub ucm () {
1255   my ($self) = @_;
1256   
1257 =pod
1258
1259 =head2 ucm
1260
1261 Returns true if the view is a UCM view.
1262
1263 Parameters:
1264
1265 =for html <blockquote>
1266
1267 =over
1268
1269 =item none
1270
1271 =back
1272
1273 =for html </blockquote>
1274
1275 Returns:
1276
1277 =for html <blockquote>
1278
1279 =over
1280
1281 =item boolean
1282
1283 =back
1284
1285 =for html </blockquote>
1286
1287 =cut
1288
1289   return $self->{ucm};
1290 } # ucm
1291
1292 sub uuid () {
1293   my ($self) = @_;
1294   
1295 =pod
1296
1297 =head2 uuid
1298
1299 Returns the uuid for the view.
1300
1301 Parameters:
1302
1303 =for html <blockquote>
1304
1305 =over
1306
1307 =item none
1308
1309 =back
1310
1311 =for html </blockquote>
1312
1313 Returns:
1314
1315 =for html <blockquote>
1316
1317 =over
1318
1319 =item uuid
1320
1321 =back
1322
1323 =for html </blockquote>
1324
1325 =cut
1326
1327   return $self->{uuid};
1328 } # uuid
1329
1330 sub exists () {
1331   my ($self) = @_;
1332
1333 =pod
1334
1335 =head3 exists
1336
1337 Returns true if the view exists - false otherwise.
1338
1339 Parameters:
1340
1341 =for html <blockquote>
1342
1343 =over
1344
1345 =item none
1346
1347 =back
1348
1349 =for html </blockquote>
1350
1351 Returns:
1352
1353 =for html <blockquote>
1354
1355 =over
1356
1357 =item boolean
1358
1359 =back
1360
1361 =for html </blockquote>
1362
1363 =cut
1364
1365   my ($status, @output) = $Clearcase::CC->execute ("lsview $self->{tag}");
1366   
1367   return !$status;
1368 } # exists
1369
1370 sub create (;$$$) {
1371   my ($self, $host, $vws, $opts) = @_;
1372     
1373 =pod
1374
1375 =head2 create
1376
1377 Creates a view
1378
1379 Parameters:
1380
1381 =for html <blockquote>
1382
1383 =over
1384
1385 =item host
1386
1387 Host to create the view on. Default is to use -stgloc -auto.
1388
1389 =item vws
1390
1391 View working storage directory to use. Default is to use -stgloc -auto.
1392
1393 =back
1394
1395 =for html </blockquote>
1396
1397 Returns:
1398
1399 =for html <blockquote>
1400
1401 =over
1402
1403 =item $status
1404
1405 Status from cleartool
1406
1407 =item @output
1408
1409 Ouput from cleartool
1410
1411 =back
1412
1413 =for html </blockquote>
1414
1415 =cut
1416
1417   if ($self->exists) {
1418     $self->updateViewInfo;
1419       
1420     return (0, ())
1421   } # if
1422
1423   my ($status, @output);
1424     
1425   $opts ||= '';
1426
1427   if ($host && $vws) {
1428     ($status, @output) = $Clearcase::CC->execute(
1429       "mkview -tag $self->{tag} $opts " .
1430       "-host $host -hpath $vws -gpath $vws $vws"
1431     );
1432   } else {
1433     # Note this requires that -stgloc's work and that using -auto is not a 
1434     # problem.
1435     ($status, @output) = $Clearcase::CC->execute(
1436       "mkview -tag $self->{tag} $opts -stgloc -auto"
1437     );
1438   } # if
1439
1440   $self->updateViewInfo;
1441
1442   return ($status, @output);
1443 } # create
1444   
1445 # TODO Is this used?
1446 sub createUCM ($$) {
1447   my ($self, $stream, $pvob) = @_;
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   return (0, ()) if $self->exists;
1494       
1495   # Update object members
1496   $self->{pvob} = $pvob;
1497     
1498   # Need to create the view
1499   my ($status, @output) = 
1500     $Clearcase::CC->execute ("mkview -tag $self->{tag} -stream " 
1501                            . "$self->{stream}\@$self->{pvob} -stgloc -auto");
1502  
1503   return ($status, @output)
1504     if $status;
1505       
1506   $self->updateViewInfo;
1507
1508   return ($status, @output);
1509 } # createUCM
1510
1511 sub remove () {
1512   my ($self) = @_;
1513
1514 =pod
1515
1516 =head3 remove
1517
1518 Removes the view.
1519
1520 Parameters:
1521
1522 =for html <blockquote>
1523
1524 =over
1525
1526 =item none
1527
1528 =back
1529
1530 =for html </blockquote>
1531
1532 Returns:
1533
1534 =for html <blockquote>
1535
1536 =over
1537
1538 =item $status
1539
1540 Status from cleartool
1541
1542 =item @output
1543
1544 Ouput from cleartool
1545
1546 =back
1547
1548 =for html </blockquote>
1549
1550 =cut
1551
1552   return (0, ()) unless $self->exists;
1553       
1554   my ($status, @output);
1555
1556   if ($self->dynamic) {
1557     $self->stop;
1558
1559     ($status, @output) = $Clearcase::CC->execute (
1560        "rmview -force -tag $self->{tag}"
1561      );
1562   } else {
1563     error 'Removal of snapshot views not implemented yet', 1;
1564     #($status, @output) = $Clearcase::CC->execute (
1565     #  "rmview -force $self->{snapshot_view_pname}"
1566     #);
1567   } # if
1568
1569   return ($status, @output);
1570 } # remove
1571
1572 sub start () {
1573   my ($self) = @_;
1574
1575 =pod
1576
1577 =head2 start
1578
1579 Starts the view.
1580
1581 Parameters:
1582
1583 =for html <blockquote>
1584
1585 =over
1586
1587 =item none
1588
1589 =back
1590
1591 =for html </blockquote>
1592
1593 Returns:
1594
1595 =for html <blockquote>
1596
1597 =over
1598
1599 =item $status
1600
1601 Status from cleartool
1602
1603 =item @output
1604
1605 Ouput from cleartool
1606
1607 =back
1608
1609 =for html </blockquote>
1610
1611 =cut
1612
1613   return $Clearcase::CC->execute ("startview $self->{tag}");
1614 } # start
1615
1616 sub stop () {
1617   my ($self) = @_;
1618
1619 =pod
1620
1621 =head2 stop
1622
1623 Stops the view.
1624
1625 Parameters:
1626
1627 =for html <blockquote>
1628
1629 =over
1630
1631 =item none
1632
1633 =back
1634
1635 =for html </blockquote>
1636
1637 Returns:
1638
1639 =for html <blockquote>
1640
1641 =over
1642
1643 =item $status
1644
1645 Status from cleartool
1646
1647 =item @output
1648
1649 Ouput from cleartool
1650
1651 =back
1652
1653 =for html </blockquote>
1654
1655 =cut
1656
1657   return $Clearcase::CC->execute ("endview $self->{tag}");
1658 } # stop
1659
1660 sub kill () {
1661   my ($self) = @_;
1662
1663 =pod
1664
1665 =head2 kill
1666
1667 Stops the view at the view_server process if nobody else is accessing the view.
1668
1669 Parameters:
1670
1671 =for html <blockquote>
1672
1673 =over
1674
1675 =item none
1676
1677 =back
1678
1679 =for html </blockquote>
1680
1681 Returns:
1682
1683 =for html <blockquote>
1684
1685 =over
1686
1687 =item $status
1688
1689 Status from cleartool
1690
1691 =item @output
1692
1693 Ouput from cleartool
1694
1695 =back
1696
1697 =for html </blockquote>
1698
1699 =cut
1700
1701   return $Clearcase::CC->execute ("endview -server $self->{tag}");
1702 } # kill
1703
1704 sub set () {
1705   my ($self) = @_;
1706
1707 =pod
1708
1709 =head3 set
1710
1711 Starts the view then changes directory the to view's root.
1712
1713 Parameters:
1714
1715 =for html <blockquote>
1716
1717 =over
1718
1719 =item none
1720
1721 =back
1722
1723 =for html </blockquote>
1724
1725 Returns:
1726
1727 =for html <blockquote>
1728
1729 =over
1730
1731 =item $status
1732
1733 Status from cleartool
1734
1735 =item @output
1736
1737 Ouput from cleartool
1738
1739 =back
1740
1741 =for html </blockquote>
1742
1743 =cut
1744
1745   my ($status, @output) = $self->start;
1746
1747   chdir "$Clearcase::VIEWTAG_PREFIX/$self->{tag}";
1748
1749   return ($status, @output);
1750 } # set
1751
1752 sub updateViewInfo () {
1753   my ($self) = @_;
1754
1755   my ($status, @output) = $Clearcase::CC->execute (
1756     "lsview -long -properties -full $self->{tag}"
1757   );
1758
1759   # Assuming this view is an empty shell of an object that the user may possibly
1760   # use the create method on, return our blessings...
1761
1762   # No longer assume that. Could equally be the case where the view server
1763   # failed to respond. Carry on then...return if $status != 0;
1764
1765   # Defaults
1766   $self->{type}               = 'dynamic';
1767   $self->{ucm}                = 0;
1768   $self->{additional_groups}  = '';
1769
1770   foreach (@output) {
1771     if (/Global path: (.*)/) {
1772       $self->{gpath} = $1;
1773     } elsif (/Server host: (.*)/) {
1774       $self->{shost} = $1;
1775     } elsif (/Region: (.*)/) {
1776       $self->{region} = $1;
1777     } elsif (/Active: (.*)/) {
1778       $self->{active} = ($1 eq 'YES') ? 1 : 0;
1779     } elsif (/View uuid: (.*)/) {
1780       $self->{uuid} = $1;
1781     } elsif (/View on host: (.*)/) {
1782       $self->{host} = $1;
1783     } elsif (/View server access path: (.*)/) {
1784       $self->{access_path} = $1;
1785     } elsif (/View attributes: (.*)/) {
1786       my $view_attributes = $1;
1787       $self->{type}   = $view_attributes =~ /webview/
1788                       ? 'webview'
1789                       : $view_attributes =~ /snapshot/
1790                       ? 'snapshot'
1791                       : 'dynamic';
1792       $self->{ucm}    = $view_attributes =~ /ucmview/  
1793                                          ? 1
1794                                          : 0;
1795     } elsif (/Created (\S+) by (.+)/) {
1796       $self->{created_date}   = $1;
1797       $self->{created_by}     = $2;
1798     } elsif (/Last modified (\S+) by (.+)/) {
1799       $self->{modified_date}  = $1;
1800       $self->{modified_by}    = $2;
1801     } elsif (/Last accessed (\S+) by (.+)/) {
1802       $self->{accessed_date}  = $1;
1803       $self->{accessed_by}    = $2;
1804     } elsif (/Last config spec update (\S+) by (.+)/) {
1805       $self->{cs_updated_date}        = $1;
1806       $self->{cs_updated_by}          = $2;
1807     } elsif (/Text mode: (\S+)/) {
1808       $self->{text_mode} = $1;
1809     } elsif (/Properties: (.*)/) {
1810       $self->{properties} = $1;
1811     } elsif (/Owner: (\S+)\s+: (\S+) /) {
1812       $self->{owner}          = $1;
1813       $self->{owner_mode}     = $2;
1814     } elsif (/Group: (.+)\s+:\s+(\S+)\s+/) {
1815       $self->{group}          = $1;
1816        $self->{group_mode}     = $2;
1817     } elsif (/Other:\s+: (\S+) /) {
1818       $self->{other_mode}     = $1;
1819     } elsif (/Additional groups: (.*)/) {
1820       my @additional_groups = split /\s+/, $1;
1821       $self->{additional_groups} = \@additional_groups;
1822     } # if
1823   } # foreach
1824
1825   # Change modes to numeric
1826   $self->{mode} = 0;
1827
1828   if ($self->{owner_mode}) {
1829     $self->{mode} += 400 if $self->{owner_mode} =~ /r/;
1830     $self->{mode} += 200 if $self->{owner_mode} =~ /w/;
1831     $self->{mode} += 100 if $self->{owner_mode} =~ /x/;
1832     $self->{mode} += 40  if $self->{group_mode} =~ /r/;
1833     $self->{mode} += 20  if $self->{group_mode} =~ /w/;
1834     $self->{mode} += 10  if $self->{group_mode} =~ /x/;
1835     $self->{mode} += 4   if $self->{other_mode} =~ /r/;
1836     $self->{mode} += 2   if $self->{other_mode} =~ /w/;
1837     $self->{mode} += 1   if $self->{other_mode} =~ /x/;
1838   } # if
1839   
1840   return;
1841 } # updateViewInfo
1842
1843 1;
1844
1845 =pod
1846
1847 =head2 DEPENDENCIES
1848
1849 =for html <p><a href="/php/scm_man.php?file=lib/Clearcase.pm">Clearcase</a></p>
1850
1851 =head2 INCOMPATABILITIES
1852
1853 None
1854
1855 =head2 BUGS AND LIMITATIONS
1856
1857 There are no known bugs in this module.
1858
1859 Please report problems to Andrew DeFaria <Andrew@ClearSCM.com>.
1860
1861 =head2 LICENSE AND COPYRIGHT
1862
1863 Copyright (c) 2007, ClearSCM, Inc. All rights reserved.
1864
1865 =cut