/** * It executes the subset ISQL commands that set the rewrite rules in Virtuoso for dereferencing * the subset URI-s. * * @param jobConf the {@link eu.aliada.linkeddataserversetup.model.JobConfiguration} that contains * information to setup the rewrite rules in Virtuoso * @param subset the {@link eu.aliada.linkeddataserversetup.model.Subset} that contains * information to setup the rewrite rules in Virtuoso * @return if the ISQL commands have been executed successfully. * @since 2.0 */ public boolean executeSubsetIsqlCommands(final JobConfiguration jobConf, final Subset subset) { boolean success = false; // Get global ISQL commands file for rewriting rules in Virtuoso LOGGER.debug(MessageCatalog._00036_GET_ISQL_COMMANDS_FILE); final String isqlCommandsFilename = getIsqlCommandsFile( subset.getIsqlCommandsSubsetFilename(), jobConf.getIsqlCommandsSubsetFilenameDefault()); // Compose URI document part + URI Concept part + Subset URI Concept part String uriDocConceptSubset = ""; if (subset.getUriConceptPart() != null) { uriDocConceptSubset = removeLeadingTralingSlashes(subset.getUriConceptPart()); if (uriDocConceptSubset.length() > 0) { uriDocConceptSubset = uriDocConcept + "/" + uriDocConceptSubset; } } // Variables for creating rules for Document listing with extension int createVirtualPath = 0; final int urrlListSubset = 1; // It is a subset final String rulesNamessuffixDataset = rulesNamesSuffix; String uriDocConceptParent = ""; if (subset.getUriConceptPart().contains("/")) { // If the Concept part of the subset contains an /, // a parent virtual path must also be created // for the Document listing with extension createVirtualPath = 1; uriDocConceptParent = uriDocConceptSubset.substring(0, uriDocConceptSubset.lastIndexOf('/')); } // Add a "/" at the beginning and end of the Document concept part String uriDocSlash = "/" + uriDocPart; if (!uriDocSlash.endsWith("/")) { uriDocSlash = uriDocSlash + "/"; } // If the URI Concept part of the subset is empty, its // corresponding URL Rewrite rules will not be created if ((isqlCommandsFilename != null) && (uriDocConceptSubset.length() > 0)) { // Compose Rules Names suffix for the subset, // adding the subset concept part of the URI String rulesNamesSuffixSubset = rulesNamesSuffix + uriDocConceptSubset; rulesNamesSuffixSubset = rulesNamesSuffixSubset.replace("/", ""); // Compose ISQL command execution statement final String isqlCommand = String.format( ISQL_COMMAND_FORMAT, jobConf.getIsqlCommandPath(), jobConf.getStoreIp(), jobConf.getStoreSqlPort(), jobConf.getSqlLogin(), jobConf.getSqlPassword(), isqlCommandsFilename, jobConf.getListeningHost(), jobConf.getVirtualHost(), uriIdPart, uriDocSlash, uriDefPart, graphsSelectEncoded, graphsEncoded, domainNameEncoded, rulesNamesSuffixSubset, uriDocConceptSubset, DATASET_INDEX_PAGE, ontologyEncoded, uriIdPartEncoded, createVirtualPath, urrlListSubset, rulesNamessuffixDataset, uriDocConceptParent); LOGGER.debug(isqlCommand); // Execute ISQL command try { LOGGER.debug(MessageCatalog._00040_EXECUTING_ISQL); final Process commandProcess = Runtime.getRuntime().exec(isqlCommand); final BufferedReader stdInput = new BufferedReader(new InputStreamReader(commandProcess.getInputStream())); String comOutput = ""; while ((comOutput = stdInput.readLine()) != null) { LOGGER.debug(comOutput); } success = true; } catch (IOException exception) { LOGGER.error(MessageCatalog._00033_EXTERNAL_PROCESS_START_FAILURE, exception, isqlCommand); } } return success; }