convert v1.1 modelServiceInstance to serviceInstance
@param modelInstance the ModelServiceInstance11 object
@return the ServiceInstance11 object
430746
public static ServiceInstance11 toServiceInstance11(ModelServiceInstance11 modelInstance){
        if (modelInstance==null) throw new NullPointerException();
        Map<String, String> meta = new HashMap<>();
        if (modelInstance.getMetadata() != null) {
            for (Entry<String, String> en : modelInstance.getMetadata()
                    .entrySet()) {
                meta.put(en.getKey(), en.getValue());
            }
        }
        return new ServiceInstance11(modelInstance.getServiceName(),
                modelInstance.getInstanceId(),
                modelInstance.getUri(),
                modelInstance.isMonitorEnabled(), modelInstance.getStatus(),
                modelInstance.getAddress(), modelInstance.getPort(), meta);
    }
1101747
public static void validateProvidedServiceInstance(
            ProvidedServiceInstance serviceInstance) throws ServiceException {
        
        if (serviceInstance == null) {
            throw new ServiceException(
                    ErrorCode.SERVICE_DIRECTORY_NULL_ARGUMENT_ERROR,
                    ErrorCode.SERVICE_DIRECTORY_NULL_ARGUMENT_ERROR.getMessageTemplate(),
                    "service instance");
        }
               
        validateServiceName(serviceInstance.getServiceName());
        validateURI(serviceInstance.getUri());
        validateAddress(serviceInstance.getAddress());
        
        if (serviceInstance.getMetadata()!=null) { //allow metadata as null
            validateMetadata(serviceInstance.getMetadata());
        }
    }
1199236
public ModelAndView getModelAndView(final HttpServletRequest request,
                                        final boolean isSuccess,
                                        final WebApplicationService service,
                                        final Class ownerClass) {
        val view = getView(request, isSuccess, service, ownerClass);
        return new ModelAndView(view);
    }
69421
public List<ModelServiceInstance> getModelInstancesByMetadataKey(String keyName){
        ModelMetadataKey key = getModelMetadataKey(keyName);
        if(key == null || key.getServiceInstances().isEmpty()){
            return Collections.<ModelServiceInstance>emptyList();
        }else{
            return new ArrayList<ModelServiceInstance>(key.getServiceInstances());
        }
    }
1077179
@Override
    public Collection<ServiceInstance<T>> queryForInstances(String name) throws Exception
    {
        return queryForInstances(name, null);
    }
15513
protected static AbatisService getInstance(Context context, String dbName, int version) {
      if (instance == null) {
         instance = new AbatisService(context, dbName, version);
      }
      return instance;
   }
601626
public List<ModelServiceInstance> getAllModelServiceInstance() {
        return getData() == null ? Collections.<ModelServiceInstance>emptyList() : getData().getServiceInstances();
    }
662840
public ArrayList<OvhModel> serviceName_models_GET(String serviceName) throws IOException {
		String qPath = "/vps/{serviceName}/models";
		StringBuilder sb = path(qPath, serviceName);
		String resp = exec(qPath, "GET", sb.toString(), null);
		return convertTo(resp, t6);
	}
188810
public static ErrorCode validateProvidedServiceInstance(ProvidedServiceInstance serviceInstance) {

        ErrorCode retstr = isIdValid(serviceInstance.getProviderId());
        if (retstr != ErrorCode.OK) {
            return retstr;
        }

        retstr = isNameValid(serviceInstance.getServiceName());
        if (retstr != ErrorCode.OK) {
            return retstr;
        }

        retstr = isUriValid(serviceInstance.getUri());
        if (retstr != ErrorCode.OK) {
            return retstr;
        }

        retstr = isPortValid(serviceInstance.getPort());
        if (retstr != ErrorCode.OK) {
            return retstr;
        }

        /**
        * Skip the ip validation.
        retstr = isAddressValid(serviceInstance.getAddress());
        if (retstr != ErrorCode.OK) {
            return retstr;
        }
        **/

        Map<String, String> metadata = serviceInstance.getMetadata();
        if (metadata != null && metadata.size() > 0) {
            Iterator<Entry<String, String>> itor = metadata.entrySet().iterator();
            while (itor.hasNext()) {
                Map.Entry<String, String> entry = (Map.Entry<String, String>) itor
                        .next();
                if (!isOptionalFieldValid(entry.getKey(), metaKeyRegEx)) {
                    return ErrorCode.SERVICE_INSTANCE_METAKEY_FORMAT_ERROR;
                }
            }
        }
        return ErrorCode.OK;
    }
