java.util.List<String> repos = map.get( groupId );
if ( repos == null )
{
- repos = new java.util.ArrayList<String>();
+ repos = new ArrayList<String>();
map.put( groupId, repos );
}
repos.add( repo.getId() );
java.util.List<String> groups = map.get( repositoryId );
if ( groups == null )
{
- groups = new java.util.ArrayList<String>();
+ groups = new ArrayList<String>();
map.put( repositoryId, groups );
}
groups.add( group.getId() );
import org.apache.archiva.admin.model.proxyconnectorrule.ProxyConnectorRuleAdmin;
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
import org.apache.archiva.rest.api.services.ProxyConnectorRuleService;
+import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import javax.inject.Inject;
/**
* @author Olivier Lamy
*/
-@Service ( "proxyConnectorRuleService#rest" )
+@Service ("proxyConnectorRuleService#rest")
public class DefaultProxyConnectorRuleService
extends AbstractRestService
implements ProxyConnectorRuleService
}
}
+ private void validateProxyConnectorRule( ProxyConnectorRule proxyConnectorRule )
+ throws ArchivaRestServiceException
+ {
+ if ( StringUtils.isEmpty( proxyConnectorRule.getPattern() ) )
+ {
+ ArchivaRestServiceException e = new ArchivaRestServiceException( "pattern cannot be empty", null );
+ e.setErrorKey( "proxy-connector-rule.pattern.empty" );
+ throw e;
+ }
+
+ if ( proxyConnectorRule.getProxyConnectors() == null || proxyConnectorRule.getProxyConnectors().isEmpty() )
+ {
+ ArchivaRestServiceException e =
+ new ArchivaRestServiceException( "proxyConnector rule must have proxyConnectors.", null );
+ e.setErrorKey( "proxy-connector-rule.pattern.connectors.empty" );
+ throw e;
+ }
+
+ for ( ProxyConnectorRule proxyConnectorRule1 : getProxyConnectorRules() )
+ {
+ if ( StringUtils.equals( proxyConnectorRule.getPattern(), proxyConnectorRule1.getPattern() )
+ && proxyConnectorRule.getProxyConnectorRuleType() == proxyConnectorRule1.getProxyConnectorRuleType() )
+ {
+ ArchivaRestServiceException e =
+ new ArchivaRestServiceException( "same ProxyConnector rule already exists.", null );
+ e.setErrorKey( "proxy-connector-rule.pattern.already.exists" );
+ throw e;
+ }
+ }
+ }
+
public Boolean addProxyConnectorRule( ProxyConnectorRule proxyConnectorRule )
throws ArchivaRestServiceException
{
+
+ validateProxyConnectorRule( proxyConnectorRule );
+
try
{
proxyConnectorRuleAdmin.addProxyConnectorRule( proxyConnectorRule, getAuditInformation() );
proxy-connector-rule.pattern=Pattern
proxy-connector-rule.added=ProxyConnector rule added.
proxy-connector-rule.updated=ProxyConnector rule updated.
+proxy-connector-rule.pattern.empty=Pattern cannot be empty.
+proxy-connector-rule.pattern.already.exists=Same ProxyConnector rule already exists.
+proxy-connector-rule.pattern.connectors.empty=You must select proxyConnectors.
* specific language governing permissions and limitations
* under the License.
*/
-define("archiva.proxy-connectors-rules",["jquery","i18n","jquery.tmpl","bootstrap","jquery.validate","knockout"
+define("archiva.proxy-connectors-rules",["jquery","i18n","jquery.tmpl","bootstrap","jquery.ui","knockout"
,"knockout.simpleGrid","knockout.sortable","archiva.proxy-connectors"], function() {
addProxyConnectorRule=function(proxyConnectorRule){
$("#proxy-connector-rule-add-btn" ).button("loading");
$.log("addProxyConnectorRule");
- self.saveProxyConnectorRule(proxyConnectorRule,"restServices/archivaServices/proxyConnectorRuleService/proxyConnectorRule",true);
+ self.saveProxyConnectorRule(proxyConnectorRule,"restServices/archivaServices/proxyConnectorRuleService/proxyConnectorRule",true,
+ function(){
+ $("#proxy-connector-rule-add-btn" ).button("reset");
+ });
}
this.saveProxyConnectorRule=function(proxyConnectorRule,url,add,completeFnCallback){
<div class="control-group">
<label class="control-label" for="id">${$.i18n.prop('proxy-connector-rule.pattern')}</label>
<div class="controls">
- <input type="text" class="input-large required" id="proxy-connector-rule-pattern" name="id" size="15"
+ <input type="text" class="input-large required" id="pattern" name="pattern" size="15"
data-bind="value:proxyConnectorRule.pattern,css:{'uneditable-input': update},readonly:update"/>
</div>
</div>