Skip to content

Commit c723d0d

Browse files
author
a-brandt
committed
fixed some sonarlint issues
1 parent 61bbde8 commit c723d0d

27 files changed

+653
-628
lines changed

src/main/java/com/arangodb/BaseArangoDriver.java

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ protected void validateDocumentHandle(String documentHandle) throws ArangoExcept
9595
* @param allowNull
9696
* @throws ArangoException
9797
* @see <a href=
98-
* "http://www.arangodb.com/manuals/current/NamingConventions.html#DatabaseNames">
98+
* "https://docs.arangodb.com/NamingConventions/DatabaseNames.html">
9999
* DatabaseNames documentation</a>
100100
*/
101101
protected void validateDatabaseName(String database, boolean allowNull) throws ArangoException {
@@ -425,9 +425,6 @@ protected <T> T createEntityImpl(HttpResponseEntity res, Class<T> type) throws A
425425
}
426426

427427
protected String createEndpointUrl(String database, Object... paths) throws ArangoException {
428-
429-
// FIXME: Very very foolish implement.
430-
431428
List<String> list = new ArrayList<String>();
432429

433430
if (database != null) {
@@ -443,4 +440,31 @@ protected String createEndpointUrl(String database, Object... paths) throws Aran
443440
return StringUtils.join(false, list);
444441
}
445442

443+
protected String createEndpointUrl(String database, String str, Object... paths) throws ArangoException {
444+
if (paths == null) {
445+
return createEndpointUrl(database, paths);
446+
}
447+
Object[] newPaths = new Object[paths.length + 1];
448+
newPaths[0] = str;
449+
for (int i = 0; i < paths.length; i++) {
450+
newPaths[i + 1] = paths[i];
451+
}
452+
return createEndpointUrl(database, newPaths);
453+
}
454+
455+
protected String createUserEndpointUrl(String database, Object... paths) throws ArangoException {
456+
return createEndpointUrl(database, "/_api/user", paths);
457+
}
458+
459+
protected String createJobEndpointUrl(String database, Object... paths) throws ArangoException {
460+
return createEndpointUrl(database, "/_api/job", paths);
461+
}
462+
463+
protected String createIndexEndpointUrl(String database, Object... paths) throws ArangoException {
464+
return createEndpointUrl(database, "/_api/index", paths);
465+
}
466+
467+
protected String createGharialEndpointUrl(String database, Object... paths) throws ArangoException {
468+
return createEndpointUrl(database, "/_api/gharial", paths);
469+
}
446470
}
Lines changed: 69 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,78 @@
11
package com.arangodb;
22

3-
import com.arangodb.entity.*;
3+
import com.arangodb.entity.ReplicationApplierConfigEntity;
4+
import com.arangodb.entity.ReplicationApplierStateEntity;
5+
import com.arangodb.entity.ReplicationInventoryEntity;
6+
import com.arangodb.entity.ReplicationLoggerConfigEntity;
7+
import com.arangodb.entity.ReplicationLoggerStateEntity;
8+
import com.arangodb.entity.ReplicationSyncEntity;
9+
import com.arangodb.entity.RestrictType;
410
import com.arangodb.impl.BaseDriverInterface;
511
import com.arangodb.util.DumpHandler;
612

