001    /*
002    * file CcVobResource.java
003    *
004    * Licensed Materials - Property of IBM
005    * Restricted Materials of IBM
006    *
007    * com.ibm.rational.wvcm.stp.cc.CcVobResource
008    *
009    * (C) Copyright IBM Corporation 2004, 2009.  All Rights Reserved.
010    * Note to U.S. Government Users Restricted Rights:  Use, duplication or
011    * disclosure restricted by GSA ADP  Schedule Contract with IBM Corp.
012    */
013    
014    package com.ibm.rational.wvcm.stp.cc;
015    
016    import static com.ibm.rational.wvcm.stpex.StpExBase.PROPERTY_NAMESPACE;
017    
018    import java.util.List;
019    
020    import javax.wvcm.Feedback;
021    import javax.wvcm.ResourceList;
022    import javax.wvcm.WvcmException;
023    import javax.wvcm.PropertyNameList.PropertyName;
024    
025    import com.ibm.rational.wvcm.stp.ccex.CcExFileList.RequestForMastershipFlag;
026    import com.ibm.rational.wvcm.stpex.StpExEnumeration;
027    
028    /**
029     * <p>
030     * Base interface containing properties and methods common to
031     * all VOB-resident ClearCase resources.
032     * </p>
033     */
034    public interface CcVobResource extends CcResource {
035    
036        /** Flags for the doApplyAttribute method */
037        enum ApplyAttributeFlag implements StpExEnumeration {
038    
039            /**
040             * Replace existing attribute instance.
041             */
042            REPLACE("replace"),
043    
044            /**
045             * If the attribute type was created with a default value, uses
046             * that value for the attribute instead of the value specified in
047             * the call. An error occurs if the attribute type was not created 
048             * with a default value. 
049             */
050            DEFAULT("default");
051            
052            private String m_name;
053    
054            private ApplyAttributeFlag(String name) { m_name = name; }
055    
056            /* (non-Javadoc)
057             * @see java.lang.Object#toString()
058             */
059            public String toString() { return m_name; }
060        }
061    
062        /**
063         * Apply the specified attribute to this VOB resource.
064         * @param flags array of flags which specify the behavior of the operation
065         * @param comment Comment (if any) to be used for operation.  Empty string if none.
066         * @param attributeName Name of an existing attribute type to be used to create 
067         * an instance will to be applied to this resource.
068         * @param attributeValue Value of attribute instance.  If the vtype of the attribute type is
069         * a string, it must be enclosed in additional quotes <em>within the string</em>.  For example, if
070         * specified as a constant it would appear as <code>"\"string value\""</code>.  If the
071         * vtype is not a string, this should be a string representation of the given value 
072         * (e.g. <code>"3.1415"</code>, <code>"0xa413"</code>, etc.).
073         * @param feedback 
074         * @return A new proxy for this resource, whose properties are specified by feedback.
075         * @throws WvcmException
076         */
077        CcVobResource doApplyAttribute(ApplyAttributeFlag[] flags, String comment, 
078                String attributeName, String attributeValue, Feedback feedback)
079        throws WvcmException;
080        
081        /**
082         * Remove the specified attribute from this VOB resource.
083         * @param comment Comment (if any) to be used for operation.  Empty string if none.
084         * @param attributeName Name of the attribute to be removed from this resource
085         * @param feedback 
086         * @return A new proxy for this resource, whose properties are specified by feedback.
087         * @throws WvcmException
088         */
089        CcVobResource doRemoveAttribute(String comment,  String attributeName, Feedback feedback)
090        throws WvcmException;
091        
092        /**
093         * <p>
094         * Request for local mastership of this VOB resource.
095         * </p>
096         * <p>
097         * Note: this operation is only supported for CcBranch and CcBranchType resources.
098         * </p>
099         * @param flags array of flags which specify the behavior of the operation.
100         * @param comment Comment (if any) to be used for operation.  Empty string if none.
101         * @param feedback list of properties to fetch on this resource.
102         * @return new proxy with the requested properties available.
103         * @throws WvcmException
104         */
105        CcVobResource 
106        doRequestForMastership(RequestForMastershipFlag[] flags, String comment, Feedback feedback) 
107            throws WvcmException;
108    
109        /** The VOB in which this VOB resource resides. */
110        PropertyName<CcVob> VOB =
111            new PropertyName<CcVob>(PROPERTY_NAMESPACE, "vob");
112    
113        /**
114         * Get the value of this proxy's {@link #VOB} property.
115         * @return This resource's VOB. Will never be null.
116         * @throws WvcmException
117         */
118        public CcVob getVob() throws WvcmException;
119    
120        /** List of attributes attached to this resource. */
121        public static final PropertyName<List<CcAttribute>> ATTRIBUTE_LIST =
122            new PropertyName<List<CcAttribute>>(PROPERTY_NAMESPACE, "attribute-list");
123        
124        /**
125         *  Get the value of this proxy's {@link #ATTRIBUTE_LIST} property.
126         *  @return List of CcAttribute proxies applied to this resource.  Empty list if none.
127         *  @throws WvcmException if this proxy doesn't define a value for this property.
128         */
129        public List<CcAttribute> getAttributeList() throws WvcmException;
130        
131        /** Replica in which this resource resides. */
132        public static final PropertyName<CcReplica> CURRENT_REPLICA =
133            new PropertyName<CcReplica>(PROPERTY_NAMESPACE, "current-replica");
134        
135        /**
136         * Returns the value of this proxy's {@link #CURRENT_REPLICA} property.
137         * 
138         * @return Replica in which the resource resides as a CcReplica instance.
139         * @throws WvcmException
140         *             if this proxy doesn't define a value for this property.
141         */
142        public CcReplica getCurrentReplica() throws WvcmException;
143    
144        /** List of hyperlink resources attached to this resource. */
145        public static final PropertyName<ResourceList<CcHyperlink>> HYPERLINK_LIST =
146            new PropertyName<ResourceList<CcHyperlink>>(PROPERTY_NAMESPACE, "hyperlink-list");
147    
148        /**
149         *  Get the value of this proxy's {@link #HYPERLINK_LIST} property.
150         *  @return List of CcHyperlink proxies applied to this resource.  Empty list if none.
151         *  @throws WvcmException if this proxy doesn't define a value for this property.
152         */
153        public ResourceList<CcHyperlink> getHyperlinkList() throws WvcmException;
154    
155        /** CcLockInfo object contains the supported lock properties. */
156        public static final PropertyName<CcLockInfo> LOCK_INFO =
157            new PropertyName<CcLockInfo>(PROPERTY_NAMESPACE, "lock-info");
158    
159        /**
160         * Returns the value of this proxy's {@link #LOCK_INFO} property.
161         * 
162         * @return the CcLockInfo object for the resource.
163         *         <code>null</code> if the object is not locked.
164         * @throws WvcmException
165         *             if this proxy doesn't define a value for this property.
166         */
167        public CcLockInfo getLockInfo() throws WvcmException;
168    
169        /**
170         * Sets (or replaces) the lock on this proxy according to the
171         * {@link #LOCK_INFO} property.
172         * @param lockInfo lock information for the new lock, or <code>null</code>
173         *        to unlock the proxy.
174         */
175        public void setLockInfo(CcLockInfo lockInfo);
176    
177        
178        /**
179         * Does this object have local mastership? If true, this object is mastered
180         * in the same replica as its VOB.  Otherwise, it is mastered at a replica
181         * remote from that of its VOB.
182         */
183        PropertyName<Boolean> HAS_LOCAL_MASTERSHIP =
184            new PropertyName<Boolean>(PROPERTY_NAMESPACE, "has-local-mastership"); //$NON-NLS-1$
185    
186        /**
187         * Get the value of this proxy's {@link #HAS_LOCAL_MASTERSHIP} property.
188         * @return true if this object has local mastership, else false
189         * @throws WvcmException if this proxy doesn't define a value for this property.
190         */
191        boolean getHasLocalMastership() throws WvcmException;
192    
193        
194        /** Replica which has mastery of this resource. */
195        public static final PropertyName<CcReplica> CC_MASTER_REPLICA =
196            new PropertyName<CcReplica>(PROPERTY_NAMESPACE, "cc-master-replica");
197        
198        /**
199         * Returns the value of this proxy's {@link #CC_MASTER_REPLICA} property.
200         * 
201         * @return Replica in which the resource is mastered as a CcReplica instance.
202         *         null if resource cannot be mastered.
203         * @throws WvcmException
204         *             if this proxy doesn't define a value for this property.
205         */
206       public CcReplica getMasterReplica() throws WvcmException;
207     
208       /**
209        * <p>
210        * The permissions applied to this resource.
211        * </p>
212        */
213       PropertyName<CcPermissions> PERMISSIONS =
214           new PropertyName<CcPermissions>(PROPERTY_NAMESPACE, "cc-permissions");
215       
216       /**
217        * Get the value of this resource's {@link #PERMISSIONS} property.
218        * 
219        * @return A permissions object from which specific permissions 
220        * information can be extracted.
221        * @throws WvcmException
222        */
223       CcPermissions getPermissions() throws WvcmException;
224       
225       /**
226        * Set the value of this proxy's {@link #PERMISSIONS} property.
227        * 
228        * @param permissions  A permissions object.  Use the one returned
229        *                     by getPermissions and modify it.
230        * @throws WvcmException
231        *         if this proxy doesn't define a value for this property.
232        */
233       void setPermissions(CcPermissions permissions) throws WvcmException;
234    
235       
236    }