Example usage for java.lang Boolean getBoolean

List of usage examples for java.lang Boolean getBoolean

Introduction

In this page you can find the example usage for java.lang Boolean getBoolean.

Prototype

public static boolean getBoolean(String name) 

Source Link

Document

Returns true if and only if the system property named by the argument exists and is equal to, ignoring case, the string "true" .

Usage

From source file:org.opennms.ng.services.collectd.DefaultCollectionAgent.java

private DefaultCollectionAgent(final CollectionAgentService agentService) {
    super(null);/*ww  w  . j  a v a  2  s.c o m*/
    m_agentService = agentService;

    if (Boolean.getBoolean("DefaultCollectionAgent.loadSnmpDataOnInit")) {
        getSnmpInterfaceData();
    }
}

From source file:org.apache.atlas.web.service.SecureEmbeddedServer.java

protected Connector getConnector(int port) throws IOException {
    org.apache.commons.configuration.Configuration config = getConfiguration();

    SslContextFactory sslContextFactory = new SslContextFactory();
    sslContextFactory.setKeyStorePath(config.getString(KEYSTORE_FILE_KEY,
            System.getProperty(KEYSTORE_FILE_KEY, DEFAULT_KEYSTORE_FILE_LOCATION)));
    sslContextFactory.setKeyStorePassword(getPassword(config, KEYSTORE_PASSWORD_KEY));
    sslContextFactory.setKeyManagerPassword(getPassword(config, SERVER_CERT_PASSWORD_KEY));
    sslContextFactory.setTrustStorePath(config.getString(TRUSTSTORE_FILE_KEY,
            System.getProperty(TRUSTSTORE_FILE_KEY, DEFATULT_TRUSTORE_FILE_LOCATION)));
    sslContextFactory.setTrustStorePassword(getPassword(config, TRUSTSTORE_PASSWORD_KEY));
    sslContextFactory/*from   w w  w.  ja va 2  s.c  om*/
            .setWantClientAuth(config.getBoolean(CLIENT_AUTH_KEY, Boolean.getBoolean(CLIENT_AUTH_KEY)));

    List<Object> cipherList = config.getList(ATLAS_SSL_EXCLUDE_CIPHER_SUITES, DEFAULT_CIPHER_SUITES);
    sslContextFactory.setExcludeCipherSuites(cipherList.toArray(new String[cipherList.size()]));
    sslContextFactory.setRenegotiationAllowed(false);

    String[] excludedProtocols = config.containsKey(ATLAS_SSL_EXCLUDE_PROTOCOLS)
            ? config.getStringArray(ATLAS_SSL_EXCLUDE_PROTOCOLS)
            : DEFAULT_EXCLUDE_PROTOCOLS;
    if (excludedProtocols != null && excludedProtocols.length > 0) {
        sslContextFactory.addExcludeProtocols(excludedProtocols);
    }

    // SSL HTTP Configuration
    // HTTP Configuration
    HttpConfiguration http_config = new HttpConfiguration();
    http_config.setSecureScheme("https");
    final int bufferSize = AtlasConfiguration.WEBSERVER_REQUEST_BUFFER_SIZE.getInt();
    http_config.setSecurePort(port);
    http_config.setRequestHeaderSize(bufferSize);
    http_config.setResponseHeaderSize(bufferSize);
    http_config.setSendServerVersion(true);
    http_config.setSendDateHeader(false);

    HttpConfiguration https_config = new HttpConfiguration(http_config);
    https_config.addCustomizer(new SecureRequestCustomizer());

    // SSL Connector
    ServerConnector sslConnector = new ServerConnector(server,
            new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()),
            new HttpConnectionFactory(https_config));
    sslConnector.setPort(port);
    server.addConnector(sslConnector);

    return sslConnector;
}

From source file:org.craftercms.cstudio.alfresco.service.impl.DeploymentEndpointConfigImpl.java

