Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/mitre/cvw/CVWObject.java


1   /*
2    * Copyright (c) 1996-2000. The MITRE Corporation (http://www.mitre.org/).
3    * All rights reserved.
4    * CVW comes with ABSOLUTELY NO WARRANTY. See license for details.
5    */
6   
7   package org.mitre.cvw;
8   
9   import java.util.*;
10  import java.io.Serializable;
11  import java.awt.Frame;
12  import java.awt.Image;
13  import java.awt.Window;
14  import javax.swing.*;
15  
16  /**************************************************************
17   ********************* CVW Object Info ************************
18   **************************************************************/
19  /**
20   * The base class for all CVW objects
21   * @version 
22   * @author Deb Ercolini
23   */
24  public class CVWObject extends Observable implements ObjectValues, Serializable {
25    public String name;
26    String icon;
27    public CVWObjNum objNum;                //"#xxxx"
28    String type;
29    int typeValue;                   // the enumeration type
30    CVWObjNum owner;                 //#xxxx
31    Date createdOn;
32    Date lastModifiedOn;
33    CVWObjNum lastModifiedBy;
34    boolean cached = true;
35  
36  /* 4/15/99 dage - These are transient because they may be null values and 
37   * when an object is serializable the values to be written cannot be null
38   * or so it seems.
39   */
40    transient CVWObjNum location;              //"#xxxx"
41    transient CVWObjNum owners[];              //array of #xxxx
42    transient String desc;
43    transient CVWCoordinator jcvw = CVWCoordinator.getInstance();
44  
45  /**
46   * If an object is sessile, it cannot be moved. 
47   * <br>  <code>true</code>,(1 on the CVW server) means cant be moved
48   * <br>  <code>false</code>, (0  on the CVW server) means can be moved.
49   */
50    boolean sessile;
51  
52  /**
53   * This variable is set when the user does a &quot;Information&quot;, 
54   * &quot;Permissions&quot;, &quot;Members&quot;, or &quot;Access&quot;
55   * When the CVW server sends the cvw-object-detail MCP it will open the
56   * get info dialog to the correct tab.
57   *
58   * @see #setMetaDataType
59   * @see #getMetaDataType
60   */
61    int metaDataType;
62  
63    public static final int GETINFO = 0;
64    public static final int ACCESS = 1;
65  //future for when acl/members is third tab of get info for 
66  //groups/rooms
67    public static final int ACL = 2;     
68    public static final int MEMBERS = 2;
69   
70  
71  /* 11/21/96 dage/dee - need to define shortcuts as types
72   */
73    public static Hashtable ObjectTypes = null;
74  /* 12/22/98 dage - moved to static values to ObjectValues class
75   */
76    
77  /***********************************************
78   *********** Class methods *********************
79   ***********************************************/
80  
81  /**
82   * this method is called the when the first obj is instantiated
83   * it maps the enumerated type to the CVW server string
84   * dage
85   */
86    public static void initObjectTypes() {
87      System.err.println("initializing object types");
88      ObjectTypes = new Hashtable(20);
89      ObjectTypes.put((new Integer(UNKNOWN)), "Unknown");
90      ObjectTypes.put((new Integer(USER)), "User");
91      ObjectTypes.put((new Integer(PROXY)), "Proxy");
92      ObjectTypes.put((new Integer(DOC)), "Document");
93      ObjectTypes.put((new Integer(DOC_SC)), "SC to Document");
94      ObjectTypes.put((new Integer(URL)), "URL");
95      ObjectTypes.put((new Integer(URL_SC)), "SC to URL");
96      ObjectTypes.put((new Integer(NOTE)), "Note");
97      ObjectTypes.put((new Integer(NOTE_SC)), "SC to Note");
98      ObjectTypes.put((new Integer(WHITEBOARD)), "Whiteboard");
99      ObjectTypes.put((new Integer(WHITEBOARD_SC)), "SC to Whiteboard");
100     ObjectTypes.put((new Integer(FOLDER)), "Folder");
101     ObjectTypes.put((new Integer(FOLDER_SC)), "SC to Folder");
102     ObjectTypes.put((new Integer(GROUP)), "Group");
103     ObjectTypes.put((new Integer(BALLOT)), "Ballot");
104     ObjectTypes.put((new Integer(RECORDER)), "Recorder");
105     ObjectTypes.put((new Integer(ROOM)), "Room");
106     ObjectTypes.put((new Integer(FLOOR)), "Floor");
107     ObjectTypes.put((new Integer(FORM)), "Form");
108     ObjectTypes.put((new Integer(ROOMKEY)), "Room Key");
109     ObjectTypes.put((new Integer(FORMFOLDER)), "Form Folder");
110    }
111 
112 /**
113  * Returns the CVW server string given the integer value
114  * dage 
115  * 
116  * @param i the integer of the type you are looking for
117  * @return  the string known by the CVW server
118  */
119   public static String getStringFromType(int i) {
120      return (String)ObjectTypes.get(new Integer(i));
121    }
122 
123 /**
124  * Returns the CVW server string given the Integer value
125  * dage 
126  *
127  * @param i the Integer of the type you are looking for
128  * @return  the string known by the CVW server
129  */
130   public static String getStringFromType(Integer i) {
131      return (String)ObjectTypes.get(i);
132    }
133 
134 /**
135  * Returns the integer value given the CVW server string 
136  * dage 
137  *
138  * @param str the string known by the CVW server
139  * @return the integer of the type you are looking for
140  */
141   public static int getTypeFromString(String str) {
142     for (Enumeration e = ObjectTypes.keys() ; e.hasMoreElements() ;) {
143        Integer key = (Integer) e.nextElement();
144        String value = (String)ObjectTypes.get(key);
145       //System.err.println(key + " " + value);
146        if (value.equals(str)) 
147    return key.intValue();
148         }
149     return -1;
150    }
151 
152 /**
153  * Returns a long value representing the date given a string.
154  * java dates are stored in milliseconds and the CVW server measures
155  * in seconds so we append "000"
156  * Dee Goepel
157  *
158  * @param str the date from the CVW server to be converted
159  * @return a long integeter representing the date
160   public static long convertDateFromServer(String str) {
161 System.err.println("in old code cvwObject::convertDateFromServer");
162     return DateUtils.convertDateFromServer(str);
163   }
164  */
165 
166 /* dage - these methods return the enumerated types and the CVW server 
167  *    strings.
168  */
169 /**
170  * Returns the keys of object types as an Enumeration
171  *
172  * @return the keys of object types  
173  */
174   public static Enumeration getObjectTypes() {
175      return ObjectTypes.keys();
176    }
177 
178 /**
179  * Returns the string values of object types as an Enumeration
180  * @return the string values of object types as an Enumeration
181  */
182   public static Enumeration getObjectTypeStrings() {
183      return ObjectTypes.elements();
184    }
185 
186 /**
187  * Checks the user quota before creating an object
188  *
189  * @return boolean returns true if user can create an object
190  */
191   public static boolean checkQuota() {
192       boolean ok =  (CVWUser.getCurrentUser().getQuota() > 0);
193       if (!ok) {
194        System.err.println("Quota limit exceded");
195        CVWCoordinator.getInstance().displayError("You cannot create any more items.  Please contact your administrator for help.", "User Quota Exceded", false);
196       }
197       return ok;
198      }
199 /**
200 
201 /**
202  * Starts the creation of a CVWObject
203  *
204  * @param type the type of CVWObject to be created
205  */
206   public static void newCommand(String type) {
207       if (!checkQuota())
208    return;
209 
210     CVWObject cvwObj;
211     if(type.equals("Folder")) {
212       cvwObj = new CVWFolder();
213     } else if(type.equals("Note")) {
214       cvwObj = new CVWNote();
215     } else if(type.equals("URL") || type.equals("Web Reference")) {
216       cvwObj = new CVWURL();
217     } else if(type.equals("Whiteboard")) {
218       cvwObj = new CVWWhiteboard();
219     } else if(type.equals("Group")) {
220       cvwObj = new CVWGroup();
221     } else if(type.equals("Document")) {
222       cvwObj = new CVWDocument();
223     } else {
224        FileNew newDiag = new FileNew(CVWCoordinator.getInstance(), "CVW - New", true);
225   newDiag.pack();
226       newDiag.setVisible(true);
227   return;
228     }
229     cvwObj.create();
230   }
231 
232 /***********************************************
233  *********** End Class methods *****************
234  ***********************************************/
235 
236 /**
237  * Constructor
238  */
239   public CVWObject() {
240 
241     }
242 
243 /**
244  * Constructor
245  *
246  * @param type the type of this object as defined by ObjectValues
247  */
248   public CVWObject(int t) {
249      typeValue = t;
250      type = getStringFromType(t);
251     }
252 
253 /**
254  * Constructor
255  *
256  * @param type the type of this object as a String as defined by the CVW server 
257  */
258   public CVWObject(String t) {
259      type = t;
260      typeValue = getTypeFromString(t);
261      if (typeValue == -1) 
262   typeValue = UNKNOWN;
263     }
264 
265 /**
266  * Returns whether this object is a shortcut.  
267  * @return <code>true</true> if the object is a shortcut
268  */
269   public boolean isShortcut() {
270     //return false;
271     if (type.startsWith("SC to"))
272   return true;
273     else 
274   return false;
275    }
276 
277 /**
278  * Sets the basic values, the object number and the name of the object.
279  * @param oNum the object number of the object
280  * @param n the name of the object
281  */
282   public void setValues(CVWObjNum oNum, String n) {
283       objNum = oNum;
284       name = n;
285     }
286 
287 /**
288  * Sets the all the values of the object when received from the CVW server.
289  * 3/2/98 - dage added
290  * <br> MCP receive cvw-object-info
291  *
292  * @param oNum object number of this object
293  * @param n name from the get info dialog box
294  * @param i icon file on CVW server
295  * @param own object number of the user who created this object
296  * @param mdate date of the last modification of this object
297  * @param mby object number of the user who last modified this object
298  * @param cdate date this object was created
299  * @param sess sessile value from the get info dialog box
300  *
301  * @see CVWServerComm
302  * @see CVWCache#cacheObject
303  */
304   public void setValues(CVWObjNum oNum, String n, String i, CVWObjNum own,
305             Date mdate, CVWObjNum mby, Date cdate, boolean sess) {
306       objNum = oNum;
307       name = n;
308       icon = i;
309       owner = own;
310       lastModifiedOn = mdate;
311       lastModifiedBy = mby;
312       createdOn = cdate;
313       sessile = sess;
314     }
315 
316 /* 1/5/98 - dage added
317  */
318 /**
319  * Changes the name of the object on the CVW server
320  * <br> MCP send cvw-modify-metadata
321  * @param newName
322  */
323   public void setName(String newName) {
324     String n;
325     n = prepTextForServer(newName);
326     CVWServerComm.sendMCPCmdToServer("#$#cvw-modify-metadata",
327           "object: " + objNum.strValue() +
328           " name: " + n);
329    }
330 
331 /**
332  * Returns the name of this object.
333  * @return name of this object
334  */
335   public String getName() {
336   return name;
337    }
338    
339 /**
340  * Returns the server unique name of this object.  This is just name for 
341  * objects on the local server or name@serverid for remote objects/users.
342  * This resides on the generic object because it may get called on non-user
343  * objects (groups, etc).  Although we currently only support a server field
344  * for users, it will probably expand to groups and other objects later.
345  * 
346  * @return federated name of this object
347  */
348   public String getFederatedName() {
349       if (this instanceof CVWUser) {
350     CVWUser user = (CVWUser)this;
351     CVWServer serv = user.getServer();
352     if (serv != jcvw.localServer)
353         return name+CVWServer.delimiter+serv.getID();
354       }
355       return name;
356    }
357    
358 /** 
359  * Returns the cvw base name:
360  * if the cvw object is a shortcut the default cvw name is:
361  * "SC to <name>";  This will return the <name> only part.
362  *
363  * @return the base name 
364  */
365   public String getBaseName() {
366      if (isShortcut() && name.startsWith("SC to ")) 
367   return name.substring(6);
368      else
369   return name;
370    }
371 
372 /**
373  * Returns the object number.
374  * @return the object number
375  */
376   public CVWObjNum getObjNum() {
377     return objNum;
378    }
379 
380 /**
381  * Returns the object number as a string.
382  * @return the object number as a string
383  */
384   public String getObjNumStr() {
385     return objNum.strValue();
386    }
387 
388 /**
389  * Returns the icon of object with &quot;.gif&quot; appended to it.
390  * @return  the icon of object with &quot;.gif&quot; appended to it.
391  */
392   public String getIcon() {
393     return icon + ".gif";
394    }
395 
396 /**
397  * Returns the image of this object.
398  * @return the image of this object
399  */
400    public Image getImage() {
401      return null;
402     }
403 
404 /**
405  * Returns the type of object as known by the CVW server.
406  * @return the type of object 
407  * 
408  * @see #getBaseType
409  */
410   public String getType() {
411   return type;
412    }
413    
414 /** 
415  * Returns the cvw base type. 
416  * If the cvw object is a shortcut the cvw server sends down the type as:
417  * "SC to <type>".  This will return the <type> only part.
418  * @return String the base type 
419  * 
420  * @see #getType
421  */
422   public String getBaseType() {
423      if (isShortcut()) 
424   return type.substring(6);
425      else
426   return type;
427    }
428 
429 /**
430  * Returns whether this object is in the cache or not
431  * @return whether this object is in the cache or not
432  */
433    public boolean isCached() {
434   return cached;
435      }
436 
437 /**
438  * Sets whether this object is in the cache or not
439  * @param b whether this object is in the cache or not
440  */
441    public void setCached(boolean b) {
442   cached = b;
443      }
444 
445 /**
446  * Returns the detail name for display. 
447  * For most objects this is the description, subclasses should over ride it.
448  *
449  * @return the detail name for display
450  *
451  * @see #getRawDetailName
452  */
453   public String getDetailName() {
454   return desc;
455    }
456  
457 /**
458  * Returns the actual detail name as defined by each subclass.
459  *
460  * @return 
461  *
462  * @see #getDetailName
463  */
464   public String getRawDetailName() {
465      if (desc != null)
466   return desc;
467      else
468   return new String();
469    }
470  
471 /**
472  * Sets the detail name for this object
473  * @param detailName any additional info for this object
474  */
475   public void setRawDetailName(String detailName) {
476   desc = detailName;
477    }
478  
479 /**
480  * Returns the name of the owner of this object, 
481  * returns &quot;---&quot; instead of &quot;Unknown&quot;
482  * 2/2/98 dage 
483  * @return the name of the owner of this object
484  */
485   public String getOwnerName() {
486      CVWObject obj = (CVWObject)(CVWCache.getInstance().get(owner));
487      if (obj != null)
488   return obj.name;
489      else 
490   return "---";
491    }
492 
493 /**
494  * Returns the name of the user who modified this object, 
495  * returns &quot;---&quot;" instead of "&quot;Unknown&quot;"
496  * 2/2/98 dage 
497  * @return the name of the user who modified this object
498  */
499   public String getModifiedByName() {
500      CVWUser user = getModifiedBy();
501      if (user != null)
502   return user.name;
503      else 
504   return "---";
505    }
506 
507 /* 2/25/98 dage - return the CVWUser
508  */
509 /**
510  * Returns the user who modified this object
511  * @return the user who modified this object
512  */
513   public CVWUser getModifiedBy() {
514      CVWUser user = (CVWUser)(CVWCache.getInstance().get(lastModifiedBy));
515      return user;
516   }
517 
518 /* 2/2/98 dage - return "---" if date is base start date
519  *    returns just the date (not the time)
520  */
521 /**
522  * Returns the date this object was created as a string.
523  * @return the date this object was created as a string
524  *
525  * @see #getDateForDisplay
526  */
527   public String getCreatedDateForDisplay() {
528   return getDateForDisplay(createdOn);
529    }
530 
531 /* 2/2/98 dage - return "---" if date is base start date
532  *    returns just the date (not the time)
533  */
534 /**
535  * Returns the date this object was modified as a string.
536  * @return the date this object was modified as a string
537  *
538  * @see #getDateForDisplay
539  */
540   public String getModifiedDateForDisplay() {
541   return getDateForDisplay(lastModifiedOn);
542    }
543 
544 /**
545  * Returns the desired string format of the date passed in.
546  * @param d the date to be converted
547  * @return the date in the desired string for display
548  */
549   public String getDateForDisplay(Date d) {
550     if (d.equals(DateUtils.dateZero))
551   return "---";
552     return DateUtils.formatDate(d);
553    }
554 
555 /**
556  * Returns the desired string format of the date passed in.
557  * @param d the date to be converted
558  * @return the date in the desired string for display
559  */
560   public String getDateForDetailDisplay(Date d) {
561     if (d.equals(DateUtils.dateZero))
562   return "---";
563     return DateUtils.formatDateTime(d);
564    }
565 
566 /* 10/3/96 dage - list of owners may change, this method needs to
567  *   be allowed to be called from outside.
568  * 1/8/99 dage - yes, the concept of public vs. private was considered ;-)
569  */
570 /**
571  * Sets the owners of the object.  Owners has been defined as other users
572  * who have been given permission to edit this object.
573  * @param owns a space delimited list of object numbers
574  */
575   public void setOwners(String owns) {
576     StringTokenizer ownST = new StringTokenizer(owns, " ");
577     owners = new CVWObjNum[ownST.countTokens()];
578     int i = 0;
579     while (ownST.hasMoreTokens()) {
580           owners[i] = new CVWObjNum((String)ownST.nextElement());
581           //System.err.println(i + " " + owners[i].toString());
582           i++;
583          }
584     setChanged();
585     notifyObservers("owners");
586    }
587 
588 /**
589  * Returns a vector of CVWObjects built from owners.
590  * 8/28/97 dage 
591  *
592  * @return vector of CVWObjects
593  */
594   public Vector getOwners() {
595     Vector v = new Vector(owners.length);
596     CVWCache cache = CVWCache.getInstance();
597     CVWObject obj;
598 /* 9/10/97 dage - dont include the owner of the object.
599     obj = cache.get(owner);
600     if (obj != null) //should never happen
601        v.addElement(obj);
602  */
603     for(int i = 0; i<owners.length;i++) {
604       obj = cache.get(owners[i]);
605       //System.err.println(i + " " + obj);
606       if (obj != null)
607         v.addElement(obj);
608      }
609     return v;
610   }
611 
612 /* 5/19/98 dage - added to get to top environment location 
613  *   either user or room
614  * 5/19/98 dage - we dont cache locations of users
615  */
616 /**
617  * Returns the CVWRoom or CVWUser that this object is located in.
618 
619  * BTW, we don't cache the location of users (they move to much).
620  *
621  * @return the top environment location, either user or room
622  */
623   public CVWObject getTopLocation() {
624   if (this instanceof CVWRoom || this instanceof CVWUser)
625     return this;
626   if (location == null)
627     return this;
628   CVWCache cache = CVWCache.getInstance();
629   CVWObject loc = cache.get(location);
630   if (loc == null)
631     return this;
632   if (loc instanceof CVWRoom || loc instanceof CVWUser)
633     return loc;
634   else
635     return loc.getTopLocation();
636     }
637   
638 /**
639  * Sets the metaDataType variable when the user does a &quot;Information&quot;, 
640  * &quot;Permissions&quot;, &quot;Members&quot;, or &quot;Access&quot;
641  * so that when the CVW server sends the cvw-object-detail MCP it will open the
642  * get info dialog to the correct tab.
643  * <br> MCP send cvw-object-detail-request
644  * @param type <code>GETINFO</code> or <code>ACCESS</code>
645  *
646  * @see #getMetaDataType
647  * @see #startInfoDialog
648  */
649 
650   public void setMetaDataType(int type) {
651     metaDataType = type;
652    }
653 
654 /**
655  * Gets the metaDataType value.
656  * @return the metaDataType value
657  *
658  * @see #setMetaDataType
659  */
660   public int getMetaDataType() {
661     return metaDataType;
662    }
663 
664 /**
665  * Returns a string which is preprocessed for the communications to the CVW server
666  * @param oldStr the string to be processed
667  * @return  the processed string 
668  *
669  * @see CVWServerComm#prepTextForServer
670  */
671   public String prepTextForServer(String oldStr) {
672     return CVWServerComm.prepTextForServer(oldStr);
673    }
674 
675 /**
676  * Converts a boolean to the string needed by the CVW server
677  * 11/20/96
678  * @param bool the boolean to be converted
679  * @return the CVW server string
680  */
681   public String convertBooleanToIntString(boolean bool) {
682     if (bool)
683       return "1";
684     return "0";
685   }
686 
687 /**
688  * Builds the MCP parameter list for notifying the CVW server of any changes to
689  * the information for this object. Only those values which had changed in the 
690  * &quot;Get Info&quote; dialog box
691  *
692  * @param newName name from the get info dialog box
693  * @param newMove sessile value from the get info dialog box
694  * @param newDesc description from the get info dialog box
695  * @return the subclass/instance specific values to be sent to the server
696  */
697 
698   public String getObjectModifyMCP(String newName, boolean newMove, String newDesc) {
699  
700     String param = "";
701  
702       if (!desc.equals(newDesc))
703         param = " description: " + prepTextForServer(newDesc);
704       if (!newName.equals(name))
705         param = param + " name: " +  prepTextForServer(newName);
706     if (newMove != sessile) {
707       sessile = newMove;
708       param = param + " sessile: " +  convertBooleanToIntString(sessile);
709      }
710     return param;
711   }
712 
713 /**
714  * Starts building the MCP for notifying the server of any change to the information
715  * of this object
716  *
717  * @param newName name from the get info dialog box
718  * @param newMove sessile value from the get info dialog box
719  * @param newDesc description from the get info dialog box
720  */
721   public void objectModify(String newName, boolean newMove, String newDesc) {
722     String param = getObjectModifyMCP(newName, newMove, newDesc);
723     objectModify(param);
724    }
725  
726 /**
727  * Sends the MCP to the CVW server
728  * <br> MCP send cvw-modify-metadata
729  * @param param the subclass/instance specific values to be sent to the server
730  */
731   public void objectModify(String param) {
732     if (param.length() != 0) {
733     // If no problems, then set the CVW server.
734     CVWServerComm.sendMCPCmdToServer("#$#cvw-modify-metadata",
735                                 "object: " +  objNum.strValue() + param);
736  
737     }
738   }
739 
740 /* 7/22/98 dage - objects know how to create themselves!!!
741  */
742 /**
743  * Opens a blank &quot;Get Info&quote; dialog box for the user to create an instance
744  * of this object on the CVW server.  When creating an object the use is only presented
745  * with the first tab, &quot;Description&quot;
746  */
747   public void create() {
748     FolderDialog dialog = new FolderDialog("CVW - New " + getType());
749     ObjectPanel pan = getObjectPanel(dialog);
750     dialog.addTab("Description", pan);
751     dialog.pack();
752     dialog.setVisible(true);
753     pan.nameField.requestFocus();
754   }
755 
756 /**
757  * Returns a MCP string representing the values to be sent to the CVW server when
758  * creating an object
759  * <br> MCP send cvw-object-create
760  *
761  * @param name name from the get info dialog box
762  * @param sessile sessile value from the get info dialog box
763  * @param desc description from the get info dialog box
764  * @return the subclass/instance specific values to be sent to the server
765  */
766   public String getObjectCreateMCP(String name, boolean sessile, String desc) {
767      return " type: " + getStringFromType(typeValue) +
768                       " name: " + prepTextForServer(name) +
769                       " description: " + prepTextForServer(desc) +
770                       " sessile: " + convertBooleanToIntString(sessile);
771    }
772  
773 /**
774  * Starts the process of building the MCP to be sent to the CVW server when 
775  * the user creates a new object.
776  *
777  * @param name name from the get info dialog box
778  * @param sessile sessile value from the get info dialog box
779  * @param desc description from the get info dialog box
780  */
781   public void objectCreate(String name, boolean sessile, String desc) {
782     String cmd = getObjectCreateMCP(name, sessile, desc);
783     objectCreate(cmd);
784   }
785 
786 /**
787  * Builds the MCP parameter list for creating the object on the CVW server.
788  * <br> MCP send cvw-object-create
789  *
790  * @param param the subclass/instance specific values to be sent to the server
791  */
792   public void objectCreate(String param) {
793     CVWServerComm.sendMCPCmdToServer("#$#cvw-object-create ", param);
794   }
795 
796 /*  12/30/97 dage - if creating a group, request an update of groups
797  */
798 /**
799  * The results of creating an object on the CVW server. Display the
800  * success or failure of the create in the scrollback.  Try to auto
801  * open the object.
802  *
803  * @param mcpCmd The mcp sent from the server.
804  *  HEARTBURN -- objectCreateResults
805  * @see #autoOpenObject
806  * @see MCPCommand
807  */
808   public void objectCreateResult(MCPCommand mcpCmd) {
809       String loc = "your Carrying folder.";
810       if (typeValue == GROUP) {
811         loc = "the Group Manager.";
812         GroupManager.getInstance().requestSystemGroups();
813        }
814       jcvw.displayPrvSysMsg("\"" + name +
815         "\" successfully created.  It now resides in " + loc);
816       autoOpenObject();
817    }
818 
819 /**** special case scenario
820    talk to cvw server, it says yes
821    talk to doc server, it creates new document
822    talk to cvw server, now there is an error,
823    need to delete the new document from the doc server with a token
824    This is for create doc, copy doc, create wb from doc, create wb
825  *****/
826 
827   public static void objectCreateError(MCPCommand mcpCmd) {
828       CVWCoordinator.getInstance().displayError( "An error occurred while creating your " +
829                         mcpCmd.get("type") + " named \"" +
830                         mcpCmd.get("name") +
831                         "\" (" + mcpCmd.get("error_msg") + ").");
832     }
833 
834 
835 /**
836  * Upon creating an object, open it for the user automatically.
837  *
838  * @see #objectCreateResult
839  * @see CVWNote
840  * @see CVWGroup
841  */
842   public void autoOpenObject() {
843   //most objects do nothing
844   }
845 
846 
847   public void startOpen() {
848       CVWServerComm.sendMCPCmdToServer("#$#cvw-object-open",
849        "object: " + objNum.strValue());
850    }
851 
852 /**
853  * Starts the process of opening a get info dialog box. Sets the metaDataType
854  * to <code>GETINFO</code>.
855  * <br> MCP send cvw-object-detail-request
856  *
857  * @see #startInfoDialog(int type)
858  */
859   public void startInfoDialog () {
860   startInfoDialog(GETINFO);
861    }
862 
863 
864 /**
865  * Starts the process of opening a get info dialog box. Sets the metaDataType
866  * so that when the CVW server sends MCP the correct tabbed panel will be in focus.
867  * <br> MCP send cvw-object-detail-request
868  *
869  * @param type metaDataType to denote which tabbed panel should be opened
870  *
871  * @see #getInfo
872  */
873   public void startInfoDialog (int type) {
874     /* 12/18/96 dage - check first to see if get info on obj is ready open */
875     Window win = WindowMgr.getInstance().getObjectWindow("org.mitre.cvw.FolderDialog", objNum);
876     if (win != null) {
877         ((FolderDialog)win).toFront(type);
878         return;    // dont open a new one
879       }
880 
881     //if (WindowMgr.getWindowMgr().objectWindowExists("org.mitre.cvw.FolderDialog", objNum))
882         //return;
883 
884     metaDataType = type;
885     CVWServerComm.sendMCPCmdToServer("#$#cvw-object-detail-request", 
886               "object: " + objNum.strValue());
887   }
888 
889 /**
890  * Opens the Get Info window for this object. All objects have the Description and
891  * Permissions tabs.  CVWGroups and CVWRooms have a third panel representing their
892  * members and users allowed in the room, respectively.
893  * <br> MCP receive cvw-object-detail
894  *
895  * @param desc the description of this object
896  * @param perms whether the user has permissions to edit this object
897  * @param owners space delimited string of object numbers of the owners
898  * 
899  * @see #startInfoDialog
900  * @see FolderDialog
901  * @see ObjectPanel
902  * @see ObjectOwnerPanel
903  * 
904  */
905   public void getInfo(String desc, String perms, String owners) {
906 
907       this.desc = desc;
908       if (this.desc == null)
909          this.desc = "";
910       
911       if (type.indexOf("SC to") != -1) {
912         perms = "shortcut";       // not editable regardless of ownership
913        }
914       //System.err.println("perms: " + perms+ "  type:"+type);
915 
916       FolderDialog dialog = new FolderDialog("Information About " + name);
917       ObjectPanel objPan = getObjectPanel(dialog, perms);
918       dialog.addTab("Description", objPan);
919       ObjectOwnerPanel acl = new ObjectOwnerPanel(this, dialog, perms);
920       dialog.addTab("Permissions", acl);
921       String title = this.has3rdPanel();
922       ObjectOwnerPanel tmp = null;
923       if (title != null) {
924         tmp = get3rdPanel(dialog, perms);
925   dialog.addTab(title, tmp);
926       }
927 
928 // 9/10/99
929      dialog.folder.addChangeListener(acl);
930      if (tmp != null)
931        dialog.folder.addChangeListener(tmp);
932  
933      WindowMgr.getWindowMgr().addObjectWindow(WindowMgr.OBJECT, dialog, objNum);
934       dialog.pack();
935       dialog.setVisible(true);
936       if (tmp != null && (tmp instanceof ObjectAccessPanel) &&
937       (this instanceof CVWGroup)) {
938   ((ObjectAccessPanel)tmp).setDroppable(true);
939       }
940       dialog.toFront(metaDataType);
941      
942 // do this afterwards because then the usergroupselection will be updated by
943 //   the observable methods.
944      this.setOwners(owners);
945    }
946 
947 /**
948  * Returns the instance of the object panel for this viewing/editing this object
949  * @param diag the parent window
950  * @param perms whether the current user has permissions to edit the object
951  * @return instance of the object panel for general CVWObjects
952  */
953   public ObjectPanel getObjectPanel(FolderDialog diag, String perms) {
954      return new ObjectPanel(this, diag, perms);
955    }
956 
957 /* 7/22/98 dage - used when creating an object
958  */
959 /**
960  * Returns an instance of the object panel for generic objects, used when creating an
961  * object.
962  * @param diag the parent window
963  * @return instance of the object panel specifically for this object
964  */
965 
966   public ObjectPanel getObjectPanel(FolderDialog diag) {
967      return new ObjectPanel(this, diag);
968    }
969 
970 /**
971  * Returns the title of the third tabbed panel in the get info dialog box,
972  * return null if no third panel. Most CVWObject descendents do not have a third panel.
973  * @return <code>null</code>
974  * @see CVWGroup#has3rdPanel
975  * @see CVWRoom#has3rdPanel
976  */
977   public String has3rdPanel() {
978   return null;
979     }
980 
981 /**
982  * Returns the instance of the third tabbed panel in the get info dialog box,
983  * return null if no third panel. Most CVWObject descendents do not have a third panel.
984  * @param diag the parent window the panel will go in
985  * @param perms whether the current user has permissions to edit this group
986  * @return the third tabbed panel in the get info dialog box
987  * @return <code>null</code>
988  * @see CVWGroup#get3rdPanel
989  * @see CVWRoom#get3rdPanel
990  */
991   public ObjectOwnerPanel get3rdPanel(FolderDialog diag, String perms) {
992   return null;
993    }
994 
995 /**
996  * Sets the detail information variables.
997  * Currently not used.
998  * @param descr the description of this object
999  * @param perms whether the user has permissions to edit this object
1000 * @param owns a space delimited list of object numbers who are the owners of this object
1001 */
1002  public void updateDetailInfo(String descr, String perms, String owns) {
1003  setOwners(owns);
1004  desc = descr;
1005    }
1006
1007/**
1008 * Returns a list of object numbers which represent the new object numbers contained 
1009 * in the new vector exluding those that are in the old array. 
1010 * This is to process contents or owners of an object. 
1011 * 5/30/98 dage
1012 *
1013 * @param oNums[] array of CVWObjNums
1014 * @param newV a vector of CVWObjNums as strings
1015 * @return a space delimited list of objects numbers 
1016 */
1017  public String newObjNumString(CVWObjNum oNums[], Vector newV) {
1018    String newONums = "";
1019    boolean changed = false;
1020    boolean contains = false;
1021    boolean check = true;
1022    if (newV.size() != oNums.length) {
1023      check = false;    //if different sizes, then send new, dont bother checking
1024      changed = true;
1025     }
1026    for (int i = 0; i< newV.size(); i++) {
1027        String oNum = (String)newV.elementAt(i);
1028        newONums += oNum + " ";
1029        if (check) {   //see if this obj num is contained in orig oNums list
1030          //System.err.println("checking" + oNum);
1031          contains = false;
1032          for (int j=0;j<oNums.length; j++) {
1033                //System.err.println("checking" + j + oNums[j]);
1034            if (oNums[j].equals(oNum)) {
1035               contains = true;
1036               break;    //break from for loop
1037             }
1038           }
1039          if (!contains) { 
1040            changed = true;
1041            check = false;   //stop checking
1042          }
1043         }
1044     }
1045    if (!changed) {
1046      //System.err.println("new oNums = old oNums");
1047      return null;
1048     }
1049    //System.err.println("new oNums: " + newONums);
1050    newONums = "\"" + newONums.trim() + "\"";
1051    return newONums;
1052   }
1053
1054/**
1055 * Sends the owner access list to the CVW server when the user has changed
1056 * the permissions of this object.
1057 * <br> MCP send cvw-access-set-owners
1058 * 5/30/98
1059 * @param u vector of CVWObjects (CVWUsers)
1060 * @param g vector of CVWObjects (CVWGroups)
1061 */
1062  public void updateOwners(Vector u, Vector g) {
1063    //System.err.println("update owners: " + u.size() + " " + g.size());
1064    Vector newV = buildObjNumStrVector(u, g);
1065    String newOwners = newObjNumString(owners, newV);
1066    if (newOwners == null) return;
1067    //System.err.println("#$#cvw-access-set-owners " + 
1068    CVWServerComm.sendMCPCmdToServer("#$#cvw-access-set-owners",
1069            "object: " + objNum.strValue() +
1070            " owners: " + newOwners);
1071    }
1072
1073/**
1074 * Processes the results of the setting the the owners of the object.
1075 * <br> MCP receive cvw-access-set-owners-result
1076 *
1077 * @param err the error code from the CVW server, 0 denotes no error
1078 * @param ownList space delimited list of object numbers sent to the CVW server
1079 * 
1080 * @see #updateOwners
1081 */
1082  public void updateOwnersResult(String err, String ownList) {
1083    if (!err.equals("0"))
1084  System.err.println("error in updateOwners: " + err);
1085    }
1086
1087
1088/**
1089 * Processes the results of the setting the the acl of the object.
1090 * This is currently only used by CVWRoom.
1091 * <br> MCP receive cvw-access-set-acl-result
1092 *
1093 * @param err the error code from the CVW server, 0 denotes no error
1094 * @param aclList space delimited list of object numbers sent to the CVW server
1095 * 
1096 * @see CVWRoom#updateACL
1097 */
1098  public void updateACLResult(String err, String aclList) {
1099    if (!err.equals("0"))
1100      System.err.println("error in updateACL: " + err);
1101    }
1102
1103/**********   object delete methods      **************/
1104/**
1105 * Starts the process of deleting an object.
1106 *
1107 * The current mode of operation is
1108 * Check CVW server to see if permission to delete the object,
1109 * send cvw-object-delete with final = 0
1110 * <br>start of process if not a document
1111 * <br>if so, and not a document ask user if sure
1112 * <br>if yes, then send cvw-object-delete with final = 1
1113 * <br>end of process if not a document
1114 * <p>
1115 * <br>start of process if a document
1116 * <br>if so, check to see if the doc server can delete it
1117 * <br>if yes, ask the user if sure
1118 * <br>if yes, then send cvw-object-delete with final = 1
1119 * <br>CVW server will send cvw-document-delete
1120 * <br>try to delete on document server
1121 * <br>return to CVW server whether the delete on the doc server happened
1122 * <br>end of process if a document
1123 *
1124 * <br> MCP send cvw-object-delete
1125 * @param objNum the object number of the object to delete
1126 * @see #confirmDelete
1127 * @see CVWDocument#doDocDelete
1128 */
1129  public void startDeleteDialog() {
1130    CVWServerComm.sendMCPCmdToServer("#$#cvw-object-delete",
1131                        "object: " + objNum.strValue() + " final: 0");
1132   }
1133
1134/** 3/5/97 dage - dont do doDocFunction for deletion of SC to Document
1135 *  12/30/97 dage - if deleting a group, request an update of groups
1136 * 6/3/98 dage - make the dialog modal to the appropriate frame
1137 */
1138/**
1139 * Either notifies the user that the object has been deleted or confirms the
1140 * delete of the object with the user because the CVW server has okayed
1141 * the user to delete the object (i.e. the suer has permissions)
1142 * <br> MCP receive cvw-object-delete-result
1143 * @param objNum the object number of the object to be deleted
1144 * @param name the name of the object to be deleted
1145 * @param finalTime if &quot;1&quot; then the object has been deleted, notify the user
1146 * if not, then ask the user if they really want to delete the object
1147 * @see CVWDocument#doDocFunction
1148 * @see CVWDocument#doDocDelete
1149 */
1150  public void confirmDelete(String name, int finalTime) {
1151    if (finalTime == 1) {
1152      jcvw.displayPrvSysMsg("\""+name+"\" has been deleted.");
1153      if (typeValue == CVWObject.GROUP)
1154        GroupManager.getInstance().requestSystemGroups();
1155      else if (typeValue == CVWObject.FOLDER) 
1156        ContentsCoordinator.getInstance().closeFolder(objNum); 
1157      return;
1158     }
1159
1160        showDeleteDialog();
1161   }
1162
1163   protected void showDeleteDialog() {
1164      String text = "Are you sure you want to delete \""+name+"\"?";
1165      JFrame frame = getObjectFrame();
1166      OkCancelDialog confDialog = new OkCancelDialog(frame, text, true, "Confirm Delete");
1167      confDialog.pack();
1168      confDialog.setVisible(true);
1169      if (!confDialog.cancel) {
1170         CVWServerComm.sendMCPCmdToServer("#$#cvw-object-delete",
1171                                          "object: " + objNum.strValue() + " final: 1");
1172        }
1173    }
1174
1175
1176/* 6/3/98 dage - moved this code from CVWServerComm 
1177 *  shortcuts are handled int handleShortcutError
1178 */
1179/**
1180 * The CVW server denyed the user the ability to delete an object
1181 * Hint: the item # and the object # will be different in the following situation:
1182 * you are deleting a folder which has a note in it .. you cannot delete the note.
1183 * the object # is that of the folder, the item # is that of the note.
1184 * <br> MCP receieve cvw-object-delete-result
1185 *
1186 * @param item the object number of the item which had a problem being deleted
1187 * @param error the error message
1188 * @param name the name of the object to be deleted
1189 * @see #handleShortcutError
1190 */
1191   public void deleteResultError(String item, String error) {
1192      CVWObject iObj;
1193      String iName = "";
1194      boolean folderDelete = false;
1195      if (item != null && !objNum.equals(item)) {
1196        folderDelete = true;
1197        iObj = CVWCache.getInstance().get(item);
1198        if (iObj != null)
1199          iName = iObj.name;
1200       }
1201
1202      JFrame frame = getObjectFrame();
1203      if (error.equals("permission")) {
1204        String msg = "You don't have permission to delete \""+name+"\".";
1205        if (folderDelete)
1206           msg = "\""+name+"\" cannot be deleted.  It contains \"" + iName +
1207                                "\" which you do not have pemission to delete.";
1208        jcvw.displayError(frame, msg, "Delete Error");
1209      } else // if (error.equals("unknown"))
1210        jcvw.displayError(frame, "An unknown error occured while trying to delete \""+name+"\".  ", "Delete Error");
1211
1212    }
1213
1214/**
1215 * User has asked to delete an object that has shortcuts, this will confirm to
1216 * delete the original object and *ALL* shortcuts to it, regardless of who owns them, this
1217 * will show the user all shortcuts and who owns them.
1218 * <br>
1219 * Hint: the item # and the object # will be different in the following situation:
1220 * you are deleting a folder which has a note in it .. the note has a shortcut.
1221 * the object # is that of the folder, the item # is that of the note.
1222 * <br> MCP receieve cvw-object-delete-result
1223 * 
1224 * @param object the object number of the object to be deleted
1225 * @param item the item which is having the problem being deleted
1226 * @param shortcuts a space delimited list of object numbers of the shortcuts
1227 */
1228  public void handleShortcutError(String item, String shortcuts) {
1229    String toPrint;
1230    String scs = "";
1231    StringTokenizer existing = new StringTokenizer(shortcuts, " ");
1232
1233    boolean folderDelete = false;
1234    CVWObject folder;
1235    String folderName = "";
1236
1237    CVWObject problem = (CVWObject)(CVWCache.getInstance().get(item));
1238    String iName = item;
1239    JFrame frame = getObjectFrame();
1240    if (problem != null)  {
1241        iName = problem.name;
1242        frame = problem.getObjectFrame();
1243      }
1244     if (item != null && !objNum.equals(item)) {
1245        folderDelete = true;
1246        folder = this;
1247        folderName = name;
1248      }
1249
1250    while(existing.hasMoreTokens()) {
1251      String objnum = existing.nextToken();
1252      CVWObject shortcut = CVWCache.getInstance().get(objnum);
1253      if (shortcut != null) {
1254        CVWUser owner = (CVWUser)(CVWCache.getInstance().get(shortcut.owner));
1255        if (owner != null)
1256            toPrint = "\""+shortcut.name + "\" (owned by "+owner.name+
1257                                        ", created on "+
1258                                        shortcut.getCreatedDateForDisplay() +
1259                                        ")";
1260        else
1261            toPrint = "\""+shortcut.name+"\"";
1262      } else toPrint = objnum;
1263
1264      scs += toPrint + "\n";
1265    }
1266    String msg = "Are you sure you want to delete\"" + name +"\"?  It";
1267    if (folderDelete)
1268      msg = "Are you sure you want to delete\"" + folderName + "\"?  It contains \"" + iName + "\" which";
1269    msg += " has shortcuts, all of which will be deleted.  Below are the shortcuts:";
1270    OkCancelTextDialog ok = new OkCancelTextDialog(frame, msg, true, "Confirm Delete", OkCancelDialog.WARNING, scs);
1271    ok.pack();
1272    ok.setVisible(true);
1273    if (!ok.cancel)
1274       CVWServerComm.sendMCPCmdToServer("#$#cvw-object-delete-shortcuts",
1275                                                        "object: " + objNum.strValue() +
1276                                                        " item: " + item);
1277 }
1278/**********  end object delete methods      **************/
1279
1280/********** object copy methods      **************/
1281
1282/* 1/5/98 dage - cleaned up code
1283 * 4/10/98 dage - moved DSI code to DSIController
1284 */
1285/**
1286 * Copy or create Shortcut of the object.
1287 * User selected Copy or Shortcut from the object menu.
1288 *
1289 * @param type the type of copy either <code>Copy</code> or <code>Shortcut</code>
1290 */
1291  public void objectCopy(String type) {
1292System.err.println("in CVWObject::copy");
1293    CVWServerComm.sendMCPCmdToServer("#$#cvw-object-copy", 
1294            "object: " + objNum.strValue() + " copytype: " + type);
1295  }
1296
1297/**
1298 * Display the results of the object copy from the server.
1299 * 0 denotes no error, otherwise display the message from the server.
1300 * <br> MCP receive cvw-object-copy-result
1301 *
1302 * @param mcpCmd
1303 *
1304 * @see MCPCommand
1305 */
1306  public void objectCopyResult(MCPCommand mcpCmd) {
1307    if (mcpCmd.get("error").equals("0")) {
1308      jcvw.displayPrvSysMsg("\"" + name + "\"  successfully copied.  " +
1309                        "A " + mcpCmd.get("copytype") +
1310                        " now resides in your Carrying folder.");
1311     }
1312    else
1313      jcvw.displayError("(" + mcpCmd.get("error_msg") +
1314                        ") occurred while copying your " +
1315                        mcpCmd.get("copytype")+ ".");
1316   }
1317/********** end object copy methods      **************/
1318
1319/**********   object move methods      **************/
1320/**
1321 * Processes a drop or a take on a CVW object by sending the appropriate command
1322 * to the CVW server.
1323 * <br> MCP send cvw-move
1324 * @param action either &quot;Drop&quot; or &quot;Take&quot;
1325 * @param object the object to be moved
1326 */
1327  public void doDropTake(String action) {
1328
1329    if (action.startsWith("Drop"))
1330  moveObject(jcvw.getCurrentRoom());
1331     else
1332  moveObject(jcvw.getCurrentUser());
1333  }
1334
1335/**
1336 * Moves this object to another object.
1337 * @param toObj the destination object
1338 */
1339   public void moveObject(CVWObject toObj) {
1340      moveObject(toObj, null);
1341    }
1342
1343/**
1344 * Moves this object to another object.
1345 * <br> MCP send cvw-move
1346 * @param toObj the destination object
1347 * @param frame the window that this object is currently in so that errors
1348 * displayed in dialog box is associated with that frame
1349 */
1350   public void moveObject(CVWObject toObj, JFrame frame) {
1351    String fromString = "";
1352    String toString = toObj.objNum.strValue();
1353    if (location != null) {
1354        fromString = location.strValue();
1355        if (fromString.equals(toString)) {
1356          String msg = "\"" + name + "\"";
1357          if (frame == null)
1358            frame = getObjectFrame();
1359          if (//!(frame instanceof CVWFolderWindow) && 
1360    location.equals(jcvw.getCurrentUser().objNum))
1361             msg = "You already have " + msg;
1362          else
1363             msg = msg + " is already there.";
1364          jcvw.displayError(frame,  msg, "Move Error");
1365          return;
1366         }
1367        fromString = " from: " + fromString;
1368     }
1369    toString = " to: " + toString;
1370
1371    CVWServerComm.sendMCPCmdToServer("#$#cvw-move", "object: " + objNum.strValue() +
1372                                 toString + fromString);
1373    }
1374
1375/* 6/5/98 dage - added code to make error dialog modal to the object window
1376 * 11/10/98 dage - moveObjectResult, differentiated between moving within private
1377 *   folders and taking from room and public/private give to user/move to room
1378 * 2/3/99 dage - moved from CVWCoordinator
1379 */
1380/**
1381 * Processes the results of an error.
1382 * <br> MCP receive cvw-move-result
1383 * @param error either &quot;1&quot; or &quot;0&quot;
1384 * @param msg the error message from the CVW server
1385 * @param receiver the object number of the destination object
1386 * @param origin the object number of the origination object
1387 */
1388  public void moveResult(String error, String msg, String receiver, String origin) {
1389
1390    JFrame frame = getObjectFrame();
1391    String n = "\""+name+"\"";
1392
1393    if (error.equals("1")) {
1394       if (msg.indexOf("locked down") != -1)
1395         jcvw.displayError(frame, n+" is locked down and cannot be moved.", "Move Error");
1396       else if (msg.indexOf("currently checked out") != -1)
1397         jcvw.displayError(frame, n+" is currently checked out.  Documents cannot be moved while you are working on them.", "Move Error");
1398       else if (msg.indexOf("currently being edited") != -1)
1399         jcvw.displayError(frame, n+" is currently being edited.  Documents cannot be moved until the changes have been saved or discarded.", "Move Error");
1400       else
1401         jcvw.displayError(frame, msg);
1402        //if (waitingForTakeResult.equals(object))
1403          //displayError(frame, n+" cannot be opened for editing.");
1404  return;
1405     } 
1406
1407      //if (this instanceof CVWGroup && groupManager.groupViewerIsOpen())
1408                //GroupManager.getInstance().requestSystemGroups();
1409
1410      boolean pub = true;
1411      CVWObject currentUser = jcvw.getCurrentUser();
1412      if (currentUser.objNum.equals(receiver)) {
1413        CVWObject orig = CVWCache.getInstance().get(origin);
1414        if (orig != null) {
1415           CVWObject oTop = orig.getTopLocation();
1416           if (oTop == currentUser)
1417             pub = false;
1418         }
1419        if (pub)
1420           jcvw.displayPubSysMsg("You take " + n + ".");
1421        else
1422           jcvw.displayPrvSysMsg("You move " + n + " to your Carrying Folder.");
1423        //if (waitingForTakeResult.equals(object))
1424          //sendMCPCmdToServer("#$#cvw-document-checkout-request","object: " + object);
1425  return;
1426       } 
1427      CVWObject room = jcvw.getCurrentRoom();
1428      if (room.objNum.equals(receiver)) { //SHOULD Check!!!
1429          jcvw.displayPubSysMsg("You drop " + n + " in " + room.name + ".");
1430          return;
1431   }
1432
1433      pub = false;
1434      String verb = "move ";
1435      CVWObject dest = CVWCache.getInstance().get(receiver);
1436      String