Maven: updating mirrored repositories fixed (IDEA-77593)

This commit is contained in:
Anton Makeev
2011-11-25 12:20:22 +01:00
parent 8d9fca3e85
commit 83029b2355
8 changed files with 45 additions and 16 deletions
@@ -33,7 +33,7 @@ public interface MavenServerIndexer extends Remote {
String SEARCH_TERM_CLASS_NAMES = "c";
int createIndex(@NotNull String indexId,
@Nullable String repositoryId,
@NotNull String repositoryId,
@Nullable File file,
@Nullable String url,
@NotNull File indexDir) throws RemoteException, MavenServerIndexerException;
@@ -72,7 +72,7 @@ public class Maven2ServerIndexerImpl extends MavenRemoteObject implements MavenS
}
public int createIndex(@NotNull String indexId,
@Nullable String repositoryId,
@NotNull String repositoryId,
@Nullable File file,
@Nullable String url,
@NotNull File indexDir) throws MavenServerIndexerException {
@@ -35,7 +35,7 @@ import java.rmi.RemoteException;
import java.util.Arrays;
import java.util.Collections;
public class MavenFacadeEmbedderTest extends MavenImportingTestCase {
public class MavenServerEmbedderTest extends MavenImportingTestCase {
private MavenEmbedderWrapper myEmbedder;
private Maven2ServerEmbedderImpl myEmbedderImpl;
@@ -45,7 +45,7 @@ public class Maven3ServerImpl extends MavenRemoteObject implements MavenServer {
public MavenServerIndexer createIndexer() throws RemoteException {
try {
Maven3FacadeIndexerImpl result = new Maven3FacadeIndexerImpl();
Maven3ServerIndexerImpl result = new Maven3ServerIndexerImpl();
UnicastRemoteObject.exportObject(result, 0);
return result;
}
@@ -27,10 +27,10 @@ import java.rmi.RemoteException;
import java.util.Collection;
import java.util.Set;
public class Maven3FacadeIndexerImpl extends MavenRemoteObject implements MavenServerIndexer {
public class Maven3ServerIndexerImpl extends MavenRemoteObject implements MavenServerIndexer {
@Override
public int createIndex(@NotNull String indexId,
@Nullable String repositoryId,
@NotNull String repositoryId,
@Nullable File file,
@Nullable String url,
@NotNull File indexDir) throws RemoteException, MavenServerIndexerException {
@@ -156,7 +156,7 @@ public class MavenIndex {
doOpen();
}
catch (Exception e1) {
MavenLog.LOG.info(e1);
MavenLog.LOG.warn(e1);
try {
doOpen();
}
@@ -223,7 +223,7 @@ public class MavenIndex {
}
}
catch (IOException e) {
MavenLog.LOG.info(e);
MavenLog.LOG.warn(e);
}
}
@@ -291,15 +291,13 @@ public class MavenIndex {
private void handleUpdateException(Exception e) {
myFailureMessage = e.getMessage();
MavenLog.LOG.info("Failed to update Maven indices for: [" + myRepositoryId + "] " + myRepositoryPathOrUrl, e);
MavenLog.LOG.warn("Failed to update Maven indices for: [" + myRepositoryId + "] " + myRepositoryPathOrUrl, e);
}
private int createContext(File contextDir, String suffix) throws MavenServerIndexerException {
String indexId = myDir.getName() + "-" + suffix;
// Nexus cannot update index if the id does not equal to the stored one.
String repoId = contextDir.exists() ? null : myDir.getName();
return myIndexer.createIndex(indexId,
repoId,
myRepositoryId,
getRepositoryFile(),
getRepositoryUrl(),
contextDir);
@@ -661,7 +659,7 @@ public class MavenIndex {
if (indexId != 0 && releaseIndexContext) myIndexer.releaseIndex(indexId);
}
catch (MavenServerIndexerException e) {
MavenLog.LOG.info(e);
MavenLog.LOG.warn(e);
if (exceptions[0] == null) exceptions[0] = new MavenIndexException(e);
}
@@ -680,7 +678,7 @@ public class MavenIndex {
if (enumerator != null) enumerator.close();
}
catch (IOException e) {
MavenLog.LOG.info(e);
MavenLog.LOG.warn(e);
if (exceptions[0] == null) exceptions[0] = new MavenIndexException(e);
}
}
@@ -50,7 +50,7 @@ public abstract class MavenIndexerWrapper extends RemoteObjectWrapper<MavenServe
}
public synchronized int createIndex(@NotNull final String indexId,
@Nullable final String repositoryId,
@NotNull final String repositoryId,
@Nullable final File file,
@Nullable final String url,
@NotNull final File indexDir) throws MavenServerIndexerException {
@@ -186,7 +186,7 @@ public abstract class MavenIndexerWrapper extends RemoteObjectWrapper<MavenServe
private int remoteId = -1;
private final @NotNull String indexId;
private final @Nullable String repositoryId;
private final @NotNull String repositoryId;
private final @Nullable File file;
private final @Nullable String url;
private final @NotNull File indexDir;
@@ -100,6 +100,36 @@ public class MavenProjectIndicesManagerTest extends MavenIndicesTestCase {
myIndicesFixture.getProjectIndicesManager().scheduleUpdateAll();
assertUnorderedElementsAreEqual(myIndicesFixture.getProjectIndicesManager().getGroupIds(), "test", "jmock");
updateSettingsXmlFully("<settings>" +
" <mirrors>" +
" <mirror>" +
" <id>nexus</id>" +
" <mirrorOf>anotherRepoId</mirrorOf>" +
" <url>file:///" + myIndicesFixture.getRepositoryHelper().getTestDataPath("remote_mirror") + "</url>" +
" </mirror>" +
" </mirrors>" +
"</settings>");
myIndicesFixture.getProjectIndicesManager().scheduleUpdateAll();
assertUnorderedElementsAreEqual(myIndicesFixture.getProjectIndicesManager().getGroupIds(), "test", "jmock");
updateSettingsXmlFully("<settings>" +
" <mirrors>" +
" <mirror>" +
" <id>nexus</id>" +
" <mirrorOf>central</mirrorOf>" +
" <url>file:///" + myIndicesFixture.getRepositoryHelper().getTestDataPath("remote_mirror") + "</url>" +
" </mirror>" +
" </mirrors>" +
"</settings>");
myIndicesFixture.getProjectIndicesManager().scheduleUpdateAll();
assertUnorderedElementsAreEqual(myIndicesFixture.getProjectIndicesManager().getGroupIds(), "test", "jmock", "junit");
myIndicesFixture.tearDown();
myIndicesFixture = new MavenIndicesTestFixture(myDir, myProject, "local2", "remote_mirror");
myIndicesFixture.setUp();
updateSettingsXmlFully("<settings>" +
" <mirrors>" +
" <mirror>" +
@@ -112,6 +142,7 @@ public class MavenProjectIndicesManagerTest extends MavenIndicesTestCase {
myIndicesFixture.getProjectIndicesManager().scheduleUpdateAll();
assertUnorderedElementsAreEqual(myIndicesFixture.getProjectIndicesManager().getGroupIds(), "test", "jmock", "junit");
}
public void testCheckingLocalRepositoryForAbsentIndices() throws Exception {