@Override
protected void loadConfiguration(String key) {
    NodeRef configRef = getConfigRef(key);
    PersistenceManagerService persistenceManagerService = getService(PersistenceManagerService.class);
    Document document = persistenceManagerService.loadXml(configRef);
    if (document != null) {
        Element root = document.getRootElement();
        DeploymentConfigTO config = new DeploymentConfigTO();
        List<Element> endpoints = root.selectNodes(CStudioXmlConstants.DOCUMENT_ELM_ENDPOINT_ROOT);
        for (Element endpointElm : endpoints) {
            DeploymentEndpointConfigTO endpointConfig = new DeploymentEndpointConfigTO();

            String name = endpointElm.valueOf(CStudioXmlConstants.DOCUMENT_ELM_ENDPOINT_NAME);
            endpointConfig.setName(name);

            String type = endpointElm.valueOf(CStudioXmlConstants.DOCUMENT_ELM_ENDPOINT_TYPE);
            endpointConfig.setType(type);

            String serverUrl = endpointElm.valueOf(CStudioXmlConstants.DOCUMENT_ELM_ENDPOINT_SERVER_URL);
            endpointConfig.setServerUrl(serverUrl);

            String versionUrl = endpointElm.valueOf(CStudioXmlConstants.DOCUMENT_ELM_ENDPOINT_VERSION_URL);
            endpointConfig.setVersionUrl(versionUrl);

            String password = endpointElm.valueOf(CStudioXmlConstants.DOCUMENT_ELM_ENDPOINT_PASSWORD);
            endpointConfig.setPassword(password);

            String target = endpointElm.valueOf(CStudioXmlConstants.DOCUMENT_ELM_ENDPOINT_TARGET);
            endpointConfig.setTarget(target);

            String siteId = endpointElm.valueOf(CStudioXmlConstants.DOCUMENT_ELM_ENDPOINT_SITE_ID);
            endpointConfig.setSiteId(siteId);

            String sendMetadataStr = endpointElm
                    .valueOf(CStudioXmlConstants.DOCUMENT_ELM_ENDPOINT_SEND_METADATA);
            boolean sendMetadataVal = (StringUtils.isNotEmpty(sendMetadataStr))
                    && Boolean.getBoolean(sendMetadataStr);
            endpointConfig.setSendMetadata(sendMetadataVal);

            List<Element> excludePatternElms = endpointElm
                    .selectNodes(CStudioXmlConstants.DOCUMENT_ELM_ENDPOINT_EXCLUDE_PATTERN + "/"
                            + CStudioXmlConstants.DOCUMENT_ELM_ENDPOINT_PATTERN);
            List<String> excludePatternStrs = new FastList<String>();
            for (Element patternElem : excludePatternElms) {
                excludePatternStrs.add(patternElem.getText());
            }//from w w  w  . j a  v a 2  s  .co m
            endpointConfig.setExcludePattern(excludePatternStrs);

            List<Element> includePatternElms = endpointElm
                    .selectNodes(CStudioXmlConstants.DOCUMENT_ELM_ENDPOINT_INCLUDE_PATTERN + "/"
                            + CStudioXmlConstants.DOCUMENT_ELM_ENDPOINT_PATTERN);
            List<String> includePatternStrs = new FastList<String>();
            for (Element patternElem : includePatternElms) {
                includePatternStrs.add(patternElem.getText());
            }
            endpointConfig.setIncludePattern(includePatternStrs);

            String bucketSizeStr = endpointElm.valueOf(CStudioXmlConstants.DOCUMENT_ELM_ENDPOINT_BUCKET_SIZE);
            if (StringUtils.isNotEmpty(bucketSizeStr)) {
                try {
                    int bucketSizeVal = Integer.parseInt(bucketSizeStr);
                    endpointConfig.setBucketSize(bucketSizeVal);
                } catch (NumberFormatException exc) {
                    if (LOGGER.isInfoEnabled()) {
                        String configPath = persistenceManagerService.getNodePath(configRef);
                        LOGGER.info(String.format(
                                "Illegal number format for buckets size in deployment endpoint %s config [path: %s]",
                                name, configPath));
                        LOGGER.info(String.format("Default bucket size %d will be used for endpoint [%s]",
                                endpointConfig.getBucketSize(), name));
                    }
                }

            } else {
                if (LOGGER.isInfoEnabled()) {
                    String configPath = persistenceManagerService.getNodePath(configRef);
                    LOGGER.info(String.format(
                            "Buckets size not defined in deployment endpoint (%s) config [path: %s]", name,
                            configPath));
                    LOGGER.info(String.format("Default bucket size (%d) will be used for endpoint [%s]",
                            endpointConfig.getBucketSize(), name));
                }
            }

            String statusUrl = endpointElm.valueOf(CStudioXmlConstants.DOCUMENT_ELM_ENDPOINT_STATUS_URL);
            endpointConfig.setStatusUrl(statusUrl);

            config.addEndpoint(endpointConfig);
        }

        config.setLastUpdated(new Date());
        siteMapping.put(key, config);
    }
}

