Example #1
0
  protected CRepository copyCRepository1_0_1(
      org.sonatype.nexus.configuration.model.v1_0_1.CRepository oldrepos) {
    CRepository newrepos = new CRepository();
    newrepos.setId(oldrepos.getId());
    newrepos.setName(oldrepos.getName());
    newrepos.setType("maven2");
    newrepos.setLocalStatus(
        oldrepos.isAvailable()
            ? org.sonatype.nexus.configuration.model.v1_0_2.Configuration.LOCAL_STATUS_IN_SERVICE
            : org.sonatype.nexus.configuration.model.v1_0_2.Configuration
                .LOCAL_STATUS_OUT_OF_SERVICE);
    newrepos.setProxyMode(
        oldrepos.isOffline()
            ? CRepository.PROXY_MODE_BLOCKED_MANUAL
            : CRepository.PROXY_MODE_ALLOW);
    newrepos.setAllowWrite(!oldrepos.isReadOnly());
    newrepos.setBrowseable(oldrepos.isBrowseable());
    newrepos.setIndexable(oldrepos.isIndexable());
    newrepos.setNotFoundCacheTTL(oldrepos.getNotFoundCacheTTL());
    newrepos.setArtifactMaxAge(oldrepos.getArtifactMaxAge());
    newrepos.setMetadataMaxAge(oldrepos.getMetadataMaxAge());
    newrepos.setRealmId(oldrepos.getRealmId());
    newrepos.setMaintainProxiedRepositoryMetadata(oldrepos.isMaintainProxiedRepositoryMetadata());

    if (oldrepos.getLocalStorage() != null) {
      CLocalStorage localStorage = new CLocalStorage();
      localStorage.setUrl(oldrepos.getLocalStorage().getUrl());
      newrepos.setLocalStorage(localStorage);
    }

    if (oldrepos.getRemoteStorage() != null) {
      CRemoteStorage remoteStorage = new CRemoteStorage();
      remoteStorage.setUrl(oldrepos.getRemoteStorage().getUrl());
      if (oldrepos.getRemoteStorage().getAuthentication() != null) {
        remoteStorage.setAuthentication(
            copyCRemoteAuthentication1_0_1(oldrepos.getRemoteStorage().getAuthentication()));
      }
      if (oldrepos.getRemoteStorage().getConnectionSettings() != null) {
        remoteStorage.setConnectionSettings(
            copyCRemoteConnectionSettings1_0_1(
                oldrepos.getRemoteStorage().getConnectionSettings()));
      }
      if (oldrepos.getRemoteStorage().getHttpProxySettings() != null) {
        remoteStorage.setHttpProxySettings(
            copyCRemoteHttpProxySettings1_0_1(oldrepos.getRemoteStorage().getHttpProxySettings()));
      }
      newrepos.setRemoteStorage(remoteStorage);
    }
    return newrepos;
  }