summaryrefslogtreecommitdiff
path: root/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNRepos.java
blob: 7d967bfdc6c45996dca7c51f4f34a7677b911d89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
/**
 * @copyright
 * ====================================================================
 *    Licensed to the Apache Software Foundation (ASF) under one
 *    or more contributor license agreements.  See the NOTICE file
 *    distributed with this work for additional information
 *    regarding copyright ownership.  The ASF licenses this file
 *    to you under the Apache License, Version 2.0 (the
 *    "License"); you may not use this file except in compliance
 *    with the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing,
 *    software distributed under the License is distributed on an
 *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 *    KIND, either express or implied.  See the License for the
 *    specific language governing permissions and limitations
 *    under the License.
 * ====================================================================
 * @endcopyright
 */

package org.apache.subversion.javahl;

import java.util.Set;
import java.io.OutputStream;
import java.io.InputStream;
import java.io.File;

import org.apache.subversion.javahl.callback.ReposNotifyCallback;
import org.apache.subversion.javahl.callback.ReposFreezeAction;
import org.apache.subversion.javahl.types.*;

/**
 * This class offers the same commands as the svnadmin commandline
 * client.
 */
public class SVNRepos implements ISVNRepos
{
    /**
     * Load the required native library.
     */
    static
    {
        NativeResources.loadNativeLibrary();
    }

    /**
     * Standard empty contructor, builds just the native peer.
     */
    public SVNRepos()
    {
        cppAddr = ctNative();
    }

    /**
     * Don't call this function!  public for backward compat purposes.
     */
    public long getCppAddr()
    {
        return cppAddr;
    }

    /**
     * Build the native peer
     * @return the adress of the peer
     */
    private native long ctNative();

    /**
     * release the native peer (should not depend on finalize)
     */
    public native void dispose();

    /**
     * release the native peer (should use dispose instead)
     * public for backward compat.  Shouldn't call this directly.
     */
    public native void finalize();

    /**
     * slot for the adress of the native peer. The JNI code is the only user
     * of this member
     */
    protected long cppAddr;

    /**
     * @return Version information about the underlying native libraries.
     */
    public Version getVersion()
    {
        return NativeResources.getVersion();
    }

    /**
     * create a subversion repository.
     * @param path                  the path where the repository will been
     *                              created.
     * @param disableFsyncCommit    disable to fsync at the commit (BDB).
     * @param keepLog               keep the log files (BDB).
     * @param configPath            optional path for user configuration files.
     * @param fstype                the type of the filesystem (BDB or FSFS)
     * @throws ClientException  throw in case of problem
     */
    public native void create(File path, boolean disableFsyncCommit,
                              boolean keepLog, File configPath,
                              String fstype) throws ClientException;

    /**
     * deltify the revisions in the repository
     * @param path              the path to the repository
     * @param start             start revision
     * @param end               end revision
     * @throws ClientException  throw in case of problem
     */
    public native void deltify(File path, Revision start, Revision end)
            throws ClientException;

    public native void dump(File path, OutputStream dataOut,
                            Revision start, Revision end, boolean incremental,
                            boolean useDeltas, ReposNotifyCallback callback)
            throws ClientException;

    /**
     * make a hot copy of the repository
     * @param path              the path to the source repository
     * @param targetPath        the path to the target repository
     * @param cleanLogs         clean the unused log files in the source
     *                          repository
     * @throws ClientException  throw in case of problem
     */
    public native void hotcopy(File path, File targetPath,
                               boolean cleanLogs, boolean incremental)
            throws ClientException;

    public void hotcopy(File path, File targetPath,
                        boolean cleanLogs) throws ClientException
    {
        hotcopy(path, targetPath, cleanLogs, false);
    }

    /**
     * list all logfiles (BDB) in use or not)
     * @param path              the path to the repository
     * @param receiver          interface to receive the logfile names
     * @throws ClientException  throw in case of problem
     */
    public native void listDBLogs(File path, ISVNRepos.MessageReceiver receiver)
            throws ClientException;

    /**
     * list unused logfiles
     * @param path              the path to the repository
     * @param receiver          interface to receive the logfile names
     * @throws ClientException  throw in case of problem
     */
    public native void listUnusedDBLogs(File path, ISVNRepos.MessageReceiver receiver)
            throws ClientException;

    public void load(File path, InputStream dataInput,
                     boolean ignoreUUID, boolean forceUUID,
                     boolean usePreCommitHook, boolean usePostCommitHook,
                     String relativePath, ReposNotifyCallback callback)
            throws ClientException
    {
        load(path, dataInput, Revision.START, Revision.HEAD,
             ignoreUUID, forceUUID, usePreCommitHook, usePostCommitHook,
             relativePath, callback);
    }

    public native void load(File path, InputStream dataInput,
                            Revision start, Revision end,
                            boolean ignoreUUID, boolean forceUUID,
                            boolean usePreCommitHook, boolean usePostCommitHook,
                            String relativePath, ReposNotifyCallback callback)
            throws ClientException;

    /**
     * list all open transactions in a repository
     * @param path              the path to the repository
     * @param receiver          receives one transaction name per call
     * @throws ClientException  throw in case of problem
     */
    public native void lstxns(File path, ISVNRepos.MessageReceiver receiver)
            throws ClientException;

    public native long recover(File path, ReposNotifyCallback callback)
            throws ClientException;

    public native void freeze(ReposFreezeAction action, File... paths)
            throws ClientException;

    /**
     * remove open transaction in a repository
     * @param path              the path to the repository
     * @param transactions      the transactions to be removed
     * @throws ClientException  throw in case of problem
     */
    public native void rmtxns(File path, String[] transactions)
            throws ClientException;

    /**
     * Change the value of the revision property <code>propName</code>
     * to <code>propValue</code>.  By default, does not run
     * pre-/post-revprop-change hook scripts.
     *
     * @param path The path to the repository.
     * @param rev The revision for which to change a property value.
     * @param propName The name of the property to change.
     * @param propValue The new value to set for the property.
     * @param usePreRevPropChangeHook Whether to run the
     * <i>pre-revprop-change</i> hook script.
     * @param usePostRevPropChangeHook Whether to run the
     * <i>post-revprop-change</i> hook script.
     * @throws SubversionException If a problem occurs.
     */
    public native void setRevProp(File path, Revision rev,
                                  String propName, String propValue,
                                  boolean usePreRevPropChangeHook,
                                  boolean usePostRevPropChangeHook)
            throws SubversionException;

    public native void verify(File path, Revision start, Revision end,
                              ReposNotifyCallback callback)
            throws ClientException;

    /**
     * list all locks in the repository
     * @param path              the path to the repository
     * @param depth             the depth to recurse
     * @throws ClientException  throw in case of problem
     */
    public native Set<Lock> lslocks(File path, Depth depth)
            throws ClientException;

    /**
     * remove multiple locks from the repository
     * @param path              the path to the repository
     * @param locks             the name of the locked items
     * @throws ClientException  throw in case of problem
     */
    public native void rmlocks(File path, String[] locks)
            throws ClientException;

    public native void upgrade(File path, ReposNotifyCallback callback);

    public native void pack(File path, ReposNotifyCallback callback);

    public native void cancelOperation()
            throws ClientException;
}