From source file:org.openiam.idm.srvc.pswd.rule.AbstractPasswordRule.java

protected boolean getBoolean(final PolicyAttribute attribute) {
    boolean enabled = false;
    if (attribute != null && StringUtils.isNotBlank(attribute.getValue1())) {
        enabled = Boolean.getBoolean(attribute.getValue1());
    }//from   www . j  av a2  s  .c om
    return enabled;
}

From source file:com.seajas.search.profiler.task.FeedInjectionTask.java

/**
 * {@inheritDoc}//from www. j  a  v a 2  s . co m
 */
@Override
public void inject(final String triggerName, final Long intervalTotal,
        final InjectionJobInterrupted interrupted) {
    Date currentTime = new Date();

    List<Feed> enabledFeeds = getInjectableFeeds(triggerName, intervalTotal, currentTime);

    // Only log when we're not doing distributed injection - so to not get this every second

    if (logger.isInfoEnabled() && intervalTotal == null)
        logger.info("Performing feed injection under trigger '" + triggerName + "' (" + enabledFeeds.size()
                + " feed" + (enabledFeeds.size() != 1 ? "s" : "") + ")");

    // We report on the number of feeds first, and then move on to potentially canceling the operation

    if (Boolean.getBoolean("profiler.indexing.disabled")) {
        if (logger.isInfoEnabled())
            logger.info(
                    "Indexing has been explicitly disabled using 'profiler.indexing.disabled=true'. Skipping injection.");

        return;
    }

    for (Feed feed : enabledFeeds) {
        if (interrupted.isInterrupted()) {
            logger.warn("This job was interrupted - not continuing with feed injection");

            break;
        }

        // Mark this feed's injection date (ahead of the actual injection - but then this is not such a critical matter)

        profilerService.updateFeedLastInjected(feed.getId(), currentTime);

        // Determine whether this feed falls within the anonymization run from / until range

        if (feed.getFeedAnonymization() != null) {
            Date currentDate = Calendar.getInstance().getTime(),
                    runFrom = feed.getFeedAnonymization().getRunFrom(),
                    runUntil = feed.getFeedAnonymization().getRunUntil();

            if ((runFrom != null && currentDate.before(runFrom))
                    || (runUntil != null && currentDate.after(runUntil))) {
                logger.info("The feed with name '" + feed.getName()
                        + "' falls outside of its anonymization run from/until date - skipping");

                continue;
            }
        }

        // Create a map out of the feed result parameters

        Map<String, String> resultParameters = new HashMap<String, String>();

        if (feed.getFeedResultParameters() != null && feed.getFeedResultParameters().size() > 0)
            for (FeedResultParameter feedResultParameter : feed.getFeedResultParameters()) {
                if (resultParameters.containsKey(feedResultParameter.getFieldName()))
                    logger.warn("The result map already contains a parameter named '"
                            + feedResultParameter.getFieldName() + "' - it will be overwritten");

                resultParameters.put(feedResultParameter.getFieldName(), feedResultParameter.getFieldValue());
            }

        // Now inject each feed URL

        for (FeedUrl feedUrl : feed.getFeedUrls()) {
            if (interrupted.isInterrupted()) {
                logger.warn("This job was interrupted - not continuing with feed injection");

                break;
            }

            try {
                Long feedDelay = 0L, resultDelay = 0L;

                // Determine the feed-URL specific anonymization settings

                if (feed.getFeedAnonymization() != null) {
                    // Determine the feed delay

                    feedDelay = feed.getFeedAnonymization() != null
                            && feed.getFeedAnonymization().getFeedDelay() != null
                                    ? feed.getFeedAnonymization().getFeedDelay()
                                    : 0L;

                    if (feed.getFeedAnonymization().getIsFeedDelayRandomized())
                        feedDelay = (long) randomGenerator
                                .nextInt(feedDelay.intValue() - RANDOM_RANGE_MINIMUM + 1)
                                + RANDOM_RANGE_MINIMUM;

                    // Don't randomize the result delay here, but instead do this on the contender-side

                    resultDelay = feed.getFeedAnonymization() != null
                            && feed.getFeedAnonymization().getFeedElementDelay() != null
                                    ? feed.getFeedAnonymization().getFeedElementDelay()
                                    : 0L;
                }

                // Perform the optional authentication step

                String authenticatedUrl = feedUrl.getUrl();
                Map<String, String> authenticatedResultParameters = resultParameters;

                if (feed.getFeedConnection() != null) {
                    if (feed.getFeedConnection().getAuthenticationStrategy() != null) {
                        AuthenticationResult authenticationResult = profilerService.applyAuthenticationStrategy(
                                feed.getFeedConnection().getAuthenticationStrategy(), authenticatedUrl,
                                authenticatedResultParameters);

                        authenticatedUrl = authenticationResult.getUrl();
                        authenticatedResultParameters = authenticationResult.getResultParameters();
                    }
                }

                URI uri = new URI(authenticatedUrl);
                String hostname = StringUtils.hasText(uri.getHost()) ? uri.getHost().replace("www.", "")
                        : "localhost";

                logger.info("Injecting feed with name '" + feed.getName() + "' and URI '" + uri
                        + "' into bridge layer");

                // Determine which of the result parameters to turn into headers

                Map<String, String> resultHeaders = null;

                if (StringUtils.hasText(resultMappingParameter) && StringUtils.hasText(resultMappingHeader)) {
                    if (!authenticatedResultParameters.containsKey(resultMappingParameter)) {
                        if (logger.isDebugEnabled())
                            logger.debug("Result mapping was requested, but result mapping parameter '"
                                    + resultMappingParameter
                                    + "' is not present in the result parameter map - not adding header '"
                                    + resultMappingHeader + "'");
                    } else {
                        resultHeaders = new HashMap<String, String>();

                        resultHeaders.put(resultMappingHeader,
                                authenticatedResultParameters.get(resultMappingParameter));
                    }
                }

                // Inject it into the queue

                com.seajas.search.bridge.jms.model.Feed resultFeed = new com.seajas.search.bridge.jms.model.Feed();

                resultFeed.setUri(uri);
                resultFeed.setId(feed.getId());
                resultFeed.setName(feed.getName());
                resultFeed.setHostname(hostname);
                resultFeed.setCollection(feed.getCollection());

                resultFeed.setFeedEncodingOverride(feed.getFeedEncodingOverride());
                resultFeed.setResultEncodingOverride(feed.getResultEncodingOverride());
                resultFeed.setLanguageOverride(feed.getLanguage());
                resultFeed.setSummaryBased(feed.getIsSummaryBased());

                resultFeed.setDelay(feedDelay);
                resultFeed.setElementDelay(resultDelay);
                resultFeed.setElementDelayRandomized(feed.getFeedAnonymization() != null
                        && Boolean.TRUE.equals(feed.getFeedAnonymization().getIsFeedElementDelayRandomized()));

                resultFeed.setUserAgent(determineUserAgent(feed));
                resultFeed.setUserAgentsOverride(feed.getFeedAnonymization() != null
                        ? feed.getFeedAnonymization().getPreferredUserAgents()
                        : null);
                resultFeed.setUserAgentsOverrideRandomized(feed.getFeedAnonymization() != null && Boolean.TRUE
                        .equals(feed.getFeedAnonymization().getIsPreferredUserAgentsRandomized()));

                resultFeed.setResultParameters(authenticatedResultParameters);
                resultFeed.setRetrievalRequestHeaders(resultHeaders);

                injectionService.inject(resultFeed, GroupIdDecorator.decorate(hostname), feedDelay);
            } catch (URISyntaxException e) {
                logger.error("The given " + (feed.getFeedConnection() != null
                        && feed.getFeedConnection().getAuthenticationStrategy() != null ? "(unauthenticated) "
                                : "")
                        + "feed URI '" + feedUrl.getUrl() + "' is not valid");
            }
        }
    }

    if (logger.isTraceEnabled())
        logger.trace("Finished feed injection for trigger '" + triggerName + "'");
}

