Skip to content

Commit be0aa2e

Browse files
author
Vladimir Kotal
committed
move DTO logic near the controller
1 parent 1ebe0a8 commit be0aa2e

File tree

3 files changed

+29
-31
lines changed

3 files changed

+29
-31
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/history/RepositoryInfo.java

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import org.opengrok.indexer.configuration.Project;
3535
import org.opengrok.indexer.configuration.RuntimeEnvironment;
3636
import org.opengrok.indexer.logger.LoggerFactory;
37-
import org.opengrok.indexer.util.BeanBuilder;
3837
import org.opengrok.indexer.util.ClassUtil;
3938
import org.opengrok.indexer.util.PathUtils;
4039

@@ -88,30 +87,6 @@ public RepositoryInfo(RepositoryInfo orig) {
8887
this.currentVersion = orig.currentVersion;
8988
}
9089

91-
/**
92-
* @return Data Transfer Object for RepositoryInfo.
93-
* It will have the same members as in RepositoryInfo except datePatterns.
94-
*/
95-
public Object getRepositoryInfoData() {
96-
return createRepositoryInfoTO();
97-
}
98-
99-
private Object createRepositoryInfoTO() {
100-
BeanBuilder builder = new BeanBuilder();
101-
102-
builder.add("type", String.class, this.type)
103-
.add("directoryNameRelative", String.class, this.directoryNameRelative)
104-
.add("remote", boolean.class, this.remote)
105-
.add("parent", String.class, this.parent)
106-
.add("branch", String.class, this.branch)
107-
.add("currentVersion", String.class, this.currentVersion)
108-
.add("working", Boolean.class, this.working == null ? false : this.working)
109-
.add("handleRenamedFiles", boolean.class, this.handleRenamedFiles)
110-
.add("historyEnabled", boolean.class, this.historyEnabled);
111-
112-
return builder.build();
113-
}
114-
11590
/**
11691
* @return true if the repository handles renamed files, false otherwise.
11792
*/

opengrok-web/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,6 @@ Portions Copyright (c) 2018, Chris Fraire <[email protected]>.
148148
<artifactId>org.suigeneris.jrcs.diff</artifactId>
149149
<version>0.4.2</version>
150150
</dependency>
151-
<dependency>
152-
<groupId>cglib</groupId>
153-
<artifactId>cglib</artifactId>
154-
<version>3.2.4</version>
155-
</dependency>
156151
</dependencies>
157152

158153
<build>

opengrok-web/src/main/java/org/opengrok/web/api/v1/controller/RepositoriesController.java

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import org.opengrok.indexer.configuration.RuntimeEnvironment;
2626
import org.opengrok.indexer.history.RepositoryInfo;
27+
import org.opengrok.indexer.util.BeanBuilder;
2728
import org.opengrok.indexer.util.ClassUtil;
2829

2930
import javax.ws.rs.GET;
@@ -41,10 +42,37 @@ public class RepositoriesController {
4142

4243
private RuntimeEnvironment env = RuntimeEnvironment.getInstance();
4344

45+
static class RepositoryInfoDTO {
46+
// Contains all members of RepositoryInfo except datePatterns
47+
String directoryNameRelative;
48+
Boolean working;
49+
String type;
50+
boolean remote;
51+
String parent;
52+
String branch;
53+
String currentVersion;
54+
}
55+
56+
private Object createRepositoryInfoTO(RepositoryInfo ri) {
57+
BeanBuilder builder = new BeanBuilder();
58+
builder.add("type", String.class, ri.getType())
59+
.add("directoryNameRelative", String.class, ri.getDirectoryNameRelative())
60+
.add("remote", boolean.class, ri.isRemote())
61+
.add("parent", String.class, ri.getParent())
62+
.add("branch", String.class, ri.getBranch())
63+
.add("currentVersion", String.class, ri.getCurrentVersion())
64+
.add("working", Boolean.class, ri.isWorking())
65+
.add("handleRenamedFiles", boolean.class, ri.isHandleRenamedFiles())
66+
.add("historyEnabled", boolean.class, ri.isHistoryEnabled());
67+
68+
return builder.build();
69+
}
70+
71+
4472
private Object getRepositoryInfoData(String repositoryPath) {
4573
for (RepositoryInfo ri : env.getRepositories()) {
4674
if (ri.getDirectoryNameRelative().equals(repositoryPath)) {
47-
return ri.getRepositoryInfoData();
75+
return createRepositoryInfoTO(ri);
4876
}
4977
}
5078

0 commit comments

Comments
 (0)