Search in sources :

Example 1 with UserInterfaceOptions

use of org.apache.archiva.configuration.model.UserInterfaceOptions in project archiva by apache.

the class ArchivaConfigurationTest method testStoreConfigurationUser.

@Test
public void testStoreConfigurationUser() throws Exception {
    Path baseFile = getTestFile("target/test/test-file.xml");
    Files.deleteIfExists(baseFile);
    assertFalse(Files.exists(baseFile));
    Path userFile = getTestFile("target/test/test-file-user.xml");
    Files.deleteIfExists(userFile);
    assertFalse(Files.exists(userFile));
    Files.createDirectories(userFile.getParent());
    FileUtils.writeStringToFile(userFile.toFile(), "<configuration/>", Charset.forName("UTF-8"));
    ArchivaConfiguration archivaConfiguration = lookup(ArchivaConfiguration.class, "test-save-user");
    Configuration configuration = new Configuration();
    configuration.setWebapp(new WebappConfiguration());
    configuration.getWebapp().setUi(new UserInterfaceOptions());
    configuration.getWebapp().getUi().setAppletFindEnabled(false);
    archivaConfiguration.save(configuration);
    assertTrue("Check file exists", Files.exists(userFile));
    assertFalse("Check file not created", Files.exists(baseFile));
    // check it
    configuration = archivaConfiguration.getConfiguration();
    assertFalse("check value", configuration.getWebapp().getUi().isAppletFindEnabled());
}
Also used : Path(java.nio.file.Path) LegacyArtifactPath(org.apache.archiva.configuration.model.LegacyArtifactPath) WebappConfiguration(org.apache.archiva.configuration.model.WebappConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) ProxyConnectorConfiguration(org.apache.archiva.configuration.model.ProxyConnectorConfiguration) RepositoryGroupConfiguration(org.apache.archiva.configuration.model.RepositoryGroupConfiguration) Configuration(org.apache.archiva.configuration.model.Configuration) RepositoryScanningConfiguration(org.apache.archiva.configuration.model.RepositoryScanningConfiguration) RemoteRepositoryConfiguration(org.apache.archiva.configuration.model.RemoteRepositoryConfiguration) WebappConfiguration(org.apache.archiva.configuration.model.WebappConfiguration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) NetworkProxyConfiguration(org.apache.archiva.configuration.model.NetworkProxyConfiguration) UserInterfaceOptions(org.apache.archiva.configuration.model.UserInterfaceOptions) Test(org.junit.Test)

Example 2 with UserInterfaceOptions

use of org.apache.archiva.configuration.model.UserInterfaceOptions in project archiva by apache.

the class ArchivaConfigurationTest method testStoreConfiguration.

@Test
public void testStoreConfiguration() throws Exception {
    Path file = getTestFile("target/test/test-file.xml");
    Files.deleteIfExists(file);
    assertFalse(Files.exists(file));
    // TODO: remove with commons-configuration 1.4
    // file.getParentFile().mkdirs();
    // FileUtils.writeStringToFile( file, "<configuration/>", null );
    DefaultArchivaConfiguration archivaConfiguration = (DefaultArchivaConfiguration) lookup(ArchivaConfiguration.class, "test-save");
    archivaConfiguration.reload();
    Configuration configuration = new Configuration();
    configuration.setVersion("1");
    configuration.setWebapp(new WebappConfiguration());
    configuration.getWebapp().setUi(new UserInterfaceOptions());
    configuration.getWebapp().getUi().setAppletFindEnabled(false);
    // add a change listener
    ConfigurationListener listener = mock(ConfigurationListener.class);
    archivaConfiguration.addListener(listener);
    listener.configurationEvent(new ConfigurationEvent(ConfigurationEvent.SAVED));
    archivaConfiguration.save(configuration);
    assertTrue("Check file exists", Files.exists(file));
    // check it
    configuration = archivaConfiguration.getConfiguration();
    assertFalse("check value", configuration.getWebapp().getUi().isAppletFindEnabled());
    // read it back
    archivaConfiguration = (DefaultArchivaConfiguration) lookup(ArchivaConfiguration.class, "test-read-saved");
    archivaConfiguration.reload();
    configuration = archivaConfiguration.getConfiguration();
    assertFalse("check value", configuration.getWebapp().getUi().isAppletFindEnabled());
}
Also used : Path(java.nio.file.Path) LegacyArtifactPath(org.apache.archiva.configuration.model.LegacyArtifactPath) WebappConfiguration(org.apache.archiva.configuration.model.WebappConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) ProxyConnectorConfiguration(org.apache.archiva.configuration.model.ProxyConnectorConfiguration) RepositoryGroupConfiguration(org.apache.archiva.configuration.model.RepositoryGroupConfiguration) Configuration(org.apache.archiva.configuration.model.Configuration) RepositoryScanningConfiguration(org.apache.archiva.configuration.model.RepositoryScanningConfiguration) RemoteRepositoryConfiguration(org.apache.archiva.configuration.model.RemoteRepositoryConfiguration) WebappConfiguration(org.apache.archiva.configuration.model.WebappConfiguration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) NetworkProxyConfiguration(org.apache.archiva.configuration.model.NetworkProxyConfiguration) UserInterfaceOptions(org.apache.archiva.configuration.model.UserInterfaceOptions) Test(org.junit.Test)