446479
public static <S> S prepareInstance(Class<? extends S> serviceClass) {
        try {
            final Constructor<? extends S> constructor = serviceClass.getDeclaredConstructor();
            AccessController.doPrivileged(new PrivilegedAction<Void>() {
                @Override
                public Void run() {
                    constructor.setAccessible(true);
                    return null;
                }
            });
            return constructor.newInstance();
        } catch (LinkageError e) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "prepareInstance(): Could not instantiate service class " + serviceClass.getName(), e);
            }
            return null;

        } catch (InvocationTargetException e) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "prepareInstance(): The exception happened on loading " + serviceClass.getName(), e);
            }
            return null;

        } catch (IllegalArgumentException e) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "prepareInstance(): The exception happened on loading " + serviceClass.getName(), e);
            }
            return null;
        } catch (InstantiationException e) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "prepareInstance(): The exception happened on loading " + serviceClass.getName(), e);
            }
            return null;
        } catch (IllegalAccessException e) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "prepareInstance(): The exception happened on loading " + serviceClass.getName(), e);
            }
            return null;
        } catch (SecurityException e) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "prepareInstance(): The exception happened on loading " + serviceClass.getName(), e);
            }
            return null;
        } catch (NoSuchMethodException e) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "prepareInstance(): The exception happened on loading " + serviceClass.getName(), e);
            }
            return null;
        }
    }
1064019
def _get_model_instance(model_cls, data):
        
        if not isinstance(data, (model_cls, dict)):
            raise TypeError('{0} is not valid type, instance of '
                            '{1} or dict required'.format(data, model_cls))
        return model_cls(**data) if isinstance(data, dict) else data
226566
protected Model restoreModel(InputStream inputStream) throws Exception {
    final File instanceDir = solrResourceLoader.getInstancePath().toFile();
    return ModelGuesser.loadModelGuess(inputStream, instanceDir);
  }
1067479
public List<EDBObject> convertModelToEDBObject(Object model, ConnectorInformation info) {
        if (!OpenEngSBModel.class.isAssignableFrom(model.getClass())) {
            throw new IllegalArgumentException("This function need to get a model passed");
        }
        List<EDBObject> objects = new ArrayList<>();
        if (model != null) {
            convertSubModel((OpenEngSBModel) model, objects, info);
        }
        return objects;
    }
1224922
protected static AbatisService getInstance(Context context, int version) {
      if (instance == null) {
         instance = new AbatisService(context, version);
      }
      return instance;
   }
607370
public List<ModelServiceInstance> getAllInstances() {
        List<ModelServiceInstance> result = Collections.emptyList();
        try {
            result = getDirectoryServiceClient().getAllInstances();
        }catch (ServiceException se){
            LOGGER.error("Error when getAllInstances()",se);
        }
        return result;
    }
283547
public List<ModelServiceInstance> getAllInstances(){
        HttpResponse result = invoker.invoke("/service" , null, HttpMethod.GET);

        if (result.getHttpCode() != HTTP_OK) {
           throw new ServiceException(ErrorCode.REMOTE_DIRECTORY_SERVER_ERROR,
                    "HTTP Code is not OK, code=%s", result.getHttpCode());
        }

        List<ModelServiceInstance> allInstances = _deserialize(result.getRetBody(), new TypeReference<List<ModelServiceInstance>>(){});
        return allInstances;
    }
433514
private void getAllServices() {
        try {
            List<ModelServiceInstance> instances = new DirectoryServiceRestfulClient().getAllInstances();
            for (ModelServiceInstance instance :instances){
                printServiceInstance(ServiceInstanceUtils.toServiceInstance(instance));
            }
        } catch (ServiceException e) {
            e.printStackTrace();
            fail(e.getServiceDirectoryError().getErrorMessage());
        }
    }