713
/**
814
* Created by fbartels on 10/27/14.
915
*/
10-
public interface InternalReplicationDriver extends BaseDriverInterface {
11-
ReplicationInventoryEntity getReplicationInventory(String database, Boolean includeSystem) throws ArangoException;
12-
13-
<T> void getReplicationDump(
14-
String database,
15-
String collectionName,
16-
Long from, Long to, Integer chunkSize, Boolean ticks,
17-
Class<T> clazz, DumpHandler<T> handler) throws ArangoException;
18-
19-
ReplicationSyncEntity syncReplication(
20-
String _database,
21-
String endpoint, String database,
22-
String username, String password,
23-
RestrictType restrictType, String... restrictCollections
24-
) throws ArangoException;
25-
26-
String getReplicationServerId() throws ArangoException;
27-
28-
boolean startReplicationLogger(String database) throws ArangoException;
29-
30-
boolean stopReplicationLogger(String database) throws ArangoException;
31-
32-
ReplicationLoggerConfigEntity getReplicationLoggerConfig(String database) throws ArangoException;
33-
34-
ReplicationLoggerConfigEntity setReplicationLoggerConfig(
35-
String database,
36-
Boolean autoStart,
37-
Boolean logRemoteChanges,
38-
Long maxEvents,
39-
Long maxEventsSize
40-
) throws ArangoException;
41-
42-
ReplicationLoggerStateEntity getReplicationLoggerState(String database) throws ArangoException;
43-
44-
ReplicationApplierConfigEntity getReplicationApplierConfig(String database) throws ArangoException;
45-
46-
ReplicationApplierConfigEntity setReplicationApplierConfig(
47-
String _database,
48-
String endpoint,
49-
String database,
50-
String username,
51-
String password,
52-
Integer maxConnectRetries,
53-
Integer connectTimeout,
54-
Integer requestTimeout,
55-
Integer chunkSize,
56-
Boolean autoStart,
57-
Boolean adaptivePolling
58-
) throws ArangoException;
59-
60-
ReplicationApplierConfigEntity setReplicationApplierConfig(
61-
String database,
62-
ReplicationApplierConfigEntity param
63-
) throws ArangoException;
64-
65-
ReplicationApplierStateEntity startReplicationApplier(String database, Long from) throws ArangoException;
66-
67-
ReplicationApplierStateEntity stopReplicationApplier(String database) throws ArangoException;
68-
69-
ReplicationApplierStateEntity getReplicationApplierState(String database) throws ArangoException;
16+
public interface InternalReplicationDriver extends BaseDriverInterface {
17+
ReplicationInventoryEntity getReplicationInventory(String database, Boolean includeSystem) throws ArangoException;
18+
19+
<T> void getReplicationDump(
20+
String database,
21+
String collectionName,
22+
Long from,
23+
Long to,
24+
Integer chunkSize,
25+
Boolean ticks,
26+
Class<T> clazz,
27+
DumpHandler<T> handler) throws ArangoException;
28+
29+
ReplicationSyncEntity syncReplication(
30+
String localDatabase,
31+
String endpoint,
32+
String database,
33+
String username,
34+
String password,
35+
RestrictType restrictType,
36+
String... restrictCollections) throws ArangoException;
37+
38+
String getReplicationServerId() throws ArangoException;
39+
40+
boolean startReplicationLogger(String database) throws ArangoException;
41+
42+
boolean stopReplicationLogger(String database) throws ArangoException;
43+
44+
ReplicationLoggerConfigEntity getReplicationLoggerConfig(String database) throws ArangoException;
45+
46+
ReplicationLoggerConfigEntity setReplicationLoggerConfig(
47+
String database,
48+
Boolean autoStart,
49+
Boolean logRemoteChanges,
50+
Long maxEvents,
51+
Long maxEventsSize) throws ArangoException;
52+
53+
ReplicationLoggerStateEntity getReplicationLoggerState(String database) throws ArangoException;
54+
55+
ReplicationApplierConfigEntity getReplicationApplierConfig(String database) throws ArangoException;
56+
57+
ReplicationApplierConfigEntity setReplicationApplierConfig(
58+
String localDatabase,
59+
String endpoint,
60+
String database,
61+
String username,
62+
String password,
63+
Integer maxConnectRetries,
64+
Integer connectTimeout,
65+
Integer requestTimeout,
66+
Integer chunkSize,
67+
Boolean autoStart,
68+
Boolean adaptivePolling) throws ArangoException;
69+
70+
ReplicationApplierConfigEntity setReplicationApplierConfig(String database, ReplicationApplierConfigEntity param)
71+
throws ArangoException;
72+
73+
ReplicationApplierStateEntity startReplicationApplier(String database, Long from) throws ArangoException;
74+
75+
ReplicationApplierStateEntity stopReplicationApplier(String database) throws ArangoException;
76+
77+
ReplicationApplierStateEntity getReplicationApplierState(String database) throws ArangoException;
7078
}
Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.arangodb.entity;
22

3+
import java.util.ArrayList;
34
import java.util.List;
45

56
/**
@@ -8,14 +9,17 @@
89
*/
910
public class GraphGetCollectionsResultEntity extends BaseEntity {
1011

11-
List<String> collections;
12+
List<String> collections;
1213

13-
public List<String> getCollections() {
14-
return collections;
15-
}
14+
public List<String> getCollections() {
15+
if (collections == null) {
16+
collections = new ArrayList<String>();
17+
}
18+
return collections;
19+
}
1620

17-
public void setCollections(List<String> collections) {
18-
this.collections = collections;
19-
}
21+
public void setCollections(List<String> collections) {
22+
this.collections = collections;
23+
}
2024

2125
}

src/main/java/com/arangodb/http/InvocationHandlerImpl.java

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,29 @@
88
/**
99
* Created by fbartels on 10/27/14.
1010
*/
11-
public class InvocationHandlerImpl implements InvocationHandler {
12-
private BaseDriverInterface testImpl;
11+
public class InvocationHandlerImpl implements InvocationHandler {
12+
private BaseDriverInterface testImpl;
1313

14-
public InvocationHandlerImpl(BaseDriverInterface impl) {
15-
this.testImpl = impl;
16-
}
14+
public InvocationHandlerImpl(BaseDriverInterface impl) {
15+
this.testImpl = impl;
16+
}
1717

18-
@Override
19-
public Object invoke(Object proxy, Method method, Object[] args)
20-
throws Throwable {
21-
if(Object.class == method.getDeclaringClass()) {
22-
String name = method.getName();
23-
if("equals".equals(name)) {
24-
return proxy == args[0];
25-
} else if("hashCode".equals(name)) {
26-
return System.identityHashCode(proxy);
27-
} else if("toString".equals(name)) {
28-
return proxy.getClass().getName() + "@" +
29-
Integer.toHexString(System.identityHashCode(proxy)) +
30-
", with InvocationHandler " + this;
31-
} else {
32-
throw new IllegalStateException(String.valueOf(method));
33-
}
34-
}
35-
testImpl.getHttpManager().setCurrentObject(
36-
new InvocationObject(method, testImpl, args)
37-
);
38-
return method.invoke(testImpl, args);
39-
}
18+
@Override
19+
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
20+
if (Object.class == method.getDeclaringClass()) {
21+
String name = method.getName();
22+
if ("equals".equals(name)) {
23+
return proxy == args[0];
24+
} else if ("hashCode".equals(name)) {
25+
return System.identityHashCode(proxy);
26+
} else if ("toString".equals(name)) {
27+
return proxy.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(proxy))
28+
+ ", with InvocationHandler " + this;
29+
} else {
30+
throw new IllegalStateException(String.valueOf(method));
31+
}
32+
}
33+
testImpl.getHttpManager().setCurrentObject(new InvocationObject(method, testImpl, args));
34+
return method.invoke(testImpl, args);
35+
}
4036
}

src/main/java/com/arangodb/impl/AnnotationHandler.java

Lines changed: 42 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ public class AnnotationHandler {
1818
private static Logger logger = LoggerFactory.getLogger(AnnotationHandler.class);
1919

2020
static class DocumentAttributes {
21-
public Field rev;
22-
public Field id;
23-
public Field key;
24-
public Field from;
25-
public Field to;
21+
public Field rev; // NOSONAR
22+
public Field id; // NOSONAR
23+
public Field key; // NOSONAR
24+
public Field from; // NOSONAR
25+
public Field to; // NOSONAR
2626
}
2727

2828
static Map<Class<?>, DocumentAttributes> class2DocumentAttributes;
@@ -32,56 +32,57 @@ static class DocumentAttributes {
3232
}
3333

3434
public AnnotationHandler() {
35+
// nothing todo here
3536
}
3637

3738
@SuppressWarnings({ "unchecked", "rawtypes" })
3839
public synchronized void updateDocumentAttributes(Object o, long rev, String id, String key) {
39-
if (o == null) {
40-
41-
} else if (o instanceof java.util.Map) {
42-
java.util.Map m = (java.util.Map) o;
43-
m.put(BaseDocument.ID, id);
44-
m.put(BaseDocument.KEY, key);
45-
m.put(BaseDocument.REV, rev);
46-
} else {
47-
DocumentAttributes documentAttributes = getDocumentAttributes(o);
48-
setAttribute(documentAttributes.id, o, id);
49-
setAttribute(documentAttributes.key, o, key);
50-
setAttribute(documentAttributes.rev, o, rev);
40+
if (o != null) {
41+
if (o instanceof java.util.Map) {
42+
java.util.Map m = (java.util.Map) o;
43+
m.put(BaseDocument.ID, id);
44+
m.put(BaseDocument.KEY, key);
45+
m.put(BaseDocument.REV, rev);
46+
} else {
47+
DocumentAttributes documentAttributes = getDocumentAttributes(o);
48+
setAttribute(documentAttributes.id, o, id);
49+
setAttribute(documentAttributes.key, o, key);
50+
setAttribute(documentAttributes.rev, o, rev);
51+
}
5152
}
5253
}
5354

5455
@SuppressWarnings({ "unchecked", "rawtypes" })
5556
public synchronized void updateDocumentRev(Object o, long rev) {
56-
if (o == null) {
57-
58-
} else if (o instanceof java.util.Map) {
59-
java.util.Map m = (java.util.Map) o;
60-
m.put(BaseDocument.REV, rev);
61-
} else {
62-
DocumentAttributes documentAttributes = getDocumentAttributes(o);
63-
setAttribute(documentAttributes.rev, o, rev);
57+
if (o != null) {
58+
if (o instanceof java.util.Map) {
59+
java.util.Map m = (java.util.Map) o;
60+
m.put(BaseDocument.REV, rev);
61+
} else {
62+
DocumentAttributes documentAttributes = getDocumentAttributes(o);
63+
setAttribute(documentAttributes.rev, o, rev);
64+
}
6465
}
6566
}
6667

6768
@SuppressWarnings({ "unchecked", "rawtypes" })
6869
public synchronized void updateEdgeAttributes(Object o, long rev, String id, String key, String from, String to) {
69-
if (o == null) {
70-
71-
} else if (o instanceof java.util.Map) {
72-
java.util.Map m = (java.util.Map) o;
73-
m.put(BaseDocument.ID, id);
74-
m.put(BaseDocument.KEY, key);
75-
m.put(BaseDocument.REV, rev);
76-
m.put(BaseDocument.FROM, from);
77-
m.put(BaseDocument.TO, to);
78-
} else {
79-
DocumentAttributes documentAttributes = getDocumentAttributes(o);
80-
setAttribute(documentAttributes.id, o, id);
81-
setAttribute(documentAttributes.key, o, key);
82-
setAttribute(documentAttributes.rev, o, rev);
83-
setAttribute(documentAttributes.from, o, from);
84-
setAttribute(documentAttributes.to, o, to);
70+
if (o != null) {
71+
if (o instanceof java.util.Map) {
72+
java.util.Map m = (java.util.Map) o;
73+
m.put(BaseDocument.ID, id);
74+
m.put(BaseDocument.KEY, key);
75+
m.put(BaseDocument.REV, rev);
76+
m.put(BaseDocument.FROM, from);
77+
m.put(BaseDocument.TO, to);
78+
} else {
79+
DocumentAttributes documentAttributes = getDocumentAttributes(o);
80+
setAttribute(documentAttributes.id, o, id);
81+
setAttribute(documentAttributes.key, o, key);
82+
setAttribute(documentAttributes.rev, o, rev);
83+
setAttribute(documentAttributes.from, o, from);
84+
setAttribute(documentAttributes.to, o, to);
85+
}
8586
}
8687
}
8788

0 commit comments

Comments
 (0)