Check if the database is in a specific condition by checking the result of a SQL statement loaded as a resource.
@param resource  the resource containing the SQL statement that would return a number
@return true if the returned number is greater than 0
426899
protected boolean isInConditionResource(String resource){
		Resource sqlResource = context.getResource(resource);
		InputStream in = null;
		String sql = null;
		try{
			in = sqlResource.getInputStream();
			sql = IOUtils.toString(in);
		} catch(IOException ioe){
			throw new RuntimeException("Failed to get condition SQL (" + ioe.getMessage() + ") from: " + resource, ioe);
		}finally{
			IOUtils.closeQuietly(in);
		}
		if (StringUtils.isNotBlank(sql)){
			return isInCondition(sql);
		}else{
			return true;
		}
	}
1249820
@Override
    public boolean isConnected(final Connection _connection)
        throws SQLException
    {
        boolean ret = false;
        final Statement stmt = _connection.createStatement();
        try {
            final ResultSet resultset = stmt
                        .executeQuery("select product from product_component_version where product like 'Oracle%'");
            ret = resultset.next();
            resultset.close();
        } finally {
            stmt.close();
        }
        return ret;
    }
690957
public boolean hasPermission(Authentication authentication,
                                 Object resource,
                                 Object privilege) {
        boolean logPermission = isLogPermission(resource);
        return checkRole(authentication, privilege, logPermission)
            || checkPermission(authentication, resource, privilege, true, logPermission);
    }
1040901
public ResponseBuilder initialize(final Resource resource) {

        if (MISSING_RESOURCE.equals(resource)) {
            throw new NotFoundException();
        } else if (DELETED_RESOURCE.equals(resource)) {
            throw new ClientErrorException(GONE);
        }

        setResource(resource);
        return status(NO_CONTENT);
    }
107045
public function hasResource($resource) {

		if(null !== $resource && false === is_string($resource)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($resource)), E_USER_ERROR);
		}

		return true === array_key_exists($resource, $this -> resources);
	}
196204
protected function matchesResource(Resource $resource = null)
    {
        // If the resource is null we should only return true if the current resource is also null.
        if ($resource === null) {
            return $this->getResource() === null || (
                $this->getResourceType() === null && $this->getResourceId() === null
            );
        }

        // If the permission's resource id is null then all resources with a specific ID are accepted.
        if ($this->getResourceId() === null) {
            return $this->getResourceType() === $resource->getResourceType();
        }

        // Otherwise make sure that we're matching a specific resource.
        return (
            $this->getResourceType() === $resource->getResourceType() &&
            $this->getResourceId() === $resource->getResourceId()
        );
    }
1275282
protected boolean existsTable(){
        try {
            int count = sqlManager.getSingleResult(Integer.class,
                    new StringSqlResource(String.format("SELECT COUNT(*) FROM %s", tableName)));

            if(count == 0){
                // TODO Should insert an initial record?
                return false;
            }
            return true;

        } catch(SQLRuntimeException ex){
            return false;
        }
    }
815818
@SuppressWarnings({ "PMD.CyclomaticComplexity", "PMD.NPathComplexity",
        "PMD.CollapsibleIfStatements", "PMD.DataflowAnomalyAnalysis" })
    public int matches(URI resource) {
        if (protocol != null && !protocol.equals("*")) {
            if (resource.getScheme() == null) {
                return -1;
            }
            if (Arrays.stream(protocol.split(","))
                .noneMatch(proto -> proto.equals(resource.getScheme()))) {
                return -1;
            }
        }
        if (host != null && !host.equals("*")) {
            if (resource.getHost() == null
                || !resource.getHost().equals(host)) {
                return -1;
            }
        }
        if (port != null && !port.equals("*")) {
            if (Integer.parseInt(port) != resource.getPort()) {
                return -1;
            }
        }

        String[] reqElements = PathSpliterator.stream(resource.getPath())
            .skip(1).toArray(size -> new String[size]);
        String[] reqElementsPlus = null; // Created lazily
        for (int pathIdx = 0; pathIdx < pathPatternElements.length; pathIdx++) {
            String[] pathPattern = pathPatternElements[pathIdx];
            if (prefixSegs[pathIdx] == pathPattern.length - 1
                && lastIsEmpty(pathPattern)) {
                // Special case, pattern ends with vertical bar
                if (reqElementsPlus == null) {
                    reqElementsPlus = reqElements;
                    if (!lastIsEmpty(reqElementsPlus)) {
                        reqElementsPlus = Arrays.copyOf(
                            reqElementsPlus, reqElementsPlus.length + 1);
                        reqElementsPlus[reqElementsPlus.length - 1] = "";
                    }
                }
                if (matchPath(pathPattern, reqElementsPlus)) {
                    return prefixSegs[pathIdx];
                }
            } else {
                if (matchPath(pathPattern, reqElements)) {
                    return prefixSegs[pathIdx];
                }
            }
        }
        return -1;
    }