From source file:org.josso.gateway.protocol.handler.NtlmProtocolHandler.java

public void setEnableBasic(String enableBasic) {
    this.setEnableBasic(Boolean.getBoolean(enableBasic));
}

From source file:com.destroystokyo.paperclip.Paperclip.java

static void run(final String[] args) {
    try {/*from   ww w. j av a 2s  . co m*/
        digest = MessageDigest.getInstance("SHA-256");
    } catch (NoSuchAlgorithmException e) {
        System.err.println("Could not create hashing instance");
        e.printStackTrace();
        System.exit(1);
    }

    final PatchData patchInfo;
    try (final InputStream is = getConfig()) {
        patchInfo = PatchData.parse(is);
    } catch (final IllegalArgumentException e) {
        System.err.println("Invalid patch file");
        e.printStackTrace();
        System.exit(1);
        return;
    } catch (final IOException e) {
        System.err.println("Error reading patch file");
        e.printStackTrace();
        System.exit(1);
        return;
    }

    final File vanillaJar = new File(cache, "mojang_" + patchInfo.getVersion() + ".jar");
    paperJar = new File(cache, "patched_" + patchInfo.getVersion() + ".jar");

    final boolean vanillaValid;
    final boolean paperValid;
    try {
        vanillaValid = checkJar(vanillaJar, patchInfo.getOriginalHash());
        paperValid = checkJar(paperJar, patchInfo.getPatchedHash());
    } catch (final IOException e) {
        System.err.println("Error reading jar");
        e.printStackTrace();
        System.exit(1);
        return;
    }

    if (!paperValid) {
        if (!vanillaValid) {
            System.out.println("Downloading original jar...");
            //noinspection ResultOfMethodCallIgnored
            cache.mkdirs();
            //noinspection ResultOfMethodCallIgnored
            vanillaJar.delete();

            try (final InputStream stream = patchInfo.getOriginalUrl().openStream()) {
                final ReadableByteChannel rbc = Channels.newChannel(stream);
                try (final FileOutputStream fos = new FileOutputStream(vanillaJar)) {
                    fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
                }
            } catch (final IOException e) {
                System.err.println("Error downloading original jar");
                e.printStackTrace();
                System.exit(1);
            }

            // Only continue from here if the downloaded jar is correct
            try {
                if (!checkJar(vanillaJar, patchInfo.getOriginalHash())) {
                    System.err.println("Invalid original jar, quitting.");
                    System.exit(1);
                }
            } catch (final IOException e) {
                System.err.println("Error reading jar");
                e.printStackTrace();
                System.exit(1);
            }
        }

        if (paperJar.exists()) {
            if (!paperJar.delete()) {
                System.err.println("Error deleting invalid jar");
                System.exit(1);
            }
        }

        System.out.println("Patching original jar...");
        final byte[] vanillaJarBytes;
        final byte[] patch;
        try {
            vanillaJarBytes = getBytes(vanillaJar);
            patch = Utils.readFully(patchInfo.getPatchFile().openStream());
        } catch (final IOException e) {
            System.err.println("Error patching original jar");
            e.printStackTrace();
            System.exit(1);
            return;
        }

        // Patch the jar to create the final jar to run
        try (final FileOutputStream jarOutput = new FileOutputStream(paperJar)) {
            Patch.patch(vanillaJarBytes, patch, jarOutput);
        } catch (final CompressorException | InvalidHeaderException | IOException e) {
            System.err.println("Error patching origin jar");
            e.printStackTrace();
            System.exit(1);
        }
    }

    // Exit if user has set `paperclip.patchonly` system property to `true`
    if (Boolean.getBoolean("paperclip.patchonly")) {
        System.exit(0);
    }

    // Get main class info from jar
    final String main;
    try (final FileInputStream fs = new FileInputStream(paperJar);
            final JarInputStream js = new JarInputStream(fs)) {
        main = js.getManifest().getMainAttributes().getValue("Main-Class");
    } catch (final IOException e) {
        System.err.println("Error reading from patched jar");
        e.printStackTrace();
        System.exit(1);
        return;
    }

    // Run the jar
    Utils.invoke(main, args);
}

