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 */
026public abstract class ScmProviderRepository {
027    private String user;
028
029    private String password;
030
031    @Deprecated
032    private boolean persistCheckout = false;
033
034    /**
035     * @since 1.4
036     */
037    private boolean pushChanges = true;
038
039    /**
040     * Some SCMs have the concept of a work item (or task) which may need to be
041     * specified to allow changes to be pushed or delivered to a target.
042     * This allows you to answer the question: For this workItem, what changed?
043     * Auditors have been known to love this... :)
044     * SCMs known to implement this are:
045     * <ul>
046     * <li>IBM Rational Team Concert (workItem)
047     * <li>Microsoft Team Foundation Server (workItem)
048     * <li>IBM Rational ClearQuest Enabled UCM ClearCase (task)
049     * </ul>
050     * There may be others that support this feature.
051     * <P>
052     * These SCMs can be configured to reject a push/deliver unless additional
053     * information (by way of a workItem/task) is supplied.
054     * <P>
055     * This field is only relevant when pushChanges = true.
056     * <P>
057     * It should be noted however, when pushChanges = true, a workItem does not
058     * need to be set, as the need for a workItem may be optional.
059     *
060     * @since 1.9.5
061     */
062    @Deprecated
063    private String workItem;
064
065    /**
066     * @return the user
067     */
068    public String getUser() {
069        return user;
070    }
071
072    /**
073     * Set the user.
074     *
075     * @param user the user
076     */
077    public void setUser(String user) {
078        this.user = user;
079    }
080
081    /**
082     * @return the password
083     */
084    public String getPassword() {
085        return password;
086    }
087
088    /**
089     * Set the password.
090     *
091     * @param password the user password
092     */
093    public void setPassword(String password) {
094        this.password = password;
095    }
096
097    /**
098     * Should distributed changes be pushed to the central repository?
099     * For many distributed SCMs like Git, a change like a commit
100     * is only stored in your local copy of the repository.  Pushing
101     * the change allows your to more easily share it with other users.
102     *
103     * @return TODO
104     * @since 1.4
105     */
106    public boolean isPushChanges() {
107        return pushChanges;
108    }
109
110    /**
111     * @param pushChanges TODO
112     * @since 1.4
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     *
151     * @return TODO
152     */
153    @Deprecated
154    public boolean isPersistCheckout() {
155        String persist = System.getProperty("maven.scm.persistcheckout");
156        if (persist != null) {
157            return Boolean.valueOf(persist).booleanValue();
158        }
159        return persistCheckout;
160    }
161
162    @Deprecated
163    public void setPersistCheckout(boolean persistCheckout) {
164        this.persistCheckout = persistCheckout;
165    }
166
167    /**
168     * Get a {@link ScmProviderRepository} that represents the parent folder in the repository.
169     * Useful when the repository does not exist yet, and we need to create it from the parent.
170     *
171     * @return the parent repository
172     * @throws UnsupportedOperationException unless overridden by subclass
173     */
174    public ScmProviderRepository getParent() {
175        throw new UnsupportedOperationException();
176    }
177
178    /**
179     * Get the relative path between the repository provided as argument and the current repository.
180     *
181     * @param ancestor another repository that should be ancestor of this one
182     * @return the relative path or <code>null</code> if it can't be resolved
183     * @throws UnsupportedOperationException unless overridden by subclass
184     */
185    public String getRelativePath(ScmProviderRepository ancestor) {
186        throw new UnsupportedOperationException();
187    }
188}