mirror of
https://github.com/theonedev/onedev.git
synced 2025-12-08 18:26:30 +00:00
Upgrade to JDK7.
This commit is contained in:
parent
b939f910f9
commit
dba7531177
@ -6,7 +6,7 @@ import java.util.Collection;
|
|||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import com.pmease.commons.util.EasySet;
|
import com.google.common.collect.Sets;
|
||||||
import com.pmease.commons.util.FileUtils;
|
import com.pmease.commons.util.FileUtils;
|
||||||
|
|
||||||
public class ListChangedFilesCommandTest extends GitCommandTest {
|
public class ListChangedFilesCommandTest extends GitCommandTest {
|
||||||
@ -37,7 +37,7 @@ public class ListChangedFilesCommandTest extends GitCommandTest {
|
|||||||
|
|
||||||
Collection<String> changedFiles = git.findChangedFiles().fromRev("HEAD~4").toRev("HEAD").call();
|
Collection<String> changedFiles = git.findChangedFiles().fromRev("HEAD~4").toRev("HEAD").call();
|
||||||
|
|
||||||
Assert.assertTrue(changedFiles.containsAll(EasySet.of("a", "b", "c", "d")));
|
Assert.assertTrue(changedFiles.containsAll(Sets.newHashSet("a", "b", "c", "d")));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,74 +1,75 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<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/xsd/maven-4.0.0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
<modelVersion>4.0.0</modelVersion>
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<parent>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>parent.general</artifactId>
|
<parent>
|
||||||
<groupId>com.pmease</groupId>
|
<artifactId>parent.general</artifactId>
|
||||||
<version>1.0.28</version>
|
<groupId>com.pmease</groupId>
|
||||||
</parent>
|
<version>1.0.28</version>
|
||||||
<artifactId>commons.jetty</artifactId>
|
</parent>
|
||||||
<build>
|
<artifactId>commons.jetty</artifactId>
|
||||||
<plugins>
|
<build>
|
||||||
<plugin>
|
<plugins>
|
||||||
<groupId>com.pmease</groupId>
|
<plugin>
|
||||||
<artifactId>plugin.maven</artifactId>
|
<groupId>com.pmease</groupId>
|
||||||
</plugin>
|
<artifactId>plugin.maven</artifactId>
|
||||||
<plugin>
|
</plugin>
|
||||||
<artifactId>maven-source-plugin</artifactId>
|
<plugin>
|
||||||
</plugin>
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
<plugin>
|
</plugin>
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
<plugin>
|
||||||
</plugin>
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
</plugins>
|
</plugin>
|
||||||
</build>
|
</plugins>
|
||||||
<dependencies>
|
</build>
|
||||||
<dependency>
|
<dependencies>
|
||||||
<groupId>com.pmease</groupId>
|
<dependency>
|
||||||
<artifactId>commons.loader</artifactId>
|
<groupId>com.pmease</groupId>
|
||||||
<version>1.0.29</version>
|
<artifactId>commons.loader</artifactId>
|
||||||
</dependency>
|
<version>1.0.29</version>
|
||||||
<dependency>
|
</dependency>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
<dependency>
|
||||||
<artifactId>jetty-server</artifactId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<version>${jettyVersion}</version>
|
<artifactId>jetty-server</artifactId>
|
||||||
</dependency>
|
<version>${jettyVersion}</version>
|
||||||
<dependency>
|
</dependency>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
<dependency>
|
||||||
<artifactId>jetty-servlets</artifactId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<version>${jettyVersion}</version>
|
<artifactId>jetty-servlets</artifactId>
|
||||||
</dependency>
|
<version>${jettyVersion}</version>
|
||||||
<dependency>
|
</dependency>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
<dependency>
|
||||||
<artifactId>jetty-servlet</artifactId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<version>${jettyVersion}</version>
|
<artifactId>jetty-servlet</artifactId>
|
||||||
</dependency>
|
<version>${jettyVersion}</version>
|
||||||
<dependency>
|
</dependency>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
<dependency>
|
||||||
<artifactId>jetty-websocket</artifactId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<version>${jettyVersion}</version>
|
<artifactId>jetty-websocket</artifactId>
|
||||||
</dependency>
|
<version>${jettyVersion}</version>
|
||||||
</dependencies>
|
</dependency>
|
||||||
<repositories>
|
</dependencies>
|
||||||
<repository>
|
<repositories>
|
||||||
<id>pmeaseRepo</id>
|
<repository>
|
||||||
<name>PMEase Repository</name>
|
<id>pmeaseRepo</id>
|
||||||
<releases>
|
<name>PMEase Repository</name>
|
||||||
<enabled>true</enabled>
|
<releases>
|
||||||
<updatePolicy>never</updatePolicy>
|
<enabled>true</enabled>
|
||||||
<checksumPolicy>fail</checksumPolicy>
|
<updatePolicy>never</updatePolicy>
|
||||||
</releases>
|
<checksumPolicy>fail</checksumPolicy>
|
||||||
<snapshots>
|
</releases>
|
||||||
<enabled>true</enabled>
|
<snapshots>
|
||||||
<updatePolicy>always</updatePolicy>
|
<enabled>true</enabled>
|
||||||
<checksumPolicy>fail</checksumPolicy>
|
<updatePolicy>always</updatePolicy>
|
||||||
</snapshots>
|
<checksumPolicy>fail</checksumPolicy>
|
||||||
<url>http://artifact.pmease.com/</url>
|
</snapshots>
|
||||||
</repository>
|
<url>http://artifact.pmease.com/</url>
|
||||||
</repositories>
|
</repository>
|
||||||
<properties>
|
</repositories>
|
||||||
<moduleClass>com.pmease.commons.jetty.JettyModule</moduleClass>
|
<properties>
|
||||||
<jettyVersion>8.1.10.v20130312</jettyVersion>
|
<moduleClass>com.pmease.commons.jetty.JettyModule</moduleClass>
|
||||||
</properties>
|
<jettyVersion>8.1.10.v20130312</jettyVersion>
|
||||||
<version>1.0.29</version>
|
</properties>
|
||||||
|
<version>1.0.29</version>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@ -15,8 +15,8 @@ import org.apache.shiro.authz.Permission;
|
|||||||
import org.apache.shiro.realm.AuthorizingRealm;
|
import org.apache.shiro.realm.AuthorizingRealm;
|
||||||
import org.apache.shiro.subject.PrincipalCollection;
|
import org.apache.shiro.subject.PrincipalCollection;
|
||||||
|
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.pmease.commons.util.EasySet;
|
|
||||||
|
|
||||||
public abstract class AbstractRealm extends AuthorizingRealm {
|
public abstract class AbstractRealm extends AuthorizingRealm {
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ public abstract class AbstractRealm extends AuthorizingRealm {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<Permission> getObjectPermissions() {
|
public Collection<Permission> getObjectPermissions() {
|
||||||
return EasySet.of((Permission)getUserById(userId));
|
return Sets.newHashSet((Permission)getUserById(userId));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,26 +34,33 @@ public class ClassUtils extends org.apache.commons.lang3.ClassUtils {
|
|||||||
.getCodeSource().getLocation().getFile());
|
.getCodeSource().getLocation().getFile());
|
||||||
if (location.isFile()) {
|
if (location.isFile()) {
|
||||||
String packagePath = packageLocator.getPackage().getName().replace('.', '/') + "/";
|
String packagePath = packageLocator.getPackage().getName().replace('.', '/') + "/";
|
||||||
JarFile jarFile;
|
JarFile jarFile = null;
|
||||||
try {
|
try {
|
||||||
jarFile = new JarFile(location);
|
jarFile = new JarFile(location);
|
||||||
|
Enumeration<JarEntry> entries = jarFile.entries();
|
||||||
|
while (entries.hasMoreElements()) {
|
||||||
|
JarEntry entry = entries.nextElement();
|
||||||
|
if (entry.getName().startsWith(packagePath) && entry.getName().endsWith(".class")) {
|
||||||
|
String className = entry.getName().replace('/', '.');
|
||||||
|
className = StringUtils.substringBeforeLast(className, ".");
|
||||||
|
Class<T> clazz;
|
||||||
|
try {
|
||||||
|
clazz = (Class<T>) superClass.getClassLoader().loadClass(className);
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
if (superClass.isAssignableFrom(clazz) && clazz != superClass)
|
||||||
|
classes.add(clazz);
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
} finally {
|
||||||
Enumeration<JarEntry> entries = jarFile.entries();
|
if (jarFile != null) {
|
||||||
while (entries.hasMoreElements()) {
|
|
||||||
JarEntry entry = entries.nextElement();
|
|
||||||
if (entry.getName().startsWith(packagePath) && entry.getName().endsWith(".class")) {
|
|
||||||
String className = entry.getName().replace('/', '.');
|
|
||||||
className = StringUtils.substringBeforeLast(className, ".");
|
|
||||||
Class<T> clazz;
|
|
||||||
try {
|
try {
|
||||||
clazz = (Class<T>) superClass.getClassLoader().loadClass(className);
|
jarFile.close();
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
}
|
||||||
if (superClass.isAssignableFrom(clazz) && clazz != superClass)
|
|
||||||
classes.add(clazz);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -1,15 +0,0 @@
|
|||||||
package com.pmease.commons.util;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class EasyList {
|
|
||||||
|
|
||||||
public static <T> List<T> of(T...objects) {
|
|
||||||
List<T> list = new ArrayList<T>();
|
|
||||||
for (int i=0; i<objects.length; i++)
|
|
||||||
list.add(objects[i]);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,15 +0,0 @@
|
|||||||
package com.pmease.commons.util;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class EasySet {
|
|
||||||
|
|
||||||
public static <T> Set<T> of(T...objects) {
|
|
||||||
Set<T> set = new HashSet<T>();
|
|
||||||
for (int i=0; i<objects.length; i++)
|
|
||||||
set.add(objects[i]);
|
|
||||||
return set;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -9,6 +9,8 @@ import java.util.Collection;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
public class PathUtilsTest {
|
public class PathUtilsTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -23,15 +25,15 @@ public class PathUtilsTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldMatchLongest() {
|
public void shouldMatchLongest() {
|
||||||
Collection<String> basePaths = EasyList.of("/path1/path2", "/path1/path2/path3");
|
Collection<String> basePaths = Lists.newArrayList("/path1/path2", "/path1/path2/path3");
|
||||||
assertEquals(matchLongest(basePaths, "/path1/path2/path3/path4"), "/path1/path2/path3");
|
assertEquals(matchLongest(basePaths, "/path1/path2/path3/path4"), "/path1/path2/path3");
|
||||||
assertNull(matchLongest(basePaths, "/path1/path23"));
|
assertNull(matchLongest(basePaths, "/path1/path23"));
|
||||||
assertNull(matchLongest(basePaths, "/path1/path3"));
|
assertNull(matchLongest(basePaths, "/path1/path3"));
|
||||||
|
|
||||||
basePaths = EasyList.of("/path1/path2", "/path1\\");
|
basePaths = Lists.newArrayList("/path1/path2", "/path1\\");
|
||||||
assertEquals(matchLongest(basePaths, "path1\\path234"), "/path1\\");
|
assertEquals(matchLongest(basePaths, "path1\\path234"), "/path1\\");
|
||||||
|
|
||||||
basePaths = EasyList.of("/asset1/asset2", "/asset1");
|
basePaths = Lists.newArrayList("/asset1/asset2", "/asset1");
|
||||||
assertEquals(matchLongest(basePaths, "/asset1/asset2/test.html"), "/asset1/asset2");
|
assertEquals(matchLongest(basePaths, "/asset1/asset2/test.html"), "/asset1/asset2");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import org.apache.wicket.markup.head.HeaderItem;
|
|||||||
import org.apache.wicket.request.resource.CssResourceReference;
|
import org.apache.wicket.request.resource.CssResourceReference;
|
||||||
import org.apache.wicket.request.resource.JavaScriptResourceReference;
|
import org.apache.wicket.request.resource.JavaScriptResourceReference;
|
||||||
|
|
||||||
import com.pmease.commons.util.EasyList;
|
import com.google.common.collect.Lists;
|
||||||
import com.pmease.commons.wicket.asset.bootstrap.BootstrapHeaderItem;
|
import com.pmease.commons.wicket.asset.bootstrap.BootstrapHeaderItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,7 +31,7 @@ public class CommonResourceReference extends JavaScriptResourceReference {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<? extends HeaderItem> getDependencies() {
|
public Iterable<? extends HeaderItem> getDependencies() {
|
||||||
return EasyList.of(
|
return Lists.newArrayList(
|
||||||
BootstrapHeaderItem.get(),
|
BootstrapHeaderItem.get(),
|
||||||
CssHeaderItem.forReference(new CssResourceReference(CommonResourceReference.class, "common.css")));
|
CssHeaderItem.forReference(new CssResourceReference(CommonResourceReference.class, "common.css")));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import org.apache.wicket.markup.head.HeaderItem;
|
|||||||
import org.apache.wicket.request.resource.CssResourceReference;
|
import org.apache.wicket.request.resource.CssResourceReference;
|
||||||
import org.apache.wicket.request.resource.JavaScriptResourceReference;
|
import org.apache.wicket.request.resource.JavaScriptResourceReference;
|
||||||
|
|
||||||
import com.pmease.commons.util.EasyList;
|
import com.google.common.collect.Lists;
|
||||||
import com.pmease.commons.wicket.asset.JQueryHeaderItem;
|
import com.pmease.commons.wicket.asset.JQueryHeaderItem;
|
||||||
|
|
||||||
public class BootstrapResourceReference extends JavaScriptResourceReference {
|
public class BootstrapResourceReference extends JavaScriptResourceReference {
|
||||||
@ -28,6 +28,6 @@ public class BootstrapResourceReference extends JavaScriptResourceReference {
|
|||||||
HeaderItem stylesheet = CssHeaderItem.forReference(
|
HeaderItem stylesheet = CssHeaderItem.forReference(
|
||||||
new CssResourceReference(BootstrapResourceReference.class, "css/bootstrap.css"));
|
new CssResourceReference(BootstrapResourceReference.class, "css/bootstrap.css"));
|
||||||
|
|
||||||
return EasyList.of(jquery, stylesheet);
|
return Lists.newArrayList(jquery, stylesheet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,6 +1,5 @@
|
|||||||
package com.pmease.commons.wicket.component.tabbable;
|
package com.pmease.commons.wicket.component.tabbable;
|
||||||
|
|
||||||
import org.apache.wicket.Page;
|
|
||||||
import org.apache.wicket.markup.html.list.ListItem;
|
import org.apache.wicket.markup.html.list.ListItem;
|
||||||
import org.apache.wicket.model.IModel;
|
import org.apache.wicket.model.IModel;
|
||||||
|
|
||||||
@ -12,9 +11,9 @@ public class PageTab implements Tab {
|
|||||||
|
|
||||||
private final IModel<String> titleModel;
|
private final IModel<String> titleModel;
|
||||||
|
|
||||||
private final Class<? extends Page>[] pageClasses;
|
private final Class<?>[] pageClasses;
|
||||||
|
|
||||||
public PageTab(IModel<String> titleModel, Class<? extends Page>...pageClasses) {
|
public PageTab(IModel<String> titleModel, Class<?>...pageClasses) {
|
||||||
Preconditions.checkArgument(pageClasses.length > 0, "At least one page class has to be provided.");
|
Preconditions.checkArgument(pageClasses.length > 0, "At least one page class has to be provided.");
|
||||||
|
|
||||||
this.titleModel = titleModel;
|
this.titleModel = titleModel;
|
||||||
@ -25,7 +24,7 @@ public class PageTab implements Tab {
|
|||||||
return titleModel;
|
return titleModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final Class<? extends Page>[] getPageClasses() {
|
protected final Class<?>[] getPageClasses() {
|
||||||
return pageClasses;
|
return pageClasses;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,7 +43,7 @@ public class PageTab implements Tab {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isActive(ListItem<Tab> item) {
|
public boolean isActive(ListItem<Tab> item) {
|
||||||
for (Class<? extends Page> pageClass: pageClasses) {
|
for (Class<?> pageClass: pageClasses) {
|
||||||
if (pageClass.isAssignableFrom(item.getPage().getClass()))
|
if (pageClass.isAssignableFrom(item.getPage().getClass()))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,10 +10,11 @@ public class PageTabComponent extends Panel {
|
|||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public PageTabComponent(String id, PageTab tab) {
|
public PageTabComponent(String id, PageTab tab) {
|
||||||
super(id);
|
super(id);
|
||||||
|
|
||||||
Link<?> pageLink = newLink("link", tab.getPageClasses()[0]);
|
Link<?> pageLink = newLink("link", (Class<? extends Page>) tab.getPageClasses()[0]);
|
||||||
add(pageLink);
|
add(pageLink);
|
||||||
pageLink.add(new Label("label", tab.getTitleModel()));
|
pageLink.add(new Label("label", tab.getTitleModel()));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import org.apache.wicket.markup.head.HeaderItem;
|
|||||||
import org.apache.wicket.request.resource.CssResourceReference;
|
import org.apache.wicket.request.resource.CssResourceReference;
|
||||||
import org.apache.wicket.request.resource.JavaScriptResourceReference;
|
import org.apache.wicket.request.resource.JavaScriptResourceReference;
|
||||||
|
|
||||||
import com.pmease.commons.util.EasyList;
|
import com.google.common.collect.Lists;
|
||||||
import com.pmease.commons.wicket.asset.bootstrap.BootstrapHeaderItem;
|
import com.pmease.commons.wicket.asset.bootstrap.BootstrapHeaderItem;
|
||||||
|
|
||||||
public class EditableResourceReference extends JavaScriptResourceReference {
|
public class EditableResourceReference extends JavaScriptResourceReference {
|
||||||
@ -24,7 +24,7 @@ public class EditableResourceReference extends JavaScriptResourceReference {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<? extends HeaderItem> getDependencies() {
|
public Iterable<? extends HeaderItem> getDependencies() {
|
||||||
return EasyList.of(
|
return Lists.newArrayList(
|
||||||
BootstrapHeaderItem.get(),
|
BootstrapHeaderItem.get(),
|
||||||
CssHeaderItem.forReference(new CssResourceReference(EditableResourceReference.class, "editable.css")));
|
CssHeaderItem.forReference(new CssResourceReference(EditableResourceReference.class, "editable.css")));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,9 +8,9 @@ import org.apache.wicket.markup.html.basic.Label;
|
|||||||
import org.apache.wicket.markup.html.form.DropDownChoice;
|
import org.apache.wicket.markup.html.form.DropDownChoice;
|
||||||
import org.apache.wicket.model.IModel;
|
import org.apache.wicket.model.IModel;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import com.pmease.commons.editable.EditContext;
|
import com.pmease.commons.editable.EditContext;
|
||||||
import com.pmease.commons.editable.PropertyEditContext;
|
import com.pmease.commons.editable.PropertyEditContext;
|
||||||
import com.pmease.commons.util.EasyList;
|
|
||||||
import com.pmease.commons.wicket.editable.EditableResourceBehavior;
|
import com.pmease.commons.wicket.editable.EditableResourceBehavior;
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
@ -48,7 +48,7 @@ public class NullableBooleanPropertyEditContext extends PropertyEditContext {
|
|||||||
setPropertyValue(null);
|
setPropertyValue(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}, EasyList.of("yes", "no")) {
|
}, Lists.newArrayList("yes", "no")) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onComponentTag(ComponentTag tag) {
|
protected void onComponentTag(ComponentTag tag) {
|
||||||
|
|||||||
@ -17,7 +17,6 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
import com.pmease.commons.git.Git;
|
import com.pmease.commons.git.Git;
|
||||||
import com.pmease.gitop.core.manager.RepositoryManager;
|
import com.pmease.gitop.core.manager.RepositoryManager;
|
||||||
import com.pmease.gitop.core.manager.UserManager;
|
|
||||||
import com.pmease.gitop.core.model.Repository;
|
import com.pmease.gitop.core.model.Repository;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@ -31,16 +30,18 @@ public class GitServlet extends HttpServlet {
|
|||||||
private final RepositoryManager repositoryManager;
|
private final RepositoryManager repositoryManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public GitServlet(UserManager userManager, RepositoryManager repositoryManager) {
|
public GitServlet(RepositoryManager repositoryManager) {
|
||||||
this.repositoryManager = repositoryManager;
|
this.repositoryManager = repositoryManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Repository getRepository(HttpServletResponse response, String repoInfo) throws IOException {
|
private Repository getRepository(HttpServletRequest request, HttpServletResponse response, String repoInfo) throws IOException {
|
||||||
String ownerName = StringUtils.substringBefore(repoInfo, "/");
|
String ownerName = StringUtils.substringBefore(repoInfo, "/");
|
||||||
String repositoryName = StringUtils.substringAfter(repoInfo, "/");
|
String repositoryName = StringUtils.substringAfter(repoInfo, "/");
|
||||||
|
|
||||||
if (StringUtils.isBlank(ownerName) || StringUtils.isBlank(repositoryName)) {
|
if (StringUtils.isBlank(ownerName) || StringUtils.isBlank(repositoryName)) {
|
||||||
String message = "Expecting url of format http(s)://<server>:<port>/<owner name>/<repository name>";
|
String urlRoot = StringUtils.substringBeforeLast(request.getRequestURL().toString(), "?");
|
||||||
|
urlRoot = StringUtils.substringBeforeLast(urlRoot, "/");
|
||||||
|
String message = "Expecting url of format " + urlRoot + "/<owner name>/<repository name>";
|
||||||
logger.error("Error serving git request: " + message);
|
logger.error("Error serving git request: " + message);
|
||||||
response.sendError(HttpServletResponse.SC_BAD_REQUEST, message);
|
response.sendError(HttpServletResponse.SC_BAD_REQUEST, message);
|
||||||
return null;
|
return null;
|
||||||
@ -69,7 +70,7 @@ public class GitServlet extends HttpServlet {
|
|||||||
String service = StringUtils.substringAfterLast(pathInfo, "/");
|
String service = StringUtils.substringAfterLast(pathInfo, "/");
|
||||||
|
|
||||||
String repoInfo = StringUtils.substringBeforeLast(pathInfo, "/");
|
String repoInfo = StringUtils.substringBeforeLast(pathInfo, "/");
|
||||||
Repository repository = getRepository(resp, repoInfo);
|
Repository repository = getRepository(req, resp, repoInfo);
|
||||||
|
|
||||||
if (repository != null) {
|
if (repository != null) {
|
||||||
doNotCache(resp);
|
doNotCache(resp);
|
||||||
@ -106,7 +107,7 @@ public class GitServlet extends HttpServlet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String repoInfo = pathInfo.substring(0, pathInfo.length() - INFO_REFS.length());
|
String repoInfo = pathInfo.substring(0, pathInfo.length() - INFO_REFS.length());
|
||||||
Repository repository = getRepository(resp, repoInfo);
|
Repository repository = getRepository(req, resp, repoInfo);
|
||||||
if (repository != null) {
|
if (repository != null) {
|
||||||
doNotCache(resp);
|
doNotCache(resp);
|
||||||
String service = req.getParameter("service");
|
String service = req.getParameter("service");
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
package com.pmease.gitop.core.gatekeeper;
|
package com.pmease.gitop.core.gatekeeper;
|
||||||
|
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
import com.pmease.commons.editable.annotation.Editable;
|
import com.pmease.commons.editable.annotation.Editable;
|
||||||
import com.pmease.commons.util.EasySet;
|
|
||||||
import com.pmease.gitop.core.model.MergeRequest;
|
import com.pmease.gitop.core.model.MergeRequest;
|
||||||
import com.pmease.gitop.core.model.User;
|
import com.pmease.gitop.core.model.User;
|
||||||
import com.pmease.gitop.core.model.Vote;
|
import com.pmease.gitop.core.model.Vote;
|
||||||
@ -17,7 +17,7 @@ public class ApprovedByRepositoryOwner extends AbstractGateKeeper {
|
|||||||
Vote.Result result = repositoryOwner.checkVoteSince(request.getBaseUpdate());
|
Vote.Result result = repositoryOwner.checkVoteSince(request.getBaseUpdate());
|
||||||
|
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
request.inviteToVote(EasySet.of(repositoryOwner), 1);
|
request.inviteToVote(Sets.newHashSet(repositoryOwner), 1);
|
||||||
return pending("To be approved by user '" + repositoryOwner.getName() + "'.");
|
return pending("To be approved by user '" + repositoryOwner.getName() + "'.");
|
||||||
} else if (result.isAccept()) {
|
} else if (result.isAccept()) {
|
||||||
return accept("Approved by user '" + repositoryOwner.getName() + "'.");
|
return accept("Approved by user '" + repositoryOwner.getName() + "'.");
|
||||||
|
|||||||
@ -2,9 +2,9 @@ package com.pmease.gitop.core.gatekeeper;
|
|||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
import com.pmease.commons.editable.annotation.Editable;
|
import com.pmease.commons.editable.annotation.Editable;
|
||||||
import com.pmease.commons.loader.AppLoader;
|
import com.pmease.commons.loader.AppLoader;
|
||||||
import com.pmease.commons.util.EasySet;
|
|
||||||
import com.pmease.gitop.core.manager.UserManager;
|
import com.pmease.gitop.core.manager.UserManager;
|
||||||
import com.pmease.gitop.core.model.MergeRequest;
|
import com.pmease.gitop.core.model.MergeRequest;
|
||||||
import com.pmease.gitop.core.model.User;
|
import com.pmease.gitop.core.model.User;
|
||||||
@ -33,7 +33,7 @@ public class ApprovedBySpecifiedUser extends AbstractGateKeeper {
|
|||||||
|
|
||||||
Vote.Result result = user.checkVoteSince(request.getBaseUpdate());
|
Vote.Result result = user.checkVoteSince(request.getBaseUpdate());
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
request.inviteToVote(EasySet.of(user), 1);
|
request.inviteToVote(Sets.newHashSet(user), 1);
|
||||||
return pending("To be approved by user '" + user.getName() + "'.");
|
return pending("To be approved by user '" + user.getName() + "'.");
|
||||||
} else if (result.isAccept()) {
|
} else if (result.isAccept()) {
|
||||||
return accept("Approved by user '" + user.getName() + "'.");
|
return accept("Approved by user '" + user.getName() + "'.");
|
||||||
|
|||||||
@ -2,7 +2,7 @@ package com.pmease.gitop.core.gatekeeper;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.pmease.commons.util.EasyList;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
public abstract class CheckResult {
|
public abstract class CheckResult {
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ public abstract class CheckResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CheckResult(String reason) {
|
public CheckResult(String reason) {
|
||||||
this.reasons = EasyList.of(reason);
|
this.reasons = Lists.newArrayList(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getReasons() {
|
public List<String> getReasons() {
|
||||||
|
|||||||
@ -93,8 +93,8 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.6</source>
|
<source>1.7</source>
|
||||||
<target>1.6</target>
|
<target>1.7</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
|||||||
@ -40,8 +40,8 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.6</source>
|
<source>1.7</source>
|
||||||
<target>1.6</target>
|
<target>1.7</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user