From 63ec7241afe761aeae2f2a77d4dc9b11095e279d Mon Sep 17 00:00:00 2001 From: Alexander Ebadirad Date: Wed, 14 Feb 2018 19:48:29 -0700 Subject: [PATCH 01/22] Interfaces for tracing, debugging, and scaffolding --- .../java/com/marklogic/hub/Debugging.java | 42 +- .../java/com/marklogic/hub/FlowManager.java | 2 +- .../main/java/com/marklogic/hub/Tracing.java | 42 +- .../com/marklogic/hub/impl/DebuggingImpl.java | 70 +++ .../com/marklogic/hub/impl/TracingImpl.java | 69 +++ .../marklogic/hub/scaffold/Scaffolding.java | 448 ++---------------- .../hub/scaffold/impl/ScaffoldingImpl.java | 435 +++++++++++++++++ .../java/com/marklogic/hub/DebugLibTest.java | 2 +- .../com/marklogic/hub/EndToEndFlowTests.java | 2 +- .../com/marklogic/hub/EntityManagerTest.java | 4 +- .../com/marklogic/hub/FlowManagerTest.java | 6 +- .../java/com/marklogic/hub/HubTestBase.java | 8 +- .../com/marklogic/hub/ScaffoldingTest.java | 14 +- .../hub/ScaffoldingValidatorTest.java | 3 +- .../java/com/marklogic/hub/TracingTest.java | 21 +- .../hub/collector/StreamCollectorTest.java | 2 +- .../GenerateHubTDETemplateCommandTest.java | 9 +- .../marklogic/hub/flow/FlowRunnerTest.java | 2 +- .../com/marklogic/hub/job/JobManagerTest.java | 2 +- .../gradle/task/CreateEntityTask.groovy | 2 +- .../gradle/task/CreateFlowTask.groovy | 2 +- .../com/marklogic/gradle/task/HubTask.groovy | 4 +- .../gradle/task/InstalledTests.groovy | 12 +- .../service/EntityManagerService.java | 6 +- .../web/CurrentProjectController.java | 2 +- .../quickstart/web/SettingsController.java | 4 +- .../service/EntityManagerServiceTest.java | 5 +- .../service/FlowManagerServiceTest.java | 2 +- .../web/EntitiesControllerTest.java | 5 +- 29 files changed, 676 insertions(+), 551 deletions(-) create mode 100644 marklogic-data-hub/src/main/java/com/marklogic/hub/impl/DebuggingImpl.java create mode 100644 marklogic-data-hub/src/main/java/com/marklogic/hub/impl/TracingImpl.java create mode 100644 marklogic-data-hub/src/main/java/com/marklogic/hub/scaffold/impl/ScaffoldingImpl.java diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/Debugging.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/Debugging.java index 1c85477e84..ce286a728e 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/Debugging.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/Debugging.java @@ -13,56 +13,32 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.marklogic.hub; import com.marklogic.client.DatabaseClient; -import com.marklogic.client.extensions.ResourceManager; -import com.marklogic.client.extensions.ResourceServices.ServiceResult; -import com.marklogic.client.extensions.ResourceServices.ServiceResultIterator; -import com.marklogic.client.io.Format; -import com.marklogic.client.io.StringHandle; -import com.marklogic.client.util.RequestParameters; +import com.marklogic.hub.impl.DebuggingImpl; -public class Debugging extends ResourceManager { - private static final String NAME = "ml:debug"; +public interface Debugging { - public Debugging(DatabaseClient client) { - super(); - client.init(NAME, this); - } + static Debugging create(DatabaseClient client){ + return new DebuggingImpl(client); + }; /** * Enables debugging */ - public void enable() { - RequestParameters params = new RequestParameters(); - params.add("enable", "true"); - this.getServices().post(params, new StringHandle("{}").withFormat(Format.JSON)); - } + void enable(); /** * Disables debugging */ - public void disable() { - RequestParameters params = new RequestParameters(); - params.add("enable", "false"); - this.getServices().post(params, new StringHandle("{}").withFormat(Format.JSON)); - } + void disable(); /** * Determines if the hub has debugging enabled or not * * @return - true if enabled, false otherwise */ - public boolean isEnabled() { - RequestParameters params = new RequestParameters(); - ServiceResultIterator resultItr = this.getServices().get(params); - if (resultItr == null || ! resultItr.hasNext()) { - return false; - } - ServiceResult res = resultItr.next(); - StringHandle handle = new StringHandle(); - String enabled = res.getContent(handle).get(); - return Boolean.parseBoolean(enabled); - } + boolean isEnabled(); } diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/FlowManager.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/FlowManager.java index b951351a45..0da52ab781 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/FlowManager.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/FlowManager.java @@ -279,7 +279,7 @@ public List getLegacyFlows() { public List updateLegacyFlows(String fromVersion) { - Scaffolding scaffolding = new Scaffolding(hubConfig.getProjectDir(), hubConfig.newFinalClient()); + Scaffolding scaffolding = Scaffolding.create(hubConfig.getProjectDir(), hubConfig.newFinalClient()); List updatedFlows = new ArrayList<>(); File[] entityDirs = hubConfig.getHubEntitiesDir().toFile().listFiles(pathname -> pathname.isDirectory()); diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/Tracing.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/Tracing.java index fbdd5ceb8b..15f27778d6 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/Tracing.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/Tracing.java @@ -13,56 +13,32 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.marklogic.hub; import com.marklogic.client.DatabaseClient; -import com.marklogic.client.extensions.ResourceManager; -import com.marklogic.client.extensions.ResourceServices.ServiceResult; -import com.marklogic.client.extensions.ResourceServices.ServiceResultIterator; -import com.marklogic.client.io.Format; -import com.marklogic.client.io.StringHandle; -import com.marklogic.client.util.RequestParameters; +import com.marklogic.hub.impl.TracingImpl; -public class Tracing extends ResourceManager { - private static final String NAME = "ml:tracing"; +public interface Tracing { - public Tracing(DatabaseClient client) { - super(); - client.init(NAME, this); - } + static Tracing create(DatabaseClient client){ + return new TracingImpl(client); + }; /** * Enables tracing */ - public void enable() { - RequestParameters params = new RequestParameters(); - params.add("enable", "true"); - this.getServices().post(params, new StringHandle("{}").withFormat(Format.JSON)); - } + void enable(); /** * Disables tracing */ - public void disable() { - RequestParameters params = new RequestParameters(); - params.add("enable", "false"); - this.getServices().post(params, new StringHandle("{}").withFormat(Format.JSON)); - } + void disable(); /** * Determines if the hub has tracing enabled or not * * @return - true if enabled, false otherwise */ - public boolean isEnabled() { - RequestParameters params = new RequestParameters(); - ServiceResultIterator resultItr = this.getServices().get(params); - if (resultItr == null || ! resultItr.hasNext()) { - return false; - } - ServiceResult res = resultItr.next(); - StringHandle handle = new StringHandle(); - String enabled = res.getContent(handle).get(); - return Boolean.parseBoolean(enabled); - } + boolean isEnabled(); } diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/DebuggingImpl.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/DebuggingImpl.java new file mode 100644 index 0000000000..a98ace6774 --- /dev/null +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/DebuggingImpl.java @@ -0,0 +1,70 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.marklogic.hub.impl; + +import com.marklogic.client.DatabaseClient; +import com.marklogic.client.extensions.ResourceManager; +import com.marklogic.client.extensions.ResourceServices.ServiceResult; +import com.marklogic.client.extensions.ResourceServices.ServiceResultIterator; +import com.marklogic.client.io.Format; +import com.marklogic.client.io.StringHandle; +import com.marklogic.client.util.RequestParameters; +import com.marklogic.hub.Debugging; + +public class DebuggingImpl extends ResourceManager implements Debugging { + private static final String NAME = "ml:debug"; + + public DebuggingImpl(DatabaseClient client) { + super(); + client.init(NAME, this); + } + + /** + * Enables debugging + */ + @Override public void enable() { + RequestParameters params = new RequestParameters(); + params.add("enable", "true"); + this.getServices().post(params, new StringHandle("{}").withFormat(Format.JSON)); + } + + /** + * Disables debugging + */ + @Override public void disable() { + RequestParameters params = new RequestParameters(); + params.add("enable", "false"); + this.getServices().post(params, new StringHandle("{}").withFormat(Format.JSON)); + } + + /** + * Determines if the hub has debugging enabled or not + * + * @return - true if enabled, false otherwise + */ + @Override public boolean isEnabled() { + RequestParameters params = new RequestParameters(); + ServiceResultIterator resultItr = this.getServices().get(params); + if (resultItr == null || ! resultItr.hasNext()) { + return false; + } + ServiceResult res = resultItr.next(); + StringHandle handle = new StringHandle(); + String enabled = res.getContent(handle).get(); + return Boolean.parseBoolean(enabled); + } +} diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/TracingImpl.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/TracingImpl.java new file mode 100644 index 0000000000..0ee2ecbe9e --- /dev/null +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/TracingImpl.java @@ -0,0 +1,69 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.marklogic.hub.impl; + +import com.marklogic.client.DatabaseClient; +import com.marklogic.client.extensions.ResourceManager; +import com.marklogic.client.extensions.ResourceServices.ServiceResult; +import com.marklogic.client.extensions.ResourceServices.ServiceResultIterator; +import com.marklogic.client.io.Format; +import com.marklogic.client.io.StringHandle; +import com.marklogic.client.util.RequestParameters; +import com.marklogic.hub.Tracing; + +public class TracingImpl extends ResourceManager implements Tracing { + private static final String NAME = "ml:tracing"; + + public TracingImpl(DatabaseClient client) { + super(); + client.init(NAME, this); + } + + /** + * Enables tracing + */ + @Override public void enable() { + RequestParameters params = new RequestParameters(); + params.add("enable", "true"); + this.getServices().post(params, new StringHandle("{}").withFormat(Format.JSON)); + } + + /** + * Disables tracing + */ + @Override public void disable() { + RequestParameters params = new RequestParameters(); + params.add("enable", "false"); + this.getServices().post(params, new StringHandle("{}").withFormat(Format.JSON)); + } + + /** + * Determines if the hub has tracing enabled or not + * + * @return - true if enabled, false otherwise + */ + @Override public boolean isEnabled() { + RequestParameters params = new RequestParameters(); + ServiceResultIterator resultItr = this.getServices().get(params); + if (resultItr == null || ! resultItr.hasNext()) { + return false; + } + ServiceResult res = resultItr.next(); + StringHandle handle = new StringHandle(); + String enabled = res.getContent(handle).get(); + return Boolean.parseBoolean(enabled); + } +} diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/scaffold/Scaffolding.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/scaffold/Scaffolding.java index df0bf6f8df..c2b262543e 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/scaffold/Scaffolding.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/scaffold/Scaffolding.java @@ -1,412 +1,23 @@ -/* - * Copyright 2012-2018 MarkLogic Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ package com.marklogic.hub.scaffold; -import com.marklogic.client.DatabaseClient; -import com.marklogic.client.extensions.ResourceManager; -import com.marklogic.client.extensions.ResourceServices; -import com.marklogic.client.io.StringHandle; -import com.marklogic.client.util.RequestParameters; -import com.marklogic.hub.collector.impl.CollectorImpl; import com.marklogic.hub.error.ScaffoldingValidationException; -import com.marklogic.hub.flow.*; -import com.marklogic.hub.main.impl.MainPluginImpl; -import com.marklogic.hub.util.FileUtil; -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.IOUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.w3c.dom.Document; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; +import com.marklogic.hub.flow.CodeFormat; +import com.marklogic.hub.flow.DataFormat; +import com.marklogic.hub.flow.FlowType; +import com.marklogic.hub.scaffold.impl.ScaffoldingImpl; +import com.marklogic.client.DatabaseClient; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import java.io.*; -import java.nio.charset.StandardCharsets; +import java.io.File; import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.ArrayList; import java.util.List; -import java.util.regex.Pattern; - -public class Scaffolding { - - private String projectDir; - private Path pluginsDir; - private Path entitiesDir; - private ScaffoldingValidator validator; - private DatabaseClient databaseClient; - protected final Logger logger = LoggerFactory.getLogger(this.getClass()); - - public Scaffolding(String projectDir, DatabaseClient databaseClient) { - this.projectDir = projectDir; - this.pluginsDir = Paths.get(this.projectDir, "plugins"); - this.entitiesDir = this.pluginsDir.resolve("entities"); - this.databaseClient = databaseClient; - validator = new ScaffoldingValidator(projectDir); - } - - public Path getFlowDir(String entityName, String flowName, FlowType flowType) { - Path entityDir = entitiesDir.resolve(entityName); - Path typeDir = entityDir.resolve(flowType.toString()); - Path flowDir = typeDir.resolve(flowName); - return flowDir; - } - - public void createEntity(String entityName) { - Path entityDir = entitiesDir.resolve(entityName); - entityDir.toFile().mkdirs(); - } - - public void createFlow(String entityName, String flowName, - FlowType flowType, CodeFormat codeFormat, - DataFormat dataFormat) { - createFlow(entityName, flowName, flowType, codeFormat, dataFormat, false); - } - - public void createFlow(String entityName, String flowName, - FlowType flowType, CodeFormat codeFormat, - DataFormat dataFormat, boolean useEsModel) { - try { - Path flowDir = getFlowDir(entityName, flowName, flowType); - flowDir.toFile().mkdirs(); - - if (flowType.equals(FlowType.HARMONIZE)) { - writeFile("scaffolding/" + flowType + "/" + codeFormat + "/collector." + codeFormat, - flowDir.resolve("collector." + codeFormat)); - - writeFile("scaffolding/" + flowType + "/" + codeFormat + "/writer." + codeFormat, - flowDir.resolve("writer." + codeFormat)); - } - - if (useEsModel) { - ContentPlugin cp = new ContentPlugin(databaseClient); - String content = cp.getContents(entityName, codeFormat, flowType); - writeBuffer(content, flowDir.resolve("content." + codeFormat)); - - } else { - writeFile("scaffolding/" + flowType + "/" + codeFormat + "/content." + codeFormat, - flowDir.resolve("content." + codeFormat)); - } - - writeFile("scaffolding/" + flowType + "/" + codeFormat + "/headers." + codeFormat, - flowDir.resolve("headers." + codeFormat)); - - writeFile("scaffolding/" + flowType + "/" + codeFormat + "/triples." + codeFormat, - flowDir.resolve("triples." + codeFormat)); - - - writeFile("scaffolding/" + flowType + "/" + codeFormat + "/main." + codeFormat, - flowDir.resolve("main." + codeFormat)); - - Flow flow = FlowBuilder.newFlow() - .withEntityName(entityName) - .withName(flowName) - .withType(flowType) - .withCodeFormat(codeFormat) - .withDataFormat(dataFormat) - .build(); - - FileWriter fw = new FileWriter(flowDir.resolve(flowName + ".properties").toFile()); - flow.toProperties().store(fw, ""); - fw.close(); - } - catch(IOException e) { - throw new RuntimeException(e); - } - } - - private Document readLegacyFlowXml(File file) { - try { - FileInputStream is = new FileInputStream(file); - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - factory.setNamespaceAware(true); - DocumentBuilder builder = factory.newDocumentBuilder(); - return builder.parse(is); - } - catch(IOException | ParserConfigurationException | SAXException e) { - throw new RuntimeException(e); - } - } - - public List updateLegacyFlows(String fromVersion, String entityName) { - Path entityDir = entitiesDir.resolve(entityName); - Path inputDir = entityDir.resolve("input"); - Path harmonizeDir = entityDir.resolve("harmonize"); - - updateLegacyEntity(entityName); +public interface Scaffolding { - List updatedFlows = new ArrayList<>(); - File[] inputFlows = inputDir.toFile().listFiles((pathname) -> pathname.isDirectory() && !pathname.getName().equals("REST")); - if (inputFlows != null) { - for (File inputFlow : inputFlows) { - if (updateLegacyFlow(fromVersion, entityName, inputFlow.getName(), FlowType.INPUT)) { - updatedFlows.add(entityName + " => " + inputFlow.getName()); - } - } - } - - File[] harmonizeFlows = harmonizeDir.toFile().listFiles((pathname) -> pathname.isDirectory() && !pathname.getName().equals("REST")); - if (harmonizeFlows != null) { - for (File harmonizeFlow : harmonizeFlows) { - if(updateLegacyFlow(fromVersion, entityName, harmonizeFlow.getName(), FlowType.HARMONIZE)) { - updatedFlows.add(entityName + " => " + harmonizeFlow.getName()); - } - } - } - - return updatedFlows; + static Scaffolding create(String projectDir, DatabaseClient databaseClient) { + return new ScaffoldingImpl(projectDir, databaseClient); } - public void updateLegacyEntity(String entityName) { - Path entityDir = entitiesDir.resolve(entityName); - - File[] entityFiles = entityDir.toFile().listFiles((dir, name) -> name.matches("[^.]+\\.entity\\.json")); - if (entityFiles != null && entityFiles.length == 0) { - String fileContents = getFileContent("scaffolding/Entity.json", entityName); - writeToFile(fileContents, entityDir.resolve(entityName + ".entity.json").toFile()); - } - } - - public boolean updateLegacyFlow(String fromVersion, String entityName, String flowName, FlowType flowType) { - boolean updated = false; - - Path flowDir = getFlowDir(entityName, flowName, flowType); - File[] mainFiles = flowDir.toFile().listFiles((dir, name) -> name.matches("main\\.(sjs|xqy)")); - if (mainFiles.length < 1 || !flowDir.resolve(flowName + ".properties").toFile().exists()) { - File[] files = flowDir.toFile().listFiles((dir, name) -> name.endsWith(".xml")); - - for (File file : files) { - Document doc = readLegacyFlowXml(file); - if (doc.getDocumentElement().getLocalName().equals("flow")) { - DataFormat dataFormat = null; - CodeFormat codeFormat = null; - NodeList nodes = doc.getElementsByTagName("data-format"); - if (nodes.getLength() == 1) { - String format = nodes.item(0).getTextContent(); - if (format.equals("application/json")) { - dataFormat = DataFormat.JSON; - } else if (format.equals("application/xml")) { - dataFormat = DataFormat.XML; - } else { - throw new RuntimeException("Invalid Data Format"); - } - } - - if (flowDir.resolve("content").resolve("content.sjs").toFile().exists()) { - codeFormat = CodeFormat.JAVASCRIPT; - } else if (flowDir.resolve("content").resolve("content.xqy").toFile().exists()) { - codeFormat = CodeFormat.XQUERY; - } else { - throw new RuntimeException("Invalid Code Format"); - } - - String suffix = ""; - if (fromVersion.startsWith("1.")) { - suffix = "-1x"; - } - writeFile("scaffolding/" + flowType + "/" + codeFormat + "/main-legacy" + suffix + "." + codeFormat, - flowDir.resolve("main." + codeFormat)); - - file.delete(); - - FlowBuilder flowBuilder = FlowBuilder.newFlow() - .withEntityName(entityName) - .withName(flowName) - .withType(flowType) - .withCodeFormat(codeFormat) - .withDataFormat(dataFormat) - .withMain(new MainPluginImpl("main." + codeFormat, codeFormat)); - - if (flowType.equals(FlowType.HARMONIZE)) { - flowBuilder.withCollector(new CollectorImpl("collector/collector." + codeFormat, codeFormat)); - - if (codeFormat.equals(CodeFormat.JAVASCRIPT)) { - updateLegacySjsWriter(flowDir); - } - } - - Flow flow = flowBuilder.build(); - try { - FileWriter fw = new FileWriter(flowDir.resolve(flowName + ".properties").toFile()); - flow.toProperties().store(fw, ""); - fw.close(); - } catch (IOException e) { - throw new RuntimeException(e); - } - updated = true; - } - } - } - return updated; - } - - private void updateLegacySjsWriter(Path flowDir) { - Path writerFile = flowDir.resolve("writer").resolve("writer.sjs"); - if (writerFile.toFile().exists()) { - try { - String contents = FileUtils.readFileToString(writerFile.toFile()); - Pattern pattern = Pattern.compile("module.exports[^;]+;", Pattern.MULTILINE); - contents = pattern.matcher(contents).replaceAll("module.exports = write;"); - FileOutputStream fileOutputStream = new FileOutputStream(writerFile.toFile()); - IOUtils.write(contents, fileOutputStream); - fileOutputStream.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - - private void writeFile(String srcFile, Path dstFile) { - logger.info("writing: " + srcFile + " => " + dstFile.toString()); - if (!dstFile.toFile().exists()) { - InputStream inputStream = Scaffolding.class.getClassLoader() - .getResourceAsStream(srcFile); - FileUtil.copy(inputStream, dstFile.toFile()); - } - } - - private void writeBuffer(String buffer, Path dstFile) { - logger.info("writing: " + dstFile.toString()); - if (!dstFile.toFile().exists()) { - InputStream inputStream = new ByteArrayInputStream(buffer.getBytes(StandardCharsets.UTF_8)); - FileUtil.copy(inputStream, dstFile.toFile()); - } - } - - public void createRestExtension(String entityName, String extensionName, - FlowType flowType, CodeFormat codeFormat) throws ScaffoldingValidationException { - logger.info(extensionName); - - if(!validator.isUniqueRestServiceExtension(extensionName)) { - throw new ScaffoldingValidationException("A rest service extension with the same name as " + extensionName + " already exists."); - } - String scaffoldRestServicesPath = "scaffolding/rest/services/"; - String fileContent = getFileContent(scaffoldRestServicesPath + codeFormat + "/template." + codeFormat, extensionName); - File dstFile = createEmptyRestExtensionFile(entityName, extensionName, flowType, codeFormat); - writeToFile(fileContent, dstFile); - writeMetadataForFile(dstFile, scaffoldRestServicesPath + "metadata/template.xml", extensionName); - } - - public void createRestTransform(String entityName, String transformName, - FlowType flowType, CodeFormat codeFormat) throws ScaffoldingValidationException { - logger.info(transformName); - if(!validator.isUniqueRestTransform(transformName)) { - throw new ScaffoldingValidationException("A rest transform with the same name as " + transformName + " already exists."); - } - String scaffoldRestTransformsPath = "scaffolding/rest/transforms/"; - String fileContent = getFileContent(scaffoldRestTransformsPath + codeFormat + "/template." + codeFormat, transformName); - File dstFile = createEmptyRestTransformFile(entityName, transformName, flowType, codeFormat); - writeToFile(fileContent, dstFile); - writeMetadataForFile(dstFile, scaffoldRestTransformsPath + "metadata/template.xml", transformName); - } - - private void writeToFile(String fileContent, File dstFile) { - try { - FileWriter fw = new FileWriter(dstFile); - BufferedWriter bw = new BufferedWriter(fw); - bw.write(fileContent); - bw.close(); - } - catch(IOException e) { - throw new RuntimeException(e); - } - } - - private File createEmptyRestExtensionFile(String entityName, String extensionName, - FlowType flowType, CodeFormat codeFormat) { - Path restDir = getRestDirectory(entityName, flowType); - return createEmptyFile(restDir, "services", extensionName + "." + codeFormat); - } - - private File createEmptyRestTransformFile(String entityName, String transformName, - FlowType flowType, CodeFormat codeFormat) { - Path restDir = getRestDirectory(entityName, flowType); - return createEmptyFile(restDir, "transforms", transformName + "." + codeFormat); - } - - private File createEmptyFile(Path directory, String subDirectoryName, String fileName) { - Path fileDirectory = directory; - if(subDirectoryName != null) { - fileDirectory = directory.resolve(subDirectoryName); - } - fileDirectory.toFile().mkdirs(); - File file = fileDirectory.resolve(fileName).toFile(); - try { - file.createNewFile(); - } catch (IOException e) { - throw new RuntimeException(e); - } - return file; - } - - public Path getEntityDir(String entityName) { - return entitiesDir.resolve(entityName); - } - - private Path getRestDirectory(String entityName, FlowType flowType) { - return getFlowDir(entityName, "REST", flowType); - } - - private void writeMetadataForFile(File file, String metadataTemplatePath, String metadataName) { - String fileContent = getFileContent(metadataTemplatePath, metadataName); - File metadataFile = createEmptyMetadataForFile(file, metadataName); - writeToFile(fileContent, metadataFile); - } - - private File createEmptyMetadataForFile(File file, String metadataName) { - File metadataDir = new File(file.getParentFile(), "metadata"); - metadataDir.mkdir(); - File metadataFile = new File(metadataDir, metadataName + ".xml"); - try { - metadataFile.createNewFile(); - } catch (IOException e) { - throw new RuntimeException(e); - } - return metadataFile; - } - - private String getFileContent(String srcFile, String placeholder) { - StringBuilder output = new StringBuilder(); - InputStream inputStream = null; - BufferedReader rdr = null; - try { - inputStream = Scaffolding.class.getClassLoader() - .getResourceAsStream(srcFile); - rdr = new BufferedReader(new InputStreamReader(inputStream)); - String bufferedLine = null; - while ((bufferedLine = rdr.readLine()) != null) { - if(bufferedLine.contains("placeholder")) { - bufferedLine = bufferedLine.replace("placeholder", placeholder); - } - output.append(bufferedLine); - output.append("\n"); - } - inputStream.close(); - rdr.close(); - } catch (IOException e) { - throw new RuntimeException(e); - } - return output.toString(); - } - - public static String getAbsolutePath(String first, String... more) { + static String getAbsolutePath(String first, String... more) { StringBuilder absolutePath = new StringBuilder(first); for (String path : more) { absolutePath.append(File.separator); @@ -415,28 +26,29 @@ public static String getAbsolutePath(String first, String... more) { return absolutePath.toString(); } - public class ContentPlugin extends ResourceManager { - private static final String NAME = "ml:scaffoldContent"; + Path getFlowDir(String entityName, String flowName, FlowType flowType); - private RequestParameters params = new RequestParameters(); + void createEntity(String entityName); - public ContentPlugin(DatabaseClient client) { - super(); - client.init(NAME, this); - } + void createFlow(String entityName, String flowName, + FlowType flowType, CodeFormat codeFormat, + DataFormat dataFormat); - public String getContents(String entityName, CodeFormat codeFormat, FlowType flowType) { - params.add("entity", entityName); - params.add("codeFormat", codeFormat.toString()); - params.add("flowType", flowType.toString()); - ResourceServices.ServiceResultIterator resultItr = this.getServices().get(params); - if (resultItr == null || ! resultItr.hasNext()) { - throw new RuntimeException("Unable to get Content Plugin scaffold"); - } - ResourceServices.ServiceResult res = resultItr.next(); - return res.getContent(new StringHandle()).get().replaceAll("\n", "\r\n"); - } + void createFlow(String entityName, String flowName, + FlowType flowType, CodeFormat codeFormat, + DataFormat dataFormat, boolean useEsModel); - } + List updateLegacyFlows(String fromVersion, String entityName); + + void updateLegacyEntity(String entityName); + + boolean updateLegacyFlow(String fromVersion, String entityName, String flowName, FlowType flowType); + + void createRestExtension(String entityName, String extensionName, + FlowType flowType, CodeFormat codeFormat) throws ScaffoldingValidationException; + + void createRestTransform(String entityName, String transformName, + FlowType flowType, CodeFormat codeFormat) throws ScaffoldingValidationException; + Path getEntityDir(String entityName); } diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/scaffold/impl/ScaffoldingImpl.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/scaffold/impl/ScaffoldingImpl.java new file mode 100644 index 0000000000..1fb63c4b02 --- /dev/null +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/scaffold/impl/ScaffoldingImpl.java @@ -0,0 +1,435 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.marklogic.hub.scaffold.impl; + +import com.marklogic.client.DatabaseClient; +import com.marklogic.client.extensions.ResourceManager; +import com.marklogic.client.extensions.ResourceServices; +import com.marklogic.client.io.StringHandle; +import com.marklogic.client.util.RequestParameters; +import com.marklogic.hub.collector.impl.CollectorImpl; +import com.marklogic.hub.error.ScaffoldingValidationException; +import com.marklogic.hub.flow.*; +import com.marklogic.hub.main.impl.MainPluginImpl; +import com.marklogic.hub.scaffold.Scaffolding; +import com.marklogic.hub.scaffold.ScaffoldingValidator; +import com.marklogic.hub.util.FileUtil; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import java.io.*; +import java.nio.charset.StandardCharsets; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Pattern; + +public class ScaffoldingImpl implements Scaffolding { + + private String projectDir; + private Path pluginsDir; + private Path entitiesDir; + private ScaffoldingValidator validator; + private DatabaseClient databaseClient; + protected final Logger logger = LoggerFactory.getLogger(this.getClass()); + + public ScaffoldingImpl(String projectDir, DatabaseClient databaseClient) { + this.projectDir = projectDir; + this.pluginsDir = Paths.get(this.projectDir, "plugins"); + this.entitiesDir = this.pluginsDir.resolve("entities"); + this.databaseClient = databaseClient; + validator = new ScaffoldingValidator(projectDir); + } + + @Override public Path getFlowDir(String entityName, String flowName, FlowType flowType) { + Path entityDir = entitiesDir.resolve(entityName); + Path typeDir = entityDir.resolve(flowType.toString()); + Path flowDir = typeDir.resolve(flowName); + return flowDir; + } + + @Override public void createEntity(String entityName) { + Path entityDir = entitiesDir.resolve(entityName); + entityDir.toFile().mkdirs(); + } + + @Override public void createFlow(String entityName, String flowName, + FlowType flowType, CodeFormat codeFormat, + DataFormat dataFormat) { + createFlow(entityName, flowName, flowType, codeFormat, dataFormat, false); + } + + @Override public void createFlow(String entityName, String flowName, + FlowType flowType, CodeFormat codeFormat, + DataFormat dataFormat, boolean useEsModel) { + try { + Path flowDir = getFlowDir(entityName, flowName, flowType); + flowDir.toFile().mkdirs(); + + if (flowType.equals(FlowType.HARMONIZE)) { + writeFile("scaffolding/" + flowType + "/" + codeFormat + "/collector." + codeFormat, + flowDir.resolve("collector." + codeFormat)); + + writeFile("scaffolding/" + flowType + "/" + codeFormat + "/writer." + codeFormat, + flowDir.resolve("writer." + codeFormat)); + } + + if (useEsModel) { + ContentPlugin cp = new ContentPlugin(databaseClient); + String content = cp.getContents(entityName, codeFormat, flowType); + writeBuffer(content, flowDir.resolve("content." + codeFormat)); + + } else { + writeFile("scaffolding/" + flowType + "/" + codeFormat + "/content." + codeFormat, + flowDir.resolve("content." + codeFormat)); + } + + writeFile("scaffolding/" + flowType + "/" + codeFormat + "/headers." + codeFormat, + flowDir.resolve("headers." + codeFormat)); + + writeFile("scaffolding/" + flowType + "/" + codeFormat + "/triples." + codeFormat, + flowDir.resolve("triples." + codeFormat)); + + + writeFile("scaffolding/" + flowType + "/" + codeFormat + "/main." + codeFormat, + flowDir.resolve("main." + codeFormat)); + + Flow flow = FlowBuilder.newFlow() + .withEntityName(entityName) + .withName(flowName) + .withType(flowType) + .withCodeFormat(codeFormat) + .withDataFormat(dataFormat) + .build(); + + FileWriter fw = new FileWriter(flowDir.resolve(flowName + ".properties").toFile()); + flow.toProperties().store(fw, ""); + fw.close(); + } + catch(IOException e) { + throw new RuntimeException(e); + } + } + + private Document readLegacyFlowXml(File file) { + try { + FileInputStream is = new FileInputStream(file); + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + factory.setNamespaceAware(true); + DocumentBuilder builder = factory.newDocumentBuilder(); + return builder.parse(is); + } + catch(IOException | ParserConfigurationException | SAXException e) { + throw new RuntimeException(e); + } + } + + @Override public List updateLegacyFlows(String fromVersion, String entityName) { + Path entityDir = entitiesDir.resolve(entityName); + Path inputDir = entityDir.resolve("input"); + Path harmonizeDir = entityDir.resolve("harmonize"); + + + updateLegacyEntity(entityName); + + List updatedFlows = new ArrayList<>(); + File[] inputFlows = inputDir.toFile().listFiles((pathname) -> pathname.isDirectory() && !pathname.getName().equals("REST")); + if (inputFlows != null) { + for (File inputFlow : inputFlows) { + if (updateLegacyFlow(fromVersion, entityName, inputFlow.getName(), FlowType.INPUT)) { + updatedFlows.add(entityName + " => " + inputFlow.getName()); + } + } + } + + File[] harmonizeFlows = harmonizeDir.toFile().listFiles((pathname) -> pathname.isDirectory() && !pathname.getName().equals("REST")); + if (harmonizeFlows != null) { + for (File harmonizeFlow : harmonizeFlows) { + if(updateLegacyFlow(fromVersion, entityName, harmonizeFlow.getName(), FlowType.HARMONIZE)) { + updatedFlows.add(entityName + " => " + harmonizeFlow.getName()); + } + } + } + + return updatedFlows; + } + + @Override public void updateLegacyEntity(String entityName) { + Path entityDir = entitiesDir.resolve(entityName); + + File[] entityFiles = entityDir.toFile().listFiles((dir, name) -> name.matches("[^.]+\\.entity\\.json")); + if (entityFiles != null && entityFiles.length == 0) { + String fileContents = getFileContent("scaffolding/Entity.json", entityName); + writeToFile(fileContents, entityDir.resolve(entityName + ".entity.json").toFile()); + } + } + + @Override public boolean updateLegacyFlow(String fromVersion, String entityName, String flowName, FlowType flowType) { + boolean updated = false; + + Path flowDir = getFlowDir(entityName, flowName, flowType); + File[] mainFiles = flowDir.toFile().listFiles((dir, name) -> name.matches("main\\.(sjs|xqy)")); + if (mainFiles.length < 1 || !flowDir.resolve(flowName + ".properties").toFile().exists()) { + File[] files = flowDir.toFile().listFiles((dir, name) -> name.endsWith(".xml")); + + for (File file : files) { + Document doc = readLegacyFlowXml(file); + if (doc.getDocumentElement().getLocalName().equals("flow")) { + DataFormat dataFormat = null; + CodeFormat codeFormat = null; + NodeList nodes = doc.getElementsByTagName("data-format"); + if (nodes.getLength() == 1) { + String format = nodes.item(0).getTextContent(); + if (format.equals("application/json")) { + dataFormat = DataFormat.JSON; + } else if (format.equals("application/xml")) { + dataFormat = DataFormat.XML; + } else { + throw new RuntimeException("Invalid Data Format"); + } + } + + if (flowDir.resolve("content").resolve("content.sjs").toFile().exists()) { + codeFormat = CodeFormat.JAVASCRIPT; + } else if (flowDir.resolve("content").resolve("content.xqy").toFile().exists()) { + codeFormat = CodeFormat.XQUERY; + } else { + throw new RuntimeException("Invalid Code Format"); + } + + String suffix = ""; + if (fromVersion.startsWith("1.")) { + suffix = "-1x"; + } + writeFile("scaffolding/" + flowType + "/" + codeFormat + "/main-legacy" + suffix + "." + codeFormat, + flowDir.resolve("main." + codeFormat)); + + file.delete(); + + FlowBuilder flowBuilder = FlowBuilder.newFlow() + .withEntityName(entityName) + .withName(flowName) + .withType(flowType) + .withCodeFormat(codeFormat) + .withDataFormat(dataFormat) + .withMain(new MainPluginImpl("main." + codeFormat, codeFormat)); + + if (flowType.equals(FlowType.HARMONIZE)) { + flowBuilder.withCollector(new CollectorImpl("collector/collector." + codeFormat, codeFormat)); + + if (codeFormat.equals(CodeFormat.JAVASCRIPT)) { + updateLegacySjsWriter(flowDir); + } + } + + Flow flow = flowBuilder.build(); + try { + FileWriter fw = new FileWriter(flowDir.resolve(flowName + ".properties").toFile()); + flow.toProperties().store(fw, ""); + fw.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + updated = true; + } + } + } + return updated; + } + + private void updateLegacySjsWriter(Path flowDir) { + Path writerFile = flowDir.resolve("writer").resolve("writer.sjs"); + if (writerFile.toFile().exists()) { + try { + String contents = FileUtils.readFileToString(writerFile.toFile()); + Pattern pattern = Pattern.compile("module.exports[^;]+;", Pattern.MULTILINE); + contents = pattern.matcher(contents).replaceAll("module.exports = write;"); + FileOutputStream fileOutputStream = new FileOutputStream(writerFile.toFile()); + IOUtils.write(contents, fileOutputStream); + fileOutputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + private void writeFile(String srcFile, Path dstFile) { + logger.info("writing: " + srcFile + " => " + dstFile.toString()); + if (!dstFile.toFile().exists()) { + InputStream inputStream = Scaffolding.class.getClassLoader() + .getResourceAsStream(srcFile); + FileUtil.copy(inputStream, dstFile.toFile()); + } + } + + private void writeBuffer(String buffer, Path dstFile) { + logger.info("writing: " + dstFile.toString()); + if (!dstFile.toFile().exists()) { + InputStream inputStream = new ByteArrayInputStream(buffer.getBytes(StandardCharsets.UTF_8)); + FileUtil.copy(inputStream, dstFile.toFile()); + } + } + + @Override public void createRestExtension(String entityName, String extensionName, + FlowType flowType, CodeFormat codeFormat) throws ScaffoldingValidationException { + logger.info(extensionName); + + if(!validator.isUniqueRestServiceExtension(extensionName)) { + throw new ScaffoldingValidationException("A rest service extension with the same name as " + extensionName + " already exists."); + } + String scaffoldRestServicesPath = "scaffolding/rest/services/"; + String fileContent = getFileContent(scaffoldRestServicesPath + codeFormat + "/template." + codeFormat, extensionName); + File dstFile = createEmptyRestExtensionFile(entityName, extensionName, flowType, codeFormat); + writeToFile(fileContent, dstFile); + writeMetadataForFile(dstFile, scaffoldRestServicesPath + "metadata/template.xml", extensionName); + } + + @Override public void createRestTransform(String entityName, String transformName, + FlowType flowType, CodeFormat codeFormat) throws ScaffoldingValidationException { + logger.info(transformName); + if(!validator.isUniqueRestTransform(transformName)) { + throw new ScaffoldingValidationException("A rest transform with the same name as " + transformName + " already exists."); + } + String scaffoldRestTransformsPath = "scaffolding/rest/transforms/"; + String fileContent = getFileContent(scaffoldRestTransformsPath + codeFormat + "/template." + codeFormat, transformName); + File dstFile = createEmptyRestTransformFile(entityName, transformName, flowType, codeFormat); + writeToFile(fileContent, dstFile); + writeMetadataForFile(dstFile, scaffoldRestTransformsPath + "metadata/template.xml", transformName); + } + + private void writeToFile(String fileContent, File dstFile) { + try { + FileWriter fw = new FileWriter(dstFile); + BufferedWriter bw = new BufferedWriter(fw); + bw.write(fileContent); + bw.close(); + } + catch(IOException e) { + throw new RuntimeException(e); + } + } + + private File createEmptyRestExtensionFile(String entityName, String extensionName, + FlowType flowType, CodeFormat codeFormat) { + Path restDir = getRestDirectory(entityName, flowType); + return createEmptyFile(restDir, "services", extensionName + "." + codeFormat); + } + + private File createEmptyRestTransformFile(String entityName, String transformName, + FlowType flowType, CodeFormat codeFormat) { + Path restDir = getRestDirectory(entityName, flowType); + return createEmptyFile(restDir, "transforms", transformName + "." + codeFormat); + } + + private File createEmptyFile(Path directory, String subDirectoryName, String fileName) { + Path fileDirectory = directory; + if(subDirectoryName != null) { + fileDirectory = directory.resolve(subDirectoryName); + } + fileDirectory.toFile().mkdirs(); + File file = fileDirectory.resolve(fileName).toFile(); + try { + file.createNewFile(); + } catch (IOException e) { + throw new RuntimeException(e); + } + return file; + } + + @Override public Path getEntityDir(String entityName) { + return entitiesDir.resolve(entityName); + } + + private Path getRestDirectory(String entityName, FlowType flowType) { + return getFlowDir(entityName, "REST", flowType); + } + + private void writeMetadataForFile(File file, String metadataTemplatePath, String metadataName) { + String fileContent = getFileContent(metadataTemplatePath, metadataName); + File metadataFile = createEmptyMetadataForFile(file, metadataName); + writeToFile(fileContent, metadataFile); + } + + private File createEmptyMetadataForFile(File file, String metadataName) { + File metadataDir = new File(file.getParentFile(), "metadata"); + metadataDir.mkdir(); + File metadataFile = new File(metadataDir, metadataName + ".xml"); + try { + metadataFile.createNewFile(); + } catch (IOException e) { + throw new RuntimeException(e); + } + return metadataFile; + } + + private String getFileContent(String srcFile, String placeholder) { + StringBuilder output = new StringBuilder(); + InputStream inputStream = null; + BufferedReader rdr = null; + try { + inputStream = Scaffolding.class.getClassLoader() + .getResourceAsStream(srcFile); + rdr = new BufferedReader(new InputStreamReader(inputStream)); + String bufferedLine = null; + while ((bufferedLine = rdr.readLine()) != null) { + if(bufferedLine.contains("placeholder")) { + bufferedLine = bufferedLine.replace("placeholder", placeholder); + } + output.append(bufferedLine); + output.append("\n"); + } + inputStream.close(); + rdr.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + return output.toString(); + } + + public class ContentPlugin extends ResourceManager { + private static final String NAME = "ml:scaffoldContent"; + + private RequestParameters params = new RequestParameters(); + + public ContentPlugin(DatabaseClient client) { + super(); + client.init(NAME, this); + } + + public String getContents(String entityName, CodeFormat codeFormat, FlowType flowType) { + params.add("entity", entityName); + params.add("codeFormat", codeFormat.toString()); + params.add("flowType", flowType.toString()); + ResourceServices.ServiceResultIterator resultItr = this.getServices().get(params); + if (resultItr == null || ! resultItr.hasNext()) { + throw new RuntimeException("Unable to get Content Plugin scaffold"); + } + ResourceServices.ServiceResult res = resultItr.next(); + return res.getContent(new StringHandle()).get().replaceAll("\n", "\r\n"); + } + + } + +} diff --git a/marklogic-data-hub/src/test/java/com/marklogic/hub/DebugLibTest.java b/marklogic-data-hub/src/test/java/com/marklogic/hub/DebugLibTest.java index 79ef710af2..005a20b6e2 100644 --- a/marklogic-data-hub/src/test/java/com/marklogic/hub/DebugLibTest.java +++ b/marklogic-data-hub/src/test/java/com/marklogic/hub/DebugLibTest.java @@ -29,7 +29,7 @@ public class DebugLibTest extends HubTestBase { public static void setup() { installHub(); - Scaffolding scaffolding = new Scaffolding(PROJECT_PATH, stagingClient); + Scaffolding scaffolding = Scaffolding.create(PROJECT_PATH, stagingClient); scaffolding.createFlow(entityName, flowName, FlowType.INPUT, CodeFormat.XQUERY, DataFormat.XML); installUserModules(getHubConfig(), true); diff --git a/marklogic-data-hub/src/test/java/com/marklogic/hub/EndToEndFlowTests.java b/marklogic-data-hub/src/test/java/com/marklogic/hub/EndToEndFlowTests.java index d02d650518..3fce54aa0f 100644 --- a/marklogic-data-hub/src/test/java/com/marklogic/hub/EndToEndFlowTests.java +++ b/marklogic-data-hub/src/test/java/com/marklogic/hub/EndToEndFlowTests.java @@ -109,7 +109,7 @@ public static void setup() { enableTracing(); enableDebugging(); - scaffolding = new Scaffolding(projectDir.toString(), finalClient); + scaffolding = Scaffolding.create(projectDir.toString(), finalClient); scaffolding.createEntity(ENTITY); scaffoldFlows("scaffolded"); diff --git a/marklogic-data-hub/src/test/java/com/marklogic/hub/EntityManagerTest.java b/marklogic-data-hub/src/test/java/com/marklogic/hub/EntityManagerTest.java index 21326053e0..ddb5c02640 100644 --- a/marklogic-data-hub/src/test/java/com/marklogic/hub/EntityManagerTest.java +++ b/marklogic-data-hub/src/test/java/com/marklogic/hub/EntityManagerTest.java @@ -63,7 +63,7 @@ public static void teardown() throws IOException { } private void installEntity() { - Scaffolding scaffolding = new Scaffolding(projectDir.toString(), finalClient); + Scaffolding scaffolding = Scaffolding.create(projectDir.toString(), finalClient); Path employeeDir = scaffolding.getEntityDir("employee"); employeeDir.toFile().mkdirs(); assertTrue(employeeDir.toFile().exists()); @@ -71,7 +71,7 @@ private void installEntity() { } // private void removeEntity() throws IOException { -// Scaffolding scaffolding = new Scaffolding(projectDir.toString(), finalClient); +// Scaffolding scaffolding = Scaffolding.create(projectDir.toString(), finalClient); // Path employeeDir = scaffolding.getEntityDir("employee"); // FileUtils.deleteDirectory(employeeDir.toFile()); // } diff --git a/marklogic-data-hub/src/test/java/com/marklogic/hub/FlowManagerTest.java b/marklogic-data-hub/src/test/java/com/marklogic/hub/FlowManagerTest.java index ddd4dfde5b..0657c377dd 100644 --- a/marklogic-data-hub/src/test/java/com/marklogic/hub/FlowManagerTest.java +++ b/marklogic-data-hub/src/test/java/com/marklogic/hub/FlowManagerTest.java @@ -158,7 +158,7 @@ public void testFlowToXml() throws IOException, ParserConfigurationException, SA @Test public void testGetLocalFlows() throws IOException { - Scaffolding scaffolding = new Scaffolding("del-me-dir", stagingClient); + Scaffolding scaffolding = Scaffolding.create("del-me-dir", stagingClient); scaffolding.createEntity("my-entity"); FlowManager fm = new FlowManager(getHubConfig("del-me-dir")); @@ -188,7 +188,7 @@ public void testGetLocalFlows() throws IOException { @Test public void testGetFlowFromProperties() throws IOException { - Scaffolding scaffolding = new Scaffolding("del-me-dir", stagingClient); + Scaffolding scaffolding = Scaffolding.create("del-me-dir", stagingClient); scaffolding.createEntity("my-entity"); FlowManager fm = new FlowManager(getHubConfig("del-me-dir")); @@ -389,7 +389,7 @@ public void testRunFlowWithAll() throws SAXException, IOException, ParserConfigu public void testHasLegacyflows() throws IOException, InterruptedException, ParserConfigurationException, SAXException, JSONException { FlowManager fm = new FlowManager(getHubConfig()); - Scaffolding scaffolding = new Scaffolding(getHubConfig().getProjectDir(), stagingClient); + Scaffolding scaffolding = Scaffolding.create(getHubConfig().getProjectDir(), stagingClient); scaffolding.createEntity("new-entity"); scaffolding.createFlow("new-entity", "new-flow", FlowType.HARMONIZE, CodeFormat.XQUERY, DataFormat.XML); assertEquals(0, fm.getLegacyFlows().size()); diff --git a/marklogic-data-hub/src/test/java/com/marklogic/hub/HubTestBase.java b/marklogic-data-hub/src/test/java/com/marklogic/hub/HubTestBase.java index 1ae09f7ab2..9cdaad5995 100644 --- a/marklogic-data-hub/src/test/java/com/marklogic/hub/HubTestBase.java +++ b/marklogic-data-hub/src/test/java/com/marklogic/hub/HubTestBase.java @@ -211,19 +211,19 @@ public HubTestBase() { } protected static void enableDebugging() { - new Debugging(stagingClient).enable(); + Debugging.create(stagingClient).enable(); } protected static void disableDebugging() { - new Debugging(stagingClient).disable(); + Debugging.create(stagingClient).disable(); } protected static void enableTracing() { - new Tracing(stagingClient).enable(); + Tracing.create(stagingClient).enable(); } protected static void disableTracing() { - new Tracing(stagingClient).disable(); + Tracing.create(stagingClient).disable(); } protected static HubConfig getHubConfig() { diff --git a/marklogic-data-hub/src/test/java/com/marklogic/hub/ScaffoldingTest.java b/marklogic-data-hub/src/test/java/com/marklogic/hub/ScaffoldingTest.java index 29da587a3b..bff3baab1f 100644 --- a/marklogic-data-hub/src/test/java/com/marklogic/hub/ScaffoldingTest.java +++ b/marklogic-data-hub/src/test/java/com/marklogic/hub/ScaffoldingTest.java @@ -54,7 +54,7 @@ public void teardown() throws IOException { @Test public void createEntity() throws FileNotFoundException { assertFalse(projectDir.exists()); - Scaffolding scaffolding = new Scaffolding(projectDir.toString(), stagingClient); + Scaffolding scaffolding = Scaffolding.create(projectDir.toString(), stagingClient); scaffolding.createEntity("my-fun-test"); assertTrue(projectDir.exists()); @@ -88,7 +88,7 @@ private void createFlow(CodeFormat codeFormat, DataFormat dataFormat, FlowType f String entityName = "my-fun-test"; String flowName = "test-" + flowType.toString() + "-" + codeFormat.toString() + "-" + dataFormat.toString(); - Scaffolding scaffolding = new Scaffolding(projectDir.toString(), finalClient); + Scaffolding scaffolding = Scaffolding.create(projectDir.toString(), finalClient); Path entityDir = scaffolding.getEntityDir(entityName); assertFalse(entityDir.toFile().exists(), entityDir.toString() + " should not exist but does"); @@ -194,7 +194,7 @@ public void createXqyRestExtension() throws IOException { String extensionName = "myExtension"; FlowType flowType = FlowType.HARMONIZE; CodeFormat pluginCodeFormat = CodeFormat.XQUERY; - Scaffolding scaffolding = new Scaffolding(projectDir.toString(), stagingClient); + Scaffolding scaffolding = Scaffolding.create(projectDir.toString(), stagingClient); try { scaffolding.createRestExtension(entityName, extensionName, flowType, pluginCodeFormat); } catch (ScaffoldingValidationException e) { @@ -218,7 +218,7 @@ public void createSjsRestExtension() throws IOException { String extensionName = "myExtension"; FlowType flowType = FlowType.INPUT; CodeFormat pluginCodeFormat = CodeFormat.JAVASCRIPT; - Scaffolding scaffolding = new Scaffolding(projectDir.toString(), stagingClient); + Scaffolding scaffolding = Scaffolding.create(projectDir.toString(), stagingClient); try { scaffolding.createRestExtension(entityName, extensionName, flowType, pluginCodeFormat); } catch (ScaffoldingValidationException e) { @@ -242,7 +242,7 @@ public void createXqyRestTransform() throws IOException { String transformName = "myTransform"; FlowType flowType = FlowType.HARMONIZE; CodeFormat pluginCodeFormat = CodeFormat.XQUERY; - Scaffolding scaffolding = new Scaffolding(projectDir.toString(), stagingClient); + Scaffolding scaffolding = Scaffolding.create(projectDir.toString(), stagingClient); try { scaffolding.createRestTransform(entityName, transformName, flowType, pluginCodeFormat); } catch (ScaffoldingValidationException e) { @@ -262,7 +262,7 @@ public void createSjsRestTransform() throws IOException { String transformName = "myTransform"; FlowType flowType = FlowType.HARMONIZE; CodeFormat pluginCodeFormat = CodeFormat.JAVASCRIPT; - Scaffolding scaffolding = new Scaffolding(projectDir.toString(), stagingClient); + Scaffolding scaffolding = Scaffolding.create(projectDir.toString(), stagingClient); try { scaffolding.createRestTransform(entityName, transformName, flowType, pluginCodeFormat); } catch (ScaffoldingValidationException e) { @@ -280,7 +280,7 @@ private void updateLegacyFlow(String fromVersion, String entityName, CodeFormat try { String flowName = "legacy-" + codeFormat.toString() + "-" + dataFormat.toString() + "-" + flowType.toString() + "-flow"; - Scaffolding scaffolding = new Scaffolding(projectDir.toString(), stagingClient); + Scaffolding scaffolding = Scaffolding.create(projectDir.toString(), stagingClient); assertEquals(0, scaffolding.updateLegacyFlows(fromVersion, entityName).size()); Path flowParentDir = projectPath.resolve("plugins").resolve("entities").resolve(entityName).resolve(flowType.toString()); diff --git a/marklogic-data-hub/src/test/java/com/marklogic/hub/ScaffoldingValidatorTest.java b/marklogic-data-hub/src/test/java/com/marklogic/hub/ScaffoldingValidatorTest.java index 910b94b794..67e65aa7f7 100644 --- a/marklogic-data-hub/src/test/java/com/marklogic/hub/ScaffoldingValidatorTest.java +++ b/marklogic-data-hub/src/test/java/com/marklogic/hub/ScaffoldingValidatorTest.java @@ -13,7 +13,6 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; -import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; @@ -26,7 +25,7 @@ public class ScaffoldingValidatorTest extends HubTestBase { private static final String projectPath = "./test-project"; private static final String TEST_ENTITY_NAME = "test-entity"; - private Scaffolding scaffolding = new Scaffolding(projectPath, stagingClient); + private Scaffolding scaffolding = Scaffolding.create(projectPath, stagingClient); private ScaffoldingValidator validator = new ScaffoldingValidator(projectPath); @BeforeClass diff --git a/marklogic-data-hub/src/test/java/com/marklogic/hub/TracingTest.java b/marklogic-data-hub/src/test/java/com/marklogic/hub/TracingTest.java index bf1482cfe4..acc2124dbc 100644 --- a/marklogic-data-hub/src/test/java/com/marklogic/hub/TracingTest.java +++ b/marklogic-data-hub/src/test/java/com/marklogic/hub/TracingTest.java @@ -5,7 +5,6 @@ import com.marklogic.client.io.JacksonHandle; import com.marklogic.client.query.RawStructuredQueryDefinition; import com.marklogic.client.query.StructuredQueryBuilder; -import com.marklogic.client.query.StructuredQueryDefinition; import com.marklogic.hub.flow.Flow; import com.marklogic.hub.flow.FlowRunner; import org.custommonkey.xmlunit.XMLUnit; @@ -39,13 +38,13 @@ public static void setup() throws IOException, URISyntaxException { @Before public void beforeEach() { clearDatabases(HubConfig.DEFAULT_JOB_NAME, HubConfig.DEFAULT_TRACE_NAME, HubConfig.DEFAULT_FINAL_NAME); - new Tracing(stagingClient).disable(); + Tracing.create(stagingClient).disable(); } @AfterClass public static void teardown() { clearDatabases(HubConfig.DEFAULT_JOB_NAME, HubConfig.DEFAULT_TRACE_NAME, HubConfig.DEFAULT_FINAL_NAME); - new Tracing(stagingClient).disable(); + Tracing.create(stagingClient).disable(); } @Test @@ -53,7 +52,7 @@ public void runXMLFlowSansTracing() { assertEquals(0, getFinalDocCount()); assertEquals(0, getTracingDocCount()); - Tracing t = new Tracing(stagingClient); + Tracing t = Tracing.create(stagingClient); assertFalse(t.isEnabled()); FlowManager fm = new FlowManager(getHubConfig()); @@ -75,7 +74,7 @@ public void runJSONFlowSansTracing() { assertEquals(0, getFinalDocCount()); assertEquals(0, getTracingDocCount()); - Tracing t = new Tracing(stagingClient); + Tracing t = Tracing.create(stagingClient); assertFalse(t.isEnabled()); FlowManager fm = new FlowManager(getHubConfig()); @@ -97,7 +96,7 @@ public void runXMLFlowWithTracing() { assertEquals(0, getFinalDocCount()); assertEquals(0, getTracingDocCount()); - Tracing t = new Tracing(stagingClient); + Tracing t = Tracing.create(stagingClient); assertFalse(t.isEnabled()); t.enable(); @@ -122,7 +121,7 @@ public void runJSONFlowWithTracing() { assertEquals(0, getFinalDocCount()); assertEquals(0, getTracingDocCount()); - Tracing t = new Tracing(stagingClient); + Tracing t = Tracing.create(stagingClient); assertFalse(t.isEnabled()); t.enable(); @@ -148,7 +147,7 @@ public void runXMLErrorFlowWithoutTracing() { assertEquals(0, getFinalDocCount()); assertEquals(0, getTracingDocCount()); - Tracing t = new Tracing(stagingClient); + Tracing t = Tracing.create(stagingClient); assertFalse(t.isEnabled()); FlowManager fm = new FlowManager(getHubConfig()); @@ -176,7 +175,7 @@ public void runXMLWriterErrorFlowWithoutTracing() { assertEquals(0, getFinalDocCount()); assertEquals(0, getTracingDocCount()); - Tracing t = new Tracing(stagingClient); + Tracing t = Tracing.create(stagingClient); assertFalse(t.isEnabled()); FlowManager fm = new FlowManager(getHubConfig()); @@ -204,7 +203,7 @@ public void runJSONErrorFlowWithoutTracing() { assertEquals(0, getFinalDocCount()); assertEquals(0, getTracingDocCount()); - Tracing t = new Tracing(stagingClient); + Tracing t = Tracing.create(stagingClient); assertFalse(t.isEnabled()); FlowManager fm = new FlowManager(getHubConfig()); @@ -234,7 +233,7 @@ public void runJSONWriterErrorFlowWithoutTracing() { assertEquals(0, getFinalDocCount()); assertEquals(0, getTracingDocCount()); - Tracing t = new Tracing(stagingClient); + Tracing t = Tracing.create(stagingClient); assertFalse(t.isEnabled()); FlowManager fm = new FlowManager(getHubConfig()); diff --git a/marklogic-data-hub/src/test/java/com/marklogic/hub/collector/StreamCollectorTest.java b/marklogic-data-hub/src/test/java/com/marklogic/hub/collector/StreamCollectorTest.java index d6cef7d7b7..b0579929c5 100644 --- a/marklogic-data-hub/src/test/java/com/marklogic/hub/collector/StreamCollectorTest.java +++ b/marklogic-data-hub/src/test/java/com/marklogic/hub/collector/StreamCollectorTest.java @@ -65,7 +65,7 @@ public static void setup() throws IOException { disableDebugging(); disableTracing(); - Scaffolding scaffolding = new Scaffolding(projectDir.toString(), stagingClient); + Scaffolding scaffolding = Scaffolding.create(projectDir.toString(), stagingClient); scaffolding.createEntity(ENTITY); scaffolding.createFlow(ENTITY, "testharmonize", FlowType.HARMONIZE, CodeFormat.XQUERY, DataFormat.XML); diff --git a/marklogic-data-hub/src/test/java/com/marklogic/hub/deploy/commands/GenerateHubTDETemplateCommandTest.java b/marklogic-data-hub/src/test/java/com/marklogic/hub/deploy/commands/GenerateHubTDETemplateCommandTest.java index 58f087aecf..4dd2efb680 100644 --- a/marklogic-data-hub/src/test/java/com/marklogic/hub/deploy/commands/GenerateHubTDETemplateCommandTest.java +++ b/marklogic-data-hub/src/test/java/com/marklogic/hub/deploy/commands/GenerateHubTDETemplateCommandTest.java @@ -1,18 +1,11 @@ package com.marklogic.hub.deploy.commands; -import com.marklogic.appdeployer.command.CommandContext; -import com.marklogic.hub.HubConfig; import com.marklogic.hub.HubTestBase; import com.marklogic.hub.scaffold.Scaffolding; import com.marklogic.hub.util.FileUtil; -import org.custommonkey.xmlunit.XMLUnit; -import org.easymock.EasyMock; import org.junit.AfterClass; import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; -import org.junit.jupiter.api.BeforeEach; -import org.xml.sax.SAXException; import java.io.File; import java.io.IOException; @@ -52,7 +45,7 @@ public static void teardown() throws IOException { } private void installEntity(String entityName) { - Scaffolding scaffolding = new Scaffolding(projectDir.toString(), finalClient); + Scaffolding scaffolding = Scaffolding.create(projectDir.toString(), finalClient); Path entityDir = scaffolding.getEntityDir(entityName); entityDir.toFile().mkdirs(); assertTrue(entityDir.toFile().exists()); diff --git a/marklogic-data-hub/src/test/java/com/marklogic/hub/flow/FlowRunnerTest.java b/marklogic-data-hub/src/test/java/com/marklogic/hub/flow/FlowRunnerTest.java index c080868c03..581db51783 100644 --- a/marklogic-data-hub/src/test/java/com/marklogic/hub/flow/FlowRunnerTest.java +++ b/marklogic-data-hub/src/test/java/com/marklogic/hub/flow/FlowRunnerTest.java @@ -55,7 +55,7 @@ public static void setup() throws IOException { enableDebugging(); enableTracing(); - Scaffolding scaffolding = new Scaffolding(projectDir.toString(), stagingClient); + Scaffolding scaffolding = Scaffolding.create(projectDir.toString(), stagingClient); scaffolding.createEntity(ENTITY); scaffolding.createFlow(ENTITY, "testharmonize", FlowType.HARMONIZE, CodeFormat.XQUERY, DataFormat.XML); diff --git a/marklogic-data-hub/src/test/java/com/marklogic/hub/job/JobManagerTest.java b/marklogic-data-hub/src/test/java/com/marklogic/hub/job/JobManagerTest.java index 5f61050a81..168ed5b7e6 100644 --- a/marklogic-data-hub/src/test/java/com/marklogic/hub/job/JobManagerTest.java +++ b/marklogic-data-hub/src/test/java/com/marklogic/hub/job/JobManagerTest.java @@ -44,7 +44,7 @@ public static void setupSuite() { enableDebugging(); enableTracing(); - Scaffolding scaffolding = new Scaffolding(projectDir.toString(), stagingClient); + Scaffolding scaffolding = Scaffolding.create(projectDir.toString(), stagingClient); scaffolding.createEntity(ENTITY); // Traces can be XML or JSON, depending on the DataFormat of the flow that created them. Get some of each // to make sure export and import work correctly. diff --git a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/CreateEntityTask.groovy b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/CreateEntityTask.groovy index 135d762410..fa1f805528 100644 --- a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/CreateEntityTask.groovy +++ b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/CreateEntityTask.groovy @@ -16,7 +16,7 @@ class CreateEntityTask extends HubTask { def projectDir = getHubConfig().projectDir println "entityName: " + entityName println "projectDir: " + projectDir.toString() - Scaffolding scaffolding = new Scaffolding(projectDir, getFinalClient()) + Scaffolding scaffolding = Scaffolding.createImpl(projectDir, getFinalClient()) scaffolding.createEntity(entityName) } } diff --git a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/CreateFlowTask.groovy b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/CreateFlowTask.groovy index 710047a304..f0f823de78 100644 --- a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/CreateFlowTask.groovy +++ b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/CreateFlowTask.groovy @@ -49,7 +49,7 @@ abstract class CreateFlowTask extends HubTask { } def projectDir = getHubConfig().projectDir - Scaffolding scaffolding = new Scaffolding(projectDir, getFinalClient()) + Scaffolding scaffolding = Scaffolding.createImpl(projectDir, getFinalClient()) println "Creating an " + pluginFormat + " " + flowType + " flow named " + flowName + " for entity " + entityName scaffolding.createFlow(entityName, flowName, flowType, pluginFormat, dataFormat, useES) } diff --git a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/HubTask.groovy b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/HubTask.groovy index d46f304ca4..347be66fa0 100644 --- a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/HubTask.groovy +++ b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/HubTask.groovy @@ -23,12 +23,12 @@ abstract class HubTask extends DefaultTask { @Internal Tracing getTracing() { - return new Tracing(getStagingClient()) + return Tracing.create(getStagingClient()) } @Internal Debugging getDebugging() { - return new Debugging(getStagingClient()) + return Debugging.create(getStagingClient()) } @Internal diff --git a/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/InstalledTests.groovy b/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/InstalledTests.groovy index 7838f980b8..8a65f15fa2 100644 --- a/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/InstalledTests.groovy +++ b/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/InstalledTests.groovy @@ -2,11 +2,11 @@ package com.marklogic.gradle.task import com.marklogic.client.io.DOMHandle import com.marklogic.client.io.DocumentMetadataHandle -import com.marklogic.hub.Debugging import com.marklogic.hub.HubConfig -import com.marklogic.hub.Tracing import org.gradle.testkit.runner.UnexpectedBuildFailure import org.gradle.testkit.runner.UnexpectedBuildSuccess +import com.marklogic.hub.Tracing; +import com.marklogic.hub.Debugging; import java.nio.file.Paths @@ -33,7 +33,7 @@ class InstalledTests extends BaseTest { then: notThrown(UnexpectedBuildFailure) result.task(":hubEnableDebugging").outcome == SUCCESS - Debugging d = new Debugging(hubConfig().newStagingClient()) + Debugging d = Debugging.create(hubConfig().newStagingClient()) d.isEnabled() == true } @@ -44,7 +44,7 @@ class InstalledTests extends BaseTest { then: notThrown(UnexpectedBuildFailure) result.task(":hubDisableDebugging").outcome == SUCCESS - Debugging d = new Debugging(hubConfig().newStagingClient()) + Debugging d = Debugging.create(hubConfig().newStagingClient()) d.isEnabled() == false } @@ -55,7 +55,7 @@ class InstalledTests extends BaseTest { then: notThrown(UnexpectedBuildFailure) result.task(":hubEnableTracing").outcome == SUCCESS - Tracing t = new Tracing(hubConfig().newStagingClient()) + Tracing t = Tracing.create(hubConfig().newStagingClient()) t.isEnabled() == true } @@ -66,7 +66,7 @@ class InstalledTests extends BaseTest { then: notThrown(UnexpectedBuildFailure) result.task(":hubDisableTracing").outcome == SUCCESS - Tracing t = new Tracing(hubConfig().newStagingClient()) + Tracing t = Tracing.create(hubConfig().newStagingClient()) t.isEnabled() == false } diff --git a/quick-start/src/main/java/com/marklogic/quickstart/service/EntityManagerService.java b/quick-start/src/main/java/com/marklogic/quickstart/service/EntityManagerService.java index 94cedcbac7..97ba4dee7f 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/service/EntityManagerService.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/service/EntityManagerService.java @@ -124,7 +124,7 @@ public List getEntities() throws IOException { } public EntityModel createEntity(String projectDir, EntityModel newEntity) throws IOException { - Scaffolding scaffolding = new Scaffolding(projectDir, envConfig().getFinalClient()); + Scaffolding scaffolding = Scaffolding.create(projectDir, envConfig().getFinalClient()); scaffolding.createEntity(newEntity.getName()); if (newEntity.inputFlows != null) { @@ -300,14 +300,14 @@ public FlowModel getFlow(String entityName, FlowType flowType, String flowName) } public FlowModel createFlow(String projectDir, String entityName, FlowType flowType, FlowModel newFlow) throws IOException { - Scaffolding scaffolding = new Scaffolding(projectDir, envConfig().getFinalClient()); + Scaffolding scaffolding = Scaffolding.create(projectDir, envConfig().getFinalClient()); newFlow.entityName = entityName; scaffolding.createFlow(entityName, newFlow.flowName, flowType, newFlow.codeFormat, newFlow.dataFormat, newFlow.useEsModel); return getFlow(entityName, flowType, newFlow.flowName); } public void deleteFlow(String projectDir, String entityName, String flowName, FlowType flowType) throws IOException { - Scaffolding scaffolding = new Scaffolding(projectDir, envConfig().getFinalClient()); + Scaffolding scaffolding = Scaffolding.create(projectDir, envConfig().getFinalClient()); Path flowDir = scaffolding.getFlowDir(entityName, flowName, flowType); FileUtils.deleteDirectory(flowDir.toFile()); } diff --git a/quick-start/src/main/java/com/marklogic/quickstart/web/CurrentProjectController.java b/quick-start/src/main/java/com/marklogic/quickstart/web/CurrentProjectController.java index a8514a6da9..16fb8231d8 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/web/CurrentProjectController.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/web/CurrentProjectController.java @@ -100,7 +100,7 @@ public void onError() {} envConfig().setInitialized(installed); if (installed) { if (envConfig().getEnvironment().equals("local")) { - Tracing tracing = new Tracing(envConfig().getStagingClient()); + Tracing tracing = Tracing.create(envConfig().getStagingClient()); tracing.enable(); } logger.info("OnFinished: installing user modules"); diff --git a/quick-start/src/main/java/com/marklogic/quickstart/web/SettingsController.java b/quick-start/src/main/java/com/marklogic/quickstart/web/SettingsController.java index 2eb2a24371..7734bba1ff 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/web/SettingsController.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/web/SettingsController.java @@ -35,14 +35,14 @@ public class SettingsController extends EnvironmentAware { private Tracing getTracing() { if (tracing == null) { - tracing = new Tracing(envConfig().getStagingClient()); + tracing = Tracing.create(envConfig().getStagingClient()); } return tracing; } private Debugging getDebugging() { if (debugging == null) { - debugging = new Debugging(envConfig().getStagingClient()); + debugging = Debugging.create(envConfig().getStagingClient()); } return debugging; } diff --git a/quick-start/src/test/java/com/marklogic/quickstart/service/EntityManagerServiceTest.java b/quick-start/src/test/java/com/marklogic/quickstart/service/EntityManagerServiceTest.java index 97cd0e4445..36e3509ccc 100644 --- a/quick-start/src/test/java/com/marklogic/quickstart/service/EntityManagerServiceTest.java +++ b/quick-start/src/test/java/com/marklogic/quickstart/service/EntityManagerServiceTest.java @@ -2,7 +2,6 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.marklogic.hub.HubConfig; import com.marklogic.hub.HubConfigBuilder; import com.marklogic.hub.HubTestBase; import com.marklogic.hub.flow.CodeFormat; @@ -19,8 +18,6 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.mock.web.MockHttpServletRequest; -import org.springframework.mock.web.MockHttpSession; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.test.context.junit4.SpringRunner; @@ -62,7 +59,7 @@ private static void setEnvConfig(EnvironmentConfig envConfig) { public void setUp() throws IOException { FileUtils.deleteDirectory(projectDir.toFile()); - Scaffolding scaffolding = new Scaffolding(projectDir.toString(), stagingClient); + Scaffolding scaffolding = Scaffolding.create(projectDir.toString(), stagingClient); scaffolding.createEntity(ENTITY); scaffolding.createFlow(ENTITY, "sjs-json-input-flow", FlowType.INPUT, CodeFormat.JAVASCRIPT, DataFormat.JSON); diff --git a/quick-start/src/test/java/com/marklogic/quickstart/service/FlowManagerServiceTest.java b/quick-start/src/test/java/com/marklogic/quickstart/service/FlowManagerServiceTest.java index 31268c3590..cb11d8b05b 100644 --- a/quick-start/src/test/java/com/marklogic/quickstart/service/FlowManagerServiceTest.java +++ b/quick-start/src/test/java/com/marklogic/quickstart/service/FlowManagerServiceTest.java @@ -58,7 +58,7 @@ public static void setup() throws IOException { FileUtils.deleteDirectory(projectDir.toFile()); installHub(); - Scaffolding scaffolding = new Scaffolding(projectDir.toString(), stagingClient); + Scaffolding scaffolding = Scaffolding.create(projectDir.toString(), stagingClient); scaffolding.createEntity(ENTITY); scaffolding.createFlow(ENTITY, "sjs-json-input-flow", FlowType.INPUT, CodeFormat.JAVASCRIPT, DataFormat.JSON); diff --git a/quick-start/src/test/java/com/marklogic/quickstart/web/EntitiesControllerTest.java b/quick-start/src/test/java/com/marklogic/quickstart/web/EntitiesControllerTest.java index 5b4aac9afb..9b674e6f04 100644 --- a/quick-start/src/test/java/com/marklogic/quickstart/web/EntitiesControllerTest.java +++ b/quick-start/src/test/java/com/marklogic/quickstart/web/EntitiesControllerTest.java @@ -5,7 +5,6 @@ import com.marklogic.client.document.DocumentRecord; import com.marklogic.client.io.DocumentMetadataHandle; import com.marklogic.client.io.JacksonHandle; -import com.marklogic.hub.HubConfig; import com.marklogic.hub.HubConfigBuilder; import com.marklogic.hub.flow.CodeFormat; import com.marklogic.hub.flow.DataFormat; @@ -67,7 +66,7 @@ public void runHarmonizeNoOptions() throws IOException, InterruptedException { installHub(); Path projectDir = Paths.get(".", PROJECT_PATH); - Scaffolding scaffolding = new Scaffolding(projectDir.toString(), stagingClient); + Scaffolding scaffolding = Scaffolding.create(projectDir.toString(), stagingClient); scaffolding.createFlow(ENTITY, "sjs-json-harmonization-flow", FlowType.HARMONIZE, CodeFormat.JAVASCRIPT, DataFormat.JSON); @@ -108,7 +107,7 @@ public void runHarmonizeFlowWithOptions() throws IOException, InterruptedExcepti installHub(); Path projectDir = Paths.get(".", PROJECT_PATH); - Scaffolding scaffolding = new Scaffolding(projectDir.toString(), stagingClient); + Scaffolding scaffolding = Scaffolding.create(projectDir.toString(), stagingClient); scaffolding.createFlow(ENTITY, "sjs-json-harmonization-flow", FlowType.HARMONIZE, CodeFormat.JAVASCRIPT, DataFormat.JSON); From ba2eb7789a6d3b5c4f5fd0a20a78da64f03a37de Mon Sep 17 00:00:00 2001 From: Alexander Ebadirad Date: Wed, 14 Feb 2018 20:20:02 -0700 Subject: [PATCH 02/22] Entity manager refactor --- .../java/com/marklogic/hub/EntityManager.java | 241 +---------------- .../commands/LoadUserModulesCommand.java | 2 +- .../marklogic/hub/impl/EntityManagerImpl.java | 245 ++++++++++++++++++ .../com/marklogic/hub/EntityManagerTest.java | 6 +- .../service/EntityManagerService.java | 4 +- 5 files changed, 258 insertions(+), 240 deletions(-) create mode 100644 marklogic-data-hub/src/main/java/com/marklogic/hub/impl/EntityManagerImpl.java diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/EntityManager.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/EntityManager.java index 1b5ccc8fa3..0cc84d14c8 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/EntityManager.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/EntityManager.java @@ -1,246 +1,19 @@ -/* - * Copyright 2012-2018 MarkLogic Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ package com.marklogic.hub; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.marklogic.client.DatabaseClient; -import com.marklogic.client.ext.helper.LoggingObject; -import com.marklogic.client.ext.modulesloader.impl.AssetFileLoader; -import com.marklogic.client.ext.modulesloader.impl.DefaultModulesLoader; -import com.marklogic.client.ext.modulesloader.impl.PropertiesModuleManager; -import com.marklogic.client.extensions.ResourceManager; -import com.marklogic.client.extensions.ResourceServices; -import com.marklogic.client.io.JacksonHandle; -import com.marklogic.client.io.StringHandle; -import com.marklogic.client.util.RequestParameters; -import com.marklogic.hub.util.HubModuleManager; -import org.apache.commons.io.FileUtils; -import org.springframework.core.io.FileSystemResource; +import com.marklogic.hub.impl.EntityManagerImpl; import org.springframework.core.io.Resource; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; import java.util.List; -import java.util.stream.Collectors; -public class EntityManager extends LoggingObject { - private static final String ENTITY_FILE_EXTENSION = ".entity.json"; +public interface EntityManager { - private HubConfig hubConfig; - - public EntityManager(HubConfig hubConfig) { - this.hubConfig = hubConfig; - } - - public boolean saveSearchOptions() { - SearchOptionsGenerator generator = new SearchOptionsGenerator(hubConfig.newStagingClient()); - try { - Path dir = Paths.get(hubConfig.getProjectDir(), HubConfig.ENTITY_CONFIG_DIR); - if (!dir.toFile().exists()) { - dir.toFile().mkdirs(); - } - - File stagingFile = Paths.get(dir.toString(), HubConfig.STAGING_ENTITY_SEARCH_OPTIONS_FILE).toFile(); - File finalFile = Paths.get(dir.toString(), HubConfig.FINAL_ENTITY_SEARCH_OPTIONS_FILE).toFile(); - - long lastModified = Math.max(stagingFile.lastModified(), finalFile.lastModified()); - List entities = getModifiedRawEntities(lastModified); - if (entities.size() > 0) { - String options = generator.generateOptions(entities); - FileUtils.writeStringToFile(stagingFile, options); - FileUtils.writeStringToFile(finalFile, options); - return true; - } - } - catch(IOException e) { - e.printStackTrace(); - } - return false; - } - - public List deploySearchOptions() { - // save them first - saveSearchOptions(); - - HubModuleManager propsManager = getPropsMgr(); - DefaultModulesLoader modulesLoader = new DefaultModulesLoader(new AssetFileLoader(hubConfig.newFinalClient(), propsManager)); - - modulesLoader.setModulesManager(propsManager); - modulesLoader.setShutdownTaskExecutorAfterLoadingModules(false); - - List loadedResources = new ArrayList<>(); - - Path dir = Paths.get(hubConfig.getProjectDir(), HubConfig.ENTITY_CONFIG_DIR); - File stagingFile = Paths.get(dir.toString(), HubConfig.STAGING_ENTITY_SEARCH_OPTIONS_FILE).toFile(); - if (stagingFile.exists()) { - modulesLoader.setDatabaseClient(hubConfig.newStagingClient()); - Resource r = modulesLoader.installQueryOptions(new FileSystemResource(stagingFile)); - if (r != null) { - loadedResources.add(r); - } - } - - File finalFile = Paths.get(dir.toString(), HubConfig.FINAL_ENTITY_SEARCH_OPTIONS_FILE).toFile(); - if (finalFile.exists()) { - modulesLoader.setDatabaseClient(hubConfig.newFinalClient()); - Resource r = modulesLoader.installQueryOptions(new FileSystemResource(finalFile)); - if (r != null) { - loadedResources.add(r); - } - } - modulesLoader.setShutdownTaskExecutorAfterLoadingModules(true); - modulesLoader.waitForTaskExecutorToFinish(); - - return loadedResources; + static EntityManager create(HubConfig hubConfig) { + return new EntityManagerImpl(hubConfig); } - public boolean saveDbIndexes() { - try { - Path dir = hubConfig.getEntityDatabaseDir(); - if (!dir.toFile().exists()) { - dir.toFile().mkdirs(); - } - File finalFile = dir.resolve("final-database.json").toFile(); - File stagingFile = dir.resolve("staging-database.json").toFile(); - - long lastModified = Math.max(finalFile.lastModified(), stagingFile.lastModified()); - List entities = getModifiedRawEntities(lastModified); - if (entities.size() > 0) { - DbIndexGenerator generator = new DbIndexGenerator(hubConfig.newFinalClient()); - String indexes = generator.getIndexes(entities); - FileUtils.writeStringToFile(finalFile, indexes); - FileUtils.writeStringToFile(stagingFile, indexes); - return true; - } - } - catch(IOException e) { - e.printStackTrace(); - } - return false; - } + boolean saveSearchOptions(); - private HubModuleManager getPropsMgr() { - String timestampFile = hubConfig.getUserModulesDeployTimestampFile(); - HubModuleManager propertiesModuleManager = new HubModuleManager(timestampFile); - return propertiesModuleManager; - } - - private List getModifiedRawEntities(long minimumFileTimestampToLoad) { - logger.info("min modified: " + minimumFileTimestampToLoad); - HubModuleManager propsManager = getPropsMgr(); - propsManager.setMinimumFileTimestampToLoad(minimumFileTimestampToLoad); - - List entities = new ArrayList<>(); - List tempEntities = new ArrayList<>(); - Path entitiesPath = hubConfig.getHubEntitiesDir(); - File[] entityFiles = entitiesPath.toFile().listFiles(pathname -> pathname.isDirectory() && !pathname.isHidden()); - List entityNames; - if (entityFiles != null) { - entityNames = Arrays.stream(entityFiles) - .map(file -> file.getName()) - .collect(Collectors.toList()); - - ObjectMapper objectMapper = new ObjectMapper(); - try { - boolean hasOneChanged = false; - for (String entityName : entityNames) { - File[] entityDefs = entitiesPath.resolve(entityName).toFile().listFiles((dir, name) -> name.endsWith(ENTITY_FILE_EXTENSION)); - for (File entityDef : entityDefs) { - if (propsManager.hasFileBeenModifiedSinceLastLoaded(entityDef)) { - hasOneChanged = true; - } - FileInputStream fileInputStream = new FileInputStream(entityDef); - tempEntities.add(objectMapper.readTree(fileInputStream)); - fileInputStream.close(); - } - } - // all or nothing - if (hasOneChanged) { - entities.addAll(tempEntities); - } - } catch (IOException e) { - throw new RuntimeException(e); - } - - } - return entities; - } - - private class SearchOptionsGenerator extends ResourceManager { - private static final String NAME = "ml:searchOptionsGenerator"; - - private RequestParameters params = new RequestParameters(); - - SearchOptionsGenerator(DatabaseClient client) { - super(); - client.init(NAME, this); - } - - String generateOptions(List entities) { - try { - ObjectMapper objectMapper = new ObjectMapper(); - JsonNode node = objectMapper.valueToTree(entities); - ResourceServices.ServiceResultIterator resultItr = this.getServices().post(params, new JacksonHandle(node)); - if (resultItr == null || ! resultItr.hasNext()) { - throw new IOException("Unable to generate search options"); - } - ResourceServices.ServiceResult res = resultItr.next(); - return res.getContent(new StringHandle()).get(); - } - catch(Exception e) { - e.printStackTrace(); - } - return "{}"; - } - } - - private class DbIndexGenerator extends ResourceManager { - private static final String NAME = "ml:dbConfigs"; - - private RequestParameters params = new RequestParameters(); - - DbIndexGenerator(DatabaseClient client) { - super(); - client.init(NAME, this); - } - - public String getIndexes(List entities) { - try { - ObjectMapper objectMapper = new ObjectMapper(); - JsonNode node = objectMapper.valueToTree(entities); - ResourceServices.ServiceResultIterator resultItr = this.getServices().post(params, new JacksonHandle(node)); - if (resultItr == null || ! resultItr.hasNext()) { - throw new IOException("Unable to generate database indexes"); - } - ResourceServices.ServiceResult res = resultItr.next(); - return res.getContent(new StringHandle()).get(); - } - catch(Exception e) { - e.printStackTrace(); - } - return "{}"; - } - } + List deploySearchOptions(); + boolean saveDbIndexes(); } diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/deploy/commands/LoadUserModulesCommand.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/deploy/commands/LoadUserModulesCommand.java index 637d609b6e..0e92227aae 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/deploy/commands/LoadUserModulesCommand.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/deploy/commands/LoadUserModulesCommand.java @@ -163,7 +163,7 @@ public void execute(CommandContext context) { } // deploy the auto-generated ES search options - EntityManager entityManager = new EntityManager(hubConfig); + EntityManager entityManager = EntityManager.create(hubConfig); entityManager.deploySearchOptions(); try { diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/EntityManagerImpl.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/EntityManagerImpl.java new file mode 100644 index 0000000000..5718006913 --- /dev/null +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/EntityManagerImpl.java @@ -0,0 +1,245 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.marklogic.hub.impl; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.marklogic.client.DatabaseClient; +import com.marklogic.client.ext.helper.LoggingObject; +import com.marklogic.client.ext.modulesloader.impl.AssetFileLoader; +import com.marklogic.client.ext.modulesloader.impl.DefaultModulesLoader; +import com.marklogic.client.extensions.ResourceManager; +import com.marklogic.client.extensions.ResourceServices; +import com.marklogic.client.io.JacksonHandle; +import com.marklogic.client.io.StringHandle; +import com.marklogic.client.util.RequestParameters; +import com.marklogic.hub.EntityManager; +import com.marklogic.hub.HubConfig; +import com.marklogic.hub.util.HubModuleManager; +import org.apache.commons.io.FileUtils; +import org.springframework.core.io.FileSystemResource; +import org.springframework.core.io.Resource; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +public class EntityManagerImpl extends LoggingObject implements EntityManager { + private static final String ENTITY_FILE_EXTENSION = ".entity.json"; + + private HubConfig hubConfig; + + public EntityManagerImpl(HubConfig hubConfig) { + this.hubConfig = hubConfig; + } + + @Override public boolean saveSearchOptions() { + SearchOptionsGenerator generator = new SearchOptionsGenerator(hubConfig.newStagingClient()); + try { + Path dir = Paths.get(hubConfig.getProjectDir(), HubConfig.ENTITY_CONFIG_DIR); + if (!dir.toFile().exists()) { + dir.toFile().mkdirs(); + } + + File stagingFile = Paths.get(dir.toString(), HubConfig.STAGING_ENTITY_SEARCH_OPTIONS_FILE).toFile(); + File finalFile = Paths.get(dir.toString(), HubConfig.FINAL_ENTITY_SEARCH_OPTIONS_FILE).toFile(); + + long lastModified = Math.max(stagingFile.lastModified(), finalFile.lastModified()); + List entities = getModifiedRawEntities(lastModified); + if (entities.size() > 0) { + String options = generator.generateOptions(entities); + FileUtils.writeStringToFile(stagingFile, options); + FileUtils.writeStringToFile(finalFile, options); + return true; + } + } + catch(IOException e) { + e.printStackTrace(); + } + return false; + } + + @Override public List deploySearchOptions() { + // save them first + saveSearchOptions(); + + HubModuleManager propsManager = getPropsMgr(); + DefaultModulesLoader modulesLoader = new DefaultModulesLoader(new AssetFileLoader(hubConfig.newFinalClient(), propsManager)); + + modulesLoader.setModulesManager(propsManager); + modulesLoader.setShutdownTaskExecutorAfterLoadingModules(false); + + List loadedResources = new ArrayList<>(); + + Path dir = Paths.get(hubConfig.getProjectDir(), HubConfig.ENTITY_CONFIG_DIR); + File stagingFile = Paths.get(dir.toString(), HubConfig.STAGING_ENTITY_SEARCH_OPTIONS_FILE).toFile(); + if (stagingFile.exists()) { + modulesLoader.setDatabaseClient(hubConfig.newStagingClient()); + Resource r = modulesLoader.installQueryOptions(new FileSystemResource(stagingFile)); + if (r != null) { + loadedResources.add(r); + } + } + + File finalFile = Paths.get(dir.toString(), HubConfig.FINAL_ENTITY_SEARCH_OPTIONS_FILE).toFile(); + if (finalFile.exists()) { + modulesLoader.setDatabaseClient(hubConfig.newFinalClient()); + Resource r = modulesLoader.installQueryOptions(new FileSystemResource(finalFile)); + if (r != null) { + loadedResources.add(r); + } + } + modulesLoader.setShutdownTaskExecutorAfterLoadingModules(true); + modulesLoader.waitForTaskExecutorToFinish(); + + return loadedResources; + } + + @Override public boolean saveDbIndexes() { + try { + Path dir = hubConfig.getEntityDatabaseDir(); + if (!dir.toFile().exists()) { + dir.toFile().mkdirs(); + } + File finalFile = dir.resolve("final-database.json").toFile(); + File stagingFile = dir.resolve("staging-database.json").toFile(); + + long lastModified = Math.max(finalFile.lastModified(), stagingFile.lastModified()); + List entities = getModifiedRawEntities(lastModified); + if (entities.size() > 0) { + DbIndexGenerator generator = new DbIndexGenerator(hubConfig.newFinalClient()); + String indexes = generator.getIndexes(entities); + FileUtils.writeStringToFile(finalFile, indexes); + FileUtils.writeStringToFile(stagingFile, indexes); + return true; + } + } + catch(IOException e) { + e.printStackTrace(); + } + return false; + } + + private HubModuleManager getPropsMgr() { + String timestampFile = hubConfig.getUserModulesDeployTimestampFile(); + HubModuleManager propertiesModuleManager = new HubModuleManager(timestampFile); + return propertiesModuleManager; + } + + private List getModifiedRawEntities(long minimumFileTimestampToLoad) { + logger.info("min modified: " + minimumFileTimestampToLoad); + HubModuleManager propsManager = getPropsMgr(); + propsManager.setMinimumFileTimestampToLoad(minimumFileTimestampToLoad); + + List entities = new ArrayList<>(); + List tempEntities = new ArrayList<>(); + Path entitiesPath = hubConfig.getHubEntitiesDir(); + File[] entityFiles = entitiesPath.toFile().listFiles(pathname -> pathname.isDirectory() && !pathname.isHidden()); + List entityNames; + if (entityFiles != null) { + entityNames = Arrays.stream(entityFiles) + .map(file -> file.getName()) + .collect(Collectors.toList()); + + ObjectMapper objectMapper = new ObjectMapper(); + try { + boolean hasOneChanged = false; + for (String entityName : entityNames) { + File[] entityDefs = entitiesPath.resolve(entityName).toFile().listFiles((dir, name) -> name.endsWith(ENTITY_FILE_EXTENSION)); + for (File entityDef : entityDefs) { + if (propsManager.hasFileBeenModifiedSinceLastLoaded(entityDef)) { + hasOneChanged = true; + } + FileInputStream fileInputStream = new FileInputStream(entityDef); + tempEntities.add(objectMapper.readTree(fileInputStream)); + fileInputStream.close(); + } + } + // all or nothing + if (hasOneChanged) { + entities.addAll(tempEntities); + } + } catch (IOException e) { + throw new RuntimeException(e); + } + + } + return entities; + } + + private class SearchOptionsGenerator extends ResourceManager { + private static final String NAME = "ml:searchOptionsGenerator"; + + private RequestParameters params = new RequestParameters(); + + SearchOptionsGenerator(DatabaseClient client) { + super(); + client.init(NAME, this); + } + + String generateOptions(List entities) { + try { + ObjectMapper objectMapper = new ObjectMapper(); + JsonNode node = objectMapper.valueToTree(entities); + ResourceServices.ServiceResultIterator resultItr = this.getServices().post(params, new JacksonHandle(node)); + if (resultItr == null || ! resultItr.hasNext()) { + throw new IOException("Unable to generate search options"); + } + ResourceServices.ServiceResult res = resultItr.next(); + return res.getContent(new StringHandle()).get(); + } + catch(Exception e) { + e.printStackTrace(); + } + return "{}"; + } + } + + private class DbIndexGenerator extends ResourceManager { + private static final String NAME = "ml:dbConfigs"; + + private RequestParameters params = new RequestParameters(); + + DbIndexGenerator(DatabaseClient client) { + super(); + client.init(NAME, this); + } + + public String getIndexes(List entities) { + try { + ObjectMapper objectMapper = new ObjectMapper(); + JsonNode node = objectMapper.valueToTree(entities); + ResourceServices.ServiceResultIterator resultItr = this.getServices().post(params, new JacksonHandle(node)); + if (resultItr == null || ! resultItr.hasNext()) { + throw new IOException("Unable to generate database indexes"); + } + ResourceServices.ServiceResult res = resultItr.next(); + return res.getContent(new StringHandle()).get(); + } + catch(Exception e) { + e.printStackTrace(); + } + return "{}"; + } + } + +} diff --git a/marklogic-data-hub/src/test/java/com/marklogic/hub/EntityManagerTest.java b/marklogic-data-hub/src/test/java/com/marklogic/hub/EntityManagerTest.java index 3c1015bcfc..c46e9bda1c 100644 --- a/marklogic-data-hub/src/test/java/com/marklogic/hub/EntityManagerTest.java +++ b/marklogic-data-hub/src/test/java/com/marklogic/hub/EntityManagerTest.java @@ -108,7 +108,7 @@ public void testDeploySearchOptionsWithNoEntities() { assertEquals(0, getStagingDocCount()); assertEquals(0, getFinalDocCount()); - EntityManager entityManager = new EntityManager(getHubConfig()); + EntityManager entityManager = EntityManager.create(getHubConfig()); List deployed = entityManager.deploySearchOptions(); assertEquals(0, deployed.size()); @@ -133,7 +133,7 @@ public void testDeploySearchOptions() throws IOException, SAXException { assertEquals(0, getStagingDocCount()); assertEquals(0, getFinalDocCount()); - EntityManager entityManager = new EntityManager(getHubConfig()); + EntityManager entityManager = EntityManager.create(getHubConfig()); List deployed = entityManager.deploySearchOptions(); assertEquals(2, deployed.size()); @@ -168,7 +168,7 @@ public void testSaveDbIndexes() throws IOException { assertFalse(dir.resolve("final-database.json").toFile().exists()); assertFalse(dir.resolve("staging-database.json").toFile().exists()); - EntityManager entityManager = new EntityManager(getHubConfig()); + EntityManager entityManager = EntityManager.create(getHubConfig()); assertTrue(entityManager.saveDbIndexes()); assertTrue(dir.resolve("final-database.json").toFile().exists()); diff --git a/quick-start/src/main/java/com/marklogic/quickstart/service/EntityManagerService.java b/quick-start/src/main/java/com/marklogic/quickstart/service/EntityManagerService.java index 97ba4dee7f..8bb64ff64a 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/service/EntityManagerService.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/service/EntityManagerService.java @@ -202,12 +202,12 @@ public void deleteEntity(String entity) throws IOException { } public void deploySearchOptions(EnvironmentConfig environmentConfig) { - EntityManager em = new EntityManager(environmentConfig.getMlSettings()); + EntityManager em = EntityManager.create(environmentConfig.getMlSettings()); em.deploySearchOptions(); } public void saveDbIndexes(EnvironmentConfig environmentConfig) { - EntityManager em = new EntityManager(environmentConfig.getMlSettings()); + EntityManager em = EntityManager.create(environmentConfig.getMlSettings()); em.saveDbIndexes(); } From ea554e7d12e6e2abee18d86f543c13e4e6f2df0b Mon Sep 17 00:00:00 2001 From: Alexander Ebadirad Date: Wed, 14 Feb 2018 21:58:18 -0700 Subject: [PATCH 03/22] Entitiesvalidator interface& impl --- .../hub/validate/EntitiesValidator.java | 55 ++--------------- .../validate/impl/EntitiesValidatorImpl.java | 60 +++++++++++++++++++ .../com/marklogic/hub/EndToEndFlowTests.java | 2 +- .../quickstart/service/DataHubService.java | 2 +- .../service/EntityManagerService.java | 2 +- 5 files changed, 69 insertions(+), 52 deletions(-) create mode 100644 marklogic-data-hub/src/main/java/com/marklogic/hub/validate/impl/EntitiesValidatorImpl.java diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/validate/EntitiesValidator.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/validate/EntitiesValidator.java index 5d1eb26c53..84435cf81a 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/validate/EntitiesValidator.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/validate/EntitiesValidator.java @@ -1,59 +1,16 @@ -/* - * Copyright 2012-2018 MarkLogic Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ package com.marklogic.hub.validate; import com.fasterxml.jackson.databind.JsonNode; import com.marklogic.client.DatabaseClient; -import com.marklogic.client.extensions.ResourceManager; -import com.marklogic.client.extensions.ResourceServices; -import com.marklogic.client.io.Format; -import com.marklogic.client.io.JacksonHandle; -import com.marklogic.client.io.StringHandle; -import com.marklogic.client.util.RequestParameters; +import com.marklogic.hub.validate.impl.EntitiesValidatorImpl; -public class EntitiesValidator extends ResourceManager { - private static final String NAME = "ml:validate"; +public interface EntitiesValidator { - public EntitiesValidator(DatabaseClient client) { - super(); - client.init(NAME, this); + static EntitiesValidator create(DatabaseClient client){ + return new EntitiesValidatorImpl(client); } - public JsonNode validateAll() { - ResourceServices.ServiceResultIterator resultItr = this.getServices().get(new RequestParameters()); - if (resultItr == null || ! resultItr.hasNext()) { - return null; - } - ResourceServices.ServiceResult res = resultItr.next(); - return res.getContent(new JacksonHandle()).get(); - } + JsonNode validateAll(); - public JsonNode validate(String entity, String flow, String plugin, String type, String content) { - RequestParameters params = new RequestParameters(); - params.add("entity", entity); - params.add("flow", flow); - params.add("plugin", plugin); - params.add("type", type); - StringHandle handle = new StringHandle(content); - handle.setFormat(Format.TEXT); - ResourceServices.ServiceResultIterator resultItr = this.getServices().post(params, handle ); - if (resultItr == null || ! resultItr.hasNext()) { - return null; - } - ResourceServices.ServiceResult res = resultItr.next(); - return res.getContent(new JacksonHandle()).get(); - } + JsonNode validate(String entity, String flow, String plugin, String type, String content); } diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/validate/impl/EntitiesValidatorImpl.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/validate/impl/EntitiesValidatorImpl.java new file mode 100644 index 0000000000..a60ad5241b --- /dev/null +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/validate/impl/EntitiesValidatorImpl.java @@ -0,0 +1,60 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.marklogic.hub.validate.impl; + +import com.fasterxml.jackson.databind.JsonNode; +import com.marklogic.client.DatabaseClient; +import com.marklogic.client.extensions.ResourceManager; +import com.marklogic.client.extensions.ResourceServices; +import com.marklogic.client.io.Format; +import com.marklogic.client.io.JacksonHandle; +import com.marklogic.client.io.StringHandle; +import com.marklogic.client.util.RequestParameters; +import com.marklogic.hub.validate.EntitiesValidator; + +public class EntitiesValidatorImpl extends ResourceManager implements EntitiesValidator { + private static final String NAME = "ml:validate"; + + public EntitiesValidatorImpl(DatabaseClient client) { + super(); + client.init(NAME, this); + } + + @Override public JsonNode validateAll() { + ResourceServices.ServiceResultIterator resultItr = this.getServices().get(new RequestParameters()); + if (resultItr == null || ! resultItr.hasNext()) { + return null; + } + ResourceServices.ServiceResult res = resultItr.next(); + return res.getContent(new JacksonHandle()).get(); + } + + @Override public JsonNode validate(String entity, String flow, String plugin, String type, String content) { + RequestParameters params = new RequestParameters(); + params.add("entity", entity); + params.add("flow", flow); + params.add("plugin", plugin); + params.add("type", type); + StringHandle handle = new StringHandle(content); + handle.setFormat(Format.TEXT); + ResourceServices.ServiceResultIterator resultItr = this.getServices().post(params, handle ); + if (resultItr == null || ! resultItr.hasNext()) { + return null; + } + ResourceServices.ServiceResult res = resultItr.next(); + return res.getContent(new JacksonHandle()).get(); + } +} diff --git a/marklogic-data-hub/src/test/java/com/marklogic/hub/EndToEndFlowTests.java b/marklogic-data-hub/src/test/java/com/marklogic/hub/EndToEndFlowTests.java index 072c66c507..8a83cf4090 100644 --- a/marklogic-data-hub/src/test/java/com/marklogic/hub/EndToEndFlowTests.java +++ b/marklogic-data-hub/src/test/java/com/marklogic/hub/EndToEndFlowTests.java @@ -172,7 +172,7 @@ public static void teardown() { } private JsonNode validateUserModules() { - EntitiesValidator ev = new EntitiesValidator(getHubConfig().newStagingClient()); + EntitiesValidator ev = EntitiesValidator.create(getHubConfig().newStagingClient()); return ev.validateAll(); } diff --git a/quick-start/src/main/java/com/marklogic/quickstart/service/DataHubService.java b/quick-start/src/main/java/com/marklogic/quickstart/service/DataHubService.java index decdb64927..8fbd17f6bb 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/service/DataHubService.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/service/DataHubService.java @@ -135,7 +135,7 @@ public PreInstallCheck preInstallCheck(HubConfig config) { @Async public void validateUserModules(HubConfig hubConfig, ValidateListener validateListener) { - EntitiesValidator ev = new EntitiesValidator(hubConfig.newStagingClient()); + EntitiesValidator ev = EntitiesValidator.create(hubConfig.newStagingClient()); validateListener.onValidate(ev.validateAll()); } diff --git a/quick-start/src/main/java/com/marklogic/quickstart/service/EntityManagerService.java b/quick-start/src/main/java/com/marklogic/quickstart/service/EntityManagerService.java index 8bb64ff64a..be5cc1e70a 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/service/EntityManagerService.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/service/EntityManagerService.java @@ -326,7 +326,7 @@ public JsonNode validatePlugin( else { type = "xquery"; } - EntitiesValidator validator = new EntitiesValidator(config.newStagingClient()); + EntitiesValidator validator = EntitiesValidator.create(config.newStagingClient()); return validator.validate(entityName, flowName, plugin.fileContents.replaceAll("\\.(sjs|xqy)", ""), type, plugin.fileContents); } From 450e76db0f48d88f616446a6215cbd44b0ceb5c4 Mon Sep 17 00:00:00 2001 From: Alexander Ebadirad Date: Wed, 14 Feb 2018 23:09:05 -0700 Subject: [PATCH 04/22] Job manager interface and implementation changes --- .../java/com/marklogic/hub/FlowManager.java | 2 +- .../hub/flow/impl/FlowRunnerImpl.java | 2 +- .../com/marklogic/hub/job/JobManager.java | 270 +--------------- .../hub/job/impl/JobManagerImpl.java | 291 ++++++++++++++++++ .../com/marklogic/hub/util/MlcpRunner.java | 2 +- .../com/marklogic/hub/job/JobManagerTest.java | 21 +- .../com/marklogic/gradle/task/HubTask.groovy | 4 +- .../quickstart/service/JobService.java | 2 +- 8 files changed, 316 insertions(+), 278 deletions(-) create mode 100644 marklogic-data-hub/src/main/java/com/marklogic/hub/job/impl/JobManagerImpl.java diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/FlowManager.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/FlowManager.java index 0da52ab781..3f3ec5297a 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/FlowManager.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/FlowManager.java @@ -60,7 +60,7 @@ public FlowManager(HubConfig hubConfig) { this.stagingClient = hubConfig.newStagingClient(); this.finalClient = hubConfig.newFinalClient(); this.jobClient = hubConfig.newJobDbClient(); - this.jobManager = new JobManager(this.jobClient, this.hubConfig.newTraceDbClient()); + this.jobManager = JobManager.create(this.jobClient, this.hubConfig.newTraceDbClient()); this.dataMovementManager = this.stagingClient.newDataMovementManager(); this.stagingClient.init(NAME, this); } diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/flow/impl/FlowRunnerImpl.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/flow/impl/FlowRunnerImpl.java index 35949d7c81..fdfa5c87f3 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/flow/impl/FlowRunnerImpl.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/flow/impl/FlowRunnerImpl.java @@ -153,7 +153,7 @@ public void awaitCompletion(long timeout, TimeUnit unit) throws InterruptedExcep @Override public JobTicket run() { String jobId = UUID.randomUUID().toString(); - JobManager jobManager = new JobManager(hubConfig.newJobDbClient(), hubConfig.newTraceDbClient()); + JobManager jobManager = JobManager.create(hubConfig.newJobDbClient(), hubConfig.newTraceDbClient()); Job job = Job.withFlow(flow) .withJobId(jobId); diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/job/JobManager.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/job/JobManager.java index 7a007d41b3..96a544ea65 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/job/JobManager.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/job/JobManager.java @@ -1,105 +1,23 @@ -/* - * Copyright 2012-2018 MarkLogic Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ package com.marklogic.hub.job; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; import com.marklogic.client.DatabaseClient; -import com.marklogic.client.DatabaseClientFactory; import com.marklogic.client.Transaction; -import com.marklogic.client.datamovement.*; -import com.marklogic.client.document.DocumentWriteSet; -import com.marklogic.client.document.JSONDocumentManager; -import com.marklogic.client.ext.datamovement.consumer.WriteToZipConsumer; -import com.marklogic.client.extensions.ResourceManager; -import com.marklogic.client.extensions.ResourceServices; -import com.marklogic.client.io.DocumentMetadataHandle; -import com.marklogic.client.io.Format; -import com.marklogic.client.io.JacksonDatabindHandle; -import com.marklogic.client.io.StringHandle; -import com.marklogic.client.query.*; -import com.marklogic.client.util.RequestParameters; +import com.marklogic.hub.job.impl.JobManagerImpl; -import javax.xml.namespace.QName; -import java.io.File; import java.io.IOException; import java.nio.file.Path; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.Scanner; -import java.util.TimeZone; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; -public class JobManager { +public interface JobManager { - private DatabaseClient traceClient; - private DatabaseClient jobClient; - private JSONDocumentManager docMgr; - private JobDeleteResource jobDeleteRunner = null; - - private static final String ISO_8601_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX"; - private static SimpleDateFormat simpleDateFormat8601; - static { - try { - simpleDateFormat8601 = new SimpleDateFormat(ISO_8601_FORMAT); - // Java 1.6 doesn't yet know about X (ISO 8601 format) - } catch (IllegalArgumentException e) { - if ( "Illegal pattern character 'X'".equals(e.getMessage()) ) { - simpleDateFormat8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); - } - } + static JobManager create(DatabaseClient jobClient, DatabaseClient traceClient){ + return new JobManagerImpl(jobClient, traceClient); } - static { simpleDateFormat8601.setTimeZone(TimeZone.getTimeZone("UTC")); } - private ObjectMapper objectMapper = new ObjectMapper() - // if we don't do the next two lines Jackson will automatically close our streams which is undesirable - .configure(JsonGenerator.Feature.AUTO_CLOSE_TARGET, false) - .configure(JsonParser.Feature.AUTO_CLOSE_SOURCE, false) - // we do the next two so dates are written in xs:dateTime format - // which makes them ready for range indexes in MarkLogic Server - .configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false) - .setDateFormat(simpleDateFormat8601); - public JobManager(DatabaseClient jobClient, DatabaseClient traceClient) { - this.jobClient = jobClient; - this.traceClient = traceClient; - this.docMgr = jobClient.newJSONDocumentManager(); - this.jobDeleteRunner = new JobDeleteResource(jobClient); - } + void saveJob(Job job); - public void saveJob(Job job) { - saveJob(job, null); - } + void saveJob(Job job, Transaction transaction); - public void saveJob(Job job, Transaction transaction) { - JacksonDatabindHandle contentHandle = new JacksonDatabindHandle<>(job); - contentHandle.setMapper(objectMapper); - DocumentMetadataHandle metadataHandle = new DocumentMetadataHandle(); - metadataHandle = metadataHandle.withCollections("job"); - DocumentWriteSet writeSet = docMgr.newWriteSet(); - writeSet.add("/jobs/" + job.getJobId() + ".json", metadataHandle, contentHandle); - docMgr.write(writeSet, transaction); - } - - public JobDeleteResponse deleteJobs(String jobIds) { - return this.jobDeleteRunner.deleteJobs(jobIds); - } + JobDeleteResponse deleteJobs(String jobIds); /** * Export Job documents and their associated Trace documents to a zip file. @@ -107,182 +25,12 @@ public JobDeleteResponse deleteJobs(String jobIds) { * @param exportFilePath specifies where the zip file will be written * @param jobIds a comma-separated list of jobIds; if null, all will be exported */ - public JobExportResponse exportJobs(Path exportFilePath, String[] jobIds) { - JobExportResponse response = new JobExportResponse(); - response.fullPath = exportFilePath.toAbsolutePath().toString(); - - File zipFile = exportFilePath.toFile(); - WriteToZipConsumer zipConsumer = new WriteToZipConsumer(zipFile); - - QueryManager qm = jobClient.newQueryManager(); - - // Build a query that will match everything - StringQueryDefinition emptyQuery = qm.newStringDefinition(); - emptyQuery.setCriteria(""); - - // Get the job(s) document(s) - StructuredQueryBuilder sqb = qm.newStructuredQueryBuilder(); - DataMovementManager dmm = jobClient.newDataMovementManager(); - QueryBatcher batcher = null; - StructuredQueryDefinition query = null; - if (jobIds == null) { - batcher = dmm.newQueryBatcher(emptyQuery); - } - else { - batcher = dmm.newQueryBatcher(sqb.value(sqb.jsonProperty("jobId"), jobIds)); - } - batcher.onUrisReady(new ExportListener().onDocumentReady(zipConsumer)); - JobTicket jobTicket = dmm.startJob(batcher); - - batcher.awaitCompletion(); - dmm.stopJob(batcher); - dmm.release(); - - JobReport report = dmm.getJobReport(jobTicket); - long jobCount = report.getSuccessEventsCount(); - response.totalJobs = jobCount; - - if (jobCount > 0) { - - // Get the traces that go with the job(s) - dmm = this.traceClient.newDataMovementManager(); - if (jobIds == null) { - batcher = dmm.newQueryBatcher(emptyQuery); - } - else { - batcher = dmm.newQueryBatcher(sqb.value(sqb.element(new QName("jobId")), jobIds)); - } - batcher.onUrisReady(new ExportListener().onDocumentReady(zipConsumer)); - jobTicket = dmm.startJob(batcher); - - batcher.awaitCompletion(); - dmm.stopJob(batcher); - dmm.release(); - - report = dmm.getJobReport(jobTicket); - long traceCount = report.getSuccessEventsCount(); - response.totalTraces = traceCount; - - zipConsumer.close(); - } - else { - // there were no jobs, so don't produce an empty zip file - zipConsumer.close(); - zipFile.delete(); - } - - return response; - } + JobExportResponse exportJobs(Path exportFilePath, String[] jobIds); /** * Import Job documents and their associated Trace documents from a zip file. * * @param importFilePath specifies where the zip file exists */ - public void importJobs(Path importFilePath) throws IOException { - ZipFile importZip = new ZipFile(importFilePath.toFile()); - Enumeration entries = importZip.entries(); - - DataMovementManager dmm = jobClient.newDataMovementManager(); - WriteBatcher writer = dmm - .newWriteBatcher() - .withJobName("Load jobs") - .withBatchSize(50); - JobTicket ticket = dmm.startJob(writer); - - // Add each Job entry to the writer; set aside the Trace entries. - ArrayList traceEntries = new ArrayList(); - DocumentMetadataHandle jobMetadata = new DocumentMetadataHandle().withCollections("job"); - while (entries.hasMoreElements()) { - ZipEntry entry = entries.nextElement(); - - if (entry.getName().startsWith("/jobs/")) { - // Delimiter = \A, which is the beginning of the input - Scanner s = new Scanner(importZip.getInputStream(entry)).useDelimiter("\\A"); - String entryText = s.hasNext() ? s.next() : ""; - - writer.add( - entry.getName(), - jobMetadata, - new StringHandle(entryText).withFormat(Format.JSON) - ); - } - else { - traceEntries.add(entry); - } - } - - writer.flushAndWait(); - dmm.stopJob(ticket); - dmm.release(); - - if (traceEntries.size() > 0) { - dmm = this.traceClient.newDataMovementManager(); - writer = dmm - .newWriteBatcher() - .withJobName("Load traces"); - ticket = dmm.startJob(writer); - - DocumentMetadataHandle traceMetadata = new DocumentMetadataHandle().withCollections("trace"); - - for (ZipEntry entry: traceEntries) { - // Delimiter = \A, which is the beginning of the input - Scanner s = new Scanner(importZip.getInputStream(entry)).useDelimiter("\\A"); - String entryText = s.hasNext() ? s.next() : ""; - - writer.add( - entry.getName(), - traceMetadata, - new StringHandle(entryText) - .withFormat(entry.getName().endsWith(".json") ? Format.JSON : Format.XML) - ); - } - writer.flushAndWait(); - dmm.stopJob(ticket); - dmm.release(); - } - } - - public class JobDeleteResource extends ResourceManager { - private static final String DELETE_SERVICE = "ml:deleteJobs"; - - private DatabaseClient srcClient; - - public JobDeleteResource(DatabaseClient srcClient) { - super(); - this.srcClient = srcClient; - this.srcClient.init(DELETE_SERVICE, this); - } - - /** - * - * @param jobIds comma-separated list of jobIds to delete. - * @return comma-separated list of jobIds that were successfully deleted - */ - public JobDeleteResponse deleteJobs(String jobIds) { - JobDeleteResponse resp = null; - try { - RequestParameters params = new RequestParameters(); - params.add("jobIds", jobIds); - - ResourceServices services = this.getServices(); - ResourceServices.ServiceResultIterator resultItr = - services.post(params, new StringHandle("{}").withFormat(Format.JSON)); - if (resultItr == null || ! resultItr.hasNext()) { - resp = new JobDeleteResponse(); - } - else { - ResourceServices.ServiceResult res = resultItr.next(); - StringHandle handle = new StringHandle(); - ObjectMapper objectMapper = new ObjectMapper(); - resp = objectMapper.readValue(res.getContent(handle).get(), JobDeleteResponse.class); - } - } catch (IOException e) { - e.printStackTrace(); - throw new RuntimeException(e); - } - return resp; - } - } - + void importJobs(Path importFilePath) throws IOException; } diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/job/impl/JobManagerImpl.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/job/impl/JobManagerImpl.java new file mode 100644 index 0000000000..4503001054 --- /dev/null +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/job/impl/JobManagerImpl.java @@ -0,0 +1,291 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.marklogic.hub.job.impl; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.marklogic.client.DatabaseClient; +import com.marklogic.client.Transaction; +import com.marklogic.client.datamovement.*; +import com.marklogic.client.document.DocumentWriteSet; +import com.marklogic.client.document.JSONDocumentManager; +import com.marklogic.client.ext.datamovement.consumer.WriteToZipConsumer; +import com.marklogic.client.extensions.ResourceManager; +import com.marklogic.client.extensions.ResourceServices; +import com.marklogic.client.io.DocumentMetadataHandle; +import com.marklogic.client.io.Format; +import com.marklogic.client.io.JacksonDatabindHandle; +import com.marklogic.client.io.StringHandle; +import com.marklogic.client.query.*; +import com.marklogic.client.util.RequestParameters; +import com.marklogic.hub.job.Job; +import com.marklogic.hub.job.JobDeleteResponse; +import com.marklogic.hub.job.JobExportResponse; +import com.marklogic.hub.job.JobManager; + +import javax.xml.namespace.QName; +import java.io.File; +import java.io.IOException; +import java.nio.file.Path; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.Scanner; +import java.util.TimeZone; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +public class JobManagerImpl implements JobManager { + + private DatabaseClient traceClient; + private DatabaseClient jobClient; + private JSONDocumentManager docMgr; + private JobDeleteResource jobDeleteRunner = null; + + private static final String ISO_8601_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX"; + private static SimpleDateFormat simpleDateFormat8601; + static { + try { + simpleDateFormat8601 = new SimpleDateFormat(ISO_8601_FORMAT); + // Java 1.6 doesn't yet know about X (ISO 8601 format) + } catch (IllegalArgumentException e) { + if ( "Illegal pattern character 'X'".equals(e.getMessage()) ) { + simpleDateFormat8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); + } + } + } + static { simpleDateFormat8601.setTimeZone(TimeZone.getTimeZone("UTC")); } + private ObjectMapper objectMapper = new ObjectMapper() + // if we don't do the next two lines Jackson will automatically close our streams which is undesirable + .configure(JsonGenerator.Feature.AUTO_CLOSE_TARGET, false) + .configure(JsonParser.Feature.AUTO_CLOSE_SOURCE, false) + // we do the next two so dates are written in xs:dateTime format + // which makes them ready for range indexes in MarkLogic Server + .configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false) + .setDateFormat(simpleDateFormat8601); + + public JobManagerImpl(DatabaseClient jobClient, DatabaseClient traceClient) { + this.jobClient = jobClient; + this.traceClient = traceClient; + this.docMgr = jobClient.newJSONDocumentManager(); + this.jobDeleteRunner = new JobDeleteResource(jobClient); + } + + @Override public void saveJob(Job job) { + saveJob(job, null); + } + + @Override public void saveJob(Job job, Transaction transaction) { + JacksonDatabindHandle contentHandle = new JacksonDatabindHandle<>(job); + contentHandle.setMapper(objectMapper); + DocumentMetadataHandle metadataHandle = new DocumentMetadataHandle(); + metadataHandle = metadataHandle.withCollections("job"); + DocumentWriteSet writeSet = docMgr.newWriteSet(); + writeSet.add("/jobs/" + job.getJobId() + ".json", metadataHandle, contentHandle); + docMgr.write(writeSet, transaction); + } + + @Override public JobDeleteResponse deleteJobs(String jobIds) { + return this.jobDeleteRunner.deleteJobs(jobIds); + } + + /** + * Export Job documents and their associated Trace documents to a zip file. + * + * @param exportFilePath specifies where the zip file will be written + * @param jobIds a comma-separated list of jobIds; if null, all will be exported + */ + @Override public JobExportResponse exportJobs(Path exportFilePath, String[] jobIds) { + JobExportResponse response = new JobExportResponse(); + response.fullPath = exportFilePath.toAbsolutePath().toString(); + + File zipFile = exportFilePath.toFile(); + WriteToZipConsumer zipConsumer = new WriteToZipConsumer(zipFile); + + QueryManager qm = jobClient.newQueryManager(); + + // Build a query that will match everything + StringQueryDefinition emptyQuery = qm.newStringDefinition(); + emptyQuery.setCriteria(""); + + // Get the job(s) document(s) + StructuredQueryBuilder sqb = qm.newStructuredQueryBuilder(); + DataMovementManager dmm = jobClient.newDataMovementManager(); + QueryBatcher batcher = null; + StructuredQueryDefinition query = null; + if (jobIds == null) { + batcher = dmm.newQueryBatcher(emptyQuery); + } + else { + batcher = dmm.newQueryBatcher(sqb.value(sqb.jsonProperty("jobId"), jobIds)); + } + batcher.onUrisReady(new ExportListener().onDocumentReady(zipConsumer)); + JobTicket jobTicket = dmm.startJob(batcher); + + batcher.awaitCompletion(); + dmm.stopJob(batcher); + dmm.release(); + + JobReport report = dmm.getJobReport(jobTicket); + long jobCount = report.getSuccessEventsCount(); + response.totalJobs = jobCount; + + if (jobCount > 0) { + + // Get the traces that go with the job(s) + dmm = this.traceClient.newDataMovementManager(); + if (jobIds == null) { + batcher = dmm.newQueryBatcher(emptyQuery); + } + else { + batcher = dmm.newQueryBatcher(sqb.value(sqb.element(new QName("jobId")), jobIds)); + } + batcher.onUrisReady(new ExportListener().onDocumentReady(zipConsumer)); + jobTicket = dmm.startJob(batcher); + + batcher.awaitCompletion(); + dmm.stopJob(batcher); + dmm.release(); + + report = dmm.getJobReport(jobTicket); + long traceCount = report.getSuccessEventsCount(); + response.totalTraces = traceCount; + + zipConsumer.close(); + } + else { + // there were no jobs, so don't produce an empty zip file + zipConsumer.close(); + zipFile.delete(); + } + + return response; + } + + /** + * Import Job documents and their associated Trace documents from a zip file. + * + * @param importFilePath specifies where the zip file exists + */ + @Override public void importJobs(Path importFilePath) throws IOException { + ZipFile importZip = new ZipFile(importFilePath.toFile()); + Enumeration entries = importZip.entries(); + + DataMovementManager dmm = jobClient.newDataMovementManager(); + WriteBatcher writer = dmm + .newWriteBatcher() + .withJobName("Load jobs") + .withBatchSize(50); + JobTicket ticket = dmm.startJob(writer); + + // Add each Job entry to the writer; set aside the Trace entries. + ArrayList traceEntries = new ArrayList(); + DocumentMetadataHandle jobMetadata = new DocumentMetadataHandle().withCollections("job"); + while (entries.hasMoreElements()) { + ZipEntry entry = entries.nextElement(); + + if (entry.getName().startsWith("/jobs/")) { + // Delimiter = \A, which is the beginning of the input + Scanner s = new Scanner(importZip.getInputStream(entry)).useDelimiter("\\A"); + String entryText = s.hasNext() ? s.next() : ""; + + writer.add( + entry.getName(), + jobMetadata, + new StringHandle(entryText).withFormat(Format.JSON) + ); + } + else { + traceEntries.add(entry); + } + } + + writer.flushAndWait(); + dmm.stopJob(ticket); + dmm.release(); + + if (traceEntries.size() > 0) { + dmm = this.traceClient.newDataMovementManager(); + writer = dmm + .newWriteBatcher() + .withJobName("Load traces"); + ticket = dmm.startJob(writer); + + DocumentMetadataHandle traceMetadata = new DocumentMetadataHandle().withCollections("trace"); + + for (ZipEntry entry: traceEntries) { + // Delimiter = \A, which is the beginning of the input + Scanner s = new Scanner(importZip.getInputStream(entry)).useDelimiter("\\A"); + String entryText = s.hasNext() ? s.next() : ""; + + writer.add( + entry.getName(), + traceMetadata, + new StringHandle(entryText) + .withFormat(entry.getName().endsWith(".json") ? Format.JSON : Format.XML) + ); + } + writer.flushAndWait(); + dmm.stopJob(ticket); + dmm.release(); + } + } + + public class JobDeleteResource extends ResourceManager { + private static final String DELETE_SERVICE = "ml:deleteJobs"; + + private DatabaseClient srcClient; + + public JobDeleteResource(DatabaseClient srcClient) { + super(); + this.srcClient = srcClient; + this.srcClient.init(DELETE_SERVICE, this); + } + + /** + * + * @param jobIds comma-separated list of jobIds to delete. + * @return comma-separated list of jobIds that were successfully deleted + */ + public JobDeleteResponse deleteJobs(String jobIds) { + JobDeleteResponse resp = null; + try { + RequestParameters params = new RequestParameters(); + params.add("jobIds", jobIds); + + ResourceServices services = this.getServices(); + ResourceServices.ServiceResultIterator resultItr = + services.post(params, new StringHandle("{}").withFormat(Format.JSON)); + if (resultItr == null || ! resultItr.hasNext()) { + resp = new JobDeleteResponse(); + } + else { + ResourceServices.ServiceResult res = resultItr.next(); + StringHandle handle = new StringHandle(); + ObjectMapper objectMapper = new ObjectMapper(); + resp = objectMapper.readValue(res.getContent(handle).get(), JobDeleteResponse.class); + } + } catch (IOException e) { + e.printStackTrace(); + throw new RuntimeException(e); + } + return resp; + } + } + +} diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/util/MlcpRunner.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/util/MlcpRunner.java index 1a042cc87d..a2fe596ea0 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/util/MlcpRunner.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/util/MlcpRunner.java @@ -50,7 +50,7 @@ public MlcpRunner(String mlcpPath, String mainClass, HubConfig hubConfig, Flow f this.withHubconfig(hubConfig); - this.jobManager = new JobManager(hubConfig.newJobDbClient(), hubConfig.newTraceDbClient()); + this.jobManager = JobManager.create(hubConfig.newJobDbClient(), hubConfig.newTraceDbClient()); this.flowStatusListener = statusListener; this.flow = flow; this.mlcpOptions = mlcpOptions; diff --git a/marklogic-data-hub/src/test/java/com/marklogic/hub/job/JobManagerTest.java b/marklogic-data-hub/src/test/java/com/marklogic/hub/job/JobManagerTest.java index a8feccf968..b98c9b0db0 100644 --- a/marklogic-data-hub/src/test/java/com/marklogic/hub/job/JobManagerTest.java +++ b/marklogic-data-hub/src/test/java/com/marklogic/hub/job/JobManagerTest.java @@ -20,7 +20,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.StringJoiner; import java.util.zip.ZipFile; import static org.junit.jupiter.api.Assertions.*; @@ -118,7 +117,7 @@ private static synchronized void recordJobId(String jobId) { public void deleteOneJob() { assertEquals(4, getJobDocCount()); assertEquals(8, getTracingDocCount()); - JobManager manager = new JobManager(jobClient, traceClient); + JobManager manager = JobManager.create(jobClient, traceClient); String jobs = jobIds.get(1); JobDeleteResponse actual = manager.deleteJobs(jobs); @@ -142,7 +141,7 @@ public void deleteMultipleJobs() { assertEquals(4, getJobDocCount()); assertEquals(8, getTracingDocCount()); String jobs = jobIds.get(0) + "," + jobIds.get(2); - JobManager manager = new JobManager(jobClient, traceClient); + JobManager manager = JobManager.create(jobClient, traceClient); JobDeleteResponse actual = manager.deleteJobs(jobs); @@ -162,7 +161,7 @@ public void deleteMultipleJobs() { @Test public void deleteInvalidJob() { - JobManager manager = new JobManager(jobClient, traceClient); + JobManager manager = JobManager.create(jobClient, traceClient); JobDeleteResponse actual = manager.deleteJobs("InvalidId"); @@ -174,7 +173,7 @@ public void deleteInvalidJob() { @Test public void deleteEmptyStringJob() { - JobManager manager = new JobManager(jobClient, traceClient); + JobManager manager = JobManager.create(jobClient, traceClient); JobDeleteResponse actual = manager.deleteJobs(""); @@ -186,7 +185,7 @@ public void deleteEmptyStringJob() { @Test public void deleteNullJob() { - JobManager manager = new JobManager(jobClient, traceClient); + JobManager manager = JobManager.create(jobClient, traceClient); JobDeleteResponse actual = manager.deleteJobs(null); @@ -200,7 +199,7 @@ public void deleteNullJob() { public void exportOneJob() throws IOException { final String EXPORT_FILENAME = "testExport.zip"; Path exportPath = projectDir.resolve(EXPORT_FILENAME); - JobManager manager = new JobManager(jobClient, traceClient); + JobManager manager = JobManager.create(jobClient, traceClient); File zipFile = exportPath.toFile(); assertFalse(zipFile.exists()); @@ -223,7 +222,7 @@ public void exportOneJob() throws IOException { public void exportMultipleJobs() throws IOException { final String EXPORT_FILENAME = "testExport.zip"; Path exportPath = projectDir.resolve(EXPORT_FILENAME); - JobManager manager = new JobManager(jobClient, traceClient); + JobManager manager = JobManager.create(jobClient, traceClient); File zipFile = exportPath.toFile(); assertFalse(zipFile.exists()); @@ -246,7 +245,7 @@ public void exportMultipleJobs() throws IOException { public void exportAllJobs() throws IOException { final String EXPORT_FILENAME = "testExport.zip"; Path exportPath = projectDir.resolve(EXPORT_FILENAME); - JobManager manager = new JobManager(jobClient, traceClient); + JobManager manager = JobManager.create(jobClient, traceClient); File zipFile = exportPath.toFile(); assertFalse(zipFile.exists()); @@ -272,7 +271,7 @@ public void exportNoJobs() throws IOException { // if the jobs database is empty, do not produce a zip file. final String EXPORT_FILENAME = "testExport.zip"; Path exportPath = projectDir.resolve(EXPORT_FILENAME); - JobManager manager = new JobManager(jobClient, traceClient); + JobManager manager = JobManager.create(jobClient, traceClient); File zipFile = exportPath.toFile(); assertFalse(zipFile.exists()); @@ -291,7 +290,7 @@ public void importJobs() throws URISyntaxException, IOException { assertEquals(0, getJobDocCount()); assertEquals(0, getTracingDocCount()); - JobManager manager = new JobManager(jobClient, traceClient); + JobManager manager = JobManager.create(jobClient, traceClient); manager.importJobs(Paths.get(url.toURI())); assertEquals(4, getJobDocCount()); diff --git a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/HubTask.groovy b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/HubTask.groovy index 347be66fa0..022a05aed2 100644 --- a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/HubTask.groovy +++ b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/HubTask.groovy @@ -5,7 +5,7 @@ import com.fasterxml.jackson.databind.ObjectMapper import com.marklogic.appdeployer.command.CommandContext import com.marklogic.client.DatabaseClient import com.marklogic.hub.* -import com.marklogic.hub.job.JobManager +import com.marklogic.hub.job.JobManager; import org.gradle.api.DefaultTask import org.gradle.api.tasks.Internal @@ -38,7 +38,7 @@ abstract class HubTask extends DefaultTask { @Internal JobManager getJobManager() { - return new JobManager(getHubConfig().newJobDbClient(), getHubConfig().newTraceDbClient()); + return JobManager.create(getHubConfig().newJobDbClient(), getHubConfig().newTraceDbClient()); } @Internal diff --git a/quick-start/src/main/java/com/marklogic/quickstart/service/JobService.java b/quick-start/src/main/java/com/marklogic/quickstart/service/JobService.java index f6022a817f..aa11f9f6bd 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/service/JobService.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/service/JobService.java @@ -45,7 +45,7 @@ public class JobService extends SearchableService { public JobService(DatabaseClient jobClient, DatabaseClient traceClient) { this.queryMgr = jobClient.newQueryManager(); - this.jobMgr = new JobManager(jobClient, traceClient); + this.jobMgr = JobManager.create(jobClient, traceClient); } public StringHandle getJobs(JobQuery jobQuery) { From 6d94a5129eb6b733f2fea653a5bae26df5cca38f Mon Sep 17 00:00:00 2001 From: Alexander Ebadirad Date: Wed, 14 Feb 2018 23:16:01 -0700 Subject: [PATCH 05/22] FlowManager interface refactor --- .../com/marklogic/hub/DataHubUpgrader.java | 2 +- .../java/com/marklogic/hub/FlowManager.java | 290 ++--------------- .../commands/LoadUserModulesCommand.java | 2 +- .../marklogic/hub/impl/FlowManagerImpl.java | 300 ++++++++++++++++++ .../com/marklogic/hub/EndToEndFlowTests.java | 2 +- .../com/marklogic/hub/FlowManagerTest.java | 18 +- .../java/com/marklogic/hub/TracingTest.java | 16 +- .../hub/collector/EmptyCollectorTest.java | 2 +- .../hub/collector/StreamCollectorTest.java | 2 +- .../marklogic/hub/flow/FlowRunnerTest.java | 2 +- .../com/marklogic/hub/job/JobManagerTest.java | 2 +- .../com/marklogic/gradle/task/HubTask.groovy | 2 +- .../service/FlowManagerService.java | 2 +- .../service/FlowManagerServiceTest.java | 6 +- 14 files changed, 354 insertions(+), 294 deletions(-) create mode 100644 marklogic-data-hub/src/main/java/com/marklogic/hub/impl/FlowManagerImpl.java diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/DataHubUpgrader.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/DataHubUpgrader.java index 2ab6db40e1..8e15046082 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/DataHubUpgrader.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/DataHubUpgrader.java @@ -69,7 +69,7 @@ public boolean upgradeHub(List updatedFlows) throws CantUpgradeException } // update legacy flows to include main.(sjs|xqy) - List flows = new FlowManager(hubConfig).updateLegacyFlows(currentVersion); + List flows = FlowManager.create(hubConfig).updateLegacyFlows(currentVersion); if (updatedFlows != null) { updatedFlows.addAll(flows); } diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/FlowManager.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/FlowManager.java index 3f3ec5297a..af0e1b8133 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/FlowManager.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/FlowManager.java @@ -1,179 +1,41 @@ -/* - * Copyright 2012-2018 MarkLogic Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ package com.marklogic.hub; -import com.marklogic.client.DatabaseClient; -import com.marklogic.client.datamovement.DataMovementManager; -import com.marklogic.client.extensions.ResourceManager; -import com.marklogic.client.extensions.ResourceServices.ServiceResult; -import com.marklogic.client.extensions.ResourceServices.ServiceResultIterator; -import com.marklogic.client.io.DOMHandle; -import com.marklogic.client.util.RequestParameters; -import com.marklogic.hub.collector.impl.CollectorImpl; -import com.marklogic.hub.flow.*; +import com.marklogic.hub.flow.Flow; +import com.marklogic.hub.flow.FlowRunner; +import com.marklogic.hub.flow.FlowType; import com.marklogic.hub.flow.impl.FlowImpl; -import com.marklogic.hub.flow.impl.FlowRunnerImpl; -import com.marklogic.hub.job.JobManager; -import com.marklogic.hub.main.impl.MainPluginImpl; -import com.marklogic.hub.scaffold.Scaffolding; -import org.w3c.dom.Document; +import com.marklogic.hub.impl.FlowManagerImpl; import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import java.io.File; -import java.io.FileInputStream; import java.nio.file.Path; -import java.util.ArrayList; import java.util.List; -import java.util.Properties; -import java.util.regex.Pattern; -public class FlowManager extends ResourceManager { - private static final String HUB_NS = "http://marklogic.com/data-hub"; - private static final String NAME = "ml:flow"; +public interface FlowManager { - private DatabaseClient stagingClient; - private DatabaseClient finalClient; - private DatabaseClient jobClient; - private HubConfig hubConfig; - private JobManager jobManager; - - private DataMovementManager dataMovementManager; - - public FlowManager(HubConfig hubConfig) { - super(); - this.hubConfig = hubConfig; - this.stagingClient = hubConfig.newStagingClient(); - this.finalClient = hubConfig.newFinalClient(); - this.jobClient = hubConfig.newJobDbClient(); - this.jobManager = JobManager.create(this.jobClient, this.hubConfig.newTraceDbClient()); - this.dataMovementManager = this.stagingClient.newDataMovementManager(); - this.stagingClient.init(NAME, this); + static FlowManager create(HubConfig hubConfig){ + return new FlowManagerImpl(hubConfig); } + /** + * Turns an XML document into a flow + * @param doc - the xml document representing a flow + * @return a Flow instance + */ + static Flow flowFromXml(Element doc) { + return FlowImpl.fromXml(doc); + } /** * retrieves a list of all the flows on the local files systems * @return a list of Flows */ - public List getLocalFlows() { - List flows = new ArrayList<>(); - - Path entitiesDir = hubConfig.getHubEntitiesDir(); - File[] entities = entitiesDir.toFile().listFiles((pathname -> pathname.isDirectory())); - if (entities != null) { - for (File entity : entities) { - String entityName = entity.getName(); - flows.addAll(getLocalFlowsForEntity(entityName)); - } - } - return flows; - } - - public List getLocalFlowsForEntity(String entityName) { - return getLocalFlowsForEntity(entityName, null); - } - - public List getLocalFlowsForEntity(String entityName, FlowType flowType) { - - List flows = new ArrayList<>(); - Path entitiesDir = hubConfig.getHubEntitiesDir(); - Path entityDir = entitiesDir.resolve(entityName); - Path inputDir = entityDir.resolve("input"); - Path harmonizeDir = entityDir.resolve("harmonize"); - boolean getInputFlows = false; - boolean getHarmonizeFlows = false; - if (flowType == null) { - getInputFlows = getHarmonizeFlows = true; - } - else if (flowType.equals(FlowType.INPUT)) { - getInputFlows = true; - } - else if (flowType.equals(FlowType.HARMONIZE)) { - getHarmonizeFlows = true; - } - - if (getInputFlows) { - File[] inputFlows = inputDir.toFile().listFiles((pathname) -> pathname.isDirectory() && !pathname.getName().equals("REST")); - if (inputFlows != null) { - for (File inputFlow : inputFlows) { - Flow flow = getLocalFlow(entityName, inputFlow.toPath(), FlowType.INPUT); - if (flow != null) { - flows.add(flow); - } - } - } - } - - if (getHarmonizeFlows) { - File[] harmonizeFlows = harmonizeDir.toFile().listFiles((pathname) -> pathname.isDirectory() && !pathname.getName().equals("REST")); - if (harmonizeFlows != null) { - for (File harmonizeFlow : harmonizeFlows) { - Flow flow = getLocalFlow(entityName, harmonizeFlow.toPath(), FlowType.HARMONIZE); - if (flow != null) { - flows.add(flow); - } - - } - } - } - return flows; - } - - public Flow getFlowFromProperties(Path propertiesFile) { - String quotedSeparator = Pattern.quote(File.separator); - String flowTypeRegex = ".+" + quotedSeparator + "(input|harmonize)" + quotedSeparator + ".+"; - FlowType flowType = propertiesFile.toString().replaceAll(flowTypeRegex, "$1").equals("input") - ? FlowType.INPUT : FlowType.HARMONIZE; - - String entityName = propertiesFile.toString().replaceAll(".+" + quotedSeparator + "([^/\\\\]+)" + quotedSeparator + "(input|harmonize)" + quotedSeparator + ".+", "$1"); - return getLocalFlow(entityName, propertiesFile.getParent(), flowType); - } - - private Flow getLocalFlow(String entityName, Path flowDir, FlowType flowType) { - try { - String flowName = flowDir.getFileName().toString(); - File propertiesFile = flowDir.resolve(flowName + ".properties").toFile(); - if (propertiesFile.exists()) { - Properties properties = new Properties(); - FileInputStream fis = new FileInputStream(propertiesFile); - properties.load(fis); - fis.close(); + List getLocalFlows(); - FlowBuilder flowBuilder = FlowBuilder.newFlow() - .withEntityName(entityName) - .withName(flowName) - .withType(flowType) - .withCodeFormat(CodeFormat.getCodeFormat((String) properties.get("codeFormat"))) - .withDataFormat(DataFormat.getDataFormat((String) properties.get("dataFormat"))) - .withMain(new MainPluginImpl((String) properties.get("mainModule"), CodeFormat.getCodeFormat((String) properties.get("mainCodeFormat")))); + List getLocalFlowsForEntity(String entityName); - if (flowType.equals(FlowType.HARMONIZE)) { - flowBuilder.withCollector(new CollectorImpl((String) properties.get("collectorModule"), CodeFormat.getCodeFormat((String) properties.get("collectorCodeFormat")))); - } + List getLocalFlowsForEntity(String entityName, FlowType flowType); - return flowBuilder.build(); - } - } - catch(Exception e) { - e.printStackTrace(); - } - return null; - } + Flow getFlowFromProperties(Path propertiesFile); /** * Retrieves a list of flows installed on the MarkLogic server @@ -182,32 +44,7 @@ private Flow getLocalFlow(String entityName, Path flowDir, FlowType flowType) { * - the entity from which to fetch the flows * @return - a list of flows for the given entity */ - public List getFlows(String entityName) { - RequestParameters params = new RequestParameters(); - params.add("entity-name", entityName); - ServiceResultIterator resultItr = this.getServices().get(params); - if (resultItr == null || ! resultItr.hasNext()) { - return null; - } - ServiceResult res = resultItr.next(); - DOMHandle handle = new DOMHandle(); - Document parent = res.getContent(handle).get(); - NodeList children = parent.getDocumentElement().getChildNodes(); - - ArrayList flows = null; - if (children.getLength() > 0) { - flows = new ArrayList<>(); - } - - Node node; - for (int i = 0; i < children.getLength(); i++) { - node = children.item(i); - if (node.getNodeType() == Node.ELEMENT_NODE) { - flows.add(flowFromXml((Element)children.item(i))); - } - } - return flows; - } + List getFlows(String entityName); /** * Retrieves a named flow from a given entity @@ -218,90 +55,13 @@ public List getFlows(String entityName) { * - the name of the flow to get * @return the flow */ - public Flow getFlow(String entityName, String flowName) { - return getFlow(entityName, flowName, null); - } - - public Flow getFlow(String entityName, String flowName, FlowType flowType) { - RequestParameters params = new RequestParameters(); - params.add("entity-name", entityName); - params.add("flow-name", flowName); - if (flowType != null) { - params.add("flow-type", flowType.toString()); - } - ServiceResultIterator resultItr = this.getServices().get(params); - if (resultItr == null || ! resultItr.hasNext()) { - return null; - } - ServiceResult res = resultItr.next(); - DOMHandle handle = new DOMHandle(); - Document parent = res.getContent(handle).get(); - return flowFromXml(parent.getDocumentElement()); - } - - public List getLegacyFlows() { - List oldFlows = new ArrayList<>(); - Path entitiesDir = hubConfig.getHubEntitiesDir(); - - File[] entityDirs = entitiesDir.toFile().listFiles(pathname -> pathname.isDirectory()); - if (entityDirs != null) { - for (File entityDir : entityDirs) { - Path inputDir = entityDir.toPath().resolve("input"); - Path harmonizeDir = entityDir.toPath().resolve("harmonize"); - - - File[] inputFlows = inputDir.toFile().listFiles((pathname) -> pathname.isDirectory() && !pathname.getName().equals("REST")); - if (inputFlows != null) { - for (File inputFlow : inputFlows) { - File[] mainFiles = inputFlow.listFiles((dir, name) -> name.matches("main\\.(sjs|xqy)")); - File[] flowFiles = inputFlow.listFiles((dir, name) -> name.matches(inputFlow.getName() + "\\.xml")); - if (mainFiles.length < 1 && flowFiles.length == 1) { - oldFlows.add(entityDir.getName() + " => " + inputFlow.getName()); - } - } - } - - File[] harmonizeFlows = harmonizeDir.toFile().listFiles((pathname) -> pathname.isDirectory() && !pathname.getName().equals("REST")); - if (harmonizeFlows != null) { - for (File harmonizeFlow : harmonizeFlows) { - File[] mainFiles = harmonizeFlow.listFiles((dir, name) -> name.matches("main\\.(sjs|xqy)")); - File[] flowFiles = harmonizeFlow.listFiles((dir, name) -> name.matches(harmonizeFlow.getName() + "\\.xml")); - if (mainFiles.length < 1 && flowFiles.length == 1) { - oldFlows.add(entityDir.getName() + " => " + harmonizeFlow.getName()); - } - } - } - } - } - - return oldFlows; - } - - public List updateLegacyFlows(String fromVersion) { - - Scaffolding scaffolding = Scaffolding.create(hubConfig.getProjectDir(), hubConfig.newFinalClient()); + Flow getFlow(String entityName, String flowName); - List updatedFlows = new ArrayList<>(); - File[] entityDirs = hubConfig.getHubEntitiesDir().toFile().listFiles(pathname -> pathname.isDirectory()); - if (entityDirs != null) { - for (File entityDir : entityDirs) { - updatedFlows.addAll(scaffolding.updateLegacyFlows(fromVersion, entityDir.getName())); - } - } + Flow getFlow(String entityName, String flowName, FlowType flowType); - return updatedFlows; - } + List getLegacyFlows(); - public FlowRunner newFlowRunner() { - return new FlowRunnerImpl(hubConfig); - } + List updateLegacyFlows(String fromVersion); - /** - * Turns an XML document into a flow - * @param doc - the xml document representing a flow - * @return a Flow instance - */ - public static Flow flowFromXml(Element doc) { - return FlowImpl.fromXml(doc); - } + FlowRunner newFlowRunner(); } diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/deploy/commands/LoadUserModulesCommand.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/deploy/commands/LoadUserModulesCommand.java index 0e92227aae..412f1f95b2 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/deploy/commands/LoadUserModulesCommand.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/deploy/commands/LoadUserModulesCommand.java @@ -133,7 +133,7 @@ boolean isFlowPropertiesFile(Path dir) { @Override public void execute(CommandContext context) { - FlowManager flowManager = new FlowManager(hubConfig); + FlowManager flowManager = FlowManager.create(hubConfig); List legacyFlows = flowManager.getLegacyFlows(); if (legacyFlows.size() > 0) { throw new LegacyFlowsException(legacyFlows); diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/FlowManagerImpl.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/FlowManagerImpl.java new file mode 100644 index 0000000000..c64a8af63b --- /dev/null +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/FlowManagerImpl.java @@ -0,0 +1,300 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.marklogic.hub.impl; + +import com.marklogic.client.DatabaseClient; +import com.marklogic.client.datamovement.DataMovementManager; +import com.marklogic.client.extensions.ResourceManager; +import com.marklogic.client.extensions.ResourceServices.ServiceResult; +import com.marklogic.client.extensions.ResourceServices.ServiceResultIterator; +import com.marklogic.client.io.DOMHandle; +import com.marklogic.client.util.RequestParameters; +import com.marklogic.hub.FlowManager; +import com.marklogic.hub.HubConfig; +import com.marklogic.hub.collector.impl.CollectorImpl; +import com.marklogic.hub.flow.*; +import com.marklogic.hub.flow.impl.FlowRunnerImpl; +import com.marklogic.hub.job.JobManager; +import com.marklogic.hub.main.impl.MainPluginImpl; +import com.marklogic.hub.scaffold.Scaffolding; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import java.io.File; +import java.io.FileInputStream; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; +import java.util.regex.Pattern; + +public class FlowManagerImpl extends ResourceManager implements FlowManager { + private static final String HUB_NS = "http://marklogic.com/data-hub"; + private static final String NAME = "ml:flow"; + + private DatabaseClient stagingClient; + private DatabaseClient finalClient; + private DatabaseClient jobClient; + private HubConfig hubConfig; + private JobManager jobManager; + + private DataMovementManager dataMovementManager; + + public FlowManagerImpl(HubConfig hubConfig) { + super(); + this.hubConfig = hubConfig; + this.stagingClient = hubConfig.newStagingClient(); + this.finalClient = hubConfig.newFinalClient(); + this.jobClient = hubConfig.newJobDbClient(); + this.jobManager = JobManager.create(this.jobClient, this.hubConfig.newTraceDbClient()); + this.dataMovementManager = this.stagingClient.newDataMovementManager(); + this.stagingClient.init(NAME, this); + } + + + /** + * retrieves a list of all the flows on the local files systems + * @return a list of Flows + */ + @Override public List getLocalFlows() { + List flows = new ArrayList<>(); + + Path entitiesDir = hubConfig.getHubEntitiesDir(); + File[] entities = entitiesDir.toFile().listFiles((pathname -> pathname.isDirectory())); + if (entities != null) { + for (File entity : entities) { + String entityName = entity.getName(); + flows.addAll(getLocalFlowsForEntity(entityName)); + } + } + return flows; + } + + @Override public List getLocalFlowsForEntity(String entityName) { + return getLocalFlowsForEntity(entityName, null); + } + + @Override public List getLocalFlowsForEntity(String entityName, FlowType flowType) { + + List flows = new ArrayList<>(); + Path entitiesDir = hubConfig.getHubEntitiesDir(); + Path entityDir = entitiesDir.resolve(entityName); + Path inputDir = entityDir.resolve("input"); + Path harmonizeDir = entityDir.resolve("harmonize"); + boolean getInputFlows = false; + boolean getHarmonizeFlows = false; + if (flowType == null) { + getInputFlows = getHarmonizeFlows = true; + } + else if (flowType.equals(FlowType.INPUT)) { + getInputFlows = true; + } + else if (flowType.equals(FlowType.HARMONIZE)) { + getHarmonizeFlows = true; + } + + if (getInputFlows) { + File[] inputFlows = inputDir.toFile().listFiles((pathname) -> pathname.isDirectory() && !pathname.getName().equals("REST")); + if (inputFlows != null) { + for (File inputFlow : inputFlows) { + Flow flow = getLocalFlow(entityName, inputFlow.toPath(), FlowType.INPUT); + if (flow != null) { + flows.add(flow); + } + } + } + } + + if (getHarmonizeFlows) { + File[] harmonizeFlows = harmonizeDir.toFile().listFiles((pathname) -> pathname.isDirectory() && !pathname.getName().equals("REST")); + if (harmonizeFlows != null) { + for (File harmonizeFlow : harmonizeFlows) { + Flow flow = getLocalFlow(entityName, harmonizeFlow.toPath(), FlowType.HARMONIZE); + if (flow != null) { + flows.add(flow); + } + + } + } + } + return flows; + } + + @Override public Flow getFlowFromProperties(Path propertiesFile) { + String quotedSeparator = Pattern.quote(File.separator); + String flowTypeRegex = ".+" + quotedSeparator + "(input|harmonize)" + quotedSeparator + ".+"; + FlowType flowType = propertiesFile.toString().replaceAll(flowTypeRegex, "$1").equals("input") + ? FlowType.INPUT : FlowType.HARMONIZE; + + String entityName = propertiesFile.toString().replaceAll(".+" + quotedSeparator + "([^/\\\\]+)" + quotedSeparator + "(input|harmonize)" + quotedSeparator + ".+", "$1"); + return getLocalFlow(entityName, propertiesFile.getParent(), flowType); + } + + private Flow getLocalFlow(String entityName, Path flowDir, FlowType flowType) { + try { + String flowName = flowDir.getFileName().toString(); + File propertiesFile = flowDir.resolve(flowName + ".properties").toFile(); + if (propertiesFile.exists()) { + Properties properties = new Properties(); + FileInputStream fis = new FileInputStream(propertiesFile); + properties.load(fis); + fis.close(); + + FlowBuilder flowBuilder = FlowBuilder.newFlow() + .withEntityName(entityName) + .withName(flowName) + .withType(flowType) + .withCodeFormat(CodeFormat.getCodeFormat((String) properties.get("codeFormat"))) + .withDataFormat(DataFormat.getDataFormat((String) properties.get("dataFormat"))) + .withMain(new MainPluginImpl((String) properties.get("mainModule"), CodeFormat.getCodeFormat((String) properties.get("mainCodeFormat")))); + + if (flowType.equals(FlowType.HARMONIZE)) { + flowBuilder.withCollector(new CollectorImpl((String) properties.get("collectorModule"), CodeFormat.getCodeFormat((String) properties.get("collectorCodeFormat")))); + } + + return flowBuilder.build(); + } + } + catch(Exception e) { + e.printStackTrace(); + } + return null; + } + + /** + * Retrieves a list of flows installed on the MarkLogic server + * + * @param entityName + * - the entity from which to fetch the flows + * @return - a list of flows for the given entity + */ + @Override public List getFlows(String entityName) { + RequestParameters params = new RequestParameters(); + params.add("entity-name", entityName); + ServiceResultIterator resultItr = this.getServices().get(params); + if (resultItr == null || ! resultItr.hasNext()) { + return null; + } + ServiceResult res = resultItr.next(); + DOMHandle handle = new DOMHandle(); + Document parent = res.getContent(handle).get(); + NodeList children = parent.getDocumentElement().getChildNodes(); + + ArrayList flows = null; + if (children.getLength() > 0) { + flows = new ArrayList<>(); + } + + Node node; + for (int i = 0; i < children.getLength(); i++) { + node = children.item(i); + if (node.getNodeType() == Node.ELEMENT_NODE) { + flows.add(FlowManager.flowFromXml((Element)children.item(i))); + } + } + return flows; + } + + /** + * Retrieves a named flow from a given entity + * + * @param entityName + * - the entity that the flow belongs to + * @param flowName + * - the name of the flow to get + * @return the flow + */ + @Override public Flow getFlow(String entityName, String flowName) { + return getFlow(entityName, flowName, null); + } + + @Override public Flow getFlow(String entityName, String flowName, FlowType flowType) { + RequestParameters params = new RequestParameters(); + params.add("entity-name", entityName); + params.add("flow-name", flowName); + if (flowType != null) { + params.add("flow-type", flowType.toString()); + } + ServiceResultIterator resultItr = this.getServices().get(params); + if (resultItr == null || ! resultItr.hasNext()) { + return null; + } + ServiceResult res = resultItr.next(); + DOMHandle handle = new DOMHandle(); + Document parent = res.getContent(handle).get(); + return FlowManager.flowFromXml(parent.getDocumentElement()); + } + + @Override public List getLegacyFlows() { + List oldFlows = new ArrayList<>(); + Path entitiesDir = hubConfig.getHubEntitiesDir(); + + File[] entityDirs = entitiesDir.toFile().listFiles(pathname -> pathname.isDirectory()); + if (entityDirs != null) { + for (File entityDir : entityDirs) { + Path inputDir = entityDir.toPath().resolve("input"); + Path harmonizeDir = entityDir.toPath().resolve("harmonize"); + + + File[] inputFlows = inputDir.toFile().listFiles((pathname) -> pathname.isDirectory() && !pathname.getName().equals("REST")); + if (inputFlows != null) { + for (File inputFlow : inputFlows) { + File[] mainFiles = inputFlow.listFiles((dir, name) -> name.matches("main\\.(sjs|xqy)")); + File[] flowFiles = inputFlow.listFiles((dir, name) -> name.matches(inputFlow.getName() + "\\.xml")); + if (mainFiles.length < 1 && flowFiles.length == 1) { + oldFlows.add(entityDir.getName() + " => " + inputFlow.getName()); + } + } + } + + File[] harmonizeFlows = harmonizeDir.toFile().listFiles((pathname) -> pathname.isDirectory() && !pathname.getName().equals("REST")); + if (harmonizeFlows != null) { + for (File harmonizeFlow : harmonizeFlows) { + File[] mainFiles = harmonizeFlow.listFiles((dir, name) -> name.matches("main\\.(sjs|xqy)")); + File[] flowFiles = harmonizeFlow.listFiles((dir, name) -> name.matches(harmonizeFlow.getName() + "\\.xml")); + if (mainFiles.length < 1 && flowFiles.length == 1) { + oldFlows.add(entityDir.getName() + " => " + harmonizeFlow.getName()); + } + } + } + } + } + + return oldFlows; + } + + @Override public List updateLegacyFlows(String fromVersion) { + + Scaffolding scaffolding = Scaffolding.create(hubConfig.getProjectDir(), hubConfig.newFinalClient()); + + List updatedFlows = new ArrayList<>(); + File[] entityDirs = hubConfig.getHubEntitiesDir().toFile().listFiles(pathname -> pathname.isDirectory()); + if (entityDirs != null) { + for (File entityDir : entityDirs) { + updatedFlows.addAll(scaffolding.updateLegacyFlows(fromVersion, entityDir.getName())); + } + } + + return updatedFlows; + } + + @Override public FlowRunner newFlowRunner() { + return new FlowRunnerImpl(hubConfig); + } + + } diff --git a/marklogic-data-hub/src/test/java/com/marklogic/hub/EndToEndFlowTests.java b/marklogic-data-hub/src/test/java/com/marklogic/hub/EndToEndFlowTests.java index 8a83cf4090..3810318051 100644 --- a/marklogic-data-hub/src/test/java/com/marklogic/hub/EndToEndFlowTests.java +++ b/marklogic-data-hub/src/test/java/com/marklogic/hub/EndToEndFlowTests.java @@ -146,7 +146,7 @@ public static void setup() { createLegacyFlow("legacy", codeFormat, dataFormat, flowType, useEs); }); - flowManager = new FlowManager(getHubConfig()); + flowManager = FlowManager.create(getHubConfig()); List legacyFlows = flowManager.getLegacyFlows(); assertEquals(8, legacyFlows.size(), String.join("\n", legacyFlows)); assertEquals(8, flowManager.updateLegacyFlows("2.0.0").size()); // don't change this value diff --git a/marklogic-data-hub/src/test/java/com/marklogic/hub/FlowManagerTest.java b/marklogic-data-hub/src/test/java/com/marklogic/hub/FlowManagerTest.java index 0657c377dd..3b83f76f31 100644 --- a/marklogic-data-hub/src/test/java/com/marklogic/hub/FlowManagerTest.java +++ b/marklogic-data-hub/src/test/java/com/marklogic/hub/FlowManagerTest.java @@ -161,7 +161,7 @@ public void testGetLocalFlows() throws IOException { Scaffolding scaffolding = Scaffolding.create("del-me-dir", stagingClient); scaffolding.createEntity("my-entity"); - FlowManager fm = new FlowManager(getHubConfig("del-me-dir")); + FlowManager fm = FlowManager.create(getHubConfig("del-me-dir")); assertEquals(0, fm.getLocalFlows().size()); CodeFormat[] codeFormats = new CodeFormat[] { CodeFormat.JAVASCRIPT, CodeFormat.XQUERY }; @@ -191,7 +191,7 @@ public void testGetFlowFromProperties() throws IOException { Scaffolding scaffolding = Scaffolding.create("del-me-dir", stagingClient); scaffolding.createEntity("my-entity"); - FlowManager fm = new FlowManager(getHubConfig("del-me-dir")); + FlowManager fm = FlowManager.create(getHubConfig("del-me-dir")); allCombos((codeFormat, dataFormat, flowType, useEs) -> { String flowName = flowType.toString() + "-" + codeFormat.toString() + "-" + dataFormat.toString(); @@ -222,7 +222,7 @@ public void testGetFlows() { installModule("/entities/test/harmonize/my-test-flow1/my-test-flow1.xml", "flow-manager-test/my-test-flow1/my-test-flow1.xml"); installModule("/entities/test/harmonize/my-test-flow2/my-test-flow2.xml", "flow-manager-test/my-test-flow1/my-test-flow2.xml"); - FlowManager fm = new FlowManager(getHubConfig()); + FlowManager fm = FlowManager.create(getHubConfig()); List flows = fm.getFlows("test"); assertEquals(2, flows.size()); @@ -263,7 +263,7 @@ public void testGetFlows() { public void getTestFlow() { installModule("/entities/test/harmonize/my-test-flow1/my-test-flow1.xml", "flow-manager-test/my-test-flow1/my-test-flow1-json.xml"); - FlowManager fm = new FlowManager(getHubConfig()); + FlowManager fm = FlowManager.create(getHubConfig()); Flow flow1 = fm.getFlow("test", "my-test-flow1"); assertEquals("my-test-flow1", flow1.getName()); assertEquals(CodeFormat.JAVASCRIPT, flow1.getCodeFormat()); @@ -286,7 +286,7 @@ public void testRunFlow() throws SAXException, IOException, ParserConfigurationE installModules(); assertEquals(2, getStagingDocCount()); assertEquals(0, getFinalDocCount()); - FlowManager fm = new FlowManager(getHubConfig()); + FlowManager fm = FlowManager.create(getHubConfig()); Flow flow1 = fm.getFlow("test", "my-test-flow1"); FlowRunner flowRunner = fm.newFlowRunner() .withFlow(flow1) @@ -306,7 +306,7 @@ public void testRunFlowWithBackwards() throws SAXException, IOException, ParserC installModules(); assertEquals(0, getStagingDocCount()); assertEquals(2, getFinalDocCount()); - FlowManager fm = new FlowManager(getHubConfig()); + FlowManager fm = FlowManager.create(getHubConfig()); Flow flow1 = fm.getFlow("test", "my-test-flow1"); FlowRunner flowRunner = fm.newFlowRunner() .withFlow(flow1) @@ -337,7 +337,7 @@ public void testRunFlowWithHeader() throws SAXException, IOException, ParserConf assertEquals(2, getStagingDocCount()); assertEquals(0, getFinalDocCount()); - FlowManager fm = new FlowManager(getHubConfig()); + FlowManager fm = FlowManager.create(getHubConfig()); Flow flow1 = fm.getFlow("test", "my-test-flow-with-header"); FlowRunner flowRunner = fm.newFlowRunner() .withFlow(flow1) @@ -368,7 +368,7 @@ public void testRunFlowWithAll() throws SAXException, IOException, ParserConfigu assertEquals(2, getStagingDocCount()); assertEquals(0, getFinalDocCount()); - FlowManager fm = new FlowManager(getHubConfig()); + FlowManager fm = FlowManager.create(getHubConfig()); Flow flow1 = fm.getFlow("test", "my-test-flow-with-all"); FlowRunner flowRunner = fm.newFlowRunner() .withFlow(flow1) @@ -387,7 +387,7 @@ public void testRunFlowWithAll() throws SAXException, IOException, ParserConfigu @Test public void testHasLegacyflows() throws IOException, InterruptedException, ParserConfigurationException, SAXException, JSONException { - FlowManager fm = new FlowManager(getHubConfig()); + FlowManager fm = FlowManager.create(getHubConfig()); Scaffolding scaffolding = Scaffolding.create(getHubConfig().getProjectDir(), stagingClient); scaffolding.createEntity("new-entity"); diff --git a/marklogic-data-hub/src/test/java/com/marklogic/hub/TracingTest.java b/marklogic-data-hub/src/test/java/com/marklogic/hub/TracingTest.java index acc2124dbc..8881f0e766 100644 --- a/marklogic-data-hub/src/test/java/com/marklogic/hub/TracingTest.java +++ b/marklogic-data-hub/src/test/java/com/marklogic/hub/TracingTest.java @@ -55,7 +55,7 @@ public void runXMLFlowSansTracing() { Tracing t = Tracing.create(stagingClient); assertFalse(t.isEnabled()); - FlowManager fm = new FlowManager(getHubConfig()); + FlowManager fm = FlowManager.create(getHubConfig()); Flow flow = fm.getFlow("trace-entity", "tracemeXML"); FlowRunner flowRunner = fm.newFlowRunner() @@ -77,7 +77,7 @@ public void runJSONFlowSansTracing() { Tracing t = Tracing.create(stagingClient); assertFalse(t.isEnabled()); - FlowManager fm = new FlowManager(getHubConfig()); + FlowManager fm = FlowManager.create(getHubConfig()); Flow flow = fm.getFlow("trace-entity", "tracemeJSON"); FlowRunner flowRunner = fm.newFlowRunner() @@ -102,7 +102,7 @@ public void runXMLFlowWithTracing() { t.enable(); assertTrue(t.isEnabled()); - FlowManager fm = new FlowManager(getHubConfig()); + FlowManager fm = FlowManager.create(getHubConfig()); Flow flow = fm.getFlow("trace-entity", "tracemeXML"); FlowRunner flowRunner = fm.newFlowRunner() @@ -127,7 +127,7 @@ public void runJSONFlowWithTracing() { t.enable(); assertTrue(t.isEnabled()); - FlowManager fm = new FlowManager(getHubConfig()); + FlowManager fm = FlowManager.create(getHubConfig()); Flow flow = fm.getFlow("trace-entity", "tracemeJSON"); FlowRunner flowRunner = fm.newFlowRunner() @@ -150,7 +150,7 @@ public void runXMLErrorFlowWithoutTracing() { Tracing t = Tracing.create(stagingClient); assertFalse(t.isEnabled()); - FlowManager fm = new FlowManager(getHubConfig()); + FlowManager fm = FlowManager.create(getHubConfig()); Flow flow = fm.getFlow("trace-entity", "tracemeXMLError"); FlowRunner flowRunner = fm.newFlowRunner() @@ -178,7 +178,7 @@ public void runXMLWriterErrorFlowWithoutTracing() { Tracing t = Tracing.create(stagingClient); assertFalse(t.isEnabled()); - FlowManager fm = new FlowManager(getHubConfig()); + FlowManager fm = FlowManager.create(getHubConfig()); Flow flow = fm.getFlow("trace-entity", "tracemeXMLWriterError"); FlowRunner flowRunner = fm.newFlowRunner() @@ -206,7 +206,7 @@ public void runJSONErrorFlowWithoutTracing() { Tracing t = Tracing.create(stagingClient); assertFalse(t.isEnabled()); - FlowManager fm = new FlowManager(getHubConfig()); + FlowManager fm = FlowManager.create(getHubConfig()); Flow flow = fm.getFlow("trace-entity", "tracemeJSONError"); FlowRunner flowRunner = fm.newFlowRunner() @@ -236,7 +236,7 @@ public void runJSONWriterErrorFlowWithoutTracing() { Tracing t = Tracing.create(stagingClient); assertFalse(t.isEnabled()); - FlowManager fm = new FlowManager(getHubConfig()); + FlowManager fm = FlowManager.create(getHubConfig()); Flow flow = fm.getFlow("trace-entity", "tracemeJSONWriterError"); FlowRunner flowRunner = fm.newFlowRunner() diff --git a/marklogic-data-hub/src/test/java/com/marklogic/hub/collector/EmptyCollectorTest.java b/marklogic-data-hub/src/test/java/com/marklogic/hub/collector/EmptyCollectorTest.java index db4de4b7bb..9479eb8983 100644 --- a/marklogic-data-hub/src/test/java/com/marklogic/hub/collector/EmptyCollectorTest.java +++ b/marklogic-data-hub/src/test/java/com/marklogic/hub/collector/EmptyCollectorTest.java @@ -61,7 +61,7 @@ public static void teardown() { public void runCollector() { assertEquals(0, getStagingDocCount()); assertEquals(0, getFinalDocCount()); - FlowManager fm = new FlowManager(getHubConfig()); + FlowManager fm = FlowManager.create(getHubConfig()); Flow harmonizeFlow = fm.getFlow(ENTITY, "testharmonize", FlowType.HARMONIZE); HashMap options = new HashMap<>(); diff --git a/marklogic-data-hub/src/test/java/com/marklogic/hub/collector/StreamCollectorTest.java b/marklogic-data-hub/src/test/java/com/marklogic/hub/collector/StreamCollectorTest.java index b0579929c5..ece96e44c8 100644 --- a/marklogic-data-hub/src/test/java/com/marklogic/hub/collector/StreamCollectorTest.java +++ b/marklogic-data-hub/src/test/java/com/marklogic/hub/collector/StreamCollectorTest.java @@ -126,7 +126,7 @@ public void runCollector() { // having to wait for the entire harmonize flow to finish. assertEquals(DOC_COUNT, getStagingDocCount()); assertEquals(0, getFinalDocCount()); - FlowManager fm = new FlowManager(getHubConfig()); + FlowManager fm = FlowManager.create(getHubConfig()); Flow harmonizeFlow = fm.getFlow(ENTITY, "testharmonize", FlowType.HARMONIZE); HashMap options = new HashMap<>(); diff --git a/marklogic-data-hub/src/test/java/com/marklogic/hub/flow/FlowRunnerTest.java b/marklogic-data-hub/src/test/java/com/marklogic/hub/flow/FlowRunnerTest.java index 581db51783..f0bf05c03d 100644 --- a/marklogic-data-hub/src/test/java/com/marklogic/hub/flow/FlowRunnerTest.java +++ b/marklogic-data-hub/src/test/java/com/marklogic/hub/flow/FlowRunnerTest.java @@ -76,7 +76,7 @@ public static void teardown() { @Test public void testPassOptions() throws IOException, ParserConfigurationException, SAXException { - FlowManager fm = new FlowManager(getHubConfig()); + FlowManager fm = FlowManager.create(getHubConfig()); Flow harmonizeFlow = fm.getFlow(ENTITY, "testharmonize", FlowType.HARMONIZE); HashMap options = new HashMap<>(); diff --git a/marklogic-data-hub/src/test/java/com/marklogic/hub/job/JobManagerTest.java b/marklogic-data-hub/src/test/java/com/marklogic/hub/job/JobManagerTest.java index b98c9b0db0..5e163e96da 100644 --- a/marklogic-data-hub/src/test/java/com/marklogic/hub/job/JobManagerTest.java +++ b/marklogic-data-hub/src/test/java/com/marklogic/hub/job/JobManagerTest.java @@ -75,7 +75,7 @@ public static void teardownSuite() { public void setup() { // Run a flow a couple times to generate some job/trace data. jobIds.clear(); - FlowManager fm = new FlowManager(getHubConfig()); + FlowManager fm = FlowManager.create(getHubConfig()); Flow harmonizeFlow = fm.getFlow(ENTITY, HARMONIZE_FLOW_XML, FlowType.HARMONIZE); HashMap options = new HashMap<>(); options.put("name", "Bob Smith"); diff --git a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/HubTask.groovy b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/HubTask.groovy index 022a05aed2..6039c485f1 100644 --- a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/HubTask.groovy +++ b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/HubTask.groovy @@ -33,7 +33,7 @@ abstract class HubTask extends DefaultTask { @Internal FlowManager getFlowManager() { - return new FlowManager(getHubConfig()) + return FlowManager.create(getHubConfig()) } @Internal diff --git a/quick-start/src/main/java/com/marklogic/quickstart/service/FlowManagerService.java b/quick-start/src/main/java/com/marklogic/quickstart/service/FlowManagerService.java index 0f980a138a..fc596b5e3f 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/service/FlowManagerService.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/service/FlowManagerService.java @@ -56,7 +56,7 @@ private EnvironmentConfig envConfig() { } private FlowManager getFlowManager() { - return new FlowManager(envConfig().getMlSettings()); + return FlowManager.create(envConfig().getMlSettings()); } public List getFlows(String projectDir, String entityName, FlowType flowType) { diff --git a/quick-start/src/test/java/com/marklogic/quickstart/service/FlowManagerServiceTest.java b/quick-start/src/test/java/com/marklogic/quickstart/service/FlowManagerServiceTest.java index cb11d8b05b..82dd4ab3d8 100644 --- a/quick-start/src/test/java/com/marklogic/quickstart/service/FlowManagerServiceTest.java +++ b/quick-start/src/test/java/com/marklogic/quickstart/service/FlowManagerServiceTest.java @@ -135,7 +135,7 @@ public void runMlcp() throws IOException, InterruptedException, JSONException { String flowName = "sjs-json-input-flow"; - FlowManager flowManager = new FlowManager(getHubConfig()); + FlowManager flowManager = FlowManager.create(getHubConfig()); Flow flow = flowManager.getFlow(ENTITY, flowName, FlowType.INPUT); ObjectMapper objectMapper = new ObjectMapper(); @@ -183,7 +183,7 @@ public void runHarmonizationFlow() throws InterruptedException { setEnvConfig(envConfig); String flowName = "sjs-json-harmonization-flow"; - FlowManager flowManager = new FlowManager(getHubConfig()); + FlowManager flowManager = FlowManager.create(getHubConfig()); Flow flow = flowManager.getFlow(ENTITY, flowName, FlowType.HARMONIZE); HubConfig hubConfig = getHubConfig(); @@ -226,7 +226,7 @@ public void runHarmonizationFlowWithOptions() throws InterruptedException { setEnvConfig(envConfig); String flowName = "sjs-json-harmonization-flow"; - FlowManager flowManager = new FlowManager(getHubConfig()); + FlowManager flowManager = FlowManager.create(getHubConfig()); Flow flow = flowManager.getFlow(ENTITY, flowName, FlowType.HARMONIZE); HubConfig hubConfig = getHubConfig(); From dc054b1bfefbacf6c6344d120259b0d3aedfd0ac Mon Sep 17 00:00:00 2001 From: Alexander Ebadirad Date: Thu, 15 Feb 2018 11:25:02 -0700 Subject: [PATCH 06/22] Fixing tests due to refactor --- .../groovy/com/marklogic/gradle/task/CreateEntityTask.groovy | 2 +- .../main/groovy/com/marklogic/gradle/task/CreateFlowTask.groovy | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/CreateEntityTask.groovy b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/CreateEntityTask.groovy index fa1f805528..03a472100a 100644 --- a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/CreateEntityTask.groovy +++ b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/CreateEntityTask.groovy @@ -16,7 +16,7 @@ class CreateEntityTask extends HubTask { def projectDir = getHubConfig().projectDir println "entityName: " + entityName println "projectDir: " + projectDir.toString() - Scaffolding scaffolding = Scaffolding.createImpl(projectDir, getFinalClient()) + Scaffolding scaffolding = Scaffolding.create(projectDir, getFinalClient()) scaffolding.createEntity(entityName) } } diff --git a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/CreateFlowTask.groovy b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/CreateFlowTask.groovy index f0f823de78..449615cb27 100644 --- a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/CreateFlowTask.groovy +++ b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/CreateFlowTask.groovy @@ -49,7 +49,7 @@ abstract class CreateFlowTask extends HubTask { } def projectDir = getHubConfig().projectDir - Scaffolding scaffolding = Scaffolding.createImpl(projectDir, getFinalClient()) + Scaffolding scaffolding = Scaffolding.create(projectDir, getFinalClient()) println "Creating an " + pluginFormat + " " + flowType + " flow named " + flowName + " for entity " + entityName scaffolding.createFlow(entityName, flowName, flowType, pluginFormat, dataFormat, useES) } From e9e0d5d7c687da83c40281ceca67a74a9215a306 Mon Sep 17 00:00:00 2001 From: Alexander Ebadirad Date: Thu, 15 Feb 2018 13:47:36 -0700 Subject: [PATCH 07/22] Removal of preintellcheck as a class, now a subclass of datahub --- .../main/java/com/marklogic/hub/DataHub.java | 134 +++++++++++++++--- .../com/marklogic/hub/PreInstallCheck.java | 36 ----- .../java/com/marklogic/hub/DataHubTest.java | 76 +++++----- .../gradle/task/PreinstallCheckTask.groovy | 28 ++-- .../quickstart/service/DataHubService.java | 5 +- .../web/CurrentProjectController.java | 5 +- 6 files changed, 172 insertions(+), 112 deletions(-) delete mode 100644 marklogic-data-hub/src/main/java/com/marklogic/hub/PreInstallCheck.java diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/DataHub.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/DataHub.java index df740dfddd..ac6ab8da20 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/DataHub.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/DataHub.java @@ -242,46 +242,44 @@ public List getCommandList() { return commands; } - public PreInstallCheck runPreInstallCheck() { - return runPreInstallCheck(null); + public void runPreInstallCheck() { + runPreInstallCheck(null); } - public PreInstallCheck runPreInstallCheck(Versions versions) { - PreInstallCheck check = new PreInstallCheck(); + public void runPreInstallCheck(Versions versions) { Map portsInUse = getServerPortsInUse(); Set ports = portsInUse.keySet(); String serverName = portsInUse.get(hubConfig.getStagingPort()); - check.stagingPortInUse = ports.contains(hubConfig.getStagingPort()) && serverName != null && !serverName.equals(hubConfig.getStagingHttpName()); - if (check.stagingPortInUse) { - check.stagingPortInUseBy = serverName; + stagingPortInUse = ports.contains(hubConfig.getStagingPort()) && serverName != null && !serverName.equals(hubConfig.getStagingHttpName()); + if (stagingPortInUse) { + stagingPortInUseBy = serverName; } serverName = portsInUse.get(hubConfig.getFinalPort()); - check.finalPortInUse = ports.contains(hubConfig.getFinalPort()) && serverName != null && !serverName.equals(hubConfig.getFinalHttpName()); - if (check.finalPortInUse) { - check.finalPortInUseBy = serverName; + finalPortInUse = ports.contains(hubConfig.getFinalPort()) && serverName != null && !serverName.equals(hubConfig.getFinalHttpName()); + if (finalPortInUse) { + finalPortInUseBy = serverName; } serverName = portsInUse.get(hubConfig.getJobPort()); - check.jobPortInUse = ports.contains(hubConfig.getJobPort()) && serverName != null && !serverName.equals(hubConfig.getJobHttpName()); - if (check.jobPortInUse) { - check.jobPortInUseBy = serverName; + jobPortInUse = ports.contains(hubConfig.getJobPort()) && serverName != null && !serverName.equals(hubConfig.getJobHttpName()); + if (jobPortInUse) { + jobPortInUseBy = serverName; } serverName = portsInUse.get(hubConfig.getTracePort()); - check.tracePortInUse = ports.contains(hubConfig.getTracePort()) && serverName != null && !serverName.equals(hubConfig.getTraceHttpName()); - if (check.tracePortInUse) { - check.tracePortInUseBy = serverName; + tracePortInUse = ports.contains(hubConfig.getTracePort()) && serverName != null && !serverName.equals(hubConfig.getTraceHttpName()); + if (tracePortInUse) { + tracePortInUseBy = serverName; } if (versions == null) { versions = new Versions(hubConfig); } - check.serverVersion = versions.getMarkLogicVersion(); - check.serverVersionOk = isServerVersionValid(check.serverVersion); - return check; + serverVersion = versions.getMarkLogicVersion(); + serverVersionOk = isServerVersionValid(serverVersion); } /** @@ -397,4 +395,102 @@ private Map getServerPortsInUse() { }); return portsInUse; } + + private boolean stagingPortInUse; + private String stagingPortInUseBy; + private boolean finalPortInUse; + private String finalPortInUseBy; + private boolean jobPortInUse; + private String jobPortInUseBy; + private boolean tracePortInUse; + private String tracePortInUseBy; + private boolean serverVersionOk; + private String serverVersion; + + public boolean isSafeToInstall() { + return !(isStagingPortInUse() || + isFinalPortInUse() || + isJobPortInUse() || + isTracePortInUse()) && isServerVersionOk(); + } + + public boolean isStagingPortInUse() { + return stagingPortInUse; + } + + public void setStagingPortInUse(boolean stagingPortInUse) { + this.stagingPortInUse = stagingPortInUse; + } + + public String getStagingPortInUseBy() { + return stagingPortInUseBy; + } + + public void setStagingPortInUseBy(String stagingPortInUseBy) { + this.stagingPortInUseBy = stagingPortInUseBy; + } + + public boolean isFinalPortInUse() { + return finalPortInUse; + } + + public void setFinalPortInUse(boolean finalPortInUse) { + this.finalPortInUse = finalPortInUse; + } + + public String getFinalPortInUseBy() { + return finalPortInUseBy; + } + + public void setFinalPortInUseBy(String finalPortInUseBy) { + this.finalPortInUseBy = finalPortInUseBy; + } + + public boolean isJobPortInUse() { + return jobPortInUse; + } + + public void setJobPortInUse(boolean jobPortInUse) { + this.jobPortInUse = jobPortInUse; + } + + public String getJobPortInUseBy() { + return jobPortInUseBy; + } + + public void setJobPortInUseBy(String jobPortInUseBy) { + this.jobPortInUseBy = jobPortInUseBy; + } + + public boolean isTracePortInUse() { + return tracePortInUse; + } + + public void setTracePortInUse(boolean tracePortInUse) { + this.tracePortInUse = tracePortInUse; + } + + public String getTracePortInUseBy() { + return tracePortInUseBy; + } + + public void setTracePortInUseBy(String tracePortInUseBy) { + this.tracePortInUseBy = tracePortInUseBy; + } + + public boolean isServerVersionOk() { + return serverVersionOk; + } + + public void setServerVersionOk(boolean serverVersionOk) { + this.serverVersionOk = serverVersionOk; + } + + public String getServerVersion() { + return serverVersion; + } + + public void setServerVersion(String serverVersion) { + this.serverVersion = serverVersion; + } } diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/PreInstallCheck.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/PreInstallCheck.java deleted file mode 100644 index fc55490d33..0000000000 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/PreInstallCheck.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2012-2018 MarkLogic Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.marklogic.hub; - -public class PreInstallCheck { - public boolean stagingPortInUse; - public String stagingPortInUseBy; - public boolean finalPortInUse; - public String finalPortInUseBy; - public boolean jobPortInUse; - public String jobPortInUseBy; - public boolean tracePortInUse; - public String tracePortInUseBy; - public boolean serverVersionOk; - public String serverVersion; - - public boolean isSafeToInstall() { - return !(stagingPortInUse || - finalPortInUse || - jobPortInUse || - tracePortInUse) && serverVersionOk; - } -} diff --git a/marklogic-data-hub/src/test/java/com/marklogic/hub/DataHubTest.java b/marklogic-data-hub/src/test/java/com/marklogic/hub/DataHubTest.java index d36a6fc20b..98f9fe6767 100644 --- a/marklogic-data-hub/src/test/java/com/marklogic/hub/DataHubTest.java +++ b/marklogic-data-hub/src/test/java/com/marklogic/hub/DataHubTest.java @@ -180,13 +180,13 @@ public void testPreFlightCheckNoHubInstalled() { expect(versions.getMarkLogicVersion()).andReturn("9.0-2"); replay(dh, serverManager, versions); - PreInstallCheck check = dh.runPreInstallCheck(); - assertTrue(check.serverVersionOk); - assertFalse(check.stagingPortInUse); - assertFalse(check.finalPortInUse); - assertFalse(check.jobPortInUse); - assertFalse(check.tracePortInUse); - assertTrue(check.isSafeToInstall()); + dh.runPreInstallCheck(); + assertTrue(dh.isServerVersionOk()); + assertFalse(dh.isStagingPortInUse()); + assertFalse(dh.isFinalPortInUse()); + assertFalse(dh.isJobPortInUse()); + assertFalse(dh.isTracePortInUse()); + assertTrue(dh.isSafeToInstall()); } @Test @@ -204,13 +204,13 @@ public void testPreFlightCheckHubAlreadyInstalled() { expect(versions.getMarkLogicVersion()).andReturn("9.0-2"); replay(dh, serverManager, versions); - PreInstallCheck check = dh.runPreInstallCheck(); - assertTrue(check.serverVersionOk); - assertFalse(check.stagingPortInUse); - assertFalse(check.finalPortInUse); - assertFalse(check.jobPortInUse); - assertFalse(check.tracePortInUse); - assertTrue(check.isSafeToInstall()); + dh.runPreInstallCheck(); + assertTrue(dh.isServerVersionOk()); + assertFalse(dh.isStagingPortInUse()); + assertFalse(dh.isFinalPortInUse()); + assertFalse(dh.isJobPortInUse()); + assertFalse(dh.isTracePortInUse()); + assertTrue(dh.isSafeToInstall()); } @Test @@ -225,14 +225,14 @@ public void testPreFlightCheckStagingPortTaken() { expect(versions.getMarkLogicVersion()).andReturn("9.0-2"); replay(serverManager, dh, versions); - PreInstallCheck check = dh.runPreInstallCheck(); - assertTrue(check.serverVersionOk); - assertTrue(check.stagingPortInUse); - assertEquals("port-stealer", check.stagingPortInUseBy); - assertFalse(check.finalPortInUse); - assertFalse(check.jobPortInUse); - assertFalse(check.tracePortInUse); - assertFalse(check.isSafeToInstall()); + dh.runPreInstallCheck(); + assertTrue(dh.isServerVersionOk()); + assertTrue(dh.isStagingPortInUse()); + assertEquals("port-stealer", dh.getStagingPortInUseBy()); + assertFalse(dh.isFinalPortInUse()); + assertFalse(dh.isJobPortInUse()); + assertFalse(dh.isTracePortInUse()); + assertFalse(dh.isSafeToInstall()); } @Test @@ -247,14 +247,14 @@ public void testPreFlightCheckStagingPortTakenAndBadVersion() { expect(versions.getMarkLogicVersion()).andReturn("9.0-1"); replay(dh, versions, serverManager); - PreInstallCheck check = dh.runPreInstallCheck(versions); - assertFalse(check.serverVersionOk); - assertTrue(check.stagingPortInUse); - assertEquals("port-stealer", check.stagingPortInUseBy); - assertFalse(check.finalPortInUse); - assertFalse(check.jobPortInUse); - assertFalse(check.tracePortInUse); - assertFalse(check.isSafeToInstall()); + dh.runPreInstallCheck(versions); + assertFalse(dh.isServerVersionOk()); + assertTrue(dh.isStagingPortInUse()); + assertEquals("port-stealer", dh.getStagingPortInUseBy()); + assertFalse(dh.isFinalPortInUse()); + assertFalse(dh.isJobPortInUse()); + assertFalse(dh.isTracePortInUse()); + assertFalse(dh.isSafeToInstall()); } @Test @@ -269,13 +269,13 @@ public void testPreFlightCheckFinalPortTaken() { expect(versions.getMarkLogicVersion()).andReturn("9.0-2"); replay(dh, versions, serverManager); - PreInstallCheck check = dh.runPreInstallCheck(); - assertTrue(check.serverVersionOk); - assertFalse(check.stagingPortInUse); - assertTrue(check.finalPortInUse); - assertEquals("port-stealer", check.finalPortInUseBy); - assertFalse(check.jobPortInUse); - assertFalse(check.tracePortInUse); - assertFalse(check.isSafeToInstall()); + dh.runPreInstallCheck(); + assertTrue(dh.isServerVersionOk()); + assertFalse(dh.isStagingPortInUse()); + assertTrue(dh.isFinalPortInUse()); + assertEquals("port-stealer", dh.getFinalPortInUseBy()); + assertFalse(dh.isJobPortInUse()); + assertFalse(dh.isTracePortInUse()); + assertFalse(dh.isSafeToInstall()); } } diff --git a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/PreinstallCheckTask.groovy b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/PreinstallCheckTask.groovy index a7fe481382..430add9f21 100644 --- a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/PreinstallCheckTask.groovy +++ b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/PreinstallCheckTask.groovy @@ -1,5 +1,6 @@ package com.marklogic.gradle.task +import com.marklogic.hub.DataHub import org.gradle.api.tasks.TaskAction import org.gradle.api.tasks.TaskExecutionException @@ -7,8 +8,9 @@ class PreinstallCheckTask extends HubTask { @TaskAction void runPreinstallCheck() { - def check = getDataHub().runPreInstallCheck() - if (!check.isSafeToInstall()) { + DataHub dh = getDataHub(); + dh.runPreInstallCheck() + if (!dh.isSafeToInstall()) { StringBuilder sb = new StringBuilder(); sb.append("\n\n" + "██╗ ██╗ ██████╗ ██╗ ██╗███████╗████████╗ ██████╗ ███╗ ██╗ \n" + @@ -28,32 +30,32 @@ class PreinstallCheckTask extends HubTask { .append("PreInstall Check: [FAILED]\n") .append("---------------------------------------\n") - if (!check.serverVersionOk) { - sb.append("- PROBLEM: Unsupported MarkLogic Server Version: " + check.serverVersion + "\n") + if (!dh.isServerVersionOk()) { + sb.append("- PROBLEM: Unsupported MarkLogic Server Version: " + dh.getServerVersion() + "\n") .append(" FIX: Update to a supported version of MarkLogic.\n") } - if (check.stagingPortInUseBy != null) { - sb.append("- PROBLEM: Staging Port " + hubConfig.stagingPort + " already in use by: [" + check.stagingPortInUseBy + "]\n") + if (dh.getStagingPortInUseBy() != null) { + sb.append("- PROBLEM: Staging Port " + hubConfig.stagingPort + " already in use by: [" + dh.getStagingPortInUseBy() + "]\n") .append(" FIX: Change the [mlStagingPort] property in gradle.properties to a free port\n") } - if (check.finalPortInUseBy != null) { - sb.append("- PROBLEM: Final Port " + hubConfig.finalPort + " already in use by: [" + check.finalPortInUseBy + "]\n") + if (dh.getFinalPortInUseBy() != null) { + sb.append("- PROBLEM: Final Port " + hubConfig.finalPort + " already in use by: [" + dh.getFinalPortInUseBy() + "]\n") .append(" FIX: Change the [mlFinalPort] property in gradle.properties to a free port\n") } - if (check.jobPortInUseBy != null) { - sb.append("- PROBLEM: Job Port " + hubConfig.jobPort + " already in use by: [" + check.jobPortInUseBy + "]\n") + if (dh.getJobPortInUseBy() != null) { + sb.append("- PROBLEM: Job Port " + hubConfig.jobPort + " already in use by: [" + dh.getJobPortInUseBy() + "]\n") .append(" FIX: Change the [mlJobPort] property in gradle.properties to a free port\n") } - if (check.tracePortInUseBy != null) { - sb.append("- PROBLEM: Trace Port " + hubConfig.tracePort + " already in use by: [" + check.tracePortInUseBy + "]\n") + if (dh.getTracePortInUseBy() != null) { + sb.append("- PROBLEM: Trace Port " + hubConfig.tracePort + " already in use by: [" + dh.getTracePortInUseBy() + "]\n") .append(" FIX: Change the [mlTracePort] property in gradle.properties to a free port\n") } throw new TaskExecutionException(this, new Throwable(sb.toString())) } - print(check.toString()) + print(dh.toString()) } } diff --git a/quick-start/src/main/java/com/marklogic/quickstart/service/DataHubService.java b/quick-start/src/main/java/com/marklogic/quickstart/service/DataHubService.java index 8fbd17f6bb..f0514760c0 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/service/DataHubService.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/service/DataHubService.java @@ -20,7 +20,6 @@ import com.marklogic.hub.DataHub; import com.marklogic.hub.DataHubUpgrader; import com.marklogic.hub.HubConfig; -import com.marklogic.hub.PreInstallCheck; import com.marklogic.hub.deploy.commands.LoadUserModulesCommand; import com.marklogic.hub.deploy.util.HubDeployStatusListener; import com.marklogic.hub.error.CantUpgradeException; @@ -128,9 +127,9 @@ public void uninstallUserModules(HubConfig config) { PerformanceLogger.logTimeInsideMethod(startTime, "DataHubService.uninstallUserModules"); } - public PreInstallCheck preInstallCheck(HubConfig config) { + public void preInstallCheck(HubConfig config) { DataHub dataHub = new DataHub(config); - return dataHub.runPreInstallCheck(); + dataHub.runPreInstallCheck(); } @Async diff --git a/quick-start/src/main/java/com/marklogic/quickstart/web/CurrentProjectController.java b/quick-start/src/main/java/com/marklogic/quickstart/web/CurrentProjectController.java index 16fb8231d8..831a419efb 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/web/CurrentProjectController.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/web/CurrentProjectController.java @@ -19,7 +19,6 @@ import com.fasterxml.jackson.databind.JsonNode; import com.marklogic.hub.HubConfig; import com.marklogic.hub.InstallInfo; -import com.marklogic.hub.PreInstallCheck; import com.marklogic.hub.Tracing; import com.marklogic.hub.deploy.util.HubDeployStatusListener; import com.marklogic.hub.error.CantUpgradeException; @@ -211,8 +210,8 @@ public ResponseEntity updateHub() throws IOException, CantUpgradeException { @RequestMapping(value = "/preinstall-check", method = RequestMethod.GET, produces = {MediaType.APPLICATION_JSON_VALUE}) @ResponseBody - public PreInstallCheck preInstallCheck() { - return dataHubService.preInstallCheck(envConfig().getMlSettings()); + public void preInstallCheck() { + dataHubService.preInstallCheck(envConfig().getMlSettings()); } private void startProjectWatcher() throws IOException { From 47a3ef090531187dc73c62f9eac7c9bbed6a20db Mon Sep 17 00:00:00 2001 From: Alexander Ebadirad Date: Thu, 15 Feb 2018 14:49:22 -0700 Subject: [PATCH 08/22] Shifting hubdatabase and hubupgrader into datahub, updating associations --- .../main/java/com/marklogic/hub/DataHub.java | 126 +++++++-- .../com/marklogic/hub/DataHubUpgrader.java | 90 ------ .../java/com/marklogic/hub/HubDatabase.java | 39 --- .../java/com/marklogic/hub/InstallInfo.java | 261 +++++++++++++----- .../marklogic/hub/collector/Collector.java | 5 - .../gradle/task/UpdateHubTask.groovy | 4 +- .../quickstart/model/SearchQuery.java | 4 +- .../quickstart/service/DataHubService.java | 3 +- .../quickstart/service/SearchService.java | 8 +- .../quickstart/web/SearchController.java | 4 +- 10 files changed, 311 insertions(+), 233 deletions(-) delete mode 100644 marklogic-data-hub/src/main/java/com/marklogic/hub/DataHubUpgrader.java delete mode 100644 marklogic-data-hub/src/main/java/com/marklogic/hub/HubDatabase.java diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/DataHub.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/DataHub.java index ac6ab8da20..d9a6336c28 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/DataHub.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/DataHub.java @@ -25,6 +25,7 @@ import com.marklogic.hub.deploy.HubAppDeployer; import com.marklogic.hub.deploy.commands.*; import com.marklogic.hub.deploy.util.HubDeployStatusListener; +import com.marklogic.hub.error.CantUpgradeException; import com.marklogic.hub.error.ServerValidationException; import com.marklogic.hub.util.Versions; import com.marklogic.mgmt.ManageClient; @@ -33,6 +34,7 @@ import com.marklogic.mgmt.resource.databases.DatabaseManager; import com.marklogic.rest.util.Fragment; import com.marklogic.rest.util.ResourcesFragment; +import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -40,9 +42,12 @@ import org.springframework.core.io.support.PathMatchingResourcePatternResolver; import org.springframework.core.io.support.ResourcePatternResolver; +import java.io.File; import java.io.IOException; +import java.nio.file.Paths; import java.text.SimpleDateFormat; import java.util.*; +import java.util.regex.Pattern; public class DataHub { @@ -100,39 +105,39 @@ public InstallInfo isInstalled() { InstallInfo installInfo = new InstallInfo(); ResourcesFragment srf = getServerManager().getAsXml(); - installInfo.stagingAppServerExists = srf.resourceExists(hubConfig.getStagingHttpName()); - installInfo.finalAppServerExists = srf.resourceExists(hubConfig.getFinalHttpName()); - installInfo.traceAppServerExists = srf.resourceExists(hubConfig.getTraceHttpName()); - installInfo.jobAppServerExists = srf.resourceExists(hubConfig.getJobHttpName()); + installInfo.setStagingAppServerExists(srf.resourceExists(hubConfig.getStagingHttpName())); + installInfo.setFinalAppServerExists(srf.resourceExists(hubConfig.getFinalHttpName())); + installInfo.setTraceAppServerExists(srf.resourceExists(hubConfig.getTraceHttpName())); + installInfo.setJobAppServerExists(srf.resourceExists(hubConfig.getJobHttpName())); ResourcesFragment drf = getDatabaseManager().getAsXml(); - installInfo.stagingDbExists = drf.resourceExists(hubConfig.getStagingDbName()); - installInfo.finalDbExists = drf.resourceExists(hubConfig.getFinalDbName()); - installInfo.traceDbExists = drf.resourceExists(hubConfig.getTraceDbName()); - installInfo.jobDbExists = drf.resourceExists(hubConfig.getJobDbName()); + installInfo.setStagingDbExists(drf.resourceExists(hubConfig.getStagingDbName())); + installInfo.setFinalDbExists(drf.resourceExists(hubConfig.getFinalDbName())); + installInfo.setTraceDbExists(drf.resourceExists(hubConfig.getTraceDbName())); + installInfo.setJobDbExists(drf.resourceExists(hubConfig.getJobDbName())); - if (installInfo.stagingDbExists) { + if (installInfo.isStagingDbExists()) { Fragment f = getDatabaseManager().getPropertiesAsXml(hubConfig.getStagingDbName()); - installInfo.stagingTripleIndexOn = Boolean.parseBoolean(f.getElementValue("//m:triple-index")); - installInfo.stagingCollectionLexiconOn = Boolean.parseBoolean(f.getElementValue("//m:collection-lexicon")); - installInfo.stagingForestsExist = (f.getElements("//m:forest").size() > 0); + installInfo.setStagingTripleIndexOn(Boolean.parseBoolean(f.getElementValue("//m:triple-index"))); + installInfo.setStagingCollectionLexiconOn(Boolean.parseBoolean(f.getElementValue("//m:collection-lexicon"))); + installInfo.setStagingForestsExist((f.getElements("//m:forest").size() > 0)); } - if (installInfo.finalDbExists) { + if (installInfo.isFinalDbExists()) { Fragment f = getDatabaseManager().getPropertiesAsXml(hubConfig.getFinalDbName()); - installInfo.finalTripleIndexOn = Boolean.parseBoolean(f.getElementValue("//m:triple-index")); - installInfo.finalCollectionLexiconOn = Boolean.parseBoolean(f.getElementValue("//m:collection-lexicon")); - installInfo.finalForestsExist = (f.getElements("//m:forest").size() > 0); + installInfo.setFinalTripleIndexOn(Boolean.parseBoolean(f.getElementValue("//m:triple-index"))); + installInfo.setFinalCollectionLexiconOn(Boolean.parseBoolean(f.getElementValue("//m:collection-lexicon"))); + installInfo.setFinalForestsExist((f.getElements("//m:forest").size() > 0)); } - if (installInfo.traceDbExists) { + if (installInfo.isTraceDbExists()) { Fragment f = getDatabaseManager().getPropertiesAsXml(hubConfig.getTraceDbName()); - installInfo.traceForestsExist = (f.getElements("//m:forest").size() > 0); + installInfo.setTraceForestsExist((f.getElements("//m:forest").size() > 0)); } - if (installInfo.jobDbExists) { + if (installInfo.isJobDbExists()) { Fragment f = getDatabaseManager().getPropertiesAsXml(hubConfig.getJobDbName()); - installInfo.jobForestsExist = (f.getElements("//m:forest").size() > 0); + installInfo.setJobForestsExist((f.getElements("//m:forest").size() > 0)); } logger.info(installInfo.toString()); @@ -396,6 +401,8 @@ private Map getServerPortsInUse() { return portsInUse; } + + // Here is the former PreCheckInstall class stuff private boolean stagingPortInUse; private String stagingPortInUseBy; private boolean finalPortInUse; @@ -493,4 +500,83 @@ public String getServerVersion() { public void setServerVersion(String serverVersion) { this.serverVersion = serverVersion; } + + //HubDatabase stuff goes here + + public enum HubDatabase { + STAGING("staging"), + FINAL("final"); + + private String type; + + HubDatabase(String type) { + this.type = type; + } + + public static HubDatabase getHubDatabase(String database) { + for (HubDatabase hubDatabase : HubDatabase.values()) { + if (hubDatabase.toString().equals(database)) { + return hubDatabase; + } + } + return null; + } + + public String toString() { + return this.type; + } + } + + //DataHubUpgrader stuff + public static String MIN_UPGRADE_VERSION = "1.1.3"; + + public boolean upgradeHub() throws CantUpgradeException { + return upgradeHub(null); + } + + public boolean upgradeHub(List updatedFlows) throws CantUpgradeException { + boolean isHubInstalled = this.isInstalled().isInstalled(); + + String currentVersion = new Versions(hubConfig).getHubVersion(); + int compare = Versions.compare(currentVersion, MIN_UPGRADE_VERSION); + if (compare == -1) { + throw new CantUpgradeException(currentVersion, MIN_UPGRADE_VERSION); + } + + boolean result = false; + boolean alreadyInitialized = hubConfig.getHubProject().isInitialized(); + File buildGradle = Paths.get(hubConfig.getProjectDir(), "build.gradle").toFile(); + try { + // update the hub-internal-config files + hubConfig.initHubProject(); + + if (alreadyInitialized) { + // replace the hub version in build.gradle + String text = FileUtils.readFileToString(buildGradle); + String version = hubConfig.getJarVersion(); + text = Pattern.compile("^(\\s*)id\\s+['\"]com.marklogic.ml-data-hub['\"]\\s+version.+$", Pattern.MULTILINE).matcher(text).replaceAll("$1id 'com.marklogic.ml-data-hub' version '" + version + "'"); + text = Pattern.compile("^(\\s*)compile.+marklogic-data-hub.+$", Pattern.MULTILINE).matcher(text).replaceAll("$1compile 'com.marklogic:marklogic-data-hub:" + version + "'"); + FileUtils.writeStringToFile(buildGradle, text); + + hubConfig.getHubSecurityDir().resolve("roles").resolve("data-hub-user.json").toFile().delete(); + } + + // update legacy flows to include main.(sjs|xqy) + List flows = FlowManager.create(hubConfig).updateLegacyFlows(currentVersion); + if (updatedFlows != null) { + updatedFlows.addAll(flows); + } + + if (isHubInstalled) { + // install hub modules into MarkLogic + this.install(); + } + + result = true; + } + catch(IOException e) { + e.printStackTrace(); + } + return result; + } } diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/DataHubUpgrader.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/DataHubUpgrader.java deleted file mode 100644 index 8e15046082..0000000000 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/DataHubUpgrader.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2012-2018 MarkLogic Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.marklogic.hub; - -import com.marklogic.hub.error.CantUpgradeException; -import com.marklogic.hub.util.Versions; -import org.apache.commons.io.FileUtils; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Paths; -import java.util.List; -import java.util.regex.Pattern; - -public class DataHubUpgrader { - - public static String MIN_UPGRADE_VERSION = "1.1.3"; - - private HubConfig hubConfig; - private DataHub dataHub; - - public DataHubUpgrader(HubConfig hubConfig) { - this.hubConfig = hubConfig; - this.dataHub = new DataHub(hubConfig); - } - - public boolean upgradeHub() throws CantUpgradeException { - return upgradeHub(null); - } - - public boolean upgradeHub(List updatedFlows) throws CantUpgradeException { - boolean isHubInstalled = dataHub.isInstalled().isInstalled(); - - String currentVersion = new Versions(hubConfig).getHubVersion(); - int compare = Versions.compare(currentVersion, MIN_UPGRADE_VERSION); - if (compare == -1) { - throw new CantUpgradeException(currentVersion, MIN_UPGRADE_VERSION); - } - - boolean result = false; - boolean alreadyInitialized = hubConfig.getHubProject().isInitialized(); - File buildGradle = Paths.get(hubConfig.getProjectDir(), "build.gradle").toFile(); - try { - // update the hub-internal-config files - hubConfig.initHubProject(); - - if (alreadyInitialized) { - // replace the hub version in build.gradle - String text = FileUtils.readFileToString(buildGradle); - String version = hubConfig.getJarVersion(); - text = Pattern.compile("^(\\s*)id\\s+['\"]com.marklogic.ml-data-hub['\"]\\s+version.+$", Pattern.MULTILINE).matcher(text).replaceAll("$1id 'com.marklogic.ml-data-hub' version '" + version + "'"); - text = Pattern.compile("^(\\s*)compile.+marklogic-data-hub.+$", Pattern.MULTILINE).matcher(text).replaceAll("$1compile 'com.marklogic:marklogic-data-hub:" + version + "'"); - FileUtils.writeStringToFile(buildGradle, text); - - hubConfig.getHubSecurityDir().resolve("roles").resolve("data-hub-user.json").toFile().delete(); - } - - // update legacy flows to include main.(sjs|xqy) - List flows = FlowManager.create(hubConfig).updateLegacyFlows(currentVersion); - if (updatedFlows != null) { - updatedFlows.addAll(flows); - } - - if (isHubInstalled) { - // install hub modules into MarkLogic - dataHub.install(); - } - - result = true; - } - catch(IOException e) { - e.printStackTrace(); - } - return result; - } - -} diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/HubDatabase.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/HubDatabase.java deleted file mode 100644 index 821e77af27..0000000000 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/HubDatabase.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2012-2018 MarkLogic Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.marklogic.hub; - -public enum HubDatabase { - STAGING("staging"), - FINAL("final"); - - private String type; - HubDatabase(String type) { - this.type = type; - } - - public static HubDatabase getHubDatabase(String database) { - for (HubDatabase hubDatabase : HubDatabase.values()) { - if (hubDatabase.toString().equals(database)) { - return hubDatabase; - } - } - return null; - } - - public String toString() { - return this.type; - } -} diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/InstallInfo.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/InstallInfo.java index 1ab56ad1ad..758ac4240d 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/InstallInfo.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/InstallInfo.java @@ -16,70 +16,70 @@ package com.marklogic.hub; public class InstallInfo { - public boolean stagingAppServerExists = false; - public boolean finalAppServerExists = false; - public boolean traceAppServerExists = false; - public boolean jobAppServerExists = false; - - public boolean stagingDbExists = false; - public boolean finalDbExists = false; - public boolean traceDbExists = false; - public boolean jobDbExists = false; - - public boolean stagingTripleIndexOn = false; - public boolean stagingCollectionLexiconOn = false; - public boolean finalTripleIndexOn = false; - public boolean finalCollectionLexiconOn = false; - - public boolean stagingForestsExist = false; - public boolean finalForestsExist = false; - public boolean traceForestsExist = false; - public boolean jobForestsExist = false; + private boolean stagingAppServerExists = false; + private boolean finalAppServerExists = false; + private boolean traceAppServerExists = false; + private boolean jobAppServerExists = false; + + private boolean stagingDbExists = false; + private boolean finalDbExists = false; + private boolean traceDbExists = false; + private boolean jobDbExists = false; + + private boolean stagingTripleIndexOn = false; + private boolean stagingCollectionLexiconOn = false; + private boolean finalTripleIndexOn = false; + private boolean finalCollectionLexiconOn = false; + + private boolean stagingForestsExist = false; + private boolean finalForestsExist = false; + private boolean traceForestsExist = false; + private boolean jobForestsExist = false; public boolean isPartiallyInstalled() { return ( - stagingAppServerExists || - finalAppServerExists || - traceAppServerExists || - jobAppServerExists || - stagingDbExists || - stagingTripleIndexOn || - stagingCollectionLexiconOn || - finalDbExists || - finalTripleIndexOn || - finalCollectionLexiconOn || - traceDbExists || - jobDbExists || - stagingForestsExist || - finalForestsExist || - traceForestsExist || - jobForestsExist + isStagingAppServerExists() || + isFinalAppServerExists() || + isTraceAppServerExists() || + isJobAppServerExists() || + isStagingDbExists() || + isStagingTripleIndexOn() || + isStagingCollectionLexiconOn() || + isFinalDbExists() || + isFinalTripleIndexOn() || + isFinalCollectionLexiconOn() || + isTraceDbExists() || + isJobDbExists() || + isStagingForestsExist() || + isFinalForestsExist() || + isTraceForestsExist() || + isJobForestsExist() ); } public boolean isInstalled() { boolean appserversOk = ( - stagingAppServerExists && - finalAppServerExists && - traceAppServerExists && - jobAppServerExists + isStagingAppServerExists() && + isFinalAppServerExists() && + isTraceAppServerExists() && + isJobAppServerExists() ); boolean dbsOk = ( - stagingDbExists && - stagingTripleIndexOn && - stagingCollectionLexiconOn && - finalDbExists && - finalTripleIndexOn && - finalCollectionLexiconOn && - traceDbExists && - jobDbExists + isStagingDbExists() && + isStagingTripleIndexOn() && + isStagingCollectionLexiconOn() && + isFinalDbExists() && + isFinalTripleIndexOn() && + isFinalCollectionLexiconOn() && + isTraceDbExists() && + isJobDbExists() ); boolean forestsOk = ( - stagingForestsExist && - finalForestsExist && - traceForestsExist && - jobForestsExist + isStagingForestsExist() && + isFinalForestsExist() && + isTraceForestsExist() && + isJobForestsExist() ); return (appserversOk && dbsOk && forestsOk); @@ -89,27 +89,154 @@ public String toString() { return "\n" + "Checking MarkLogic Installation:\n" + "\tAppServers:\n" + - "\t\tStaging: " + (stagingAppServerExists ? "exists" : "MISSING") + "\n" + - "\t\tFinal: " + (finalAppServerExists? "exists" : "MISSING") + "\n" + - "\t\tTrace: " + (traceAppServerExists? "exists" : "MISSING") + "\n" + - "\t\tJob: " + (jobAppServerExists? "exists" : "MISSING") + "\n" + + "\t\tStaging: " + (isStagingAppServerExists() ? "exists" : "MISSING") + "\n" + + "\t\tFinal: " + (isFinalAppServerExists() ? "exists" : "MISSING") + "\n" + + "\t\tTrace: " + (isTraceAppServerExists() ? "exists" : "MISSING") + "\n" + + "\t\tJob: " + (isJobAppServerExists() ? "exists" : "MISSING") + "\n" + "\tDatabases:\n" + - "\t\tStaging: " + (stagingDbExists ? "exists" : "MISSING") + "\n" + - "\t\tFinal: " + (finalDbExists? "exists" : "MISSING") + "\n" + - "\t\tTrace: " + (traceDbExists ? "exists" : "MISSING") + "\n" + - "\t\tJob: " + (jobDbExists ? "exists" : "MISSING") + "\n" + + "\t\tStaging: " + (isStagingDbExists() ? "exists" : "MISSING") + "\n" + + "\t\tFinal: " + (isFinalDbExists() ? "exists" : "MISSING") + "\n" + + "\t\tTrace: " + (isTraceDbExists() ? "exists" : "MISSING") + "\n" + + "\t\tJob: " + (isJobDbExists() ? "exists" : "MISSING") + "\n" + "\tDatabases Indexes:\n" + - "\t\tStaging Triples Index : " + (stagingTripleIndexOn ? "exists" : "MISSING") + "\n" + - "\t\tStaging Collection Lexicon : " + (stagingCollectionLexiconOn ? "exists" : "MISSING") + "\n" + - "\t\tFinal Triples Index : " + (finalTripleIndexOn ? "exists" : "MISSING") + "\n" + - "\t\tFinal Collection Lexicon : " + (finalCollectionLexiconOn ? "exists" : "MISSING") + "\n" + + "\t\tStaging Triples Index : " + (isStagingTripleIndexOn() ? "exists" : "MISSING") + "\n" + + "\t\tStaging Collection Lexicon : " + (isStagingCollectionLexiconOn() ? "exists" : "MISSING") + "\n" + + "\t\tFinal Triples Index : " + (isFinalTripleIndexOn() ? "exists" : "MISSING") + "\n" + + "\t\tFinal Collection Lexicon : " + (isFinalCollectionLexiconOn() ? "exists" : "MISSING") + "\n" + "\tForests\n" + - "\t\tStaging: " + (stagingForestsExist ? "exists" : "MISSING") + "\n" + - "\t\tFinal: " + (finalForestsExist ? "exists" : "MISSING") + "\n" + - "\t\tTrace: " + (traceForestsExist ? "exists" : "MISSING") + "\n" + - "\t\tJob: " + (jobForestsExist ? "exists" : "MISSING") + "\n" + + "\t\tStaging: " + (isStagingForestsExist() ? "exists" : "MISSING") + "\n" + + "\t\tFinal: " + (isFinalForestsExist() ? "exists" : "MISSING") + "\n" + + "\t\tTrace: " + (isTraceForestsExist() ? "exists" : "MISSING") + "\n" + + "\t\tJob: " + (isJobForestsExist() ? "exists" : "MISSING") + "\n" + "\n\n" + "OVERAL RESULT: " + (isInstalled() ? "INSTALLED" : "NOT INSTALLED") + "\n"; } + public boolean isStagingAppServerExists() { + return stagingAppServerExists; + } + + public void setStagingAppServerExists(boolean stagingAppServerExists) { + this.stagingAppServerExists = stagingAppServerExists; + } + + public boolean isFinalAppServerExists() { + return finalAppServerExists; + } + + public void setFinalAppServerExists(boolean finalAppServerExists) { + this.finalAppServerExists = finalAppServerExists; + } + + public boolean isTraceAppServerExists() { + return traceAppServerExists; + } + + public void setTraceAppServerExists(boolean traceAppServerExists) { + this.traceAppServerExists = traceAppServerExists; + } + + public boolean isJobAppServerExists() { + return jobAppServerExists; + } + + public void setJobAppServerExists(boolean jobAppServerExists) { + this.jobAppServerExists = jobAppServerExists; + } + + public boolean isStagingDbExists() { + return stagingDbExists; + } + + public void setStagingDbExists(boolean stagingDbExists) { + this.stagingDbExists = stagingDbExists; + } + + public boolean isFinalDbExists() { + return finalDbExists; + } + + public void setFinalDbExists(boolean finalDbExists) { + this.finalDbExists = finalDbExists; + } + + public boolean isTraceDbExists() { + return traceDbExists; + } + + public void setTraceDbExists(boolean traceDbExists) { + this.traceDbExists = traceDbExists; + } + + public boolean isJobDbExists() { + return jobDbExists; + } + + public void setJobDbExists(boolean jobDbExists) { + this.jobDbExists = jobDbExists; + } + + public boolean isStagingTripleIndexOn() { + return stagingTripleIndexOn; + } + + public void setStagingTripleIndexOn(boolean stagingTripleIndexOn) { + this.stagingTripleIndexOn = stagingTripleIndexOn; + } + + public boolean isStagingCollectionLexiconOn() { + return stagingCollectionLexiconOn; + } + + public void setStagingCollectionLexiconOn(boolean stagingCollectionLexiconOn) { + this.stagingCollectionLexiconOn = stagingCollectionLexiconOn; + } + + public boolean isFinalTripleIndexOn() { + return finalTripleIndexOn; + } + + public void setFinalTripleIndexOn(boolean finalTripleIndexOn) { + this.finalTripleIndexOn = finalTripleIndexOn; + } + + public boolean isFinalCollectionLexiconOn() { + return finalCollectionLexiconOn; + } + + public void setFinalCollectionLexiconOn(boolean finalCollectionLexiconOn) { + this.finalCollectionLexiconOn = finalCollectionLexiconOn; + } + + public boolean isStagingForestsExist() { + return stagingForestsExist; + } + + public void setStagingForestsExist(boolean stagingForestsExist) { + this.stagingForestsExist = stagingForestsExist; + } + + public boolean isFinalForestsExist() { + return finalForestsExist; + } + + public void setFinalForestsExist(boolean finalForestsExist) { + this.finalForestsExist = finalForestsExist; + } + + public boolean isTraceForestsExist() { + return traceForestsExist; + } + + public void setTraceForestsExist(boolean traceForestsExist) { + this.traceForestsExist = traceForestsExist; + } + + public boolean isJobForestsExist() { + return jobForestsExist; + } + + public void setJobForestsExist(boolean jobForestsExist) { + this.jobForestsExist = jobForestsExist; + } } diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/collector/Collector.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/collector/Collector.java index e9f6323350..213985cd5a 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/collector/Collector.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/collector/Collector.java @@ -17,14 +17,9 @@ import com.marklogic.client.DatabaseClient; import com.marklogic.hub.HubConfig; -import com.marklogic.hub.HubDatabase; import com.marklogic.hub.flow.CodeFormat; -import com.marklogic.hub.flow.FlowType; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamWriter; import java.util.Map; -import java.util.Properties; public interface Collector { diff --git a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/UpdateHubTask.groovy b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/UpdateHubTask.groovy index 3a823b8767..f4dc6456f6 100644 --- a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/UpdateHubTask.groovy +++ b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/UpdateHubTask.groovy @@ -1,6 +1,6 @@ package com.marklogic.gradle.task -import com.marklogic.hub.DataHubUpgrader +import com.marklogic.hub.DataHub import org.gradle.api.tasks.TaskAction class UpdateHubTask extends HubTask { @@ -9,7 +9,7 @@ class UpdateHubTask extends HubTask { void updateHub() { if (getFlowManager().getLegacyFlows().size() > 0) { def updatedFlows = new ArrayList() - new DataHubUpgrader(hubConfig).upgradeHub(updatedFlows) + new DataHub(hubConfig).upgradeHub(updatedFlows) println "Legacy Flows Updated:\n\t" + String.join("\n\t", updatedFlows) } diff --git a/quick-start/src/main/java/com/marklogic/quickstart/model/SearchQuery.java b/quick-start/src/main/java/com/marklogic/quickstart/model/SearchQuery.java index 1321b0181c..8e407a113c 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/model/SearchQuery.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/model/SearchQuery.java @@ -15,7 +15,7 @@ */ package com.marklogic.quickstart.model; -import com.marklogic.hub.HubDatabase; +import com.marklogic.hub.DataHub; import java.util.List; import java.util.Map; @@ -26,6 +26,6 @@ public class SearchQuery { public boolean entitiesOnly; public long start; public long count; - public HubDatabase database; + public DataHub.HubDatabase database; public Map> facets; } diff --git a/quick-start/src/main/java/com/marklogic/quickstart/service/DataHubService.java b/quick-start/src/main/java/com/marklogic/quickstart/service/DataHubService.java index f0514760c0..dfc04a23cd 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/service/DataHubService.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/service/DataHubService.java @@ -18,7 +18,6 @@ import com.marklogic.appdeployer.command.Command; import com.marklogic.appdeployer.impl.SimpleAppDeployer; import com.marklogic.hub.DataHub; -import com.marklogic.hub.DataHubUpgrader; import com.marklogic.hub.HubConfig; import com.marklogic.hub.deploy.commands.LoadUserModulesCommand; import com.marklogic.hub.deploy.util.HubDeployStatusListener; @@ -161,7 +160,7 @@ public String getLastDeployed(HubConfig config) { } public boolean updateHub(HubConfig config) throws IOException, CantUpgradeException { - boolean result = new DataHubUpgrader(config).upgradeHub(); + boolean result = new DataHub(config).upgradeHub(); if (result) { ConnectionAuthenticationToken authenticationToken = (ConnectionAuthenticationToken) SecurityContextHolder.getContext().getAuthentication(); if (authenticationToken != null) { diff --git a/quick-start/src/main/java/com/marklogic/quickstart/service/SearchService.java b/quick-start/src/main/java/com/marklogic/quickstart/service/SearchService.java index 7f64088e36..2f572f7a90 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/service/SearchService.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/service/SearchService.java @@ -23,8 +23,8 @@ import com.marklogic.client.query.QueryManager; import com.marklogic.client.query.StructuredQueryBuilder; import com.marklogic.client.query.StructuredQueryDefinition; +import com.marklogic.hub.DataHub; import com.marklogic.hub.HubConfig; -import com.marklogic.hub.HubDatabase; import com.marklogic.quickstart.model.SearchQuery; import javax.xml.namespace.QName; @@ -51,7 +51,7 @@ public SearchService(HubConfig hubConfig) { public StringHandle search(SearchQuery searchQuery) { QueryManager queryMgr; String dbPrefix; - if (searchQuery.database.equals(HubDatabase.STAGING)) { + if (searchQuery.database.equals(DataHub.HubDatabase.STAGING)) { queryMgr = stagingQueryMgr; dbPrefix = "staging-"; } @@ -104,9 +104,9 @@ public StringHandle search(SearchQuery searchQuery) { return queryMgr.search(sqd, sh, searchQuery.start); } - public String getDoc(HubDatabase database, String docUri) { + public String getDoc(DataHub.HubDatabase database, String docUri) { GenericDocumentManager docMgr; - if (database.equals(HubDatabase.STAGING)) { + if (database.equals(DataHub.HubDatabase.STAGING)) { docMgr = stagingDocMgr; } else { diff --git a/quick-start/src/main/java/com/marklogic/quickstart/web/SearchController.java b/quick-start/src/main/java/com/marklogic/quickstart/web/SearchController.java index 1fbd689041..feec573269 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/web/SearchController.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/web/SearchController.java @@ -16,7 +16,7 @@ package com.marklogic.quickstart.web; import com.fasterxml.jackson.core.JsonProcessingException; -import com.marklogic.hub.HubDatabase; +import com.marklogic.hub.DataHub; import com.marklogic.quickstart.EnvironmentAware; import com.marklogic.quickstart.model.SearchQuery; import com.marklogic.quickstart.service.SearchService; @@ -52,7 +52,7 @@ public String search(@RequestBody SearchQuery searchQuery) throws JsonProcessing @RequestMapping(value = "/doc", method = RequestMethod.GET) @ResponseBody - public ResponseEntity getDoc(@RequestParam HubDatabase database, @RequestParam String docUri) { + public ResponseEntity getDoc(@RequestParam DataHub.HubDatabase database, @RequestParam String docUri) { HttpHeaders headers = new HttpHeaders(); String body = searchService.getDoc(database, docUri); if (body.startsWith("<")) { From 378b14d6b0ce8841434cc325bf17f2a374285382 Mon Sep 17 00:00:00 2001 From: Alexander Ebadirad Date: Fri, 16 Feb 2018 10:56:32 -0700 Subject: [PATCH 09/22] Hubproject interface creation --- .../java/com/marklogic/hub/HubProject.java | 247 ++--------------- .../com/marklogic/hub/impl/HubConfigImpl.java | 2 +- .../marklogic/hub/impl/HubProjectImpl.java | 252 ++++++++++++++++++ .../marklogic/quickstart/model/Project.java | 2 +- .../quickstart/service/TraceServiceTest.java | 2 +- 5 files changed, 277 insertions(+), 228 deletions(-) create mode 100644 marklogic-data-hub/src/main/java/com/marklogic/hub/impl/HubProjectImpl.java diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/HubProject.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/HubProject.java index ed4afe3421..706faf7202 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/HubProject.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/HubProject.java @@ -1,255 +1,52 @@ -/* - * Copyright 2012-2018 MarkLogic Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ package com.marklogic.hub; -import com.marklogic.hub.util.FileUtil; -import org.apache.commons.io.IOUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import com.marklogic.hub.impl.HubProjectImpl; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStream; -import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; -import java.nio.file.StandardCopyOption; -import java.nio.file.attribute.PosixFilePermission; -import java.util.HashMap; -import java.util.HashSet; import java.util.Map; -import java.util.Set; -/** - * Class for creating a hub Project - */ -public class HubProject { +public interface HubProject { + String HUB_CONFIG_DIR = "hub-internal-config"; + String USER_CONFIG_DIR = "user-config"; - public static final String HUB_CONFIG_DIR = "hub-internal-config"; - public static final String USER_CONFIG_DIR = "user-config"; - public static final String ENTITY_CONFIG_DIR = "entity-config"; - - private Path projectDir; - private Path pluginsDir; - - protected final Logger logger = LoggerFactory.getLogger(this.getClass()); - - public HubProject(String projectDirStr) { - this.projectDir = Paths.get(projectDirStr).toAbsolutePath(); - this.pluginsDir = this.projectDir.resolve("plugins"); + static HubProject create(String projectDirStr) { + return new HubProjectImpl(projectDirStr); } - public Path getHubPluginsDir() { - return this.pluginsDir; - } + Path getHubPluginsDir(); - public Path getHubEntitiesDir() { - return this.pluginsDir.resolve("entities"); - } + Path getHubEntitiesDir(); - public Path getHubConfigDir() { - return this.projectDir.resolve(HUB_CONFIG_DIR); - } + Path getHubConfigDir(); - public Path getHubDatabaseDir() { - return getHubConfigDir().resolve("databases"); - } + Path getHubDatabaseDir(); - public Path getHubServersDir() { - return getHubConfigDir().resolve("servers"); - } + Path getHubServersDir(); - public Path getHubSecurityDir() { - return getHubConfigDir().resolve("security"); - } + Path getHubSecurityDir(); - public Path getHubMimetypesDir() { - return getHubConfigDir().resolve("mimetypes"); - } + Path getHubMimetypesDir(); - public Path getUserConfigDir() { - return this.projectDir.resolve(USER_CONFIG_DIR); - } + Path getUserConfigDir(); - public Path getUserSecurityDir() { - return getUserConfigDir().resolve("security"); - } + Path getUserSecurityDir(); - public Path getUserDatabaseDir() { - return getUserConfigDir().resolve("databases"); - } + Path getUserDatabaseDir(); - public Path getUserSchemasDir() { - return getUserConfigDir().resolve("schemas"); - } + Path getUserSchemasDir(); - public Path getUserServersDir() { - return getUserConfigDir().resolve("servers"); - } + Path getUserServersDir(); - public Path getEntityConfigDir() { - return this.projectDir.resolve(ENTITY_CONFIG_DIR); - } + Path getEntityConfigDir(); - public Path getEntityDatabaseDir() { - return getEntityConfigDir().resolve("databases"); - } + Path getEntityDatabaseDir(); - - - public boolean isInitialized() { - File buildGradle = this.projectDir.resolve("build.gradle").toFile(); - File gradleProperties = this.projectDir.resolve("gradle.properties").toFile(); - - File hubConfigDir = getHubConfigDir().toFile(); - File userConfigDir = getUserConfigDir().toFile(); - File databasesDir = getHubDatabaseDir().toFile(); - File serversDir = getHubServersDir().toFile(); - File securityDir = getHubSecurityDir().toFile(); - - boolean newConfigInitialized = - hubConfigDir.exists() && - hubConfigDir.isDirectory() && - userConfigDir.exists() && - userConfigDir.isDirectory() && - databasesDir.exists() && - databasesDir.isDirectory() && - serversDir.exists() && - serversDir.isDirectory() && - securityDir.exists() && - securityDir.isDirectory(); - - return buildGradle.exists() && - gradleProperties.exists() && - newConfigInitialized; - } + boolean isInitialized(); /** * Initializes a directory as a hub project directory. * This means putting certain files and folders in place. * @param customTokens - some custom tokens to start with */ - public void init(Map customTokens) { - this.pluginsDir.toFile().mkdirs(); - - Path serversDir = getHubServersDir(); - serversDir.toFile().mkdirs(); - writeResourceFile("ml-config/servers/staging-server.json", serversDir.resolve("staging-server.json"), true); - writeResourceFile("ml-config/servers/final-server.json", serversDir.resolve("final-server.json"), true); - writeResourceFile("ml-config/servers/trace-server.json", serversDir.resolve("trace-server.json"), true); - writeResourceFile("ml-config/servers/job-server.json", serversDir.resolve("job-server.json"), true); - - Path databasesDir = getHubDatabaseDir(); - databasesDir.toFile().mkdirs(); - writeResourceFile("ml-config/databases/staging-database.json", databasesDir.resolve("staging-database.json"), true); - writeResourceFile("ml-config/databases/final-database.json", databasesDir.resolve("final-database.json"), true); - writeResourceFile("ml-config/databases/trace-database.json", databasesDir.resolve("trace-database.json"), true); - writeResourceFile("ml-config/databases/job-database.json", databasesDir.resolve("job-database.json"), true); - writeResourceFile("ml-config/databases/modules-database.json", databasesDir.resolve("modules-database.json"), true); - writeResourceFile("ml-config/databases/schemas-database.json", databasesDir.resolve("schemas-database.json"), true); - writeResourceFile("ml-config/databases/triggers-database.json", databasesDir.resolve("triggers-database.json"), true); - - Path securityDir = getHubSecurityDir(); - Path rolesDir = securityDir.resolve("roles"); - Path usersDir = securityDir.resolve("users"); - - rolesDir.toFile().mkdirs(); - usersDir.toFile().mkdirs(); - - writeResourceFile("ml-config/security/roles/data-hub-role.json", rolesDir.resolve("data-hub-role.json"), true); - writeResourceFile("ml-config/security/users/data-hub-user.json", usersDir.resolve("data-hub-user.json"), true); - - Path mimetypesDir = getHubMimetypesDir(); - mimetypesDir.toFile().mkdirs(); - writeResourceFile("ml-config/mimetypes/woff.json", mimetypesDir.resolve("woff.json"), true); - writeResourceFile("ml-config/mimetypes/woff2.json", mimetypesDir.resolve("woff2.json"), true); - - getUserServersDir().toFile().mkdirs(); - getUserDatabaseDir().toFile().mkdirs(); - - Path gradlew = projectDir.resolve("gradlew"); - writeResourceFile("scaffolding/gradlew", gradlew); - makeExecutable(gradlew); - - Path gradlewbat = projectDir.resolve("gradlew.bat"); - writeResourceFile("scaffolding/gradlew.bat", gradlewbat); - makeExecutable(gradlewbat); - - Path gradleWrapperDir = projectDir.resolve("gradle").resolve("wrapper"); - gradleWrapperDir.toFile().mkdirs(); - - writeResourceFile("scaffolding/gradle/wrapper/gradle-wrapper.jar", gradleWrapperDir.resolve("gradle-wrapper.jar")); - writeResourceFile("scaffolding/gradle/wrapper/gradle-wrapper.properties", gradleWrapperDir.resolve("gradle-wrapper.properties")); - - writeResourceFile("scaffolding/build_gradle", projectDir.resolve("build.gradle")); - writeResourceFileWithReplace(customTokens, "scaffolding/gradle_properties", projectDir.resolve("gradle.properties")); - writeResourceFile("scaffolding/gradle-local_properties", projectDir.resolve("gradle-local.properties")); - } - - private void makeExecutable(Path file) { - Set perms = new HashSet<>(); - perms.add(PosixFilePermission.OWNER_READ); - perms.add(PosixFilePermission.OWNER_WRITE); - perms.add(PosixFilePermission.OWNER_EXECUTE); - - try { - Files.setPosixFilePermissions(file, perms); - } catch (Exception e) { - - } - } - - private void writeResourceFile(String srcFile, Path dstFile) { - writeResourceFile(srcFile, dstFile, false); - } - - private void writeResourceFile(String srcFile, Path dstFile, boolean overwrite) { - if (overwrite || !dstFile.toFile().exists()) { - logger.info("Getting file: " + srcFile); - InputStream inputStream = HubProject.class.getClassLoader().getResourceAsStream(srcFile); - FileUtil.copy(inputStream, dstFile.toFile()); - } - } - - private void writeResourceFileWithReplace(Map customTokens, String srcFile, Path dstFile) { - writeResourceFileWithReplace(customTokens, srcFile, dstFile, false); - } - - private void writeResourceFileWithReplace(Map customTokens, String srcFile, Path dstFile, boolean overwrite) { - try { - if (overwrite || !dstFile.toFile().exists()) { - logger.info("Getting file with Replace: " + srcFile); - InputStream inputStream = HubProject.class.getClassLoader().getResourceAsStream(srcFile); - - String fileContents = IOUtils.toString(inputStream); - for (String key : customTokens.keySet()) { - - String value = customTokens.get(key); - if (value != null) { - fileContents = fileContents.replace(key, value); - } - } - FileWriter writer = new FileWriter(dstFile.toFile()); - writer.write(fileContents); - writer.close(); - } - } - catch(IOException e) { - throw new RuntimeException(e); - } - } + void init(Map customTokens); } diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/HubConfigImpl.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/HubConfigImpl.java index cfa5340082..32685342e8 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/HubConfigImpl.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/HubConfigImpl.java @@ -570,7 +570,7 @@ public String getProjectDir() { public void setProjectDir(String projectDir) { this.projectDir = projectDir; - this.hubProject = new HubProject(projectDir); + this.hubProject = HubProject.create(projectDir); } @JsonIgnore diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/HubProjectImpl.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/HubProjectImpl.java new file mode 100644 index 0000000000..bbf267d46f --- /dev/null +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/HubProjectImpl.java @@ -0,0 +1,252 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.marklogic.hub.impl; + +import com.marklogic.hub.HubProject; +import com.marklogic.hub.util.FileUtil; +import org.apache.commons.io.IOUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.attribute.PosixFilePermission; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +/** + * Class for creating a hub Project + */ +public class HubProjectImpl implements HubProject { + + public static final String ENTITY_CONFIG_DIR = "entity-config"; + + private Path projectDir; + private Path pluginsDir; + + protected final Logger logger = LoggerFactory.getLogger(this.getClass()); + + public HubProjectImpl(String projectDirStr) { + this.projectDir = Paths.get(projectDirStr).toAbsolutePath(); + this.pluginsDir = this.projectDir.resolve("plugins"); + } + + @Override public Path getHubPluginsDir() { + return this.pluginsDir; + } + + @Override public Path getHubEntitiesDir() { + return this.pluginsDir.resolve("entities"); + } + + @Override public Path getHubConfigDir() { + return this.projectDir.resolve(HUB_CONFIG_DIR); + } + + @Override public Path getHubDatabaseDir() { + return getHubConfigDir().resolve("databases"); + } + + @Override public Path getHubServersDir() { + return getHubConfigDir().resolve("servers"); + } + + @Override public Path getHubSecurityDir() { + return getHubConfigDir().resolve("security"); + } + + @Override public Path getHubMimetypesDir() { + return getHubConfigDir().resolve("mimetypes"); + } + + @Override public Path getUserConfigDir() { + return this.projectDir.resolve(USER_CONFIG_DIR); + } + + @Override public Path getUserSecurityDir() { + return getUserConfigDir().resolve("security"); + } + + @Override public Path getUserDatabaseDir() { + return getUserConfigDir().resolve("databases"); + } + + @Override public Path getUserSchemasDir() { + return getUserConfigDir().resolve("schemas"); + } + + @Override public Path getUserServersDir() { + return getUserConfigDir().resolve("servers"); + } + + @Override public Path getEntityConfigDir() { + return this.projectDir.resolve(ENTITY_CONFIG_DIR); + } + + @Override public Path getEntityDatabaseDir() { + return getEntityConfigDir().resolve("databases"); + } + + + + @Override public boolean isInitialized() { + File buildGradle = this.projectDir.resolve("build.gradle").toFile(); + File gradleProperties = this.projectDir.resolve("gradle.properties").toFile(); + + File hubConfigDir = getHubConfigDir().toFile(); + File userConfigDir = getUserConfigDir().toFile(); + File databasesDir = getHubDatabaseDir().toFile(); + File serversDir = getHubServersDir().toFile(); + File securityDir = getHubSecurityDir().toFile(); + + boolean newConfigInitialized = + hubConfigDir.exists() && + hubConfigDir.isDirectory() && + userConfigDir.exists() && + userConfigDir.isDirectory() && + databasesDir.exists() && + databasesDir.isDirectory() && + serversDir.exists() && + serversDir.isDirectory() && + securityDir.exists() && + securityDir.isDirectory(); + + return buildGradle.exists() && + gradleProperties.exists() && + newConfigInitialized; + } + + /** + * Initializes a directory as a hub project directory. + * This means putting certain files and folders in place. + * @param customTokens - some custom tokens to start with + */ + @Override public void init(Map customTokens) { + this.pluginsDir.toFile().mkdirs(); + + Path serversDir = getHubServersDir(); + serversDir.toFile().mkdirs(); + writeResourceFile("ml-config/servers/staging-server.json", serversDir.resolve("staging-server.json"), true); + writeResourceFile("ml-config/servers/final-server.json", serversDir.resolve("final-server.json"), true); + writeResourceFile("ml-config/servers/trace-server.json", serversDir.resolve("trace-server.json"), true); + writeResourceFile("ml-config/servers/job-server.json", serversDir.resolve("job-server.json"), true); + + Path databasesDir = getHubDatabaseDir(); + databasesDir.toFile().mkdirs(); + writeResourceFile("ml-config/databases/staging-database.json", databasesDir.resolve("staging-database.json"), true); + writeResourceFile("ml-config/databases/final-database.json", databasesDir.resolve("final-database.json"), true); + writeResourceFile("ml-config/databases/trace-database.json", databasesDir.resolve("trace-database.json"), true); + writeResourceFile("ml-config/databases/job-database.json", databasesDir.resolve("job-database.json"), true); + writeResourceFile("ml-config/databases/modules-database.json", databasesDir.resolve("modules-database.json"), true); + writeResourceFile("ml-config/databases/schemas-database.json", databasesDir.resolve("schemas-database.json"), true); + writeResourceFile("ml-config/databases/triggers-database.json", databasesDir.resolve("triggers-database.json"), true); + + Path securityDir = getHubSecurityDir(); + Path rolesDir = securityDir.resolve("roles"); + Path usersDir = securityDir.resolve("users"); + + rolesDir.toFile().mkdirs(); + usersDir.toFile().mkdirs(); + + writeResourceFile("ml-config/security/roles/data-hub-role.json", rolesDir.resolve("data-hub-role.json"), true); + writeResourceFile("ml-config/security/users/data-hub-user.json", usersDir.resolve("data-hub-user.json"), true); + + Path mimetypesDir = getHubMimetypesDir(); + mimetypesDir.toFile().mkdirs(); + writeResourceFile("ml-config/mimetypes/woff.json", mimetypesDir.resolve("woff.json"), true); + writeResourceFile("ml-config/mimetypes/woff2.json", mimetypesDir.resolve("woff2.json"), true); + + getUserServersDir().toFile().mkdirs(); + getUserDatabaseDir().toFile().mkdirs(); + + Path gradlew = projectDir.resolve("gradlew"); + writeResourceFile("scaffolding/gradlew", gradlew); + makeExecutable(gradlew); + + Path gradlewbat = projectDir.resolve("gradlew.bat"); + writeResourceFile("scaffolding/gradlew.bat", gradlewbat); + makeExecutable(gradlewbat); + + Path gradleWrapperDir = projectDir.resolve("gradle").resolve("wrapper"); + gradleWrapperDir.toFile().mkdirs(); + + writeResourceFile("scaffolding/gradle/wrapper/gradle-wrapper.jar", gradleWrapperDir.resolve("gradle-wrapper.jar")); + writeResourceFile("scaffolding/gradle/wrapper/gradle-wrapper.properties", gradleWrapperDir.resolve("gradle-wrapper.properties")); + + writeResourceFile("scaffolding/build_gradle", projectDir.resolve("build.gradle")); + writeResourceFileWithReplace(customTokens, "scaffolding/gradle_properties", projectDir.resolve("gradle.properties")); + writeResourceFile("scaffolding/gradle-local_properties", projectDir.resolve("gradle-local.properties")); + } + + private void makeExecutable(Path file) { + Set perms = new HashSet<>(); + perms.add(PosixFilePermission.OWNER_READ); + perms.add(PosixFilePermission.OWNER_WRITE); + perms.add(PosixFilePermission.OWNER_EXECUTE); + + try { + Files.setPosixFilePermissions(file, perms); + } catch (Exception e) { + + } + } + + private void writeResourceFile(String srcFile, Path dstFile) { + writeResourceFile(srcFile, dstFile, false); + } + + private void writeResourceFile(String srcFile, Path dstFile, boolean overwrite) { + if (overwrite || !dstFile.toFile().exists()) { + logger.info("Getting file: " + srcFile); + InputStream inputStream = HubProject.class.getClassLoader().getResourceAsStream(srcFile); + FileUtil.copy(inputStream, dstFile.toFile()); + } + } + + private void writeResourceFileWithReplace(Map customTokens, String srcFile, Path dstFile) { + writeResourceFileWithReplace(customTokens, srcFile, dstFile, false); + } + + private void writeResourceFileWithReplace(Map customTokens, String srcFile, Path dstFile, boolean overwrite) { + try { + if (overwrite || !dstFile.toFile().exists()) { + logger.info("Getting file with Replace: " + srcFile); + InputStream inputStream = HubProject.class.getClassLoader().getResourceAsStream(srcFile); + + String fileContents = IOUtils.toString(inputStream); + for (String key : customTokens.keySet()) { + + String value = customTokens.get(key); + if (value != null) { + fileContents = fileContents.replace(key, value); + } + } + FileWriter writer = new FileWriter(dstFile.toFile()); + writer.write(fileContents); + writer.close(); + } + } + catch(IOException e) { + throw new RuntimeException(e); + } + } +} diff --git a/quick-start/src/main/java/com/marklogic/quickstart/model/Project.java b/quick-start/src/main/java/com/marklogic/quickstart/model/Project.java index 32f430f9b1..a819d3d3c3 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/model/Project.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/model/Project.java @@ -35,7 +35,7 @@ public Project(int id, String path) { } public boolean isInitialized() { - return new HubProject(this.path).isInitialized(); + return HubProject.create(this.path).isInitialized(); } public List getEnvironments() { diff --git a/quick-start/src/test/java/com/marklogic/quickstart/service/TraceServiceTest.java b/quick-start/src/test/java/com/marklogic/quickstart/service/TraceServiceTest.java index 7cb7cf3fa6..ef3770b63e 100644 --- a/quick-start/src/test/java/com/marklogic/quickstart/service/TraceServiceTest.java +++ b/quick-start/src/test/java/com/marklogic/quickstart/service/TraceServiceTest.java @@ -53,7 +53,7 @@ public static void setupClass() throws IOException { enableTracing(); - Scaffolding scaffolding = new Scaffolding(projectDir.toString(), stagingClient); + Scaffolding scaffolding = Scaffolding.create(projectDir.toString(), stagingClient); scaffolding.createEntity(ENTITY); scaffolding.createFlow(ENTITY, "sjs-json-harmonize-flow", FlowType.HARMONIZE, CodeFormat.JAVASCRIPT, DataFormat.JSON); From 77730729e8f4ad14f2a099c79e0ca1f36bd323f2 Mon Sep 17 00:00:00 2001 From: Alexander Ebadirad Date: Fri, 16 Feb 2018 13:43:54 -0700 Subject: [PATCH 10/22] Refactoring datahub to use an interface for its base class --- .../main/java/com/marklogic/hub/DataHub.java | 559 +++--------------- .../com/marklogic/hub/impl/DataHubImpl.java | 559 ++++++++++++++++++ .../com/marklogic/hub/DataHubInstallTest.java | 2 +- .../java/com/marklogic/hub/DataHubTest.java | 3 +- .../java/com/marklogic/hub/HubTestBase.java | 2 +- .../hub/collector/EmptyCollectorTest.java | 2 +- .../hub/collector/StreamCollectorTest.java | 2 +- .../marklogic/hub/flow/FlowRunnerTest.java | 2 +- .../com/marklogic/gradle/DataHubPlugin.groovy | 2 +- .../gradle/task/UpdateHubTask.groovy | 2 +- .../quickstart/model/EnvironmentConfig.java | 2 +- .../marklogic/quickstart/model/Project.java | 2 +- .../quickstart/service/DataHubService.java | 16 +- .../quickstart/web/BaseTestController.java | 2 +- 14 files changed, 645 insertions(+), 512 deletions(-) create mode 100644 marklogic-data-hub/src/main/java/com/marklogic/hub/impl/DataHubImpl.java diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/DataHub.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/DataHub.java index d9a6336c28..264fb7ffd5 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/DataHub.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/DataHub.java @@ -1,149 +1,64 @@ -/* - * Copyright 2012-2018 MarkLogic Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ package com.marklogic.hub; -import com.marklogic.appdeployer.AppConfig; import com.marklogic.appdeployer.command.Command; -import com.marklogic.appdeployer.command.CommandMapBuilder; -import com.marklogic.appdeployer.command.appservers.DeployOtherServersCommand; -import com.marklogic.appdeployer.command.forests.DeployCustomForestsCommand; -import com.marklogic.client.FailedRequestException; -import com.marklogic.client.eval.ServerEvaluationCall; -import com.marklogic.hub.deploy.HubAppDeployer; -import com.marklogic.hub.deploy.commands.*; import com.marklogic.hub.deploy.util.HubDeployStatusListener; import com.marklogic.hub.error.CantUpgradeException; import com.marklogic.hub.error.ServerValidationException; +import com.marklogic.hub.impl.DataHubImpl; import com.marklogic.hub.util.Versions; import com.marklogic.mgmt.ManageClient; import com.marklogic.mgmt.admin.AdminManager; import com.marklogic.mgmt.resource.appservers.ServerManager; import com.marklogic.mgmt.resource.databases.DatabaseManager; -import com.marklogic.rest.util.Fragment; -import com.marklogic.rest.util.ResourcesFragment; -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.core.io.Resource; -import org.springframework.core.io.support.PathMatchingResourcePatternResolver; -import org.springframework.core.io.support.ResourcePatternResolver; -import java.io.File; -import java.io.IOException; -import java.nio.file.Paths; -import java.text.SimpleDateFormat; -import java.util.*; -import java.util.regex.Pattern; +import java.util.List; -public class DataHub { +public interface DataHub { - private ManageClient _manageClient; - private DatabaseManager _databaseManager; - private ServerManager _serverManager; - private HubConfig hubConfig; - - private AdminManager _adminManager; - - protected final Logger logger = LoggerFactory.getLogger(this.getClass()); + static DataHub create(HubConfig hubConfig) { + return new DataHubImpl(hubConfig); + } + //HubDatabase stuff goes here + enum HubDatabase { + STAGING("staging"), + FINAL("final"); - public DataHub(HubConfig hubConfig) { - this.hubConfig = hubConfig; - } + private String type; - public ManageClient getManageClient() { - if (this._manageClient == null) { - this._manageClient = hubConfig.getManageClient(); + HubDatabase(String type) { + this.type = type; } - return this._manageClient; - } - public AdminManager getAdminManager() { - if (this._adminManager == null) { - this._adminManager = hubConfig.getAdminManager(); + public static HubDatabase getHubDatabase(String database) { + for (HubDatabase hubDatabase : HubDatabase.values()) { + if (hubDatabase.toString().equals(database)) { + return hubDatabase; + } + } + return null; } - return this._adminManager; - } - void setAdminManager(AdminManager manager) { - this._adminManager = manager; - } - public DatabaseManager getDatabaseManager() { - if (this._databaseManager == null) { - this._databaseManager = new DatabaseManager(getManageClient()); + public String toString() { + return this.type; } - return this._databaseManager; } - public ServerManager getServerManager() { - if (this._serverManager == null) { - this._serverManager = new ServerManager(getManageClient()); - } - return this._serverManager; - } - void setServerManager(ServerManager manager) { this._serverManager = manager; } - /** - * Determines if the data hub is installed in MarkLogic - * @return true if installed, false otherwise - */ - public InstallInfo isInstalled() { - - InstallInfo installInfo = new InstallInfo(); - - ResourcesFragment srf = getServerManager().getAsXml(); - installInfo.setStagingAppServerExists(srf.resourceExists(hubConfig.getStagingHttpName())); - installInfo.setFinalAppServerExists(srf.resourceExists(hubConfig.getFinalHttpName())); - installInfo.setTraceAppServerExists(srf.resourceExists(hubConfig.getTraceHttpName())); - installInfo.setJobAppServerExists(srf.resourceExists(hubConfig.getJobHttpName())); - - ResourcesFragment drf = getDatabaseManager().getAsXml(); - installInfo.setStagingDbExists(drf.resourceExists(hubConfig.getStagingDbName())); - installInfo.setFinalDbExists(drf.resourceExists(hubConfig.getFinalDbName())); - installInfo.setTraceDbExists(drf.resourceExists(hubConfig.getTraceDbName())); - installInfo.setJobDbExists(drf.resourceExists(hubConfig.getJobDbName())); - - if (installInfo.isStagingDbExists()) { - Fragment f = getDatabaseManager().getPropertiesAsXml(hubConfig.getStagingDbName()); - installInfo.setStagingTripleIndexOn(Boolean.parseBoolean(f.getElementValue("//m:triple-index"))); - installInfo.setStagingCollectionLexiconOn(Boolean.parseBoolean(f.getElementValue("//m:collection-lexicon"))); - installInfo.setStagingForestsExist((f.getElements("//m:forest").size() > 0)); - } + ManageClient getManageClient(); - if (installInfo.isFinalDbExists()) { - Fragment f = getDatabaseManager().getPropertiesAsXml(hubConfig.getFinalDbName()); - installInfo.setFinalTripleIndexOn(Boolean.parseBoolean(f.getElementValue("//m:triple-index"))); - installInfo.setFinalCollectionLexiconOn(Boolean.parseBoolean(f.getElementValue("//m:collection-lexicon"))); - installInfo.setFinalForestsExist((f.getElements("//m:forest").size() > 0)); - } + AdminManager getAdminManager(); - if (installInfo.isTraceDbExists()) { - Fragment f = getDatabaseManager().getPropertiesAsXml(hubConfig.getTraceDbName()); - installInfo.setTraceForestsExist((f.getElements("//m:forest").size() > 0)); - } + DatabaseManager getDatabaseManager(); - if (installInfo.isJobDbExists()) { - Fragment f = getDatabaseManager().getPropertiesAsXml(hubConfig.getJobDbName()); - installInfo.setJobForestsExist((f.getElements("//m:forest").size() > 0)); - } + ServerManager getServerManager(); - logger.info(installInfo.toString()); + void setServerManager(ServerManager manager); - return installInfo; - } + /** + * Determines if the data hub is installed in MarkLogic + * @return true if installed, false otherwise + */ + InstallInfo isInstalled(); /** * Validates the MarkLogic server to ensure compatibility with the hub @@ -151,432 +66,90 @@ public InstallInfo isInstalled() { * @return true if valid, false otherwise * @throws ServerValidationException if the server is not compatible */ - public boolean isServerVersionValid(String versionString) { - try { - if (versionString == null) { - versionString = new Versions(hubConfig).getMarkLogicVersion(); - } - int major = Integer.parseInt(versionString.replaceAll("([^.]+)\\..*", "$1")); - if (major < 9) { - return false; - } - boolean isNightly = versionString.matches("[^-]+-(\\d{4})(\\d{2})(\\d{2})"); - if (major == 9) { - String alteredString = versionString.replaceAll("[^\\d]+", ""); - if (alteredString.length() < 4) { - alteredString = StringUtils.rightPad(alteredString, 4, "0"); - } - int ver = Integer.parseInt(alteredString.substring(0, 4)); - if (!isNightly && ver < 9011) { - return false; - } - } - if (isNightly) { - String dateString = versionString.replaceAll("[^-]+-(\\d{4})(\\d{2})(\\d{2})", "$1-$2-$3"); - Date minDate = new GregorianCalendar(2017, 6, 1).getTime(); - Date date = new SimpleDateFormat("y-M-d").parse(dateString); - if (date.before(minDate)) { - return false; - } - } - - } - catch(Exception e) { - throw new ServerValidationException(e.toString()); - } - return true; - } + boolean isServerVersionValid(String versionString); - public void initProject() { - logger.info("Initializing the Hub Project"); - hubConfig.initHubProject(); - } + void initProject(); /** * Removes user's modules from the modules db * TODO: this becomes much simpler when we move code into the server dir */ - public void clearUserModules() { - ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(DataHub.class.getClassLoader()); - try { - ArrayList options = new ArrayList<>(); - for (Resource r : resolver.getResources("classpath*:/ml-modules/options/*.xml")) { - options.add(r.getFilename().replace(".xml", "")); - } - for (Resource r : resolver.getResources("classpath*:/ml-modules-traces/options/*.xml")) { - options.add(r.getFilename().replace(".xml", "")); - } - for (Resource r : resolver.getResources("classpath*:/ml-modules-jobs/options/*.xml")) { - options.add(r.getFilename().replace(".xml", "")); - } + void clearUserModules(); - ArrayList services = new ArrayList<>(); - for (Resource r : resolver.getResources("classpath*:/ml-modules/services/*.xqy")) { - services.add(r.getFilename().replaceAll("\\.(xqy|sjs)", "")); - } + List getCommandList(); + void runPreInstallCheck(); - ArrayList transforms = new ArrayList<>(); - for (Resource r : resolver.getResources("classpath*:/ml-modules/transforms/*")) { - transforms.add(r.getFilename().replaceAll("\\.(xqy|sjs)", "")); - } - - String query = - "cts:uris((),(),cts:not-query(cts:collection-query('hub-core-module')))[\n" + - " fn:not(\n" + - " fn:matches(., \"^.+options/(" + String.join("|", options) + ").xml$\") or\n" + - " fn:matches(., \"/marklogic.rest.resource/(" + String.join("|", services) + ")/assets/(metadata\\.xml|resource\\.(xqy|sjs))\") or\n" + - " fn:matches(., \"/marklogic.rest.transform/(" + String.join("|", transforms) + ")/assets/(metadata\\.xml|transform\\.(xqy|sjs))\")\n" + - " )\n" + - "] ! xdmp:document-delete(.)\n"; - runInDatabase(query, hubConfig.getModulesDbName()); - } - catch(FailedRequestException e) { - logger.error("Failed to clear user modules"); - } catch (IOException e) { - e.printStackTrace(); - } - } - - public List getCommandList() { - Map> commandMap = getCommands(); - List commands = new ArrayList<>(); - for (String name : commandMap.keySet()) { - commands.addAll(commandMap.get(name)); - } - return commands; - } - - public void runPreInstallCheck() { - runPreInstallCheck(null); - } - - public void runPreInstallCheck(Versions versions) { - - Map portsInUse = getServerPortsInUse(); - Set ports = portsInUse.keySet(); - - String serverName = portsInUse.get(hubConfig.getStagingPort()); - stagingPortInUse = ports.contains(hubConfig.getStagingPort()) && serverName != null && !serverName.equals(hubConfig.getStagingHttpName()); - if (stagingPortInUse) { - stagingPortInUseBy = serverName; - } - - serverName = portsInUse.get(hubConfig.getFinalPort()); - finalPortInUse = ports.contains(hubConfig.getFinalPort()) && serverName != null && !serverName.equals(hubConfig.getFinalHttpName()); - if (finalPortInUse) { - finalPortInUseBy = serverName; - } - - serverName = portsInUse.get(hubConfig.getJobPort()); - jobPortInUse = ports.contains(hubConfig.getJobPort()) && serverName != null && !serverName.equals(hubConfig.getJobHttpName()); - if (jobPortInUse) { - jobPortInUseBy = serverName; - } - - serverName = portsInUse.get(hubConfig.getTracePort()); - tracePortInUse = ports.contains(hubConfig.getTracePort()) && serverName != null && !serverName.equals(hubConfig.getTraceHttpName()); - if (tracePortInUse) { - tracePortInUseBy = serverName; - } - - if (versions == null) { - versions = new Versions(hubConfig); - } - serverVersion = versions.getMarkLogicVersion(); - serverVersionOk = isServerVersionValid(serverVersion); - } + void runPreInstallCheck(Versions versions); /** * Installs the data hub configuration and server-side modules into MarkLogic */ - public void install() { - install(null); - } + void install(); /** * Installs the data hub configuration and server-side modules into MarkLogic * @param listener - the callback method to receive status updates */ - public void install(HubDeployStatusListener listener) { - initProject(); - - logger.info("Installing the Data Hub into MarkLogic"); - - AppConfig config = hubConfig.getAppConfig(); - HubAppDeployer deployer = new HubAppDeployer(getManageClient(), getAdminManager(), listener); - deployer.setCommands(getCommandList()); - deployer.deploy(config); - } + void install(HubDeployStatusListener listener); - public void updateIndexes() { - AppConfig config = hubConfig.getAppConfig(); - HubAppDeployer deployer = new HubAppDeployer(getManageClient(), getAdminManager(), null); - List commands = new ArrayList<>(); - commands.add(new DeployHubDatabasesCommand(hubConfig)); - deployer.setCommands(commands); - deployer.deploy(config); - } + void updateIndexes(); /** * Uninstalls the data hub configuration and server-side modules from MarkLogic */ - public void uninstall() { - uninstall(null); - } + void uninstall(); /** * Uninstalls the data hub configuration and server-side modules from MarkLogic * @param listener - the callback method to receive status updates */ - public void uninstall(HubDeployStatusListener listener) { - logger.debug("Uninstalling the Data Hub from MarkLogic"); - - AppConfig config = hubConfig.getAppConfig(); - HubAppDeployer deployer = new HubAppDeployer(getManageClient(), getAdminManager(), listener); - deployer.setCommands(getCommandList()); - deployer.undeploy(config); - } - - private void runInDatabase(String query, String databaseName) { - ServerEvaluationCall eval = hubConfig.newStagingClient().newServerEval(); - String xqy = - "xdmp:invoke-function(function() {" + - query + - "}," + - "" + - " {xdmp:database(\"" + databaseName + "\")}" + - " update-auto-commit" + - ")"; - eval.xquery(xqy).eval(); - } - - private Map> getCommands() { - Map> commandMap = new CommandMapBuilder().buildCommandMap(); - - List securityCommands = commandMap.get("mlSecurityCommands"); - securityCommands.set(0, new DeployHubRolesCommand(hubConfig)); - securityCommands.set(1, new DeployHubUsersCommand(hubConfig)); - - List dbCommands = new ArrayList<>(); - dbCommands.add(new DeployHubDatabasesCommand(hubConfig)); - dbCommands.add(new DeployHubOtherDatabasesCommand(hubConfig)); - dbCommands.add(new DeployHubTriggersDatabaseCommand(hubConfig)); - dbCommands.add(new DeployHubSchemasDatabaseCommand(hubConfig)); - commandMap.put("mlDatabaseCommands", dbCommands); + void uninstall(HubDeployStatusListener listener); - // don't deploy rest api servers - commandMap.remove("mlRestApiCommands"); + boolean isSafeToInstall(); - List serverCommands = new ArrayList<>(); - serverCommands.add(new DeployHubServersCommand(hubConfig)); - DeployOtherServersCommand otherServersCommand = new DeployOtherServersCommand(); - otherServersCommand.setFilenamesToIgnore("staging-server.json", "final-server.json", "job-server.json", "trace-server.json"); - serverCommands.add(otherServersCommand); - commandMap.put("mlServerCommands", serverCommands); + boolean isStagingPortInUse(); - List moduleCommands = new ArrayList<>(); - moduleCommands.add(new LoadHubModulesCommand(hubConfig)); - moduleCommands.add(new LoadUserModulesCommand(hubConfig)); - commandMap.put("mlModuleCommands", moduleCommands); + void setStagingPortInUse(boolean stagingPortInUse); - List mimetypeCommands = commandMap.get("mlMimetypeCommands"); - mimetypeCommands.add(0, new DeployHubMimetypesCommand(hubConfig)); - - List forestCommands = commandMap.get("mlForestCommands"); - DeployCustomForestsCommand deployCustomForestsCommand = (DeployCustomForestsCommand)forestCommands.get(0); - deployCustomForestsCommand.setCustomForestsPath(hubConfig.getCustomForestPath()); - - return commandMap; - } - - private Map getServerPortsInUse() { - Map portsInUse = new HashMap<>(); - ResourcesFragment srf = getServerManager().getAsXml(); - srf.getListItemNameRefs().forEach(s -> { - Fragment fragment = getServerManager().getPropertiesAsXml(s); - int port = Integer.parseInt(fragment.getElementValue("//m:port")); - portsInUse.put(port, s); - }); - return portsInUse; - } - - - // Here is the former PreCheckInstall class stuff - private boolean stagingPortInUse; - private String stagingPortInUseBy; - private boolean finalPortInUse; - private String finalPortInUseBy; - private boolean jobPortInUse; - private String jobPortInUseBy; - private boolean tracePortInUse; - private String tracePortInUseBy; - private boolean serverVersionOk; - private String serverVersion; - - public boolean isSafeToInstall() { - return !(isStagingPortInUse() || - isFinalPortInUse() || - isJobPortInUse() || - isTracePortInUse()) && isServerVersionOk(); - } - - public boolean isStagingPortInUse() { - return stagingPortInUse; - } + String getStagingPortInUseBy(); - public void setStagingPortInUse(boolean stagingPortInUse) { - this.stagingPortInUse = stagingPortInUse; - } + void setStagingPortInUseBy(String stagingPortInUseBy); - public String getStagingPortInUseBy() { - return stagingPortInUseBy; - } + boolean isFinalPortInUse(); - public void setStagingPortInUseBy(String stagingPortInUseBy) { - this.stagingPortInUseBy = stagingPortInUseBy; - } + void setFinalPortInUse(boolean finalPortInUse); - public boolean isFinalPortInUse() { - return finalPortInUse; - } + String getFinalPortInUseBy(); - public void setFinalPortInUse(boolean finalPortInUse) { - this.finalPortInUse = finalPortInUse; - } + void setFinalPortInUseBy(String finalPortInUseBy); - public String getFinalPortInUseBy() { - return finalPortInUseBy; - } + boolean isJobPortInUse(); - public void setFinalPortInUseBy(String finalPortInUseBy) { - this.finalPortInUseBy = finalPortInUseBy; - } + void setJobPortInUse(boolean jobPortInUse); - public boolean isJobPortInUse() { - return jobPortInUse; - } + String getJobPortInUseBy(); - public void setJobPortInUse(boolean jobPortInUse) { - this.jobPortInUse = jobPortInUse; - } + void setJobPortInUseBy(String jobPortInUseBy); - public String getJobPortInUseBy() { - return jobPortInUseBy; - } + boolean isTracePortInUse(); - public void setJobPortInUseBy(String jobPortInUseBy) { - this.jobPortInUseBy = jobPortInUseBy; - } + void setTracePortInUse(boolean tracePortInUse); - public boolean isTracePortInUse() { - return tracePortInUse; - } + String getTracePortInUseBy(); - public void setTracePortInUse(boolean tracePortInUse) { - this.tracePortInUse = tracePortInUse; - } + void setTracePortInUseBy(String tracePortInUseBy); - public String getTracePortInUseBy() { - return tracePortInUseBy; - } + boolean isServerVersionOk(); - public void setTracePortInUseBy(String tracePortInUseBy) { - this.tracePortInUseBy = tracePortInUseBy; - } + void setServerVersionOk(boolean serverVersionOk); - public boolean isServerVersionOk() { - return serverVersionOk; - } + String getServerVersion(); - public void setServerVersionOk(boolean serverVersionOk) { - this.serverVersionOk = serverVersionOk; - } + void setServerVersion(String serverVersion); - public String getServerVersion() { - return serverVersion; - } + boolean upgradeHub() throws CantUpgradeException; - public void setServerVersion(String serverVersion) { - this.serverVersion = serverVersion; - } + boolean upgradeHub(List updatedFlows) throws CantUpgradeException; - //HubDatabase stuff goes here - - public enum HubDatabase { - STAGING("staging"), - FINAL("final"); - - private String type; - - HubDatabase(String type) { - this.type = type; - } - - public static HubDatabase getHubDatabase(String database) { - for (HubDatabase hubDatabase : HubDatabase.values()) { - if (hubDatabase.toString().equals(database)) { - return hubDatabase; - } - } - return null; - } - - public String toString() { - return this.type; - } - } - - //DataHubUpgrader stuff - public static String MIN_UPGRADE_VERSION = "1.1.3"; - - public boolean upgradeHub() throws CantUpgradeException { - return upgradeHub(null); - } - - public boolean upgradeHub(List updatedFlows) throws CantUpgradeException { - boolean isHubInstalled = this.isInstalled().isInstalled(); - - String currentVersion = new Versions(hubConfig).getHubVersion(); - int compare = Versions.compare(currentVersion, MIN_UPGRADE_VERSION); - if (compare == -1) { - throw new CantUpgradeException(currentVersion, MIN_UPGRADE_VERSION); - } - - boolean result = false; - boolean alreadyInitialized = hubConfig.getHubProject().isInitialized(); - File buildGradle = Paths.get(hubConfig.getProjectDir(), "build.gradle").toFile(); - try { - // update the hub-internal-config files - hubConfig.initHubProject(); - - if (alreadyInitialized) { - // replace the hub version in build.gradle - String text = FileUtils.readFileToString(buildGradle); - String version = hubConfig.getJarVersion(); - text = Pattern.compile("^(\\s*)id\\s+['\"]com.marklogic.ml-data-hub['\"]\\s+version.+$", Pattern.MULTILINE).matcher(text).replaceAll("$1id 'com.marklogic.ml-data-hub' version '" + version + "'"); - text = Pattern.compile("^(\\s*)compile.+marklogic-data-hub.+$", Pattern.MULTILINE).matcher(text).replaceAll("$1compile 'com.marklogic:marklogic-data-hub:" + version + "'"); - FileUtils.writeStringToFile(buildGradle, text); - - hubConfig.getHubSecurityDir().resolve("roles").resolve("data-hub-user.json").toFile().delete(); - } - - // update legacy flows to include main.(sjs|xqy) - List flows = FlowManager.create(hubConfig).updateLegacyFlows(currentVersion); - if (updatedFlows != null) { - updatedFlows.addAll(flows); - } - - if (isHubInstalled) { - // install hub modules into MarkLogic - this.install(); - } - - result = true; - } - catch(IOException e) { - e.printStackTrace(); - } - return result; - } } diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/DataHubImpl.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/DataHubImpl.java new file mode 100644 index 0000000000..d12f618996 --- /dev/null +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/DataHubImpl.java @@ -0,0 +1,559 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.marklogic.hub.impl; + +import com.marklogic.appdeployer.AppConfig; +import com.marklogic.appdeployer.command.Command; +import com.marklogic.appdeployer.command.CommandMapBuilder; +import com.marklogic.appdeployer.command.appservers.DeployOtherServersCommand; +import com.marklogic.appdeployer.command.forests.DeployCustomForestsCommand; +import com.marklogic.client.FailedRequestException; +import com.marklogic.client.eval.ServerEvaluationCall; +import com.marklogic.hub.DataHub; +import com.marklogic.hub.FlowManager; +import com.marklogic.hub.HubConfig; +import com.marklogic.hub.InstallInfo; +import com.marklogic.hub.deploy.HubAppDeployer; +import com.marklogic.hub.deploy.commands.*; +import com.marklogic.hub.deploy.util.HubDeployStatusListener; +import com.marklogic.hub.error.CantUpgradeException; +import com.marklogic.hub.error.ServerValidationException; +import com.marklogic.hub.util.Versions; +import com.marklogic.mgmt.ManageClient; +import com.marklogic.mgmt.admin.AdminManager; +import com.marklogic.mgmt.resource.appservers.ServerManager; +import com.marklogic.mgmt.resource.databases.DatabaseManager; +import com.marklogic.rest.util.Fragment; +import com.marklogic.rest.util.ResourcesFragment; +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.core.io.Resource; +import org.springframework.core.io.support.PathMatchingResourcePatternResolver; +import org.springframework.core.io.support.ResourcePatternResolver; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Paths; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.regex.Pattern; + +public class DataHubImpl implements DataHub { + + private ManageClient _manageClient; + private DatabaseManager _databaseManager; + private ServerManager _serverManager; + private HubConfig hubConfig; + + private AdminManager _adminManager; + + protected final Logger logger = LoggerFactory.getLogger(this.getClass()); + + public DataHubImpl(HubConfig hubConfig) { + this.hubConfig = hubConfig; + } + + @Override public ManageClient getManageClient() { + if (this._manageClient == null) { + this._manageClient = hubConfig.getManageClient(); + } + return this._manageClient; + } + + @Override public AdminManager getAdminManager() { + if (this._adminManager == null) { + this._adminManager = hubConfig.getAdminManager(); + } + return this._adminManager; + } + void setAdminManager(AdminManager manager) { + this._adminManager = manager; + } + + @Override public DatabaseManager getDatabaseManager() { + if (this._databaseManager == null) { + this._databaseManager = new DatabaseManager(getManageClient()); + } + return this._databaseManager; + } + + @Override public ServerManager getServerManager() { + if (this._serverManager == null) { + this._serverManager = new ServerManager(getManageClient()); + } + return this._serverManager; + } + @Override public void setServerManager(ServerManager manager) { this._serverManager = manager; } + /** + * Determines if the data hub is installed in MarkLogic + * @return true if installed, false otherwise + */ + @Override public InstallInfo isInstalled() { + + InstallInfo installInfo = new InstallInfo(); + + ResourcesFragment srf = getServerManager().getAsXml(); + installInfo.setStagingAppServerExists(srf.resourceExists(hubConfig.getStagingHttpName())); + installInfo.setFinalAppServerExists(srf.resourceExists(hubConfig.getFinalHttpName())); + installInfo.setTraceAppServerExists(srf.resourceExists(hubConfig.getTraceHttpName())); + installInfo.setJobAppServerExists(srf.resourceExists(hubConfig.getJobHttpName())); + + ResourcesFragment drf = getDatabaseManager().getAsXml(); + installInfo.setStagingDbExists(drf.resourceExists(hubConfig.getStagingDbName())); + installInfo.setFinalDbExists(drf.resourceExists(hubConfig.getFinalDbName())); + installInfo.setTraceDbExists(drf.resourceExists(hubConfig.getTraceDbName())); + installInfo.setJobDbExists(drf.resourceExists(hubConfig.getJobDbName())); + + if (installInfo.isStagingDbExists()) { + Fragment f = getDatabaseManager().getPropertiesAsXml(hubConfig.getStagingDbName()); + installInfo.setStagingTripleIndexOn(Boolean.parseBoolean(f.getElementValue("//m:triple-index"))); + installInfo.setStagingCollectionLexiconOn(Boolean.parseBoolean(f.getElementValue("//m:collection-lexicon"))); + installInfo.setStagingForestsExist((f.getElements("//m:forest").size() > 0)); + } + + if (installInfo.isFinalDbExists()) { + Fragment f = getDatabaseManager().getPropertiesAsXml(hubConfig.getFinalDbName()); + installInfo.setFinalTripleIndexOn(Boolean.parseBoolean(f.getElementValue("//m:triple-index"))); + installInfo.setFinalCollectionLexiconOn(Boolean.parseBoolean(f.getElementValue("//m:collection-lexicon"))); + installInfo.setFinalForestsExist((f.getElements("//m:forest").size() > 0)); + } + + if (installInfo.isTraceDbExists()) { + Fragment f = getDatabaseManager().getPropertiesAsXml(hubConfig.getTraceDbName()); + installInfo.setTraceForestsExist((f.getElements("//m:forest").size() > 0)); + } + + if (installInfo.isJobDbExists()) { + Fragment f = getDatabaseManager().getPropertiesAsXml(hubConfig.getJobDbName()); + installInfo.setJobForestsExist((f.getElements("//m:forest").size() > 0)); + } + + logger.info(installInfo.toString()); + + return installInfo; + } + + /** + * Validates the MarkLogic server to ensure compatibility with the hub + * @param versionString - the version of the server to validate + * @return true if valid, false otherwise + * @throws ServerValidationException if the server is not compatible + */ + @Override public boolean isServerVersionValid(String versionString) { + try { + if (versionString == null) { + versionString = new Versions(hubConfig).getMarkLogicVersion(); + } + int major = Integer.parseInt(versionString.replaceAll("([^.]+)\\..*", "$1")); + if (major < 9) { + return false; + } + boolean isNightly = versionString.matches("[^-]+-(\\d{4})(\\d{2})(\\d{2})"); + if (major == 9) { + String alteredString = versionString.replaceAll("[^\\d]+", ""); + if (alteredString.length() < 4) { + alteredString = StringUtils.rightPad(alteredString, 4, "0"); + } + int ver = Integer.parseInt(alteredString.substring(0, 4)); + if (!isNightly && ver < 9011) { + return false; + } + } + if (isNightly) { + String dateString = versionString.replaceAll("[^-]+-(\\d{4})(\\d{2})(\\d{2})", "$1-$2-$3"); + Date minDate = new GregorianCalendar(2017, 6, 1).getTime(); + Date date = new SimpleDateFormat("y-M-d").parse(dateString); + if (date.before(minDate)) { + return false; + } + } + + } + catch(Exception e) { + throw new ServerValidationException(e.toString()); + } + return true; + } + + @Override public void initProject() { + logger.info("Initializing the Hub Project"); + hubConfig.initHubProject(); + } + + /** + * Removes user's modules from the modules db + * TODO: this becomes much simpler when we move code into the server dir + */ + @Override public void clearUserModules() { + ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(DataHub.class.getClassLoader()); + try { + ArrayList options = new ArrayList<>(); + for (Resource r : resolver.getResources("classpath*:/ml-modules/options/*.xml")) { + options.add(r.getFilename().replace(".xml", "")); + } + for (Resource r : resolver.getResources("classpath*:/ml-modules-traces/options/*.xml")) { + options.add(r.getFilename().replace(".xml", "")); + } + for (Resource r : resolver.getResources("classpath*:/ml-modules-jobs/options/*.xml")) { + options.add(r.getFilename().replace(".xml", "")); + } + + ArrayList services = new ArrayList<>(); + for (Resource r : resolver.getResources("classpath*:/ml-modules/services/*.xqy")) { + services.add(r.getFilename().replaceAll("\\.(xqy|sjs)", "")); + } + + + ArrayList transforms = new ArrayList<>(); + for (Resource r : resolver.getResources("classpath*:/ml-modules/transforms/*")) { + transforms.add(r.getFilename().replaceAll("\\.(xqy|sjs)", "")); + } + + String query = + "cts:uris((),(),cts:not-query(cts:collection-query('hub-core-module')))[\n" + + " fn:not(\n" + + " fn:matches(., \"^.+options/(" + String.join("|", options) + ").xml$\") or\n" + + " fn:matches(., \"/marklogic.rest.resource/(" + String.join("|", services) + ")/assets/(metadata\\.xml|resource\\.(xqy|sjs))\") or\n" + + " fn:matches(., \"/marklogic.rest.transform/(" + String.join("|", transforms) + ")/assets/(metadata\\.xml|transform\\.(xqy|sjs))\")\n" + + " )\n" + + "] ! xdmp:document-delete(.)\n"; + runInDatabase(query, hubConfig.getModulesDbName()); + } + catch(FailedRequestException e) { + logger.error("Failed to clear user modules"); + } catch (IOException e) { + e.printStackTrace(); + } + } + + @Override public List getCommandList() { + Map> commandMap = getCommands(); + List commands = new ArrayList<>(); + for (String name : commandMap.keySet()) { + commands.addAll(commandMap.get(name)); + } + return commands; + } + + @Override public void runPreInstallCheck() { + runPreInstallCheck(null); + } + + @Override public void runPreInstallCheck(Versions versions) { + + Map portsInUse = getServerPortsInUse(); + Set ports = portsInUse.keySet(); + + String serverName = portsInUse.get(hubConfig.getStagingPort()); + stagingPortInUse = ports.contains(hubConfig.getStagingPort()) && serverName != null && !serverName.equals(hubConfig.getStagingHttpName()); + if (stagingPortInUse) { + stagingPortInUseBy = serverName; + } + + serverName = portsInUse.get(hubConfig.getFinalPort()); + finalPortInUse = ports.contains(hubConfig.getFinalPort()) && serverName != null && !serverName.equals(hubConfig.getFinalHttpName()); + if (finalPortInUse) { + finalPortInUseBy = serverName; + } + + serverName = portsInUse.get(hubConfig.getJobPort()); + jobPortInUse = ports.contains(hubConfig.getJobPort()) && serverName != null && !serverName.equals(hubConfig.getJobHttpName()); + if (jobPortInUse) { + jobPortInUseBy = serverName; + } + + serverName = portsInUse.get(hubConfig.getTracePort()); + tracePortInUse = ports.contains(hubConfig.getTracePort()) && serverName != null && !serverName.equals(hubConfig.getTraceHttpName()); + if (tracePortInUse) { + tracePortInUseBy = serverName; + } + + if (versions == null) { + versions = new Versions(hubConfig); + } + serverVersion = versions.getMarkLogicVersion(); + serverVersionOk = isServerVersionValid(serverVersion); + } + + /** + * Installs the data hub configuration and server-side modules into MarkLogic + */ + @Override public void install() { + install(null); + } + + /** + * Installs the data hub configuration and server-side modules into MarkLogic + * @param listener - the callback method to receive status updates + */ + @Override public void install(HubDeployStatusListener listener) { + initProject(); + + logger.info("Installing the Data Hub into MarkLogic"); + + AppConfig config = hubConfig.getAppConfig(); + HubAppDeployer deployer = new HubAppDeployer(getManageClient(), getAdminManager(), listener); + deployer.setCommands(getCommandList()); + deployer.deploy(config); + } + + @Override public void updateIndexes() { + AppConfig config = hubConfig.getAppConfig(); + HubAppDeployer deployer = new HubAppDeployer(getManageClient(), getAdminManager(), null); + List commands = new ArrayList<>(); + commands.add(new DeployHubDatabasesCommand(hubConfig)); + deployer.setCommands(commands); + deployer.deploy(config); + } + + /** + * Uninstalls the data hub configuration and server-side modules from MarkLogic + */ + @Override public void uninstall() { + uninstall(null); + } + + /** + * Uninstalls the data hub configuration and server-side modules from MarkLogic + * @param listener - the callback method to receive status updates + */ + @Override public void uninstall(HubDeployStatusListener listener) { + logger.debug("Uninstalling the Data Hub from MarkLogic"); + + AppConfig config = hubConfig.getAppConfig(); + HubAppDeployer deployer = new HubAppDeployer(getManageClient(), getAdminManager(), listener); + deployer.setCommands(getCommandList()); + deployer.undeploy(config); + } + + private void runInDatabase(String query, String databaseName) { + ServerEvaluationCall eval = hubConfig.newStagingClient().newServerEval(); + String xqy = + "xdmp:invoke-function(function() {" + + query + + "}," + + "" + + " {xdmp:database(\"" + databaseName + "\")}" + + " update-auto-commit" + + ")"; + eval.xquery(xqy).eval(); + } + + private Map> getCommands() { + Map> commandMap = new CommandMapBuilder().buildCommandMap(); + + List securityCommands = commandMap.get("mlSecurityCommands"); + securityCommands.set(0, new DeployHubRolesCommand(hubConfig)); + securityCommands.set(1, new DeployHubUsersCommand(hubConfig)); + + List dbCommands = new ArrayList<>(); + dbCommands.add(new DeployHubDatabasesCommand(hubConfig)); + dbCommands.add(new DeployHubOtherDatabasesCommand(hubConfig)); + dbCommands.add(new DeployHubTriggersDatabaseCommand(hubConfig)); + dbCommands.add(new DeployHubSchemasDatabaseCommand(hubConfig)); + commandMap.put("mlDatabaseCommands", dbCommands); + + // don't deploy rest api servers + commandMap.remove("mlRestApiCommands"); + + List serverCommands = new ArrayList<>(); + serverCommands.add(new DeployHubServersCommand(hubConfig)); + DeployOtherServersCommand otherServersCommand = new DeployOtherServersCommand(); + otherServersCommand.setFilenamesToIgnore("staging-server.json", "final-server.json", "job-server.json", "trace-server.json"); + serverCommands.add(otherServersCommand); + commandMap.put("mlServerCommands", serverCommands); + + List moduleCommands = new ArrayList<>(); + moduleCommands.add(new LoadHubModulesCommand(hubConfig)); + moduleCommands.add(new LoadUserModulesCommand(hubConfig)); + commandMap.put("mlModuleCommands", moduleCommands); + + List mimetypeCommands = commandMap.get("mlMimetypeCommands"); + mimetypeCommands.add(0, new DeployHubMimetypesCommand(hubConfig)); + + List forestCommands = commandMap.get("mlForestCommands"); + DeployCustomForestsCommand deployCustomForestsCommand = (DeployCustomForestsCommand)forestCommands.get(0); + deployCustomForestsCommand.setCustomForestsPath(hubConfig.getCustomForestPath()); + + return commandMap; + } + + private Map getServerPortsInUse() { + Map portsInUse = new HashMap<>(); + ResourcesFragment srf = getServerManager().getAsXml(); + srf.getListItemNameRefs().forEach(s -> { + Fragment fragment = getServerManager().getPropertiesAsXml(s); + int port = Integer.parseInt(fragment.getElementValue("//m:port")); + portsInUse.put(port, s); + }); + return portsInUse; + } + + + // Here is the former PreCheckInstall class stuff + private boolean stagingPortInUse; + private String stagingPortInUseBy; + private boolean finalPortInUse; + private String finalPortInUseBy; + private boolean jobPortInUse; + private String jobPortInUseBy; + private boolean tracePortInUse; + private String tracePortInUseBy; + private boolean serverVersionOk; + private String serverVersion; + + @Override public boolean isSafeToInstall() { + return !(isStagingPortInUse() || + isFinalPortInUse() || + isJobPortInUse() || + isTracePortInUse()) && isServerVersionOk(); + } + + @Override public boolean isStagingPortInUse() { + return stagingPortInUse; + } + + @Override public void setStagingPortInUse(boolean stagingPortInUse) { + this.stagingPortInUse = stagingPortInUse; + } + + @Override public String getStagingPortInUseBy() { + return stagingPortInUseBy; + } + + @Override public void setStagingPortInUseBy(String stagingPortInUseBy) { + this.stagingPortInUseBy = stagingPortInUseBy; + } + + @Override public boolean isFinalPortInUse() { + return finalPortInUse; + } + + @Override public void setFinalPortInUse(boolean finalPortInUse) { + this.finalPortInUse = finalPortInUse; + } + + @Override public String getFinalPortInUseBy() { + return finalPortInUseBy; + } + + @Override public void setFinalPortInUseBy(String finalPortInUseBy) { + this.finalPortInUseBy = finalPortInUseBy; + } + + @Override public boolean isJobPortInUse() { + return jobPortInUse; + } + + @Override public void setJobPortInUse(boolean jobPortInUse) { + this.jobPortInUse = jobPortInUse; + } + + @Override public String getJobPortInUseBy() { + return jobPortInUseBy; + } + + @Override public void setJobPortInUseBy(String jobPortInUseBy) { + this.jobPortInUseBy = jobPortInUseBy; + } + + @Override public boolean isTracePortInUse() { + return tracePortInUse; + } + + @Override public void setTracePortInUse(boolean tracePortInUse) { + this.tracePortInUse = tracePortInUse; + } + + @Override public String getTracePortInUseBy() { + return tracePortInUseBy; + } + + @Override public void setTracePortInUseBy(String tracePortInUseBy) { + this.tracePortInUseBy = tracePortInUseBy; + } + + @Override public boolean isServerVersionOk() { + return serverVersionOk; + } + + @Override public void setServerVersionOk(boolean serverVersionOk) { + this.serverVersionOk = serverVersionOk; + } + + @Override public String getServerVersion() { + return serverVersion; + } + + @Override public void setServerVersion(String serverVersion) { + this.serverVersion = serverVersion; + } + + //DataHubUpgrader stuff + public static String MIN_UPGRADE_VERSION = "1.1.3"; + + @Override public boolean upgradeHub() throws CantUpgradeException { + return upgradeHub(null); + } + + @Override public boolean upgradeHub(List updatedFlows) throws CantUpgradeException { + boolean isHubInstalled = this.isInstalled().isInstalled(); + + String currentVersion = new Versions(hubConfig).getHubVersion(); + int compare = Versions.compare(currentVersion, MIN_UPGRADE_VERSION); + if (compare == -1) { + throw new CantUpgradeException(currentVersion, MIN_UPGRADE_VERSION); + } + + boolean result = false; + boolean alreadyInitialized = hubConfig.getHubProject().isInitialized(); + File buildGradle = Paths.get(hubConfig.getProjectDir(), "build.gradle").toFile(); + try { + // update the hub-internal-config files + hubConfig.initHubProject(); + + if (alreadyInitialized) { + // replace the hub version in build.gradle + String text = FileUtils.readFileToString(buildGradle); + String version = hubConfig.getJarVersion(); + text = Pattern.compile("^(\\s*)id\\s+['\"]com.marklogic.ml-data-hub['\"]\\s+version.+$", Pattern.MULTILINE).matcher(text).replaceAll("$1id 'com.marklogic.ml-data-hub' version '" + version + "'"); + text = Pattern.compile("^(\\s*)compile.+marklogic-data-hub.+$", Pattern.MULTILINE).matcher(text).replaceAll("$1compile 'com.marklogic:marklogic-data-hub:" + version + "'"); + FileUtils.writeStringToFile(buildGradle, text); + + hubConfig.getHubSecurityDir().resolve("roles").resolve("data-hub-user.json").toFile().delete(); + } + + // update legacy flows to include main.(sjs|xqy) + List flows = FlowManager.create(hubConfig).updateLegacyFlows(currentVersion); + if (updatedFlows != null) { + updatedFlows.addAll(flows); + } + + if (isHubInstalled) { + // install hub modules into MarkLogic + this.install(); + } + + result = true; + } + catch(IOException e) { + e.printStackTrace(); + } + return result; + } +} diff --git a/marklogic-data-hub/src/test/java/com/marklogic/hub/DataHubInstallTest.java b/marklogic-data-hub/src/test/java/com/marklogic/hub/DataHubInstallTest.java index dc274694c5..ecc2bfc0e3 100644 --- a/marklogic-data-hub/src/test/java/com/marklogic/hub/DataHubInstallTest.java +++ b/marklogic-data-hub/src/test/java/com/marklogic/hub/DataHubInstallTest.java @@ -183,7 +183,7 @@ public void testClearUserModules() throws URISyntaxException { URL url = DataHubInstallTest.class.getClassLoader().getResource("data-hub-test"); String path = Paths.get(url.toURI()).toFile().getAbsolutePath(); HubConfig hubConfig = getHubConfig(path); - DataHub dataHub = new DataHub(hubConfig); + DataHub dataHub = DataHub.create(hubConfig); dataHub.clearUserModules(); int totalCount = getDocCount(HubConfig.DEFAULT_MODULES_DB_NAME, null); diff --git a/marklogic-data-hub/src/test/java/com/marklogic/hub/DataHubTest.java b/marklogic-data-hub/src/test/java/com/marklogic/hub/DataHubTest.java index 98f9fe6767..ac92bebbdf 100644 --- a/marklogic-data-hub/src/test/java/com/marklogic/hub/DataHubTest.java +++ b/marklogic-data-hub/src/test/java/com/marklogic/hub/DataHubTest.java @@ -15,6 +15,7 @@ */ package com.marklogic.hub; +import com.marklogic.hub.impl.DataHubImpl; import com.marklogic.hub.util.Versions; import com.marklogic.mgmt.resource.appservers.ServerManager; import com.marklogic.rest.util.Fragment; @@ -56,7 +57,7 @@ public static void setup() { @Before public void beforeTests() { - dh = EasyMock.createMockBuilder(DataHub.class) + dh = EasyMock.createMockBuilder(DataHubImpl.class) .withConstructor(HubConfig.class) .withArgs(getHubConfig()) .createMock(); diff --git a/marklogic-data-hub/src/test/java/com/marklogic/hub/HubTestBase.java b/marklogic-data-hub/src/test/java/com/marklogic/hub/HubTestBase.java index 9cdaad5995..3f417def54 100644 --- a/marklogic-data-hub/src/test/java/com/marklogic/hub/HubTestBase.java +++ b/marklogic-data-hub/src/test/java/com/marklogic/hub/HubTestBase.java @@ -231,7 +231,7 @@ protected static HubConfig getHubConfig() { } protected static DataHub getDataHub() { - return new DataHub(getHubConfig()); + return DataHub.create(getHubConfig()); } protected static HubConfig getHubConfig(String projectDir) { diff --git a/marklogic-data-hub/src/test/java/com/marklogic/hub/collector/EmptyCollectorTest.java b/marklogic-data-hub/src/test/java/com/marklogic/hub/collector/EmptyCollectorTest.java index 9479eb8983..78f9e406ef 100644 --- a/marklogic-data-hub/src/test/java/com/marklogic/hub/collector/EmptyCollectorTest.java +++ b/marklogic-data-hub/src/test/java/com/marklogic/hub/collector/EmptyCollectorTest.java @@ -45,7 +45,7 @@ public static void setup() throws IOException { scaffolding.createFlow(ENTITY, "testharmonize", FlowType.HARMONIZE, CodeFormat.XQUERY, DataFormat.XML); - DataHub dh = new DataHub(getHubConfig()); + DataHub dh = DataHub.create(getHubConfig()); dh.clearUserModules(); installUserModules(getHubConfig(), false); clearDatabases(HubConfig.DEFAULT_STAGING_NAME, HubConfig.DEFAULT_FINAL_NAME, HubConfig.DEFAULT_TRACE_NAME, HubConfig.DEFAULT_JOB_NAME); diff --git a/marklogic-data-hub/src/test/java/com/marklogic/hub/collector/StreamCollectorTest.java b/marklogic-data-hub/src/test/java/com/marklogic/hub/collector/StreamCollectorTest.java index ece96e44c8..513544cdef 100644 --- a/marklogic-data-hub/src/test/java/com/marklogic/hub/collector/StreamCollectorTest.java +++ b/marklogic-data-hub/src/test/java/com/marklogic/hub/collector/StreamCollectorTest.java @@ -70,7 +70,7 @@ public static void setup() throws IOException { scaffolding.createFlow(ENTITY, "testharmonize", FlowType.HARMONIZE, CodeFormat.XQUERY, DataFormat.XML); - DataHub dh = new DataHub(getHubConfig()); + DataHub dh = DataHub.create(getHubConfig()); dh.clearUserModules(); installUserModules(getHubConfig(), false); clearDatabases(HubConfig.DEFAULT_STAGING_NAME, HubConfig.DEFAULT_FINAL_NAME, HubConfig.DEFAULT_TRACE_NAME, HubConfig.DEFAULT_JOB_NAME); diff --git a/marklogic-data-hub/src/test/java/com/marklogic/hub/flow/FlowRunnerTest.java b/marklogic-data-hub/src/test/java/com/marklogic/hub/flow/FlowRunnerTest.java index f0bf05c03d..d78781b88c 100644 --- a/marklogic-data-hub/src/test/java/com/marklogic/hub/flow/FlowRunnerTest.java +++ b/marklogic-data-hub/src/test/java/com/marklogic/hub/flow/FlowRunnerTest.java @@ -60,7 +60,7 @@ public static void setup() throws IOException { scaffolding.createFlow(ENTITY, "testharmonize", FlowType.HARMONIZE, CodeFormat.XQUERY, DataFormat.XML); - DataHub dh = new DataHub(getHubConfig()); + DataHub dh = DataHub.create(getHubConfig()); dh.clearUserModules(); installUserModules(getHubConfig(), false); diff --git a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/DataHubPlugin.groovy b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/DataHubPlugin.groovy index c8e7d63f0c..ba2d79a058 100644 --- a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/DataHubPlugin.groovy +++ b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/DataHubPlugin.groovy @@ -86,7 +86,7 @@ class DataHubPlugin implements Plugin { .build() project.extensions.add("hubConfig", hubConfig) - dataHub = new DataHub(hubConfig) + dataHub = DataHub.create(hubConfig) project.extensions.add("dataHub", dataHub) } diff --git a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/UpdateHubTask.groovy b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/UpdateHubTask.groovy index f4dc6456f6..bf06fb049e 100644 --- a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/UpdateHubTask.groovy +++ b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/UpdateHubTask.groovy @@ -9,7 +9,7 @@ class UpdateHubTask extends HubTask { void updateHub() { if (getFlowManager().getLegacyFlows().size() > 0) { def updatedFlows = new ArrayList() - new DataHub(hubConfig).upgradeHub(updatedFlows) + DataHub.create(hubConfig).upgradeHub(updatedFlows) println "Legacy Flows Updated:\n\t" + String.join("\n\t", updatedFlows) } diff --git a/quick-start/src/main/java/com/marklogic/quickstart/model/EnvironmentConfig.java b/quick-start/src/main/java/com/marklogic/quickstart/model/EnvironmentConfig.java index 18eb86f60b..be3fbfa32c 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/model/EnvironmentConfig.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/model/EnvironmentConfig.java @@ -101,7 +101,7 @@ public EnvironmentConfig(String projectDir, String environment, String username, mlSettings.getAppConfig().setAppServicesUsername(username); mlSettings.getAppConfig().setAppServicesPassword(password); } - dataHub = new DataHub(mlSettings); + dataHub = DataHub.create(mlSettings); // warm the caches getStagingClient(); diff --git a/quick-start/src/main/java/com/marklogic/quickstart/model/Project.java b/quick-start/src/main/java/com/marklogic/quickstart/model/Project.java index a819d3d3c3..26624330dd 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/model/Project.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/model/Project.java @@ -51,7 +51,7 @@ public List getEnvironments() { public void initialize(HubConfig hubConfig) { hubConfig.setProjectDir(this.path); - DataHub hub = new DataHub(hubConfig); + DataHub hub = DataHub.create(hubConfig); hub.initProject(); } } diff --git a/quick-start/src/main/java/com/marklogic/quickstart/service/DataHubService.java b/quick-start/src/main/java/com/marklogic/quickstart/service/DataHubService.java index dfc04a23cd..d972c8bddd 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/service/DataHubService.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/service/DataHubService.java @@ -54,7 +54,7 @@ public class DataHubService { public boolean install(HubConfig config, HubDeployStatusListener listener) throws DataHubException { logger.info("Installing Data Hub"); - DataHub dataHub = new DataHub(config); + DataHub dataHub = DataHub.create(config); try { dataHub.install(listener); return true; @@ -66,7 +66,7 @@ public boolean install(HubConfig config, HubDeployStatusListener listener) throw } public void updateIndexes(HubConfig config) { - DataHub dataHub = new DataHub(config); + DataHub dataHub = DataHub.create(config); try { dataHub.updateIndexes(); } catch(Throwable e) { @@ -101,7 +101,7 @@ public void installUserModules(HubConfig config, boolean forceLoad, DeployUserMo public void reinstallUserModules(HubConfig config, DeployUserModulesListener deployListener, ValidateListener validateListener) { long startTime = PerformanceLogger.monitorTimeInsideMethod(); - DataHub dataHub = new DataHub(config); + DataHub dataHub = DataHub.create(config); try { dataHub.clearUserModules(); installUserModules(config, true, deployListener); @@ -117,7 +117,7 @@ public void reinstallUserModules(HubConfig config, DeployUserModulesListener dep public void uninstallUserModules(HubConfig config) { long startTime = PerformanceLogger.monitorTimeInsideMethod(); - DataHub dataHub = new DataHub(config); + DataHub dataHub = DataHub.create(config); try { dataHub.clearUserModules(); } catch(Throwable e) { @@ -127,7 +127,7 @@ public void uninstallUserModules(HubConfig config) { } public void preInstallCheck(HubConfig config) { - DataHub dataHub = new DataHub(config); + DataHub dataHub = DataHub.create(config); dataHub.runPreInstallCheck(); } @@ -139,7 +139,7 @@ public void validateUserModules(HubConfig hubConfig, ValidateListener validateLi } public void uninstall(HubConfig config, HubDeployStatusListener listener) throws DataHubException { - DataHub dataHub = new DataHub(config); + DataHub dataHub = DataHub.create(config); try { dataHub.uninstall(listener); } catch(Throwable e) { @@ -160,7 +160,7 @@ public String getLastDeployed(HubConfig config) { } public boolean updateHub(HubConfig config) throws IOException, CantUpgradeException { - boolean result = new DataHub(config).upgradeHub(); + boolean result = DataHub.create(config).upgradeHub(); if (result) { ConnectionAuthenticationToken authenticationToken = (ConnectionAuthenticationToken) SecurityContextHolder.getContext().getAuthentication(); if (authenticationToken != null) { @@ -173,7 +173,7 @@ public boolean updateHub(HubConfig config) throws IOException, CantUpgradeExcept } public void clearContent(HubConfig config, String database) { - DataHub dataHub = new DataHub(config); + DataHub dataHub = DataHub.create(config); DatabaseManager mgr = new DatabaseManager(dataHub.getManageClient()); mgr.clearDatabase(database); } diff --git a/quick-start/src/test/java/com/marklogic/quickstart/web/BaseTestController.java b/quick-start/src/test/java/com/marklogic/quickstart/web/BaseTestController.java index 50f5e84539..61950941d4 100644 --- a/quick-start/src/test/java/com/marklogic/quickstart/web/BaseTestController.java +++ b/quick-start/src/test/java/com/marklogic/quickstart/web/BaseTestController.java @@ -34,7 +34,7 @@ protected void setEnvConfig(EnvironmentConfig envConfig) { public void baseSetUp() throws IOException { envConfig = new EnvironmentConfig(PROJECT_PATH, "local", "admin", "admin"); setEnvConfig(envConfig); - DataHub dh = new DataHub(envConfig.getMlSettings()); + DataHub dh = DataHub.create(envConfig.getMlSettings()); dh.initProject(); projectManagerService.addProject(PROJECT_PATH); } From 513438860c3c911e4a65efbeef15224ed5387d9b Mon Sep 17 00:00:00 2001 From: Alexander Ebadirad Date: Fri, 16 Feb 2018 14:41:17 -0700 Subject: [PATCH 11/22] Hubconfig builder interface --- .../com/marklogic/hub/HubConfigBuilder.java | 189 +------------- .../hub/impl/HubConfigBuilderImpl.java | 240 ++++++++++++++++++ .../com/marklogic/gradle/task/BaseTest.groovy | 2 - 3 files changed, 253 insertions(+), 178 deletions(-) create mode 100644 marklogic-data-hub/src/main/java/com/marklogic/hub/impl/HubConfigBuilderImpl.java diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/HubConfigBuilder.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/HubConfigBuilder.java index 3af21fbb8c..0ad6832d42 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/HubConfigBuilder.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/HubConfigBuilder.java @@ -1,85 +1,29 @@ -/* - * Copyright 2012-2018 MarkLogic Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ package com.marklogic.hub; import com.marklogic.appdeployer.AppConfig; -import com.marklogic.appdeployer.DefaultAppConfigFactory; -import com.marklogic.hub.impl.HubConfigImpl; -import com.marklogic.mgmt.DefaultManageConfigFactory; +import com.marklogic.hub.impl.HubConfigBuilderImpl; import com.marklogic.mgmt.ManageClient; import com.marklogic.mgmt.ManageConfig; import com.marklogic.mgmt.admin.AdminConfig; import com.marklogic.mgmt.admin.AdminManager; -import com.marklogic.mgmt.admin.DefaultAdminConfigFactory; -import com.marklogic.mgmt.util.SimplePropertySource; -import java.io.File; -import java.io.FileInputStream; -import java.io.InputStream; import java.util.Properties; -/** - * A class for building a HubConfig class. Create a HubConfig instance like so: - * - *
{@code
- *     HubConfig hubConfig = HubConfigBuilder.newHubConfigBuilder("/path/to/your/project")
- *         .withPropertiesFromEnvironment("local")
- *         .build();
- *}
- */ -public class HubConfigBuilder { - - private static final String GRADLE_PROPERTIES_FILENAME = "gradle.properties"; - - private HubConfigImpl hubConfig; - - private String projectDir; - - private Properties properties; - - private boolean usePropertiesFromEnvironment = false; - private String environment; - - private ManageConfig manageConfig; - private ManageClient manageClient; - private AdminConfig adminConfig; - private AdminManager adminManager; - private AppConfig appConfig; - - private HubConfigBuilder(String projectDir) { - this.projectDir = projectDir; - this.hubConfig = new HubConfigImpl(projectDir); - } - +public interface HubConfigBuilder { /** * Returns a new {@link HubConfigBuilder} instance * @param projectDir - the hub's project directory * @return a new {@link HubConfigBuilder} */ - public static HubConfigBuilder newHubConfigBuilder(String projectDir) { - return new HubConfigBuilder(projectDir); + static HubConfigBuilder newHubConfigBuilder(String projectDir) { + return new HubConfigBuilderImpl(projectDir); } /** * Tells the builder to load properties from the gradle files in the project dir * @return the {@link HubConfigBuilder} instance */ - public HubConfigBuilder withPropertiesFromEnvironment() { - return withPropertiesFromEnvironment(null); - } + HubConfigBuilder withPropertiesFromEnvironment(); /** * Tells the builder to load properties from the gradle files in the project dir @@ -87,11 +31,7 @@ public HubConfigBuilder withPropertiesFromEnvironment() { * @param environment - the name of the environment to use (local,dev,qa,prod,...) * @return the {@link HubConfigBuilder} instance */ - public HubConfigBuilder withPropertiesFromEnvironment(String environment) { - this.usePropertiesFromEnvironment = true; - this.environment = environment; - return this; - } + HubConfigBuilder withPropertiesFromEnvironment(String environment); /** * Tells the builder to use the given properties. If properties are also being loaded from the @@ -100,149 +40,46 @@ public HubConfigBuilder withPropertiesFromEnvironment(String environment) { * @param properties - A {@link Properties} object with properties set * @return the {@link HubConfigBuilder} instance */ - public HubConfigBuilder withProperties(Properties properties) { - this.properties = properties; - return this; - } + HubConfigBuilder withProperties(Properties properties); /** * Sets the {@link AppConfig} for the {@link HubConfig} * @param appConfig - an {@link AppConfig} object * @return the {@link HubConfigBuilder} instance */ - public HubConfigBuilder withAppConfig(AppConfig appConfig) { - this.appConfig = appConfig; - return this; - } + HubConfigBuilder withAppConfig(AppConfig appConfig); /** * Sets the {@link AdminConfig} for the {@link HubConfig} * @param adminConfig - an {@link AdminConfig} object * @return the {@link HubConfigBuilder} instance */ - public HubConfigBuilder withAdminConfig(AdminConfig adminConfig) { - this.adminConfig = adminConfig; - return this; - } + HubConfigBuilder withAdminConfig(AdminConfig adminConfig); /** * Sets the {@link AdminManager} for the {@link HubConfig} * @param adminManager - an {@link AdminManager} object * @return the {@link HubConfigBuilder} instance */ - public HubConfigBuilder withAdminManager(AdminManager adminManager) { - this.adminManager = adminManager; - return this; - } + HubConfigBuilder withAdminManager(AdminManager adminManager); /** * Sets the {@link ManageConfig} for the {@link HubConfig} * @param manageConfig - a {@link ManageConfig} object * @return the {@link HubConfigBuilder} instance */ - public HubConfigBuilder withManageConfig(ManageConfig manageConfig) { - this.manageConfig = manageConfig; - return this; - } + HubConfigBuilder withManageConfig(ManageConfig manageConfig); /** * Sets the {@link ManageClient} for the {@link HubConfig} * @param manageClient - a {@link ManageClient} * @return the {@link HubConfigBuilder} instance */ - public HubConfigBuilder withManageClient(ManageClient manageClient) { - this.manageClient = manageClient; - return this; - } + HubConfigBuilder withManageClient(ManageClient manageClient); /** * Builds the {@link HubConfig} instance * @return the created {@link HubConfig} */ - public HubConfig build() { - Properties actualProperties = null; - if (usePropertiesFromEnvironment) { - actualProperties = getPropertiesFromEnvironment(); - } - - if (actualProperties == null) { - actualProperties = new Properties(); - } - - - Properties tmpProperties = actualProperties; - if (properties != null) { - properties.forEach(tmpProperties::put); - } - - hubConfig.loadConfigurationFromProperties(actualProperties); - - SimplePropertySource propertySource = new SimplePropertySource(actualProperties); - - if (appConfig != null) { - hubConfig.setAppConfig(appConfig); - } - else { - hubConfig.setAppConfig(new DefaultAppConfigFactory(propertySource).newAppConfig()); - } - - if (adminConfig != null) { - hubConfig.setAdminConfig(adminConfig); - } - else { - hubConfig.setAdminConfig(new DefaultAdminConfigFactory(propertySource).newAdminConfig()); - } - - if (adminManager != null) { - hubConfig.setAdminManager(adminManager); - } - else { - hubConfig.setAdminManager(new AdminManager(hubConfig.getAdminConfig())); - } - - if (manageConfig != null) { - hubConfig.setManageConfig(manageConfig); - } - else { - hubConfig.setManageConfig(new DefaultManageConfigFactory(propertySource).newManageConfig()); - } - - if (manageClient != null) { - hubConfig.setManageClient(manageClient); - } - else { - hubConfig.setManageClient(new ManageClient(hubConfig.getManageConfig())); - } - - return hubConfig; - } - - // loads properties off of disk - private Properties getPropertiesFromEnvironment() { - Properties environmentProperties = new Properties(); - - File file = new File(this.projectDir, GRADLE_PROPERTIES_FILENAME); - loadPropertiesFromFile(file, environmentProperties); - if (environment != null) { - File envPropertiesFile = new File(this.projectDir, "gradle-" + environment + ".properties"); - loadPropertiesFromFile(envPropertiesFile, environmentProperties); - } - - return environmentProperties; - } - - // loads properties from a .properties file - private void loadPropertiesFromFile(File propertiesFile, Properties loadedProperties) { - InputStream is; - try { - if(propertiesFile.exists()) { - is = new FileInputStream( propertiesFile ); - loadedProperties.load( is ); - is.close(); - } - } - catch ( Exception e ) { - e.printStackTrace(); - } - } + HubConfig build(); } diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/HubConfigBuilderImpl.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/HubConfigBuilderImpl.java new file mode 100644 index 0000000000..b5fbc632a6 --- /dev/null +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/HubConfigBuilderImpl.java @@ -0,0 +1,240 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.marklogic.hub.impl; + +import com.marklogic.appdeployer.AppConfig; +import com.marklogic.appdeployer.DefaultAppConfigFactory; +import com.marklogic.hub.HubConfig; +import com.marklogic.hub.HubConfigBuilder; +import com.marklogic.mgmt.DefaultManageConfigFactory; +import com.marklogic.mgmt.ManageClient; +import com.marklogic.mgmt.ManageConfig; +import com.marklogic.mgmt.admin.AdminConfig; +import com.marklogic.mgmt.admin.AdminManager; +import com.marklogic.mgmt.admin.DefaultAdminConfigFactory; +import com.marklogic.mgmt.util.SimplePropertySource; + +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.util.Properties; + +/** + * A class for building a HubConfig class. Create a HubConfig instance like so: + * + *
{@code
+ *     HubConfig hubConfig = HubConfigBuilder.newHubConfigBuilder("/path/to/your/project")
+ *         .withPropertiesFromEnvironment("local")
+ *         .build();
+ *}
+ */ +public class HubConfigBuilderImpl implements HubConfigBuilder { + + private static final String GRADLE_PROPERTIES_FILENAME = "gradle.properties"; + + private HubConfigImpl hubConfig; + + private String projectDir; + + private Properties properties; + + private boolean usePropertiesFromEnvironment = false; + private String environment; + + private ManageConfig manageConfig; + private ManageClient manageClient; + private AdminConfig adminConfig; + private AdminManager adminManager; + private AppConfig appConfig; + + public HubConfigBuilderImpl(String projectDir) { + this.projectDir = projectDir; + this.hubConfig = new HubConfigImpl(projectDir); + } + + /** + * Tells the builder to load properties from the gradle files in the project dir + * @return the {@link HubConfigBuilder} instance + */ + @Override public HubConfigBuilder withPropertiesFromEnvironment() { + return withPropertiesFromEnvironment(null); + } + + /** + * Tells the builder to load properties from the gradle files in the project dir + * but to look for an environment properties file with overrides + * @param environment - the name of the environment to use (local,dev,qa,prod,...) + * @return the {@link HubConfigBuilder} instance + */ + @Override public HubConfigBuilder withPropertiesFromEnvironment(String environment) { + this.usePropertiesFromEnvironment = true; + this.environment = environment; + return this; + } + + /** + * Tells the builder to use the given properties. If properties are also being loaded from the + * gradle files in the project dir, then these properties will be merged into the others taking + * precedence over the ones loaded from disk + * @param properties - A {@link Properties} object with properties set + * @return the {@link HubConfigBuilder} instance + */ + @Override public HubConfigBuilder withProperties(Properties properties) { + this.properties = properties; + return this; + } + + /** + * Sets the {@link AppConfig} for the {@link HubConfig} + * @param appConfig - an {@link AppConfig} object + * @return the {@link HubConfigBuilder} instance + */ + @Override public HubConfigBuilder withAppConfig(AppConfig appConfig) { + this.appConfig = appConfig; + return this; + } + + /** + * Sets the {@link AdminConfig} for the {@link HubConfig} + * @param adminConfig - an {@link AdminConfig} object + * @return the {@link HubConfigBuilder} instance + */ + @Override public HubConfigBuilder withAdminConfig(AdminConfig adminConfig) { + this.adminConfig = adminConfig; + return this; + } + + /** + * Sets the {@link AdminManager} for the {@link HubConfig} + * @param adminManager - an {@link AdminManager} object + * @return the {@link HubConfigBuilder} instance + */ + @Override public HubConfigBuilder withAdminManager(AdminManager adminManager) { + this.adminManager = adminManager; + return this; + } + + /** + * Sets the {@link ManageConfig} for the {@link HubConfig} + * @param manageConfig - a {@link ManageConfig} object + * @return the {@link HubConfigBuilder} instance + */ + @Override public HubConfigBuilder withManageConfig(ManageConfig manageConfig) { + this.manageConfig = manageConfig; + return this; + } + + /** + * Sets the {@link ManageClient} for the {@link HubConfig} + * @param manageClient - a {@link ManageClient} + * @return the {@link HubConfigBuilder} instance + */ + @Override public HubConfigBuilder withManageClient(ManageClient manageClient) { + this.manageClient = manageClient; + return this; + } + + /** + * Builds the {@link HubConfig} instance + * @return the created {@link HubConfig} + */ + @Override public HubConfig build() { + Properties actualProperties = null; + if (usePropertiesFromEnvironment) { + actualProperties = getPropertiesFromEnvironment(); + } + + if (actualProperties == null) { + actualProperties = new Properties(); + } + + + Properties tmpProperties = actualProperties; + if (properties != null) { + properties.forEach(tmpProperties::put); + } + + hubConfig.loadConfigurationFromProperties(actualProperties); + + SimplePropertySource propertySource = new SimplePropertySource(actualProperties); + + if (appConfig != null) { + hubConfig.setAppConfig(appConfig); + } + else { + hubConfig.setAppConfig(new DefaultAppConfigFactory(propertySource).newAppConfig()); + } + + if (adminConfig != null) { + hubConfig.setAdminConfig(adminConfig); + } + else { + hubConfig.setAdminConfig(new DefaultAdminConfigFactory(propertySource).newAdminConfig()); + } + + if (adminManager != null) { + hubConfig.setAdminManager(adminManager); + } + else { + hubConfig.setAdminManager(new AdminManager(hubConfig.getAdminConfig())); + } + + if (manageConfig != null) { + hubConfig.setManageConfig(manageConfig); + } + else { + hubConfig.setManageConfig(new DefaultManageConfigFactory(propertySource).newManageConfig()); + } + + if (manageClient != null) { + hubConfig.setManageClient(manageClient); + } + else { + hubConfig.setManageClient(new ManageClient(hubConfig.getManageConfig())); + } + + return hubConfig; + } + + // loads properties off of disk + private Properties getPropertiesFromEnvironment() { + Properties environmentProperties = new Properties(); + + File file = new File(this.projectDir, GRADLE_PROPERTIES_FILENAME); + loadPropertiesFromFile(file, environmentProperties); + if (environment != null) { + File envPropertiesFile = new File(this.projectDir, "gradle-" + environment + ".properties"); + loadPropertiesFromFile(envPropertiesFile, environmentProperties); + } + + return environmentProperties; + } + + // loads properties from a .properties file + private void loadPropertiesFromFile(File propertiesFile, Properties loadedProperties) { + InputStream is; + try { + if(propertiesFile.exists()) { + is = new FileInputStream( propertiesFile ); + loadedProperties.load( is ); + is.close(); + } + } + catch ( Exception e ) { + e.printStackTrace(); + } + } +} diff --git a/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/BaseTest.groovy b/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/BaseTest.groovy index 8ffe0de114..2198517038 100644 --- a/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/BaseTest.groovy +++ b/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/BaseTest.groovy @@ -11,8 +11,6 @@ import com.marklogic.client.io.InputStreamHandle import com.marklogic.client.io.StringHandle import com.marklogic.hub.HubConfig import com.marklogic.hub.HubConfigBuilder -import com.marklogic.mgmt.ManageClient -import com.marklogic.mgmt.resource.databases.DatabaseManager import org.apache.commons.io.FileUtils import org.apache.commons.io.FilenameUtils import org.custommonkey.xmlunit.XMLUnit From e237403f06d84efee0554a93659d47cde24fc01d Mon Sep 17 00:00:00 2001 From: Alexander Ebadirad Date: Tue, 20 Feb 2018 12:14:47 -0700 Subject: [PATCH 12/22] Create installinfo interface --- .../java/com/marklogic/hub/InstallInfo.java | 246 +++--------------- .../com/marklogic/hub/impl/DataHubImpl.java | 2 +- .../marklogic/hub/impl/InstallInfoImpl.java | 244 +++++++++++++++++ 3 files changed, 287 insertions(+), 205 deletions(-) create mode 100644 marklogic-data-hub/src/main/java/com/marklogic/hub/impl/InstallInfoImpl.java diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/InstallInfo.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/InstallInfo.java index 758ac4240d..0b0afb0918 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/InstallInfo.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/InstallInfo.java @@ -1,242 +1,80 @@ -/* - * Copyright 2012-2018 MarkLogic Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ package com.marklogic.hub; -public class InstallInfo { - private boolean stagingAppServerExists = false; - private boolean finalAppServerExists = false; - private boolean traceAppServerExists = false; - private boolean jobAppServerExists = false; - - private boolean stagingDbExists = false; - private boolean finalDbExists = false; - private boolean traceDbExists = false; - private boolean jobDbExists = false; - - private boolean stagingTripleIndexOn = false; - private boolean stagingCollectionLexiconOn = false; - private boolean finalTripleIndexOn = false; - private boolean finalCollectionLexiconOn = false; - - private boolean stagingForestsExist = false; - private boolean finalForestsExist = false; - private boolean traceForestsExist = false; - private boolean jobForestsExist = false; - - public boolean isPartiallyInstalled() { - return ( - isStagingAppServerExists() || - isFinalAppServerExists() || - isTraceAppServerExists() || - isJobAppServerExists() || - isStagingDbExists() || - isStagingTripleIndexOn() || - isStagingCollectionLexiconOn() || - isFinalDbExists() || - isFinalTripleIndexOn() || - isFinalCollectionLexiconOn() || - isTraceDbExists() || - isJobDbExists() || - isStagingForestsExist() || - isFinalForestsExist() || - isTraceForestsExist() || - isJobForestsExist() - ); - } +import com.marklogic.hub.impl.InstallInfoImpl; - public boolean isInstalled() { - boolean appserversOk = ( - isStagingAppServerExists() && - isFinalAppServerExists() && - isTraceAppServerExists() && - isJobAppServerExists() - ); - - boolean dbsOk = ( - isStagingDbExists() && - isStagingTripleIndexOn() && - isStagingCollectionLexiconOn() && - isFinalDbExists() && - isFinalTripleIndexOn() && - isFinalCollectionLexiconOn() && - isTraceDbExists() && - isJobDbExists() - ); - boolean forestsOk = ( - isStagingForestsExist() && - isFinalForestsExist() && - isTraceForestsExist() && - isJobForestsExist() - ); - - return (appserversOk && dbsOk && forestsOk); - } +public interface InstallInfo { - public String toString() { - return "\n" + - "Checking MarkLogic Installation:\n" + - "\tAppServers:\n" + - "\t\tStaging: " + (isStagingAppServerExists() ? "exists" : "MISSING") + "\n" + - "\t\tFinal: " + (isFinalAppServerExists() ? "exists" : "MISSING") + "\n" + - "\t\tTrace: " + (isTraceAppServerExists() ? "exists" : "MISSING") + "\n" + - "\t\tJob: " + (isJobAppServerExists() ? "exists" : "MISSING") + "\n" + - "\tDatabases:\n" + - "\t\tStaging: " + (isStagingDbExists() ? "exists" : "MISSING") + "\n" + - "\t\tFinal: " + (isFinalDbExists() ? "exists" : "MISSING") + "\n" + - "\t\tTrace: " + (isTraceDbExists() ? "exists" : "MISSING") + "\n" + - "\t\tJob: " + (isJobDbExists() ? "exists" : "MISSING") + "\n" + - "\tDatabases Indexes:\n" + - "\t\tStaging Triples Index : " + (isStagingTripleIndexOn() ? "exists" : "MISSING") + "\n" + - "\t\tStaging Collection Lexicon : " + (isStagingCollectionLexiconOn() ? "exists" : "MISSING") + "\n" + - "\t\tFinal Triples Index : " + (isFinalTripleIndexOn() ? "exists" : "MISSING") + "\n" + - "\t\tFinal Collection Lexicon : " + (isFinalCollectionLexiconOn() ? "exists" : "MISSING") + "\n" + - "\tForests\n" + - "\t\tStaging: " + (isStagingForestsExist() ? "exists" : "MISSING") + "\n" + - "\t\tFinal: " + (isFinalForestsExist() ? "exists" : "MISSING") + "\n" + - "\t\tTrace: " + (isTraceForestsExist() ? "exists" : "MISSING") + "\n" + - "\t\tJob: " + (isJobForestsExist() ? "exists" : "MISSING") + "\n" + - "\n\n" + - "OVERAL RESULT: " + (isInstalled() ? "INSTALLED" : "NOT INSTALLED") + "\n"; + static InstallInfo create() { + return new InstallInfoImpl(); } - public boolean isStagingAppServerExists() { - return stagingAppServerExists; - } + boolean isPartiallyInstalled(); - public void setStagingAppServerExists(boolean stagingAppServerExists) { - this.stagingAppServerExists = stagingAppServerExists; - } + boolean isInstalled(); - public boolean isFinalAppServerExists() { - return finalAppServerExists; - } + String toString(); - public void setFinalAppServerExists(boolean finalAppServerExists) { - this.finalAppServerExists = finalAppServerExists; - } + boolean isStagingAppServerExists(); - public boolean isTraceAppServerExists() { - return traceAppServerExists; - } + void setStagingAppServerExists(boolean stagingAppServerExists); - public void setTraceAppServerExists(boolean traceAppServerExists) { - this.traceAppServerExists = traceAppServerExists; - } + boolean isFinalAppServerExists(); - public boolean isJobAppServerExists() { - return jobAppServerExists; - } + void setFinalAppServerExists(boolean finalAppServerExists); - public void setJobAppServerExists(boolean jobAppServerExists) { - this.jobAppServerExists = jobAppServerExists; - } + boolean isTraceAppServerExists(); - public boolean isStagingDbExists() { - return stagingDbExists; - } + void setTraceAppServerExists(boolean traceAppServerExists); - public void setStagingDbExists(boolean stagingDbExists) { - this.stagingDbExists = stagingDbExists; - } + boolean isJobAppServerExists(); - public boolean isFinalDbExists() { - return finalDbExists; - } + void setJobAppServerExists(boolean jobAppServerExists); - public void setFinalDbExists(boolean finalDbExists) { - this.finalDbExists = finalDbExists; - } + boolean isStagingDbExists(); - public boolean isTraceDbExists() { - return traceDbExists; - } + void setStagingDbExists(boolean stagingDbExists); - public void setTraceDbExists(boolean traceDbExists) { - this.traceDbExists = traceDbExists; - } + boolean isFinalDbExists(); - public boolean isJobDbExists() { - return jobDbExists; - } + void setFinalDbExists(boolean finalDbExists); - public void setJobDbExists(boolean jobDbExists) { - this.jobDbExists = jobDbExists; - } + boolean isTraceDbExists(); - public boolean isStagingTripleIndexOn() { - return stagingTripleIndexOn; - } + void setTraceDbExists(boolean traceDbExists); - public void setStagingTripleIndexOn(boolean stagingTripleIndexOn) { - this.stagingTripleIndexOn = stagingTripleIndexOn; - } + boolean isJobDbExists(); - public boolean isStagingCollectionLexiconOn() { - return stagingCollectionLexiconOn; - } + void setJobDbExists(boolean jobDbExists); - public void setStagingCollectionLexiconOn(boolean stagingCollectionLexiconOn) { - this.stagingCollectionLexiconOn = stagingCollectionLexiconOn; - } + boolean isStagingTripleIndexOn(); - public boolean isFinalTripleIndexOn() { - return finalTripleIndexOn; - } + void setStagingTripleIndexOn(boolean stagingTripleIndexOn); - public void setFinalTripleIndexOn(boolean finalTripleIndexOn) { - this.finalTripleIndexOn = finalTripleIndexOn; - } + boolean isStagingCollectionLexiconOn(); - public boolean isFinalCollectionLexiconOn() { - return finalCollectionLexiconOn; - } + void setStagingCollectionLexiconOn(boolean stagingCollectionLexiconOn); - public void setFinalCollectionLexiconOn(boolean finalCollectionLexiconOn) { - this.finalCollectionLexiconOn = finalCollectionLexiconOn; - } + boolean isFinalTripleIndexOn(); - public boolean isStagingForestsExist() { - return stagingForestsExist; - } + void setFinalTripleIndexOn(boolean finalTripleIndexOn); - public void setStagingForestsExist(boolean stagingForestsExist) { - this.stagingForestsExist = stagingForestsExist; - } + boolean isFinalCollectionLexiconOn(); - public boolean isFinalForestsExist() { - return finalForestsExist; - } + void setFinalCollectionLexiconOn(boolean finalCollectionLexiconOn); - public void setFinalForestsExist(boolean finalForestsExist) { - this.finalForestsExist = finalForestsExist; - } + boolean isStagingForestsExist(); - public boolean isTraceForestsExist() { - return traceForestsExist; - } + void setStagingForestsExist(boolean stagingForestsExist); - public void setTraceForestsExist(boolean traceForestsExist) { - this.traceForestsExist = traceForestsExist; - } + boolean isFinalForestsExist(); - public boolean isJobForestsExist() { - return jobForestsExist; - } + void setFinalForestsExist(boolean finalForestsExist); - public void setJobForestsExist(boolean jobForestsExist) { - this.jobForestsExist = jobForestsExist; - } + boolean isTraceForestsExist(); + + void setTraceForestsExist(boolean traceForestsExist); + + boolean isJobForestsExist(); + + void setJobForestsExist(boolean jobForestsExist); } diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/DataHubImpl.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/DataHubImpl.java index d12f618996..d797e9fb25 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/DataHubImpl.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/DataHubImpl.java @@ -105,7 +105,7 @@ void setAdminManager(AdminManager manager) { */ @Override public InstallInfo isInstalled() { - InstallInfo installInfo = new InstallInfo(); + InstallInfo installInfo = InstallInfo.create(); ResourcesFragment srf = getServerManager().getAsXml(); installInfo.setStagingAppServerExists(srf.resourceExists(hubConfig.getStagingHttpName())); diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/InstallInfoImpl.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/InstallInfoImpl.java new file mode 100644 index 0000000000..50d7afb233 --- /dev/null +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/InstallInfoImpl.java @@ -0,0 +1,244 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.marklogic.hub.impl; + +import com.marklogic.hub.InstallInfo; + +public class InstallInfoImpl implements InstallInfo { + private boolean stagingAppServerExists = false; + private boolean finalAppServerExists = false; + private boolean traceAppServerExists = false; + private boolean jobAppServerExists = false; + + private boolean stagingDbExists = false; + private boolean finalDbExists = false; + private boolean traceDbExists = false; + private boolean jobDbExists = false; + + private boolean stagingTripleIndexOn = false; + private boolean stagingCollectionLexiconOn = false; + private boolean finalTripleIndexOn = false; + private boolean finalCollectionLexiconOn = false; + + private boolean stagingForestsExist = false; + private boolean finalForestsExist = false; + private boolean traceForestsExist = false; + private boolean jobForestsExist = false; + + @Override public boolean isPartiallyInstalled() { + return ( + isStagingAppServerExists() || + isFinalAppServerExists() || + isTraceAppServerExists() || + isJobAppServerExists() || + isStagingDbExists() || + isStagingTripleIndexOn() || + isStagingCollectionLexiconOn() || + isFinalDbExists() || + isFinalTripleIndexOn() || + isFinalCollectionLexiconOn() || + isTraceDbExists() || + isJobDbExists() || + isStagingForestsExist() || + isFinalForestsExist() || + isTraceForestsExist() || + isJobForestsExist() + ); + } + + @Override public boolean isInstalled() { + boolean appserversOk = ( + isStagingAppServerExists() && + isFinalAppServerExists() && + isTraceAppServerExists() && + isJobAppServerExists() + ); + + boolean dbsOk = ( + isStagingDbExists() && + isStagingTripleIndexOn() && + isStagingCollectionLexiconOn() && + isFinalDbExists() && + isFinalTripleIndexOn() && + isFinalCollectionLexiconOn() && + isTraceDbExists() && + isJobDbExists() + ); + boolean forestsOk = ( + isStagingForestsExist() && + isFinalForestsExist() && + isTraceForestsExist() && + isJobForestsExist() + ); + + return (appserversOk && dbsOk && forestsOk); + } + + @Override public String toString() { + return "\n" + + "Checking MarkLogic Installation:\n" + + "\tAppServers:\n" + + "\t\tStaging: " + (isStagingAppServerExists() ? "exists" : "MISSING") + "\n" + + "\t\tFinal: " + (isFinalAppServerExists() ? "exists" : "MISSING") + "\n" + + "\t\tTrace: " + (isTraceAppServerExists() ? "exists" : "MISSING") + "\n" + + "\t\tJob: " + (isJobAppServerExists() ? "exists" : "MISSING") + "\n" + + "\tDatabases:\n" + + "\t\tStaging: " + (isStagingDbExists() ? "exists" : "MISSING") + "\n" + + "\t\tFinal: " + (isFinalDbExists() ? "exists" : "MISSING") + "\n" + + "\t\tTrace: " + (isTraceDbExists() ? "exists" : "MISSING") + "\n" + + "\t\tJob: " + (isJobDbExists() ? "exists" : "MISSING") + "\n" + + "\tDatabases Indexes:\n" + + "\t\tStaging Triples Index : " + (isStagingTripleIndexOn() ? "exists" : "MISSING") + "\n" + + "\t\tStaging Collection Lexicon : " + (isStagingCollectionLexiconOn() ? "exists" : "MISSING") + "\n" + + "\t\tFinal Triples Index : " + (isFinalTripleIndexOn() ? "exists" : "MISSING") + "\n" + + "\t\tFinal Collection Lexicon : " + (isFinalCollectionLexiconOn() ? "exists" : "MISSING") + "\n" + + "\tForests\n" + + "\t\tStaging: " + (isStagingForestsExist() ? "exists" : "MISSING") + "\n" + + "\t\tFinal: " + (isFinalForestsExist() ? "exists" : "MISSING") + "\n" + + "\t\tTrace: " + (isTraceForestsExist() ? "exists" : "MISSING") + "\n" + + "\t\tJob: " + (isJobForestsExist() ? "exists" : "MISSING") + "\n" + + "\n\n" + + "OVERAL RESULT: " + (isInstalled() ? "INSTALLED" : "NOT INSTALLED") + "\n"; + } + + @Override public boolean isStagingAppServerExists() { + return stagingAppServerExists; + } + + @Override public void setStagingAppServerExists(boolean stagingAppServerExists) { + this.stagingAppServerExists = stagingAppServerExists; + } + + @Override public boolean isFinalAppServerExists() { + return finalAppServerExists; + } + + @Override public void setFinalAppServerExists(boolean finalAppServerExists) { + this.finalAppServerExists = finalAppServerExists; + } + + @Override public boolean isTraceAppServerExists() { + return traceAppServerExists; + } + + @Override public void setTraceAppServerExists(boolean traceAppServerExists) { + this.traceAppServerExists = traceAppServerExists; + } + + @Override public boolean isJobAppServerExists() { + return jobAppServerExists; + } + + @Override public void setJobAppServerExists(boolean jobAppServerExists) { + this.jobAppServerExists = jobAppServerExists; + } + + @Override public boolean isStagingDbExists() { + return stagingDbExists; + } + + @Override public void setStagingDbExists(boolean stagingDbExists) { + this.stagingDbExists = stagingDbExists; + } + + @Override public boolean isFinalDbExists() { + return finalDbExists; + } + + @Override public void setFinalDbExists(boolean finalDbExists) { + this.finalDbExists = finalDbExists; + } + + @Override public boolean isTraceDbExists() { + return traceDbExists; + } + + @Override public void setTraceDbExists(boolean traceDbExists) { + this.traceDbExists = traceDbExists; + } + + @Override public boolean isJobDbExists() { + return jobDbExists; + } + + @Override public void setJobDbExists(boolean jobDbExists) { + this.jobDbExists = jobDbExists; + } + + @Override public boolean isStagingTripleIndexOn() { + return stagingTripleIndexOn; + } + + @Override public void setStagingTripleIndexOn(boolean stagingTripleIndexOn) { + this.stagingTripleIndexOn = stagingTripleIndexOn; + } + + @Override public boolean isStagingCollectionLexiconOn() { + return stagingCollectionLexiconOn; + } + + @Override public void setStagingCollectionLexiconOn(boolean stagingCollectionLexiconOn) { + this.stagingCollectionLexiconOn = stagingCollectionLexiconOn; + } + + @Override public boolean isFinalTripleIndexOn() { + return finalTripleIndexOn; + } + + @Override public void setFinalTripleIndexOn(boolean finalTripleIndexOn) { + this.finalTripleIndexOn = finalTripleIndexOn; + } + + @Override public boolean isFinalCollectionLexiconOn() { + return finalCollectionLexiconOn; + } + + @Override public void setFinalCollectionLexiconOn(boolean finalCollectionLexiconOn) { + this.finalCollectionLexiconOn = finalCollectionLexiconOn; + } + + @Override public boolean isStagingForestsExist() { + return stagingForestsExist; + } + + @Override public void setStagingForestsExist(boolean stagingForestsExist) { + this.stagingForestsExist = stagingForestsExist; + } + + @Override public boolean isFinalForestsExist() { + return finalForestsExist; + } + + @Override public void setFinalForestsExist(boolean finalForestsExist) { + this.finalForestsExist = finalForestsExist; + } + + @Override public boolean isTraceForestsExist() { + return traceForestsExist; + } + + @Override public void setTraceForestsExist(boolean traceForestsExist) { + this.traceForestsExist = traceForestsExist; + } + + @Override public boolean isJobForestsExist() { + return jobForestsExist; + } + + @Override public void setJobForestsExist(boolean jobForestsExist) { + this.jobForestsExist = jobForestsExist; + } +} From f31b239c4743941a7bbea88ace8657328357fc67 Mon Sep 17 00:00:00 2001 From: Alexander Ebadirad Date: Mon, 26 Feb 2018 09:23:41 -0700 Subject: [PATCH 13/22] Change names from searchoptions to queryoptions for java api consistency --- .../main/java/com/marklogic/hub/DataHub.java | 8 +++ .../java/com/marklogic/hub/EntityManager.java | 4 +- .../java/com/marklogic/hub/HubConfig.java | 4 +- .../commands/LoadUserModulesCommand.java | 2 +- .../marklogic/hub/impl/EntityManagerImpl.java | 22 ++++---- .../com/marklogic/hub/EntityManagerTest.java | 52 +++++++++---------- .../service/EntityManagerService.java | 2 +- 7 files changed, 51 insertions(+), 43 deletions(-) diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/DataHub.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/DataHub.java index 264fb7ffd5..5b1e7521bc 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/DataHub.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/DataHub.java @@ -44,6 +44,14 @@ public String toString() { } } + enum DatabaseKind { + STAGING, + FINAL, + JOB, + TRACE, + SCHEMA + } + ManageClient getManageClient(); AdminManager getAdminManager(); diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/EntityManager.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/EntityManager.java index 0cc84d14c8..bd407dcc3f 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/EntityManager.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/EntityManager.java @@ -11,9 +11,9 @@ static EntityManager create(HubConfig hubConfig) { return new EntityManagerImpl(hubConfig); } - boolean saveSearchOptions(); + boolean saveQueryOptions(); - List deploySearchOptions(); + List deployQueryOptions(); boolean saveDbIndexes(); } diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/HubConfig.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/HubConfig.java index c0e474857f..e04141963c 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/HubConfig.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/HubConfig.java @@ -41,8 +41,8 @@ public interface HubConfig { String HUB_CONFIG_DIR = "hub-internal-config"; String USER_CONFIG_DIR = "user-config"; String ENTITY_CONFIG_DIR = "entity-config"; - String STAGING_ENTITY_SEARCH_OPTIONS_FILE = "staging-entity-options.xml"; - String FINAL_ENTITY_SEARCH_OPTIONS_FILE = "final-entity-options.xml"; + String STAGING_ENTITY_QUERY_OPTIONS_FILE = "staging-entity-options.xml"; + String FINAL_ENTITY_QUERY_OPTIONS_FILE = "final-entity-options.xml"; String DEFAULT_STAGING_NAME = "data-hub-STAGING"; String DEFAULT_FINAL_NAME = "data-hub-FINAL"; diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/deploy/commands/LoadUserModulesCommand.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/deploy/commands/LoadUserModulesCommand.java index 412f1f95b2..ddd188be85 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/deploy/commands/LoadUserModulesCommand.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/deploy/commands/LoadUserModulesCommand.java @@ -164,7 +164,7 @@ public void execute(CommandContext context) { // deploy the auto-generated ES search options EntityManager entityManager = EntityManager.create(hubConfig); - entityManager.deploySearchOptions(); + entityManager.deployQueryOptions(); try { if (startPath.toFile().exists()) { diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/EntityManagerImpl.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/EntityManagerImpl.java index 5718006913..76843a684c 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/EntityManagerImpl.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/EntityManagerImpl.java @@ -52,16 +52,16 @@ public EntityManagerImpl(HubConfig hubConfig) { this.hubConfig = hubConfig; } - @Override public boolean saveSearchOptions() { - SearchOptionsGenerator generator = new SearchOptionsGenerator(hubConfig.newStagingClient()); + @Override public boolean saveQueryOptions() { + QueryOptionsGenerator generator = new QueryOptionsGenerator(hubConfig.newStagingClient()); try { Path dir = Paths.get(hubConfig.getProjectDir(), HubConfig.ENTITY_CONFIG_DIR); if (!dir.toFile().exists()) { dir.toFile().mkdirs(); } - File stagingFile = Paths.get(dir.toString(), HubConfig.STAGING_ENTITY_SEARCH_OPTIONS_FILE).toFile(); - File finalFile = Paths.get(dir.toString(), HubConfig.FINAL_ENTITY_SEARCH_OPTIONS_FILE).toFile(); + File stagingFile = Paths.get(dir.toString(), HubConfig.STAGING_ENTITY_QUERY_OPTIONS_FILE).toFile(); + File finalFile = Paths.get(dir.toString(), HubConfig.FINAL_ENTITY_QUERY_OPTIONS_FILE).toFile(); long lastModified = Math.max(stagingFile.lastModified(), finalFile.lastModified()); List entities = getModifiedRawEntities(lastModified); @@ -78,9 +78,9 @@ public EntityManagerImpl(HubConfig hubConfig) { return false; } - @Override public List deploySearchOptions() { + @Override public List deployQueryOptions() { // save them first - saveSearchOptions(); + saveQueryOptions(); HubModuleManager propsManager = getPropsMgr(); DefaultModulesLoader modulesLoader = new DefaultModulesLoader(new AssetFileLoader(hubConfig.newFinalClient(), propsManager)); @@ -91,7 +91,7 @@ public EntityManagerImpl(HubConfig hubConfig) { List loadedResources = new ArrayList<>(); Path dir = Paths.get(hubConfig.getProjectDir(), HubConfig.ENTITY_CONFIG_DIR); - File stagingFile = Paths.get(dir.toString(), HubConfig.STAGING_ENTITY_SEARCH_OPTIONS_FILE).toFile(); + File stagingFile = Paths.get(dir.toString(), HubConfig.STAGING_ENTITY_QUERY_OPTIONS_FILE).toFile(); if (stagingFile.exists()) { modulesLoader.setDatabaseClient(hubConfig.newStagingClient()); Resource r = modulesLoader.installQueryOptions(new FileSystemResource(stagingFile)); @@ -100,7 +100,7 @@ public EntityManagerImpl(HubConfig hubConfig) { } } - File finalFile = Paths.get(dir.toString(), HubConfig.FINAL_ENTITY_SEARCH_OPTIONS_FILE).toFile(); + File finalFile = Paths.get(dir.toString(), HubConfig.FINAL_ENTITY_QUERY_OPTIONS_FILE).toFile(); if (finalFile.exists()) { modulesLoader.setDatabaseClient(hubConfig.newFinalClient()); Resource r = modulesLoader.installQueryOptions(new FileSystemResource(finalFile)); @@ -186,12 +186,12 @@ private List getModifiedRawEntities(long minimumFileTimestampToLoad) { return entities; } - private class SearchOptionsGenerator extends ResourceManager { + private class QueryOptionsGenerator extends ResourceManager { private static final String NAME = "ml:searchOptionsGenerator"; private RequestParameters params = new RequestParameters(); - SearchOptionsGenerator(DatabaseClient client) { + QueryOptionsGenerator(DatabaseClient client) { super(); client.init(NAME, this); } @@ -202,7 +202,7 @@ String generateOptions(List entities) { JsonNode node = objectMapper.valueToTree(entities); ResourceServices.ServiceResultIterator resultItr = this.getServices().post(params, new JacksonHandle(node)); if (resultItr == null || ! resultItr.hasNext()) { - throw new IOException("Unable to generate search options"); + throw new IOException("Unable to generate query options"); } ResourceServices.ServiceResult res = resultItr.next(); return res.getContent(new StringHandle()).get(); diff --git a/marklogic-data-hub/src/test/java/com/marklogic/hub/EntityManagerTest.java b/marklogic-data-hub/src/test/java/com/marklogic/hub/EntityManagerTest.java index c46e9bda1c..3a896ca3d9 100644 --- a/marklogic-data-hub/src/test/java/com/marklogic/hub/EntityManagerTest.java +++ b/marklogic-data-hub/src/test/java/com/marklogic/hub/EntityManagerTest.java @@ -99,25 +99,25 @@ private HubModuleManager getPropsMgr() { public void testDeploySearchOptionsWithNoEntities() { Path dir = Paths.get(getHubConfig().getProjectDir(), HubConfig.ENTITY_CONFIG_DIR); - assertNull(getModulesFile("/Default/" + HubConfig.DEFAULT_STAGING_NAME + "/rest-api/options/" + HubConfig.STAGING_ENTITY_SEARCH_OPTIONS_FILE)); - assertNull(getModulesFile("/Default/" + HubConfig.DEFAULT_FINAL_NAME + "/rest-api/options/" + HubConfig.FINAL_ENTITY_SEARCH_OPTIONS_FILE)); - Paths.get(dir.toString(), HubConfig.STAGING_ENTITY_SEARCH_OPTIONS_FILE).toFile().delete(); - Paths.get(dir.toString(), HubConfig.FINAL_ENTITY_SEARCH_OPTIONS_FILE).toFile().delete(); - assertFalse(Paths.get(dir.toString(), HubConfig.STAGING_ENTITY_SEARCH_OPTIONS_FILE).toFile().exists()); - assertFalse(Paths.get(dir.toString(), HubConfig.FINAL_ENTITY_SEARCH_OPTIONS_FILE).toFile().exists()); + assertNull(getModulesFile("/Default/" + HubConfig.DEFAULT_STAGING_NAME + "/rest-api/options/" + HubConfig.STAGING_ENTITY_QUERY_OPTIONS_FILE)); + assertNull(getModulesFile("/Default/" + HubConfig.DEFAULT_FINAL_NAME + "/rest-api/options/" + HubConfig.FINAL_ENTITY_QUERY_OPTIONS_FILE)); + Paths.get(dir.toString(), HubConfig.STAGING_ENTITY_QUERY_OPTIONS_FILE).toFile().delete(); + Paths.get(dir.toString(), HubConfig.FINAL_ENTITY_QUERY_OPTIONS_FILE).toFile().delete(); + assertFalse(Paths.get(dir.toString(), HubConfig.STAGING_ENTITY_QUERY_OPTIONS_FILE).toFile().exists()); + assertFalse(Paths.get(dir.toString(), HubConfig.FINAL_ENTITY_QUERY_OPTIONS_FILE).toFile().exists()); assertEquals(0, getStagingDocCount()); assertEquals(0, getFinalDocCount()); EntityManager entityManager = EntityManager.create(getHubConfig()); - List deployed = entityManager.deploySearchOptions(); + List deployed = entityManager.deployQueryOptions(); assertEquals(0, deployed.size()); - assertFalse(Paths.get(dir.toString(), HubConfig.STAGING_ENTITY_SEARCH_OPTIONS_FILE).toFile().exists()); - assertFalse(Paths.get(dir.toString(), HubConfig.FINAL_ENTITY_SEARCH_OPTIONS_FILE).toFile().exists()); + assertFalse(Paths.get(dir.toString(), HubConfig.STAGING_ENTITY_QUERY_OPTIONS_FILE).toFile().exists()); + assertFalse(Paths.get(dir.toString(), HubConfig.FINAL_ENTITY_QUERY_OPTIONS_FILE).toFile().exists()); assertEquals(0, getStagingDocCount()); assertEquals(0, getFinalDocCount()); - assertNull(getModulesFile("/Default/" + HubConfig.DEFAULT_STAGING_NAME + "/rest-api/options/" + HubConfig.STAGING_ENTITY_SEARCH_OPTIONS_FILE)); - assertNull(getModulesFile("/Default/" + HubConfig.DEFAULT_FINAL_NAME + "/rest-api/options/" + HubConfig.FINAL_ENTITY_SEARCH_OPTIONS_FILE)); + assertNull(getModulesFile("/Default/" + HubConfig.DEFAULT_STAGING_NAME + "/rest-api/options/" + HubConfig.STAGING_ENTITY_QUERY_OPTIONS_FILE)); + assertNull(getModulesFile("/Default/" + HubConfig.DEFAULT_FINAL_NAME + "/rest-api/options/" + HubConfig.FINAL_ENTITY_QUERY_OPTIONS_FILE)); } @Test @@ -126,36 +126,36 @@ public void testDeploySearchOptions() throws IOException, SAXException { Path dir = Paths.get(getHubConfig().getProjectDir(), HubConfig.ENTITY_CONFIG_DIR); - assertNull(getModulesFile("/Default/" + HubConfig.DEFAULT_STAGING_NAME + "/rest-api/options/" + HubConfig.STAGING_ENTITY_SEARCH_OPTIONS_FILE)); - assertNull(getModulesFile("/Default/" + HubConfig.DEFAULT_FINAL_NAME + "/rest-api/options/" + HubConfig.FINAL_ENTITY_SEARCH_OPTIONS_FILE)); - assertFalse(Paths.get(dir.toString(), HubConfig.STAGING_ENTITY_SEARCH_OPTIONS_FILE).toFile().exists()); - assertFalse(Paths.get(dir.toString(), HubConfig.FINAL_ENTITY_SEARCH_OPTIONS_FILE).toFile().exists()); + assertNull(getModulesFile("/Default/" + HubConfig.DEFAULT_STAGING_NAME + "/rest-api/options/" + HubConfig.STAGING_ENTITY_QUERY_OPTIONS_FILE)); + assertNull(getModulesFile("/Default/" + HubConfig.DEFAULT_FINAL_NAME + "/rest-api/options/" + HubConfig.FINAL_ENTITY_QUERY_OPTIONS_FILE)); + assertFalse(Paths.get(dir.toString(), HubConfig.STAGING_ENTITY_QUERY_OPTIONS_FILE).toFile().exists()); + assertFalse(Paths.get(dir.toString(), HubConfig.FINAL_ENTITY_QUERY_OPTIONS_FILE).toFile().exists()); assertEquals(0, getStagingDocCount()); assertEquals(0, getFinalDocCount()); EntityManager entityManager = EntityManager.create(getHubConfig()); - List deployed = entityManager.deploySearchOptions(); + List deployed = entityManager.deployQueryOptions(); assertEquals(2, deployed.size()); - assertTrue(Paths.get(dir.toString(), HubConfig.STAGING_ENTITY_SEARCH_OPTIONS_FILE).toFile().exists()); - assertTrue(Paths.get(dir.toString(), HubConfig.FINAL_ENTITY_SEARCH_OPTIONS_FILE).toFile().exists()); + assertTrue(Paths.get(dir.toString(), HubConfig.STAGING_ENTITY_QUERY_OPTIONS_FILE).toFile().exists()); + assertTrue(Paths.get(dir.toString(), HubConfig.FINAL_ENTITY_QUERY_OPTIONS_FILE).toFile().exists()); assertEquals(0, getStagingDocCount()); assertEquals(0, getFinalDocCount()); - assertXMLEqual(getResource("entity-manager-test/options.xml"), getModulesFile("/Default/" + HubConfig.DEFAULT_STAGING_NAME + "/rest-api/options/" + HubConfig.STAGING_ENTITY_SEARCH_OPTIONS_FILE)); - assertXMLEqual(getResource("entity-manager-test/options.xml"), getModulesFile("/Default/" + HubConfig.DEFAULT_FINAL_NAME + "/rest-api/options/" + HubConfig.FINAL_ENTITY_SEARCH_OPTIONS_FILE)); + assertXMLEqual(getResource("entity-manager-test/options.xml"), getModulesFile("/Default/" + HubConfig.DEFAULT_STAGING_NAME + "/rest-api/options/" + HubConfig.STAGING_ENTITY_QUERY_OPTIONS_FILE)); + assertXMLEqual(getResource("entity-manager-test/options.xml"), getModulesFile("/Default/" + HubConfig.DEFAULT_FINAL_NAME + "/rest-api/options/" + HubConfig.FINAL_ENTITY_QUERY_OPTIONS_FILE)); updateManagerEntity(); - deployed = entityManager.deploySearchOptions(); + deployed = entityManager.deployQueryOptions(); assertEquals(2, deployed.size()); - assertTrue(Paths.get(dir.toString(), HubConfig.STAGING_ENTITY_SEARCH_OPTIONS_FILE).toFile().exists()); - assertTrue(Paths.get(dir.toString(), HubConfig.FINAL_ENTITY_SEARCH_OPTIONS_FILE).toFile().exists()); + assertTrue(Paths.get(dir.toString(), HubConfig.STAGING_ENTITY_QUERY_OPTIONS_FILE).toFile().exists()); + assertTrue(Paths.get(dir.toString(), HubConfig.FINAL_ENTITY_QUERY_OPTIONS_FILE).toFile().exists()); assertEquals(0, getStagingDocCount()); assertEquals(0, getFinalDocCount()); - assertXMLEqual(getResource("entity-manager-test/options2.xml"), getModulesFile("/Default/" + HubConfig.DEFAULT_STAGING_NAME + "/rest-api/options/" + HubConfig.STAGING_ENTITY_SEARCH_OPTIONS_FILE)); - assertXMLEqual(getResource("entity-manager-test/options2.xml"), getModulesFile("/Default/" + HubConfig.DEFAULT_FINAL_NAME + "/rest-api/options/" + HubConfig.FINAL_ENTITY_SEARCH_OPTIONS_FILE)); + assertXMLEqual(getResource("entity-manager-test/options2.xml"), getModulesFile("/Default/" + HubConfig.DEFAULT_STAGING_NAME + "/rest-api/options/" + HubConfig.STAGING_ENTITY_QUERY_OPTIONS_FILE)); + assertXMLEqual(getResource("entity-manager-test/options2.xml"), getModulesFile("/Default/" + HubConfig.DEFAULT_FINAL_NAME + "/rest-api/options/" + HubConfig.FINAL_ENTITY_QUERY_OPTIONS_FILE)); // shouldn't deploy a 2nd time because of modules properties files - deployed = entityManager.deploySearchOptions(); + deployed = entityManager.deployQueryOptions(); assertEquals(0, deployed.size()); } diff --git a/quick-start/src/main/java/com/marklogic/quickstart/service/EntityManagerService.java b/quick-start/src/main/java/com/marklogic/quickstart/service/EntityManagerService.java index be5cc1e70a..73f0e0cc31 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/service/EntityManagerService.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/service/EntityManagerService.java @@ -203,7 +203,7 @@ public void deleteEntity(String entity) throws IOException { public void deploySearchOptions(EnvironmentConfig environmentConfig) { EntityManager em = EntityManager.create(environmentConfig.getMlSettings()); - em.deploySearchOptions(); + em.deployQueryOptions(); } public void saveDbIndexes(EnvironmentConfig environmentConfig) { From eb2e71750551d5ff4251c118a96d17c856257cd0 Mon Sep 17 00:00:00 2001 From: Alexander Ebadirad Date: Mon, 26 Feb 2018 13:27:43 -0700 Subject: [PATCH 14/22] encapsulate the spring resource use while still returning if the staging/final databases had the resource loaded --- .../src/main/java/com/marklogic/hub/EntityManager.java | 5 ++--- .../java/com/marklogic/hub/impl/EntityManagerImpl.java | 10 ++++++---- .../test/java/com/marklogic/hub/EntityManagerTest.java | 7 +++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/EntityManager.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/EntityManager.java index bd407dcc3f..18e360f637 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/EntityManager.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/EntityManager.java @@ -1,9 +1,8 @@ package com.marklogic.hub; import com.marklogic.hub.impl.EntityManagerImpl; -import org.springframework.core.io.Resource; -import java.util.List; +import java.util.HashMap; public interface EntityManager { @@ -13,7 +12,7 @@ static EntityManager create(HubConfig hubConfig) { boolean saveQueryOptions(); - List deployQueryOptions(); + HashMap deployQueryOptions(); boolean saveDbIndexes(); } diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/EntityManagerImpl.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/EntityManagerImpl.java index 76843a684c..fd49b20bc1 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/EntityManagerImpl.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/EntityManagerImpl.java @@ -26,6 +26,7 @@ import com.marklogic.client.io.JacksonHandle; import com.marklogic.client.io.StringHandle; import com.marklogic.client.util.RequestParameters; +import com.marklogic.hub.DataHub; import com.marklogic.hub.EntityManager; import com.marklogic.hub.HubConfig; import com.marklogic.hub.util.HubModuleManager; @@ -40,6 +41,7 @@ import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.List; import java.util.stream.Collectors; @@ -78,7 +80,7 @@ public EntityManagerImpl(HubConfig hubConfig) { return false; } - @Override public List deployQueryOptions() { + @Override public HashMap deployQueryOptions() { // save them first saveQueryOptions(); @@ -88,7 +90,7 @@ public EntityManagerImpl(HubConfig hubConfig) { modulesLoader.setModulesManager(propsManager); modulesLoader.setShutdownTaskExecutorAfterLoadingModules(false); - List loadedResources = new ArrayList<>(); + HashMap loadedResources = new HashMap<>(); Path dir = Paths.get(hubConfig.getProjectDir(), HubConfig.ENTITY_CONFIG_DIR); File stagingFile = Paths.get(dir.toString(), HubConfig.STAGING_ENTITY_QUERY_OPTIONS_FILE).toFile(); @@ -96,7 +98,7 @@ public EntityManagerImpl(HubConfig hubConfig) { modulesLoader.setDatabaseClient(hubConfig.newStagingClient()); Resource r = modulesLoader.installQueryOptions(new FileSystemResource(stagingFile)); if (r != null) { - loadedResources.add(r); + loadedResources.put(DataHub.DatabaseKind.STAGING, true); } } @@ -105,7 +107,7 @@ public EntityManagerImpl(HubConfig hubConfig) { modulesLoader.setDatabaseClient(hubConfig.newFinalClient()); Resource r = modulesLoader.installQueryOptions(new FileSystemResource(finalFile)); if (r != null) { - loadedResources.add(r); + loadedResources.put(DataHub.DatabaseKind.FINAL, true); } } modulesLoader.setShutdownTaskExecutorAfterLoadingModules(true); diff --git a/marklogic-data-hub/src/test/java/com/marklogic/hub/EntityManagerTest.java b/marklogic-data-hub/src/test/java/com/marklogic/hub/EntityManagerTest.java index 3a896ca3d9..a750a02735 100644 --- a/marklogic-data-hub/src/test/java/com/marklogic/hub/EntityManagerTest.java +++ b/marklogic-data-hub/src/test/java/com/marklogic/hub/EntityManagerTest.java @@ -24,14 +24,13 @@ import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; -import org.springframework.core.io.Resource; import org.xml.sax.SAXException; import java.io.File; import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.List; +import java.util.HashMap; import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; import static org.junit.Assert.*; @@ -109,7 +108,7 @@ public void testDeploySearchOptionsWithNoEntities() { assertEquals(0, getFinalDocCount()); EntityManager entityManager = EntityManager.create(getHubConfig()); - List deployed = entityManager.deployQueryOptions(); + HashMap deployed = entityManager.deployQueryOptions(); assertEquals(0, deployed.size()); assertFalse(Paths.get(dir.toString(), HubConfig.STAGING_ENTITY_QUERY_OPTIONS_FILE).toFile().exists()); @@ -134,7 +133,7 @@ public void testDeploySearchOptions() throws IOException, SAXException { assertEquals(0, getFinalDocCount()); EntityManager entityManager = EntityManager.create(getHubConfig()); - List deployed = entityManager.deployQueryOptions(); + HashMap deployed = entityManager.deployQueryOptions(); assertEquals(2, deployed.size()); assertTrue(Paths.get(dir.toString(), HubConfig.STAGING_ENTITY_QUERY_OPTIONS_FILE).toFile().exists()); From beee32e6f762743d0f00e70c1005bd0e10657c6a Mon Sep 17 00:00:00 2001 From: Alexander Ebadirad Date: Mon, 26 Feb 2018 20:38:24 -0700 Subject: [PATCH 15/22] Create databasekind enum as its own enum, remove any external dependecies on unsupporting libraries for hub config and remove the json ignore for the interface exposed methods --- .../main/java/com/marklogic/hub/DataHub.java | 25 +-------- .../java/com/marklogic/hub/DatabaseKind.java | 9 +++ .../java/com/marklogic/hub/HubConfig.java | 56 ++++--------------- .../com/marklogic/hub/impl/DataHubImpl.java | 22 +++++--- .../marklogic/hub/impl/EntityManagerImpl.java | 6 +- .../java/com/marklogic/hub/DataHubTest.java | 2 +- .../java/com/marklogic/hub/HubTestBase.java | 5 +- .../com/marklogic/gradle/DataHubPlugin.groovy | 3 +- .../quickstart/service/DataHubService.java | 7 +-- 9 files changed, 48 insertions(+), 87 deletions(-) create mode 100644 marklogic-data-hub/src/main/java/com/marklogic/hub/DatabaseKind.java diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/DataHub.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/DataHub.java index 5b1e7521bc..4f239cc33d 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/DataHub.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/DataHub.java @@ -1,15 +1,10 @@ package com.marklogic.hub; -import com.marklogic.appdeployer.command.Command; import com.marklogic.hub.deploy.util.HubDeployStatusListener; import com.marklogic.hub.error.CantUpgradeException; import com.marklogic.hub.error.ServerValidationException; import com.marklogic.hub.impl.DataHubImpl; import com.marklogic.hub.util.Versions; -import com.marklogic.mgmt.ManageClient; -import com.marklogic.mgmt.admin.AdminManager; -import com.marklogic.mgmt.resource.appservers.ServerManager; -import com.marklogic.mgmt.resource.databases.DatabaseManager; import java.util.List; @@ -44,23 +39,7 @@ public String toString() { } } - enum DatabaseKind { - STAGING, - FINAL, - JOB, - TRACE, - SCHEMA - } - - ManageClient getManageClient(); - - AdminManager getAdminManager(); - - DatabaseManager getDatabaseManager(); - - ServerManager getServerManager(); - - void setServerManager(ServerManager manager); + void clearDatabase(String database); /** * Determines if the data hub is installed in MarkLogic @@ -84,8 +63,6 @@ enum DatabaseKind { */ void clearUserModules(); - List getCommandList(); - void runPreInstallCheck(); void runPreInstallCheck(Versions versions); diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/DatabaseKind.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/DatabaseKind.java new file mode 100644 index 0000000000..1101b72206 --- /dev/null +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/DatabaseKind.java @@ -0,0 +1,9 @@ +package com.marklogic.hub; + +public enum DatabaseKind { + STAGING, + FINAL, + JOB, + TRACE, + SCHEMA +} diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/HubConfig.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/HubConfig.java index e04141963c..1a8af444ac 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/HubConfig.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/HubConfig.java @@ -15,14 +15,9 @@ */ package com.marklogic.hub; -import com.fasterxml.jackson.annotation.JsonIgnore; import com.marklogic.appdeployer.AppConfig; import com.marklogic.client.DatabaseClient; import com.marklogic.client.DatabaseClientFactory; -import com.marklogic.mgmt.ManageClient; -import com.marklogic.mgmt.ManageConfig; -import com.marklogic.mgmt.admin.AdminConfig; -import com.marklogic.mgmt.admin.AdminManager; import javax.net.ssl.SSLContext; import java.io.File; @@ -92,11 +87,9 @@ public interface HubConfig { boolean getStagingSimpleSsl(); void setStagingSimpleSsl(boolean stagingSimpleSsl); - @JsonIgnore SSLContext getStagingSslContext(); void setStagingSslContext(SSLContext stagingSslContext); - @JsonIgnore DatabaseClientFactory.SSLHostnameVerifier getStagingSslHostnameVerifier(); void setStagingSslHostnameVerifier(DatabaseClientFactory.SSLHostnameVerifier stagingSslHostnameVerifier); @@ -128,11 +121,9 @@ public interface HubConfig { String getFinalScheme(); void setFinalScheme(String finalScheme); - @JsonIgnore boolean getFinalSimpleSsl(); void setFinalSimpleSsl(boolean finalSimpleSsl); - @JsonIgnore SSLContext getFinalSslContext(); void setFinalSslContext(SSLContext finalSslContext); @@ -167,11 +158,10 @@ public interface HubConfig { String getTraceScheme(); void setTraceScheme(String traceScheme); - @JsonIgnore + boolean getTraceSimpleSsl(); void setTraceSimpleSsl(boolean traceSimpleSsl); - @JsonIgnore SSLContext getTraceSslContext(); void setTraceSslContext(SSLContext traceSslContext); @@ -209,11 +199,10 @@ public interface HubConfig { boolean getJobSimpleSsl(); void setJobSimpleSsl(boolean jobSimpleSsl); - @JsonIgnore + SSLContext getJobSslContext(); void setJobSslContext(SSLContext jobSslContext); - @JsonIgnore DatabaseClientFactory.SSLHostnameVerifier getJobSslHostnameVerifier(); void setJobSslHostnameVerifier(DatabaseClientFactory.SSLHostnameVerifier jobSslHostnameVerifier); @@ -267,31 +256,17 @@ public interface HubConfig { String getProjectDir(); void setProjectDir(String projectDir); - @JsonIgnore + HubProject getHubProject(); void initHubProject(); - @JsonIgnore String getHubModulesDeployTimestampFile(); - @JsonIgnore - String getUserModulesDeployTimestampFile(); - @JsonIgnore - File getUserContentDeployTimestampFile(); - @JsonIgnore - ManageConfig getManageConfig(); - void setManageConfig(ManageConfig manageConfig); - @JsonIgnore - ManageClient getManageClient(); - void setManageClient(ManageClient manageClient); - @JsonIgnore - AdminConfig getAdminConfig(); - void setAdminConfig(AdminConfig adminConfig); - @JsonIgnore - AdminManager getAdminManager(); - void setAdminManager(AdminManager adminManager); + String getUserModulesDeployTimestampFile(); + + File getUserContentDeployTimestampFile(); DatabaseClient newAppServicesClient(); @@ -327,33 +302,26 @@ public interface HubConfig { */ DatabaseClient newModulesDbClient(); - @JsonIgnore Path getHubPluginsDir(); - @JsonIgnore Path getHubEntitiesDir(); - @JsonIgnore Path getHubConfigDir(); - @JsonIgnore Path getHubDatabaseDir(); - @JsonIgnore Path getHubServersDir(); - @JsonIgnore Path getHubSecurityDir(); - @JsonIgnore + Path getUserSecurityDir(); - @JsonIgnore + Path getUserConfigDir(); - @JsonIgnore + Path getUserDatabaseDir(); - @JsonIgnore + Path getEntityDatabaseDir(); - @JsonIgnore + Path getUserServersDir(); - @JsonIgnore + Path getHubMimetypesDir(); - @JsonIgnore AppConfig getAppConfig(); void setAppConfig(AppConfig config); diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/DataHubImpl.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/DataHubImpl.java index d797e9fb25..c01608b9e6 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/DataHubImpl.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/DataHubImpl.java @@ -68,16 +68,21 @@ public DataHubImpl(HubConfig hubConfig) { this.hubConfig = hubConfig; } - @Override public ManageClient getManageClient() { + private ManageClient getManageClient() { if (this._manageClient == null) { - this._manageClient = hubConfig.getManageClient(); + this._manageClient = getManageClient(); } return this._manageClient; } - @Override public AdminManager getAdminManager() { + @Override public void clearDatabase(String database){ + DatabaseManager mgr = new DatabaseManager(this.getManageClient()); + mgr.clearDatabase(database); + } + + private AdminManager getAdminManager() { if (this._adminManager == null) { - this._adminManager = hubConfig.getAdminManager(); + this._adminManager = getAdminManager(); } return this._adminManager; } @@ -85,20 +90,21 @@ void setAdminManager(AdminManager manager) { this._adminManager = manager; } - @Override public DatabaseManager getDatabaseManager() { + private DatabaseManager getDatabaseManager() { if (this._databaseManager == null) { this._databaseManager = new DatabaseManager(getManageClient()); } return this._databaseManager; } - @Override public ServerManager getServerManager() { + private ServerManager getServerManager() { if (this._serverManager == null) { this._serverManager = new ServerManager(getManageClient()); } return this._serverManager; } - @Override public void setServerManager(ServerManager manager) { this._serverManager = manager; } + public void setServerManager(ServerManager manager) { this._serverManager = manager; } + /** * Determines if the data hub is installed in MarkLogic * @return true if installed, false otherwise @@ -241,7 +247,7 @@ void setAdminManager(AdminManager manager) { } } - @Override public List getCommandList() { + public List getCommandList() { Map> commandMap = getCommands(); List commands = new ArrayList<>(); for (String name : commandMap.keySet()) { diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/EntityManagerImpl.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/EntityManagerImpl.java index fd49b20bc1..cbd0e0e700 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/EntityManagerImpl.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/EntityManagerImpl.java @@ -26,7 +26,7 @@ import com.marklogic.client.io.JacksonHandle; import com.marklogic.client.io.StringHandle; import com.marklogic.client.util.RequestParameters; -import com.marklogic.hub.DataHub; +import com.marklogic.hub.DatabaseKind; import com.marklogic.hub.EntityManager; import com.marklogic.hub.HubConfig; import com.marklogic.hub.util.HubModuleManager; @@ -98,7 +98,7 @@ public EntityManagerImpl(HubConfig hubConfig) { modulesLoader.setDatabaseClient(hubConfig.newStagingClient()); Resource r = modulesLoader.installQueryOptions(new FileSystemResource(stagingFile)); if (r != null) { - loadedResources.put(DataHub.DatabaseKind.STAGING, true); + loadedResources.put(DatabaseKind.STAGING, true); } } @@ -107,7 +107,7 @@ public EntityManagerImpl(HubConfig hubConfig) { modulesLoader.setDatabaseClient(hubConfig.newFinalClient()); Resource r = modulesLoader.installQueryOptions(new FileSystemResource(finalFile)); if (r != null) { - loadedResources.put(DataHub.DatabaseKind.FINAL, true); + loadedResources.put(DatabaseKind.FINAL, true); } } modulesLoader.setShutdownTaskExecutorAfterLoadingModules(true); diff --git a/marklogic-data-hub/src/test/java/com/marklogic/hub/DataHubTest.java b/marklogic-data-hub/src/test/java/com/marklogic/hub/DataHubTest.java index ac92bebbdf..87514ea36a 100644 --- a/marklogic-data-hub/src/test/java/com/marklogic/hub/DataHubTest.java +++ b/marklogic-data-hub/src/test/java/com/marklogic/hub/DataHubTest.java @@ -45,7 +45,7 @@ public class DataHubTest extends HubTestBase { private ServerManager serverManager; @Mock - private DataHub dh; + private DataHubImpl dh; @Mock private Versions versions; diff --git a/marklogic-data-hub/src/test/java/com/marklogic/hub/HubTestBase.java b/marklogic-data-hub/src/test/java/com/marklogic/hub/HubTestBase.java index 3f417def54..fb36b5769b 100644 --- a/marklogic-data-hub/src/test/java/com/marklogic/hub/HubTestBase.java +++ b/marklogic-data-hub/src/test/java/com/marklogic/hub/HubTestBase.java @@ -36,6 +36,7 @@ import com.marklogic.hub.flow.CodeFormat; import com.marklogic.hub.flow.DataFormat; import com.marklogic.hub.flow.FlowType; +import com.marklogic.hub.impl.HubConfigImpl; import com.marklogic.hub.util.Versions; import org.apache.commons.io.FileUtils; import org.apache.commons.io.FilenameUtils; @@ -573,7 +574,7 @@ protected void assertJsonEqual(String expected, String actual, boolean strict) { protected static void installHubModules() { logger.debug("Installing Data Hub Framework modules into MarkLogic"); - HubConfig hubConfig = getHubConfig(); + HubConfigImpl hubConfig = (HubConfigImpl) getHubConfig(); List commands = new ArrayList<>(); commands.add(new LoadHubModulesCommand(hubConfig)); @@ -591,7 +592,7 @@ protected static void installUserModules(HubConfig hubConfig, boolean force) { loadUserModulesCommand.setForceLoad(force); commands.add(loadUserModulesCommand); - SimpleAppDeployer deployer = new SimpleAppDeployer(hubConfig.getManageClient(), hubConfig.getAdminManager()); + SimpleAppDeployer deployer = new SimpleAppDeployer(((HubConfigImpl)hubConfig).getManageClient(), ((HubConfigImpl)hubConfig).getAdminManager()); deployer.setCommands(commands); deployer.deploy(hubConfig.getAppConfig()); } diff --git a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/DataHubPlugin.groovy b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/DataHubPlugin.groovy index ba2d79a058..653da43581 100644 --- a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/DataHubPlugin.groovy +++ b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/DataHubPlugin.groovy @@ -4,6 +4,7 @@ import com.marklogic.appdeployer.impl.SimpleAppDeployer import com.marklogic.gradle.task.* import com.marklogic.hub.DataHub import com.marklogic.hub.HubConfigBuilder +import com.marklogic.hub.impl.DataHubImpl import com.marklogic.hub.util.Versions import org.gradle.api.Plugin import org.gradle.api.Project @@ -96,6 +97,6 @@ class DataHubPlugin implements Plugin { throw new RuntimeException("You must apply the ml-gradle plugin before the ml-datahub plugin.") } - mlAppDeployer.setCommands(dataHub.getCommandList()) + mlAppDeployer.setCommands(((DataHubImpl)dataHub).getCommandList()) } } diff --git a/quick-start/src/main/java/com/marklogic/quickstart/service/DataHubService.java b/quick-start/src/main/java/com/marklogic/quickstart/service/DataHubService.java index d972c8bddd..974f3e2b3f 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/service/DataHubService.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/service/DataHubService.java @@ -22,9 +22,9 @@ import com.marklogic.hub.deploy.commands.LoadUserModulesCommand; import com.marklogic.hub.deploy.util.HubDeployStatusListener; import com.marklogic.hub.error.CantUpgradeException; +import com.marklogic.hub.impl.HubConfigImpl; import com.marklogic.hub.util.PerformanceLogger; import com.marklogic.hub.validate.EntitiesValidator; -import com.marklogic.mgmt.resource.databases.DatabaseManager; import com.marklogic.quickstart.auth.ConnectionAuthenticationToken; import com.marklogic.quickstart.exception.DataHubException; import com.marklogic.quickstart.listeners.DeployUserModulesListener; @@ -174,8 +174,7 @@ public boolean updateHub(HubConfig config) throws IOException, CantUpgradeExcept public void clearContent(HubConfig config, String database) { DataHub dataHub = DataHub.create(config); - DatabaseManager mgr = new DatabaseManager(dataHub.getManageClient()); - mgr.clearDatabase(database); + dataHub.clearDatabase(database); } private void installUserModules(HubConfig hubConfig, boolean forceLoad, DeployUserModulesListener deployListener) { @@ -184,7 +183,7 @@ private void installUserModules(HubConfig hubConfig, boolean forceLoad, DeployUs loadUserModulesCommand.setForceLoad(forceLoad); commands.add(loadUserModulesCommand); - SimpleAppDeployer deployer = new SimpleAppDeployer(hubConfig.getManageClient(), hubConfig.getAdminManager()); + SimpleAppDeployer deployer = new SimpleAppDeployer(((HubConfigImpl)hubConfig).getManageClient(), ((HubConfigImpl)hubConfig).getAdminManager()); deployer.setCommands(commands); deployer.deploy(hubConfig.getAppConfig()); From 4e1e95c1a2ac4743d55c8d8529f79187a736de37 Mon Sep 17 00:00:00 2001 From: Alexander Ebadirad Date: Mon, 26 Feb 2018 21:41:42 -0700 Subject: [PATCH 16/22] Call hubconfig impl internally --- .../src/main/java/com/marklogic/hub/impl/DataHubImpl.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/DataHubImpl.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/DataHubImpl.java index c01608b9e6..9442982931 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/DataHubImpl.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/DataHubImpl.java @@ -58,19 +58,19 @@ public class DataHubImpl implements DataHub { private ManageClient _manageClient; private DatabaseManager _databaseManager; private ServerManager _serverManager; - private HubConfig hubConfig; + private HubConfigImpl hubConfig; private AdminManager _adminManager; protected final Logger logger = LoggerFactory.getLogger(this.getClass()); public DataHubImpl(HubConfig hubConfig) { - this.hubConfig = hubConfig; + this.hubConfig = ((HubConfigImpl)hubConfig); } private ManageClient getManageClient() { if (this._manageClient == null) { - this._manageClient = getManageClient(); + this._manageClient = this.hubConfig.getManageClient(); } return this._manageClient; } @@ -82,7 +82,7 @@ private ManageClient getManageClient() { private AdminManager getAdminManager() { if (this._adminManager == null) { - this._adminManager = getAdminManager(); + this._adminManager = this.hubConfig.getAdminManager(); } return this._adminManager; } From 33a1b79f8235737400cf52357469ab5b93100567 Mon Sep 17 00:00:00 2001 From: David Cassel Date: Tue, 27 Feb 2018 15:53:03 -0500 Subject: [PATCH 17/22] refactoring InstallInfo as requested by Erik --- .../java/com/marklogic/hub/InstallInfo.java | 64 +-- .../hub/error/InvalidDBOperationError.java | 9 + .../com/marklogic/hub/impl/DataHubImpl.java | 45 +- .../marklogic/hub/impl/InstallInfoImpl.java | 417 ++++++++++-------- 4 files changed, 275 insertions(+), 260 deletions(-) create mode 100644 marklogic-data-hub/src/main/java/com/marklogic/hub/error/InvalidDBOperationError.java diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/InstallInfo.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/InstallInfo.java index 0b0afb0918..5d61aaafd9 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/InstallInfo.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/InstallInfo.java @@ -1,5 +1,6 @@ package com.marklogic.hub; +import com.marklogic.hub.error.InvalidDBOperationError; import com.marklogic.hub.impl.InstallInfoImpl; public interface InstallInfo { @@ -14,67 +15,24 @@ static InstallInfo create() { String toString(); - boolean isStagingAppServerExists(); + boolean isAppServerExistent(DatabaseKind kind); - void setStagingAppServerExists(boolean stagingAppServerExists); + void setAppServerExistent(DatabaseKind kind, boolean stagingAppServerExists); - boolean isFinalAppServerExists(); + boolean isDbExistent(DatabaseKind kind); - void setFinalAppServerExists(boolean finalAppServerExists); + void setDbExistent(DatabaseKind kind, boolean stagingDbExists); - boolean isTraceAppServerExists(); + boolean isTripleIndexOn(DatabaseKind kind); - void setTraceAppServerExists(boolean traceAppServerExists); + void setTripleIndexOn(DatabaseKind kind, boolean stagingTripleIndexOn); - boolean isJobAppServerExists(); + boolean isCollectionLexiconOn(DatabaseKind kind); - void setJobAppServerExists(boolean jobAppServerExists); + void setCollectionLexiconOn(DatabaseKind kind, boolean stagingCollectionLexiconOn); - boolean isStagingDbExists(); + boolean areForestsExistent(DatabaseKind kind); - void setStagingDbExists(boolean stagingDbExists); + void setForestsExistent(DatabaseKind kind, boolean stagingForestsExist); - boolean isFinalDbExists(); - - void setFinalDbExists(boolean finalDbExists); - - boolean isTraceDbExists(); - - void setTraceDbExists(boolean traceDbExists); - - boolean isJobDbExists(); - - void setJobDbExists(boolean jobDbExists); - - boolean isStagingTripleIndexOn(); - - void setStagingTripleIndexOn(boolean stagingTripleIndexOn); - - boolean isStagingCollectionLexiconOn(); - - void setStagingCollectionLexiconOn(boolean stagingCollectionLexiconOn); - - boolean isFinalTripleIndexOn(); - - void setFinalTripleIndexOn(boolean finalTripleIndexOn); - - boolean isFinalCollectionLexiconOn(); - - void setFinalCollectionLexiconOn(boolean finalCollectionLexiconOn); - - boolean isStagingForestsExist(); - - void setStagingForestsExist(boolean stagingForestsExist); - - boolean isFinalForestsExist(); - - void setFinalForestsExist(boolean finalForestsExist); - - boolean isTraceForestsExist(); - - void setTraceForestsExist(boolean traceForestsExist); - - boolean isJobForestsExist(); - - void setJobForestsExist(boolean jobForestsExist); } diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/error/InvalidDBOperationError.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/error/InvalidDBOperationError.java new file mode 100644 index 0000000000..40033489c0 --- /dev/null +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/error/InvalidDBOperationError.java @@ -0,0 +1,9 @@ +package com.marklogic.hub.error; + +import com.marklogic.hub.DatabaseKind; + +public class InvalidDBOperationError extends Error { + public InvalidDBOperationError(DatabaseKind kind, String operation) { + super("Attempt to " + operation + " on the " + kind + " database"); + } +} diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/DataHubImpl.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/DataHubImpl.java index 9442982931..7b8240641f 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/DataHubImpl.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/DataHubImpl.java @@ -22,10 +22,7 @@ import com.marklogic.appdeployer.command.forests.DeployCustomForestsCommand; import com.marklogic.client.FailedRequestException; import com.marklogic.client.eval.ServerEvaluationCall; -import com.marklogic.hub.DataHub; -import com.marklogic.hub.FlowManager; -import com.marklogic.hub.HubConfig; -import com.marklogic.hub.InstallInfo; +import com.marklogic.hub.*; import com.marklogic.hub.deploy.HubAppDeployer; import com.marklogic.hub.deploy.commands.*; import com.marklogic.hub.deploy.util.HubDeployStatusListener; @@ -114,39 +111,39 @@ private ServerManager getServerManager() { InstallInfo installInfo = InstallInfo.create(); ResourcesFragment srf = getServerManager().getAsXml(); - installInfo.setStagingAppServerExists(srf.resourceExists(hubConfig.getStagingHttpName())); - installInfo.setFinalAppServerExists(srf.resourceExists(hubConfig.getFinalHttpName())); - installInfo.setTraceAppServerExists(srf.resourceExists(hubConfig.getTraceHttpName())); - installInfo.setJobAppServerExists(srf.resourceExists(hubConfig.getJobHttpName())); + installInfo.setAppServerExistent(DatabaseKind.STAGING, srf.resourceExists(hubConfig.getStagingHttpName())); + installInfo.setAppServerExistent(DatabaseKind.FINAL, srf.resourceExists(hubConfig.getFinalHttpName())); + installInfo.setAppServerExistent(DatabaseKind.TRACE, srf.resourceExists(hubConfig.getTraceHttpName())); + installInfo.setAppServerExistent(DatabaseKind.JOB, srf.resourceExists(hubConfig.getJobHttpName())); ResourcesFragment drf = getDatabaseManager().getAsXml(); - installInfo.setStagingDbExists(drf.resourceExists(hubConfig.getStagingDbName())); - installInfo.setFinalDbExists(drf.resourceExists(hubConfig.getFinalDbName())); - installInfo.setTraceDbExists(drf.resourceExists(hubConfig.getTraceDbName())); - installInfo.setJobDbExists(drf.resourceExists(hubConfig.getJobDbName())); + installInfo.setDbExistent(DatabaseKind.STAGING, drf.resourceExists(hubConfig.getStagingDbName())); + installInfo.setDbExistent(DatabaseKind.FINAL, drf.resourceExists(hubConfig.getFinalDbName())); + installInfo.setDbExistent(DatabaseKind.TRACE, drf.resourceExists(hubConfig.getTraceDbName())); + installInfo.setDbExistent(DatabaseKind.JOB, drf.resourceExists(hubConfig.getJobDbName())); - if (installInfo.isStagingDbExists()) { + if (installInfo.isDbExistent(DatabaseKind.STAGING)) { Fragment f = getDatabaseManager().getPropertiesAsXml(hubConfig.getStagingDbName()); - installInfo.setStagingTripleIndexOn(Boolean.parseBoolean(f.getElementValue("//m:triple-index"))); - installInfo.setStagingCollectionLexiconOn(Boolean.parseBoolean(f.getElementValue("//m:collection-lexicon"))); - installInfo.setStagingForestsExist((f.getElements("//m:forest").size() > 0)); + installInfo.setTripleIndexOn(DatabaseKind.STAGING, Boolean.parseBoolean(f.getElementValue("//m:triple-index"))); + installInfo.setCollectionLexiconOn(DatabaseKind.STAGING, Boolean.parseBoolean(f.getElementValue("//m:collection-lexicon"))); + installInfo.setForestsExistent(DatabaseKind.STAGING, (f.getElements("//m:forest").size() > 0)); } - if (installInfo.isFinalDbExists()) { + if (installInfo.isDbExistent(DatabaseKind.FINAL)) { Fragment f = getDatabaseManager().getPropertiesAsXml(hubConfig.getFinalDbName()); - installInfo.setFinalTripleIndexOn(Boolean.parseBoolean(f.getElementValue("//m:triple-index"))); - installInfo.setFinalCollectionLexiconOn(Boolean.parseBoolean(f.getElementValue("//m:collection-lexicon"))); - installInfo.setFinalForestsExist((f.getElements("//m:forest").size() > 0)); + installInfo.setTripleIndexOn(DatabaseKind.FINAL, Boolean.parseBoolean(f.getElementValue("//m:triple-index"))); + installInfo.setCollectionLexiconOn(DatabaseKind.FINAL, Boolean.parseBoolean(f.getElementValue("//m:collection-lexicon"))); + installInfo.setForestsExistent(DatabaseKind.FINAL, (f.getElements("//m:forest").size() > 0)); } - if (installInfo.isTraceDbExists()) { + if (installInfo.isDbExistent(DatabaseKind.TRACE)) { Fragment f = getDatabaseManager().getPropertiesAsXml(hubConfig.getTraceDbName()); - installInfo.setTraceForestsExist((f.getElements("//m:forest").size() > 0)); + installInfo.setForestsExistent(DatabaseKind.TRACE, (f.getElements("//m:forest").size() > 0)); } - if (installInfo.isJobDbExists()) { + if (installInfo.isDbExistent(DatabaseKind.JOB)) { Fragment f = getDatabaseManager().getPropertiesAsXml(hubConfig.getJobDbName()); - installInfo.setJobForestsExist((f.getElements("//m:forest").size() > 0)); + installInfo.setForestsExistent(DatabaseKind.JOB, (f.getElements("//m:forest").size() > 0)); } logger.info(installInfo.toString()); diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/InstallInfoImpl.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/InstallInfoImpl.java index 50d7afb233..25bec5752a 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/InstallInfoImpl.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/InstallInfoImpl.java @@ -15,7 +15,9 @@ */ package com.marklogic.hub.impl; +import com.marklogic.hub.DatabaseKind; import com.marklogic.hub.InstallInfo; +import com.marklogic.hub.error.InvalidDBOperationError; public class InstallInfoImpl implements InstallInfo { private boolean stagingAppServerExists = false; @@ -40,48 +42,48 @@ public class InstallInfoImpl implements InstallInfo { @Override public boolean isPartiallyInstalled() { return ( - isStagingAppServerExists() || - isFinalAppServerExists() || - isTraceAppServerExists() || - isJobAppServerExists() || - isStagingDbExists() || - isStagingTripleIndexOn() || - isStagingCollectionLexiconOn() || - isFinalDbExists() || - isFinalTripleIndexOn() || - isFinalCollectionLexiconOn() || - isTraceDbExists() || - isJobDbExists() || - isStagingForestsExist() || - isFinalForestsExist() || - isTraceForestsExist() || - isJobForestsExist() + isAppServerExistent(DatabaseKind.STAGING) || + isAppServerExistent(DatabaseKind.FINAL) || + isAppServerExistent(DatabaseKind.TRACE) || + isAppServerExistent(DatabaseKind.JOB) || + isDbExistent(DatabaseKind.STAGING) || + isTripleIndexOn(DatabaseKind.STAGING) || + isCollectionLexiconOn(DatabaseKind.STAGING) || + isDbExistent(DatabaseKind.FINAL) || + isTripleIndexOn(DatabaseKind.FINAL) || + isCollectionLexiconOn(DatabaseKind.FINAL) || + isDbExistent(DatabaseKind.TRACE) || + isDbExistent(DatabaseKind.JOB) || + areForestsExistent(DatabaseKind.STAGING) || + areForestsExistent(DatabaseKind.FINAL) || + areForestsExistent(DatabaseKind.TRACE) || + areForestsExistent(DatabaseKind.JOB) ); } @Override public boolean isInstalled() { boolean appserversOk = ( - isStagingAppServerExists() && - isFinalAppServerExists() && - isTraceAppServerExists() && - isJobAppServerExists() + isAppServerExistent(DatabaseKind.STAGING) && + isAppServerExistent(DatabaseKind.FINAL) && + isAppServerExistent(DatabaseKind.TRACE) && + isAppServerExistent(DatabaseKind.JOB) ); boolean dbsOk = ( - isStagingDbExists() && - isStagingTripleIndexOn() && - isStagingCollectionLexiconOn() && - isFinalDbExists() && - isFinalTripleIndexOn() && - isFinalCollectionLexiconOn() && - isTraceDbExists() && - isJobDbExists() + isDbExistent(DatabaseKind.STAGING) && + isTripleIndexOn(DatabaseKind.STAGING) && + isCollectionLexiconOn(DatabaseKind.STAGING) && + isDbExistent(DatabaseKind.FINAL) && + isTripleIndexOn(DatabaseKind.FINAL) && + isCollectionLexiconOn(DatabaseKind.FINAL) && + isDbExistent(DatabaseKind.TRACE) && + isDbExistent(DatabaseKind.JOB) ); boolean forestsOk = ( - isStagingForestsExist() && - isFinalForestsExist() && - isTraceForestsExist() && - isJobForestsExist() + areForestsExistent(DatabaseKind.STAGING) && + areForestsExistent(DatabaseKind.FINAL) && + areForestsExistent(DatabaseKind.TRACE) && + areForestsExistent(DatabaseKind.JOB) ); return (appserversOk && dbsOk && forestsOk); @@ -89,156 +91,205 @@ public class InstallInfoImpl implements InstallInfo { @Override public String toString() { return "\n" + - "Checking MarkLogic Installation:\n" + - "\tAppServers:\n" + - "\t\tStaging: " + (isStagingAppServerExists() ? "exists" : "MISSING") + "\n" + - "\t\tFinal: " + (isFinalAppServerExists() ? "exists" : "MISSING") + "\n" + - "\t\tTrace: " + (isTraceAppServerExists() ? "exists" : "MISSING") + "\n" + - "\t\tJob: " + (isJobAppServerExists() ? "exists" : "MISSING") + "\n" + - "\tDatabases:\n" + - "\t\tStaging: " + (isStagingDbExists() ? "exists" : "MISSING") + "\n" + - "\t\tFinal: " + (isFinalDbExists() ? "exists" : "MISSING") + "\n" + - "\t\tTrace: " + (isTraceDbExists() ? "exists" : "MISSING") + "\n" + - "\t\tJob: " + (isJobDbExists() ? "exists" : "MISSING") + "\n" + - "\tDatabases Indexes:\n" + - "\t\tStaging Triples Index : " + (isStagingTripleIndexOn() ? "exists" : "MISSING") + "\n" + - "\t\tStaging Collection Lexicon : " + (isStagingCollectionLexiconOn() ? "exists" : "MISSING") + "\n" + - "\t\tFinal Triples Index : " + (isFinalTripleIndexOn() ? "exists" : "MISSING") + "\n" + - "\t\tFinal Collection Lexicon : " + (isFinalCollectionLexiconOn() ? "exists" : "MISSING") + "\n" + - "\tForests\n" + - "\t\tStaging: " + (isStagingForestsExist() ? "exists" : "MISSING") + "\n" + - "\t\tFinal: " + (isFinalForestsExist() ? "exists" : "MISSING") + "\n" + - "\t\tTrace: " + (isTraceForestsExist() ? "exists" : "MISSING") + "\n" + - "\t\tJob: " + (isJobForestsExist() ? "exists" : "MISSING") + "\n" + - "\n\n" + - "OVERAL RESULT: " + (isInstalled() ? "INSTALLED" : "NOT INSTALLED") + "\n"; - } - - @Override public boolean isStagingAppServerExists() { - return stagingAppServerExists; - } - - @Override public void setStagingAppServerExists(boolean stagingAppServerExists) { - this.stagingAppServerExists = stagingAppServerExists; - } - - @Override public boolean isFinalAppServerExists() { - return finalAppServerExists; - } - - @Override public void setFinalAppServerExists(boolean finalAppServerExists) { - this.finalAppServerExists = finalAppServerExists; - } - - @Override public boolean isTraceAppServerExists() { - return traceAppServerExists; - } - - @Override public void setTraceAppServerExists(boolean traceAppServerExists) { - this.traceAppServerExists = traceAppServerExists; - } - - @Override public boolean isJobAppServerExists() { - return jobAppServerExists; - } - - @Override public void setJobAppServerExists(boolean jobAppServerExists) { - this.jobAppServerExists = jobAppServerExists; - } - - @Override public boolean isStagingDbExists() { - return stagingDbExists; - } - - @Override public void setStagingDbExists(boolean stagingDbExists) { - this.stagingDbExists = stagingDbExists; - } - - @Override public boolean isFinalDbExists() { - return finalDbExists; - } - - @Override public void setFinalDbExists(boolean finalDbExists) { - this.finalDbExists = finalDbExists; - } - - @Override public boolean isTraceDbExists() { - return traceDbExists; - } - - @Override public void setTraceDbExists(boolean traceDbExists) { - this.traceDbExists = traceDbExists; - } - - @Override public boolean isJobDbExists() { - return jobDbExists; - } - - @Override public void setJobDbExists(boolean jobDbExists) { - this.jobDbExists = jobDbExists; - } - - @Override public boolean isStagingTripleIndexOn() { - return stagingTripleIndexOn; - } - - @Override public void setStagingTripleIndexOn(boolean stagingTripleIndexOn) { - this.stagingTripleIndexOn = stagingTripleIndexOn; - } - - @Override public boolean isStagingCollectionLexiconOn() { - return stagingCollectionLexiconOn; - } - - @Override public void setStagingCollectionLexiconOn(boolean stagingCollectionLexiconOn) { - this.stagingCollectionLexiconOn = stagingCollectionLexiconOn; - } - - @Override public boolean isFinalTripleIndexOn() { - return finalTripleIndexOn; - } - - @Override public void setFinalTripleIndexOn(boolean finalTripleIndexOn) { - this.finalTripleIndexOn = finalTripleIndexOn; - } - - @Override public boolean isFinalCollectionLexiconOn() { - return finalCollectionLexiconOn; - } - - @Override public void setFinalCollectionLexiconOn(boolean finalCollectionLexiconOn) { - this.finalCollectionLexiconOn = finalCollectionLexiconOn; - } - - @Override public boolean isStagingForestsExist() { - return stagingForestsExist; - } - - @Override public void setStagingForestsExist(boolean stagingForestsExist) { - this.stagingForestsExist = stagingForestsExist; - } - - @Override public boolean isFinalForestsExist() { - return finalForestsExist; - } - - @Override public void setFinalForestsExist(boolean finalForestsExist) { - this.finalForestsExist = finalForestsExist; - } - - @Override public boolean isTraceForestsExist() { - return traceForestsExist; - } - - @Override public void setTraceForestsExist(boolean traceForestsExist) { - this.traceForestsExist = traceForestsExist; - } - - @Override public boolean isJobForestsExist() { - return jobForestsExist; - } - - @Override public void setJobForestsExist(boolean jobForestsExist) { - this.jobForestsExist = jobForestsExist; + "Checking MarkLogic Installation:\n" + + "\tAppServers:\n" + + "\t\tStaging: " + (isAppServerExistent(DatabaseKind.STAGING) ? "exists" : "MISSING") + "\n" + + "\t\tFinal: " + (isAppServerExistent(DatabaseKind.FINAL) ? "exists" : "MISSING") + "\n" + + "\t\tTrace: " + (isAppServerExistent(DatabaseKind.TRACE) ? "exists" : "MISSING") + "\n" + + "\t\tJob: " + (isAppServerExistent(DatabaseKind.JOB) ? "exists" : "MISSING") + "\n" + + "\tDatabases:\n" + + "\t\tStaging: " + (isDbExistent(DatabaseKind.STAGING) ? "exists" : "MISSING") + "\n" + + "\t\tFinal: " + (isDbExistent(DatabaseKind.FINAL) ? "exists" : "MISSING") + "\n" + + "\t\tTrace: " + (isDbExistent(DatabaseKind.TRACE) ? "exists" : "MISSING") + "\n" + + "\t\tJob: " + (isDbExistent(DatabaseKind.JOB) ? "exists" : "MISSING") + "\n" + + "\tDatabases Indexes:\n" + + "\t\tStaging Triples Index : " + (isTripleIndexOn(DatabaseKind.STAGING) ? "exists" : "MISSING") + "\n" + + "\t\tStaging Collection Lexicon : " + (isCollectionLexiconOn(DatabaseKind.STAGING) ? "exists" : "MISSING") + "\n" + + "\t\tFinal Triples Index : " + (isTripleIndexOn(DatabaseKind.FINAL) ? "exists" : "MISSING") + "\n" + + "\t\tFinal Collection Lexicon : " + (isCollectionLexiconOn(DatabaseKind.FINAL) ? "exists" : "MISSING") + "\n" + + "\tForests\n" + + "\t\tStaging: " + (areForestsExistent(DatabaseKind.STAGING) ? "exists" : "MISSING") + "\n" + + "\t\tFinal: " + (areForestsExistent(DatabaseKind.FINAL) ? "exists" : "MISSING") + "\n" + + "\t\tTrace: " + (areForestsExistent(DatabaseKind.TRACE) ? "exists" : "MISSING") + "\n" + + "\t\tJob: " + (areForestsExistent(DatabaseKind.JOB) ? "exists" : "MISSING") + "\n" + + "\n\n" + + "OVERAL RESULT: " + (isInstalled() ? "INSTALLED" : "NOT INSTALLED") + "\n"; + } + + @Override public boolean isAppServerExistent(DatabaseKind kind) { + boolean exists = false; + switch (kind) { + case STAGING: + exists = stagingAppServerExists; + break; + case FINAL: + exists = finalAppServerExists; + break; + case JOB: + exists = jobAppServerExists; + break; + case TRACE: + exists = traceAppServerExists; + break; + default: + throw new InvalidDBOperationError(kind, "test appserver existence"); + } + return exists; + } + + @Override public void setAppServerExistent(DatabaseKind kind, boolean exists) { + switch (kind) { + case STAGING: + this.stagingAppServerExists = exists; + break; + case FINAL: + this.finalAppServerExists = exists; + break; + case TRACE: + this.traceAppServerExists = exists; + break; + case JOB: + this.jobAppServerExists = exists; + break; + default: + throw new InvalidDBOperationError(kind, "set the triple index"); + } + } + + @Override public boolean isDbExistent(DatabaseKind kind) { + boolean exists = false; + switch (kind) { + case STAGING: + exists = stagingDbExists; + break; + case FINAL: + exists = finalDbExists; + break; + case JOB: + exists = jobDbExists; + break; + case TRACE: + exists = traceDbExists; + break; + default: + throw new InvalidDBOperationError(kind, "test database existence"); + } + return exists; + } + + @Override public void setDbExistent(DatabaseKind kind, boolean exists) { + switch (kind) { + case STAGING: + this.stagingDbExists = exists; + break; + case FINAL: + this.finalDbExists = exists; + break; + case TRACE: + this.traceDbExists = exists; + break; + case JOB: + this.jobDbExists = exists; + break; + default: + throw new InvalidDBOperationError(kind, "set the triple index"); + } + } + + + @Override public boolean isTripleIndexOn(DatabaseKind kind) { + boolean on = false; + switch (kind) { + case STAGING: + on = stagingTripleIndexOn; + break; + case FINAL: + on = finalTripleIndexOn; + break; + default: + throw new InvalidDBOperationError(kind, "check the triple index"); + } + return on; + } + + @Override public void setTripleIndexOn(DatabaseKind kind, boolean tripleIndexOn) { + switch (kind) { + case STAGING: + this.stagingTripleIndexOn = tripleIndexOn; + break; + case FINAL: + this.finalTripleIndexOn = tripleIndexOn; + break; + default: + throw new InvalidDBOperationError(kind, "set the triple index"); + } + } + + @Override public boolean isCollectionLexiconOn(DatabaseKind kind) { + boolean on = false; + switch (kind) { + case STAGING: + on = stagingCollectionLexiconOn; + break; + case FINAL: + on = finalCollectionLexiconOn; + break; + default: + throw new InvalidDBOperationError(kind, "check the collection lexicon"); + } + return on; + } + + @Override public void setCollectionLexiconOn(DatabaseKind kind, boolean collectionLexiconOn) { + switch (kind) { + case STAGING: + this.stagingCollectionLexiconOn = collectionLexiconOn; + break; + case FINAL: + this.finalCollectionLexiconOn = collectionLexiconOn; + break; + default: + throw new InvalidDBOperationError(kind, "set the collection lexicon"); + } + } + + @Override public boolean areForestsExistent(DatabaseKind kind) { + boolean exists = false; + switch (kind) { + case STAGING: + exists = stagingForestsExist; + break; + case FINAL: + exists = finalForestsExist; + break; + case TRACE: + exists = traceForestsExist; + break; + case JOB: + exists = jobForestsExist; + break; + default: + throw new InvalidDBOperationError(kind, "check forest existence"); + } + return exists; + } + + @Override public void setForestsExistent(DatabaseKind kind, boolean forestsExistent) { + switch (kind) { + case STAGING: + this.stagingForestsExist = forestsExistent; + break; + case FINAL: + this.finalForestsExist = forestsExistent; + break; + case TRACE: + this.traceForestsExist = forestsExistent; + break; + case JOB: + this.jobForestsExist = forestsExistent; + break; + default: + throw new InvalidDBOperationError(kind, "set forest existence"); + } } } From 90b776cafdd28b93fbb3facf3fd94e06a9a0aff6 Mon Sep 17 00:00:00 2001 From: David Cassel Date: Tue, 27 Feb 2018 15:55:15 -0500 Subject: [PATCH 18/22] removing unnecessary import --- .../src/main/java/com/marklogic/hub/InstallInfo.java | 1 - 1 file changed, 1 deletion(-) diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/InstallInfo.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/InstallInfo.java index 5d61aaafd9..c77150f1db 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/InstallInfo.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/InstallInfo.java @@ -1,6 +1,5 @@ package com.marklogic.hub; -import com.marklogic.hub.error.InvalidDBOperationError; import com.marklogic.hub.impl.InstallInfoImpl; public interface InstallInfo { From d8ebaba8873b789631805c01be97b8e2573b9df4 Mon Sep 17 00:00:00 2001 From: Alexander Ebadirad Date: Tue, 27 Feb 2018 14:52:56 -0700 Subject: [PATCH 19/22] Consolidate setters/getters to common methods using databasekind --- .../main/java/com/marklogic/hub/DataHub.java | 32 +---- .../com/marklogic/hub/impl/DataHubImpl.java | 132 +++++++++--------- .../java/com/marklogic/hub/DataHubTest.java | 46 +++--- 3 files changed, 92 insertions(+), 118 deletions(-) diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/DataHub.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/DataHub.java index 4f239cc33d..1fa0ce61fe 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/DataHub.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/DataHub.java @@ -93,37 +93,11 @@ public String toString() { boolean isSafeToInstall(); - boolean isStagingPortInUse(); + boolean isPortInUse(DatabaseKind kind); - void setStagingPortInUse(boolean stagingPortInUse); + void setPortInUseBy(DatabaseKind kind, String usedBy); - String getStagingPortInUseBy(); - - void setStagingPortInUseBy(String stagingPortInUseBy); - - boolean isFinalPortInUse(); - - void setFinalPortInUse(boolean finalPortInUse); - - String getFinalPortInUseBy(); - - void setFinalPortInUseBy(String finalPortInUseBy); - - boolean isJobPortInUse(); - - void setJobPortInUse(boolean jobPortInUse); - - String getJobPortInUseBy(); - - void setJobPortInUseBy(String jobPortInUseBy); - - boolean isTracePortInUse(); - - void setTracePortInUse(boolean tracePortInUse); - - String getTracePortInUseBy(); - - void setTracePortInUseBy(String tracePortInUseBy); + String getPortInUseBy(DatabaseKind kind); boolean isServerVersionOk(); diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/DataHubImpl.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/DataHubImpl.java index 7b8240641f..8f70b1732f 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/DataHubImpl.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/DataHubImpl.java @@ -27,6 +27,7 @@ import com.marklogic.hub.deploy.commands.*; import com.marklogic.hub.deploy.util.HubDeployStatusListener; import com.marklogic.hub.error.CantUpgradeException; +import com.marklogic.hub.error.InvalidDBOperationError; import com.marklogic.hub.error.ServerValidationException; import com.marklogic.hub.util.Versions; import com.marklogic.mgmt.ManageClient; @@ -409,6 +410,8 @@ private Map getServerPortsInUse() { // Here is the former PreCheckInstall class stuff + // We should probably move this into a sub class OR its own class and interface, and create a super at the + // datahub level private boolean stagingPortInUse; private String stagingPortInUseBy; private boolean finalPortInUse; @@ -421,74 +424,71 @@ private Map getServerPortsInUse() { private String serverVersion; @Override public boolean isSafeToInstall() { - return !(isStagingPortInUse() || - isFinalPortInUse() || - isJobPortInUse() || - isTracePortInUse()) && isServerVersionOk(); - } - - @Override public boolean isStagingPortInUse() { - return stagingPortInUse; - } - - @Override public void setStagingPortInUse(boolean stagingPortInUse) { - this.stagingPortInUse = stagingPortInUse; - } - - @Override public String getStagingPortInUseBy() { - return stagingPortInUseBy; - } - - @Override public void setStagingPortInUseBy(String stagingPortInUseBy) { - this.stagingPortInUseBy = stagingPortInUseBy; - } - - @Override public boolean isFinalPortInUse() { - return finalPortInUse; - } - - @Override public void setFinalPortInUse(boolean finalPortInUse) { - this.finalPortInUse = finalPortInUse; - } - - @Override public String getFinalPortInUseBy() { - return finalPortInUseBy; - } - - @Override public void setFinalPortInUseBy(String finalPortInUseBy) { - this.finalPortInUseBy = finalPortInUseBy; - } - - @Override public boolean isJobPortInUse() { - return jobPortInUse; - } - - @Override public void setJobPortInUse(boolean jobPortInUse) { - this.jobPortInUse = jobPortInUse; - } - - @Override public String getJobPortInUseBy() { - return jobPortInUseBy; - } - - @Override public void setJobPortInUseBy(String jobPortInUseBy) { - this.jobPortInUseBy = jobPortInUseBy; - } - - @Override public boolean isTracePortInUse() { - return tracePortInUse; - } - - @Override public void setTracePortInUse(boolean tracePortInUse) { - this.tracePortInUse = tracePortInUse; - } - - @Override public String getTracePortInUseBy() { - return tracePortInUseBy; + return !(isPortInUse(DatabaseKind.FINAL) || + isPortInUse(DatabaseKind.STAGING) || + isPortInUse(DatabaseKind.JOB) || + isPortInUse(DatabaseKind.TRACE)) && isServerVersionOk(); + } + + @Override public boolean isPortInUse(DatabaseKind kind){ + boolean inUse; + switch (kind) { + case STAGING: + inUse = stagingPortInUse; + break; + case FINAL: + inUse = finalPortInUse; + break; + case JOB: + inUse = jobPortInUse; + break; + case TRACE: + inUse = tracePortInUse; + break; + default: + throw new InvalidDBOperationError(kind, "check for port use"); + } + return inUse; + } + + @Override public void setPortInUseBy(DatabaseKind kind, String usedBy){ + switch (kind) { + case STAGING: + stagingPortInUseBy = usedBy; + break; + case FINAL: + finalPortInUseBy = usedBy; + break; + case JOB: + jobPortInUseBy = usedBy; + break; + case TRACE: + tracePortInUseBy = usedBy; + break; + default: + throw new InvalidDBOperationError(kind, "set if port in use"); + } } - @Override public void setTracePortInUseBy(String tracePortInUseBy) { - this.tracePortInUseBy = tracePortInUseBy; + @Override public String getPortInUseBy(DatabaseKind kind){ + String inUseBy; + switch (kind) { + case STAGING: + inUseBy = stagingPortInUseBy; + break; + case FINAL: + inUseBy = finalPortInUseBy; + break; + case JOB: + inUseBy = jobPortInUseBy; + break; + case TRACE: + inUseBy = tracePortInUseBy; + break; + default: + throw new InvalidDBOperationError(kind, "check if port is in use"); + } + return inUseBy; } @Override public boolean isServerVersionOk() { diff --git a/marklogic-data-hub/src/test/java/com/marklogic/hub/DataHubTest.java b/marklogic-data-hub/src/test/java/com/marklogic/hub/DataHubTest.java index 87514ea36a..90b9ba788c 100644 --- a/marklogic-data-hub/src/test/java/com/marklogic/hub/DataHubTest.java +++ b/marklogic-data-hub/src/test/java/com/marklogic/hub/DataHubTest.java @@ -183,10 +183,10 @@ public void testPreFlightCheckNoHubInstalled() { dh.runPreInstallCheck(); assertTrue(dh.isServerVersionOk()); - assertFalse(dh.isStagingPortInUse()); - assertFalse(dh.isFinalPortInUse()); - assertFalse(dh.isJobPortInUse()); - assertFalse(dh.isTracePortInUse()); + assertFalse(dh.isPortInUse(DatabaseKind.STAGING)); + assertFalse(dh.isPortInUse(DatabaseKind.FINAL)); + assertFalse(dh.isPortInUse(DatabaseKind.JOB)); + assertFalse(dh.isPortInUse(DatabaseKind.TRACE)); assertTrue(dh.isSafeToInstall()); } @@ -207,10 +207,10 @@ public void testPreFlightCheckHubAlreadyInstalled() { dh.runPreInstallCheck(); assertTrue(dh.isServerVersionOk()); - assertFalse(dh.isStagingPortInUse()); - assertFalse(dh.isFinalPortInUse()); - assertFalse(dh.isJobPortInUse()); - assertFalse(dh.isTracePortInUse()); + assertFalse(dh.isPortInUse(DatabaseKind.STAGING)); + assertFalse(dh.isPortInUse(DatabaseKind.FINAL)); + assertFalse(dh.isPortInUse(DatabaseKind.JOB)); + assertFalse(dh.isPortInUse(DatabaseKind.TRACE)); assertTrue(dh.isSafeToInstall()); } @@ -228,11 +228,11 @@ public void testPreFlightCheckStagingPortTaken() { dh.runPreInstallCheck(); assertTrue(dh.isServerVersionOk()); - assertTrue(dh.isStagingPortInUse()); - assertEquals("port-stealer", dh.getStagingPortInUseBy()); - assertFalse(dh.isFinalPortInUse()); - assertFalse(dh.isJobPortInUse()); - assertFalse(dh.isTracePortInUse()); + assertTrue(dh.isPortInUse(DatabaseKind.STAGING)); + assertEquals("port-stealer", dh.getPortInUseBy(DatabaseKind.STAGING)); + assertFalse(dh.isPortInUse(DatabaseKind.FINAL)); + assertFalse(dh.isPortInUse(DatabaseKind.JOB)); + assertFalse(dh.isPortInUse(DatabaseKind.TRACE)); assertFalse(dh.isSafeToInstall()); } @@ -250,11 +250,11 @@ public void testPreFlightCheckStagingPortTakenAndBadVersion() { dh.runPreInstallCheck(versions); assertFalse(dh.isServerVersionOk()); - assertTrue(dh.isStagingPortInUse()); - assertEquals("port-stealer", dh.getStagingPortInUseBy()); - assertFalse(dh.isFinalPortInUse()); - assertFalse(dh.isJobPortInUse()); - assertFalse(dh.isTracePortInUse()); + assertTrue(dh.isPortInUse(DatabaseKind.STAGING)); + assertEquals("port-stealer", dh.getPortInUseBy(DatabaseKind.STAGING)); + assertFalse(dh.isPortInUse(DatabaseKind.FINAL)); + assertFalse(dh.isPortInUse(DatabaseKind.JOB)); + assertFalse(dh.isPortInUse(DatabaseKind.TRACE)); assertFalse(dh.isSafeToInstall()); } @@ -272,11 +272,11 @@ public void testPreFlightCheckFinalPortTaken() { dh.runPreInstallCheck(); assertTrue(dh.isServerVersionOk()); - assertFalse(dh.isStagingPortInUse()); - assertTrue(dh.isFinalPortInUse()); - assertEquals("port-stealer", dh.getFinalPortInUseBy()); - assertFalse(dh.isJobPortInUse()); - assertFalse(dh.isTracePortInUse()); + assertFalse(dh.isPortInUse(DatabaseKind.STAGING)); + assertTrue(dh.isPortInUse(DatabaseKind.FINAL)); + assertEquals("port-stealer", dh.getPortInUseBy(DatabaseKind.FINAL)); + assertFalse(dh.isPortInUse(DatabaseKind.JOB)); + assertFalse(dh.isPortInUse(DatabaseKind.TRACE)); assertFalse(dh.isSafeToInstall()); } } From de1768ba5c3f1f85869f0733c5baeefc9791acd8 Mon Sep 17 00:00:00 2001 From: Alexander Ebadirad Date: Wed, 28 Feb 2018 10:42:52 -0700 Subject: [PATCH 20/22] Adding schemas, triggers, and modules to databasekind and consolidating methods based off that --- .../java/com/marklogic/hub/DatabaseKind.java | 4 +- .../java/com/marklogic/hub/HubConfig.java | 175 +------- .../hub/flow/impl/FlowRunnerImpl.java | 3 +- .../com/marklogic/hub/impl/DataHubImpl.java | 42 +- .../com/marklogic/hub/impl/HubConfigImpl.java | 408 ++++++++++-------- .../com/marklogic/hub/HubProjectTest.java | 74 ++-- .../java/com/marklogic/hub/HubTestBase.java | 8 +- .../web/CurrentProjectController.java | 3 +- 8 files changed, 304 insertions(+), 413 deletions(-) diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/DatabaseKind.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/DatabaseKind.java index 1101b72206..b53bdf28d7 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/DatabaseKind.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/DatabaseKind.java @@ -5,5 +5,7 @@ public enum DatabaseKind { FINAL, JOB, TRACE, - SCHEMA + SCHEMAS, + TRIGGERS, + MODULES } diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/HubConfig.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/HubConfig.java index 1a8af444ac..3d12a82621 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/HubConfig.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/HubConfig.java @@ -20,7 +20,6 @@ import com.marklogic.client.DatabaseClientFactory; import javax.net.ssl.SSLContext; -import java.io.File; import java.io.IOException; import java.nio.file.Path; @@ -65,177 +64,31 @@ public interface HubConfig { String getHost(); - // staging - String getStagingDbName(); - void setStagingDbName(String stagingDbName); - String getStagingHttpName(); - void setStagingHttpName(String stagingHttpName); + String getDbName(DatabaseKind kind); - Integer getStagingForestsPerHost(); - void setStagingForestsPerHost(Integer stagingForestsPerHost); + void setDbName(DatabaseKind kind, String dbName); - Integer getStagingPort(); - void setStagingPort(Integer stagingPort); + String getHttpName(DatabaseKind kind); - String getStagingAuthMethod(); - void setStagingAuthMethod(String stagingAuthMethod); + void setHttpName(DatabaseKind kind, String httpName); - String getStagingScheme(); - void setStagingScheme(String stagingScheme); + Integer getForestsPerHost(DatabaseKind kind); - boolean getStagingSimpleSsl(); - void setStagingSimpleSsl(boolean stagingSimpleSsl); + void setForestsPerHost(DatabaseKind kind, Integer forestsPerHost); - SSLContext getStagingSslContext(); - void setStagingSslContext(SSLContext stagingSslContext); - - DatabaseClientFactory.SSLHostnameVerifier getStagingSslHostnameVerifier(); - void setStagingSslHostnameVerifier(DatabaseClientFactory.SSLHostnameVerifier stagingSslHostnameVerifier); - - String getStagingCertFile(); - void setStagingCertFile(String stagingCertFile); - - String getStagingCertPassword(); - void setStagingCertPassword(String stagingCertPassword); - - String getStagingExternalName(); - void setStagingExternalName(String stagingExternalName); - - // final - String getFinalDbName(); - void setFinalDbName(String finalDbName); + Integer getPort(DatabaseKind kind); - String getFinalHttpName(); - void setFinalHttpName(String finalHttpName); + void setPort(DatabaseKind kind, Integer port); - Integer getFinalForestsPerHost(); - void setFinalForestsPerHost(Integer finalForestsPerHost); - - Integer getFinalPort(); - void setFinalPort(Integer finalPort); - - String getFinalAuthMethod(); - void setFinalAuthMethod(String finalAuthMethod); - - String getFinalScheme(); - void setFinalScheme(String finalScheme); + void setStagingSslContext(SSLContext stagingSslContext); - boolean getFinalSimpleSsl(); - void setFinalSimpleSsl(boolean finalSimpleSsl); + void setStagingSslHostnameVerifier(DatabaseClientFactory.SSLHostnameVerifier stagingSslHostnameVerifier); - SSLContext getFinalSslContext(); void setFinalSslContext(SSLContext finalSslContext); - DatabaseClientFactory.SSLHostnameVerifier getFinalSslHostnameVerifier(); void setFinalSslHostnameVerifier(DatabaseClientFactory.SSLHostnameVerifier finalSslHostnameVerifier); - String getFinalCertFile(); - void setFinalCertFile(String finalCertFile); - - String getFinalCertPassword(); - void setFinalCertPassword(String finalCertPassword); - - String getFinalExternalName(); - void setFinalExternalName(String finalExternalName); - - // traces - String getTraceDbName(); - void setTraceDbName(String traceDbName); - - String getTraceHttpName(); - void setTraceHttpName(String traceHttpName); - - Integer getTraceForestsPerHost(); - void setTraceForestsPerHost(Integer traceForestsPerHost); - - Integer getTracePort(); - void setTracePort(Integer tracePort); - - String getTraceAuthMethod(); - void setTraceAuthMethod(String traceAuthMethod); - - String getTraceScheme(); - void setTraceScheme(String traceScheme); - - - boolean getTraceSimpleSsl(); - void setTraceSimpleSsl(boolean traceSimpleSsl); - - SSLContext getTraceSslContext(); - void setTraceSslContext(SSLContext traceSslContext); - - DatabaseClientFactory.SSLHostnameVerifier getTraceSslHostnameVerifier(); - void setTraceSslHostnameVerifier(DatabaseClientFactory.SSLHostnameVerifier traceSslHostnameVerifier); - - String getTraceCertFile(); - void setTraceCertFile(String traceCertFile); - - String getTraceCertPassword(); - void setTraceCertPassword(String traceCertPassword); - - String getTraceExternalName(); - void setTraceExternalName(String traceExternalName); - - // jobs - String getJobDbName(); - void setJobDbName(String jobDbName); - - String getJobHttpName(); - void setJobHttpName(String jobHttpName); - - Integer getJobForestsPerHost(); - void setJobForestsPerHost(Integer jobForestsPerHost); - - Integer getJobPort(); - void setJobPort(Integer jobPort); - - String getJobAuthMethod(); - void setJobAuthMethod(String jobAuthMethod); - - String getJobScheme(); - void setJobScheme(String jobScheme); - - boolean getJobSimpleSsl(); - void setJobSimpleSsl(boolean jobSimpleSsl); - - - SSLContext getJobSslContext(); - void setJobSslContext(SSLContext jobSslContext); - - DatabaseClientFactory.SSLHostnameVerifier getJobSslHostnameVerifier(); - void setJobSslHostnameVerifier(DatabaseClientFactory.SSLHostnameVerifier jobSslHostnameVerifier); - - String getJobCertFile(); - void setJobCertFile(String jobCertFile); - - String getJobCertPassword(); - void setJobCertPassword(String jobCertPassword); - - String getJobExternalName(); - void setJobExternalName(String jobExternalName); - - String getModulesDbName(); - void setModulesDbName(String modulesDbName); - - Integer getModulesForestsPerHost(); - void setModulesForestsPerHost(Integer modulesForestsPerHost); - - - // triggers - String getTriggersDbName(); - void setTriggersDbName(String triggersDbName); - - Integer getTriggersForestsPerHost(); - void setTriggersForestsPerHost(Integer triggersForestsPerHost); - - // schemas - String getSchemasDbName(); - void setSchemasDbName(String schemasDbName); - - Integer getSchemasForestsPerHost(); - void setSchemasForestsPerHost(Integer schemasForestsPerHost); - // roles and users String getHubRoleName(); void setHubRoleName(String hubRoleName); @@ -243,20 +96,15 @@ public interface HubConfig { String getHubUserName(); void setHubUserName(String hubUserName); - String[] getLoadBalancerHosts(); - void setLoadBalancerHosts(String[] loadBalancerHosts); String getCustomForestPath(); - void setCustomForestPath(String customForestPath); String getModulePermissions(); - void setModulePermissions(String modulePermissions); String getProjectDir(); void setProjectDir(String projectDir); - HubProject getHubProject(); void initHubProject(); @@ -266,8 +114,6 @@ public interface HubConfig { String getUserModulesDeployTimestampFile(); - File getUserContentDeployTimestampFile(); - DatabaseClient newAppServicesClient(); /** @@ -323,6 +169,7 @@ public interface HubConfig { Path getHubMimetypesDir(); AppConfig getAppConfig(); + void setAppConfig(AppConfig config); void setAppConfig(AppConfig config, boolean skipUpdate); diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/flow/impl/FlowRunnerImpl.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/flow/impl/FlowRunnerImpl.java index fdfa5c87f3..7b16503c03 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/flow/impl/FlowRunnerImpl.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/flow/impl/FlowRunnerImpl.java @@ -26,6 +26,7 @@ import com.marklogic.client.io.Format; import com.marklogic.client.io.StringHandle; import com.marklogic.client.util.RequestParameters; +import com.marklogic.hub.DatabaseKind; import com.marklogic.hub.HubConfig; import com.marklogic.hub.collector.Collector; import com.marklogic.hub.collector.DiskQueue; @@ -66,7 +67,7 @@ public class FlowRunnerImpl implements FlowRunner { public FlowRunnerImpl(HubConfig hubConfig) { this.hubConfig = hubConfig; this.sourceClient = hubConfig.newStagingClient(); - this.destinationDatabase = hubConfig.getFinalDbName(); + this.destinationDatabase = hubConfig.getDbName(DatabaseKind.FINAL); } @Override diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/DataHubImpl.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/DataHubImpl.java index 8f70b1732f..02f2f2d475 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/DataHubImpl.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/DataHubImpl.java @@ -112,38 +112,38 @@ private ServerManager getServerManager() { InstallInfo installInfo = InstallInfo.create(); ResourcesFragment srf = getServerManager().getAsXml(); - installInfo.setAppServerExistent(DatabaseKind.STAGING, srf.resourceExists(hubConfig.getStagingHttpName())); - installInfo.setAppServerExistent(DatabaseKind.FINAL, srf.resourceExists(hubConfig.getFinalHttpName())); - installInfo.setAppServerExistent(DatabaseKind.TRACE, srf.resourceExists(hubConfig.getTraceHttpName())); - installInfo.setAppServerExistent(DatabaseKind.JOB, srf.resourceExists(hubConfig.getJobHttpName())); + installInfo.setAppServerExistent(DatabaseKind.STAGING, srf.resourceExists(hubConfig.getHttpName(DatabaseKind.STAGING))); + installInfo.setAppServerExistent(DatabaseKind.FINAL, srf.resourceExists(hubConfig.getHttpName(DatabaseKind.FINAL))); + installInfo.setAppServerExistent(DatabaseKind.TRACE, srf.resourceExists(hubConfig.getHttpName(DatabaseKind.TRACE))); + installInfo.setAppServerExistent(DatabaseKind.JOB, srf.resourceExists(hubConfig.getHttpName(DatabaseKind.JOB))); ResourcesFragment drf = getDatabaseManager().getAsXml(); - installInfo.setDbExistent(DatabaseKind.STAGING, drf.resourceExists(hubConfig.getStagingDbName())); - installInfo.setDbExistent(DatabaseKind.FINAL, drf.resourceExists(hubConfig.getFinalDbName())); - installInfo.setDbExistent(DatabaseKind.TRACE, drf.resourceExists(hubConfig.getTraceDbName())); - installInfo.setDbExistent(DatabaseKind.JOB, drf.resourceExists(hubConfig.getJobDbName())); + installInfo.setDbExistent(DatabaseKind.STAGING, drf.resourceExists(hubConfig.getDbName(DatabaseKind.STAGING))); + installInfo.setDbExistent(DatabaseKind.FINAL, drf.resourceExists(hubConfig.getDbName(DatabaseKind.FINAL))); + installInfo.setDbExistent(DatabaseKind.TRACE, drf.resourceExists(hubConfig.getDbName(DatabaseKind.TRACE))); + installInfo.setDbExistent(DatabaseKind.JOB, drf.resourceExists(hubConfig.getDbName(DatabaseKind.JOB))); if (installInfo.isDbExistent(DatabaseKind.STAGING)) { - Fragment f = getDatabaseManager().getPropertiesAsXml(hubConfig.getStagingDbName()); + Fragment f = getDatabaseManager().getPropertiesAsXml(hubConfig.getDbName(DatabaseKind.STAGING)); installInfo.setTripleIndexOn(DatabaseKind.STAGING, Boolean.parseBoolean(f.getElementValue("//m:triple-index"))); installInfo.setCollectionLexiconOn(DatabaseKind.STAGING, Boolean.parseBoolean(f.getElementValue("//m:collection-lexicon"))); installInfo.setForestsExistent(DatabaseKind.STAGING, (f.getElements("//m:forest").size() > 0)); } if (installInfo.isDbExistent(DatabaseKind.FINAL)) { - Fragment f = getDatabaseManager().getPropertiesAsXml(hubConfig.getFinalDbName()); + Fragment f = getDatabaseManager().getPropertiesAsXml(hubConfig.getDbName(DatabaseKind.FINAL)); installInfo.setTripleIndexOn(DatabaseKind.FINAL, Boolean.parseBoolean(f.getElementValue("//m:triple-index"))); installInfo.setCollectionLexiconOn(DatabaseKind.FINAL, Boolean.parseBoolean(f.getElementValue("//m:collection-lexicon"))); installInfo.setForestsExistent(DatabaseKind.FINAL, (f.getElements("//m:forest").size() > 0)); } if (installInfo.isDbExistent(DatabaseKind.TRACE)) { - Fragment f = getDatabaseManager().getPropertiesAsXml(hubConfig.getTraceDbName()); + Fragment f = getDatabaseManager().getPropertiesAsXml(hubConfig.getDbName(DatabaseKind.TRACE)); installInfo.setForestsExistent(DatabaseKind.TRACE, (f.getElements("//m:forest").size() > 0)); } if (installInfo.isDbExistent(DatabaseKind.JOB)) { - Fragment f = getDatabaseManager().getPropertiesAsXml(hubConfig.getJobDbName()); + Fragment f = getDatabaseManager().getPropertiesAsXml(hubConfig.getDbName(DatabaseKind.JOB)); installInfo.setForestsExistent(DatabaseKind.JOB, (f.getElements("//m:forest").size() > 0)); } @@ -236,7 +236,7 @@ private ServerManager getServerManager() { " fn:matches(., \"/marklogic.rest.transform/(" + String.join("|", transforms) + ")/assets/(metadata\\.xml|transform\\.(xqy|sjs))\")\n" + " )\n" + "] ! xdmp:document-delete(.)\n"; - runInDatabase(query, hubConfig.getModulesDbName()); + runInDatabase(query, hubConfig.getDbName(DatabaseKind.MODULES)); } catch(FailedRequestException e) { logger.error("Failed to clear user modules"); @@ -263,26 +263,26 @@ public List getCommandList() { Map portsInUse = getServerPortsInUse(); Set ports = portsInUse.keySet(); - String serverName = portsInUse.get(hubConfig.getStagingPort()); - stagingPortInUse = ports.contains(hubConfig.getStagingPort()) && serverName != null && !serverName.equals(hubConfig.getStagingHttpName()); + String serverName = portsInUse.get(hubConfig.getPort(DatabaseKind.STAGING)); + stagingPortInUse = ports.contains(hubConfig.getPort(DatabaseKind.STAGING)) && serverName != null && !serverName.equals(hubConfig.getHttpName(DatabaseKind.STAGING)); if (stagingPortInUse) { stagingPortInUseBy = serverName; } - serverName = portsInUse.get(hubConfig.getFinalPort()); - finalPortInUse = ports.contains(hubConfig.getFinalPort()) && serverName != null && !serverName.equals(hubConfig.getFinalHttpName()); + serverName = portsInUse.get(hubConfig.getPort(DatabaseKind.FINAL)); + finalPortInUse = ports.contains(hubConfig.getPort(DatabaseKind.FINAL)) && serverName != null && !serverName.equals(hubConfig.getHttpName(DatabaseKind.FINAL)); if (finalPortInUse) { finalPortInUseBy = serverName; } - serverName = portsInUse.get(hubConfig.getJobPort()); - jobPortInUse = ports.contains(hubConfig.getJobPort()) && serverName != null && !serverName.equals(hubConfig.getJobHttpName()); + serverName = portsInUse.get(hubConfig.getPort(DatabaseKind.JOB)); + jobPortInUse = ports.contains(hubConfig.getPort(DatabaseKind.JOB)) && serverName != null && !serverName.equals(hubConfig.getHttpName(DatabaseKind.JOB)); if (jobPortInUse) { jobPortInUseBy = serverName; } - serverName = portsInUse.get(hubConfig.getTracePort()); - tracePortInUse = ports.contains(hubConfig.getTracePort()) && serverName != null && !serverName.equals(hubConfig.getTraceHttpName()); + serverName = portsInUse.get(hubConfig.getPort(DatabaseKind.TRACE)); + tracePortInUse = ports.contains(hubConfig.getPort(DatabaseKind.TRACE)) && serverName != null && !serverName.equals(hubConfig.getHttpName(DatabaseKind.TRACE)); if (tracePortInUse) { tracePortInUseBy = serverName; } diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/HubConfigImpl.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/HubConfigImpl.java index 32685342e8..d43d710ab0 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/HubConfigImpl.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/HubConfigImpl.java @@ -23,8 +23,10 @@ import com.marklogic.client.ext.DatabaseClientConfig; import com.marklogic.client.ext.SecurityContextType; import com.marklogic.client.ext.modulesloader.ssl.SimpleX509TrustManager; +import com.marklogic.hub.DatabaseKind; import com.marklogic.hub.HubConfig; import com.marklogic.hub.HubProject; +import com.marklogic.hub.error.InvalidDBOperationError; import com.marklogic.mgmt.ManageClient; import com.marklogic.mgmt.ManageConfig; import com.marklogic.mgmt.admin.AdminConfig; @@ -135,37 +137,204 @@ public class HubConfigImpl implements HubConfig { public HubConfigImpl(String projectDir) { setProjectDir(new File(projectDir).getAbsolutePath()); } - public HubConfigImpl() {} public String getHost() { return appConfig.getHost(); } - public String getStagingDbName() { - return stagingDbName; - } - public void setStagingDbName(String stagingDbName) { - this.stagingDbName = stagingDbName; + @Override public String getDbName(DatabaseKind kind){ + String name; + switch (kind) { + case STAGING: + name = stagingDbName; + break; + case FINAL: + name = finalDbName; + break; + case JOB: + name = jobDbName; + break; + case TRACE: + name = traceDbName; + break; + case MODULES: + name = modulesDbName; + break; + case TRIGGERS: + name = triggersDbName; + break; + case SCHEMAS: + name = schemasDbName; + break; + default: + throw new InvalidDBOperationError(kind, "grab database name"); + } + return name; + } + + @Override public void setDbName(DatabaseKind kind, String dbName){ + switch (kind) { + case STAGING: + stagingDbName = dbName; + break; + case FINAL: + finalDbName = dbName; + break; + case JOB: + jobDbName = dbName; + break; + case TRACE: + traceDbName = dbName; + break; + case MODULES: + modulesDbName = dbName; + break; + case TRIGGERS: + triggersDbName = dbName; + break; + case SCHEMAS: + schemasDbName = dbName; + break; + default: + throw new InvalidDBOperationError(kind, "set database name"); + } } - public String getStagingHttpName() { - return stagingHttpName; - } - public void setStagingHttpName(String stagingHttpName) { - this.stagingHttpName = stagingHttpName; + @Override public String getHttpName(DatabaseKind kind){ + String name; + switch (kind) { + case STAGING: + name = stagingHttpName; + break; + case FINAL: + name = finalHttpName; + break; + case JOB: + name = jobHttpName; + break; + case TRACE: + name = traceHttpName; + break; + default: + throw new InvalidDBOperationError(kind, "grab http name"); + } + return name; + } + + @Override public void setHttpName(DatabaseKind kind, String httpName){ + switch (kind) { + case STAGING: + stagingHttpName = httpName; + break; + case FINAL: + finalHttpName = httpName; + break; + case JOB: + jobHttpName = httpName; + break; + case TRACE: + traceHttpName = httpName; + break; + default: + throw new InvalidDBOperationError(kind, "set http name"); + } } - public Integer getStagingForestsPerHost() { - return stagingForestsPerHost; - } - public void setStagingForestsPerHost(Integer stagingForestsPerHost) { - this.stagingForestsPerHost = stagingForestsPerHost; + @Override public Integer getForestsPerHost(DatabaseKind kind){ + Integer forests; + switch (kind) { + case STAGING: + forests = stagingForestsPerHost; + break; + case FINAL: + forests = finalForestsPerHost; + break; + case JOB: + forests = jobForestsPerHost; + break; + case TRACE: + forests = traceForestsPerHost; + break; + case MODULES: + forests = modulesForestsPerHost; + break; + case TRIGGERS: + forests = triggersForestsPerHost; + break; + case SCHEMAS: + forests = schemasForestsPerHost; + break; + default: + throw new InvalidDBOperationError(kind, "grab count of forests per host"); + } + return forests; + } + + @Override public void setForestsPerHost(DatabaseKind kind, Integer forestsPerHost){ + switch (kind) { + case STAGING: + stagingForestsPerHost = forestsPerHost; + break; + case FINAL: + finalForestsPerHost = forestsPerHost; + break; + case JOB: + jobForestsPerHost = forestsPerHost; + break; + case TRACE: + traceForestsPerHost = forestsPerHost; + break; + case MODULES: + modulesForestsPerHost = forestsPerHost; + break; + case TRIGGERS: + triggersForestsPerHost = forestsPerHost; + break; + case SCHEMAS: + schemasForestsPerHost = forestsPerHost; + break; + default: + throw new InvalidDBOperationError(kind, "set count of forests per host"); + } } - public Integer getStagingPort() { - return stagingPort; - } - public void setStagingPort(Integer stagingPort) { - this.stagingPort = stagingPort; + @Override public Integer getPort(DatabaseKind kind){ + Integer port; + switch (kind) { + case STAGING: + port = stagingPort; + break; + case FINAL: + port = finalPort; + break; + case JOB: + port = jobPort; + break; + case TRACE: + port = tracePort; + break; + default: + throw new InvalidDBOperationError(kind, "grab app port"); + } + return port; + } + + @Override public void setPort(DatabaseKind kind, Integer port){ + switch (kind) { + case STAGING: + stagingPort = port; + break; + case FINAL: + finalPort = port; + break; + case JOB: + jobPort = port; + break; + case TRACE: + tracePort = port; + break; + default: + throw new InvalidDBOperationError(kind, "set app port"); + } } public String getStagingAuthMethod() { @@ -192,14 +361,14 @@ public void setStagingSimpleSsl(boolean stagingSimpleSsl) { public SSLContext getStagingSslContext() { return stagingSslContext; } - public void setStagingSslContext(SSLContext stagingSslContext) { + @Override public void setStagingSslContext(SSLContext stagingSslContext) { this.stagingSslContext = stagingSslContext; } public DatabaseClientFactory.SSLHostnameVerifier getStagingSslHostnameVerifier() { return stagingSslHostnameVerifier; } - public void setStagingSslHostnameVerifier(DatabaseClientFactory.SSLHostnameVerifier stagingSslHostnameVerifier) { + @Override public void setStagingSslHostnameVerifier(DatabaseClientFactory.SSLHostnameVerifier stagingSslHostnameVerifier) { this.stagingSslHostnameVerifier = stagingSslHostnameVerifier; } @@ -225,34 +394,6 @@ public void setStagingExternalName(String stagingExternalName) { } // final - public String getFinalDbName() { - return finalDbName; - } - public void setFinalDbName(String finalDbName) { - this.finalDbName = finalDbName; - } - - public String getFinalHttpName() { - return finalHttpName; - } - public void setFinalHttpName(String finalHttpName) { - this.finalHttpName = finalHttpName; - } - - public Integer getFinalForestsPerHost() { - return finalForestsPerHost; - } - public void setFinalForestsPerHost(Integer finalForestsPerHost) { - this.finalForestsPerHost = finalForestsPerHost; - } - - public Integer getFinalPort() { - return finalPort; - } - public void setFinalPort(Integer finalPort) { - this.finalPort = finalPort; - } - public String getFinalAuthMethod() { return finalAuthMethod; } @@ -277,7 +418,7 @@ public void setFinalSimpleSsl(boolean finalSimpleSsl) { public SSLContext getFinalSslContext() { return finalSslContext; } - public void setFinalSslContext(SSLContext finalSslContext) { + @Override public void setFinalSslContext(SSLContext finalSslContext) { this.finalSslContext = finalSslContext; } @@ -305,39 +446,11 @@ public void setFinalCertPassword(String finalCertPassword) { public String getFinalExternalName() { return finalExternalName; } - public void setFinalExternalName(String finalExternalName) { + public void setFinalExternalName(String finalExternalName) { this.finalExternalName = finalExternalName; } // traces - public String getTraceDbName() { - return traceDbName; - } - public void setTraceDbName(String traceDbName) { - this.traceDbName = traceDbName; - } - - public String getTraceHttpName() { - return traceHttpName; - } - public void setTraceHttpName(String traceHttpName) { - this.traceHttpName = traceHttpName; - } - - public Integer getTraceForestsPerHost() { - return traceForestsPerHost; - } - public void setTraceForestsPerHost(Integer traceForestsPerHost) { - this.traceForestsPerHost = traceForestsPerHost; - } - - public Integer getTracePort() { - return tracePort; - } - public void setTracePort(Integer tracePort) { - this.tracePort = tracePort; - } - public String getTraceAuthMethod() { return traceAuthMethod; } @@ -395,34 +508,6 @@ public void setTraceExternalName(String traceExternalName) { } // jobs - public String getJobDbName() { - return jobDbName; - } - public void setJobDbName(String jobDbName) { - this.jobDbName = jobDbName; - } - - public String getJobHttpName() { - return jobHttpName; - } - public void setJobHttpName(String jobHttpName) { - this.jobHttpName = jobHttpName; - } - - public Integer getJobForestsPerHost() { - return jobForestsPerHost; - } - public void setJobForestsPerHost(Integer jobForestsPerHost) { - this.jobForestsPerHost = jobForestsPerHost; - } - - public Integer getJobPort() { - return jobPort; - } - public void setJobPort(Integer jobPort) { - this.jobPort = jobPort; - } - public String getJobAuthMethod() { return jobAuthMethod; } @@ -479,69 +564,24 @@ public void setJobExternalName(String jobExternalName) { this.jobExternalName = jobExternalName; } - public String getModulesDbName() { - return modulesDbName; - } - public void setModulesDbName(String modulesDbName) { - this.modulesDbName = modulesDbName; - } - - public Integer getModulesForestsPerHost() { - return modulesForestsPerHost; - } - public void setModulesForestsPerHost(Integer modulesForestsPerHost) { - this.modulesForestsPerHost = modulesForestsPerHost; - } - - - // triggers - public String getTriggersDbName() { - return triggersDbName; - } - public void setTriggersDbName(String triggersDbName) { - this.triggersDbName = triggersDbName; - } - - public Integer getTriggersForestsPerHost() { - return triggersForestsPerHost; - } - public void setTriggersForestsPerHost(Integer triggersForestsPerHost) { - this.triggersForestsPerHost = triggersForestsPerHost; - } - - // schemas - public String getSchemasDbName() { - return schemasDbName; - } - public void setSchemasDbName(String schemasDbName) { - this.schemasDbName = schemasDbName; - } - - public Integer getSchemasForestsPerHost() { - return schemasForestsPerHost; - } - public void setSchemasForestsPerHost(Integer schemasForestsPerHost) { - this.schemasForestsPerHost = schemasForestsPerHost; - } - // roles and users - public String getHubRoleName() { + @Override public String getHubRoleName() { return hubRoleName; } - public void setHubRoleName(String hubRoleName) { + @Override public void setHubRoleName(String hubRoleName) { this.hubRoleName = hubRoleName; } - public String getHubUserName() { + @Override public String getHubUserName() { return hubUserName; } - public void setHubUserName(String hubUserName) { + @Override public void setHubUserName(String hubUserName) { this.hubUserName = hubUserName; } @JsonIgnore - public String[] getLoadBalancerHosts() { + @Override public String[] getLoadBalancerHosts() { return loadBalancerHosts; } public void setLoadBalancerHosts(String[] loadBalancerHosts) { @@ -549,7 +589,7 @@ public void setLoadBalancerHosts(String[] loadBalancerHosts) { } @JsonIgnore - public String getCustomForestPath() { + @Override public String getCustomForestPath() { return customForestPath; } public void setCustomForestPath(String customForestPath) { @@ -557,38 +597,38 @@ public void setCustomForestPath(String customForestPath) { } @JsonIgnore - public String getModulePermissions() { + @Override public String getModulePermissions() { return modulePermissions; } public void setModulePermissions(String modulePermissions) { this.modulePermissions = modulePermissions; } - public String getProjectDir() { + @Override public String getProjectDir() { return this.projectDir; } - public void setProjectDir(String projectDir) { + @Override public void setProjectDir(String projectDir) { this.projectDir = projectDir; this.hubProject = HubProject.create(projectDir); } @JsonIgnore - public HubProject getHubProject() { + @Override public HubProject getHubProject() { return this.hubProject; } - public void initHubProject() { + @Override public void initHubProject() { this.hubProject.init(getCustomTokens()); } @JsonIgnore - public String getHubModulesDeployTimestampFile() { + @Override public String getHubModulesDeployTimestampFile() { return Paths.get(projectDir, ".tmp", HUB_MODULES_DEPLOY_TIMESTAMPS_PROPERTIES).toString(); } @JsonIgnore - public String getUserModulesDeployTimestampFile() { + @Override public String getUserModulesDeployTimestampFile() { return Paths.get(projectDir, ".tmp", USER_MODULES_DEPLOY_TIMESTAMPS_PROPERTIES).toString(); } @@ -597,7 +637,7 @@ public File getUserContentDeployTimestampFile() { return Paths.get(projectDir, ".tmp", USER_CONTENT_DEPLOY_TIMESTAMPS_PROPERTIES).toFile(); } - public void loadConfigurationFromProperties(Properties environmentProperties) { + public void loadConfigurationFromProperties(Properties environmentProperties) { this.environmentProperties = environmentProperties; if (this.environmentProperties != null) { @@ -812,81 +852,81 @@ public DatabaseClient newModulesDbClient() { } @JsonIgnore - public Path getHubPluginsDir() { + @Override public Path getHubPluginsDir() { return hubProject.getHubPluginsDir(); } @JsonIgnore - public Path getHubEntitiesDir() { return hubProject.getHubEntitiesDir(); } + @Override public Path getHubEntitiesDir() { return hubProject.getHubEntitiesDir(); } @JsonIgnore - public Path getHubConfigDir() { + @Override public Path getHubConfigDir() { return hubProject.getHubConfigDir(); } @JsonIgnore - public Path getHubDatabaseDir() { + @Override public Path getHubDatabaseDir() { return hubProject.getHubDatabaseDir(); } @JsonIgnore - public Path getHubServersDir() { + @Override public Path getHubServersDir() { return hubProject.getHubServersDir(); } @JsonIgnore - public Path getHubSecurityDir() { + @Override public Path getHubSecurityDir() { return hubProject.getHubSecurityDir(); } @JsonIgnore - public Path getUserSecurityDir() { + @Override public Path getUserSecurityDir() { return hubProject.getUserSecurityDir(); } @JsonIgnore - public Path getUserConfigDir() { + @Override public Path getUserConfigDir() { return hubProject.getUserConfigDir(); } @JsonIgnore - public Path getUserDatabaseDir() { + @Override public Path getUserDatabaseDir() { return hubProject.getUserDatabaseDir(); } @JsonIgnore - public Path getEntityDatabaseDir() { + @Override public Path getEntityDatabaseDir() { return hubProject.getEntityDatabaseDir(); } @JsonIgnore - public Path getUserServersDir() { + @Override public Path getUserServersDir() { return hubProject.getUserServersDir(); } @JsonIgnore - public Path getHubMimetypesDir() { + @Override public Path getHubMimetypesDir() { return hubProject.getHubMimetypesDir(); } @JsonIgnore - public AppConfig getAppConfig() { + @Override public AppConfig getAppConfig() { return appConfig; } - public void setAppConfig(AppConfig config) { + @Override public void setAppConfig(AppConfig config) { setAppConfig(config, false); } - public void setAppConfig(AppConfig config, boolean skipUpdate) { + @Override public void setAppConfig(AppConfig config, boolean skipUpdate) { this.appConfig = config; if (!skipUpdate) { updateAppConfig(this.appConfig); } } - public String getJarVersion() throws IOException { + @Override public String getJarVersion() throws IOException { Properties properties = new Properties(); InputStream inputStream = getClass().getClassLoader().getResourceAsStream("version.properties"); properties.load(inputStream); diff --git a/marklogic-data-hub/src/test/java/com/marklogic/hub/HubProjectTest.java b/marklogic-data-hub/src/test/java/com/marklogic/hub/HubProjectTest.java index dd3787fc2f..203401103d 100644 --- a/marklogic-data-hub/src/test/java/com/marklogic/hub/HubProjectTest.java +++ b/marklogic-data-hub/src/test/java/com/marklogic/hub/HubProjectTest.java @@ -32,25 +32,25 @@ public static void teardown() throws IOException { @Test public void testInit() throws IOException { HubConfig config = getHubConfig(); - config.setStagingHttpName("my-crazy-test-staging"); - config.setStagingDbName("my-crazy-test-staging"); - config.setStagingForestsPerHost(100); - config.setStagingPort(1111); + config.setHttpName(DatabaseKind.STAGING, "my-crazy-test-staging"); + config.setDbName(DatabaseKind.STAGING, "my-crazy-test-staging"); + config.setForestsPerHost(DatabaseKind.STAGING, 100); + config.setPort(DatabaseKind.STAGING, 1111); - config.setFinalHttpName("my-crazy-test-final"); - config.setFinalDbName("my-crazy-test-final"); - config.setFinalForestsPerHost(100); - config.setFinalPort(2222); + config.setHttpName(DatabaseKind.FINAL, "my-crazy-test-final"); + config.setDbName(DatabaseKind.FINAL, "my-crazy-test-final"); + config.setForestsPerHost(DatabaseKind.FINAL, 100); + config.setPort(DatabaseKind.FINAL, 2222); - config.setTraceHttpName("my-crazy-test-trace"); - config.setTraceDbName("my-crazy-test-trace"); - config.setTraceForestsPerHost(100); - config.setTracePort(3333); + config.setHttpName(DatabaseKind.TRACE, "my-crazy-test-trace"); + config.setDbName(DatabaseKind.TRACE, "my-crazy-test-trace"); + config.setForestsPerHost(DatabaseKind.TRACE, 100); + config.setPort(DatabaseKind.TRACE, 3333); - config.setModulesForestsPerHost(3); - config.setTriggersForestsPerHost(4); + config.setForestsPerHost(DatabaseKind.MODULES,3); + config.setForestsPerHost(DatabaseKind.TRIGGERS, 4); - config.setSchemasForestsPerHost(5); + config.setForestsPerHost(DatabaseKind.SCHEMAS, 5); config.setHubRoleName("myrole"); config.setHubUserName("myuser"); @@ -105,34 +105,34 @@ public void testInit() throws IOException { assertEquals("9001", props.getProperty("mlAdminPort")); assertEquals("9002", props.getProperty("mlManagePort")); - assertEquals(config.getStagingHttpName(), props.getProperty("mlStagingAppserverName")); - assertEquals(config.getStagingPort().toString(), props.getProperty("mlStagingPort")); - assertEquals(config.getStagingDbName(), props.getProperty("mlStagingDbName")); - assertEquals(config.getStagingForestsPerHost().toString(), props.getProperty("mlStagingForestsPerHost")); + assertEquals(config.getHttpName(DatabaseKind.STAGING), props.getProperty("mlStagingAppserverName")); + assertEquals(config.getPort(DatabaseKind.STAGING).toString(), props.getProperty("mlStagingPort")); + assertEquals(config.getDbName(DatabaseKind.STAGING), props.getProperty("mlStagingDbName")); + assertEquals(config.getForestsPerHost(DatabaseKind.STAGING).toString(), props.getProperty("mlStagingForestsPerHost")); - assertEquals(config.getFinalHttpName(), props.getProperty("mlFinalAppserverName")); - assertEquals(config.getFinalPort().toString(), props.getProperty("mlFinalPort")); - assertEquals(config.getFinalDbName(), props.getProperty("mlFinalDbName")); - assertEquals(config.getFinalForestsPerHost().toString(), props.getProperty("mlFinalForestsPerHost")); + assertEquals(config.getHttpName(DatabaseKind.FINAL), props.getProperty("mlFinalAppserverName")); + assertEquals(config.getPort(DatabaseKind.FINAL).toString(), props.getProperty("mlFinalPort")); + assertEquals(config.getDbName(DatabaseKind.FINAL), props.getProperty("mlFinalDbName")); + assertEquals(config.getForestsPerHost(DatabaseKind.FINAL).toString(), props.getProperty("mlFinalForestsPerHost")); - assertEquals(config.getTraceHttpName(), props.getProperty("mlTraceAppserverName")); - assertEquals(config.getTracePort().toString(), props.getProperty("mlTracePort")); - assertEquals(config.getTraceDbName(), props.getProperty("mlTraceDbName")); - assertEquals(config.getTraceForestsPerHost().toString(), props.getProperty("mlTraceForestsPerHost")); + assertEquals(config.getHttpName(DatabaseKind.TRACE), props.getProperty("mlTraceAppserverName")); + assertEquals(config.getPort(DatabaseKind.TRACE).toString(), props.getProperty("mlTracePort")); + assertEquals(config.getDbName(DatabaseKind.TRACE), props.getProperty("mlTraceDbName")); + assertEquals(config.getForestsPerHost(DatabaseKind.TRACE).toString(), props.getProperty("mlTraceForestsPerHost")); - assertEquals(config.getJobHttpName(), props.getProperty("mlJobAppserverName")); - assertEquals(config.getJobPort().toString(), props.getProperty("mlJobPort")); - assertEquals(config.getJobDbName(), props.getProperty("mlJobDbName")); - assertEquals(config.getJobForestsPerHost().toString(), props.getProperty("mlJobForestsPerHost")); + assertEquals(config.getHttpName(DatabaseKind.JOB), props.getProperty("mlJobAppserverName")); + assertEquals(config.getPort(DatabaseKind.JOB).toString(), props.getProperty("mlJobPort")); + assertEquals(config.getDbName(DatabaseKind.JOB), props.getProperty("mlJobDbName")); + assertEquals(config.getForestsPerHost(DatabaseKind.JOB).toString(), props.getProperty("mlJobForestsPerHost")); - assertEquals(config.getModulesDbName(), props.getProperty("mlModulesDbName")); - assertEquals(config.getModulesForestsPerHost().toString(), props.getProperty("mlModulesForestsPerHost")); + assertEquals(config.getDbName(DatabaseKind.MODULES), props.getProperty("mlModulesDbName")); + assertEquals(config.getForestsPerHost(DatabaseKind.MODULES).toString(), props.getProperty("mlModulesForestsPerHost")); - assertEquals(config.getTriggersDbName(), props.getProperty("mlTriggersDbName")); - assertEquals(config.getTriggersForestsPerHost().toString(), props.getProperty("mlTriggersForestsPerHost")); + assertEquals(config.getDbName(DatabaseKind.TRIGGERS), props.getProperty("mlTriggersDbName")); + assertEquals(config.getForestsPerHost(DatabaseKind.TRIGGERS).toString(), props.getProperty("mlTriggersForestsPerHost")); - assertEquals(config.getSchemasDbName(), props.getProperty("mlSchemasDbName")); - assertEquals(config.getSchemasForestsPerHost().toString(), props.getProperty("mlSchemasForestsPerHost")); + assertEquals(config.getDbName(DatabaseKind.SCHEMAS), props.getProperty("mlSchemasDbName")); + assertEquals(config.getForestsPerHost(DatabaseKind.SCHEMAS).toString(), props.getProperty("mlSchemasForestsPerHost")); assertEquals(config.getHubRoleName(), props.getProperty("mlHubUserRole")); assertEquals(config.getHubUserName(), props.getProperty("mlHubUserName")); diff --git a/marklogic-data-hub/src/test/java/com/marklogic/hub/HubTestBase.java b/marklogic-data-hub/src/test/java/com/marklogic/hub/HubTestBase.java index fb36b5769b..cb516a9a99 100644 --- a/marklogic-data-hub/src/test/java/com/marklogic/hub/HubTestBase.java +++ b/marklogic-data-hub/src/test/java/com/marklogic/hub/HubTestBase.java @@ -239,10 +239,10 @@ protected static HubConfig getHubConfig(String projectDir) { HubConfig hubConfig = HubConfigBuilder.newHubConfigBuilder(projectDir) .withPropertiesFromEnvironment("local") .build(); - hubConfig.setStagingPort(stagingPort); - hubConfig.setFinalPort(finalPort); - hubConfig.setTracePort(tracePort); - hubConfig.setJobPort(jobPort); + hubConfig.setPort(DatabaseKind.STAGING, stagingPort); + hubConfig.setPort(DatabaseKind.FINAL, finalPort); + hubConfig.setPort(DatabaseKind.TRACE, tracePort); + hubConfig.setPort(DatabaseKind.JOB, jobPort); hubConfig.getAppConfig().setAppServicesUsername(user); hubConfig.getAppConfig().setAppServicesPassword(password); hubConfig.getAppConfig().setHost(host); diff --git a/quick-start/src/main/java/com/marklogic/quickstart/web/CurrentProjectController.java b/quick-start/src/main/java/com/marklogic/quickstart/web/CurrentProjectController.java index 831a419efb..d697bc28a0 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/web/CurrentProjectController.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/web/CurrentProjectController.java @@ -17,6 +17,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; +import com.marklogic.hub.DatabaseKind; import com.marklogic.hub.HubConfig; import com.marklogic.hub.InstallInfo; import com.marklogic.hub.Tracing; @@ -190,7 +191,7 @@ public ResponseEntity clearDatabase(@PathVariable String database) { @ResponseBody public ResponseEntity clearDatabase() { HubConfig config = envConfig().getMlSettings(); - String[] databases = { config.getStagingDbName(), config.getFinalDbName(), config.getJobDbName(), config.getTraceDbName() }; + String[] databases = { config.getDbName(DatabaseKind.STAGING), config.getDbName(DatabaseKind.FINAL), config.getDbName(DatabaseKind.JOB), config.getDbName(DatabaseKind.TRACE) }; for (String database: databases) { dataHubService.clearContent(envConfig().getMlSettings(), database); } From b84a76a28f51519e20501684903c1752980eed88 Mon Sep 17 00:00:00 2001 From: Alexander Ebadirad Date: Fri, 2 Mar 2018 11:11:40 -0700 Subject: [PATCH 21/22] Adding copyright headers, removing database subclass, adding javadoc comments --- marklogic-data-hub/build.gradle | 17 ++++ marklogic-data-hub/gradle.properties | 17 ++++ .../main/java/com/marklogic/hub/DataHub.java | 80 ++++++++++++------- .../java/com/marklogic/hub/DatabaseKind.java | 38 ++++++++- .../java/com/marklogic/hub/EntityManager.java | 28 +++++++ .../java/com/marklogic/hub/FlowManager.java | 20 +++++ .../java/com/marklogic/hub/HubConfig.java | 5 +- .../com/marklogic/hub/HubConfigBuilder.java | 16 ++++ .../java/com/marklogic/hub/HubProject.java | 16 ++++ .../java/com/marklogic/hub/InstallInfo.java | 16 ++++ .../hub/error/InvalidDBOperationError.java | 16 ++++ .../com/marklogic/hub/impl/DataHubImpl.java | 8 +- .../hub/impl/HubConfigBuilderImpl.java | 2 +- .../marklogic/hub/job/JobExportResponse.java | 16 ++++ .../com/marklogic/hub/job/JobManager.java | 16 ++++ .../marklogic/hub/scaffold/Scaffolding.java | 16 ++++ .../hub/validate/EntitiesValidator.java | 16 ++++ .../server-side/tracing/tracing-rewriter.xml | 17 +++- .../com/marklogic/hub/ScaffoldingTest.java | 16 ++++ .../hub/ScaffoldingValidatorTest.java | 16 ++++ .../java/com/marklogic/hub/TracingTest.java | 15 ++++ ml-data-hub-plugin/build.gradle | 17 ++++ ml-data-hub-plugin/gradle.properties | 17 ++++ .../com/marklogic/gradle/DataHubPlugin.groovy | 17 ++++ .../EntityNameRequiredException.groovy | 17 ++++ .../FlowNameRequiredException.groovy | 17 ++++ .../exception/FlowNotFoundException.java | 17 ++++ .../exception/HubNotInstalledException.groovy | 17 ++++ .../exception/JobIdsRequiredException.groovy | 17 ++++ .../gradle/task/CreateEntityTask.groovy | 17 ++++ .../gradle/task/CreateFlowTask.groovy | 17 ++++ .../task/CreateHarmonizeFlowTask.groovy | 17 ++++ .../gradle/task/CreateInputFlowTask.groovy | 17 ++++ .../DeleteHubModuleTimestampsFileTask.groovy | 17 ++++ .../gradle/task/DeleteJobsTask.groovy | 17 ++++ .../gradle/task/DeployHubModulesTask.groovy | 17 ++++ .../gradle/task/DeployUserModulesTask.groovy | 17 ++++ .../gradle/task/DisableDebuggingTask.groovy | 17 ++++ .../gradle/task/DisableTracingTask.groovy | 17 ++++ .../gradle/task/EnableDebuggingTask.groovy | 17 ++++ .../gradle/task/EnableTracingTask.groovy | 17 ++++ .../gradle/task/ExportJobsTask.groovy | 17 ++++ .../GenerateTDETemplateFromEntityTask.groovy | 17 ++++ .../marklogic/gradle/task/HubInfoTask.groovy | 17 ++++ .../com/marklogic/gradle/task/HubTask.groovy | 17 ++++ .../marklogic/gradle/task/HubWatchTask.groovy | 17 ++++ .../gradle/task/ImportJobsTask.groovy | 17 ++++ .../gradle/task/InitProjectTask.groovy | 17 ++++ .../gradle/task/PreinstallCheckTask.groovy | 17 ++++ .../marklogic/gradle/task/RunFlowTask.groovy | 17 ++++ .../gradle/task/UpdateHubTask.groovy | 17 ++++ .../com.marklogic.ml-data-hub.properties | 17 ++++ .../com/marklogic/gradle/task/BaseTest.groovy | 17 ++++ .../gradle/task/BasicAuthTest.groovy | 17 ++++ .../gradle/task/CreateEntityTaskTest.groovy | 17 ++++ .../task/CreateHarmonizeFlowTaskTest.groovy | 17 ++++ .../task/CreateInputFlowTaskTest.groovy | 17 ++++ .../gradle/task/ExportJobsTaskTest.groovy | 17 ++++ .../gradle/task/InitProjectTaskTest.groovy | 17 ++++ .../gradle/task/InstalledTests.groovy | 17 ++++ .../gradle/task/JobDeleteTaskTest.groovy | 17 ++++ .../gradle/task/NotInstalledTests.groovy | 17 ++++ .../com/marklogic/gradle/task/SslTest.groovy | 17 ++++ .../com/marklogic/gradle/task/TlsTest.groovy | 17 ++++ .../gradle/task/UpdateHubTaskTest.groovy | 17 ++++ quick-start/build.gradle | 17 ++++ quick-start/gradle.properties | 17 ++++ .../com/marklogic/quickstart/Application.java | 19 ++--- .../quickstart/ApplicationRunListener.java | 19 ++--- .../com/marklogic/quickstart/AuthConfig.java | 19 ++--- .../quickstart/EnvironmentAware.java | 19 ++--- .../quickstart/PortInUseFailureAnalyzer.java | 19 ++--- .../marklogic/quickstart/WebSocketConfig.java | 19 ++--- .../auth/ConnectionAuthenticationFilter.java | 19 ++--- .../auth/ConnectionAuthenticationToken.java | 19 ++--- .../marklogic/quickstart/auth/LoginInfo.java | 19 ++--- .../auth/MarkLogicAuthenticationManager.java | 19 ++--- .../auth/RestAuthenticationEntryPoint.java | 19 ++--- .../exception/BadRequestException.java | 19 ++--- .../exception/DataHubException.java | 19 ++--- .../exception/NotFoundException.java | 19 ++--- .../listeners/DeployUserModulesListener.java | 19 ++--- .../listeners/ValidateListener.java | 19 ++--- .../quickstart/model/EnvironmentConfig.java | 19 ++--- .../marklogic/quickstart/model/FlowModel.java | 19 ++--- .../marklogic/quickstart/model/JobExport.java | 17 ++++ .../marklogic/quickstart/model/JobQuery.java | 19 ++--- .../quickstart/model/JobStatusMessage.java | 19 ++--- .../quickstart/model/PluginModel.java | 19 ++--- .../marklogic/quickstart/model/Project.java | 19 ++--- .../quickstart/model/ProjectInfo.java | 19 ++--- .../quickstart/model/SearchPathModel.java | 19 ++--- .../quickstart/model/SearchQuery.java | 23 +++--- .../quickstart/model/StatusMessage.java | 19 ++--- .../quickstart/model/TraceQuery.java | 19 ++--- .../model/entity_services/DefinitionType.java | 19 ++--- .../entity_services/DefinitionsType.java | 19 ++--- .../model/entity_services/EntityModel.java | 19 ++--- .../model/entity_services/HubUIData.java | 19 ++--- .../model/entity_services/InfoType.java | 19 ++--- .../model/entity_services/ItemType.java | 19 ++--- .../model/entity_services/JsonPojo.java | 19 ++--- .../model/entity_services/PropertyType.java | 19 ++--- .../quickstart/service/CancellableTask.java | 19 ++--- .../quickstart/service/DataHubService.java | 19 ++--- .../service/EntityManagerService.java | 19 ++--- .../service/FileSystemEventListener.java | 19 ++--- .../service/FileSystemWatcherService.java | 19 ++--- .../service/FlowManagerService.java | 19 ++--- .../quickstart/service/HubStatsService.java | 19 ++--- .../quickstart/service/JobService.java | 19 ++--- .../service/ProjectManagerService.java | 19 ++--- .../quickstart/service/SearchService.java | 27 ++++--- .../quickstart/service/SearchableService.java | 19 ++--- .../quickstart/service/TraceService.java | 19 ++--- .../marklogic/quickstart/util/FileUtil.java | 19 ++--- .../marklogic/quickstart/util/MlcpMain.java | 19 ++--- .../quickstart/web/AppController.java | 19 ++--- .../web/CurrentProjectController.java | 19 ++--- .../quickstart/web/EntitiesController.java | 19 ++--- .../quickstart/web/JobsController.java | 19 ++--- .../quickstart/web/ProjectsController.java | 19 ++--- .../quickstart/web/SearchController.java | 22 ++--- .../quickstart/web/SettingsController.java | 19 ++--- .../quickstart/web/TracesController.java | 19 ++--- .../quickstart/web/UtilController.java | 19 ++--- .../main/resources/application-dev.properties | 17 ++++ .../src/main/resources/application.properties | 17 ++++ .../src/main/resources/logback-spring.xml | 17 ++++ .../service/EntityManagerServiceTest.java | 17 ++++ .../service/FlowManagerServiceTest.java | 17 ++++ .../quickstart/service/JobServiceTest.java | 17 ++++ .../quickstart/service/TraceServiceTest.java | 17 ++++ .../quickstart/web/BaseTestController.java | 17 ++++ .../web/EntitiesControllerTest.java | 17 ++++ .../quickstart/web/HubConfigJsonTest.java | 17 ++++ .../web/ProjectsControllerTest.java | 17 ++++ .../sjs-harmonize-flow/test flow.properties | 17 ++++ 138 files changed, 1960 insertions(+), 567 deletions(-) diff --git a/marklogic-data-hub/build.gradle b/marklogic-data-hub/build.gradle index c21ac80bf0..116ce0490a 100644 --- a/marklogic-data-hub/build.gradle +++ b/marklogic-data-hub/build.gradle @@ -235,6 +235,23 @@ ext { } } +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + // for the StreamCollectorTest we need to constrain the memory // to a lower value so that the out of memory issue appears // the hack here is to run that single test in this task with diff --git a/marklogic-data-hub/gradle.properties b/marklogic-data-hub/gradle.properties index 2523b314bf..7d5b83f47f 100644 --- a/marklogic-data-hub/gradle.properties +++ b/marklogic-data-hub/gradle.properties @@ -1,3 +1,20 @@ +# +# Copyright 2012-2018 MarkLogic Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# + mlConfigDir=marklogic-data-hub/src/main/resources/ml-config mlHost=localhost diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/DataHub.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/DataHub.java index 1fa0ce61fe..054ebcf4d8 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/DataHub.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/DataHub.java @@ -1,3 +1,19 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.marklogic.hub; import com.marklogic.hub.deploy.util.HubDeployStatusListener; @@ -14,30 +30,10 @@ static DataHub create(HubConfig hubConfig) { return new DataHubImpl(hubConfig); } - //HubDatabase stuff goes here - enum HubDatabase { - STAGING("staging"), - FINAL("final"); - - private String type; - - HubDatabase(String type) { - this.type = type; - } - - public static HubDatabase getHubDatabase(String database) { - for (HubDatabase hubDatabase : HubDatabase.values()) { - if (hubDatabase.toString().equals(database)) { - return hubDatabase; - } - } - return null; - } - - public String toString() { - return this.type; - } - } + /** + * Clears the database of all documents + * @param database - the name of the database in string form + */ void clearDatabase(String database); @@ -55,42 +51,62 @@ public String toString() { */ boolean isServerVersionValid(String versionString); + /** + * Initializes the project on disk, creates scaffold project code + */ void initProject(); /** * Removes user's modules from the modules db - * TODO: this becomes much simpler when we move code into the server dir */ void clearUserModules(); + /** + * Runs the pre-install check for the datahub populating the object + * with variables necessary to perform the install. + * This is used for running install. + */ void runPreInstallCheck(); + /** + * Runs the pre-install check for the datahub populating the object + * with variables necessary to perform the install. + * This is used for running install. + * @param versions - the versions that the check is to be run against + */ void runPreInstallCheck(Versions versions); /** - * Installs the data hub configuration and server-side modules into MarkLogic + * Installs the data hub configuration and server-side config files into MarkLogic */ void install(); /** - * Installs the data hub configuration and server-side modules into MarkLogic + * Installs the data hub configuration and server-side config files into MarkLogic * @param listener - the callback method to receive status updates */ void install(HubDeployStatusListener listener); + /** + * Updates the indexes in the database based on the project + */ void updateIndexes(); /** - * Uninstalls the data hub configuration and server-side modules from MarkLogic + * Uninstalls the data hub configuration and server-side config files from MarkLogic */ void uninstall(); /** - * Uninstalls the data hub configuration and server-side modules from MarkLogic + * Uninstalls the data hub configuration and server-side config files from MarkLogic * @param listener - the callback method to receive status updates */ void uninstall(HubDeployStatusListener listener); + /** + * Checks to make sure all the versions and database in a valid configuration with version check + * @return boolean - if not, returns false, if safe to proceed ahead returns true + */ boolean isSafeToInstall(); boolean isPortInUse(DatabaseKind kind); @@ -109,6 +125,12 @@ public String toString() { boolean upgradeHub() throws CantUpgradeException; + /** + * Upgrades the hub based on list of provided updated flows. All flows SHOULD be provided. + * The method without params will handle this automatically. + * @return boolean - false if upgrade fails for a reason other than an upgrade exception + * @throws CantUpgradeException - should the hub fail to upgrade for incompatibility reasons + */ boolean upgradeHub(List updatedFlows) throws CantUpgradeException; } diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/DatabaseKind.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/DatabaseKind.java index b53bdf28d7..f388c16ff8 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/DatabaseKind.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/DatabaseKind.java @@ -1,5 +1,23 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.marklogic.hub; +import com.marklogic.hub.error.InvalidDBOperationError; + public enum DatabaseKind { STAGING, FINAL, @@ -7,5 +25,23 @@ public enum DatabaseKind { TRACE, SCHEMAS, TRIGGERS, - MODULES + MODULES; + + static private String[] databaseNames = { + "staging", + "final", + "job", + "trace", + "schemas", + "triggers", + "modules" + }; + + static public String getName(DatabaseKind databaseKind){ + try { + return databaseNames[databaseKind.ordinal()]; + } catch (Exception e) { + throw new InvalidDBOperationError(databaseKind, "find databaseKind name"); + } + } } diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/EntityManager.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/EntityManager.java index 18e360f637..31bf3ecef1 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/EntityManager.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/EntityManager.java @@ -1,3 +1,19 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.marklogic.hub; import com.marklogic.hub.impl.EntityManagerImpl; @@ -10,9 +26,21 @@ static EntityManager create(HubConfig hubConfig) { return new EntityManagerImpl(hubConfig); } + /** + * Updates the query options to the file system + * @return boolean - if it fails to so, false is returned + */ boolean saveQueryOptions(); + /** + * Deploys the query option + * @return hashmap - ENUM DatabaseKind of what database and boolean if the deploy was successful or not. + */ HashMap deployQueryOptions(); + /** + * Updates the indexes for the entity on the filesystem + * @return boolean - if it fails to do so, false is returned + */ boolean saveDbIndexes(); } diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/FlowManager.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/FlowManager.java index af0e1b8133..aba5837926 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/FlowManager.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/FlowManager.java @@ -1,3 +1,19 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.marklogic.hub; import com.marklogic.hub.flow.Flow; @@ -59,6 +75,10 @@ static Flow flowFromXml(Element doc) { Flow getFlow(String entityName, String flowName, FlowType flowType); + /** + * Updates the indexes in the database based on the project + */ + List getLegacyFlows(); List updateLegacyFlows(String fromVersion); diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/HubConfig.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/HubConfig.java index 3d12a82621..be7fff6abe 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/HubConfig.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/HubConfig.java @@ -18,6 +18,7 @@ import com.marklogic.appdeployer.AppConfig; import com.marklogic.client.DatabaseClient; import com.marklogic.client.DatabaseClientFactory; +import com.marklogic.hub.impl.HubConfigImpl; import javax.net.ssl.SSLContext; import java.io.IOException; @@ -64,7 +65,9 @@ public interface HubConfig { String getHost(); - + static HubConfig create(String projectDir) { + return new HubConfigImpl(projectDir); + } String getDbName(DatabaseKind kind); void setDbName(DatabaseKind kind, String dbName); diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/HubConfigBuilder.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/HubConfigBuilder.java index 0ad6832d42..207e5cc8aa 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/HubConfigBuilder.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/HubConfigBuilder.java @@ -1,3 +1,19 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.marklogic.hub; import com.marklogic.appdeployer.AppConfig; diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/HubProject.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/HubProject.java index 706faf7202..66af1a33d9 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/HubProject.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/HubProject.java @@ -1,3 +1,19 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.marklogic.hub; import com.marklogic.hub.impl.HubProjectImpl; diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/InstallInfo.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/InstallInfo.java index c77150f1db..3b0a7d90a2 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/InstallInfo.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/InstallInfo.java @@ -1,3 +1,19 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.marklogic.hub; import com.marklogic.hub.impl.InstallInfoImpl; diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/error/InvalidDBOperationError.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/error/InvalidDBOperationError.java index 40033489c0..d11c8ac8f9 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/error/InvalidDBOperationError.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/error/InvalidDBOperationError.java @@ -1,3 +1,19 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.marklogic.hub.error; import com.marklogic.hub.DatabaseKind; diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/DataHubImpl.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/DataHubImpl.java index 02f2f2d475..2a27a29297 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/DataHubImpl.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/DataHubImpl.java @@ -295,14 +295,14 @@ public List getCommandList() { } /** - * Installs the data hub configuration and server-side modules into MarkLogic + * Installs the data hub configuration and server-side config files into MarkLogic */ @Override public void install() { install(null); } /** - * Installs the data hub configuration and server-side modules into MarkLogic + * Installs the data hub configuration and server-side config files into MarkLogic * @param listener - the callback method to receive status updates */ @Override public void install(HubDeployStatusListener listener) { @@ -326,14 +326,14 @@ public List getCommandList() { } /** - * Uninstalls the data hub configuration and server-side modules from MarkLogic + * Uninstalls the data hub configuration and server-side config files from MarkLogic */ @Override public void uninstall() { uninstall(null); } /** - * Uninstalls the data hub configuration and server-side modules from MarkLogic + * Uninstalls the data hub configuration and server-side config files from MarkLogic * @param listener - the callback method to receive status updates */ @Override public void uninstall(HubDeployStatusListener listener) { diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/HubConfigBuilderImpl.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/HubConfigBuilderImpl.java index b5fbc632a6..d6f416266d 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/HubConfigBuilderImpl.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/HubConfigBuilderImpl.java @@ -62,7 +62,7 @@ public class HubConfigBuilderImpl implements HubConfigBuilder { public HubConfigBuilderImpl(String projectDir) { this.projectDir = projectDir; - this.hubConfig = new HubConfigImpl(projectDir); + this.hubConfig = (HubConfigImpl)HubConfig.create(projectDir); } /** diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/job/JobExportResponse.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/job/JobExportResponse.java index 05b3e2f417..f059af0aeb 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/job/JobExportResponse.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/job/JobExportResponse.java @@ -1,3 +1,19 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.marklogic.hub.job; public class JobExportResponse { diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/job/JobManager.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/job/JobManager.java index e2c7852f30..d2c01adf96 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/job/JobManager.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/job/JobManager.java @@ -1,3 +1,19 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.marklogic.hub.job; import com.marklogic.client.DatabaseClient; diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/scaffold/Scaffolding.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/scaffold/Scaffolding.java index c2b262543e..15ff15e286 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/scaffold/Scaffolding.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/scaffold/Scaffolding.java @@ -1,3 +1,19 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.marklogic.hub.scaffold; import com.marklogic.hub.error.ScaffoldingValidationException; diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/validate/EntitiesValidator.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/validate/EntitiesValidator.java index 84435cf81a..459c059366 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/validate/EntitiesValidator.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/validate/EntitiesValidator.java @@ -1,3 +1,19 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.marklogic.hub.validate; import com.fasterxml.jackson.databind.JsonNode; diff --git a/marklogic-data-hub/src/server-side/tracing/tracing-rewriter.xml b/marklogic-data-hub/src/server-side/tracing/tracing-rewriter.xml index ba71ebd593..72d2194207 100644 --- a/marklogic-data-hub/src/server-side/tracing/tracing-rewriter.xml +++ b/marklogic-data-hub/src/server-side/tracing/tracing-rewriter.xml @@ -1,4 +1,19 @@ - + diff --git a/marklogic-data-hub/src/test/java/com/marklogic/hub/ScaffoldingTest.java b/marklogic-data-hub/src/test/java/com/marklogic/hub/ScaffoldingTest.java index bff3baab1f..7b3e7832c4 100644 --- a/marklogic-data-hub/src/test/java/com/marklogic/hub/ScaffoldingTest.java +++ b/marklogic-data-hub/src/test/java/com/marklogic/hub/ScaffoldingTest.java @@ -1,3 +1,19 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.marklogic.hub; import com.marklogic.hub.error.ScaffoldingValidationException; diff --git a/marklogic-data-hub/src/test/java/com/marklogic/hub/ScaffoldingValidatorTest.java b/marklogic-data-hub/src/test/java/com/marklogic/hub/ScaffoldingValidatorTest.java index 67e65aa7f7..3917230134 100644 --- a/marklogic-data-hub/src/test/java/com/marklogic/hub/ScaffoldingValidatorTest.java +++ b/marklogic-data-hub/src/test/java/com/marklogic/hub/ScaffoldingValidatorTest.java @@ -1,3 +1,19 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.marklogic.hub; import com.marklogic.hub.error.ScaffoldingValidationException; diff --git a/marklogic-data-hub/src/test/java/com/marklogic/hub/TracingTest.java b/marklogic-data-hub/src/test/java/com/marklogic/hub/TracingTest.java index 8881f0e766..98bb9e6371 100644 --- a/marklogic-data-hub/src/test/java/com/marklogic/hub/TracingTest.java +++ b/marklogic-data-hub/src/test/java/com/marklogic/hub/TracingTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.marklogic.hub; import com.fasterxml.jackson.databind.JsonNode; diff --git a/ml-data-hub-plugin/build.gradle b/ml-data-hub-plugin/build.gradle index d4c718e297..160f5b1138 100644 --- a/ml-data-hub-plugin/build.gradle +++ b/ml-data-hub-plugin/build.gradle @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + buildscript { repositories { jcenter() diff --git a/ml-data-hub-plugin/gradle.properties b/ml-data-hub-plugin/gradle.properties index b64c054231..7b1aefa2c2 100644 --- a/ml-data-hub-plugin/gradle.properties +++ b/ml-data-hub-plugin/gradle.properties @@ -1 +1,18 @@ +# +# Copyright 2012-2018 MarkLogic Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# + group=com.marklogic diff --git a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/DataHubPlugin.groovy b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/DataHubPlugin.groovy index 653da43581..f16c4ed4cc 100644 --- a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/DataHubPlugin.groovy +++ b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/DataHubPlugin.groovy @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.gradle import com.marklogic.appdeployer.impl.SimpleAppDeployer diff --git a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/exception/EntityNameRequiredException.groovy b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/exception/EntityNameRequiredException.groovy index e83d92eec0..55451cf7f9 100644 --- a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/exception/EntityNameRequiredException.groovy +++ b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/exception/EntityNameRequiredException.groovy @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.gradle.exception import org.gradle.api.GradleException diff --git a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/exception/FlowNameRequiredException.groovy b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/exception/FlowNameRequiredException.groovy index 1c711582e4..ff936528aa 100644 --- a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/exception/FlowNameRequiredException.groovy +++ b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/exception/FlowNameRequiredException.groovy @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.gradle.exception import org.gradle.api.GradleException diff --git a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/exception/FlowNotFoundException.java b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/exception/FlowNotFoundException.java index 8286879cd5..81c5a52e49 100644 --- a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/exception/FlowNotFoundException.java +++ b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/exception/FlowNotFoundException.java @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.gradle.exception; public class FlowNotFoundException extends Exception { diff --git a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/exception/HubNotInstalledException.groovy b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/exception/HubNotInstalledException.groovy index 4322c5c7dd..06f0e61c86 100644 --- a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/exception/HubNotInstalledException.groovy +++ b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/exception/HubNotInstalledException.groovy @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.gradle.exception; import org.gradle.api.GradleException; diff --git a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/exception/JobIdsRequiredException.groovy b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/exception/JobIdsRequiredException.groovy index ffbd712945..a45d092cfe 100644 --- a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/exception/JobIdsRequiredException.groovy +++ b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/exception/JobIdsRequiredException.groovy @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.gradle.exception import org.gradle.api.GradleException diff --git a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/CreateEntityTask.groovy b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/CreateEntityTask.groovy index 03a472100a..95028d5a00 100644 --- a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/CreateEntityTask.groovy +++ b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/CreateEntityTask.groovy @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.gradle.task import com.marklogic.gradle.exception.EntityNameRequiredException diff --git a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/CreateFlowTask.groovy b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/CreateFlowTask.groovy index 449615cb27..06f033f027 100644 --- a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/CreateFlowTask.groovy +++ b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/CreateFlowTask.groovy @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.gradle.task import com.marklogic.gradle.exception.EntityNameRequiredException diff --git a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/CreateHarmonizeFlowTask.groovy b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/CreateHarmonizeFlowTask.groovy index 116bd0b402..3dab717c69 100644 --- a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/CreateHarmonizeFlowTask.groovy +++ b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/CreateHarmonizeFlowTask.groovy @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.gradle.task import com.marklogic.hub.flow.FlowType diff --git a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/CreateInputFlowTask.groovy b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/CreateInputFlowTask.groovy index fc1aa5ba34..3a8f8b7227 100644 --- a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/CreateInputFlowTask.groovy +++ b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/CreateInputFlowTask.groovy @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.gradle.task import com.marklogic.hub.flow.FlowType diff --git a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/DeleteHubModuleTimestampsFileTask.groovy b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/DeleteHubModuleTimestampsFileTask.groovy index 2cd5e58824..36f99af8ad 100644 --- a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/DeleteHubModuleTimestampsFileTask.groovy +++ b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/DeleteHubModuleTimestampsFileTask.groovy @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.gradle.task import org.gradle.api.tasks.TaskAction diff --git a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/DeleteJobsTask.groovy b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/DeleteJobsTask.groovy index ae4e023f0b..829cdb5c2d 100644 --- a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/DeleteJobsTask.groovy +++ b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/DeleteJobsTask.groovy @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.gradle.task import com.marklogic.gradle.exception.JobIdsRequiredException diff --git a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/DeployHubModulesTask.groovy b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/DeployHubModulesTask.groovy index 25e00864d8..6ab430a6aa 100644 --- a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/DeployHubModulesTask.groovy +++ b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/DeployHubModulesTask.groovy @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.gradle.task import com.marklogic.hub.deploy.commands.LoadHubModulesCommand diff --git a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/DeployUserModulesTask.groovy b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/DeployUserModulesTask.groovy index e4a5d9a44e..22fec42fa0 100644 --- a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/DeployUserModulesTask.groovy +++ b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/DeployUserModulesTask.groovy @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.gradle.task import com.marklogic.hub.deploy.commands.LoadUserModulesCommand diff --git a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/DisableDebuggingTask.groovy b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/DisableDebuggingTask.groovy index 0e21c1394d..623e86eedb 100644 --- a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/DisableDebuggingTask.groovy +++ b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/DisableDebuggingTask.groovy @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.gradle.task import com.marklogic.gradle.exception.HubNotInstalledException diff --git a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/DisableTracingTask.groovy b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/DisableTracingTask.groovy index cc1b0c9411..3498c2e123 100644 --- a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/DisableTracingTask.groovy +++ b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/DisableTracingTask.groovy @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.gradle.task import com.marklogic.gradle.exception.HubNotInstalledException diff --git a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/EnableDebuggingTask.groovy b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/EnableDebuggingTask.groovy index 38bbd87e23..fd40277e34 100644 --- a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/EnableDebuggingTask.groovy +++ b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/EnableDebuggingTask.groovy @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.gradle.task import com.marklogic.gradle.exception.HubNotInstalledException diff --git a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/EnableTracingTask.groovy b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/EnableTracingTask.groovy index 6d342b1f98..5420b06346 100644 --- a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/EnableTracingTask.groovy +++ b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/EnableTracingTask.groovy @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.gradle.task import com.marklogic.gradle.exception.HubNotInstalledException diff --git a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/ExportJobsTask.groovy b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/ExportJobsTask.groovy index 99b63891a4..d92b9fb0af 100644 --- a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/ExportJobsTask.groovy +++ b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/ExportJobsTask.groovy @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.gradle.task import org.gradle.api.tasks.Input diff --git a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/GenerateTDETemplateFromEntityTask.groovy b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/GenerateTDETemplateFromEntityTask.groovy index b9604710fc..1c5d5a347a 100644 --- a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/GenerateTDETemplateFromEntityTask.groovy +++ b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/GenerateTDETemplateFromEntityTask.groovy @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.gradle.task import com.marklogic.hub.deploy.commands.GenerateHubTDETemplateCommand diff --git a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/HubInfoTask.groovy b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/HubInfoTask.groovy index fc50218d5c..f45de4fbdf 100644 --- a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/HubInfoTask.groovy +++ b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/HubInfoTask.groovy @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.gradle.task import org.gradle.api.tasks.TaskAction diff --git a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/HubTask.groovy b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/HubTask.groovy index 6039c485f1..c2b392973b 100644 --- a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/HubTask.groovy +++ b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/HubTask.groovy @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.gradle.task import com.fasterxml.jackson.databind.JsonNode diff --git a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/HubWatchTask.groovy b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/HubWatchTask.groovy index 130066ae7a..54fc95c778 100644 --- a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/HubWatchTask.groovy +++ b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/HubWatchTask.groovy @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.gradle.task import com.marklogic.hub.deploy.commands.LoadUserModulesCommand diff --git a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/ImportJobsTask.groovy b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/ImportJobsTask.groovy index 6e57ea2e2a..e655e36495 100644 --- a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/ImportJobsTask.groovy +++ b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/ImportJobsTask.groovy @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.gradle.task import org.gradle.api.tasks.Input diff --git a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/InitProjectTask.groovy b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/InitProjectTask.groovy index 6f1fca8bb7..8317b3b7d3 100644 --- a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/InitProjectTask.groovy +++ b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/InitProjectTask.groovy @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.gradle.task import org.gradle.api.tasks.TaskAction diff --git a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/PreinstallCheckTask.groovy b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/PreinstallCheckTask.groovy index 430add9f21..71f9c245a5 100644 --- a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/PreinstallCheckTask.groovy +++ b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/PreinstallCheckTask.groovy @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.gradle.task import com.marklogic.hub.DataHub diff --git a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/RunFlowTask.groovy b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/RunFlowTask.groovy index 9c448362a3..e1deb25746 100644 --- a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/RunFlowTask.groovy +++ b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/RunFlowTask.groovy @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.gradle.task import com.marklogic.client.DatabaseClient diff --git a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/UpdateHubTask.groovy b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/UpdateHubTask.groovy index bf06fb049e..e1718002a1 100644 --- a/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/UpdateHubTask.groovy +++ b/ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/UpdateHubTask.groovy @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.gradle.task import com.marklogic.hub.DataHub diff --git a/ml-data-hub-plugin/src/main/resources/META-INF/gradle-plugins/com.marklogic.ml-data-hub.properties b/ml-data-hub-plugin/src/main/resources/META-INF/gradle-plugins/com.marklogic.ml-data-hub.properties index dcdfb5c4fd..e75101d1f7 100644 --- a/ml-data-hub-plugin/src/main/resources/META-INF/gradle-plugins/com.marklogic.ml-data-hub.properties +++ b/ml-data-hub-plugin/src/main/resources/META-INF/gradle-plugins/com.marklogic.ml-data-hub.properties @@ -1 +1,18 @@ +# +# Copyright 2012-2018 MarkLogic Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# + implementation-class=com.marklogic.gradle.DataHubPlugin diff --git a/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/BaseTest.groovy b/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/BaseTest.groovy index 2198517038..8120cccd7e 100644 --- a/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/BaseTest.groovy +++ b/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/BaseTest.groovy @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.gradle.task import com.marklogic.client.FailedRequestException diff --git a/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/BasicAuthTest.groovy b/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/BasicAuthTest.groovy index f9f9ac5a02..df0b1c3f6b 100644 --- a/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/BasicAuthTest.groovy +++ b/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/BasicAuthTest.groovy @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.gradle.task import org.gradle.testkit.runner.UnexpectedBuildFailure diff --git a/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/CreateEntityTaskTest.groovy b/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/CreateEntityTaskTest.groovy index 1097474a80..ad28d4ed8c 100644 --- a/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/CreateEntityTaskTest.groovy +++ b/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/CreateEntityTaskTest.groovy @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.gradle.task import org.gradle.testkit.runner.UnexpectedBuildFailure diff --git a/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/CreateHarmonizeFlowTaskTest.groovy b/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/CreateHarmonizeFlowTaskTest.groovy index 35e395c06b..4ecde86321 100644 --- a/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/CreateHarmonizeFlowTaskTest.groovy +++ b/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/CreateHarmonizeFlowTaskTest.groovy @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.gradle.task import org.gradle.testkit.runner.UnexpectedBuildFailure diff --git a/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/CreateInputFlowTaskTest.groovy b/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/CreateInputFlowTaskTest.groovy index b80ef23810..19fa25c7e8 100644 --- a/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/CreateInputFlowTaskTest.groovy +++ b/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/CreateInputFlowTaskTest.groovy @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.gradle.task import org.gradle.testkit.runner.UnexpectedBuildFailure diff --git a/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/ExportJobsTaskTest.groovy b/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/ExportJobsTaskTest.groovy index 9823187d82..9a1bc6d793 100644 --- a/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/ExportJobsTaskTest.groovy +++ b/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/ExportJobsTaskTest.groovy @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.gradle.task import com.marklogic.client.eval.EvalResult diff --git a/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/InitProjectTaskTest.groovy b/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/InitProjectTaskTest.groovy index 7965007eaf..8f57badcac 100644 --- a/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/InitProjectTaskTest.groovy +++ b/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/InitProjectTaskTest.groovy @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.gradle.task import com.marklogic.hub.HubConfig diff --git a/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/InstalledTests.groovy b/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/InstalledTests.groovy index 8a65f15fa2..4cd9391475 100644 --- a/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/InstalledTests.groovy +++ b/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/InstalledTests.groovy @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.gradle.task import com.marklogic.client.io.DOMHandle diff --git a/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/JobDeleteTaskTest.groovy b/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/JobDeleteTaskTest.groovy index 243abc26e2..605c8fca80 100644 --- a/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/JobDeleteTaskTest.groovy +++ b/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/JobDeleteTaskTest.groovy @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.gradle.task import com.marklogic.client.eval.EvalResult diff --git a/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/NotInstalledTests.groovy b/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/NotInstalledTests.groovy index a72ee9c7ce..5bf8c8b220 100644 --- a/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/NotInstalledTests.groovy +++ b/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/NotInstalledTests.groovy @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.gradle.task import org.gradle.testkit.runner.UnexpectedBuildSuccess diff --git a/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/SslTest.groovy b/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/SslTest.groovy index ebca2038f1..5c2d541e79 100644 --- a/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/SslTest.groovy +++ b/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/SslTest.groovy @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.gradle.task import com.marklogic.client.DatabaseClientFactory diff --git a/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/TlsTest.groovy b/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/TlsTest.groovy index bf83cda301..5d3f99f1ca 100644 --- a/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/TlsTest.groovy +++ b/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/TlsTest.groovy @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.gradle.task import com.marklogic.client.DatabaseClientFactory diff --git a/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/UpdateHubTaskTest.groovy b/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/UpdateHubTaskTest.groovy index ae0990bfa6..3f6008b51a 100644 --- a/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/UpdateHubTaskTest.groovy +++ b/ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/UpdateHubTaskTest.groovy @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.gradle.task import org.apache.commons.io.FileUtils diff --git a/quick-start/build.gradle b/quick-start/build.gradle index 824c6f91ac..6e32b6aee2 100644 --- a/quick-start/build.gradle +++ b/quick-start/build.gradle @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + import java.util.concurrent.Executors buildscript { diff --git a/quick-start/gradle.properties b/quick-start/gradle.properties index 7d0c48380f..3e6154660b 100644 --- a/quick-start/gradle.properties +++ b/quick-start/gradle.properties @@ -1,3 +1,20 @@ +# +# Copyright 2012-2018 MarkLogic Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# + mlHost=localhost mlAppName=data-hub diff --git a/quick-start/src/main/java/com/marklogic/quickstart/Application.java b/quick-start/src/main/java/com/marklogic/quickstart/Application.java index 289adac2ad..5cbbf28c8d 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/Application.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/Application.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/ApplicationRunListener.java b/quick-start/src/main/java/com/marklogic/quickstart/ApplicationRunListener.java index 4a123954ce..f5f426d196 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/ApplicationRunListener.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/ApplicationRunListener.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/AuthConfig.java b/quick-start/src/main/java/com/marklogic/quickstart/AuthConfig.java index 54d2c269e1..9f732c0e01 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/AuthConfig.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/AuthConfig.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/EnvironmentAware.java b/quick-start/src/main/java/com/marklogic/quickstart/EnvironmentAware.java index 1221e9edb1..7ec1464d8c 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/EnvironmentAware.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/EnvironmentAware.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/PortInUseFailureAnalyzer.java b/quick-start/src/main/java/com/marklogic/quickstart/PortInUseFailureAnalyzer.java index 15e0a0cbf4..4e0c496f59 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/PortInUseFailureAnalyzer.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/PortInUseFailureAnalyzer.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/WebSocketConfig.java b/quick-start/src/main/java/com/marklogic/quickstart/WebSocketConfig.java index 5dcf7c692a..bf42f9fcc0 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/WebSocketConfig.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/WebSocketConfig.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/auth/ConnectionAuthenticationFilter.java b/quick-start/src/main/java/com/marklogic/quickstart/auth/ConnectionAuthenticationFilter.java index d86022a751..b0377e7378 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/auth/ConnectionAuthenticationFilter.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/auth/ConnectionAuthenticationFilter.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.auth; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/auth/ConnectionAuthenticationToken.java b/quick-start/src/main/java/com/marklogic/quickstart/auth/ConnectionAuthenticationToken.java index 6c14dffb75..ce6d627b8c 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/auth/ConnectionAuthenticationToken.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/auth/ConnectionAuthenticationToken.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.auth; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/auth/LoginInfo.java b/quick-start/src/main/java/com/marklogic/quickstart/auth/LoginInfo.java index c7d6a1cfc8..13847c0177 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/auth/LoginInfo.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/auth/LoginInfo.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.auth; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/auth/MarkLogicAuthenticationManager.java b/quick-start/src/main/java/com/marklogic/quickstart/auth/MarkLogicAuthenticationManager.java index 12b18f2531..931f26d953 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/auth/MarkLogicAuthenticationManager.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/auth/MarkLogicAuthenticationManager.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.auth; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/auth/RestAuthenticationEntryPoint.java b/quick-start/src/main/java/com/marklogic/quickstart/auth/RestAuthenticationEntryPoint.java index ff5b1e5cc4..a532c3a15f 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/auth/RestAuthenticationEntryPoint.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/auth/RestAuthenticationEntryPoint.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.auth; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/exception/BadRequestException.java b/quick-start/src/main/java/com/marklogic/quickstart/exception/BadRequestException.java index 53b4310da3..2ace53cbc1 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/exception/BadRequestException.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/exception/BadRequestException.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.exception; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/exception/DataHubException.java b/quick-start/src/main/java/com/marklogic/quickstart/exception/DataHubException.java index 8fc6b2db63..e1fb0d8df8 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/exception/DataHubException.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/exception/DataHubException.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.exception; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/exception/NotFoundException.java b/quick-start/src/main/java/com/marklogic/quickstart/exception/NotFoundException.java index 9e9367a03b..23e13d443d 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/exception/NotFoundException.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/exception/NotFoundException.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.exception; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/listeners/DeployUserModulesListener.java b/quick-start/src/main/java/com/marklogic/quickstart/listeners/DeployUserModulesListener.java index 353bfa1c8e..c1e86e27c0 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/listeners/DeployUserModulesListener.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/listeners/DeployUserModulesListener.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.listeners; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/listeners/ValidateListener.java b/quick-start/src/main/java/com/marklogic/quickstart/listeners/ValidateListener.java index 1b17bae8fe..6d15f84109 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/listeners/ValidateListener.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/listeners/ValidateListener.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.listeners; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/model/EnvironmentConfig.java b/quick-start/src/main/java/com/marklogic/quickstart/model/EnvironmentConfig.java index be3fbfa32c..4733128023 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/model/EnvironmentConfig.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/model/EnvironmentConfig.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.model; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/model/FlowModel.java b/quick-start/src/main/java/com/marklogic/quickstart/model/FlowModel.java index 96f8b0d480..fe6a93d51d 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/model/FlowModel.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/model/FlowModel.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.model; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/model/JobExport.java b/quick-start/src/main/java/com/marklogic/quickstart/model/JobExport.java index 11f12f5154..a9a757aab3 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/model/JobExport.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/model/JobExport.java @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.quickstart.model; public class JobExport { diff --git a/quick-start/src/main/java/com/marklogic/quickstart/model/JobQuery.java b/quick-start/src/main/java/com/marklogic/quickstart/model/JobQuery.java index 47d9107a9c..286750a236 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/model/JobQuery.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/model/JobQuery.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.model; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/model/JobStatusMessage.java b/quick-start/src/main/java/com/marklogic/quickstart/model/JobStatusMessage.java index a71946653d..a0d4445505 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/model/JobStatusMessage.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/model/JobStatusMessage.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.model; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/model/PluginModel.java b/quick-start/src/main/java/com/marklogic/quickstart/model/PluginModel.java index 40e327e0c0..1efc97ce32 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/model/PluginModel.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/model/PluginModel.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.model; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/model/Project.java b/quick-start/src/main/java/com/marklogic/quickstart/model/Project.java index 26624330dd..cee025338c 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/model/Project.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/model/Project.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.model; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/model/ProjectInfo.java b/quick-start/src/main/java/com/marklogic/quickstart/model/ProjectInfo.java index 9a70fd2379..891130b1fa 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/model/ProjectInfo.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/model/ProjectInfo.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.model; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/model/SearchPathModel.java b/quick-start/src/main/java/com/marklogic/quickstart/model/SearchPathModel.java index 162e2333c3..d6e3aa9595 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/model/SearchPathModel.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/model/SearchPathModel.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.model; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/model/SearchQuery.java b/quick-start/src/main/java/com/marklogic/quickstart/model/SearchQuery.java index 8e407a113c..c6aad78d99 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/model/SearchQuery.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/model/SearchQuery.java @@ -1,21 +1,22 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.model; -import com.marklogic.hub.DataHub; +import com.marklogic.hub.DatabaseKind; import java.util.List; import java.util.Map; @@ -26,6 +27,6 @@ public class SearchQuery { public boolean entitiesOnly; public long start; public long count; - public DataHub.HubDatabase database; + public String database; public Map> facets; } diff --git a/quick-start/src/main/java/com/marklogic/quickstart/model/StatusMessage.java b/quick-start/src/main/java/com/marklogic/quickstart/model/StatusMessage.java index 6c5a7dc040..eb36faa27f 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/model/StatusMessage.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/model/StatusMessage.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.model; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/model/TraceQuery.java b/quick-start/src/main/java/com/marklogic/quickstart/model/TraceQuery.java index a6daf0dc92..a4df5a1b0d 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/model/TraceQuery.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/model/TraceQuery.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.model; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/model/entity_services/DefinitionType.java b/quick-start/src/main/java/com/marklogic/quickstart/model/entity_services/DefinitionType.java index 22c8f4e5b9..cef6c557ae 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/model/entity_services/DefinitionType.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/model/entity_services/DefinitionType.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.model.entity_services; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/model/entity_services/DefinitionsType.java b/quick-start/src/main/java/com/marklogic/quickstart/model/entity_services/DefinitionsType.java index fe4d0c0aa2..a83e27512a 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/model/entity_services/DefinitionsType.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/model/entity_services/DefinitionsType.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.model.entity_services; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/model/entity_services/EntityModel.java b/quick-start/src/main/java/com/marklogic/quickstart/model/entity_services/EntityModel.java index b08cc86a37..f2c5a3dbef 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/model/entity_services/EntityModel.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/model/entity_services/EntityModel.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.model.entity_services; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/model/entity_services/HubUIData.java b/quick-start/src/main/java/com/marklogic/quickstart/model/entity_services/HubUIData.java index 2f2e913be6..d33c7ce90a 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/model/entity_services/HubUIData.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/model/entity_services/HubUIData.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.model.entity_services; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/model/entity_services/InfoType.java b/quick-start/src/main/java/com/marklogic/quickstart/model/entity_services/InfoType.java index 2dcf8f0d2b..2db64484e9 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/model/entity_services/InfoType.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/model/entity_services/InfoType.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.model.entity_services; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/model/entity_services/ItemType.java b/quick-start/src/main/java/com/marklogic/quickstart/model/entity_services/ItemType.java index cb43f5a524..1df387ba00 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/model/entity_services/ItemType.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/model/entity_services/ItemType.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.model.entity_services; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/model/entity_services/JsonPojo.java b/quick-start/src/main/java/com/marklogic/quickstart/model/entity_services/JsonPojo.java index 30025880d5..9d3fc211e4 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/model/entity_services/JsonPojo.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/model/entity_services/JsonPojo.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.model.entity_services; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/model/entity_services/PropertyType.java b/quick-start/src/main/java/com/marklogic/quickstart/model/entity_services/PropertyType.java index c9bc501a99..237a84ead5 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/model/entity_services/PropertyType.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/model/entity_services/PropertyType.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.model.entity_services; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/service/CancellableTask.java b/quick-start/src/main/java/com/marklogic/quickstart/service/CancellableTask.java index dce95d6574..0ca127c23d 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/service/CancellableTask.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/service/CancellableTask.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.service; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/service/DataHubService.java b/quick-start/src/main/java/com/marklogic/quickstart/service/DataHubService.java index 974f3e2b3f..fa497f257a 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/service/DataHubService.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/service/DataHubService.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.service; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/service/EntityManagerService.java b/quick-start/src/main/java/com/marklogic/quickstart/service/EntityManagerService.java index 73f0e0cc31..f891a13010 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/service/EntityManagerService.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/service/EntityManagerService.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.service; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/service/FileSystemEventListener.java b/quick-start/src/main/java/com/marklogic/quickstart/service/FileSystemEventListener.java index 05acbb9a70..642863b45f 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/service/FileSystemEventListener.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/service/FileSystemEventListener.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.service; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/service/FileSystemWatcherService.java b/quick-start/src/main/java/com/marklogic/quickstart/service/FileSystemWatcherService.java index 128b8d1dfd..e69fbe14ac 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/service/FileSystemWatcherService.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/service/FileSystemWatcherService.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.service; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/service/FlowManagerService.java b/quick-start/src/main/java/com/marklogic/quickstart/service/FlowManagerService.java index fc596b5e3f..8f7b2b73eb 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/service/FlowManagerService.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/service/FlowManagerService.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.service; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/service/HubStatsService.java b/quick-start/src/main/java/com/marklogic/quickstart/service/HubStatsService.java index 161db7d0e6..d7616b78ec 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/service/HubStatsService.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/service/HubStatsService.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.service; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/service/JobService.java b/quick-start/src/main/java/com/marklogic/quickstart/service/JobService.java index aa11f9f6bd..98bdf62835 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/service/JobService.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/service/JobService.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.service; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/service/ProjectManagerService.java b/quick-start/src/main/java/com/marklogic/quickstart/service/ProjectManagerService.java index 30e5cb3e8f..02c378103b 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/service/ProjectManagerService.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/service/ProjectManagerService.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.service; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/service/SearchService.java b/quick-start/src/main/java/com/marklogic/quickstart/service/SearchService.java index 2f572f7a90..305ba0a53d 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/service/SearchService.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/service/SearchService.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.service; @@ -23,7 +24,7 @@ import com.marklogic.client.query.QueryManager; import com.marklogic.client.query.StructuredQueryBuilder; import com.marklogic.client.query.StructuredQueryDefinition; -import com.marklogic.hub.DataHub; +import com.marklogic.hub.DatabaseKind; import com.marklogic.hub.HubConfig; import com.marklogic.quickstart.model.SearchQuery; @@ -51,7 +52,7 @@ public SearchService(HubConfig hubConfig) { public StringHandle search(SearchQuery searchQuery) { QueryManager queryMgr; String dbPrefix; - if (searchQuery.database.equals(DataHub.HubDatabase.STAGING)) { + if (searchQuery.database.equals(DatabaseKind.STAGING)) { queryMgr = stagingQueryMgr; dbPrefix = "staging-"; } @@ -104,9 +105,9 @@ public StringHandle search(SearchQuery searchQuery) { return queryMgr.search(sqd, sh, searchQuery.start); } - public String getDoc(DataHub.HubDatabase database, String docUri) { + public String getDoc(String database, String docUri) { GenericDocumentManager docMgr; - if (database.equals(DataHub.HubDatabase.STAGING)) { + if (database.equalsIgnoreCase(DatabaseKind.getName(DatabaseKind.STAGING))) { docMgr = stagingDocMgr; } else { diff --git a/quick-start/src/main/java/com/marklogic/quickstart/service/SearchableService.java b/quick-start/src/main/java/com/marklogic/quickstart/service/SearchableService.java index 20f7a186c6..b4e832c8df 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/service/SearchableService.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/service/SearchableService.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.service; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/service/TraceService.java b/quick-start/src/main/java/com/marklogic/quickstart/service/TraceService.java index a1913dcf6e..2f3e495259 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/service/TraceService.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/service/TraceService.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.service; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/util/FileUtil.java b/quick-start/src/main/java/com/marklogic/quickstart/util/FileUtil.java index cd0dfc7359..f6357d193d 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/util/FileUtil.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/util/FileUtil.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.util; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/util/MlcpMain.java b/quick-start/src/main/java/com/marklogic/quickstart/util/MlcpMain.java index d3dffcd106..72e58b940a 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/util/MlcpMain.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/util/MlcpMain.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.util; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/web/AppController.java b/quick-start/src/main/java/com/marklogic/quickstart/web/AppController.java index aa4e0f8698..8fbfe4115a 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/web/AppController.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/web/AppController.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.web; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/web/CurrentProjectController.java b/quick-start/src/main/java/com/marklogic/quickstart/web/CurrentProjectController.java index d697bc28a0..9faa513e15 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/web/CurrentProjectController.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/web/CurrentProjectController.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.web; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/web/EntitiesController.java b/quick-start/src/main/java/com/marklogic/quickstart/web/EntitiesController.java index 9529a0a050..4d16fd6b5b 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/web/EntitiesController.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/web/EntitiesController.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.web; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/web/JobsController.java b/quick-start/src/main/java/com/marklogic/quickstart/web/JobsController.java index 7840e67df3..fa1ab15b80 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/web/JobsController.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/web/JobsController.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.web; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/web/ProjectsController.java b/quick-start/src/main/java/com/marklogic/quickstart/web/ProjectsController.java index a1bb723e2b..1f4d973839 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/web/ProjectsController.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/web/ProjectsController.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.web; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/web/SearchController.java b/quick-start/src/main/java/com/marklogic/quickstart/web/SearchController.java index feec573269..e64b6e90c1 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/web/SearchController.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/web/SearchController.java @@ -1,22 +1,22 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.web; import com.fasterxml.jackson.core.JsonProcessingException; -import com.marklogic.hub.DataHub; import com.marklogic.quickstart.EnvironmentAware; import com.marklogic.quickstart.model.SearchQuery; import com.marklogic.quickstart.service.SearchService; @@ -52,7 +52,7 @@ public String search(@RequestBody SearchQuery searchQuery) throws JsonProcessing @RequestMapping(value = "/doc", method = RequestMethod.GET) @ResponseBody - public ResponseEntity getDoc(@RequestParam DataHub.HubDatabase database, @RequestParam String docUri) { + public ResponseEntity getDoc(@RequestParam String database, @RequestParam String docUri) { HttpHeaders headers = new HttpHeaders(); String body = searchService.getDoc(database, docUri); if (body.startsWith("<")) { diff --git a/quick-start/src/main/java/com/marklogic/quickstart/web/SettingsController.java b/quick-start/src/main/java/com/marklogic/quickstart/web/SettingsController.java index 7734bba1ff..212a3d82fd 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/web/SettingsController.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/web/SettingsController.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.web; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/web/TracesController.java b/quick-start/src/main/java/com/marklogic/quickstart/web/TracesController.java index 9395a99687..ea5e922e12 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/web/TracesController.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/web/TracesController.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.web; diff --git a/quick-start/src/main/java/com/marklogic/quickstart/web/UtilController.java b/quick-start/src/main/java/com/marklogic/quickstart/web/UtilController.java index 0d1fc636a0..1a0bce44e6 100644 --- a/quick-start/src/main/java/com/marklogic/quickstart/web/UtilController.java +++ b/quick-start/src/main/java/com/marklogic/quickstart/web/UtilController.java @@ -1,17 +1,18 @@ /* * Copyright 2012-2018 MarkLogic Corporation * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package com.marklogic.quickstart.web; diff --git a/quick-start/src/main/resources/application-dev.properties b/quick-start/src/main/resources/application-dev.properties index 7e3dabe07f..18be77943f 100644 --- a/quick-start/src/main/resources/application-dev.properties +++ b/quick-start/src/main/resources/application-dev.properties @@ -1,3 +1,20 @@ +# +# Copyright 2012-2018 MarkLogic Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# + endpoints.enabled=false endpoints.shutdown.enabled=true management.security.enabled=false diff --git a/quick-start/src/main/resources/application.properties b/quick-start/src/main/resources/application.properties index fe43c5faa5..28154f8ac5 100644 --- a/quick-start/src/main/resources/application.properties +++ b/quick-start/src/main/resources/application.properties @@ -1,3 +1,20 @@ +# +# Copyright 2012-2018 MarkLogic Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# + #Spring embedded tomcat config. Does not apply when war file is deployed on external Tomcat. server.port=${port:8080} server.contextPath=/ diff --git a/quick-start/src/main/resources/logback-spring.xml b/quick-start/src/main/resources/logback-spring.xml index d3fcfdf0be..3998266053 100644 --- a/quick-start/src/main/resources/logback-spring.xml +++ b/quick-start/src/main/resources/logback-spring.xml @@ -1,3 +1,20 @@ + + diff --git a/quick-start/src/test/java/com/marklogic/quickstart/service/EntityManagerServiceTest.java b/quick-start/src/test/java/com/marklogic/quickstart/service/EntityManagerServiceTest.java index 36e3509ccc..81458563b4 100644 --- a/quick-start/src/test/java/com/marklogic/quickstart/service/EntityManagerServiceTest.java +++ b/quick-start/src/test/java/com/marklogic/quickstart/service/EntityManagerServiceTest.java @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.quickstart.service; import com.fasterxml.jackson.databind.JsonNode; diff --git a/quick-start/src/test/java/com/marklogic/quickstart/service/FlowManagerServiceTest.java b/quick-start/src/test/java/com/marklogic/quickstart/service/FlowManagerServiceTest.java index 82dd4ab3d8..9391585501 100644 --- a/quick-start/src/test/java/com/marklogic/quickstart/service/FlowManagerServiceTest.java +++ b/quick-start/src/test/java/com/marklogic/quickstart/service/FlowManagerServiceTest.java @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.quickstart.service; import com.fasterxml.jackson.databind.JsonNode; diff --git a/quick-start/src/test/java/com/marklogic/quickstart/service/JobServiceTest.java b/quick-start/src/test/java/com/marklogic/quickstart/service/JobServiceTest.java index 7a81672be7..7b714c0485 100644 --- a/quick-start/src/test/java/com/marklogic/quickstart/service/JobServiceTest.java +++ b/quick-start/src/test/java/com/marklogic/quickstart/service/JobServiceTest.java @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.quickstart.service; import com.marklogic.client.DatabaseClient; diff --git a/quick-start/src/test/java/com/marklogic/quickstart/service/TraceServiceTest.java b/quick-start/src/test/java/com/marklogic/quickstart/service/TraceServiceTest.java index ef3770b63e..6dedfd441d 100644 --- a/quick-start/src/test/java/com/marklogic/quickstart/service/TraceServiceTest.java +++ b/quick-start/src/test/java/com/marklogic/quickstart/service/TraceServiceTest.java @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.quickstart.service; import com.fasterxml.jackson.databind.JsonNode; diff --git a/quick-start/src/test/java/com/marklogic/quickstart/web/BaseTestController.java b/quick-start/src/test/java/com/marklogic/quickstart/web/BaseTestController.java index 61950941d4..37d80c5f51 100644 --- a/quick-start/src/test/java/com/marklogic/quickstart/web/BaseTestController.java +++ b/quick-start/src/test/java/com/marklogic/quickstart/web/BaseTestController.java @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.quickstart.web; import com.marklogic.hub.DataHub; diff --git a/quick-start/src/test/java/com/marklogic/quickstart/web/EntitiesControllerTest.java b/quick-start/src/test/java/com/marklogic/quickstart/web/EntitiesControllerTest.java index 9b674e6f04..f6073fb40b 100644 --- a/quick-start/src/test/java/com/marklogic/quickstart/web/EntitiesControllerTest.java +++ b/quick-start/src/test/java/com/marklogic/quickstart/web/EntitiesControllerTest.java @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.quickstart.web; import com.fasterxml.jackson.databind.JsonNode; diff --git a/quick-start/src/test/java/com/marklogic/quickstart/web/HubConfigJsonTest.java b/quick-start/src/test/java/com/marklogic/quickstart/web/HubConfigJsonTest.java index 35afe7ab2c..f6fa66eb35 100644 --- a/quick-start/src/test/java/com/marklogic/quickstart/web/HubConfigJsonTest.java +++ b/quick-start/src/test/java/com/marklogic/quickstart/web/HubConfigJsonTest.java @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.quickstart.web; diff --git a/quick-start/src/test/java/com/marklogic/quickstart/web/ProjectsControllerTest.java b/quick-start/src/test/java/com/marklogic/quickstart/web/ProjectsControllerTest.java index 47ff69adb8..5f424d7a30 100644 --- a/quick-start/src/test/java/com/marklogic/quickstart/web/ProjectsControllerTest.java +++ b/quick-start/src/test/java/com/marklogic/quickstart/web/ProjectsControllerTest.java @@ -1,3 +1,20 @@ +/* + * Copyright 2012-2018 MarkLogic Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.marklogic.quickstart.web; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/quick-start/src/test/resources/flow-manager/sjs-harmonize-flow/test flow.properties b/quick-start/src/test/resources/flow-manager/sjs-harmonize-flow/test flow.properties index 1d7ffee9aa..3ce317cc9c 100644 --- a/quick-start/src/test/resources/flow-manager/sjs-harmonize-flow/test flow.properties +++ b/quick-start/src/test/resources/flow-manager/sjs-harmonize-flow/test flow.properties @@ -1,3 +1,20 @@ +# +# Copyright 2012-2018 MarkLogic Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# + # #Thu Jan 04 10:41:46 EST 2018 mainModule=main.sjs From b5e4c9f813df9c5e807c9bd665561545855594aa Mon Sep 17 00:00:00 2001 From: Alexander Ebadirad Date: Fri, 2 Mar 2018 12:02:01 -0700 Subject: [PATCH 22/22] Remove extra todo --- .../src/main/java/com/marklogic/hub/impl/DataHubImpl.java | 1 - 1 file changed, 1 deletion(-) diff --git a/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/DataHubImpl.java b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/DataHubImpl.java index 2a27a29297..7f2ee97bf0 100644 --- a/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/DataHubImpl.java +++ b/marklogic-data-hub/src/main/java/com/marklogic/hub/impl/DataHubImpl.java @@ -201,7 +201,6 @@ private ServerManager getServerManager() { /** * Removes user's modules from the modules db - * TODO: this becomes much simpler when we move code into the server dir */ @Override public void clearUserModules() { ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(DataHub.class.getClassLoader());