Merge branch 'stable-2.11'
* stable-2.11:
Create local user if user does not exist anymore in LDAP
Fix Eclise warnings
Change-Id: I41ef115d484b45f715fbcb737dfb713c3a5c79d4
diff --git a/BUCK b/BUCK
index e37deb4..11c5585 100644
--- a/BUCK
+++ b/BUCK
@@ -15,7 +15,7 @@
manifest_entries = [
'Gerrit-PluginName: importer',
'Gerrit-ApiType: plugin',
- 'Gerrit-ApiVersion: 2.11.2',
+ 'Gerrit-ApiVersion: 2.12-SNAPSHOT',
'Gerrit-Module: com.googlesource.gerrit.plugins.importer.Module',
'Gerrit-SshModule: com.googlesource.gerrit.plugins.importer.SshModule',
'Gerrit-HttpModule: com.googlesource.gerrit.plugins.importer.HttpModule',
diff --git a/VERSION b/VERSION
index 9e1a35c..9df7bf7 100644
--- a/VERSION
+++ b/VERSION
@@ -1,5 +1,5 @@
# Used by BUCK to include "Implementation-Version" in plugin Manifest.
# If this file doesn't exist the output of 'git describe' is used
# instead.
-PLUGIN_VERSION = '2.11.2'
+PLUGIN_VERSION = '2.12-SNAPSHOT'
diff --git a/lib/gerrit/BUCK b/lib/gerrit/BUCK
index 513f901..ae59eba 100644
--- a/lib/gerrit/BUCK
+++ b/lib/gerrit/BUCK
@@ -1,12 +1,11 @@
include_defs('//bucklets/maven_jar.bucklet')
-VER = '2.11.2'
-REPO = MAVEN_CENTRAL
+VER = '2.12-SNAPSHOT'
+REPO = MAVEN_LOCAL
maven_jar(
name = 'plugin-api',
id = 'com.google.gerrit:gerrit-plugin-api:' + VER,
- sha1 = '1d45b5fd8d3f436e34e1a11d3adc07d61717d427',
attach_source = False,
repository = REPO,
license = 'Apache2.0',
@@ -15,7 +14,6 @@
maven_jar(
name = 'gwtui-api',
id = 'com.google.gerrit:gerrit-plugin-gwtui:' + VER,
- sha1 = 'a2262a4d3d12fe4ea1e67d849d4112f222a1b2b0',
attach_source = False,
repository = REPO,
license = 'Apache2.0',
diff --git a/pom.xml b/pom.xml
deleted file mode 100644
index 5d7e185..0000000
--- a/pom.xml
+++ /dev/null
@@ -1,139 +0,0 @@
-<!--
-Copyright (C) 2015 The Android Open Source Project
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>com.googlesource.gerrit.plugins.importer</groupId>
- <artifactId>importer</artifactId>
- <packaging>jar</packaging>
- <version>2.11.2</version>
- <name>importer</name>
-
- <properties>
- <Gerrit-ApiType>plugin</Gerrit-ApiType>
- <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion>
- </properties>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <version>2.4</version>
- <configuration>
- <archive>
- <manifestEntries>
- <Gerrit-PluginName>importer</Gerrit-PluginName>
- <Gerrit-Module>com.googlesource.gerrit.plugins.importer.Module</Gerrit-Module>
- <Gerrit-SshModule>com.googlesource.gerrit.plugins.importer.SshModule</Gerrit-SshModule>
- <Gerrit-HttpModule>com.googlesource.gerrit.plugins.importer.HttpModule</Gerrit-HttpModule>
-
- <Implementation-Vendor>Gerrit Code Review</Implementation-Vendor>
- <Implementation-URL>http://code.google.com/p/gerrit/</Implementation-URL>
-
- <Implementation-Title>${Gerrit-ApiType} ${project.artifactId}</Implementation-Title>
- <Implementation-Version>${project.version}</Implementation-Version>
-
- <Gerrit-ApiType>${Gerrit-ApiType}</Gerrit-ApiType>
- <Gerrit-ApiVersion>${Gerrit-ApiVersion}</Gerrit-ApiVersion>
- </manifestEntries>
- </archive>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.3.2</version>
- <configuration>
- <source>1.7</source>
- <target>1.7</target>
- <encoding>UTF-8</encoding>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>gwt-maven-plugin</artifactId>
- <version>2.7.0</version>
- <configuration>
- <module>com.googlesource.gerrit.plugins.importer.Importer</module>
- <disableClassMetadata>true</disableClassMetadata>
- <disableCastChecking>true</disableCastChecking>
- <webappDirectory>${project.build.directory}/classes/static</webappDirectory>
- </configuration>
- <executions>
- <execution>
- <goals>
- <goal>compile</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <version>2.3</version>
- <configuration>
- <promoteTransitiveDependencies>true</promoteTransitiveDependencies>
- <createDependencyReducedPom>false</createDependencyReducedPom>
- </configuration>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>com.google.gerrit</groupId>
- <artifactId>gerrit-${Gerrit-ApiType}-api</artifactId>
- <version>${Gerrit-ApiVersion}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>com.google.gerrit</groupId>
- <artifactId>gerrit-plugin-gwtui</artifactId>
- <version>${Gerrit-ApiVersion}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>com.google.gwt</groupId>
- <artifactId>gwt-user</artifactId>
- <version>2.7.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpclient</artifactId>
- <version>4.3.4</version>
- </dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpcore</artifactId>
- <version>4.3.2</version>
- </dependency>
- </dependencies>
-</project>
diff --git a/src/main/java/com/googlesource/gerrit/plugins/importer/ConfigureRepositoryStep.java b/src/main/java/com/googlesource/gerrit/plugins/importer/ConfigureRepositoryStep.java
index 7a93521..f15a3ec 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/importer/ConfigureRepositoryStep.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/importer/ConfigureRepositoryStep.java
@@ -27,7 +27,9 @@
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.StoredConfig;
-import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
import java.io.IOException;
@Singleton
@@ -35,7 +37,7 @@
static final String R_IMPORTS = "refs/imports/";
- private final File gitDir;
+ private final Path gitDir;
@Inject
ConfigureRepositoryStep(
@@ -54,7 +56,7 @@
.concat(name.get()));
} else {
config.setString("remote", "origin", "url",
- new File(gitDir, name.get() + ".git").getCanonicalPath());
+ this.gitDir.resolve(name.get() + ".git").toString());
}
config.setString("remote", "origin", "fetch", "+refs/*:" + R_IMPORTS + "*");
diff --git a/src/main/java/com/googlesource/gerrit/plugins/importer/GerritApi.java b/src/main/java/com/googlesource/gerrit/plugins/importer/GerritApi.java
index f4d3bda..7d47c79 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/importer/GerritApi.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/importer/GerritApi.java
@@ -17,10 +17,10 @@
import com.google.common.base.Objects;
import com.google.gerrit.extensions.common.ChangeInfo;
import com.google.gerrit.extensions.common.CommentInfo;
+import com.google.gerrit.extensions.common.GroupInfo;
import com.google.gerrit.extensions.common.ProjectInfo;
import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.server.account.GetSshKeys.SshKeyInfo;
-import com.google.gerrit.server.group.GroupJson.GroupInfo;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/importer/HttpResponse.java b/src/main/java/com/googlesource/gerrit/plugins/importer/HttpResponse.java
old mode 100755
new mode 100644
diff --git a/src/main/java/com/googlesource/gerrit/plugins/importer/HttpSession.java b/src/main/java/com/googlesource/gerrit/plugins/importer/HttpSession.java
old mode 100755
new mode 100644
diff --git a/src/main/java/com/googlesource/gerrit/plugins/importer/ImportGroup.java b/src/main/java/com/googlesource/gerrit/plugins/importer/ImportGroup.java
index f94d734..c4c5f16 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/importer/ImportGroup.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/importer/ImportGroup.java
@@ -19,6 +19,7 @@
import com.google.gerrit.common.errors.NoSuchAccountException;
import com.google.gerrit.extensions.annotations.RequiresCapability;
import com.google.gerrit.extensions.common.AccountInfo;
+import com.google.gerrit.extensions.common.GroupInfo;
import com.google.gerrit.extensions.registration.DynamicSet;
import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.MethodNotAllowedException;
@@ -39,7 +40,6 @@
import com.google.gerrit.server.account.GroupIncludeCache;
import com.google.gerrit.server.config.ConfigResource;
import com.google.gerrit.server.config.GerritServerConfig;
-import com.google.gerrit.server.group.GroupJson.GroupInfo;
import com.google.gerrit.server.validators.GroupCreationValidationListener;
import com.google.gerrit.server.validators.ValidationException;
import com.google.gwtorm.server.OrmDuplicateKeyException;
@@ -199,11 +199,6 @@
initialMembers.add(accountUtil.resolveUser(api, member));
}
args.initialMembers = initialMembers;
- Set<AccountGroup.UUID> initialGroups = new HashSet<>();
- for (GroupInfo member : groupInfo.includes) {
- initialGroups.add(new AccountGroup.UUID(member.id));
- }
- args.initialGroups = initialGroups;
return args;
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/importer/ImportLog.java b/src/main/java/com/googlesource/gerrit/plugins/importer/ImportLog.java
index 46b0cbb..38e0f8b 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/importer/ImportLog.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/importer/ImportLog.java
@@ -19,23 +19,22 @@
import com.google.gerrit.audit.AuditEvent;
import com.google.gerrit.audit.AuditService;
import com.google.gerrit.common.TimeUtil;
-import com.google.gerrit.extensions.events.LifecycleListener;
import com.google.gerrit.extensions.systemstatus.ServerInformation;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.config.CanonicalWebUrl;
+import com.google.gerrit.server.util.PluginLogFile;
import com.google.gerrit.server.util.SystemLog;
import com.google.inject.Inject;
import com.google.inject.Singleton;
-import org.apache.log4j.AsyncAppender;
import org.apache.log4j.Level;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.apache.log4j.spi.LoggingEvent;
@Singleton
-class ImportLog implements LifecycleListener {
+class ImportLog extends PluginLogFile {
private static final String IMPORT_LOG_NAME = "import_log";
private static final Logger log = LogManager.getLogger(IMPORT_LOG_NAME);
@@ -46,19 +45,15 @@
public static String TARGET_PROJECT_NAME = "targetProjectName";
public static String ERROR = "error";
- private final SystemLog systemLog;
- private final ServerInformation serverInfo;
private final AuditService auditService;
private final String canonicalWebUrl;
- private boolean started;
@Inject
public ImportLog(SystemLog systemLog,
ServerInformation serverInfo,
AuditService auditService,
@CanonicalWebUrl String canonicalWebUrl) {
- this.systemLog = systemLog;
- this.serverInfo = serverInfo;
+ super(systemLog, serverInfo, IMPORT_LOG_NAME, new ImportLogLayout());
this.auditService = auditService;
this.canonicalWebUrl = canonicalWebUrl;
}
@@ -130,31 +125,4 @@
: "OK"
));
}
-
- @Override
- public void start() {
- if (!started) {
- Logger importLogger = LogManager.getLogger(IMPORT_LOG_NAME);
- String loggerName = importLogger.getName();
- AsyncAppender asyncAppender = systemLog.createAsyncAppender(
- loggerName, new ImportLogLayout());
- importLogger.removeAppender(loggerName);
- importLogger.addAppender(asyncAppender);
- importLogger.setAdditivity(false);
- started = true;
- }
- }
-
- @Override
- public void stop() {
- // stop() is called when the plugin is unloaded or when the server is
- // shutdown. Only clean up when the server is shutting down to prevent
- // issues when the plugin is reloaded. Otherwise when Gerrit loads the new
- // plugin and then unloads the old one, the unload of the old plugin would
- // remove the appenders that were just created by the new plugin. This is
- // because the logger is static.
- if (serverInfo.getState() == ServerInformation.State.SHUTDOWN) {
- LogManager.getLogger(log.getName()).removeAllAppenders();
- }
- }
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/importer/LocalApi.java b/src/main/java/com/googlesource/gerrit/plugins/importer/LocalApi.java
index f214b74..c9ec59f 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/importer/LocalApi.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/importer/LocalApi.java
@@ -19,6 +19,7 @@
import com.google.gerrit.extensions.client.ListChangesOption;
import com.google.gerrit.extensions.common.ChangeInfo;
import com.google.gerrit.extensions.common.CommentInfo;
+import com.google.gerrit.extensions.common.GroupInfo;
import com.google.gerrit.extensions.common.ProjectInfo;
import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.BadRequestException;
@@ -26,21 +27,10 @@
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.extensions.restapi.TopLevelResource;
-import com.google.gerrit.reviewdb.client.AccountGroup;
-import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.server.account.AccountResource;
import com.google.gerrit.server.account.AccountsCollection;
import com.google.gerrit.server.account.GetSshKeys;
import com.google.gerrit.server.account.GetSshKeys.SshKeyInfo;
-import com.google.gerrit.server.account.GroupCache;
-import com.google.gerrit.server.account.GroupControl;
-import com.google.gerrit.server.change.ChangeResource;
-import com.google.gerrit.server.change.ChangesCollection;
-import com.google.gerrit.server.change.ListComments;
-import com.google.gerrit.server.change.RevisionResource;
-import com.google.gerrit.server.change.Revisions;
-import com.google.gerrit.server.group.GroupJson;
-import com.google.gerrit.server.group.GroupJson.GroupInfo;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
@@ -50,33 +40,15 @@
public class LocalApi implements GerritApi {
private final com.google.gerrit.extensions.api.GerritApi gApi;
- private final GroupCache groupCache;
- private final GroupJson groupJson;
- private final GroupControl.Factory groupControlFactory;
- private final ChangesCollection changes;
- private final Revisions revisions;
- private final ListComments listComments;
private final AccountsCollection accounts;
private final GetSshKeys getSshKeys;
@Inject
LocalApi(
com.google.gerrit.extensions.api.GerritApi gApi,
- GroupCache groupCache,
- GroupJson groupJson,
- GroupControl.Factory groupControlFactory,
- ChangesCollection changes,
- Revisions revisions,
- ListComments listComments,
AccountsCollection accounts,
GetSshKeys getSshKeys) {
this.gApi = gApi;
- this.groupCache = groupCache;
- this.groupJson = groupJson;
- this.groupControlFactory = groupControlFactory;
- this.changes = changes;
- this.revisions = revisions;
- this.listComments = listComments;
this.accounts = accounts;
this.getSshKeys = getSshKeys;
}
@@ -120,23 +92,19 @@
@Override
public GroupInfo getGroup(String groupName) throws IOException,
BadRequestException, OrmException {
- AccountGroup group = groupCache.get(new AccountGroup.NameKey(groupName));
- GroupControl groupControl = groupControlFactory.controlFor(group);
- if (group == null || !groupControl.isVisible()) {
- throw new BadRequestException(String.format("Group %s not found.",
- groupName));
+ try {
+ return gApi.groups().id(groupName).get();
+ } catch (RestApiException e) {
+ throw new BadRequestException(e.getMessage());
}
- return groupJson.format(groupControl.getGroup());
}
@Override
public Iterable<CommentInfo> getComments(int changeId, String rev)
throws IOException, OrmException, BadRequestException {
try {
- ChangeResource changeRsrc = changes.parse(new Change.Id(changeId));
- RevisionResource revRsrc =
- revisions.parse(changeRsrc, IdString.fromDecoded(rev));
- Map<String, List<CommentInfo>> result = listComments.apply(revRsrc);
+ Map<String, List<CommentInfo>> result =
+ gApi.changes().id(changeId).revision(rev).comments();
for (Map.Entry<String, List<CommentInfo>> e : result.entrySet()) {
for (CommentInfo i : e.getValue()) {
@@ -145,9 +113,7 @@
}
return Iterables.concat(result.values());
- } catch (ResourceNotFoundException e) {
- return null;
- } catch (AuthException e) {
+ } catch (RestApiException e) {
throw new BadRequestException(e.getMessage());
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/importer/Module.java b/src/main/java/com/googlesource/gerrit/plugins/importer/Module.java
index dcf4099..1cad41f 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/importer/Module.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/importer/Module.java
@@ -21,12 +21,12 @@
import com.google.gerrit.extensions.annotations.Exports;
import com.google.gerrit.extensions.config.CapabilityDefinition;
+import com.google.gerrit.extensions.config.FactoryModule;
import com.google.gerrit.extensions.events.LifecycleListener;
import com.google.gerrit.extensions.registration.DynamicMap;
import com.google.gerrit.extensions.registration.DynamicSet;
import com.google.gerrit.extensions.restapi.RestApiModule;
import com.google.gerrit.extensions.webui.TopMenu;
-import com.google.gerrit.server.config.FactoryModule;
import com.google.inject.internal.UniqueAnnotations;
class Module extends FactoryModule {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/importer/RemoteApi.java b/src/main/java/com/googlesource/gerrit/plugins/importer/RemoteApi.java
old mode 100755
new mode 100644
index 05e757e..5ee6f06
--- a/src/main/java/com/googlesource/gerrit/plugins/importer/RemoteApi.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/importer/RemoteApi.java
@@ -20,12 +20,12 @@
import com.google.gerrit.extensions.client.ListChangesOption;
import com.google.gerrit.extensions.common.ChangeInfo;
import com.google.gerrit.extensions.common.CommentInfo;
+import com.google.gerrit.extensions.common.GroupInfo;
import com.google.gerrit.extensions.common.ProjectInfo;
import com.google.gerrit.extensions.common.RevisionInfo;
import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.server.OutputFormat;
import com.google.gerrit.server.account.GetSshKeys.SshKeyInfo;
-import com.google.gerrit.server.group.GroupJson.GroupInfo;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/importer/RestResponse.java b/src/main/java/com/googlesource/gerrit/plugins/importer/RestResponse.java
old mode 100755
new mode 100644
diff --git a/src/main/java/com/googlesource/gerrit/plugins/importer/RestSession.java b/src/main/java/com/googlesource/gerrit/plugins/importer/RestSession.java
old mode 100755
new mode 100644
diff --git a/src/main/resources/Documentation/build.md b/src/main/resources/Documentation/build.md
index f726c6e..a96e116 100644
--- a/src/main/resources/Documentation/build.md
+++ b/src/main/resources/Documentation/build.md
@@ -1,7 +1,7 @@
Build
=====
-This plugin can be built with Buck or Maven.
+This plugin can be built with Buck.
Buck
----
@@ -69,15 +69,3 @@
./tools/eclipse/project.py
```
-Maven
------
-
-Note that the Maven build is provided for compatibility reasons, but
-it is considered to be deprecated and will be removed in a future
-version of this plugin.
-
-To build with Maven, run
-
-```
-mvn clean package
-```