Package org.apache.karaf.cave.server.api

Examples of org.apache.karaf.cave.server.api.CaveRepositoryService


        // listing the repositories
        if (request.getParameter("repositories") != null) {
            ServiceReference caveRepositoryServiceReference = bundleContext.getServiceReference(CaveRepositoryService.class.getName());
            if (caveRepositoryServiceReference != null) {
                CaveRepositoryService caveRepositoryService = (CaveRepositoryService) bundleContext.getService(caveRepositoryServiceReference);
                if (caveRepositoryService != null) {
                    CaveRepository[] caveRepositories = caveRepositoryService.getRepositories();
                    response.setContentType("text/plain");
                    PrintWriter writer = response.getWriter();
                    for (CaveRepository caveRepository : caveRepositories) {
                        writer.println(caveRepository.getName());
                    }
                    writer.flush();
                    writer.close();
                }
                bundleContext.ungetService(caveRepositoryServiceReference);
            }
            return;
        }

        // wrapping content (repository.xml or directly artifacts)
        try {
            URL url = null;

            if (uri.endsWith("-repository.xml")) {
                // the user wants to get the Cave repository repository.xml
                // the expected format is {cave-repo-name}-repository.xml
                int index = uri.indexOf("-repository.xml");
                String caveRepositoryName = uri.substring(0, index);

                ServiceReference caveRepositoryServiceReference = bundleContext.getServiceReference(CaveRepositoryService.class.getName());
                if (caveRepositoryServiceReference != null) {
                    CaveRepositoryService caveRepositoryService = (CaveRepositoryService) bundleContext.getService(caveRepositoryServiceReference);
                    if (caveRepositoryService != null) {
                        CaveRepository caveRepository = caveRepositoryService.getRepository(caveRepositoryName);
                        if (caveRepository != null) {
                            url = caveRepository.getRepositoryXml();
                            response.setContentType("text/xml");
                        }
                    }
View Full Code Here

TOP

Related Classes of org.apache.karaf.cave.server.api.CaveRepositoryService

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.