Example 3 with UserInterfaceOptions

use of org.apache.archiva.configuration.model.UserInterfaceOptions in project archiva by apache.

the class DefaultArchivaAdministration method updateUiConfiguration.

@Override
public void updateUiConfiguration(UiConfiguration uiConfiguration) throws RepositoryAdminException {
    Configuration configuration = getArchivaConfiguration().getConfiguration();
    if (uiConfiguration != null) {
        UserInterfaceOptions userInterfaceOptions = getModelMapper().map(uiConfiguration, UserInterfaceOptions.class);
        configuration.getWebapp().setUi(userInterfaceOptions);
    } else {
        configuration.getWebapp().setUi(null);
    }
    saveConfiguration(configuration);
}
Also used : WebappConfiguration(org.apache.archiva.configuration.model.WebappConfiguration) Configuration(org.apache.archiva.configuration.model.Configuration) UserInterfaceOptions(org.apache.archiva.configuration.model.UserInterfaceOptions)

Example 4 with UserInterfaceOptions

use of org.apache.archiva.configuration.model.UserInterfaceOptions in project archiva by apache.

the class ArchivaConfigurationTest method testStoreConfigurationFallback.

@Test
public void testStoreConfigurationFallback() throws Exception {
    Path baseFile = getTestFile("target/test/test-file.xml");
    Files.deleteIfExists(baseFile);
    assertFalse(Files.exists(baseFile));
    Path userFile = getTestFile("target/test/test-file-user.xml");
    Files.deleteIfExists(userFile);
    assertFalse(Files.exists(userFile));
    Files.createDirectories(baseFile.getParent());
    FileUtils.writeStringToFile(baseFile.toFile(), "<configuration/>", Charset.forName("UTF-8"));
    ArchivaConfiguration archivaConfiguration = (ArchivaConfiguration) lookup(ArchivaConfiguration.class, "test-save-user-fallback");
    archivaConfiguration.reload();
    Configuration configuration = new Configuration();
    configuration.setWebapp(new WebappConfiguration());
    configuration.getWebapp().setUi(new UserInterfaceOptions());
    configuration.getWebapp().getUi().setAppletFindEnabled(false);
    archivaConfiguration.save(configuration);
    assertTrue("Check file exists", Files.exists(baseFile));
    assertFalse("Check file not created", Files.exists(userFile));
    // check it
    configuration = archivaConfiguration.getConfiguration();
    assertFalse("check value", configuration.getWebapp().getUi().isAppletFindEnabled());
}
Also used : Path(java.nio.file.Path) LegacyArtifactPath(org.apache.archiva.configuration.model.LegacyArtifactPath) WebappConfiguration(org.apache.archiva.configuration.model.WebappConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) ProxyConnectorConfiguration(org.apache.archiva.configuration.model.ProxyConnectorConfiguration) RepositoryGroupConfiguration(org.apache.archiva.configuration.model.RepositoryGroupConfiguration) Configuration(org.apache.archiva.configuration.model.Configuration) RepositoryScanningConfiguration(org.apache.archiva.configuration.model.RepositoryScanningConfiguration) RemoteRepositoryConfiguration(org.apache.archiva.configuration.model.RemoteRepositoryConfiguration) WebappConfiguration(org.apache.archiva.configuration.model.WebappConfiguration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) NetworkProxyConfiguration(org.apache.archiva.configuration.model.NetworkProxyConfiguration) UserInterfaceOptions(org.apache.archiva.configuration.model.UserInterfaceOptions) Test(org.junit.Test)

