/** * It executes the global ISQL commands that set the rewrite rules in Virtuoso for dereferencing * the dataset URI-s. * * @param jobConf the {@link eu.aliada.linkeddataserversetup.model.JobConfiguration} that contains * information to setup the rewrite rules in Virtuoso * @return if the ISQL commands have been executed successfully. * @since 1.0 */ public boolean executeGlobalIsqlCommands(final JobConfiguration jobConf) { boolean success = false; // Get dataset ISQL commands file for rewriting rules in Virtuoso LOGGER.debug(MessageCatalog._00036_GET_ISQL_COMMANDS_FILE); final String isqlCommandsFilename = getIsqlCommandsFile( jobConf.getIsqlCommandsDatasetFilename(), jobConf.getIsqlCommandsDatasetFilenameDefault()); // Variables for creating rules for Document listing with extension int createVirtualPath = 0; final int urrlListSubset = 0; // It is not a subset final String rulesNamessuffixDataset = rulesNamesSuffix; String uriDocConceptParent = ""; if (uriDocConcept.contains("/")) { // If the Concept part contains an /, a parent virtual path must also be created // for the Document listing with extension createVirtualPath = 1; uriDocConceptParent = uriDocConcept.substring(0, uriDocConcept.lastIndexOf('/')); } // Add a "/" at the beginning and end of the Document concept part String uriDocSlash = "/" + uriDocPart; if (!uriDocSlash.endsWith("/")) { uriDocSlash = uriDocSlash + "/"; } if (isqlCommandsFilename != null) { // 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, rulesNamesSuffix, uriDocConcept, 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; }