This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
AbstractPushMojo.java
222 lines (194 loc) · 6.69 KB
/
AbstractPushMojo.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
/*
* Copyright 2012, Red Hat, Inc. and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.zanata.maven;
import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableList;
import org.apache.commons.lang.StringUtils;
import org.zanata.client.commands.PushPullCommand;
import org.zanata.client.commands.PushPullType;
import org.zanata.client.commands.push.PushCommand;
import org.zanata.client.commands.push.PushOptions;
import org.zanata.client.commands.push.RawPushCommand;
/**
* @author Sean Flanigan <a
* href="mailto:sflaniga@redhat.com">sflaniga@redhat.com</a>
*
*/
public abstract class AbstractPushMojo extends
AbstractPushPullMojo<PushOptions> implements PushOptions {
/**
* Language of source documents
*
* @parameter expression="${zanata.sourceLang}" default-value="en-US"
*/
private String sourceLang = "en-US";
@Override
public PushPullCommand<PushOptions> initCommand() {
if (PROJECT_TYPE_FILE.equalsIgnoreCase(getProjectType())) {
return new RawPushCommand(this);
} else {
return new PushCommand(this);
}
}
/**
* Push translations from local files to the server (merge or import: see
* mergeType). This option is deprecated, replaced by pushType.
*
* @parameter expression="${zanata.pushTrans}"
*/
@Deprecated
private String pushTrans;
/**
* Type of push to perform on the server: "source" pushes source documents
* only. "trans" pushes translation documents only. "both" pushes both
* source and translation documents.
*
* @parameter expression="${zanata.pushType}" default-value="source"
*/
private String pushType = "source";
/**
* Whether the server should copy latest translations from equivalent
* messages/documents in the database
*
* @parameter expression="${zanata.copyTrans}" default-value="true"
*/
private boolean copyTrans;
/**
* Merge type: "auto" (default) or "import" (DANGER!).
*
* @parameter expression="${zanata.merge}" default-value="auto"
*/
private String merge = "auto";
/**
* Add default excludes (.svn, .git, etc) to the exclude filters.
*
* @parameter expression="${zanata.defaultExcludes}" default-value="true"
*/
private boolean defaultExcludes = true;
/**
* Maximum size, in bytes, of document chunks to transmit when using project
* type 'file'. Documents smaller than this size will be transmitted in a
* single request, larger documents will be sent over multiple requests.
*
* Usage -Dzanata.maxChunkSize=12345
*
* @parameter expression="${zanata.maxChunkSize}" default-value="1048576"
*/
private int maxChunkSize = 1024 * 1024;
/**
* File types to locate and transmit to the server when using project type
* "file".
*
* @parameter expression="${zanata.fileTypes}"
* default-value="txt,dtd,odt,fodt,odp,fodp,ods,fods,odg,fodg,odf,odb"
*/
private String[] fileTypes =
"txt,dtd,odt,fodt,odp,fodp,ods,fods,odg,fodg,odf,odb".split(",");
/**
* Case sensitive for includes and excludes options.
*
* @parameter expression="${zanata.caseSensitive}" default-value="true"
*/
private boolean caseSensitive = true;
/**
* Exclude filenames which match locales configured for the project (other
* than the source locale). For instance, if project includes de and fr,
* then the files messages_de.properties and messages_fr.properties will not
* be treated as source files.
* <p>
* NB: This parameter will be ignored for some project types which use
* different file naming conventions (eg podir, gettext).
*
* @parameter expression="${zanata.excludeLocaleFilenames}"
* default-value="true"
*/
private boolean excludeLocaleFilenames = true;
/**
* Run validation check against file. Only applies to XLIFF project type.
* "CONTENT" - content validation check (quick). "XSD" - validation check
* against xliff 1.1 schema -
* http://www.oasis-open.org/committees/xliff/documents/xliff-core-1.1.xsd.
*
* @parameter expression="${zanata.validate}" default-value="content"
*/
private String validate = "content";
/**
* Indicates if all uploaded translations were translated by you.
*
* @parameter expression="${zanata.myTrans}"
* default-value="false"
*/
private boolean myTrans = false;
@Override
public String getSourceLang() {
return sourceLang;
}
@Override
public PushPullType getPushType() {
// if the deprecated 'pushTrans' option has been used
if (pushTrans != null) {
return Boolean.parseBoolean(pushTrans) ? PushPullType.Both
: PushPullType.Source;
} else {
return PushPullType.fromString(pushType);
}
}
@Override
public boolean getCopyTrans() {
return copyTrans;
}
@Override
public String getMergeType() {
return merge;
}
@Override
public boolean getDefaultExcludes() {
return defaultExcludes;
}
@Override
public int getChunkSize() {
return maxChunkSize;
}
@Override
public ImmutableList<String> getFileTypes() {
return ImmutableList.copyOf(fileTypes);
}
@Override
public String getCommandName() {
return "push";
}
@Override
public boolean getCaseSensitive() {
return caseSensitive;
}
@Override
public boolean getExcludeLocaleFilenames() {
return excludeLocaleFilenames;
}
@Override
public String getValidate() {
return validate;
}
@Override
public boolean isMyTrans() {
return myTrans;
}
}