Checks if the inputed Repository Connection is a liberty repository

@param lie The RestRepositoryConnection connection
@param repoProperties The repository properties
@return True of the repository location is a liberty location
@throws InstallException
197753
public static boolean isLibertyRepository(RestRepositoryConnection lie, Properties repoProperties) throws InstallException {
        if (isWlpRepoEnabled(repoProperties)) {
            return lie.getRepositoryLocation().startsWith(InstallConstants.REPOSITORY_LIBERTY_URL);
        }
        return false;
    }
247990
@Override
    public void checkRepositoryStatus() throws IOException {
        for (File f : assets) {
            if (!f.exists()) {
                throw new FileNotFoundException("Could not find " + f + " in the LooseFileRepository");
            }
        }
    }
1266795
protected boolean hasDescriptionProperty(final String relPath) {

        try {
            final Node descNode = getDescriptionNodeOrNull();
            if (descNode == null) {
                return false;
            }
            return descNode.hasProperty(relPath);
        } catch (final RepositoryException e) {
            throw new RepositoryRuntimeException(e);
        }
    }
255976
private void verifyRepoRegistered(String repoFullName) {
    lock.readLock().lock();
    try {
      if (!entityListenersByRepo.containsKey(requireNonNull(repoFullName))) {
        LOG.error(
            "Repository [{}] is not registered in the entity listeners service", repoFullName);
        throw new MolgenisDataException(
            "Repository ["
                + repoFullName
                + "] is not registered, please contact your administrator");
      }
    } finally {
      lock.readLock().unlock();
    }
  }
1237832
public static boolean isWriteEnabled(Resource resource, String relPath) throws RepositoryException {

        ResourceResolver resolver = resource.getResourceResolver();
        Session session = resolver.adaptTo(Session.class);
        AccessControlManager accessManager = AccessControlUtil.getAccessControlManager(session);

        String resourcePath = resource.getPath();
        Privilege[] addPrivileges = new Privilege[]{
                accessManager.privilegeFromName(Privilege.JCR_ADD_CHILD_NODES)
        };
        boolean result = accessManager.hasPrivileges(resourcePath, addPrivileges);

        if (StringUtils.isNotBlank(relPath)) {
            if (!resourcePath.endsWith("/")) {
                resourcePath += "/";
            }
            resourcePath += relPath;
        }
        Privilege[] changePrivileges = new Privilege[]{
                accessManager.privilegeFromName(Privilege.JCR_MODIFY_PROPERTIES)
        };
        try {
            result = result && accessManager.hasPrivileges(resourcePath, changePrivileges);
        } catch (PathNotFoundException pnfex) {
            // ok, let's create it
        }

        return result;
    }
1041538
boolean isEmpty(Map<String, List<List<RepositoryResource>>> installResources) {
        if (installResources == null)
            return true;
        for (List<List<RepositoryResource>> targetList : installResources.values()) {
            for (List<RepositoryResource> mrList : targetList) {
                if (!mrList.isEmpty())
                    return false;
            }
        }
        return true;
    }
197010
protected boolean isSuccessor(NodeData mergeVersion, NodeData corrVersion) throws RepositoryException
   {
      SessionDataManager mergeDataManager = mergeSession.getTransientNodesManager();

      PropertyData successorsProperty =
         (PropertyData)mergeDataManager.getItemData(mergeVersion, new QPathEntry(Constants.JCR_SUCCESSORS, 0),
            ItemType.PROPERTY);

      if (successorsProperty != null)
      {
         for (ValueData sv : successorsProperty.getValues())
         {
            String sidentifier = ValueDataUtil.getString(sv);

            if (sidentifier.equals(corrVersion.getIdentifier()))
            {
               return true; // got it
            }

            // search in successors of the successor
            NodeData successor = (NodeData)mergeDataManager.getItemData(sidentifier);
            if (successor != null)
            {
               if (isSuccessor(successor, corrVersion))
               {
                  return true;
               }
            }
            else
            {
               throw new RepositoryException("Merge. Ssuccessor is not found by uuid " + sidentifier + ". Version "
                  + mergeSession.getLocationFactory().createJCRPath(mergeVersion.getQPath()).getAsString(false));
            }
         }
         // else it's a end of version graph node
      }

      return false;
   }
61274
public final void loadRepository(ClassLoader classLoader, String repositoryPackage, String repositoryName){
        try{
            Class repositoryClass = classLoader.loadClass(repositoryPackage + "." + repositoryName);
            Repository<T> instance = (Repository<T>) repositoryClass.newInstance();
            generatedMap.putAll(instance.get());

        } catch (ClassNotFoundException e) {
            //nothing
        } catch (InstantiationException e) {
            throw new TransfuseRuntimeException("Unable to instantiate generated Repository", e);
        } catch (IllegalAccessException e) {
            throw new TransfuseRuntimeException("Unable to access generated Repository", e);
        }
    }
922051
public ConnectionRepository readConnectionRepository(String fileName)
    {
        try
        {
            RepositoryPersistor persistor = new RepositoryPersistor();
            return persistor.readConnectionRepository(fileName);
        }
        catch (Exception e)
        {
            throw new MetadataException("Can not read repository " + fileName, e);
        }
    }
