Package org.apache.commons.scxml2.io

Examples of org.apache.commons.scxml2.io.SCXMLReader$Configuration


    }


    @Test
    public void testDontRotate() throws IndexNotFoundException {
        final Configuration configuration = mock(Configuration.class);
        final Indices indices = mock(Indices.class);

        final IndexStatistics stats = new IndexStatistics();
        final CommonStats commonStats = new CommonStats();
        commonStats.store = new StoreStats(1000, 0);
        stats.setPrimaries(commonStats);

        when(indices.getIndexStats("name")).thenReturn(stats);
        when(configuration.getElasticSearchMaxSizePerIndex()).thenReturn(100000L);

        final SizeBasedRotationStrategy strategy = new SizeBasedRotationStrategy(configuration,
                                                                                 indices);
        final RotationStrategy.Result rotate = strategy.shouldRotate("name");
View Full Code Here


    }


    @Test
    public void testRotateFailed() throws IndexNotFoundException {
        final Configuration configuration = mock(Configuration.class);
        final Indices indices = mock(Indices.class);

        when(indices.getIndexStats("name")).thenReturn(null);
        when(configuration.getElasticSearchMaxSizePerIndex()).thenReturn(100L);

        final SizeBasedRotationStrategy strategy = new SizeBasedRotationStrategy(configuration,
                                                                                 indices);
        final RotationStrategy.Result rotate = strategy.shouldRotate("name");
View Full Code Here

public class MessageCountRotationStrategyTest {

    @Test
    public void testRotate() throws IndexNotFoundException {
        final Configuration configuration = mock(Configuration.class);
        final Indices indices = mock(Indices.class);

        when(indices.numberOfMessages("name")).thenReturn(10L);
        when(configuration.getElasticSearchMaxDocsPerIndex()).thenReturn(5);

        final MessageCountRotationStrategy strategy = new MessageCountRotationStrategy(configuration,
                                                                                       indices);
        final RotationStrategy.Result rotate = strategy.shouldRotate("name");
View Full Code Here

        assertEquals(true, rotate.shouldRotate());
    }

    @Test
    public void testDontRotate() throws IndexNotFoundException {
        final Configuration configuration = mock(Configuration.class);
        final Indices indices = mock(Indices.class);

        when(indices.numberOfMessages("name")).thenReturn(1L);
        when(configuration.getElasticSearchMaxDocsPerIndex()).thenReturn(5);

        final MessageCountRotationStrategy strategy = new MessageCountRotationStrategy(configuration,
                                                                                       indices);

        final RotationStrategy.Result rotate = strategy.shouldRotate("name");
View Full Code Here

    }


    @Test
    public void testIndexUnavailable() throws IndexNotFoundException {
        final Configuration configuration = mock(Configuration.class);
        final Indices indices = mock(Indices.class);

        when(indices.numberOfMessages("name")).thenThrow(IndexNotFoundException.class).thenReturn(1L);
        when(configuration.getElasticSearchMaxDocsPerIndex()).thenReturn(5);

        final MessageCountRotationStrategy strategy = new MessageCountRotationStrategy(configuration,
                                                                                       indices);
        final RotationStrategy.Result rotate = strategy.shouldRotate("name");
View Full Code Here

      @Override
      public Configuration upgradeConfiguration(
          final org.sonatype.nexus.configuration.model.v2_2_0.Configuration oldConfig)
      {
        final Configuration newConfig = super.upgradeConfiguration(oldConfig);

        if (oldConfig.getGlobalHttpProxySettings() != null) {
          newConfig.setRemoteProxySettings(new CRemoteProxySettings());
          newConfig.getRemoteProxySettings().setHttpProxySettings(
              upgradeCRemoteHttpProxySettings(oldConfig.getGlobalHttpProxySettings())
          );
          newConfig.getRemoteProxySettings().setNonProxyHosts(
              oldConfig.getGlobalHttpProxySettings().getNonProxyHosts()
          );
        }

        return newConfig;
View Full Code Here

    org.sonatype.nexus.configuration.model.v2_5_0.Configuration oldc =
        (org.sonatype.nexus.configuration.model.v2_5_0.Configuration) message.getConfiguration();

    BasicVersionUpgrade versionConverter = new BasicVersionUpgrade();

    Configuration newc = versionConverter.upgradeConfiguration(oldc);
    newc.setVersion(Configuration.MODEL_VERSION);

    upgradeEmptyTrashTaskConfiguration(newc);
    updateSmtpSslTlsSettings(newc);

    message.setModelVersion(Configuration.MODEL_VERSION);
View Full Code Here

  }

  public void upgrade(UpgradeMessage message)
      throws ConfigurationIsCorruptedException
  {
    Configuration oldc = (Configuration) message.getConfiguration();

    org.sonatype.security.model.v2_0_0.Configuration newc = new org.sonatype.security.model.v2_0_0.Configuration();

    newc.setVersion(org.sonatype.security.model.v2_0_0.Configuration.MODEL_VERSION);

    for (CUser oldu : (List<CUser>) oldc.getUsers()) {
      org.sonatype.security.model.v2_0_0.CUser newu = new org.sonatype.security.model.v2_0_0.CUser();

      newu.setEmail(oldu.getEmail());
      newu.setId(oldu.getUserId());
      newu.setName(oldu.getName());
      newu.setPassword(oldu.getPassword());
      newu.setStatus(oldu.getStatus());
      newu.setRoles(oldu.getRoles());

      newc.addUser(newu);
    }

    for (CRole oldr : (List<CRole>) oldc.getRoles()) {
      org.sonatype.security.model.v2_0_0.CRole newr = new org.sonatype.security.model.v2_0_0.CRole();

      newr.setDescription(oldr.getDescription());
      newr.setId(oldr.getId());
      newr.setName(oldr.getName());
      newr.setPrivileges(oldr.getPrivileges());
      newr.setRoles(oldr.getRoles());
      newr.setSessionTimeout(oldr.getSessionTimeout());

      newc.addRole(newr);
    }

    for (CRepoTargetPrivilege oldp : (List<CRepoTargetPrivilege>) oldc.getRepositoryTargetPrivileges()) {
      org.sonatype.security.model.v2_0_0.CPrivilege newp = new org.sonatype.security.model.v2_0_0.CPrivilege();

      newp.setDescription(oldp.getDescription());
      newp.setId(oldp.getId());
      newp.setName(oldp.getName());
      newp.setType("target");

      org.sonatype.security.model.v2_0_0.CProperty prop = new org.sonatype.security.model.v2_0_0.CProperty();
      prop.setKey("method");
      prop.setValue(oldp.getMethod());
      newp.addProperty(prop);

      if (!StringUtils.isEmpty(oldp.getRepositoryId())) {
        prop = new org.sonatype.security.model.v2_0_0.CProperty();
        prop.setKey("repositoryGroupId");
        prop.setValue(oldp.getGroupId());
        newp.addProperty(prop);
      }

      if (!StringUtils.isEmpty(oldp.getRepositoryId())) {
        prop = new org.sonatype.security.model.v2_0_0.CProperty();
        prop.setKey("repositoryId");
        prop.setValue(oldp.getRepositoryId());
        newp.addProperty(prop);
      }

      prop = new org.sonatype.security.model.v2_0_0.CProperty();
      prop.setKey("repositoryTargetId");
      prop.setValue(oldp.getRepositoryTargetId());
      newp.addProperty(prop);

      newc.addPrivilege(newp);
    }

    for (CApplicationPrivilege oldp : (List<CApplicationPrivilege>) oldc.getApplicationPrivileges()) {
      org.sonatype.security.model.v2_0_0.CPrivilege newp = new org.sonatype.security.model.v2_0_0.CPrivilege();

      newp.setDescription(oldp.getDescription());
      newp.setId(oldp.getId());
      newp.setName(oldp.getName());
View Full Code Here

  @SuppressWarnings("unchecked")
  public void upgrade(UpgradeMessage message)
      throws ConfigurationIsCorruptedException
  {
    Configuration oldc = (Configuration) message.getConfiguration();

    org.sonatype.security.model.v2_0_1.Configuration newc = new org.sonatype.security.model.v2_0_1.Configuration();

    newc.setVersion(org.sonatype.security.model.v2_0_1.Configuration.MODEL_VERSION);

    for (CUser oldu : (List<CUser>) oldc.getUsers()) {
      org.sonatype.security.model.v2_0_1.CUser newu = new org.sonatype.security.model.v2_0_1.CUser();

      newu.setEmail(oldu.getEmail());
      newu.setId(oldu.getId());
      newu.setName(oldu.getName());
      newu.setPassword(oldu.getPassword());
      newu.setStatus(oldu.getStatus());
      newu.setRoles(oldu.getRoles());

      newc.addUser(newu);
    }

    List<RoleMap> roleMapList = new ArrayList<RoleMap>();

    for (CRole oldr : (List<CRole>) oldc.getRoles()) {
      // Simplest case, not an internal role, just copy
      if (!getRolesToRemove().contains(oldr.getId())) {
        org.sonatype.security.model.v2_0_1.CRole newr = new org.sonatype.security.model.v2_0_1.CRole();

        newr.setDescription(oldr.getDescription());
        newr.setId(oldr.getId());
        newr.setName(oldr.getName());
        newr.setPrivileges(oldr.getPrivileges());
        newr.setRoles(oldr.getRoles());
        newr.setSessionTimeout(oldr.getSessionTimeout());

        newc.addRole(newr);
      }
      // If we have internally, and the user has changed the role previously (as read only is new in this version)
      else if (shouldArchiveRole(oldr)) {
        org.sonatype.security.model.v2_0_1.CRole newr = new org.sonatype.security.model.v2_0_1.CRole();

        newr.setDescription(oldr.getDescription());
        newr.setId(oldr.getId() + "-customized");
        newr.setName(oldr.getName() + " (Customized)");
        newr.setPrivileges(oldr.getPrivileges());
        newr.setRoles(oldr.getRoles());
        newr.setSessionTimeout(oldr.getSessionTimeout());

        newc.addRole(newr);

        roleMapList.add(new RoleMap(oldr.getId(), newr.getId()));
      }
      // else the role will be removed, if it is now internal, and the user hasn't changed it
    }

    for (CPrivilege oldp : (List<CPrivilege>) oldc.getPrivileges()) {
      if (!getPrivsToRemove().contains(oldp.getId())) {
        org.sonatype.security.model.v2_0_1.CPrivilege newp =
            new org.sonatype.security.model.v2_0_1.CPrivilege();

        newp.setDescription(oldp.getDescription());
View Full Code Here

  }

  public void upgrade(UpgradeMessage message)
      throws ConfigurationIsCorruptedException
  {
    Configuration oldc = (Configuration) message.getConfiguration();

    org.sonatype.security.model.v2_0_2.Configuration newc = new org.sonatype.security.model.v2_0_2.Configuration();

    newc.setVersion(org.sonatype.security.model.Configuration.MODEL_VERSION);

    for (CUser oldu : (List<CUser>) oldc.getUsers()) {
      org.sonatype.security.model.v2_0_2.CUser newu = new org.sonatype.security.model.v2_0_2.CUser();

      newu.setEmail(oldu.getEmail());
      newu.setId(oldu.getId());
      newu.setName(oldu.getName());
      newu.setPassword(oldu.getPassword());
      newu.setStatus(oldu.getStatus());

      // convert the old roles mapping to the new one
      this.migrateOldRolesToUserRoleMapping(oldu.getId(), DEFAULT_SOURCE, oldu.getRoles(), newc);

      newc.addUser(newu);
    }

    Map<String, String> roleIdMap = new HashMap<String, String>();

    for (CRole oldr : (List<CRole>) oldc.getRoles()) {
      org.sonatype.security.model.v2_0_2.CRole newr = new org.sonatype.security.model.v2_0_2.CRole();

      newr.setDescription(oldr.getDescription());
      newr.setId(oldr.getId());
      newr.setName(oldr.getName());
      newr.setPrivileges(oldr.getPrivileges());
      newr.setRoles(oldr.getRoles());
      newr.setSessionTimeout(oldr.getSessionTimeout());

      newc.addRole(newr);

    }

    for (CPrivilege oldp : (List<CPrivilege>) oldc.getPrivileges()) {
      org.sonatype.security.model.v2_0_2.CPrivilege newp = new org.sonatype.security.model.v2_0_2.CPrivilege();

      newp.setDescription(oldp.getDescription());
      newp.setId(oldp.getId());
      newp.setName(oldp.getName());
View Full Code Here

TOP

Related Classes of org.apache.commons.scxml2.io.SCXMLReader$Configuration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.