30
30
import java .util .Objects ;
31
31
import java .util .logging .Level ;
32
32
import java .util .logging .Logger ;
33
+
34
+ import net .sf .cglib .beans .BeanGenerator ;
33
35
import org .opengrok .indexer .configuration .Project ;
34
36
import org .opengrok .indexer .configuration .RuntimeEnvironment ;
35
37
import org .opengrok .indexer .logger .LoggerFactory ;
@@ -68,93 +70,6 @@ public class RepositoryInfo implements Serializable {
68
70
private boolean handleRenamedFiles ;
69
71
private boolean historyEnabled ;
70
72
71
- public static class RepositoryInfoTO implements Serializable {
72
- private static final long serialVersionUID = -1 ;
73
-
74
- // same members as in RepositoryInfo except datePatterns
75
- private String directoryNameRelative ;
76
- private boolean working ;
77
- private String type ;
78
- private boolean remote ;
79
- private String parent ;
80
- private String branch ;
81
- private String currentVersion ;
82
- private boolean handleRenamedFiles ;
83
- private boolean historyEnabled ;
84
-
85
- public String getDirectoryNameRelative () {
86
- return directoryNameRelative ;
87
- }
88
-
89
- public void setDirectoryNameRelative (String directoryNameRelative ) {
90
- this .directoryNameRelative = directoryNameRelative ;
91
- }
92
-
93
- public boolean isWorking () {
94
- return working ;
95
- }
96
-
97
- public void setWorking (boolean working ) {
98
- this .working = working ;
99
- }
100
-
101
- public String getType () {
102
- return type ;
103
- }
104
-
105
- public void setType (String type ) {
106
- this .type = type ;
107
- }
108
-
109
- public boolean isRemote () {
110
- return remote ;
111
- }
112
-
113
- public void setRemote (boolean remote ) {
114
- this .remote = remote ;
115
- }
116
-
117
- public String getParent () {
118
- return parent ;
119
- }
120
-
121
- public void setParent (String parent ) {
122
- this .parent = parent ;
123
- }
124
-
125
- public String getBranch () {
126
- return branch ;
127
- }
128
-
129
- public void setBranch (String branch ) {
130
- this .branch = branch ;
131
- }
132
-
133
- public String getCurrentVersion () {
134
- return currentVersion ;
135
- }
136
-
137
- public void setCurrentVersion (String currentVersion ) {
138
- this .currentVersion = currentVersion ;
139
- }
140
-
141
- public boolean isHandleRenamedFiles () {
142
- return handleRenamedFiles ;
143
- }
144
-
145
- public void setHandleRenamedFiles (boolean handleRenamedFiles ) {
146
- this .handleRenamedFiles = handleRenamedFiles ;
147
- }
148
-
149
- public boolean isHistoryEnabled () {
150
- return historyEnabled ;
151
- }
152
-
153
- public void setHistoryEnabled (boolean historyEnabled ) {
154
- this .historyEnabled = historyEnabled ;
155
- }
156
- }
157
-
158
73
/**
159
74
* Empty constructor to support serialization.
160
75
*/
@@ -174,31 +89,42 @@ public RepositoryInfo(RepositoryInfo orig) {
174
89
}
175
90
176
91
/**
177
- * @return Data Transfer Object for RepositoryInfo
92
+ * @return Data Transfer Object for RepositoryInfo.
93
+ * It will have the same members as in RepositoryInfo except datePatterns.
178
94
*/
179
- public RepositoryInfoTO getRepositoryInfoData () {
95
+ public Object getRepositoryInfoData () {
180
96
return createRepositoryInfoTO ();
181
97
}
182
98
183
- private RepositoryInfoTO createRepositoryInfoTO () {
184
- RepositoryInfoTO ri = new RepositoryInfoTO ();
99
+ private Object createRepositoryInfoTO () {
100
+ BeanGenerator beanGenerator = new BeanGenerator ();
101
+ beanGenerator .addProperty ("type" , String .class );
102
+ beanGenerator .addProperty ("directoryNameRelative" , String .class );
103
+ beanGenerator .addProperty ("remote" , boolean .class );
104
+ beanGenerator .addProperty ("parent" , String .class );
105
+ beanGenerator .addProperty ("branch" , String .class );
106
+ beanGenerator .addProperty ("currentVersion" , String .class );
107
+ beanGenerator .addProperty ("working" , Boolean .class );
108
+ beanGenerator .addProperty ("handleRenamedFiles" , boolean .class );
109
+ beanGenerator .addProperty ("historyEnabled" , boolean .class );
185
110
186
- if (this .working == null ) {
187
- ri .working = false ;
188
- } else {
189
- ri .working = this .working ;
111
+ Object myBean = beanGenerator .create ();
112
+ try {
113
+ ClassUtil .setFieldValue (myBean , "type" , this .type );
114
+ ClassUtil .setFieldValue (myBean , "working" ,
115
+ this .working == null ? false : this .working );
116
+ ClassUtil .setFieldValue (myBean , "directoryNameRelative" , this .directoryNameRelative );
117
+ ClassUtil .setFieldValue (myBean , "remote" , this .remote );
118
+ ClassUtil .setFieldValue (myBean , "parent" , this .parent );
119
+ ClassUtil .setFieldValue (myBean , "branch" , this .branch );
120
+ ClassUtil .setFieldValue (myBean , "currentVersion" , this .currentVersion );
121
+ ClassUtil .setFieldValue (myBean , "handleRenamedFiles" , this .handleRenamedFiles );
122
+ ClassUtil .setFieldValue (myBean , "historyEnabled" , this .historyEnabled );
123
+ } catch (IOException e ) {
124
+ LOGGER .log (Level .WARNING , "cannot generate RepositoryInfo bean" , e );
125
+ return null ;
190
126
}
191
-
192
- ri .directoryNameRelative = this .directoryNameRelative ;
193
- ri .type = this .type ;
194
- ri .remote = this .remote ;
195
- ri .parent = this .parent ;
196
- ri .branch = this .branch ;
197
- ri .currentVersion = this .currentVersion ;
198
- ri .handleRenamedFiles = this .handleRenamedFiles ;
199
- ri .historyEnabled = this .historyEnabled ;
200
-
201
- return ri ;
127
+ return myBean ;
202
128
}
203
129
204
130
/**
0 commit comments