726050
def has_repos(self):
        
        for section in self.sections():
            if section not in self.reserved_sections:
                return True
        return False
830944
@Override
    public boolean add(RepositoryConnection repoConnection) {
        boolean ret = super.add(repoConnection);
        if (repoConnection instanceof RestRepositoryConnection) {
            ((RestRepositoryConnection) repoConnection).setUserAgent(_userAgent);
        }
        return ret;
    }
327555
public void removeRepository(Repository repo) throws GreenPepperServerException
    {
        if(!repositories.contains(repo))
        {
            throw new GreenPepperServerException( GreenPepperServerErrorKey.REPOSITORY_NOT_FOUND, "Repository not found");
        }

        repositories.remove(repo);
        repo.setProject(null);
    }
664735
public Response restoreRepository( ServletContext context, 
                                       HttpServletRequest request, 
                                       String repositoryName,
                                       String backupName, 
                                       RestoreOptions options ) throws RepositoryException {
        if (StringUtil.isBlank(backupName)) {
            throw new IllegalArgumentException("The name of the backup cannot be null");
        }
        File backup = resolveBackup(context, backupName);
        logger.debug("Restoring repository '{0}' from backup '{1}' using '{2}'", repositoryName, backup, options);
        Session session = getSession(request, repositoryName, null);
        RepositoryManager repositoryManager = ((org.modeshape.jcr.api.Workspace)session.getWorkspace()).getRepositoryManager();
        final Problems problems = repositoryManager.restoreRepository(backup, options);
        if (!problems.hasProblems()) {
            return Response.ok().build();
        }
        List<JSONAble> response = new ArrayList<JSONAble>(problems.size());
        for (Problem problem : problems) {
            RestException exception = problem.getThrowable() != null ? 
                                      new RestException(problem.getMessage(), problem.getThrowable()) : 
                                      new RestException(problem.getMessage());
            response.add(exception);
        }
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(response).build();
    }
572871
private static void replaceRepositoryInputForValues(ArtifactoryClientConfiguration configuration,
                                                        Run build, String resolverReleaseInput,
                                                        String resolverSnapshotInput, Map<String, String> env) {
        if (StringUtils.isBlank(resolverReleaseInput) || StringUtils.isBlank(resolverSnapshotInput)) {
            build.setResult(Result.FAILURE);
            throw new IllegalStateException("Input for resolve repositories cannot be empty.");
        }
        String resolveReleaseRepo = Util.replaceMacro(resolverReleaseInput, env);
        String resolveSnapshotRepo = Util.replaceMacro(resolverSnapshotInput, env);
        if (StringUtils.isBlank(resolveReleaseRepo) || StringUtils.isBlank(resolveSnapshotRepo)) {
            build.setResult(Result.FAILURE);
            throw new IllegalStateException("Resolver repository variable cannot be replaces with empty value.");
        }
        configuration.resolver.setDownloadSnapshotRepoKey(resolveSnapshotRepo);
        configuration.resolver.setRepoKey(resolveReleaseRepo);
    }
1023636
public void addRepository(Repository repo) throws GreenPepperServerException
    {
        if (findRepositoryByName(repo.getName()) != null)
        {
            throw new GreenPepperServerException( GreenPepperServerErrorKey.REPOSITORY_ALREADY_EXISTS, "Repository already exists");
        }

        repo.setProject(this);
        repositories.add(repo);
    }
904416
public static boolean repositoryDescriptionFileExists(RestRepositoryConnectionProxy proxy) {
        boolean exists = false;
        try {

            URL propertiesFileURL = getPropertiesFileLocation();

            // Are we accessing the properties file (from DHE) using a proxy ?
            if (proxy != null) {

                if (proxy.isHTTPorHTTPS()) {

                    Proxy javaNetProxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxy.getProxyURL().getHost(), proxy.getProxyURL().getPort()));
                    URLConnection connection = propertiesFileURL.openConnection(javaNetProxy);
                    InputStream is = connection.getInputStream();

                    exists = true;
                    is.close();

                    if (connection instanceof HttpURLConnection) {
                        ((HttpURLConnection) connection).disconnect();
                    }

                } else {
                    // The proxy is not an HTTP or HTTPS proxy we do not support this
                    UnsupportedOperationException ue = new UnsupportedOperationException("Non-HTTP proxy not supported");
                    throw new IOException(ue);
                }

            } else {
                // not using a proxy
                InputStream is = propertiesFileURL.openStream();
                exists = true;
                is.close();
            }

        } catch (MalformedURLException e) {
            // ignore
        } catch (IOException e) {
            // ignore
        }

        return exists;
    }
