Builds a REST service for the given Atomix instance from the given namespace.

@param atomix the Atomix instance
@param namespace the namespace from which to build the service
@return the managed REST service
328742
private static ManagedRestService buildRestService(Atomix atomix, Namespace namespace) {
    final String httpHost = namespace.getString("http_host");
    final Integer httpPort = namespace.getInt("http_port");
    return RestService.builder()
        .withAtomix(atomix)
        .withAddress(Address.from(httpHost, httpPort))
        .build();
  }
638313
@FFDCIgnore(URISyntaxException.class)
    public static String namespaceURIToPackage(String namespaceURI) {
        try {
            return nameSpaceURIToPackage(new URI(namespaceURI));
        } catch (URISyntaxException ex) {
            return null;
        }
    }
926211
public Object service(String name) {
        Object service = this.services.get(name);
        if (service == null) {
            throw new IllegalArgumentException("Service '" + name + "' not found");
        }
        return service; 
    }
860950
public IAtomType getAtomType(String identifier) throws NoSuchAtomTypeException {
    	IAtomType type = atomTypes.get(identifier);
    	if (type != null) return type;
        throw new NoSuchAtomTypeException("The AtomType " + identifier + " could not be found");
    }
794371
public <T> T getOnce(final Class<T> clazz, final String name)
	{
		return new JAXBNamedResourceFactory<T>(this.config, this.factory, name, clazz).get();
	}
1146847
def _create_namespace(namespace, apiserver_url):
    '''  '''
    # Prepare URL
    url = "{0}/api/v1/namespaces".format(apiserver_url)
    # Prepare data
    data = {
        "kind": "Namespace",
        "apiVersion": "v1",
        "metadata": {
            "name": namespace,
        }
    }
    log.trace("namespace creation requests: %s", data)
    # Make request
    ret = _kpost(url, data)
    log.trace("result is: %s", ret)
    # Check requests status
    return ret
975236
public static nsxmlnamespace[] get_filtered(nitro_service service, filtervalue[] filter) throws Exception{
		nsxmlnamespace obj = new nsxmlnamespace();
		options option = new options();
		option.set_filter(filter);
		nsxmlnamespace[] response = (nsxmlnamespace[]) obj.getfiltered(service, option);
		return response;
	}
222036
public static nsacl get(nitro_service service, String aclname) throws Exception{
		nsacl obj = new nsacl();
		obj.set_aclname(aclname);
		nsacl response = (nsacl) obj.get_resource(service);
		return response;
	}
694866
@POST
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    @Description("Creates a new namepsace.")
    public NamespaceDto createNamespace(@Context HttpServletRequest req, NamespaceDto namespaceDto) {
        if (namespaceDto == null) {
            throw new WebApplicationException("Null namespace object cannot be created.", Status.BAD_REQUEST);
        }

        PrincipalUser remoteUser = validateAndGetOwner(req, null);
        Set<PrincipalUser> users = _getPrincipalUserByUserName(namespaceDto.getUsernames());
        Namespace namespace = new Namespace(remoteUser, namespaceDto.getQualifier(), remoteUser, users);

        return NamespaceDto.transformToDto(_namespaceService.createNamespace(namespace));
    }
1165994
public DnsNameResolver build() {
        if (eventLoop == null) {
            throw new IllegalStateException("eventLoop should be specified to build a DnsNameResolver.");
        }

        if (resolveCache != null && (minTtl != null || maxTtl != null || negativeTtl != null)) {
            throw new IllegalStateException("resolveCache and TTLs are mutually exclusive");
        }

        if (authoritativeDnsServerCache != null && (minTtl != null || maxTtl != null || negativeTtl != null)) {
            throw new IllegalStateException("authoritativeDnsServerCache and TTLs are mutually exclusive");
        }

        DnsCache resolveCache = this.resolveCache != null ? this.resolveCache : newCache();
        DnsCnameCache cnameCache = this.cnameCache != null ? this.cnameCache : newCnameCache();
        AuthoritativeDnsServerCache authoritativeDnsServerCache = this.authoritativeDnsServerCache != null ?
                this.authoritativeDnsServerCache : newAuthoritativeDnsServerCache();
        return new DnsNameResolver(
                eventLoop,
                channelFactory,
                resolveCache,
                cnameCache,
                authoritativeDnsServerCache,
                dnsQueryLifecycleObserverFactory,
                queryTimeoutMillis,
                resolvedAddressTypes,
                recursionDesired,
                maxQueriesPerResolve,
                traceEnabled,
                maxPayloadSize,
                optResourceEnabled,
                hostsFileEntriesResolver,
                dnsServerAddressStreamProvider,
                searchDomains,
                ndots,
                decodeIdn);
    }
