mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-02-16 03:26:54 +01:00
Merged in feature/keys_for_violations (pull request #391)
Feature/keys for violations
This commit is contained in:
@@ -56,7 +56,8 @@ class BackendErrorNotification extends React.Component<Props> {
|
||||
{error.violations.map((violation, index) => {
|
||||
return (
|
||||
<li key={index}>
|
||||
<strong>{violation.path}:</strong> {violation.message}
|
||||
{violation.path && <strong>{violation.path}:</strong>} {violation.message}{" "}
|
||||
{violation.key && t(violation.key)}
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
|
||||
@@ -2,9 +2,10 @@ type Context = {
|
||||
type: string;
|
||||
id: string;
|
||||
}[];
|
||||
type Violation = {
|
||||
path: string;
|
||||
export type Violation = {
|
||||
path?: string;
|
||||
message: string;
|
||||
key?: string;
|
||||
};
|
||||
|
||||
export type BackendErrorContent = {
|
||||
|
||||
@@ -175,6 +175,17 @@ public final class PluginNode
|
||||
this.wrapper = wrapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getId().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof PluginNode
|
||||
&& ((PluginNode) obj).getId().equals(this.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return plugin.getPath().toString() + " -> " + children;
|
||||
|
||||
@@ -191,11 +191,11 @@ public final class PluginProcessor
|
||||
|
||||
logger.info("install plugin tree:\n{}", pluginTree);
|
||||
|
||||
List<PluginNode> rootNodes = pluginTree.getRootNodes();
|
||||
List<PluginNode> leafLastNodes = pluginTree.getLeafLastNodes();
|
||||
|
||||
logger.trace("create plugin wrappers and build classloaders");
|
||||
|
||||
Set<InstalledPlugin> wrappers = createPluginWrappers(classLoader, rootNodes);
|
||||
Set<InstalledPlugin> wrappers = createPluginWrappers(classLoader, leafLastNodes);
|
||||
|
||||
logger.debug("collected {} plugins", wrappers.size());
|
||||
|
||||
@@ -259,33 +259,6 @@ public final class PluginProcessor
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param plugins
|
||||
* @param classLoader
|
||||
* @param nodes
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
private void appendPluginWrappers(Set<InstalledPlugin> plugins,
|
||||
ClassLoader classLoader, List<PluginNode> nodes)
|
||||
throws IOException
|
||||
{
|
||||
|
||||
// TODO fix plugin loading order
|
||||
for (PluginNode node : nodes)
|
||||
{
|
||||
appendPluginWrapper(plugins, classLoader, node);
|
||||
}
|
||||
|
||||
for (PluginNode node : nodes)
|
||||
{
|
||||
appendPluginWrappers(plugins, classLoader, node.getChildren());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -484,19 +457,22 @@ public final class PluginProcessor
|
||||
*
|
||||
*
|
||||
* @param classLoader
|
||||
* @param rootNodes
|
||||
* @param nodes
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
private Set<InstalledPlugin> createPluginWrappers(ClassLoader classLoader,
|
||||
List<PluginNode> rootNodes)
|
||||
List<PluginNode> nodes)
|
||||
throws IOException
|
||||
{
|
||||
Set<InstalledPlugin> plugins = Sets.newHashSet();
|
||||
|
||||
appendPluginWrappers(plugins, classLoader, rootNodes);
|
||||
for (PluginNode node : nodes)
|
||||
{
|
||||
appendPluginWrapper(plugins, classLoader, node);
|
||||
}
|
||||
|
||||
return plugins;
|
||||
}
|
||||
|
||||
@@ -39,6 +39,8 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
@@ -134,13 +136,26 @@ public final class PluginTree
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<PluginNode> getRootNodes()
|
||||
public List<PluginNode> getLeafLastNodes()
|
||||
{
|
||||
return rootNodes;
|
||||
LinkedHashSet<PluginNode> leafFirst = new LinkedHashSet<>();
|
||||
|
||||
rootNodes.forEach(node -> appendLeafFirst(leafFirst, node));
|
||||
|
||||
LinkedList<PluginNode> leafLast = new LinkedList<>();
|
||||
|
||||
leafFirst.forEach(leafLast::addFirst);
|
||||
|
||||
return leafLast;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
private void appendLeafFirst(LinkedHashSet<PluginNode> leafFirst, PluginNode node) {
|
||||
node.getChildren().forEach(child -> appendLeafFirst(leafFirst, child));
|
||||
leafFirst.add(node);
|
||||
}
|
||||
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -235,7 +250,8 @@ public final class PluginTree
|
||||
append(buffer, indent + " ", child);
|
||||
}
|
||||
}
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private final List<PluginNode> rootNodes = Lists.newArrayList();
|
||||
|
||||
@@ -76,7 +76,7 @@ public class PluginTreeTest
|
||||
false, null, null);
|
||||
ExplodedSmp smp = createSmp(plugin);
|
||||
|
||||
new PluginTree(smp).getRootNodes();
|
||||
new PluginTree(smp).getLeafLastNodes();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,7 +88,7 @@ public class PluginTreeTest
|
||||
@Test(expected = PluginNotInstalledException.class)
|
||||
public void testPluginNotInstalled() throws IOException
|
||||
{
|
||||
new PluginTree(createSmpWithDependency("b", "a")).getRootNodes();
|
||||
new PluginTree(createSmpWithDependency("b", "a")).getLeafLastNodes();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,10 +98,10 @@ public class PluginTreeTest
|
||||
* @throws IOException
|
||||
*/
|
||||
@Test
|
||||
public void testRootNotes() throws IOException
|
||||
public void testNodes() throws IOException
|
||||
{
|
||||
List<ExplodedSmp> smps = createSmps("a", "b", "c");
|
||||
List<String> nodes = unwrapIds(new PluginTree(smps).getRootNodes());
|
||||
List<String> nodes = unwrapIds(new PluginTree(smps).getLeafLastNodes());
|
||||
|
||||
assertThat(nodes, containsInAnyOrder("a", "b", "c"));
|
||||
}
|
||||
@@ -119,7 +119,7 @@ public class PluginTreeTest
|
||||
null, null);
|
||||
ExplodedSmp smp = createSmp(plugin);
|
||||
|
||||
new PluginTree(smp).getRootNodes();
|
||||
new PluginTree(smp).getLeafLastNodes();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -140,17 +140,31 @@ public class PluginTreeTest
|
||||
//J+
|
||||
|
||||
PluginTree tree = new PluginTree(smps);
|
||||
List<PluginNode> rootNodes = tree.getRootNodes();
|
||||
List<PluginNode> nodes = tree.getLeafLastNodes();
|
||||
|
||||
assertThat(unwrapIds(rootNodes), containsInAnyOrder("a"));
|
||||
System.out.println(tree);
|
||||
|
||||
PluginNode a = rootNodes.get(0);
|
||||
assertThat(unwrapIds(nodes), contains("a", "b", "c"));
|
||||
}
|
||||
|
||||
assertThat(unwrapIds(a.getChildren()), containsInAnyOrder("b", "c"));
|
||||
@Test
|
||||
public void testComplexDependencies() throws IOException
|
||||
{
|
||||
//J-
|
||||
ExplodedSmp[] smps = new ExplodedSmp[]{
|
||||
createSmpWithDependency("a", "b", "c", "d"),
|
||||
createSmpWithDependency("b", "c"),
|
||||
createSmpWithDependency("c"),
|
||||
createSmpWithDependency("d")
|
||||
};
|
||||
//J+
|
||||
|
||||
PluginNode b = a.getChild("b");
|
||||
PluginTree tree = new PluginTree(smps);
|
||||
List<PluginNode> nodes = tree.getLeafLastNodes();
|
||||
|
||||
assertThat(unwrapIds(b.getChildren()), containsInAnyOrder("c"));
|
||||
System.out.println(tree);
|
||||
|
||||
assertThat(unwrapIds(nodes), contains("d", "c", "b", "a"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -162,15 +176,11 @@ public class PluginTreeTest
|
||||
};
|
||||
|
||||
PluginTree tree = new PluginTree(smps);
|
||||
List<PluginNode> rootNodes = tree.getRootNodes();
|
||||
List<PluginNode> nodes = tree.getLeafLastNodes();
|
||||
|
||||
assertThat(unwrapIds(rootNodes), containsInAnyOrder("a"));
|
||||
System.out.println(tree);
|
||||
|
||||
PluginNode a = rootNodes.get(0);
|
||||
assertThat(unwrapIds(a.getChildren()), containsInAnyOrder("b", "c"));
|
||||
|
||||
PluginNode b = a.getChild("b");
|
||||
assertThat(unwrapIds(b.getChildren()), containsInAnyOrder("c"));
|
||||
assertThat(unwrapIds(nodes), contains("a", "b", "c"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -185,15 +195,9 @@ public class PluginTreeTest
|
||||
|
||||
System.out.println(tree);
|
||||
|
||||
List<PluginNode> rootNodes = tree.getRootNodes();
|
||||
List<PluginNode> nodes = tree.getLeafLastNodes();
|
||||
|
||||
assertThat(unwrapIds(rootNodes), containsInAnyOrder("a"));
|
||||
|
||||
PluginNode a = rootNodes.get(0);
|
||||
assertThat(unwrapIds(a.getChildren()), containsInAnyOrder("b"));
|
||||
|
||||
PluginNode b = a.getChild("b");
|
||||
assertThat(unwrapIds(b.getChildren()), containsInAnyOrder("c"));
|
||||
assertThat(unwrapIds(nodes), contains("a", "b", "c"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -203,9 +207,9 @@ public class PluginTreeTest
|
||||
};
|
||||
|
||||
PluginTree tree = new PluginTree(smps);
|
||||
List<PluginNode> rootNodes = tree.getRootNodes();
|
||||
List<PluginNode> nodes = tree.getLeafLastNodes();
|
||||
|
||||
assertThat(unwrapIds(rootNodes), containsInAnyOrder("a"));
|
||||
assertThat(unwrapIds(nodes), containsInAnyOrder("a"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user