1055814
private List<RemoteRepository> getRemoteRepositories() throws IllegalStateException {
        // disable repositories if working offline
        if (isOffline()) {
            log.log(Level.FINE, "No remote repositories will be available, working in offline mode");
            return Collections.emptyList();
        }
        // the first repository defined is the first where we search
        Set<RemoteRepository> enhancedRepos = new LinkedHashSet<RemoteRepository>();

        // add repositories we defined by hand
        enhancedRepos.addAll(additionalRemoteRepositories);

        ProfileSelector selector = new SettingsXmlProfileSelector();
        LogModelProblemCollector problems = new LogModelProblemCollector();
        List<Profile> activeProfiles = selector.getActiveProfiles(MavenConverter.asProfiles(getSettings().getProfiles()),
                new ProfileActivationContext() {

                    @Override
                    public Map<String, String> getUserProperties() {
                        return Collections.emptyMap();
                    }

                    @SuppressWarnings({ "unchecked", "rawtypes" })
                    @Override
                    public Map<String, String> getSystemProperties() {
                        return new HashMap<String, String>((Map) SecurityActions.getProperties());
                    }

                    @Override
                    public File getProjectDirectory() {
                        return new File(SecurityActions.getProperty("user.dir"));
                    }

                    @Override
                    public Map<String, String> getProjectProperties() {
                        // TODO can we put here other values?
                        return Collections.emptyMap();
                    }

                    @Override
                    public List<String> getInactiveProfileIds() {
                        return Collections.emptyList();
                    }

                    @Override
                    public List<String> getActiveProfileIds() {
                        return getSettings().getActiveProfiles();
                    }
                }, problems);

        if (problems.hasSevereFailures()) {
            throw new IllegalStateException("Unable to get active profiles from Maven settings.");
        }

        for (Profile p : activeProfiles) {
            for (Repository repository : p.getRepositories()) {
                RemoteRepository repo = MavenConverter.asRemoteRepository(repository);
                // add remote repository from model only if not overridden by code
                if (!isIdIncluded(additionalRemoteRepositories, repo)) {
                    enhancedRepos.add(repo);
                }
            }
        }

        // add remote repositories
        for (RemoteRepository repo : remoteRepositories) {
            // add remote repository from model only if not overridden by code
            if (!isIdIncluded(additionalRemoteRepositories, repo)) {
                enhancedRepos.add(repo);
            }
        }

        // add maven central if selected but if not overridden by API
        if (useMavenCentralRepository) {
            if (!isIdIncluded(additionalRemoteRepositories, MAVEN_CENTRAL)) {
                enhancedRepos.add(MAVEN_CENTRAL);
            }
        } else {
            List<RemoteRepository> reposToRemove = new ArrayList<RemoteRepository>();
            // Attempt a remove

            for (final RemoteRepository repo : enhancedRepos) {
                // Because there are a lot of aliases for Maven Central, we have to approximate that anything named
                // "central" with URL containing "maven" is what we're looking to ban. For instance Central could be
                // http://repo.maven.apache.org/maven2 or http://repo1.maven.org/maven2
                final String repoUrl = repo.getUrl();
                if ((repoUrl.contains("maven.org") || repoUrl.contains("apache.org"))
                        && repo.getId().equalsIgnoreCase(MAVEN_CENTRAL_NAME)) {
                    // remote this "might-be" central repository, but only if not specified by hand
                    if (!isIdIncluded(additionalRemoteRepositories, MAVEN_CENTRAL)) {
                        reposToRemove.add(repo);
                    }
                }
            }
            // We have to search on URL criteria, because .equals on RemoteRepository is too strict for us to call a
            // simple remove operation on the enhancedRepos Collection
            enhancedRepos.removeAll(reposToRemove);
        }

        // use mirrors if any to do the mirroring stuff
        DefaultMirrorSelector dms = new DefaultMirrorSelector();
        // fill in mirrors
        for (Mirror mirror : getSettings().getMirrors()) {
            // Repository manager flag is set to false
            // Maven does not support specifying it in the settings.xml
            dms.add(mirror.getId(), mirror.getUrl(), mirror.getLayout(), false, mirror.getMirrorOf(),
                    mirror.getMirrorOfLayouts());
        }

        Set<RemoteRepository> mirroredRepos = new LinkedHashSet<RemoteRepository>();
        for (RemoteRepository repository : enhancedRepos) {
            RemoteRepository mirror = dms.getMirror(repository);
            if (mirror != null) {
                mirroredRepos.add(mirror);
            } else {
                mirroredRepos.add(repository);
            }
        }

        final Set<RemoteRepository> authorizedRepos = new LinkedHashSet<RemoteRepository>();
        for (RemoteRepository remoteRepository : mirroredRepos) {
            final RemoteRepository.Builder builder = new RemoteRepository.Builder(remoteRepository);

            // add authentication if <server> was provided in settings.xml file
            Server server = getSettings().getServer(remoteRepository.getId());
            if (server != null) {
                final AuthenticationBuilder authenticationBuilder = new AuthenticationBuilder()
                        .addUsername(server.getUsername())
                        .addPassword(server.getPassword())
                        .addPrivateKey(server.getPrivateKey(), server.getPassphrase());
                builder.setAuthentication(authenticationBuilder.build());
            }

            authorizedRepos.add(builder.build());
        }

        if (log.isLoggable(Level.FINER)) {
            for (RemoteRepository repository : authorizedRepos) {
                log.finer("Repository " + repository.getUrl() + " have been made available for artifact resolution");
            }
        }

        return new ArrayList<RemoteRepository>(authorizedRepos);
    }