1117883
private boolean hasContentInVfsOrImport(CmsResource resource) {

        if (m_contentFiles.contains(resource.getResourceId())) {
            return true;
        }
        try {
            List<CmsResource> resources = getCms().readSiblings(resource, CmsResourceFilter.ALL);
            if (!resources.isEmpty()) {
                return true;
            }
        } catch (CmsException e) {
            LOG.warn(e.getLocalizedMessage(), e);
        }
        return false;

    }
757326
public static boolean hasField(Connection connection, String tableName, String fieldName) throws SQLException {
        final Statement statement = connection.createStatement();
        try {
            final ResultSet resultSet = statement.executeQuery(
                    "SELECT * FROM " + TableLocation.parse(tableName) + " LIMIT 0;");
            try {
                return hasField(resultSet.getMetaData(), fieldName);
            } finally {
                resultSet.close();
            }
        } catch (SQLException ex) {
            return false;
        } finally {
            statement.close();
        }
    }
654612
protected static function isKeyResource($resource): bool {
        if(!is_resource($resource)) {
            return FALSE;
        }
        if(get_resource_type($resource) != 'OpenSSL key') {
            return FALSE;
        }
        return TRUE;
    }
119379
private boolean resourceExists(CmsObject cms, String resource) {

        try {
            cms.readResource(resource, CmsResourceFilter.ALL);
            return true;
        } catch (CmsException e) {
            return false;
        }
    }
628228
@Override
    public boolean hasStatement(Statement st, boolean includeInferred, Resource... contexts) throws RepositoryException {
        return hasStatement(st.getSubject(),st.getPredicate(),st.getObject(),includeInferred,contexts);
    }
104517
public boolean contains(String resource) {
		boolean result = storage.contains(resource);
		logger.debug("resource '{}' {} in cache", resource, (result ? "is" : "is not"));
		return result; 
	}
638495
public static boolean isFile(Resource resource) {
        Node node = resource.adaptTo(Node.class);
        if (node != null) {
            try {
                NodeType type = node.getPrimaryNodeType();
                if (type != null) {
                    String typeName = type.getName();
                    switch (typeName) {
                        case TYPE_FILE:
                            return true;
                        case TYPE_RESOURCE:
                        case TYPE_UNSTRUCTURED:
                            try {
                                Property mimeType = node.getProperty(PROP_MIME_TYPE);
                                if (mimeType != null && StringUtils.isNotBlank(mimeType.getString())) {
                                    node.getProperty(ResourceUtil.PROP_DATA);
                                    // PathNotFountException if not present
                                    return true;
                                }
                            } catch (PathNotFoundException pnfex) {
                                // ok, was a check only
                            }
                            break;
                    }
                }
            } catch (RepositoryException e) {
                LOG.error(e.getMessage(), e);
            }
        }
        return false;
    }
560762
public boolean checkResource(RequiredOrientResource resource, Action action)
	{
		if(!resource.action().equals(action.getName())) return true;
		OSecurityUser user = OrientDbWebSession.get().getEffectiveUser();
		if(user==null) return false;
		int iOperation = OrientPermission.combinedPermission(resource.permissions());
		ORule.ResourceGeneric value = OSecurityHelper.getResourceGeneric(resource.value());
		String specific = resource.specific();
		if(Strings.isEmpty(specific)) specific = null;
		if(user.checkIfAllowed(value, specific, iOperation)!=null) return true;
		while(!Strings.isEmpty(specific=Strings.beforeLastPathComponent(specific, '.')))
		{
			if(user.checkIfAllowed(value, specific+"."+ODatabaseSecurityResources.ALL, iOperation)!=null) return true;
		}
		return false;
	}
1161676
public boolean matches( String resourceName , String action )
	{
		// Match rsource name first
		if (!StringTools.matches(resourceName, resourcePattern))
			return false;
		
		// Check action
		return actions.contains(action);
	}