Skip to content

Commit

Permalink
[#26] Start ISVNManager implementation
Browse files Browse the repository at this point in the history
* reuse `CallWatch` and others
  • Loading branch information
ruspl-afed authored and eparovyshnaya committed Feb 16, 2024
1 parent 62f4e6c commit 3afc8cf
Show file tree
Hide file tree
Showing 8 changed files with 302 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright (c) 2023, 2024 ArSysOp
*
* Licensed 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.
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* ArSysOp - initial API and implementation
*/

package ru.arsysop.svn.connector.internal.adapt.jhlsv;

import java.util.HashMap;
import java.util.Map;

import org.apache.subversion.javahl.ReposNotifyInformation;
import org.eclipse.team.svn.core.connector.SVNRepositoryNotification;
import org.eclipse.team.svn.core.connector.SVNRepositoryNotification.NodeAction;

import ru.arsysop.svn.connector.internal.adapt.SvnTypeMap;

public final class NodeActionAdapter
extends SvnTypeMap<ReposNotifyInformation.NodeAction, SVNRepositoryNotification.NodeAction> {

public NodeActionAdapter(ReposNotifyInformation.NodeAction source) {
super(source);
}

@Override
protected Map<ReposNotifyInformation.NodeAction, SVNRepositoryNotification.NodeAction> fill() {
Map<ReposNotifyInformation.NodeAction, SVNRepositoryNotification.NodeAction> map = new HashMap<>();
map.put(ReposNotifyInformation.NodeAction.change, SVNRepositoryNotification.NodeAction.CHANGE);
map.put(ReposNotifyInformation.NodeAction.add, SVNRepositoryNotification.NodeAction.ADD);
map.put(ReposNotifyInformation.NodeAction.deleted, SVNRepositoryNotification.NodeAction.DELETE);
map.put(ReposNotifyInformation.NodeAction.replace, SVNRepositoryNotification.NodeAction.REPLACE);
return map;
}

@Override
protected SVNRepositoryNotification.NodeAction defaults() {
return NodeAction.UNKNOWN;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Copyright (c) 2023, 2024 ArSysOp
*
* Licensed 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.
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* ArSysOp - initial API and implementation
*/

package ru.arsysop.svn.connector.internal.adapt.jhlsv;

import java.util.LinkedHashMap;
import java.util.Map;

import org.apache.subversion.javahl.ReposNotifyInformation;
import org.apache.subversion.javahl.ReposNotifyInformation.Action;
import org.eclipse.team.svn.core.connector.SVNRepositoryNotification;

import ru.arsysop.svn.connector.internal.adapt.SvnTypeMap;

final class ReposNotifyInformationActionAdapter
extends SvnTypeMap<ReposNotifyInformation.Action, SVNRepositoryNotification.Action> {

ReposNotifyInformationActionAdapter(ReposNotifyInformation.Action source) {
super(source);
}

@Override
protected Map<ReposNotifyInformation.Action, SVNRepositoryNotification.Action> fill() {
Map<Action, SVNRepositoryNotification.Action> map = new LinkedHashMap<>();
map.put(Action.warning, SVNRepositoryNotification.Action.WARNING);
map.put(Action.dump_rev_end, SVNRepositoryNotification.Action.DUMP_REV_END);
map.put(Action.verify_rev_end, SVNRepositoryNotification.Action.VERIFY_REV_END);
map.put(Action.pack_shard_start, SVNRepositoryNotification.Action.PACK_SHARD_START);
map.put(Action.pack_shard_end, SVNRepositoryNotification.Action.PACK_SHARD_END);
map.put(Action.pack_shard_start_revprop, SVNRepositoryNotification.Action.PACK_SHARD_START_REVPROP);
map.put(Action.pack_shard_end_revprop, SVNRepositoryNotification.Action.PACK_SHARD_END_REVPROP);
map.put(Action.load_txn_start, SVNRepositoryNotification.Action.LOAD_TXN_START);
map.put(Action.load_txn_committed, SVNRepositoryNotification.Action.LOAD_TXN_COMMITTED);
map.put(Action.load_node_start, SVNRepositoryNotification.Action.LOAD_NODE_START);
map.put(Action.load_node_done, SVNRepositoryNotification.Action.LOAD_NODE_END);
map.put(Action.load_copied_node, SVNRepositoryNotification.Action.LOAD_COPIED_NODE);
map.put(Action.load_normalized_mergeinfo, SVNRepositoryNotification.Action.LOAD_NORMALIZED_MERGEINFO);
map.put(Action.mutex_acquired, SVNRepositoryNotification.Action.MUTEX_ACQUIRED);
map.put(Action.recover_start, SVNRepositoryNotification.Action.RECOVER_START);
map.put(Action.upgrade_start, SVNRepositoryNotification.Action.UPGRADE_START);
map.put(Action.load_skipped_rev, SVNRepositoryNotification.Action.LOAD_SKIPPED_REV);
map.put(Action.verify_rev_structure, SVNRepositoryNotification.Action.VERIFY_REV_STRUCTURE);
return map;
}

@Override
protected SVNRepositoryNotification.Action defaults() {
return SVNRepositoryNotification.Action.UNKNOWN;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2023, 2024 ArSysOp
*
* Licensed 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.
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* ArSysOp - initial API and implementation
*/

package ru.arsysop.svn.connector.internal.adapt.jhlsv;

import org.apache.subversion.javahl.ReposNotifyInformation;
import org.eclipse.team.svn.core.connector.SVNRepositoryNotification;

import ru.arsysop.svn.connector.internal.adapt.SvnTypeConstructor;

public final class ReposNotifyInformationAdapter
extends SvnTypeConstructor<ReposNotifyInformation, SVNRepositoryNotification> {

public ReposNotifyInformationAdapter(ReposNotifyInformation source) {
super(source);
}

@Override
public SVNRepositoryNotification adapt() {
return new SVNRepositoryNotification(//
source.getPath(), //
new NodeActionAdapter(source.getNodeAction()).adapt(),
new ReposNotifyInformationActionAdapter(source.getAction()).adapt(), //
source.getRevision(), source.getWarning(), //
source.getShard(), //
source.getNewRevision(), //
source.getOldRevision());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,18 @@

package ru.arsysop.svn.connector.internal.adapt.svjhl;

import java.util.Objects;

import org.eclipse.team.svn.core.connector.ISVNNotificationCallback;

import ru.arsysop.svn.connector.internal.adapt.jhlsv.ClientNotifyInformationAdapter;

public final class ClientNotifyCallbackAdapter implements org.apache.subversion.javahl.callback.ClientNotifyCallback {
public final class AdaptClientNotifyCallback implements org.apache.subversion.javahl.callback.ClientNotifyCallback {

private final ISVNNotificationCallback callback;

public ClientNotifyCallbackAdapter(ISVNNotificationCallback notify) {
callback = notify;
public AdaptClientNotifyCallback(ISVNNotificationCallback notify) {
callback = Objects.requireNonNull(notify);
}

public ISVNNotificationCallback callback() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (c) 2023, 2024 ArSysOp
*
* Licensed 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.
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* ArSysOp - initial API and implementation
*/

package ru.arsysop.svn.connector.internal.adapt.svjhl;

import java.util.Objects;

import org.apache.subversion.javahl.ReposNotifyInformation;
import org.eclipse.team.svn.core.connector.ISVNRepositoryNotificationCallback;

import ru.arsysop.svn.connector.internal.adapt.jhlsv.ReposNotifyInformationAdapter;

public final class AdaptReposNotifyCallback implements org.apache.subversion.javahl.callback.ReposNotifyCallback {

private final ISVNRepositoryNotificationCallback callback;

public AdaptReposNotifyCallback(ISVNRepositoryNotificationCallback notify) {
callback = Objects.requireNonNull(notify);
}

public ISVNRepositoryNotificationCallback callback() {
return callback;
}

@Override
public void onNotify(ReposNotifyInformation info) {
callback.notify(new ReposNotifyInformationAdapter(info).adapt());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@

import ru.arsysop.svn.connector.internal.adapt.jhlsv.LockNullableAdapter;
import ru.arsysop.svn.connector.internal.adapt.jhlsv.NodeKindAdapter;
import ru.arsysop.svn.connector.internal.adapt.svjhl.ClientNotifyCallbackAdapter;
import ru.arsysop.svn.connector.internal.adapt.svjhl.AdaptClientNotifyCallback;
import ru.arsysop.svn.connector.internal.adapt.svjhl.DepthAdapter;
import ru.arsysop.svn.connector.internal.adapt.svjhl.InfoCallbackAdapter;
import ru.arsysop.svn.connector.internal.adapt.svjhl.InheritedCallbackAdapter;
Expand All @@ -82,13 +82,13 @@ final class SvnKit1_10Connector implements ISVNConnector {
//FIXME: AF: not sure why do we need this
private final List<ISVNConfigurationEventHandler> handlers = new ArrayList<>();

public SvnKit1_10Connector(String name) {
SvnKit1_10Connector(String name) {
SVNFileUtil.setSleepForTimestamp(false);// not time to relax
//FIXME: AF: check if we can remove "trilead" from target
System.setProperty("svnkit.ssh.client", "apache"); //$NON-NLS-1$ //$NON-NLS-2$
watch = new CallWatch(name);
client = SVNClientImpl.newInstance();
client.notification2(new ClientNotifyCallbackAdapter(watch.notifications));
client.notification2(new AdaptClientNotifyCallback(watch.notifications));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
public final class SvnKit1_10ConnectorFactory implements ISVNConnectorFactory {

public ISVNConnector createConnector() {
return new SvnKit1_10Connector(getName());
return new SvnKit1_10Connector(String.format("SVNKit %s Connector", Version.getShortVersionString()));
}

public ISVNManager createManager() {
return new SvnKit1_10Manager();
return new SvnKit1_10Manager(String.format("SVNKit %s Manager", Version.getShortVersionString()));
}

public String getName() {
Expand Down
Loading

0 comments on commit 3afc8cf

Please sign in to comment.