mirror of https://github.com/apache/archiva.git
[MRM-1519] api to configure webappconfiguration
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1175919 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e23376ad2a
commit
fcfd86cf53
|
@ -23,6 +23,7 @@ import org.apache.archiva.admin.model.RepositoryAdminException;
|
|||
import org.apache.archiva.admin.model.beans.FileType;
|
||||
import org.apache.archiva.admin.model.beans.LegacyArtifactPath;
|
||||
import org.apache.archiva.admin.model.beans.OrganisationInformation;
|
||||
import org.apache.archiva.admin.model.beans.UiConfiguration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -90,4 +91,10 @@ public interface ArchivaAdministration
|
|||
void setOrganisationInformation( OrganisationInformation organisationInformation )
|
||||
throws RepositoryAdminException;
|
||||
|
||||
UiConfiguration getUiConfiguration()
|
||||
throws RepositoryAdminException;
|
||||
|
||||
void updateUiConfiguration( UiConfiguration uiConfiguration )
|
||||
throws RepositoryAdminException;
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
package org.apache.archiva.admin.model.beans;
|
||||
/*
|
||||
* 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 javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
* @author Olivier Lamy
|
||||
* @since 1.4
|
||||
*/
|
||||
@XmlRootElement( name = "uiConfiguration" )
|
||||
public class UiConfiguration
|
||||
{
|
||||
/**
|
||||
* true if find artifacts should be enabled.
|
||||
*/
|
||||
private boolean showFindArtifacts = true;
|
||||
|
||||
/**
|
||||
* true if applet behavior for find artifacts should be enabled.
|
||||
*/
|
||||
private boolean appletFindEnabled = true;
|
||||
|
||||
/**
|
||||
* Field disableEasterEggs.
|
||||
*/
|
||||
private boolean disableEasterEggs = false;
|
||||
|
||||
public UiConfiguration()
|
||||
{
|
||||
// noop
|
||||
}
|
||||
|
||||
public boolean isShowFindArtifacts()
|
||||
{
|
||||
return showFindArtifacts;
|
||||
}
|
||||
|
||||
public void setShowFindArtifacts( boolean showFindArtifacts )
|
||||
{
|
||||
this.showFindArtifacts = showFindArtifacts;
|
||||
}
|
||||
|
||||
public boolean isAppletFindEnabled()
|
||||
{
|
||||
return appletFindEnabled;
|
||||
}
|
||||
|
||||
public void setAppletFindEnabled( boolean appletFindEnabled )
|
||||
{
|
||||
this.appletFindEnabled = appletFindEnabled;
|
||||
}
|
||||
|
||||
public boolean isDisableEasterEggs()
|
||||
{
|
||||
return disableEasterEggs;
|
||||
}
|
||||
|
||||
public void setDisableEasterEggs( boolean disableEasterEggs )
|
||||
{
|
||||
this.disableEasterEggs = disableEasterEggs;
|
||||
}
|
||||
}
|
|
@ -25,10 +25,13 @@ import org.apache.archiva.admin.model.admin.ArchivaAdministration;
|
|||
import org.apache.archiva.admin.model.beans.FileType;
|
||||
import org.apache.archiva.admin.model.beans.LegacyArtifactPath;
|
||||
import org.apache.archiva.admin.model.beans.OrganisationInformation;
|
||||
import org.apache.archiva.admin.model.beans.UiConfiguration;
|
||||
import org.apache.archiva.admin.repository.AbstractRepositoryAdmin;
|
||||
import org.apache.archiva.audit.AuditEvent;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.archiva.configuration.Configuration;
|
||||
import org.apache.archiva.configuration.UserInterfaceOptions;
|
||||
import org.apache.archiva.configuration.WebappConfiguration;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -146,8 +149,7 @@ public class DefaultArchivaAdministration
|
|||
throws RepositoryAdminException
|
||||
{
|
||||
Configuration configuration = getArchivaConfiguration().getConfiguration();
|
||||
org.apache.archiva.configuration.FileType fileType =
|
||||
new org.apache.archiva.configuration.FileType();
|
||||
org.apache.archiva.configuration.FileType fileType = new org.apache.archiva.configuration.FileType();
|
||||
fileType.setId( fileTypeId );
|
||||
configuration.getRepositoryScanning().removeFileType( fileType );
|
||||
saveConfiguration( configuration );
|
||||
|
@ -286,7 +288,42 @@ public class DefaultArchivaAdministration
|
|||
saveConfiguration( configuration );
|
||||
}
|
||||
|
||||
//-------------------------
|
||||
public UiConfiguration getUiConfiguration()
|
||||
throws RepositoryAdminException
|
||||
{
|
||||
WebappConfiguration webappConfiguration = getArchivaConfiguration().getConfiguration().getWebapp();
|
||||
if ( webappConfiguration == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
UserInterfaceOptions userInterfaceOptions = webappConfiguration.getUi();
|
||||
if ( userInterfaceOptions == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new BeanReplicator().replicateBean( userInterfaceOptions, UiConfiguration.class );
|
||||
}
|
||||
|
||||
public void updateUiConfiguration( UiConfiguration uiConfiguration )
|
||||
throws RepositoryAdminException
|
||||
{
|
||||
Configuration configuration = getArchivaConfiguration().getConfiguration();
|
||||
if ( uiConfiguration != null )
|
||||
{
|
||||
|
||||
UserInterfaceOptions userInterfaceOptions =
|
||||
new BeanReplicator().replicateBean( uiConfiguration, UserInterfaceOptions.class );
|
||||
configuration.getWebapp().setUi( userInterfaceOptions );
|
||||
}
|
||||
else
|
||||
{
|
||||
configuration.getWebapp().setUi( null );
|
||||
}
|
||||
saveConfiguration( configuration );
|
||||
|
||||
}
|
||||
|
||||
//-------------------------
|
||||
//
|
||||
//-------------------------
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.apache.archiva.admin.model.admin.ArchivaAdministration;
|
|||
import org.apache.archiva.admin.model.beans.FileType;
|
||||
import org.apache.archiva.admin.model.beans.LegacyArtifactPath;
|
||||
import org.apache.archiva.admin.model.beans.OrganisationInformation;
|
||||
import org.apache.archiva.admin.model.beans.UiConfiguration;
|
||||
import org.apache.archiva.admin.repository.AbstractRepositoryAdminTest;
|
||||
import org.apache.archiva.audit.AuditEvent;
|
||||
import org.junit.Test;
|
||||
|
@ -170,17 +171,20 @@ public class ArchivaAdministrationTest
|
|||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void organisationInfoUpdate()
|
||||
throws Exception
|
||||
{
|
||||
OrganisationInformation organisationInformation = archivaAdministration.getOrganisationInformation();
|
||||
assertNull( organisationInformation );
|
||||
assertNotNull( organisationInformation );
|
||||
assertNull( organisationInformation.getLogoLocation() );
|
||||
assertNull( organisationInformation.getName() );
|
||||
assertNull( organisationInformation.getUrl() );
|
||||
|
||||
organisationInformation = new OrganisationInformation();
|
||||
organisationInformation.setLogoLocation( "http://foo.com/bar.png" );
|
||||
organisationInformation.setName( "foo org" );
|
||||
organisationInformation.setUrl( "http:/foo.com" );
|
||||
organisationInformation.setUrl( "http://foo.com" );
|
||||
|
||||
archivaAdministration.setOrganisationInformation( organisationInformation );
|
||||
|
||||
|
@ -191,4 +195,28 @@ public class ArchivaAdministrationTest
|
|||
assertEquals( "http://foo.com", organisationInformation.getUrl() );
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void uiConfiguration()
|
||||
throws Exception
|
||||
{
|
||||
UiConfiguration ui = archivaAdministration.getUiConfiguration();
|
||||
assertNotNull( ui );
|
||||
// assert default values
|
||||
assertFalse( ui.isDisableEasterEggs() );
|
||||
assertTrue( ui.isAppletFindEnabled() );
|
||||
assertTrue( ui.isShowFindArtifacts() );
|
||||
|
||||
ui.setAppletFindEnabled( false );
|
||||
ui.setShowFindArtifacts( false );
|
||||
ui.setDisableEasterEggs( true );
|
||||
|
||||
archivaAdministration.updateUiConfiguration( ui );
|
||||
|
||||
ui = archivaAdministration.getUiConfiguration();
|
||||
|
||||
assertTrue( ui.isDisableEasterEggs() );
|
||||
assertFalse( ui.isAppletFindEnabled() );
|
||||
assertFalse( ui.isShowFindArtifacts() );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue