diff options
author | Olivier Lamy <olamy@apache.org> | 2012-01-17 22:35:08 +0000 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2012-01-17 22:35:08 +0000 |
commit | 58c30c851dcb4fd9d9e544986d8466d4756cfa8b (patch) | |
tree | 6f548075d809c13c766eadc9adb9dd02738813cb /archiva-modules/archiva-base/archiva-repository-admin | |
parent | 32b26356e9446dfc5c4d0fb857466cd808eec353 (diff) | |
download | archiva-58c30c851dcb4fd9d9e544986d8466d4756cfa8b.tar.gz archiva-58c30c851dcb4fd9d9e544986d8466d4756cfa8b.zip |
add a rest method to validate if managed repository location already exists.
So move RepositoryCommonValidator to admin api and add the interface
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1232615 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/archiva-base/archiva-repository-admin')
-rw-r--r-- | archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/RepositoryCommonValidator.java | 60 | ||||
-rw-r--r-- | archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/AbstractRepositoryAdmin.java | 1 | ||||
-rw-r--r-- | archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/DefaultRepositoryCommonValidator.java (renamed from archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/RepositoryCommonValidator.java) | 9 |
3 files changed, 64 insertions, 6 deletions
diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/RepositoryCommonValidator.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/RepositoryCommonValidator.java new file mode 100644 index 000000000..6c862c10b --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/RepositoryCommonValidator.java @@ -0,0 +1,60 @@ +package org.apache.archiva.admin.model; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.archiva.admin.model.beans.AbstractRepository; +import org.apache.archiva.admin.model.beans.ManagedRepository; + +/** + * apply basic repository validation : id and name. + * Check if already exists. + * + * @author Olivier Lamy + * @since 1.4-M3 + */ +public interface RepositoryCommonValidator +{ + + public static final String REPOSITORY_ID_VALID_EXPRESSION = "^[a-zA-Z0-9._-]+$"; + + public static final String REPOSITORY_NAME_VALID_EXPRESSION = "^([a-zA-Z0-9.)/_(-]|\\s)+$"; + + + void basicValidation( AbstractRepository abstractRepository, boolean update ) + throws RepositoryAdminException; + + /** + * validate cronExpression and location format + * + * @param managedRepository + * @since 1.4-M2 + */ + void validateManagedRepository( ManagedRepository managedRepository ) + throws RepositoryAdminException; + + /** + * replace some interpolations ${appserver.base} with correct values + * + * @param directory + * @return + */ + String removeExpressions( String directory ); + + +} diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/AbstractRepositoryAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/AbstractRepositoryAdmin.java index bb26445e8..bed10a5a1 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/AbstractRepositoryAdmin.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/AbstractRepositoryAdmin.java @@ -20,6 +20,7 @@ package org.apache.archiva.admin.repository; import org.apache.archiva.admin.model.AuditInformation; import org.apache.archiva.admin.model.RepositoryAdminException; +import org.apache.archiva.admin.model.RepositoryCommonValidator; import org.apache.archiva.audit.AuditEvent; import org.apache.archiva.audit.AuditListener; import org.apache.archiva.configuration.ArchivaConfiguration; diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/RepositoryCommonValidator.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/DefaultRepositoryCommonValidator.java index 05756fd48..5ee256b97 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/RepositoryCommonValidator.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/DefaultRepositoryCommonValidator.java @@ -19,6 +19,7 @@ package org.apache.archiva.admin.repository; */ import org.apache.archiva.admin.model.RepositoryAdminException; +import org.apache.archiva.admin.model.RepositoryCommonValidator; import org.apache.archiva.admin.model.beans.AbstractRepository; import org.apache.archiva.admin.model.beans.ManagedRepository; import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin; @@ -41,14 +42,10 @@ import javax.inject.Named; * @since 1.4-M1 */ @Service -public class RepositoryCommonValidator +public class DefaultRepositoryCommonValidator + implements RepositoryCommonValidator { - public static final String REPOSITORY_ID_VALID_EXPRESSION = "^[a-zA-Z0-9._-]+$"; - - public static final String REPOSITORY_NAME_VALID_EXPRESSION = "^([a-zA-Z0-9.)/_(-]|\\s)+$"; - - @Inject private ArchivaConfiguration archivaConfiguration; |