001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *   http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied.  See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019package org.apache.maven.scm.provider;
020
021/**
022 * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
023 * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
024 * @author <a href="mailto:ChrisGWarp@gmail.com">Chris Graham</a>
025 *
026 */
027public abstract class ScmProviderRepository {
028    private String user;
029
030    private String password;
031
032    @Deprecated
033    private boolean persistCheckout = false;
034
035    /**
036     * @since 1.4
037     */
038    private boolean pushChanges = true;
039
040    /**
041     * Some SCMs have the concept of a work item (or task) which may need to be
042     * specified to allow changes to be pushed or delivered to a target.
043     * This allows you to answer the question: For this workItem, what changed?
044     * Auditors have been known to love this... :)
045     * SCMs known to implement this are:
046     * <ul>
047     * <li>IBM Rational Team Concert (workItem)
048     * <li>Microsoft Team Foundation Server (workItem)
049     * <li>IBM Rational ClearQuest Enabled UCM ClearCase (task)
050     * </ul>
051     * There may be others that support this feature.
052     * <P>
053     * These SCMs can be configured to reject a push/deliver unless additional
054     * information (by way of a workItem/task) is supplied.
055     * <P>
056     * This field is only relevant when pushChanges = true.
057     * <P>
058     * It should be noted however, when pushChanges = true, a workItem does not
059     * need to be set, as the need for a workItem may be optional.
060     *
061     * @since 1.9.5
062     */
063    @Deprecated
064    private String workItem;
065
066    /**
067     * @return The user.
068     */
069    public String getUser() {
070        return user;
071    }
072
073    /**
074     * Set the user.
075     *
076     * @param user The user
077     */
078    public void setUser(String user) {
079        this.user = user;
080    }
081
082    /**
083     * @return The password.
084     */
085    public String getPassword() {
086        return password;
087    }
088
089    /**
090     * Set the password.
091     *
092     * @param password The user password
093     */
094    public void setPassword(String password) {
095        this.password = password;
096    }
097
098    /**
099     * Should distributed changes be pushed to the central repository?
100     * For many distributed SCMs like Git, a change like a commit
101     * is only stored in your local copy of the repository.  Pushing
102     * the change allows your to more easily share it with other users.
103     * @return TODO
104     * @since 1.4
105     */
106    public boolean isPushChanges() {
107        return pushChanges;
108    }
109
110    /**
111     * @since 1.4
112     * @param pushChanges TODO
113     */
114    public void setPushChanges(boolean pushChanges) {
115        this.pushChanges = pushChanges;
116    }
117
118    /**
119     * @return The workItem.
120     * @since 1.9.5
121     */
122    @Deprecated
123    public String getWorkItem() {
124        return workItem;
125    }
126
127    /**
128     * Set the workItem.
129     *
130     * @param workItem The workItem.
131     * @since 1.9.5
132     */
133    @Deprecated
134    public void setWorkItem(String workItem) {
135        this.workItem = workItem;
136    }
137
138    /**
139     * Will checkouts using this repository be persisted so they can
140     * be refreshed in the future?  This property is of concern to SCMs
141     * like Perforce and Clearcase where the server must track where a
142     * user checks out to.  If false, the server entry (clientspec in Perforce
143     * terminology) will be deleted after the checkout is complete so the
144     * files will not be able to be updated.
145     * <p>
146     * This setting can be overriden by using the system property
147     * "maven.scm.persistcheckout" to true.
148     * <p>
149     * The default is false.  See SCM-113 for more detail.
150     * @return TODO
151     */
152    @Deprecated
153    public boolean isPersistCheckout() {
154        String persist = System.getProperty("maven.scm.persistcheckout");
155        if (persist != null) {
156            return Boolean.valueOf(persist).booleanValue();
157        }
158        return persistCheckout;
159    }
160
161    @Deprecated
162    public void setPersistCheckout(boolean persistCheckout) {
163        this.persistCheckout = persistCheckout;
164    }
165
166    /**
167     * Get a {@link ScmProviderRepository} that represents the parent folder in the repository.
168     * Useful when the repository does not exist yet and we need to create it from the parent.
169     *
170     * @return the parent repository
171     * @throws UnsupportedOperationException unless overridden by subclass
172     */
173    public ScmProviderRepository getParent() {
174        throw new UnsupportedOperationException();
175    }
176
177    /**
178     * Get the relative path between the repository provided as argument and the current repository.
179     *
180     * @param ancestor another repository that should be ancestor of this one
181     * @return the relative path or <code>null</code> if it can't be resolved
182     * @throws UnsupportedOperationException unless overridden by subclass
183     */
184    public String getRelativePath(ScmProviderRepository ancestor) {
185        throw new UnsupportedOperationException();
186    }
187}