mirror of
				https://github.com/scm-manager/scm-manager.git
				synced 2025-10-31 18:46:07 +01:00 
			
		
		
		
	Fix build warnings (#1562)
Co-authored-by: René Pfeuffer <rene.pfeuffer@cloudogu.com>
This commit is contained in:
		| @@ -39,10 +39,10 @@ import static java.util.Collections.unmodifiableCollection; | |||||||
|  *   .doThrow() |  *   .doThrow() | ||||||
|  *   .violation("name or alias must not be empty if not anonymous", "myParameter", "name") |  *   .violation("name or alias must not be empty if not anonymous", "myParameter", "name") | ||||||
|  *   .violation("name or alias must not be empty if not anonymous", "myParameter", "alias") |  *   .violation("name or alias must not be empty if not anonymous", "myParameter", "alias") | ||||||
|  *   .when(myParameter.getName() == null && myParameter.getAlias() == null && !myParameter.isAnonymous()) |  *   .when(myParameter.getName() == null && myParameter.getAlias() == null && !myParameter.isAnonymous()) | ||||||
|  *   .andThrow() |  *   .andThrow() | ||||||
|  *   .violation("name must be empty if anonymous", "myParameter", "name") |  *   .violation("name must be empty if anonymous", "myParameter", "name") | ||||||
|  *   .when(myParameter.getName() != null && myParameter.isAnonymous()); |  *   .when(myParameter.getName() != null && myParameter.isAnonymous()); | ||||||
|  * </pre> |  * </pre> | ||||||
|  * Mind that using this way you do not have to use if-else constructs. |  * Mind that using this way you do not have to use if-else constructs. | ||||||
|  */ |  */ | ||||||
|   | |||||||
| @@ -32,9 +32,9 @@ package sonia.scm; | |||||||
| public enum ServletContainer | public enum ServletContainer | ||||||
| { | { | ||||||
| 	SCM_SERVER, | 	SCM_SERVER, | ||||||
| 	/** Jetty version <= 6 */ | 	/** Jetty version <= 6 */ | ||||||
| 	JETTY, | 	JETTY, | ||||||
| 	/** Jetty version >= 7 */ | 	/** Jetty version >= 7 */ | ||||||
| 	ECLIPSE_JETTY, | 	ECLIPSE_JETTY, | ||||||
| 	TOMCAT, | 	TOMCAT, | ||||||
| 	GLASSFISH, | 	GLASSFISH, | ||||||
|   | |||||||
| @@ -207,8 +207,7 @@ public class ScmConfiguration implements Configuration { | |||||||
|   private String mailDomainName = DEFAULT_MAIL_DOMAIN_NAME; |   private String mailDomainName = DEFAULT_MAIL_DOMAIN_NAME; | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * Calls the {@link sonia.scm.ConfigChangedListener#configChanged(Object)} |    * Fires the {@link ScmConfigurationChangedEvent}. | ||||||
|    * method of all registered listeners. |  | ||||||
|    */ |    */ | ||||||
|   public void fireChangeEvent() { |   public void fireChangeEvent() { | ||||||
|     if (logger.isDebugEnabled()) { |     if (logger.isDebugEnabled()) { | ||||||
| @@ -294,7 +293,7 @@ public class ScmConfiguration implements Configuration { | |||||||
|    * <li><b>os</b> = Operation System</li> |    * <li><b>os</b> = Operation System</li> | ||||||
|    * <li><b>arch</b> = Architecture</li> |    * <li><b>arch</b> = Architecture</li> | ||||||
|    * </ul> |    * </ul> | ||||||
|    * For example http://plugins.scm-manager.org/scm-plugin-backend/api/{version}/plugins?os={os}&arch={arch}&snapshot=false |    * For example `http://plugins.scm-manager.org/scm-plugin-backend/api/{version}/plugins?os={os}&arch={arch}&snapshot=false` | ||||||
|    * |    * | ||||||
|    * @return the complete plugin url. |    * @return the complete plugin url. | ||||||
|    */ |    */ | ||||||
| @@ -313,6 +312,7 @@ public class ScmConfiguration implements Configuration { | |||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * Returns the mail domain, that will be used to create e-mail addresses for users without one whenever one is required. |    * Returns the mail domain, that will be used to create e-mail addresses for users without one whenever one is required. | ||||||
|  |    * | ||||||
|    * @return default mail domain |    * @return default mail domain | ||||||
|    * @since 2.8.0 |    * @since 2.8.0 | ||||||
|    */ |    */ | ||||||
|   | |||||||
| @@ -25,7 +25,7 @@ | |||||||
| package sonia.scm.filter; | package sonia.scm.filter; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Configuration for the {@link GZipFilter}. |  * Configuration for the {@link GZipResponseFilter}. | ||||||
|  * |  * | ||||||
|  * @author Sebastian Sdorra |  * @author Sebastian Sdorra | ||||||
|  * @since 1.16 |  * @since 1.16 | ||||||
|   | |||||||
| @@ -21,7 +21,7 @@ | |||||||
|  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||||
|  * SOFTWARE. |  * SOFTWARE. | ||||||
|  */ |  */ | ||||||
|      |  | ||||||
| package sonia.scm.io; | package sonia.scm.io; | ||||||
|  |  | ||||||
| //~--- non-JDK imports -------------------------------------------------------- | //~--- non-JDK imports -------------------------------------------------------- | ||||||
| @@ -37,14 +37,13 @@ import java.io.ObjectInputStream; | |||||||
| import java.io.ObjectStreamClass; | import java.io.ObjectStreamClass; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * {@link ObjectInputStream} implementation which uses the context class loader  |  * {@link ObjectInputStream} implementation which uses the context class loader | ||||||
|  * to resolve classes. |  * to resolve classes. | ||||||
|  * |  * | ||||||
|  * @author Sebastian Sdorra |  * @author Sebastian Sdorra | ||||||
|  * @since 1.36 |  * @since 1.36 | ||||||
|  */ |  */ | ||||||
| public class ScmObjectInputStream extends ObjectInputStream | public class ScmObjectInputStream extends ObjectInputStream { | ||||||
| { |  | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * the logger for ScmObjectInputStream |    * the logger for ScmObjectInputStream | ||||||
| @@ -54,11 +53,7 @@ public class ScmObjectInputStream extends ObjectInputStream | |||||||
|  |  | ||||||
|   //~--- constructors --------------------------------------------------------- |   //~--- constructors --------------------------------------------------------- | ||||||
|  |  | ||||||
|   /** |   public ScmObjectInputStream(InputStream stream) throws IOException { | ||||||
|    * {@inheritDoc} |  | ||||||
|    */ |  | ||||||
|   public ScmObjectInputStream(InputStream stream) throws IOException |  | ||||||
|   { |  | ||||||
|     super(stream); |     super(stream); | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -69,23 +64,18 @@ public class ScmObjectInputStream extends ObjectInputStream | |||||||
|    */ |    */ | ||||||
|   @Override |   @Override | ||||||
|   protected Class<?> resolveClass(ObjectStreamClass desc) |   protected Class<?> resolveClass(ObjectStreamClass desc) | ||||||
|     throws IOException, ClassNotFoundException |     throws IOException, ClassNotFoundException { | ||||||
|   { |  | ||||||
|     Class<?> clazz = null; |     Class<?> clazz = null; | ||||||
|     ClassLoader classLoader = getClassLoader(); |     ClassLoader classLoader = getClassLoader(); | ||||||
|  |  | ||||||
|     try |     try { | ||||||
|     { |  | ||||||
|       clazz = classLoader.loadClass(desc.getName()); |       clazz = classLoader.loadClass(desc.getName()); | ||||||
|     } |     } catch (ClassNotFoundException ex) { | ||||||
|     catch (ClassNotFoundException ex) |  | ||||||
|     { |  | ||||||
|       // do not log the exception, because the class  |       // do not log the exception, because the class  | ||||||
|       // is mostly found by the parent method. |       // is mostly found by the parent method. | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (clazz == null) |     if (clazz == null) { | ||||||
|     { |  | ||||||
|       clazz = super.resolveClass(desc); |       clazz = super.resolveClass(desc); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -99,15 +89,12 @@ public class ScmObjectInputStream extends ObjectInputStream | |||||||
|    * is not available the method will fall back to the class loader which has |    * is not available the method will fall back to the class loader which has | ||||||
|    * load this class. |    * load this class. | ||||||
|    * |    * | ||||||
|    * |  | ||||||
|    * @return context class loader or default class loader |    * @return context class loader or default class loader | ||||||
|    */ |    */ | ||||||
|   private ClassLoader getClassLoader() |   private ClassLoader getClassLoader() { | ||||||
|   { |  | ||||||
|     ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); |     ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); | ||||||
|  |  | ||||||
|     if (classLoader == null) |     if (classLoader == null) { | ||||||
|     { |  | ||||||
|       logger.debug("could not find context class loader, fall back to default"); |       logger.debug("could not find context class loader, fall back to default"); | ||||||
|       classLoader = ScmObjectInputStream.class.getClassLoader(); |       classLoader = ScmObjectInputStream.class.getClassLoader(); | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -21,7 +21,7 @@ | |||||||
|  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||||
|  * SOFTWARE. |  * SOFTWARE. | ||||||
|  */ |  */ | ||||||
|      |  | ||||||
| package sonia.scm.net.ahc; | package sonia.scm.net.ahc; | ||||||
|  |  | ||||||
| //~--- JDK imports ------------------------------------------------------------ | //~--- JDK imports ------------------------------------------------------------ | ||||||
| @@ -29,9 +29,8 @@ package sonia.scm.net.ahc; | |||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Advanced client for http operations. The {@link AdvancedHttpClient} replaces |  * Advanced client for http operations.The {@link AdvancedHttpClient} offers | ||||||
|  * the much more simpler implementation {@link sonia.scm.net.HttpClient}. The |  * a fluid interface for handling most common | ||||||
|  * {@link AdvancedHttpClient} offers a fluid interface for handling most common |  | ||||||
|  * http operations. The {@link AdvancedHttpClient} can be injected by the |  * http operations. The {@link AdvancedHttpClient} can be injected by the | ||||||
|  * default injection mechanism of SCM-Manager. |  * default injection mechanism of SCM-Manager. | ||||||
|  * <p> </p> |  * <p> </p> | ||||||
| @@ -62,36 +61,30 @@ import java.io.IOException; | |||||||
|  * </code></pre> |  * </code></pre> | ||||||
|  * |  * | ||||||
|  * @author Sebastian Sdorra |  * @author Sebastian Sdorra | ||||||
|  * @since 1.46 |  | ||||||
|  * |  | ||||||
|  * @apiviz.landmark |  * @apiviz.landmark | ||||||
|  |  * @since 1.46 | ||||||
|  */ |  */ | ||||||
| public abstract class AdvancedHttpClient | public abstract class AdvancedHttpClient { | ||||||
| { |  | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * Creates a {@link ContentTransformer} for the given Content-Type. |    * Creates a {@link ContentTransformer} for the given Content-Type. | ||||||
|    * |    * | ||||||
|    * @param type object type |    * @param type        object type | ||||||
|    * @param contentType content-type |    * @param contentType content-type | ||||||
|    * @throws ContentTransformerNotFoundException if no |  | ||||||
|    *   {@link ContentTransformer} could be found for the content-type |  | ||||||
|    * |  | ||||||
|    * @return {@link ContentTransformer} |    * @return {@link ContentTransformer} | ||||||
|  |    * @throws ContentTransformerNotFoundException if no | ||||||
|  |    *                                             {@link ContentTransformer} could be found for the content-type | ||||||
|    */ |    */ | ||||||
|   protected abstract ContentTransformer createTransformer(Class<?> type, |   protected abstract ContentTransformer createTransformer(Class<?> type, | ||||||
|     String contentType); |                                                           String contentType); | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * Executes the given request and returns the http response. Implementation |    * Executes the given request and returns the http response. Implementation | ||||||
|    * have to check, if the instance if from type |    * have to check, if the instance if from type | ||||||
|    * {@link AdvancedHttpRequestWithBody} in order to handle request contents. |    * {@link AdvancedHttpRequestWithBody} in order to handle request contents. | ||||||
|    * |    * | ||||||
|    * |  | ||||||
|    * @param request request to execute |    * @param request request to execute | ||||||
|    * |  | ||||||
|    * @return http response |    * @return http response | ||||||
|    * |  | ||||||
|    * @throws IOException |    * @throws IOException | ||||||
|    */ |    */ | ||||||
|   protected abstract AdvancedHttpResponse request(BaseHttpRequest<?> request) |   protected abstract AdvancedHttpResponse request(BaseHttpRequest<?> request) | ||||||
| @@ -100,26 +93,20 @@ public abstract class AdvancedHttpClient | |||||||
|   /** |   /** | ||||||
|    * Returns a builder for a DELETE request. |    * Returns a builder for a DELETE request. | ||||||
|    * |    * | ||||||
|    * |  | ||||||
|    * @param url request url |    * @param url request url | ||||||
|    * |  | ||||||
|    * @return request builder |    * @return request builder | ||||||
|    */ |    */ | ||||||
|   public AdvancedHttpRequestWithBody delete(String url) |   public AdvancedHttpRequestWithBody delete(String url) { | ||||||
|   { |  | ||||||
|     return new AdvancedHttpRequestWithBody(this, HttpMethod.DELETE, url); |     return new AdvancedHttpRequestWithBody(this, HttpMethod.DELETE, url); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * Returns a builder for a HEAD request. |    * Returns a builder for a HEAD request. | ||||||
|    * |    * | ||||||
|    * |  | ||||||
|    * @param url request url |    * @param url request url | ||||||
|    * |  | ||||||
|    * @return request builder |    * @return request builder | ||||||
|    */ |    */ | ||||||
|   public AdvancedHttpRequest head(String url) |   public AdvancedHttpRequest head(String url) { | ||||||
|   { |  | ||||||
|     return new AdvancedHttpRequest(this, HttpMethod.HEAD, url); |     return new AdvancedHttpRequest(this, HttpMethod.HEAD, url); | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -128,53 +115,41 @@ public abstract class AdvancedHttpClient | |||||||
|    * every method is supported by the underlying implementation of the http |    * every method is supported by the underlying implementation of the http | ||||||
|    * client. |    * client. | ||||||
|    * |    * | ||||||
|    * |  | ||||||
|    * @param method http method |    * @param method http method | ||||||
|    * @param url request url |    * @param url    request url | ||||||
|    * |  | ||||||
|    * @return request builder |    * @return request builder | ||||||
|    */ |    */ | ||||||
|   public AdvancedHttpRequestWithBody method(String method, String url) |   public AdvancedHttpRequestWithBody method(String method, String url) { | ||||||
|   { |  | ||||||
|     return new AdvancedHttpRequestWithBody(this, method, url); |     return new AdvancedHttpRequestWithBody(this, method, url); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * Returns a builder for a OPTIONS request. |    * Returns a builder for a OPTIONS request. | ||||||
|    * |    * | ||||||
|    * |  | ||||||
|    * @param url request url |    * @param url request url | ||||||
|    * |  | ||||||
|    * @return request builder |    * @return request builder | ||||||
|    */ |    */ | ||||||
|   public AdvancedHttpRequestWithBody options(String url) |   public AdvancedHttpRequestWithBody options(String url) { | ||||||
|   { |  | ||||||
|     return new AdvancedHttpRequestWithBody(this, HttpMethod.OPTIONS, url); |     return new AdvancedHttpRequestWithBody(this, HttpMethod.OPTIONS, url); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * Returns a builder for a POST request. |    * Returns a builder for a POST request. | ||||||
|    * |    * | ||||||
|    * |  | ||||||
|    * @param url request url |    * @param url request url | ||||||
|    * |  | ||||||
|    * @return request builder |    * @return request builder | ||||||
|    */ |    */ | ||||||
|   public AdvancedHttpRequestWithBody post(String url) |   public AdvancedHttpRequestWithBody post(String url) { | ||||||
|   { |  | ||||||
|     return new AdvancedHttpRequestWithBody(this, HttpMethod.POST, url); |     return new AdvancedHttpRequestWithBody(this, HttpMethod.POST, url); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * Returns a builder for a PUT request. |    * Returns a builder for a PUT request. | ||||||
|    * |    * | ||||||
|    * |  | ||||||
|    * @param url request url |    * @param url request url | ||||||
|    * |  | ||||||
|    * @return request builder |    * @return request builder | ||||||
|    */ |    */ | ||||||
|   public AdvancedHttpRequestWithBody put(String url) |   public AdvancedHttpRequestWithBody put(String url) { | ||||||
|   { |  | ||||||
|     return new AdvancedHttpRequestWithBody(this, HttpMethod.PUT, url); |     return new AdvancedHttpRequestWithBody(this, HttpMethod.PUT, url); | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -183,13 +158,10 @@ public abstract class AdvancedHttpClient | |||||||
|   /** |   /** | ||||||
|    * Returns a builder for a GET request. |    * Returns a builder for a GET request. | ||||||
|    * |    * | ||||||
|    * |  | ||||||
|    * @param url request url |    * @param url request url | ||||||
|    * |  | ||||||
|    * @return request builder |    * @return request builder | ||||||
|    */ |    */ | ||||||
|   public AdvancedHttpRequest get(String url) |   public AdvancedHttpRequest get(String url) { | ||||||
|   { |  | ||||||
|     return new AdvancedHttpRequest(this, HttpMethod.GET, url); |     return new AdvancedHttpRequest(this, HttpMethod.GET, url); | ||||||
|   } |   } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -31,7 +31,7 @@ import sonia.scm.plugin.ExtensionPoint; | |||||||
|  * Transforms {@link ByteSource} content to an object and vice versa. This class |  * Transforms {@link ByteSource} content to an object and vice versa. This class | ||||||
|  * is an extension point, this means that plugins can define their own |  * is an extension point, this means that plugins can define their own | ||||||
|  * {@link ContentTransformer} implementations by implementing the interface and |  * {@link ContentTransformer} implementations by implementing the interface and | ||||||
|  * annotate the implementation with the {@link sonia.scm.plugin.ext.Extension}  |  * annotate the implementation with the {@link sonia.scm.plugin.Extension} | ||||||
|  * annotation. |  * annotation. | ||||||
|  * |  * | ||||||
|  * @author Sebastian Sdorra |  * @author Sebastian Sdorra | ||||||
|   | |||||||
| @@ -21,7 +21,7 @@ | |||||||
|  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||||
|  * SOFTWARE. |  * SOFTWARE. | ||||||
|  */ |  */ | ||||||
|      |  | ||||||
| package sonia.scm.repository; | package sonia.scm.repository; | ||||||
|  |  | ||||||
| //~--- non-JDK imports -------------------------------------------------------- | //~--- non-JDK imports -------------------------------------------------------- | ||||||
| @@ -37,19 +37,15 @@ import sonia.scm.util.AssertUtil; | |||||||
|  * |  * | ||||||
|  * @author Sebastian Sdorra |  * @author Sebastian Sdorra | ||||||
|  */ |  */ | ||||||
| public abstract class AbstractRepositoryManager implements RepositoryManager | public abstract class AbstractRepositoryManager implements RepositoryManager { | ||||||
| { |  | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * Sends a {@link RepositoryHookEvent} to each registered |    * Sends the {@link RepositoryHookEvent} to the {@link ScmEventBus}. | ||||||
|    * {@link RepositoryHook} and sends the {@link RepositoryHookEvent} to |  | ||||||
|    * the {@link ScmEventBus}. |  | ||||||
|    * |    * | ||||||
|    * @param event event to be fired |    * @param event event to be fired | ||||||
|    */ |    */ | ||||||
|   @Override |   @Override | ||||||
|   public void fireHookEvent(RepositoryHookEvent event) |   public void fireHookEvent(RepositoryHookEvent event) { | ||||||
|   { |  | ||||||
|     AssertUtil.assertIsNotNull(event); |     AssertUtil.assertIsNotNull(event); | ||||||
|     AssertUtil.assertIsNotNull(event.getRepository()); |     AssertUtil.assertIsNotNull(event.getRepository()); | ||||||
|     AssertUtil.assertIsNotNull(event.getType()); |     AssertUtil.assertIsNotNull(event.getType()); | ||||||
| @@ -64,13 +60,12 @@ public abstract class AbstractRepositoryManager implements RepositoryManager | |||||||
|   /** |   /** | ||||||
|    * Send a {@link RepositoryEvent} to the {@link ScmEventBus}. |    * Send a {@link RepositoryEvent} to the {@link ScmEventBus}. | ||||||
|    * |    * | ||||||
|    * @param event type of change event |    * @param event         type of change event | ||||||
|    * @param repository repository that has changed |    * @param repository    repository that has changed | ||||||
|    * @param oldRepository old repository |    * @param oldRepository old repository | ||||||
|    */ |    */ | ||||||
|   protected void fireEvent(HandlerEventType event, Repository repository, |   protected void fireEvent(HandlerEventType event, Repository repository, | ||||||
|     Repository oldRepository) |                            Repository oldRepository) { | ||||||
|   { |  | ||||||
|     ScmEventBus.getInstance().post(new RepositoryModificationEvent(event, repository, |     ScmEventBus.getInstance().post(new RepositoryModificationEvent(event, repository, | ||||||
|       oldRepository)); |       oldRepository)); | ||||||
|   } |   } | ||||||
| @@ -78,25 +73,21 @@ public abstract class AbstractRepositoryManager implements RepositoryManager | |||||||
|   /** |   /** | ||||||
|    * Send a {@link RepositoryEvent} to the {@link ScmEventBus}. |    * Send a {@link RepositoryEvent} to the {@link ScmEventBus}. | ||||||
|    * |    * | ||||||
|    * @param event type of change event |    * @param event      type of change event | ||||||
|    * @param repository repository that has changed |    * @param repository repository that has changed | ||||||
|    */ |    */ | ||||||
|   protected void fireEvent(HandlerEventType event, Repository repository) |   protected void fireEvent(HandlerEventType event, Repository repository) { | ||||||
|   { |  | ||||||
|     ScmEventBus.getInstance().post(new RepositoryEvent(event, repository)); |     ScmEventBus.getInstance().post(new RepositoryEvent(event, repository)); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * Prepare a hook event before it is fired to the event system of SCM-Manager. |    * Prepare a hook event before it is fired to the event system of SCM-Manager. | ||||||
|    * |    * | ||||||
|    * |  | ||||||
|    * @param event hook event |    * @param event hook event | ||||||
|    * @since 1.26 |  | ||||||
|    * |  | ||||||
|    * @return |    * @return | ||||||
|  |    * @since 1.26 | ||||||
|    */ |    */ | ||||||
|   protected RepositoryHookEvent prepareHookEvent(RepositoryHookEvent event) |   protected RepositoryHookEvent prepareHookEvent(RepositoryHookEvent event) { | ||||||
|   { |  | ||||||
|     return event; |     return event; | ||||||
|   } |   } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -24,6 +24,7 @@ | |||||||
|  |  | ||||||
| package sonia.scm.repository; | package sonia.scm.repository; | ||||||
|  |  | ||||||
|  | import lombok.EqualsAndHashCode; | ||||||
| import lombok.Value; | import lombok.Value; | ||||||
|  |  | ||||||
| import java.util.stream.Stream; | import java.util.stream.Stream; | ||||||
| @@ -31,8 +32,9 @@ import java.util.stream.Stream; | |||||||
| import static java.util.stream.Stream.of; | import static java.util.stream.Stream.of; | ||||||
|  |  | ||||||
| @Value | @Value | ||||||
|  | @EqualsAndHashCode(callSuper=false) | ||||||
| public class Added extends Modification { | public class Added extends Modification { | ||||||
|   private final String path; |   String path; | ||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   Stream<String> getEffectedPaths() { |   Stream<String> getEffectedPaths() { | ||||||
|   | |||||||
| @@ -24,6 +24,7 @@ | |||||||
|  |  | ||||||
| package sonia.scm.repository; | package sonia.scm.repository; | ||||||
|  |  | ||||||
|  | import lombok.EqualsAndHashCode; | ||||||
| import lombok.Value; | import lombok.Value; | ||||||
|  |  | ||||||
| import java.util.stream.Stream; | import java.util.stream.Stream; | ||||||
| @@ -31,9 +32,10 @@ import java.util.stream.Stream; | |||||||
| import static java.util.stream.Stream.of; | import static java.util.stream.Stream.of; | ||||||
|  |  | ||||||
| @Value | @Value | ||||||
|  | @EqualsAndHashCode(callSuper=false) | ||||||
| public class Copied extends Modification { | public class Copied extends Modification { | ||||||
|   private final String sourcePath; |   String sourcePath; | ||||||
|   private final String targetPath; |   String targetPath; | ||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   Stream<String> getEffectedPaths() { |   Stream<String> getEffectedPaths() { | ||||||
|   | |||||||
| @@ -24,6 +24,7 @@ | |||||||
|  |  | ||||||
| package sonia.scm.repository; | package sonia.scm.repository; | ||||||
|  |  | ||||||
|  | import lombok.EqualsAndHashCode; | ||||||
| import lombok.Value; | import lombok.Value; | ||||||
|  |  | ||||||
| import java.util.stream.Stream; | import java.util.stream.Stream; | ||||||
| @@ -31,8 +32,9 @@ import java.util.stream.Stream; | |||||||
| import static java.util.stream.Stream.of; | import static java.util.stream.Stream.of; | ||||||
|  |  | ||||||
| @Value | @Value | ||||||
|  | @EqualsAndHashCode(callSuper=false) | ||||||
| public class Modified extends Modification { | public class Modified extends Modification { | ||||||
|   private final String path; |   String path; | ||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   Stream<String> getEffectedPaths() { |   Stream<String> getEffectedPaths() { | ||||||
|   | |||||||
| @@ -24,6 +24,7 @@ | |||||||
|  |  | ||||||
| package sonia.scm.repository; | package sonia.scm.repository; | ||||||
|  |  | ||||||
|  | import lombok.EqualsAndHashCode; | ||||||
| import lombok.Value; | import lombok.Value; | ||||||
|  |  | ||||||
| import java.util.stream.Stream; | import java.util.stream.Stream; | ||||||
| @@ -31,8 +32,9 @@ import java.util.stream.Stream; | |||||||
| import static java.util.stream.Stream.of; | import static java.util.stream.Stream.of; | ||||||
|  |  | ||||||
| @Value | @Value | ||||||
|  | @EqualsAndHashCode(callSuper=false) | ||||||
| public class Removed extends Modification { | public class Removed extends Modification { | ||||||
|   private final String path; |   String path; | ||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   Stream<String> getEffectedPaths() { |   Stream<String> getEffectedPaths() { | ||||||
|   | |||||||
| @@ -24,6 +24,7 @@ | |||||||
|  |  | ||||||
| package sonia.scm.repository; | package sonia.scm.repository; | ||||||
|  |  | ||||||
|  | import lombok.EqualsAndHashCode; | ||||||
| import lombok.Value; | import lombok.Value; | ||||||
|  |  | ||||||
| import java.util.stream.Stream; | import java.util.stream.Stream; | ||||||
| @@ -31,9 +32,10 @@ import java.util.stream.Stream; | |||||||
| import static java.util.stream.Stream.of; | import static java.util.stream.Stream.of; | ||||||
|  |  | ||||||
| @Value | @Value | ||||||
|  | @EqualsAndHashCode(callSuper=false) | ||||||
| public class Renamed extends Modification { | public class Renamed extends Modification { | ||||||
|   private final String oldPath; |   String oldPath; | ||||||
|   private final String newPath; |   String newPath; | ||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   Stream<String> getEffectedPaths() { |   Stream<String> getEffectedPaths() { | ||||||
|   | |||||||
| @@ -38,7 +38,7 @@ public class RepositoryHookEvent | |||||||
| { | { | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * Constructs a new {@link ExtendedRepositoryHookEvent}. |    * Constructs a new {@link RepositoryHookEvent}. | ||||||
|    * |    * | ||||||
|    * @param context context of current hook |    * @param context context of current hook | ||||||
|    * @param repository |    * @param repository | ||||||
|   | |||||||
| @@ -100,7 +100,7 @@ public interface RepositoryManager | |||||||
|  |  | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * Creates a new repository and afterwards executes the logic from the {@param afterCreation}. |    * Creates a new repository and afterwards executes the logic from the afterCreation. | ||||||
|    * |    * | ||||||
|    * @param repository the repository to create |    * @param repository the repository to create | ||||||
|    * @param afterCreation consumer which is executed after the repository was created |    * @param afterCreation consumer which is executed after the repository was created | ||||||
|   | |||||||
| @@ -53,12 +53,12 @@ import java.util.Set; | |||||||
|  * |  * | ||||||
|  * If the merge is successful, the result will look like this: |  * If the merge is successful, the result will look like this: | ||||||
|  * <pre><code> |  * <pre><code> | ||||||
|  *                            O    <- Merge result (new head of integration_branch) |  *                           O    <- Merge result (new head of integration_branch) | ||||||
|  *                            |\ |  *                           |\ | ||||||
|  *                            | \ |  *                           | \ | ||||||
|  *  old integration_branch -> O  O <- feature_branch |  * old integration_branch -> O  O <- feature_branch | ||||||
|  *                            |  | |  *                           |  | | ||||||
|  *                            O  O |  *                           O  O | ||||||
|  * </code></pre> |  * </code></pre> | ||||||
|  * |  * | ||||||
|  * To check whether they can be merged without conflicts beforehand do this: |  * To check whether they can be merged without conflicts beforehand do this: | ||||||
|   | |||||||
| @@ -41,18 +41,18 @@ import java.io.File; | |||||||
|  * implemented: |  * implemented: | ||||||
|  * |  * | ||||||
|  * <dl> |  * <dl> | ||||||
|  *   <dt>{@link #initialize(C, File, String)}</dt> |  *   <dt>{@link SimpleWorkingCopyFactory#initialize(C, File, String)}</dt> | ||||||
|  *   <dd>Creates a new clone of the repository for the given context in the given |  *   <dd>Creates a new clone of the repository for the given context in the given | ||||||
|  *     directory with the given branch checked out (if branches are supported).</dd> |  *     directory with the given branch checked out (if branches are supported).</dd> | ||||||
|  *   <dt>{@link #reclaim(C, File, String)}</dt> |  *   <dt>{@link SimpleWorkingCopyFactory#reclaim(C, File, String)}</dt> | ||||||
|  *   <dd>Reclaim the working directory with a already checked out clone of the |  *   <dd>Reclaim the working directory with a already checked out clone of the | ||||||
|  *     repository given in the context, so that the directory is not modified in |  *     repository given in the context, so that the directory is not modified in | ||||||
|  *     respect to the repository and the given branch is checked out (if branches |  *     respect to the repository and the given branch is checked out (if branches | ||||||
|  *     are supported).</dd> |  *     are supported).</dd> | ||||||
|  *   <dt>{@link #closeWorkingCopy(W)}</dt> |  *   <dt>{@link SimpleWorkingCopyFactory#closeWorkingCopy(W)}</dt> | ||||||
|  *   <dd>Closes resources allocated for the working copy, so that the directory can |  *   <dd>Closes resources allocated for the working copy, so that the directory can | ||||||
|  *     be put to the cache. Will be called at the end of the operation.</dd> |  *     be put to the cache. Will be called at the end of the operation.</dd> | ||||||
|  *   <dt>{@link #closeRepository(R)}</dt> |  *   <dt>{@link SimpleWorkingCopyFactory#closeRepository(R)}</dt> | ||||||
|  *   <dd>Closes resources allocated for the central repository.</dd> |  *   <dd>Closes resources allocated for the central repository.</dd> | ||||||
|  * </dl> |  * </dl> | ||||||
|  * <br> |  * <br> | ||||||
|   | |||||||
| @@ -21,7 +21,7 @@ | |||||||
|  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||||
|  * SOFTWARE. |  * SOFTWARE. | ||||||
|  */ |  */ | ||||||
|      |  | ||||||
| package sonia.scm.security; | package sonia.scm.security; | ||||||
|  |  | ||||||
| import java.util.Collection; | import java.util.Collection; | ||||||
| @@ -33,33 +33,25 @@ import java.util.function.Predicate; | |||||||
|  * @author Sebastian Sdorra |  * @author Sebastian Sdorra | ||||||
|  * @since 1.31 |  * @since 1.31 | ||||||
|  */ |  */ | ||||||
| public interface SecuritySystem | public interface SecuritySystem { | ||||||
| { |  | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * Store a new permission. |    * Store a new permission. | ||||||
|    * |    * | ||||||
|    * |  | ||||||
|    * @param permission permission to be stored |    * @param permission permission to be stored | ||||||
|    * |  | ||||||
|    * @return stored permission |  | ||||||
|    */ |    */ | ||||||
|   void addPermission(AssignedPermission permission); |   void addPermission(AssignedPermission permission); | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * Delete stored permission. |    * Delete stored permission. | ||||||
|    * |    * | ||||||
|    * |  | ||||||
|    * @param permission permission to be deleted |    * @param permission permission to be deleted | ||||||
|    */ |    */ | ||||||
|   void deletePermission(AssignedPermission permission); |   void deletePermission(AssignedPermission permission); | ||||||
|  |  | ||||||
|   //~--- get methods ---------------------------------------------------------- |  | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * Return all available permissions. |    * Return all available permissions. | ||||||
|    * |    * | ||||||
|    * |  | ||||||
|    * @return available permissions |    * @return available permissions | ||||||
|    */ |    */ | ||||||
|   Collection<PermissionDescriptor> getAvailablePermissions(); |   Collection<PermissionDescriptor> getAvailablePermissions(); | ||||||
| @@ -68,9 +60,7 @@ public interface SecuritySystem | |||||||
|    * Returns all stored permissions which are matched by the given |    * Returns all stored permissions which are matched by the given | ||||||
|    * {@link Predicate}. |    * {@link Predicate}. | ||||||
|    * |    * | ||||||
|    * |  | ||||||
|    * @param predicate predicate to filter |    * @param predicate predicate to filter | ||||||
|    * |  | ||||||
|    * @return filtered permissions |    * @return filtered permissions | ||||||
|    */ |    */ | ||||||
|   Collection<AssignedPermission> getPermissions(Predicate<AssignedPermission> predicate); |   Collection<AssignedPermission> getPermissions(Predicate<AssignedPermission> predicate); | ||||||
|   | |||||||
| @@ -43,7 +43,7 @@ public interface ExportableStore { | |||||||
|   StoreEntryMetaData getMetaData(); |   StoreEntryMetaData getMetaData(); | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * Exports the data of this store to the given {@param exporter}. |    * Exports the data of this store to the given exporter. | ||||||
|    */ |    */ | ||||||
|   void export(Exporter exporter) throws IOException; |   void export(Exporter exporter) throws IOException; | ||||||
| } | } | ||||||
|   | |||||||
| @@ -72,7 +72,7 @@ public final class Archives { | |||||||
|    * Example: |    * Example: | ||||||
|    * <pre> |    * <pre> | ||||||
|    *   Archives.addPathToTar(Paths.get("some/dir"), Files.newOutputStream("my.tar")) |    *   Archives.addPathToTar(Paths.get("some/dir"), Files.newOutputStream("my.tar")) | ||||||
|    *     .filter(path -> !path.toString().endsWith("~")) |    *     .filter(path -> !path.toString().endsWith("~")) | ||||||
|    *     .run(); |    *     .run(); | ||||||
|    * </pre> |    * </pre> | ||||||
|    * @param path The path containing the files to be added to the tar. |    * @param path The path containing the files to be added to the tar. | ||||||
|   | |||||||
| @@ -28,6 +28,7 @@ import de.otto.edison.hal.Links; | |||||||
| import org.mapstruct.AfterMapping; | import org.mapstruct.AfterMapping; | ||||||
| import org.mapstruct.Context; | import org.mapstruct.Context; | ||||||
| import org.mapstruct.Mapper; | import org.mapstruct.Mapper; | ||||||
|  | import org.mapstruct.Mapping; | ||||||
| import org.mapstruct.MappingTarget; | import org.mapstruct.MappingTarget; | ||||||
| import sonia.scm.repository.GitRepositoryConfig; | import sonia.scm.repository.GitRepositoryConfig; | ||||||
| import sonia.scm.repository.Repository; | import sonia.scm.repository.Repository; | ||||||
| @@ -46,6 +47,7 @@ public abstract class GitRepositoryConfigMapper { | |||||||
|   @Inject |   @Inject | ||||||
|   private ScmPathInfoStore scmPathInfoStore; |   private ScmPathInfoStore scmPathInfoStore; | ||||||
|  |  | ||||||
|  |   @Mapping(target = "attributes", ignore = true) // We do not map HAL attributes | ||||||
|   public abstract GitRepositoryConfigDto map(GitRepositoryConfig config, @Context Repository repository); |   public abstract GitRepositoryConfigDto map(GitRepositoryConfig config, @Context Repository repository); | ||||||
|   public abstract GitRepositoryConfig map(GitRepositoryConfigDto dto); |   public abstract GitRepositoryConfig map(GitRepositoryConfigDto dto); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -496,7 +496,7 @@ public final class GitUtil { | |||||||
|    * Returns the name of the tag or {@code null} if the the ref is not a tag. |    * Returns the name of the tag or {@code null} if the the ref is not a tag. | ||||||
|    * |    * | ||||||
|    * @param refName ref name |    * @param refName ref name | ||||||
|    * @return name of tag or {@link null} |    * @return name of tag or null | ||||||
|    * @since 1.50 |    * @since 1.50 | ||||||
|    */ |    */ | ||||||
|   public static String getTagName(String refName) { |   public static String getTagName(String refName) { | ||||||
|   | |||||||
| @@ -51,11 +51,11 @@ class SvnLookupCommandTest { | |||||||
|  |  | ||||||
|   @Test |   @Test | ||||||
|   void shouldReturnEmptyOptional() { |   void shouldReturnEmptyOptional() { | ||||||
|     LookupCommandRequest request = new LookupCommandRequest(); |     LookupCommandRequest<String> request = new LookupCommandRequest<>(); | ||||||
|     request.setType(String.class); |     request.setType(String.class); | ||||||
|     request.setArgs(new String[]{"propget"}); |     request.setArgs(new String[]{"propget"}); | ||||||
|  |  | ||||||
|     Optional<Object> result = command.lookup(request); |     Optional<String> result = command.lookup(request); | ||||||
|  |  | ||||||
|     assertThat(result).isNotPresent(); |     assertThat(result).isNotPresent(); | ||||||
|   } |   } | ||||||
| @@ -66,11 +66,11 @@ class SvnLookupCommandTest { | |||||||
|     when(context.open()).thenReturn(svnRepository); |     when(context.open()).thenReturn(svnRepository); | ||||||
|     when(svnRepository.getRepositoryUUID(true)).thenReturn(uuid); |     when(svnRepository.getRepositoryUUID(true)).thenReturn(uuid); | ||||||
|  |  | ||||||
|     LookupCommandRequest request = new LookupCommandRequest(); |     LookupCommandRequest<String> request = new LookupCommandRequest<>(); | ||||||
|     request.setType(String.class); |     request.setType(String.class); | ||||||
|     request.setArgs(new String[]{"propget", "uuid", "/"}); |     request.setArgs(new String[]{"propget", "uuid", "/"}); | ||||||
|  |  | ||||||
|     Optional<Object> result = command.lookup(request); |     Optional<String> result = command.lookup(request); | ||||||
|  |  | ||||||
|     assertThat(result).isPresent(); |     assertThat(result).isPresent(); | ||||||
|     assertThat(result.get()) |     assertThat(result.get()) | ||||||
|   | |||||||
| @@ -21,7 +21,7 @@ | |||||||
|  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||||
|  * SOFTWARE. |  * SOFTWARE. | ||||||
|  */ |  */ | ||||||
|      |  | ||||||
| package sonia.scm.repository; | package sonia.scm.repository; | ||||||
|  |  | ||||||
| //~--- non-JDK imports -------------------------------------------------------- | //~--- non-JDK imports -------------------------------------------------------- | ||||||
| @@ -50,8 +50,6 @@ import static org.mockito.Mockito.when; | |||||||
|  */ |  */ | ||||||
| public abstract class SimpleRepositoryHandlerTestBase extends AbstractTestBase { | public abstract class SimpleRepositoryHandlerTestBase extends AbstractTestBase { | ||||||
|  |  | ||||||
|  |  | ||||||
|   protected RepositoryDAO repoDao = mock(RepositoryDAO.class); |  | ||||||
|   protected Path repoPath; |   protected Path repoPath; | ||||||
|   protected Repository repository; |   protected Repository repository; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -21,7 +21,7 @@ | |||||||
|  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||||
|  * SOFTWARE. |  * SOFTWARE. | ||||||
|  */ |  */ | ||||||
|      |  | ||||||
| package sonia.scm.repository.client.api; | package sonia.scm.repository.client.api; | ||||||
|  |  | ||||||
| //~--- non-JDK imports -------------------------------------------------------- | //~--- non-JDK imports -------------------------------------------------------- | ||||||
| @@ -39,141 +39,67 @@ import java.io.IOException; | |||||||
| import java.util.List; | import java.util.List; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * |  | ||||||
|  * @author Sebastian Sdorra |  * @author Sebastian Sdorra | ||||||
|  * @since 1.18 |  * @since 1.18 | ||||||
|  */ |  */ | ||||||
| public final class RepositoryClientFactory | public final class RepositoryClientFactory { | ||||||
| { |  | ||||||
|  |  | ||||||
|   /** |   private Iterable<RepositoryClientFactoryProvider> providers; | ||||||
|    * Constructs ... |  | ||||||
|    * |   public RepositoryClientFactory() { | ||||||
|    */ |  | ||||||
|   public RepositoryClientFactory() |  | ||||||
|   { |  | ||||||
|     this.providers = |     this.providers = | ||||||
|       ServiceUtil.getServices(RepositoryClientFactoryProvider.class); |       ServiceUtil.getServices(RepositoryClientFactoryProvider.class); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   /** |  | ||||||
|    * Constructs ... |  | ||||||
|    * |  | ||||||
|    * |  | ||||||
|    * @param provider |  | ||||||
|    * |  | ||||||
|    * @param providers |  | ||||||
|    */ |  | ||||||
|   public RepositoryClientFactory( |   public RepositoryClientFactory( | ||||||
|     Iterable<RepositoryClientFactoryProvider> providers) |     Iterable<RepositoryClientFactoryProvider> providers) { | ||||||
|   { |  | ||||||
|     this.providers = providers; |     this.providers = providers; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   //~--- methods -------------------------------------------------------------- |  | ||||||
|  |  | ||||||
|   /** |  | ||||||
|    * Method description |  | ||||||
|    * |  | ||||||
|    * |  | ||||||
|    * |  | ||||||
|    * @param type |  | ||||||
|    * @param main |  | ||||||
|    * @param workingCopy |  | ||||||
|    * |  | ||||||
|    * @return |  | ||||||
|    * |  | ||||||
|    * @throws IOException |  | ||||||
|    */ |  | ||||||
|   public RepositoryClient create(String type, File main, File workingCopy) |   public RepositoryClient create(String type, File main, File workingCopy) | ||||||
|     throws IOException |     throws IOException { | ||||||
|   { |  | ||||||
|  |  | ||||||
|     return new RepositoryClient(getProvider(type).create(main, workingCopy)); |     return new RepositoryClient(getProvider(type).create(main, workingCopy)); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   /** |  | ||||||
|    * Method description |  | ||||||
|    * |  | ||||||
|    * |  | ||||||
|    * |  | ||||||
|    * @param type |  | ||||||
|    * @param url |  | ||||||
|    * @param username |  | ||||||
|    * @param password |  | ||||||
|    * @param workingCopy |  | ||||||
|    * |  | ||||||
|    * @return |  | ||||||
|    * |  | ||||||
|    * @throws IOException |  | ||||||
|    */ |  | ||||||
|   public RepositoryClient create(String type, String url, String username, |   public RepositoryClient create(String type, String url, String username, | ||||||
|     String password, File workingCopy) |                                  String password, File workingCopy) | ||||||
|     throws IOException |     throws IOException { | ||||||
|   { |  | ||||||
|     return new RepositoryClient(getProvider(type).create(url, username, |     return new RepositoryClient(getProvider(type).create(url, username, | ||||||
|       password, workingCopy)); |       password, workingCopy)); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   public RepositoryClient create(String type, String url, File workingCopy) |   public RepositoryClient create(String type, String url, File workingCopy) | ||||||
|     throws IOException |     throws IOException { | ||||||
|   { |  | ||||||
|     return new RepositoryClient(getProvider(type).create(url, null, null, workingCopy)); |     return new RepositoryClient(getProvider(type).create(url, null, null, workingCopy)); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   //~--- get methods ---------------------------------------------------------- |   public Iterable<String> getAvailableTypes() { | ||||||
|  |  | ||||||
|   /** |  | ||||||
|    * Method description |  | ||||||
|    * |  | ||||||
|    * |  | ||||||
|    * @return |  | ||||||
|    */ |  | ||||||
|   public Iterable<String> getAvailableTypes() |  | ||||||
|   { |  | ||||||
|     List<String> types = Lists.newArrayList(); |     List<String> types = Lists.newArrayList(); | ||||||
|  |  | ||||||
|     for (RepositoryClientFactoryProvider provider : providers) |     for (RepositoryClientFactoryProvider provider : providers) { | ||||||
|     { |  | ||||||
|       types.add(provider.getType()); |       types.add(provider.getType()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     return types; |     return types; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   /** |   private RepositoryClientFactoryProvider getProvider(String type) { | ||||||
|    * Method description |  | ||||||
|    * |  | ||||||
|    * |  | ||||||
|    * @param type |  | ||||||
|    * |  | ||||||
|    * @return |  | ||||||
|    */ |  | ||||||
|   private RepositoryClientFactoryProvider getProvider(String type) |  | ||||||
|   { |  | ||||||
|     RepositoryClientFactoryProvider provider = null; |     RepositoryClientFactoryProvider provider = null; | ||||||
|  |  | ||||||
|     for (RepositoryClientFactoryProvider p : providers) |     for (RepositoryClientFactoryProvider p : providers) { | ||||||
|     { |       if (p.getType().equalsIgnoreCase(type)) { | ||||||
|       if (p.getType().equalsIgnoreCase(type)) |  | ||||||
|       { |  | ||||||
|         provider = p; |         provider = p; | ||||||
|  |  | ||||||
|         break; |         break; | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (provider == null) |     if (provider == null) { | ||||||
|     { |  | ||||||
|       throw new RuntimeException( |       throw new RuntimeException( | ||||||
|         "could not find provider for type ".concat(type)); |         "could not find provider for type ".concat(type)); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     return provider; |     return provider; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   //~--- fields --------------------------------------------------------------- |  | ||||||
|  |  | ||||||
|   /** Field description */ |  | ||||||
|   private Iterable<RepositoryClientFactoryProvider> providers; |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -21,7 +21,7 @@ | |||||||
|  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||||
|  * SOFTWARE. |  * SOFTWARE. | ||||||
|  */ |  */ | ||||||
|      |  | ||||||
| package sonia.scm.repository.client.spi; | package sonia.scm.repository.client.spi; | ||||||
|  |  | ||||||
| //~--- JDK imports ------------------------------------------------------------ | //~--- JDK imports ------------------------------------------------------------ | ||||||
| @@ -29,22 +29,10 @@ package sonia.scm.repository.client.spi; | |||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * |  | ||||||
|  * @author Sebastian Sdorra |  * @author Sebastian Sdorra | ||||||
|  * @since 1.18 |  * @since 1.18 | ||||||
|  */ |  */ | ||||||
| public interface AddCommand | public interface AddCommand { | ||||||
| { |  | ||||||
|  |  | ||||||
|   /** |   void add(String path) throws IOException; | ||||||
|    * Method description |  | ||||||
|    * |  | ||||||
|    * |  | ||||||
|    * @param path |  | ||||||
|    * |  | ||||||
|    * @param file |  | ||||||
|    * |  | ||||||
|    * @throws IOException |  | ||||||
|    */ |  | ||||||
|   public void add(String path) throws IOException; |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -21,7 +21,7 @@ | |||||||
|  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||||
|  * SOFTWARE. |  * SOFTWARE. | ||||||
|  */ |  */ | ||||||
|      |  | ||||||
| package sonia.scm.repository.client.spi; | package sonia.scm.repository.client.spi; | ||||||
|  |  | ||||||
| //~--- JDK imports ------------------------------------------------------------ | //~--- JDK imports ------------------------------------------------------------ | ||||||
| @@ -29,22 +29,10 @@ package sonia.scm.repository.client.spi; | |||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * |  | ||||||
|  * @author Sebastian Sdorra |  * @author Sebastian Sdorra | ||||||
|  * @since 1.18 |  * @since 1.18 | ||||||
|  */ |  */ | ||||||
| public interface RemoveCommand | public interface RemoveCommand { | ||||||
| { |  | ||||||
|  |  | ||||||
|   /** |   void remove(String path) throws IOException; | ||||||
|    * Method description |  | ||||||
|    * |  | ||||||
|    * |  | ||||||
|    * @param file |  | ||||||
|    * |  | ||||||
|    * @param path |  | ||||||
|    * |  | ||||||
|    * @throws IOException |  | ||||||
|    */ |  | ||||||
|   public void remove(String path) throws IOException; |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -26,6 +26,7 @@ package sonia.scm.api.v2.resources; | |||||||
|  |  | ||||||
| import de.otto.edison.hal.Links; | import de.otto.edison.hal.Links; | ||||||
| import org.mapstruct.Mapper; | import org.mapstruct.Mapper; | ||||||
|  | import org.mapstruct.Mapping; | ||||||
| import org.mapstruct.ObjectFactory; | import org.mapstruct.ObjectFactory; | ||||||
| import sonia.scm.security.ApiKey; | import sonia.scm.security.ApiKey; | ||||||
|  |  | ||||||
| @@ -39,6 +40,7 @@ public abstract class ApiKeyToApiKeyDtoMapper { | |||||||
|   @Inject |   @Inject | ||||||
|   private ResourceLinks resourceLinks; |   private ResourceLinks resourceLinks; | ||||||
|  |  | ||||||
|  |   @Mapping(target = "attributes", ignore = true) // We do not map HAL attributes | ||||||
|   abstract ApiKeyDto map(ApiKey key, String user); |   abstract ApiKeyDto map(ApiKey key, String user); | ||||||
|  |  | ||||||
|   @ObjectFactory |   @ObjectFactory | ||||||
|   | |||||||
| @@ -27,10 +27,12 @@ package sonia.scm.api.v2.resources; | |||||||
| import de.otto.edison.hal.HalRepresentation; | import de.otto.edison.hal.HalRepresentation; | ||||||
| import de.otto.edison.hal.Links; | import de.otto.edison.hal.Links; | ||||||
| import lombok.Data; | import lombok.Data; | ||||||
|  | import lombok.EqualsAndHashCode; | ||||||
|  |  | ||||||
| import java.util.List; | import java.util.List; | ||||||
|  |  | ||||||
| @Data | @Data | ||||||
|  | @EqualsAndHashCode(callSuper = false) | ||||||
| public class BlameDto extends HalRepresentation { | public class BlameDto extends HalRepresentation { | ||||||
|  |  | ||||||
|   private List<BlameLineDto> lines; |   private List<BlameLineDto> lines; | ||||||
|   | |||||||
| @@ -55,6 +55,7 @@ public abstract class BrowserResultToFileObjectDtoMapper extends BaseFileObjectD | |||||||
|  |  | ||||||
|   @Mapping(target = "attributes", ignore = true) // We do not map HAL attributes |   @Mapping(target = "attributes", ignore = true) // We do not map HAL attributes | ||||||
|   @Mapping(target = "children", qualifiedBy = Children.class) |   @Mapping(target = "children", qualifiedBy = Children.class) | ||||||
|  |   @Mapping(target = "revision", ignore = true) | ||||||
|   @Children |   @Children | ||||||
|   protected abstract FileObjectDto fileObjectToDto(FileObject fileObject, @Context NamespaceAndName namespaceAndName, @Context BrowserResult browserResult, @Context Integer offset); |   protected abstract FileObjectDto fileObjectToDto(FileObject fileObject, @Context NamespaceAndName namespaceAndName, @Context BrowserResult browserResult, @Context Integer offset); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -28,6 +28,7 @@ import de.otto.edison.hal.Embedded; | |||||||
| import de.otto.edison.hal.Links; | import de.otto.edison.hal.Links; | ||||||
| import org.mapstruct.Context; | import org.mapstruct.Context; | ||||||
| import org.mapstruct.Mapper; | import org.mapstruct.Mapper; | ||||||
|  | import org.mapstruct.Mapping; | ||||||
| import org.mapstruct.ObjectFactory; | import org.mapstruct.ObjectFactory; | ||||||
| import sonia.scm.repository.Branch; | import sonia.scm.repository.Branch; | ||||||
| import sonia.scm.repository.Changeset; | import sonia.scm.repository.Changeset; | ||||||
| @@ -80,6 +81,7 @@ public abstract class DefaultChangesetToChangesetDtoMapper extends HalAppenderMa | |||||||
|  |  | ||||||
|   abstract ContributorDto map(Contributor contributor); |   abstract ContributorDto map(Contributor contributor); | ||||||
|  |  | ||||||
|  |   @Mapping(target = "attributes", ignore = true) // We do not map HAL attributes | ||||||
|   abstract SignatureDto map(Signature signature); |   abstract SignatureDto map(Signature signature); | ||||||
|  |  | ||||||
|   abstract PersonDto map(Person person); |   abstract PersonDto map(Person person); | ||||||
|   | |||||||
| @@ -29,10 +29,12 @@ import com.fasterxml.jackson.annotation.JsonProperty; | |||||||
| import de.otto.edison.hal.HalRepresentation; | import de.otto.edison.hal.HalRepresentation; | ||||||
| import de.otto.edison.hal.Links; | import de.otto.edison.hal.Links; | ||||||
| import lombok.Data; | import lombok.Data; | ||||||
|  | import lombok.EqualsAndHashCode; | ||||||
|  |  | ||||||
| import java.util.List; | import java.util.List; | ||||||
|  |  | ||||||
| @Data | @Data | ||||||
|  | @EqualsAndHashCode(callSuper = false) | ||||||
| public class DiffResultDto extends HalRepresentation { | public class DiffResultDto extends HalRepresentation { | ||||||
|  |  | ||||||
|   public DiffResultDto(Links links) { |   public DiffResultDto(Links links) { | ||||||
| @@ -42,6 +44,7 @@ public class DiffResultDto extends HalRepresentation { | |||||||
|   private List<FileDto> files; |   private List<FileDto> files; | ||||||
|  |  | ||||||
|   @Data |   @Data | ||||||
|  |   @EqualsAndHashCode(callSuper = false) | ||||||
|   @JsonInclude(JsonInclude.Include.NON_DEFAULT) |   @JsonInclude(JsonInclude.Include.NON_DEFAULT) | ||||||
|   public static class FileDto extends HalRepresentation { |   public static class FileDto extends HalRepresentation { | ||||||
|  |  | ||||||
|   | |||||||
| @@ -33,5 +33,6 @@ import sonia.scm.group.Group; | |||||||
| public abstract class GroupDtoToGroupMapper extends BaseDtoMapper { | public abstract class GroupDtoToGroupMapper extends BaseDtoMapper { | ||||||
|  |  | ||||||
|   @Mapping(target = "creationDate", ignore = true) |   @Mapping(target = "creationDate", ignore = true) | ||||||
|  |   @Mapping(target = "properties", ignore = true) | ||||||
|   public abstract Group map(GroupDto groupDto); |   public abstract Group map(GroupDto groupDto); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -90,12 +90,12 @@ public class IncomingRootResource { | |||||||
|    * -                            ° b2 |    * -                            ° b2 | ||||||
|    * - |    * - | ||||||
|    * <p> |    * <p> | ||||||
|    * - /incoming/a/master/changesets  -> a1 , e1 |    * - /incoming/a/master/changesets  -> a1 , e1 | ||||||
|    * - /incoming/b/master/changesets  -> b1 , b2 |    * - /incoming/b/master/changesets  -> b1 , b2 | ||||||
|    * - /incoming/b/f/changesets       -> b1 , b2, m2 |    * - /incoming/b/f/changesets       -> b1 , b2, m2 | ||||||
|    * - /incoming/f/b/changesets       -> f1 , e1 |    * - /incoming/f/b/changesets       -> f1 , e1 | ||||||
|    * - /incoming/a/b/changesets       -> a1 , e1 |    * - /incoming/a/b/changesets       -> a1 , e1 | ||||||
|    * - /incoming/a/b/changesets       -> a1 , e1 |    * - /incoming/a/b/changesets       -> a1 , e1 | ||||||
|    * |    * | ||||||
|    * @param namespace |    * @param namespace | ||||||
|    * @param name |    * @param name | ||||||
|   | |||||||
| @@ -232,7 +232,6 @@ public class NamespacePermissionResource { | |||||||
|    * |    * | ||||||
|    * @param permission     permission to modify |    * @param permission     permission to modify | ||||||
|    * @param permissionName permission to modify |    * @param permissionName permission to modify | ||||||
|    * @return a web response with the status code 204 |  | ||||||
|    */ |    */ | ||||||
|   @PUT |   @PUT | ||||||
|   @Path("{permission-name}") |   @Path("{permission-name}") | ||||||
| @@ -264,8 +263,8 @@ public class NamespacePermissionResource { | |||||||
|     ) |     ) | ||||||
|   ) |   ) | ||||||
|   public void update(@PathParam("namespace") String namespaceName, |   public void update(@PathParam("namespace") String namespaceName, | ||||||
|                          @PathParam("permission-name") String permissionName, |                      @PathParam("permission-name") String permissionName, | ||||||
|                          @Valid RepositoryPermissionDto permission) { |                      @Valid RepositoryPermissionDto permission) { | ||||||
|     Namespace namespace = load(namespaceName); |     Namespace namespace = load(namespaceName); | ||||||
|     String extractedPermissionName = getPermissionName(permissionName); |     String extractedPermissionName = getPermissionName(permissionName); | ||||||
|     if (!isPermissionExist(new RepositoryPermissionDto(extractedPermissionName, isGroupPermission(permissionName)), namespace)) { |     if (!isPermissionExist(new RepositoryPermissionDto(extractedPermissionName, isGroupPermission(permissionName)), namespace)) { | ||||||
| @@ -294,7 +293,6 @@ public class NamespacePermissionResource { | |||||||
|    * Update a permission to the user or group managed by the repository |    * Update a permission to the user or group managed by the repository | ||||||
|    * |    * | ||||||
|    * @param permissionName permission to delete |    * @param permissionName permission to delete | ||||||
|    * @return a web response with the status code 204 |  | ||||||
|    */ |    */ | ||||||
|   @DELETE |   @DELETE | ||||||
|   @Path("{permission-name}") |   @Path("{permission-name}") | ||||||
| @@ -311,7 +309,7 @@ public class NamespacePermissionResource { | |||||||
|     ) |     ) | ||||||
|   ) |   ) | ||||||
|   public void delete(@PathParam("namespace") String namespaceName, |   public void delete(@PathParam("namespace") String namespaceName, | ||||||
|                          @PathParam("permission-name") String permissionName) { |                      @PathParam("permission-name") String permissionName) { | ||||||
|     log.info("try to delete the permission with name: {}.", permissionName); |     log.info("try to delete the permission with name: {}.", permissionName); | ||||||
|     Namespace namespace = load(namespaceName); |     Namespace namespace = load(namespaceName); | ||||||
|     namespace.getPermissions() |     namespace.getPermissions() | ||||||
|   | |||||||
| @@ -26,6 +26,7 @@ package sonia.scm.api.v2.resources; | |||||||
|  |  | ||||||
| import de.otto.edison.hal.Links; | import de.otto.edison.hal.Links; | ||||||
| import org.mapstruct.Mapper; | import org.mapstruct.Mapper; | ||||||
|  | import org.mapstruct.Mapping; | ||||||
| import org.mapstruct.MappingTarget; | import org.mapstruct.MappingTarget; | ||||||
| import sonia.scm.lifecycle.Restarter; | import sonia.scm.lifecycle.Restarter; | ||||||
| import sonia.scm.plugin.AvailablePlugin; | import sonia.scm.plugin.AvailablePlugin; | ||||||
| @@ -51,6 +52,13 @@ public abstract class PluginDtoMapper { | |||||||
|   @Inject |   @Inject | ||||||
|   private Restarter restarter; |   private Restarter restarter; | ||||||
|  |  | ||||||
|  |   @Mapping(target = "newVersion", ignore = true) | ||||||
|  |   @Mapping(target = "pending", ignore = true) | ||||||
|  |   @Mapping(target = "core", ignore = true) | ||||||
|  |   @Mapping(target = "markedForUninstall", ignore = true) | ||||||
|  |   @Mapping(target = "dependencies", ignore = true) | ||||||
|  |   @Mapping(target = "optionalDependencies", ignore = true) | ||||||
|  |   @Mapping(target = "attributes", ignore = true) | ||||||
|   public abstract void map(PluginInformation plugin, @MappingTarget PluginDto dto); |   public abstract void map(PluginInformation plugin, @MappingTarget PluginDto dto); | ||||||
|  |  | ||||||
|   public PluginDto mapInstalled(InstalledPlugin plugin, List<AvailablePlugin> availablePlugins) { |   public PluginDto mapInstalled(InstalledPlugin plugin, List<AvailablePlugin> availablePlugins) { | ||||||
|   | |||||||
| @@ -37,6 +37,8 @@ public abstract class RepositoryDtoToRepositoryMapper extends BaseDtoMapper { | |||||||
|   @Mapping(target = "creationDate", ignore = true) |   @Mapping(target = "creationDate", ignore = true) | ||||||
|   @Mapping(target = "id", ignore = true) |   @Mapping(target = "id", ignore = true) | ||||||
|   @Mapping(target = "healthCheckFailures", ignore = true) |   @Mapping(target = "healthCheckFailures", ignore = true) | ||||||
|  |   @Mapping(target = "properties", ignore = true) | ||||||
|  |   @Mapping(target = "permissions", ignore = true) | ||||||
|   public abstract Repository map(RepositoryDto repositoryDto, @Context String id); |   public abstract Repository map(RepositoryDto repositoryDto, @Context String id); | ||||||
|  |  | ||||||
|   @AfterMapping |   @AfterMapping | ||||||
|   | |||||||
| @@ -28,6 +28,7 @@ import com.google.common.annotations.VisibleForTesting; | |||||||
| import de.otto.edison.hal.Links; | import de.otto.edison.hal.Links; | ||||||
| import org.mapstruct.Context; | import org.mapstruct.Context; | ||||||
| import org.mapstruct.Mapper; | import org.mapstruct.Mapper; | ||||||
|  | import org.mapstruct.Mapping; | ||||||
| import org.mapstruct.ObjectFactory; | import org.mapstruct.ObjectFactory; | ||||||
| import sonia.scm.importexport.ExportService; | import sonia.scm.importexport.ExportService; | ||||||
| import sonia.scm.importexport.ExportStatus; | import sonia.scm.importexport.ExportStatus; | ||||||
| @@ -56,6 +57,7 @@ public abstract class RepositoryExportInformationToDtoMapper { | |||||||
|     this.exportService = exportService; |     this.exportService = exportService; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   @Mapping(target = "attributes", ignore = true) // We do not map HAL attributes | ||||||
|   abstract RepositoryExportInformationDto map(RepositoryExportInformation info, @Context Repository repository); |   abstract RepositoryExportInformationDto map(RepositoryExportInformation info, @Context Repository repository); | ||||||
|  |  | ||||||
|   @ObjectFactory |   @ObjectFactory | ||||||
|   | |||||||
| @@ -27,6 +27,7 @@ package sonia.scm.api.v2.resources; | |||||||
| import de.otto.edison.hal.Embedded; | import de.otto.edison.hal.Embedded; | ||||||
| import de.otto.edison.hal.Links; | import de.otto.edison.hal.Links; | ||||||
| import org.mapstruct.Mapper; | import org.mapstruct.Mapper; | ||||||
|  | import org.mapstruct.Mapping; | ||||||
| import org.mapstruct.ObjectFactory; | import org.mapstruct.ObjectFactory; | ||||||
| import sonia.scm.repository.RepositoryRole; | import sonia.scm.repository.RepositoryRole; | ||||||
| import sonia.scm.repository.RepositoryRolePermissions; | import sonia.scm.repository.RepositoryRolePermissions; | ||||||
| @@ -46,6 +47,7 @@ public abstract class RepositoryRoleToRepositoryRoleDtoMapper extends BaseMapper | |||||||
|   @Inject |   @Inject | ||||||
|   private ResourceLinks resourceLinks; |   private ResourceLinks resourceLinks; | ||||||
|  |  | ||||||
|  |   @Mapping(target = "attributes", ignore = true) // We do not map HAL attributes | ||||||
|   @Override |   @Override | ||||||
|   public abstract RepositoryRoleDto map(RepositoryRole modelObject); |   public abstract RepositoryRoleDto map(RepositoryRole modelObject); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -29,6 +29,7 @@ import de.otto.edison.hal.Link; | |||||||
| import de.otto.edison.hal.Links; | import de.otto.edison.hal.Links; | ||||||
| import org.mapstruct.AfterMapping; | import org.mapstruct.AfterMapping; | ||||||
| import org.mapstruct.Mapper; | import org.mapstruct.Mapper; | ||||||
|  | import org.mapstruct.Mapping; | ||||||
| import org.mapstruct.MappingTarget; | import org.mapstruct.MappingTarget; | ||||||
| import org.mapstruct.ObjectFactory; | import org.mapstruct.ObjectFactory; | ||||||
| import sonia.scm.config.ScmConfiguration; | import sonia.scm.config.ScmConfiguration; | ||||||
| @@ -70,6 +71,8 @@ public abstract class RepositoryToRepositoryDtoMapper extends BaseMapper<Reposit | |||||||
|  |  | ||||||
|   abstract HealthCheckFailureDto toDto(HealthCheckFailure failure); |   abstract HealthCheckFailureDto toDto(HealthCheckFailure failure); | ||||||
|  |  | ||||||
|  |   @Mapping(target = "attributes", ignore = true) // We do not map HAL attributes | ||||||
|  |   @Mapping(target = "exporting", ignore = true) | ||||||
|   @Override |   @Override | ||||||
|   public abstract RepositoryDto map(Repository modelObject); |   public abstract RepositoryDto map(Repository modelObject); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -43,6 +43,7 @@ public abstract class ResteasyViolationExceptionToErrorDtoMapper { | |||||||
|   @Mapping(target = "context", ignore = true) |   @Mapping(target = "context", ignore = true) | ||||||
|   @Mapping(target = "url", ignore = true) |   @Mapping(target = "url", ignore = true) | ||||||
|   @Mapping(target = "violations", ignore = true) |   @Mapping(target = "violations", ignore = true) | ||||||
|  |   @Mapping(target = "additionalMessages", ignore = true) | ||||||
|   public abstract ErrorDto map(ConstraintViolationException exception); |   public abstract ErrorDto map(ConstraintViolationException exception); | ||||||
|  |  | ||||||
|   @AfterMapping |   @AfterMapping | ||||||
|   | |||||||
| @@ -38,6 +38,7 @@ public interface ScmViolationExceptionToErrorDtoMapper { | |||||||
|   @Mapping(target = "errorCode", ignore = true) |   @Mapping(target = "errorCode", ignore = true) | ||||||
|   @Mapping(target = "transactionId", ignore = true) |   @Mapping(target = "transactionId", ignore = true) | ||||||
|   @Mapping(target = "context", ignore = true) |   @Mapping(target = "context", ignore = true) | ||||||
|  |   @Mapping(target = "additionalMessages", ignore = true) | ||||||
|   ErrorDto map(ScmConstraintViolationException exception); |   ErrorDto map(ScmConstraintViolationException exception); | ||||||
|  |  | ||||||
|   @AfterMapping |   @AfterMapping | ||||||
|   | |||||||
| @@ -21,7 +21,7 @@ | |||||||
|  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||||
|  * SOFTWARE. |  * SOFTWARE. | ||||||
|  */ |  */ | ||||||
|      |  | ||||||
| package sonia.scm.api.v2.resources; | package sonia.scm.api.v2.resources; | ||||||
|  |  | ||||||
| import org.mapstruct.AfterMapping; | import org.mapstruct.AfterMapping; | ||||||
| @@ -37,6 +37,7 @@ import sonia.scm.user.User; | |||||||
| public abstract class UserDtoToUserMapper extends BaseDtoMapper { | public abstract class UserDtoToUserMapper extends BaseDtoMapper { | ||||||
|  |  | ||||||
|   @Mapping(target = "creationDate", ignore = true) |   @Mapping(target = "creationDate", ignore = true) | ||||||
|  |   @Mapping(target = "properties", ignore = true) | ||||||
|   public abstract User map(UserDto userDto, @Context String usedPassword); |   public abstract User map(UserDto userDto, @Context String usedPassword); | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -21,29 +21,21 @@ | |||||||
|  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||||
|  * SOFTWARE. |  * SOFTWARE. | ||||||
|  */ |  */ | ||||||
|      |  | ||||||
| package sonia.scm.plugin; |  | ||||||
|  |  | ||||||
| //~--- non-JDK imports -------------------------------------------------------- | package sonia.scm.plugin; | ||||||
|  |  | ||||||
| import com.google.common.base.Charsets; | import com.google.common.base.Charsets; | ||||||
| import com.google.common.base.Function; | import com.google.common.base.Function; | ||||||
| import com.google.common.collect.Iterables; | import com.google.common.collect.Iterables; | ||||||
| import com.google.common.io.Files; | import com.google.common.io.Files; | ||||||
|  |  | ||||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||||
|  |  | ||||||
| import sonia.scm.lifecycle.classloading.ClassLoaderLifeCycle; | import sonia.scm.lifecycle.classloading.ClassLoaderLifeCycle; | ||||||
| import sonia.scm.util.IOUtil; | import sonia.scm.util.IOUtil; | ||||||
|  |  | ||||||
| //~--- JDK imports ------------------------------------------------------------ |  | ||||||
|  |  | ||||||
| import java.io.File; | import java.io.File; | ||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
|  |  | ||||||
| import java.nio.file.Path; | import java.nio.file.Path; | ||||||
|  |  | ||||||
| import java.util.Set; | import java.util.Set; | ||||||
|  |  | ||||||
| /** | /** | ||||||
| @@ -59,27 +51,8 @@ public final class PluginsInternal | |||||||
|   private static final Logger logger = |   private static final Logger logger = | ||||||
|     LoggerFactory.getLogger(PluginsInternal.class); |     LoggerFactory.getLogger(PluginsInternal.class); | ||||||
|  |  | ||||||
|   //~--- constructors --------------------------------------------------------- |  | ||||||
|  |  | ||||||
|   /** |  | ||||||
|    * Constructs ... |  | ||||||
|    * |  | ||||||
|    */ |  | ||||||
|   private PluginsInternal() {} |   private PluginsInternal() {} | ||||||
|  |  | ||||||
|   //~--- methods -------------------------------------------------------------- |  | ||||||
|  |  | ||||||
|   /** |  | ||||||
|    * Method description |  | ||||||
|    * |  | ||||||
|    * |  | ||||||
|    * @param classLoader |  | ||||||
|    * @param directory |  | ||||||
|    * |  | ||||||
|    * @return |  | ||||||
|    * |  | ||||||
|    * @throws IOException |  | ||||||
|    */ |  | ||||||
|   public static Set<InstalledPlugin> collectPlugins(ClassLoaderLifeCycle classLoaderLifeCycle, |   public static Set<InstalledPlugin> collectPlugins(ClassLoaderLifeCycle classLoaderLifeCycle, | ||||||
|                                                     Path directory) |                                                     Path directory) | ||||||
|     throws IOException |     throws IOException | ||||||
| @@ -89,15 +62,6 @@ public final class PluginsInternal | |||||||
|     return processor.collectPlugins(classLoaderLifeCycle.getBootstrapClassLoader()); |     return processor.collectPlugins(classLoaderLifeCycle.getBootstrapClassLoader()); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   /** |  | ||||||
|    * Method description |  | ||||||
|    * |  | ||||||
|    * |  | ||||||
|    * @param parent |  | ||||||
|    * @param plugin |  | ||||||
|    * |  | ||||||
|    * @return |  | ||||||
|    */ |  | ||||||
|   public static File createPluginDirectory(File parent, InstalledPluginDescriptor plugin) |   public static File createPluginDirectory(File parent, InstalledPluginDescriptor plugin) | ||||||
|   { |   { | ||||||
|     PluginInformation info = plugin.getInformation(); |     PluginInformation info = plugin.getInformation(); | ||||||
| @@ -105,18 +69,6 @@ public final class PluginsInternal | |||||||
|     return new File(parent, info.getName()); |     return new File(parent, info.getName()); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   /** |  | ||||||
|    * Method description |  | ||||||
|    * |  | ||||||
|    * |  | ||||||
|    * @param archive |  | ||||||
|    * @param checksum |  | ||||||
|    * @param directory |  | ||||||
|    * @param checksumFile |  | ||||||
|    * @param core |  | ||||||
|    * |  | ||||||
|    * @throws IOException |  | ||||||
|    */ |  | ||||||
|   public static void extract(SmpArchive archive, String checksum, |   public static void extract(SmpArchive archive, String checksum, | ||||||
|     File directory, File checksumFile, boolean core) |     File directory, File checksumFile, boolean core) | ||||||
|     throws IOException |     throws IOException | ||||||
| @@ -144,56 +96,21 @@ public final class PluginsInternal | |||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   /** |  | ||||||
|    * Method description |  | ||||||
|    * |  | ||||||
|    * |  | ||||||
|    * @param wrapped |  | ||||||
|    * |  | ||||||
|    * @return |  | ||||||
|    */ |  | ||||||
|   public static Iterable<InstalledPluginDescriptor> unwrap(Iterable<InstalledPlugin> wrapped) |   public static Iterable<InstalledPluginDescriptor> unwrap(Iterable<InstalledPlugin> wrapped) | ||||||
|   { |   { | ||||||
|     return Iterables.transform(wrapped, new Unwrap()); |     return Iterables.transform(wrapped, new Unwrap()); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   //~--- get methods ---------------------------------------------------------- |  | ||||||
|  |  | ||||||
|   /** |  | ||||||
|    * Method description |  | ||||||
|    * |  | ||||||
|    * |  | ||||||
|    * @param pluginDirectory |  | ||||||
|    * |  | ||||||
|    * @return |  | ||||||
|    */ |  | ||||||
|   public static File getChecksumFile(File pluginDirectory) |   public static File getChecksumFile(File pluginDirectory) | ||||||
|   { |   { | ||||||
|     return new File(pluginDirectory, PluginConstants.FILE_CHECKSUM); |     return new File(pluginDirectory, PluginConstants.FILE_CHECKSUM); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   //~--- inner classes -------------------------------------------------------- |  | ||||||
|  |  | ||||||
|   /** |  | ||||||
|    * Class description |  | ||||||
|    * |  | ||||||
|    * |  | ||||||
|    * @version        Enter version here..., 14/06/05 |  | ||||||
|    * @author         Enter your name here... |  | ||||||
|    */ |  | ||||||
|   private static class Unwrap implements Function<InstalledPlugin, InstalledPluginDescriptor> |   private static class Unwrap implements Function<InstalledPlugin, InstalledPluginDescriptor> | ||||||
|   { |   { | ||||||
|  |  | ||||||
|     /** |   @Override | ||||||
|      * Method description |   public InstalledPluginDescriptor apply(InstalledPlugin wrapper) | ||||||
|      * |  | ||||||
|      * |  | ||||||
|      * @param wrapper |  | ||||||
|      * |  | ||||||
|      * @return |  | ||||||
|      */ |  | ||||||
|     @Override |  | ||||||
|     public InstalledPluginDescriptor apply(InstalledPlugin wrapper) |  | ||||||
|     { |     { | ||||||
|       return wrapper.getDescriptor(); |       return wrapper.getDescriptor(); | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -21,10 +21,9 @@ | |||||||
|  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||||
|  * SOFTWARE. |  * SOFTWARE. | ||||||
|  */ |  */ | ||||||
|      |  | ||||||
| package sonia.scm.security; | package sonia.scm.security; | ||||||
|  |  | ||||||
| //~--- non-JDK imports -------------------------------------------------------- |  | ||||||
|  |  | ||||||
| import com.github.legman.Subscribe; | import com.github.legman.Subscribe; | ||||||
| import com.google.common.base.Objects; | import com.google.common.base.Objects; | ||||||
| @@ -62,7 +61,6 @@ import java.util.stream.Collectors; | |||||||
|  |  | ||||||
| import static java.util.Objects.isNull; | import static java.util.Objects.isNull; | ||||||
|  |  | ||||||
| //~--- JDK imports ------------------------------------------------------------ |  | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * TODO add events |  * TODO add events | ||||||
| @@ -71,13 +69,10 @@ import static java.util.Objects.isNull; | |||||||
|  * @since 1.31 |  * @since 1.31 | ||||||
|  */ |  */ | ||||||
| @Singleton | @Singleton | ||||||
| public class DefaultSecuritySystem implements SecuritySystem | public class DefaultSecuritySystem implements SecuritySystem { | ||||||
| { |  | ||||||
|  |  | ||||||
|   /** Field description */ |  | ||||||
|   private static final String NAME = "security"; |   private static final String NAME = "security"; | ||||||
|  |  | ||||||
|   /** Field description */ |  | ||||||
|   private static final String PERMISSION_DESCRIPTOR = |   private static final String PERMISSION_DESCRIPTOR = | ||||||
|     "META-INF/scm/permissions.xml"; |     "META-INF/scm/permissions.xml"; | ||||||
|  |  | ||||||
| @@ -87,18 +82,8 @@ public class DefaultSecuritySystem implements SecuritySystem | |||||||
|   private static final Logger logger = |   private static final Logger logger = | ||||||
|     LoggerFactory.getLogger(DefaultSecuritySystem.class); |     LoggerFactory.getLogger(DefaultSecuritySystem.class); | ||||||
|  |  | ||||||
|   //~--- constructors --------------------------------------------------------- |  | ||||||
|  |  | ||||||
|   /** |  | ||||||
|    * Constructs ... |  | ||||||
|    * |  | ||||||
|    * |  | ||||||
|    * @param storeFactory |  | ||||||
|    */ |  | ||||||
|   @Inject |   @Inject | ||||||
|   @SuppressWarnings("unchecked") |   public DefaultSecuritySystem(ConfigurationEntryStoreFactory storeFactory, PluginLoader pluginLoader) { | ||||||
|   public DefaultSecuritySystem(ConfigurationEntryStoreFactory storeFactory, PluginLoader pluginLoader) |  | ||||||
|   { |  | ||||||
|     store = storeFactory |     store = storeFactory | ||||||
|       .withType(AssignedPermission.class) |       .withType(AssignedPermission.class) | ||||||
|       .withName(NAME) |       .withName(NAME) | ||||||
| @@ -106,19 +91,8 @@ public class DefaultSecuritySystem implements SecuritySystem | |||||||
|     this.availablePermissions = readAvailablePermissions(pluginLoader); |     this.availablePermissions = readAvailablePermissions(pluginLoader); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   //~--- methods -------------------------------------------------------------- |  | ||||||
|  |  | ||||||
|   /** |  | ||||||
|    * Method description |  | ||||||
|    * |  | ||||||
|    * |  | ||||||
|    * @param permission |  | ||||||
|    * |  | ||||||
|    * @return |  | ||||||
|    */ |  | ||||||
|   @Override |   @Override | ||||||
|   public void addPermission(AssignedPermission permission) |   public void addPermission(AssignedPermission permission) { | ||||||
|   { |  | ||||||
|     assertHasPermission(); |     assertHasPermission(); | ||||||
|     validatePermission(permission); |     validatePermission(permission); | ||||||
|  |  | ||||||
| @@ -133,15 +107,8 @@ public class DefaultSecuritySystem implements SecuritySystem | |||||||
|     //J+ |     //J+ | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   /** |  | ||||||
|    * Method description |  | ||||||
|    * |  | ||||||
|    * |  | ||||||
|    * @param permission |  | ||||||
|    */ |  | ||||||
|   @Override |   @Override | ||||||
|   public void deletePermission(AssignedPermission permission) |   public void deletePermission(AssignedPermission permission) { | ||||||
|   { |  | ||||||
|     assertHasPermission(); |     assertHasPermission(); | ||||||
|     boolean deleted = deletePermissions(sap -> Objects.equal(sap.getName(), permission.getName()) |     boolean deleted = deletePermissions(sap -> Objects.equal(sap.getName(), permission.getName()) | ||||||
|       && Objects.equal(sap.isGroupPermission(), permission.isGroupPermission()) |       && Objects.equal(sap.isGroupPermission(), permission.isGroupPermission()) | ||||||
| @@ -153,71 +120,35 @@ public class DefaultSecuritySystem implements SecuritySystem | |||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   /** |  | ||||||
|    * Method description |  | ||||||
|    * |  | ||||||
|    * |  | ||||||
|    * @param event |  | ||||||
|    */ |  | ||||||
|   @Subscribe |   @Subscribe | ||||||
|   public void handleEvent(final UserEvent event) |   public void handleEvent(final UserEvent event) { | ||||||
|   { |     if (event.getEventType() == HandlerEventType.DELETE) { | ||||||
|     if (event.getEventType() == HandlerEventType.DELETE) |  | ||||||
|     { |  | ||||||
|       deletePermissions(p -> !p.isGroupPermission() |       deletePermissions(p -> !p.isGroupPermission() | ||||||
|         && event.getItem().getName().equals(p.getName())); |         && event.getItem().getName().equals(p.getName())); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   /** |  | ||||||
|    * Method description |  | ||||||
|    * |  | ||||||
|    * |  | ||||||
|    * @param event |  | ||||||
|    */ |  | ||||||
|   @Subscribe |   @Subscribe | ||||||
|   public void handleEvent(final GroupEvent event) |   public void handleEvent(final GroupEvent event) { | ||||||
|   { |     if (event.getEventType() == HandlerEventType.DELETE) { | ||||||
|     if (event.getEventType() == HandlerEventType.DELETE) |  | ||||||
|     { |  | ||||||
|       deletePermissions(p -> p.isGroupPermission() |       deletePermissions(p -> p.isGroupPermission() | ||||||
|         && event.getItem().getName().equals(p.getName())); |         && event.getItem().getName().equals(p.getName())); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   //~--- get methods ---------------------------------------------------------- |  | ||||||
|  |  | ||||||
|   /** |  | ||||||
|    * Method description |  | ||||||
|    * |  | ||||||
|    * |  | ||||||
|    * @return |  | ||||||
|    */ |  | ||||||
|   @Override |   @Override | ||||||
|   public Collection<PermissionDescriptor> getAvailablePermissions() |   public Collection<PermissionDescriptor> getAvailablePermissions() { | ||||||
|   { |  | ||||||
|     assertHasPermission(); |     assertHasPermission(); | ||||||
|  |  | ||||||
|     return availablePermissions; |     return availablePermissions; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   /** |  | ||||||
|    * Method description |  | ||||||
|    * |  | ||||||
|    * |  | ||||||
|    * @param predicate |  | ||||||
|    * |  | ||||||
|    * @return |  | ||||||
|    */ |  | ||||||
|   @Override |   @Override | ||||||
|   public Collection<AssignedPermission> getPermissions(Predicate<AssignedPermission> predicate) |   public Collection<AssignedPermission> getPermissions(Predicate<AssignedPermission> predicate) { | ||||||
|   { |  | ||||||
|     Builder<AssignedPermission> permissions = ImmutableSet.builder(); |     Builder<AssignedPermission> permissions = ImmutableSet.builder(); | ||||||
|  |  | ||||||
|     for (Entry<String, AssignedPermission> e : store.getAll().entrySet()) |     for (Entry<String, AssignedPermission> e : store.getAll().entrySet()) { | ||||||
|     { |       if ((predicate == null) || predicate.test(e.getValue())) { | ||||||
|       if ((predicate == null) || predicate.test(e.getValue())) |  | ||||||
|       { |  | ||||||
|         permissions.add(new StoredAssignedPermission(e.getKey(), e.getValue())); |         permissions.add(new StoredAssignedPermission(e.getKey(), e.getValue())); | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
| @@ -225,25 +156,11 @@ public class DefaultSecuritySystem implements SecuritySystem | |||||||
|     return permissions.build(); |     return permissions.build(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   //~--- methods -------------------------------------------------------------- |   private void assertHasPermission() { | ||||||
|  |  | ||||||
|   /** |  | ||||||
|    * Method description |  | ||||||
|    * |  | ||||||
|    */ |  | ||||||
|   private void assertHasPermission() |  | ||||||
|   { |  | ||||||
|     PermissionPermissions.assign().check(); |     PermissionPermissions.assign().check(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   /** |   private boolean deletePermissions(Predicate<AssignedPermission> predicate) { | ||||||
|    * Method description |  | ||||||
|    * |  | ||||||
|    * |  | ||||||
|    * @param predicate |  | ||||||
|    */ |  | ||||||
|   private boolean deletePermissions(Predicate<AssignedPermission> predicate) |  | ||||||
|   { |  | ||||||
|     List<Entry<String, AssignedPermission>> toRemove = |     List<Entry<String, AssignedPermission>> toRemove = | ||||||
|       store.getAll() |       store.getAll() | ||||||
|         .entrySet() |         .entrySet() | ||||||
| @@ -253,23 +170,12 @@ public class DefaultSecuritySystem implements SecuritySystem | |||||||
|     return !toRemove.isEmpty(); |     return !toRemove.isEmpty(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   /** |  | ||||||
|    * Method description |  | ||||||
|    * |  | ||||||
|    * |  | ||||||
|    * @param context |  | ||||||
|    * @param descriptorUrl |  | ||||||
|    * |  | ||||||
|    * @return |  | ||||||
|    */ |  | ||||||
|   @SuppressWarnings("unchecked") |   @SuppressWarnings("unchecked") | ||||||
|   private static List<PermissionDescriptor> parsePermissionDescriptor( |   private static List<PermissionDescriptor> parsePermissionDescriptor( | ||||||
|     JAXBContext context, URL descriptorUrl) |     JAXBContext context, URL descriptorUrl) { | ||||||
|   { |  | ||||||
|     List<PermissionDescriptor> descriptors = Collections.EMPTY_LIST; |     List<PermissionDescriptor> descriptors = Collections.EMPTY_LIST; | ||||||
|  |  | ||||||
|     try |     try { | ||||||
|     { |  | ||||||
|       PermissionDescriptors descriptorWrapper = |       PermissionDescriptors descriptorWrapper = | ||||||
|         (PermissionDescriptors) context.createUnmarshaller().unmarshal( |         (PermissionDescriptors) context.createUnmarshaller().unmarshal( | ||||||
|           descriptorUrl); |           descriptorUrl); | ||||||
| @@ -279,26 +185,17 @@ public class DefaultSecuritySystem implements SecuritySystem | |||||||
|       logger.debug("found {} permissions at {}", descriptors.size(), |       logger.debug("found {} permissions at {}", descriptors.size(), | ||||||
|         descriptorUrl); |         descriptorUrl); | ||||||
|       logger.trace("permissions from {}: {}", descriptorUrl, descriptors); |       logger.trace("permissions from {}: {}", descriptorUrl, descriptors); | ||||||
|     } |     } catch (JAXBException ex) { | ||||||
|     catch (JAXBException ex) |  | ||||||
|     { |  | ||||||
|       logger.error("could not parse permission descriptor", ex); |       logger.error("could not parse permission descriptor", ex); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     return descriptors; |     return descriptors; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   /** |   private static ImmutableSet<PermissionDescriptor> readAvailablePermissions(PluginLoader pluginLoader) { | ||||||
|    * Method description |  | ||||||
|    * |  | ||||||
|    * @param pluginLoader |  | ||||||
|    */ |  | ||||||
|   private static ImmutableSet<PermissionDescriptor> readAvailablePermissions(PluginLoader pluginLoader) |  | ||||||
|   { |  | ||||||
|     ImmutableSet.Builder<PermissionDescriptor> builder = ImmutableSet.builder(); |     ImmutableSet.Builder<PermissionDescriptor> builder = ImmutableSet.builder(); | ||||||
|  |  | ||||||
|     try |     try { | ||||||
|     { |  | ||||||
|       JAXBContext context = |       JAXBContext context = | ||||||
|         JAXBContext.newInstance(PermissionDescriptors.class); |         JAXBContext.newInstance(PermissionDescriptors.class); | ||||||
|  |  | ||||||
| @@ -306,21 +203,16 @@ public class DefaultSecuritySystem implements SecuritySystem | |||||||
|       Enumeration<URL> descirptorEnum = |       Enumeration<URL> descirptorEnum = | ||||||
|         pluginLoader.getUberClassLoader().getResources(PERMISSION_DESCRIPTOR); |         pluginLoader.getUberClassLoader().getResources(PERMISSION_DESCRIPTOR); | ||||||
|  |  | ||||||
|       while (descirptorEnum.hasMoreElements()) |       while (descirptorEnum.hasMoreElements()) { | ||||||
|       { |  | ||||||
|         URL descriptorUrl = descirptorEnum.nextElement(); |         URL descriptorUrl = descirptorEnum.nextElement(); | ||||||
|  |  | ||||||
|         logger.debug("read permission descriptor from {}", descriptorUrl); |         logger.debug("read permission descriptor from {}", descriptorUrl); | ||||||
|  |  | ||||||
|         builder.addAll(parsePermissionDescriptor(context, descriptorUrl)); |         builder.addAll(parsePermissionDescriptor(context, descriptorUrl)); | ||||||
|       } |       } | ||||||
|     } |     } catch (IOException ex) { | ||||||
|     catch (IOException ex) |  | ||||||
|     { |  | ||||||
|       logger.error("could not read permission descriptors", ex); |       logger.error("could not read permission descriptors", ex); | ||||||
|     } |     } catch (JAXBException ex) { | ||||||
|     catch (JAXBException ex) |  | ||||||
|     { |  | ||||||
|       logger.error( |       logger.error( | ||||||
|         "could not create jaxb context to read permission descriptors", ex); |         "could not create jaxb context to read permission descriptors", ex); | ||||||
|     } |     } | ||||||
| @@ -328,62 +220,34 @@ public class DefaultSecuritySystem implements SecuritySystem | |||||||
|     return builder.build(); |     return builder.build(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   /** |   private void validatePermission(AssignedPermission perm) { | ||||||
|    * Method description |  | ||||||
|    * |  | ||||||
|    * |  | ||||||
|    * @param perm |  | ||||||
|    */ |  | ||||||
|   private void validatePermission(AssignedPermission perm) |  | ||||||
|   { |  | ||||||
|     Preconditions.checkArgument(!Strings.isNullOrEmpty(perm.getName()), |     Preconditions.checkArgument(!Strings.isNullOrEmpty(perm.getName()), | ||||||
|       "name is required"); |       "name is required"); | ||||||
|     Preconditions.checkArgument(!isNull(perm.getPermission()), |     Preconditions.checkArgument(!isNull(perm.getPermission()), | ||||||
|       "permission is required"); |       "permission is required"); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   //~--- inner classes -------------------------------------------------------- |  | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * Descriptor for permissions. |    * Descriptor for permissions. | ||||||
|    */ |    */ | ||||||
|   @XmlRootElement(name = "permissions") |   @XmlRootElement(name = "permissions") | ||||||
|   @XmlAccessorType(XmlAccessType.FIELD) |   @XmlAccessorType(XmlAccessType.FIELD) | ||||||
|   private static class PermissionDescriptors |   private static class PermissionDescriptors { | ||||||
|   { |  | ||||||
|  |  | ||||||
|     //~--- get methods -------------------------------------------------------- |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * Method description |  | ||||||
|      * |  | ||||||
|      * |  | ||||||
|      * @return |  | ||||||
|      */ |  | ||||||
|     @SuppressWarnings("unchecked") |     @SuppressWarnings("unchecked") | ||||||
|     public List<PermissionDescriptor> getPermissions() |     public List<PermissionDescriptor> getPermissions() { | ||||||
|     { |       if (permissions == null) { | ||||||
|       if (permissions == null) |  | ||||||
|       { |  | ||||||
|         permissions = Collections.EMPTY_LIST; |         permissions = Collections.EMPTY_LIST; | ||||||
|       } |       } | ||||||
|  |  | ||||||
|       return permissions; |       return permissions; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     //~--- fields ------------------------------------------------------------- |  | ||||||
|  |  | ||||||
|     /** Field description */ |  | ||||||
|     @XmlElement(name = "permission") |     @XmlElement(name = "permission") | ||||||
|     private List<PermissionDescriptor> permissions; |     private List<PermissionDescriptor> permissions; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |  | ||||||
|   //~--- fields --------------------------------------------------------------- |  | ||||||
|  |  | ||||||
|   /** Field description */ |  | ||||||
|   private final ConfigurationEntryStore<AssignedPermission> store; |   private final ConfigurationEntryStore<AssignedPermission> store; | ||||||
|  |  | ||||||
|   /** Field description */ |  | ||||||
|   private final ImmutableSet<PermissionDescriptor> availablePermissions; |   private final ImmutableSet<PermissionDescriptor> availablePermissions; | ||||||
| } | } | ||||||
|   | |||||||
| @@ -21,29 +21,21 @@ | |||||||
|  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||||
|  * SOFTWARE. |  * SOFTWARE. | ||||||
|  */ |  */ | ||||||
|      |  | ||||||
| package sonia.scm.template; | package sonia.scm.template; | ||||||
|  |  | ||||||
| //~--- non-JDK imports -------------------------------------------------------- |  | ||||||
|  |  | ||||||
| import com.github.mustachejava.Mustache; | import com.github.mustachejava.Mustache; | ||||||
|  |  | ||||||
| import com.google.common.base.Throwables; | import com.google.common.base.Throwables; | ||||||
|  |  | ||||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||||
|  |  | ||||||
| //~--- JDK imports ------------------------------------------------------------ |  | ||||||
|  |  | ||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
| import java.io.Writer; | import java.io.Writer; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * |  | ||||||
|  * @author Sebastian Sdorra |  * @author Sebastian Sdorra | ||||||
|  */ |  */ | ||||||
| public class MustacheTemplate implements Template | public class MustacheTemplate implements Template { | ||||||
| { |  | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * the logger for MustacheTemplae |    * the logger for MustacheTemplae | ||||||
| @@ -51,50 +43,22 @@ public class MustacheTemplate implements Template | |||||||
|   private static final Logger logger = |   private static final Logger logger = | ||||||
|     LoggerFactory.getLogger(MustacheTemplate.class); |     LoggerFactory.getLogger(MustacheTemplate.class); | ||||||
|  |  | ||||||
|   //~--- constructors --------------------------------------------------------- |   public MustacheTemplate(String templatePath, Mustache mustache) { | ||||||
|  |  | ||||||
|   /** |  | ||||||
|    * Constructs ... |  | ||||||
|    * |  | ||||||
|    * |  | ||||||
|    * |  | ||||||
|    * @param templatePath |  | ||||||
|    * @param mustache |  | ||||||
|    */ |  | ||||||
|   public MustacheTemplate(String templatePath, Mustache mustache) |  | ||||||
|   { |  | ||||||
|     this.templatePath = templatePath; |     this.templatePath = templatePath; | ||||||
|     this.mustache = mustache; |     this.mustache = mustache; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   //~--- methods -------------------------------------------------------------- |  | ||||||
|  |  | ||||||
|   /** |  | ||||||
|    * Method description |  | ||||||
|    * |  | ||||||
|    * |  | ||||||
|    * @param writer |  | ||||||
|    * @param environment |  | ||||||
|    * @param model |  | ||||||
|    * |  | ||||||
|    * @throws IOException |  | ||||||
|    */ |  | ||||||
|   @Override |   @Override | ||||||
|   public void execute(Writer writer, Object model) throws IOException |   public void execute(Writer writer, Object model) throws IOException { | ||||||
|   { |     if (logger.isDebugEnabled()) { | ||||||
|     if (logger.isDebugEnabled()) |  | ||||||
|     { |  | ||||||
|       logger.debug("render mustache template at {}", templatePath); |       logger.debug("render mustache template at {}", templatePath); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     try |     try { | ||||||
|     { |  | ||||||
|  |  | ||||||
|       mustache.execute(writer, model); |       mustache.execute(writer, model); | ||||||
|  |  | ||||||
|     } |     } catch (Exception ex) { | ||||||
|     catch (Exception ex) |  | ||||||
|     { |  | ||||||
|       Throwables.propagateIfInstanceOf(ex, IOException.class); |       Throwables.propagateIfInstanceOf(ex, IOException.class); | ||||||
|  |  | ||||||
|       throw new TemplateRenderException( |       throw new TemplateRenderException( | ||||||
| @@ -102,11 +66,7 @@ public class MustacheTemplate implements Template | |||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   //~--- fields --------------------------------------------------------------- |  | ||||||
|  |  | ||||||
|   /** Field description */ |  | ||||||
|   private Mustache mustache; |   private Mustache mustache; | ||||||
|  |  | ||||||
|   /** Field description */ |  | ||||||
|   private String templatePath; |   private String templatePath; | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user