From source file:org.opennms.web.controller.event.EventController.java

public EventController() {
    super();
    m_showEventCount = Boolean.getBoolean("opennms.eventlist.showCount");
}

From source file:test.SemanticConverter3.java

public void createJenaModel(RegisterContextRequest rcr) {

    OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
    Model entityOnt = FileManager.get().loadModel(ONT_FILE);
    ontModel.addSubModel(entityOnt);/*from  www.j  a v  a2  s.  co  m*/
    ontModel.setNsPrefixes(entityOnt.getNsPrefixMap());
    //        ontModel.loadImports();
    ontModel.setStrictMode(true);

    ExtendedIterator<OntProperty> iter = ontModel.listAllOntProperties();
    while (iter.hasNext()) {
        OntProperty ontProp = iter.next();
        System.out.println(ontProp.getLocalName());
    }

    OntClass entityGroup = (OntClass) ontModel.getOntClass(MAIN_ONT_URL + "EntityGroup");
    OntClass entity = (OntClass) ontModel.getOntClass(MAIN_ONT_URL + "Entity");

    OntClass metadata = (OntClass) ontModel.getOntClass(MAIN_ONT_URL + "Metadata");
    OntClass location = (OntClass) ontModel.getOntClass(entityOnt.getNsPrefixURI("geo") + "Point");

    OntClass sensingDevice = (OntClass) ontModel.getOntClass(SSN_ONT_URL + "SensingDevice");
    OntClass iotObject = (OntClass) ontModel.getOntClass(MAIN_ONT_URL + "Object");
    OntClass attribute = (OntClass) ontModel.getOntClass(MAIN_ONT_URL + "Attribute");

    String ngsiValue = "";
    ngsiValue = rcr.getRegistrationId();
    Individual entityGroupIndiv = ontModel.createIndividual(MAIN_ONT_URL + ngsiValue, entityGroup);
    entityGroupIndiv.setPropertyValue(ontModel.getProperty(MAIN_ONT_URL + "registrationId"),
            ontModel.createLiteral(ngsiValue));
    ngsiValue = rcr.getTimestamp().toString();
    entityGroupIndiv.setPropertyValue(ontModel.getProperty(MAIN_ONT_URL + "regTimeStamp"),
            ontModel.createLiteral(ngsiValue));
    ngsiValue = rcr.getDuration();
    entityGroupIndiv.setPropertyValue(ontModel.getProperty(MAIN_ONT_URL + "duration"),
            ontModel.createLiteral(ngsiValue));

    int contRegListSize = rcr.getContextRegistration().size();
    for (int i = 0; i < contRegListSize; i++) {

        rcr.getContextRegistration().get(i).getContextMetadata().size();
        for (int z = 0; z < contRegListSize; z++) {

            String regMeta = rcr.getContextRegistration().get(i).getContextMetadata().get(z).getName();
            boolean regMetaValue = Boolean.getBoolean(
                    rcr.getContextRegistration().get(i).getContextMetadata().get(z).getValue().toString());
            if (regMeta.contentEquals("linked-data") && regMetaValue) {

                int entityListSize = rcr.getContextRegistration().get(i).getEntityId().size();
                for (int j = 0; j < entityListSize; j++) {
                    ngsiValue = rcr.getContextRegistration().get(i).getEntityId().get(j).getId();
                    Individual entityInstance = ontModel.createIndividual(MAIN_ONT_URL + ngsiValue, entity);
                    entityGroupIndiv.addProperty(ontModel.getProperty(MAIN_ONT_URL + "hasEntity"),
                            entityInstance);

                    int attrListSize = rcr.getContextRegistration().get(i).getContextRegistrationAttribute()
                            .size();
                    for (int k = 0; k < attrListSize; k++) {
                        ngsiValue = rcr.getContextRegistration().get(i).getContextRegistrationAttribute().get(k)
                                .getName();
                        if (ngsiValue.isEmpty()) {
                            continue;
                        }
                        Individual attrInstance = ontModel.createIndividual(MAIN_ONT_URL + ngsiValue,
                                attribute);
                        entityInstance.addProperty(ontModel.getProperty(MAIN_ONT_URL + "hasAttribute"),
                                attrInstance);
                        ngsiValue = rcr.getContextRegistration().get(i).getContextRegistrationAttribute().get(k)
                                .getType();
                        attrInstance.setPropertyValue(ontModel.getProperty(MAIN_ONT_URL + "type"),
                                ontModel.createLiteral(ngsiValue));

                        int mdListSize = rcr.getContextRegistration().get(i).getContextRegistrationAttribute()
                                .get(k).getContextMetadata().size();
                        for (int l = 0; l < mdListSize; l++) {
                            ngsiValue = rcr.getContextRegistration().get(i).getContextRegistrationAttribute()
                                    .get(k).getContextMetadata().get(l).getName();
                            Individual mdataInstance = ontModel.createIndividual(MAIN_ONT_URL + ngsiValue,
                                    metadata);
                            attrInstance.addProperty(ontModel.getProperty(MAIN_ONT_URL + "hasMetadata"),
                                    mdataInstance);

                            ngsiValue = rcr.getContextRegistration().get(i).getContextRegistrationAttribute()
                                    .get(k).getContextMetadata().get(l).getType();
                            mdataInstance.setPropertyValue(ontModel.getProperty(MAIN_ONT_URL + "type"),
                                    ontModel.createLiteral(ngsiValue));
                            ngsiValue = rcr.getContextRegistration().get(i).getContextRegistrationAttribute()
                                    .get(k).getContextMetadata().get(l).getValue().toString();
                            mdataInstance.setPropertyValue(ontModel.getProperty(MAIN_ONT_URL + "value"),
                                    ontModel.createLiteral(ngsiValue));
                        }
                    }

                }

            }

        }

    }
    //        ngsiValue = rcr.getContextRegistration().get(0).getEntityId().get(0).getId();
    //        Individual entity1 = ontModel.createIndividual(ONT_URL + ngsiValue, entity);
    //        entityGroupIndiv.addProperty(ontModel.getProperty(ONT_URL + "hasEntity"), entity1);
    //        ngsiValue = rcr.getContextRegistration().get(0).getEntityId().get(0).getId();
    //        entity1.setPropertyValue(ontModel.getProperty(ONT_URL + "id"), ontModel.createLiteral(ngsiValue));        
    //        ngsiValue = rcr.getContextRegistration().get(0).getEntityId().get(0).getType();
    //        entity1.setPropertyValue(ontModel.getProperty(ONT_URL + "type"), ontModel.createLiteral(ngsiValue));        

    //        ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getName();
    //        Individual attribute1 = ontModel.createIndividual(ONT_URL + ngsiValue, attribute);
    //        entity1.setPropertyValue(ontModel.getProperty(ONT_URL + "hasAttribute"), attribute1);
    //        
    //        ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getType();
    //        attribute1.setPropertyValue(ontModel.getProperty(ONT_URL + "type"), ontModel.createLiteral(ngsiValue));
    //        
    //        ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(0).getName();
    //        Individual metadata1 = ontModel.createIndividual(ONT_URL + ngsiValue, metadata);
    //        attribute1.setPropertyValue(ontModel.getProperty(ONT_URL + "hasMetadata"), metadata1);
    //        
    //        ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(0).getType();
    //        metadata1.setPropertyValue(ontModel.getProperty(ONT_URL + "type"), ontModel.createLiteral(ngsiValue));
    //        ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(0).getValue().toString();
    //        metadata1.setPropertyValue(ontModel.getProperty(ONT_URL + "value"), ontModel.createLiteral(ngsiValue));
    //        
    //        ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(1).getName();
    //        Individual metadata2 = ontModel.createIndividual(ONT_URL + ngsiValue, metadata);
    //        attribute1.addProperty(ontModel.getProperty(ONT_URL + "hasMetadata"), metadata2);
    //        
    //        ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(1).getType();
    //        metadata2.setPropertyValue(ontModel.getProperty(ONT_URL + "type"), ontModel.createLiteral(ngsiValue));
    //        ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(1).getValue().toString();
    //        metadata2.setPropertyValue(ontModel.getProperty(ONT_URL + "value"), ontModel.createLiteral(ngsiValue));
    ontModel.write(System.out, "TURTLE");
    //        ontModel.write(System.out, "RDF/XML");
    //        ontModel.write(System.out, "JSON-LD");

}

From source file:org.sonar.plugins.php.phpunit.sensor.PhpUnitSensorTest.java

@Test(expected = SonarException.class)
public void shouldThrowSonarExceptionWhenReportFileIsInvalid() {
    init();//from  ww  w . j  a v a  2s. co  m
    when(configuration.getString(PhpUnitConfiguration.REPORT_FILE_NAME_PROPERTY_KEY,
            PhpUnitConfiguration.DEFAULT_REPORT_FILE_NAME)).thenReturn("punit-invalid.summary.xml");
    when(configuration.getBoolean(PhpUnitConfiguration.ANALYSE_ONLY_PROPERTY_KEY,
            Boolean.getBoolean(PhpUnitConfiguration.DEFAULT_ANALYSE_ONLY))).thenReturn(true);
    sensor.analyse(project, null);
}