Example 5 with UserInterfaceOptions

use of org.apache.archiva.configuration.model.UserInterfaceOptions in project archiva by apache.

the class ArchivaConfigurationTest method testStoreConfigurationLoadedFromDefaults.

@Test
public void testStoreConfigurationLoadedFromDefaults() throws Exception {
    Path baseFile = getTestFile("target/test/test-file.xml");
    Files.delete(baseFile);
    assertFalse(Files.exists(baseFile));
    Path userFile = getTestFile("target/test/test-file-user.xml");
    Files.deleteIfExists(userFile);
    assertFalse(Files.exists(userFile));
    ArchivaConfiguration archivaConfiguration = lookup(ArchivaConfiguration.class, "test-save-user-defaults");
    archivaConfiguration.reload();
    Configuration configuration = new Configuration();
    configuration.setWebapp(new WebappConfiguration());
    configuration.getWebapp().setUi(new UserInterfaceOptions());
    configuration.getWebapp().getUi().setAppletFindEnabled(false);
    // add a change listener
    ConfigurationListener listener = createConfigurationListenerMockControl();
    archivaConfiguration.addListener(listener);
    listener.configurationEvent(new ConfigurationEvent(ConfigurationEvent.SAVED));
    archivaConfiguration.save(configuration);
    assertTrue("Check file exists", Files.exists(userFile));
    assertFalse("Check file not created", Files.exists(baseFile));
    // check it
    configuration = archivaConfiguration.getConfiguration();
    assertFalse("check value", configuration.getWebapp().getUi().isAppletFindEnabled());
}
Also used : Path(java.nio.file.Path) LegacyArtifactPath(org.apache.archiva.configuration.model.LegacyArtifactPath) WebappConfiguration(org.apache.archiva.configuration.model.WebappConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) ProxyConnectorConfiguration(org.apache.archiva.configuration.model.ProxyConnectorConfiguration) RepositoryGroupConfiguration(org.apache.archiva.configuration.model.RepositoryGroupConfiguration) Configuration(org.apache.archiva.configuration.model.Configuration) RepositoryScanningConfiguration(org.apache.archiva.configuration.model.RepositoryScanningConfiguration) RemoteRepositoryConfiguration(org.apache.archiva.configuration.model.RemoteRepositoryConfiguration) WebappConfiguration(org.apache.archiva.configuration.model.WebappConfiguration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) NetworkProxyConfiguration(org.apache.archiva.configuration.model.NetworkProxyConfiguration) UserInterfaceOptions(org.apache.archiva.configuration.model.UserInterfaceOptions) Test(org.junit.Test)

Aggregations

UserInterfaceOptions (org.apache.archiva.configuration.model.UserInterfaceOptions)11 WebappConfiguration (org.apache.archiva.configuration.model.WebappConfiguration)10 RepositoryScanningConfiguration (org.apache.archiva.configuration.model.RepositoryScanningConfiguration)7 Configuration (org.apache.archiva.configuration.model.Configuration)6 ManagedRepositoryConfiguration (org.apache.archiva.configuration.model.ManagedRepositoryConfiguration)5 NetworkProxyConfiguration (org.apache.archiva.configuration.model.NetworkProxyConfiguration)5 ProxyConnectorConfiguration (org.apache.archiva.configuration.model.ProxyConnectorConfiguration)5 RemoteRepositoryConfiguration (org.apache.archiva.configuration.model.RemoteRepositoryConfiguration)5 RepositoryGroupConfiguration (org.apache.archiva.configuration.model.RepositoryGroupConfiguration)5 Test (org.junit.Test)5 ContextConfiguration (org.springframework.test.context.ContextConfiguration)5 Path (java.nio.file.Path)4 LegacyArtifactPath (org.apache.archiva.configuration.model.LegacyArtifactPath)4