Examples of RepositoryInformation


Examples of org.apache.stratos.adc.mgt.dto.RepositoryInformation

  }
 
  public static RepositoryInformation validateRepository(String repoURL, String repoUsername, String repoPassword,
      boolean privateRepo, boolean testConnection) throws RepositoryRequiredException, ADCException,
      RepositoryCredentialsRequiredException, InvalidRepositoryException, RepositoryTransportException {
    RepositoryInformation repositoryInformation = new RepositoryInformation();
    repositoryInformation.setRepoURL(repoURL);
    if (log.isDebugEnabled()) {
      log.debug("Validating Git Repository");
    }

    if (repoURL != null && repoURL.trim().length() > 0 && privateRepo) {
      if (log.isDebugEnabled()) {
        log.debug("External repo validation is a private repo: " + repoURL);
      }
      if (repoUsername == null || repoUsername.trim().length() == 0 || repoPassword == null
          || repoPassword.trim().length() == 0) {
        throw new RepositoryCredentialsRequiredException(
            "Username and Password are required for private repository");
      }
    }

    if (!testConnection) {
      if (log.isDebugEnabled()) {
        log.debug("External repo validation is not enabled");
      }
      return repositoryInformation;
    }

    if (repoURL == null || repoURL.trim().length() == 0) {
      // This means, no repo to validate.
      return repositoryInformation;
    }
   
    if (log.isDebugEnabled()) {
      log.debug("External repo validation enabled");
    }

    // This assumes running on Linux.
    String parentDirName = "/tmp/" + UUID.randomUUID().toString();
    CredentialsProvider credentialsProvider = null;
    if (repoUsername != null && repoUsername.trim().length() > 0 && repoPassword != null
        && repoPassword.trim().length() > 0) {
      if (log.isDebugEnabled()) {
        log.debug("External repo credentails are passed: " + repoUsername);
      }
      credentialsProvider = new UsernamePasswordCredentialsProvider(repoUsername, repoPassword.toCharArray());
    }

    // Initialize temp local file repo
    FileRepository localRepo = null;
    try {
      File f = new File(parentDirName + "/.git");
      localRepo = new FileRepository(f);
      if (log.isDebugEnabled()) {
        log.debug("Local File Repo: " + f.getAbsoluteFile());
      }
    } catch (IOException e) {
      throw new ADCException("Error creating local file repo", e);
    }

    Git git = new Git(localRepo);
    LsRemoteCommand cmd = git.lsRemote().setRemote(repoURL);
    if (credentialsProvider != null) {
      cmd.setCredentialsProvider(credentialsProvider);
    }
    try {
      Collection<Ref> collection = cmd.call();
      List<String> refNames = new ArrayList<String>();
      if (collection != null) {
        for (Ref ref : collection) {
          if (log.isDebugEnabled()) {
            log.debug(repoURL + ": " + ref.getName());
          }
          refNames.add(ref.getName());
        }
      }
      repositoryInformation.setRefName(refNames.toArray(new String[refNames.size()]));
    } catch (InvalidRemoteException e) {
      throw new InvalidRepositoryException("Provided repository url is not valid", e);
    } catch (TransportException e) {
      throw new RepositoryTransportException("Transport error when checking remote repository", e);
    } catch (GitAPIException e) {
View Full Code Here

Examples of org.apache.stratos.cartridge.agent.artifact.deployment.synchronizer.RepositoryInformation

        if(StringUtils.isNotEmpty(repoURL) && (clusterIdInPayload != null) && clusterIdInPayload.equals(clusterIdInMessage)) {
            if(log.isInfoEnabled()) {
                log.info("Executing git checkout");
            }
            RepositoryInformation repoInformation = new RepositoryInformation();
            repoInformation.setRepoUsername(repoUsername);
            if(repoPassword == null) {
              repoInformation.setRepoPassword("");
            }else {
              repoInformation.setRepoPassword(repoPassword);
            }           
            repoInformation.setRepoUrl(repoURL);
            repoInformation.setRepoPath(localRepoPath);
            repoInformation.setTenantId(tenantId);
            repoInformation.setMultitenant(isMultitenant);
            boolean cloneExists = GitBasedArtifactRepository.getInstance().cloneExists(repoInformation);
            GitBasedArtifactRepository.getInstance().checkout(repoInformation);

            ExtensionUtils.executeArtifactsUpdatedExtension();
View Full Code Here

Examples of org.springframework.data.repository.core.RepositoryInformation

   */
  public void registerCustomEditors(PropertyEditorRegistry registry) {

    for (Class<?> domainClass : repositories) {

      RepositoryInformation repositoryInformation = repositories.getRepositoryInformationFor(domainClass);
      RepositoryInvoker invoker = repositoryInvokerFactory.getInvokerFor(domainClass);

      DomainClassPropertyEditor<Object, Serializable> editor = new DomainClassPropertyEditor<Object, Serializable>(
          invoker, repositories.getEntityInformationFor(repositoryInformation.getDomainType()), registry);

      registry.registerCustomEditor(repositoryInformation.getDomainType(), editor);
    }
  }
View Full Code Here

Examples of org.springframework.data.repository.core.RepositoryInformation

      return source;
    }

    Class<?> domainType = targetType.getType();

    RepositoryInformation info = repositories.getRepositoryInformationFor(domainType);
    RepositoryInvoker invoker = repositoryInvokerFactory.getInvokerFor(domainType);

    return invoker.invokeFindOne(conversionService.convert(source, info.getIdType()));
  }
View Full Code Here

Examples of org.springframework.data.repository.core.RepositoryInformation

  @SuppressWarnings("unchecked")
  private RepositoryInvoker prepareInvokers(Class<?> domainType) {

    Object repository = repositories.getRepositoryFor(domainType);
    Assert.notNull(repository, String.format("No repository found for domain type: %s", domainType));
    RepositoryInformation information = repositories.getRepositoryInformationFor(domainType);

    if (repository instanceof PagingAndSortingRepository) {
      return new PagingAndSortingRepositoryInvoker((PagingAndSortingRepository<Object, Serializable>) repository,
          information, conversionService);
    } else if (repository instanceof CrudRepository) {
View Full Code Here

Examples of org.springframework.data.repository.core.RepositoryInformation

  @SuppressWarnings({ "unchecked" })
  public <T> T getRepository(Class<T> repositoryInterface, Object customImplementation) {

    RepositoryMetadata metadata = getRepositoryMetadata(repositoryInterface);
    Class<?> customImplementationClass = null == customImplementation ? null : customImplementation.getClass();
    RepositoryInformation information = getRepositoryInformation(metadata, customImplementationClass);

    validate(information, customImplementation);

    Object target = getTargetRepository(information);
View Full Code Here

Examples of org.springframework.data.repository.core.RepositoryInformation

   */
  protected RepositoryInformation getRepositoryInformation(RepositoryMetadata metadata,
      Class<?> customImplementationClass) {

    RepositoryInformationCacheKey cacheKey = new RepositoryInformationCacheKey(metadata, customImplementationClass);
    RepositoryInformation repositoryInformation = repositoryInformationCache.get(cacheKey);

    if (repositoryInformation != null) {
      return repositoryInformation;
    }

View Full Code Here

Examples of org.springframework.data.repository.core.RepositoryInformation

  @Test
  public void discoversCustomlyImplementedCrudMethod() throws SecurityException, NoSuchMethodException {

    RepositoryMetadata metadata = new DefaultRepositoryMetadata(FooRepository.class);
    RepositoryInformation information = new DefaultRepositoryInformation(metadata, CrudRepository.class,
        customImplementation.getClass());

    Method source = FooRepositoryCustom.class.getMethod("save", User.class);
    Method expected = customImplementation.getClass().getMethod("save", User.class);

    assertThat(information.getTargetClassMethod(source), is(expected));
  }
View Full Code Here

Examples of org.springframework.data.repository.core.RepositoryInformation

  @Test
  public void considersIntermediateMethodsAsFinderMethods() {

    RepositoryMetadata metadata = new DefaultRepositoryMetadata(ConcreteRepository.class);
    RepositoryInformation information = new DefaultRepositoryInformation(metadata, CrudRepository.class, null);

    assertThat(information.hasCustomMethod(), is(false));
  }
View Full Code Here

Examples of org.springframework.data.repository.core.RepositoryInformation

   */
  @Test
  public void doesNotConsiderManuallyDefinedSaveMethodAQueryMethod() {

    RepositoryMetadata metadata = new DefaultRepositoryMetadata(CustomRepository.class);
    RepositoryInformation information = new DefaultRepositoryInformation(metadata, PagingAndSortingRepository.class,
        null);
    assertThat(information.getQueryMethods(), is(IsEmptyIterable.<Method> emptyIterable()));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.