217084
public static AtomService documentToService(final Document document) throws ProponoException {
        final AtomService service = new AtomService();
        final Element root = document.getRootElement();
        final List<Element> spaces = root.getChildren("workspace", ATOM_PROTOCOL);
        for (final Element e : spaces) {
            service.addWorkspace(Workspace.elementToWorkspace(e));
        }
        return service;
    }
1130539
public BindingInfo createBindingInfo(Service service, String namespace,
                                         Object obj) {

        ServiceInfo si = new ServiceInfo();
        si.setTargetNamespace(ProtobufBindingFactory.PROTOBUF_BINDING_ID);

        BindingInfo info = new BindingInfo(si,
                ProtobufBindingFactory.PROTOBUF_BINDING_ID);

        return info;
    }
940334
public EntityManager createDefaultEntityManager(String namespace) {
    ConnectionParameters parameters = new ConnectionParameters();
    parameters.setNamespace(namespace);
    return createEntityManager(parameters);
  }
122397
public ServerBuilder annotatedService(String pathPrefix, Object service) {
        return annotatedService(pathPrefix, service, Function.identity(), ImmutableList.of());
    }
1116348
public Observable<Page<NamespaceResourceInner>> listAsync() {
        return listWithServiceResponseAsync()
            .map(new Func1<ServiceResponse<Page<NamespaceResourceInner>>, Page<NamespaceResourceInner>>() {
                @Override
                public Page<NamespaceResourceInner> call(ServiceResponse<Page<NamespaceResourceInner>> response) {
                    return response.body();
                }
            });
    }
1083068
protected Session session(String repoName, String wsName, List<String> lockTokens) throws Exception,
      NoSuchWorkspaceException
   {
      // To be cloud compliant we need now to ignore the provided repository name (more details in JCR-2138)
      ManageableRepository repo = repositoryService.getCurrentRepository();
      if (PropertyManager.isDevelopping() && log.isWarnEnabled())
      {
         String currentRepositoryName = repo.getConfiguration().getName();
         if (!currentRepositoryName.equals(repoName))
         {
            log.warn("The expected repository was '" + repoName
               + "' but we will use the current repository instead which is '" + currentRepositoryName + "'");
         }
      }
      SessionProvider sp = sessionProviderService.getSessionProvider(null);
      if (sp == null)
         throw new RepositoryException("SessionProvider is not properly set. Make the application calls"
            + "SessionProviderService.setSessionProvider(..) somewhere before ("
            + "for instance in Servlet Filter for WEB application)");

      Session session = sp.getSession(wsName, repo);
      if (lockTokens != null)
      {
         String[] presentLockTokens = session.getLockTokens();
         ArrayList<String> presentLockTokensList = new ArrayList<String>();
         for (int i = 0; i < presentLockTokens.length; i++)
         {
            presentLockTokensList.add(presentLockTokens[i]);
         }

         for (int i = 0; i < lockTokens.size(); i++)
         {
            String lockToken = lockTokens.get(i);
            if (!presentLockTokensList.contains(lockToken))
            {
               session.addLockToken(lockToken);
            }
         }
      }
      return session;
   }
345292
@Override
    public Service getService(URI serviceUri) throws ServiceException {
        if (serviceUri == null || !serviceUri.isAbsolute()) {
            log.warn("The Service URI is either absent or relative. Provide an absolute URI");
            return null;
        }

        OntModel model = null;
        try {
            model = this.graphStoreManager.getGraph(URIUtil.getNameSpace(serviceUri));
        } catch (URISyntaxException e) {
            log.error("The namespace of the service is not a correct URI", e);
            return null;
        }

        // Parse the service. There should only be one in the response
        ServiceReaderImpl reader = new ServiceReaderImpl();
        List<Service> services = reader.parseService(model);
        if (services != null && !services.isEmpty()) {
            return services.get(0);
        }

        return null;
    }