File tree Expand file tree Collapse file tree 3 files changed +50
-14
lines changed
opengrok-indexer/src/main/java/org/opengrok/indexer
opengrok-web/src/main/java/org/opengrok/web/api/v1/controller Expand file tree Collapse file tree 3 files changed +50
-14
lines changed Original file line number Diff line number Diff line change 35
35
import org .opengrok .indexer .configuration .RuntimeEnvironment ;
36
36
import org .opengrok .indexer .logger .LoggerFactory ;
37
37
import org .opengrok .indexer .util .ClassUtil ;
38
+ import org .opengrok .indexer .util .DTOElement ;
38
39
import org .opengrok .indexer .util .PathUtils ;
39
40
40
41
/**
@@ -55,18 +56,26 @@ public class RepositoryInfo implements Serializable {
55
56
56
57
private static final long serialVersionUID = 3L ;
57
58
59
+ @ DTOElement
58
60
private String directoryNameRelative ;
59
61
private transient String directoryNameCanonical ;
60
62
63
+ @ DTOElement
61
64
protected Boolean working ;
65
+ @ DTOElement
62
66
protected String type ; // type of the repository, should be unique
67
+ @ DTOElement
63
68
protected boolean remote ;
64
69
protected String [] datePatterns = new String [0 ];
70
+ @ DTOElement
65
71
protected String parent ;
72
+ @ DTOElement
66
73
protected String branch ;
74
+ @ DTOElement
67
75
protected String currentVersion ;
68
-
76
+ @ DTOElement
69
77
private boolean handleRenamedFiles ;
78
+ @ DTOElement
70
79
private boolean historyEnabled ;
71
80
72
81
/**
Original file line number Diff line number Diff line change
1
+ /*
2
+ * CDDL HEADER START
3
+ *
4
+ * The contents of this file are subject to the terms of the
5
+ * Common Development and Distribution License (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ *
8
+ * See LICENSE.txt included in this distribution for the specific
9
+ * language governing permissions and limitations under the License.
10
+ *
11
+ * When distributing Covered Code, include this CDDL HEADER in each
12
+ * file and include the License file at LICENSE.txt.
13
+ * If applicable, add the following below this CDDL HEADER, with the
14
+ * fields enclosed by brackets "[]" replaced with your own identifying
15
+ * information: Portions Copyright [yyyy] [name of copyright owner]
16
+ *
17
+ * CDDL HEADER END
18
+ */
19
+
20
+ /*
21
+ * Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
22
+ */
23
+
24
+ package org .opengrok .indexer .util ;
25
+
26
+ import java .lang .annotation .ElementType ;
27
+ import java .lang .annotation .Retention ;
28
+ import java .lang .annotation .RetentionPolicy ;
29
+ import java .lang .annotation .Target ;
30
+
31
+ @ Retention (RetentionPolicy .RUNTIME )
32
+ @ Target (ElementType .FIELD )
33
+ public @interface DTOElement {
34
+ String key () default "" ;
35
+ }
Original file line number Diff line number Diff line change 27
27
import org .opengrok .indexer .configuration .RuntimeEnvironment ;
28
28
import org .opengrok .indexer .history .RepositoryInfo ;
29
29
import org .opengrok .indexer .util .ClassUtil ;
30
+ import org .opengrok .indexer .util .DTOElement ;
30
31
31
32
import javax .ws .rs .GET ;
32
33
import javax .ws .rs .Path ;
@@ -44,22 +45,13 @@ public class RepositoriesController {
44
45
45
46
private RuntimeEnvironment env = RuntimeEnvironment .getInstance ();
46
47
47
- static class RepositoryInfoDTO {
48
- // Contains all members of RepositoryInfo except datePatterns
49
- String directoryNameRelative ;
50
- Boolean working ;
51
- String type ;
52
- boolean remote ;
53
- String parent ;
54
- String branch ;
55
- String currentVersion ;
56
- }
57
-
58
48
private Object createRepositoryInfoTO (RepositoryInfo ri ) {
59
49
// ModelMapper assumes getters/setters so use BeanGenerator to provide them.
60
50
BeanGenerator beanGenerator = new BeanGenerator ();
61
- for (Field field : RepositoryInfoDTO .class .getDeclaredFields ()) {
62
- beanGenerator .addProperty (field .getName (), field .getType ());
51
+ for (Field field : RepositoryInfo .class .getDeclaredFields ()) {
52
+ if (field .isAnnotationPresent (DTOElement .class )) {
53
+ beanGenerator .addProperty (field .getName (), field .getType ());
54
+ }
63
55
}
64
56
Object bean = beanGenerator .create ();
65
57
You can’t perform that action at this time.
0 commit comments