Skip to content

Commit

Permalink
Merge pull request #213 from marklogic/dino/197-Refactor-to-autodeploy
Browse files Browse the repository at this point in the history
fixed #197
  • Loading branch information
divino committed May 3, 2016
2 parents be718b2 + aa7e2eb commit cd693b3
Show file tree
Hide file tree
Showing 12 changed files with 379 additions and 368 deletions.
77 changes: 39 additions & 38 deletions marklogic-data-hub/src/main/java/com/marklogic/hub/DataHub.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,42 +69,43 @@

public class DataHub {

static final private Logger LOGGER = LoggerFactory.getLogger(DataHub.class);

private ManageConfig config;
private ManageClient client;

private File assetInstallTimeFile = new File("./assetInstallTime.properties");
private HubConfig hubConfig;

public DataHub(HubConfig hubConfig) {
init(hubConfig);
}

public DataHub(String host, String username, String password) {
hubConfig = new HubConfig();
hubConfig.host = host;
hubConfig.adminUsername = username;
hubConfig.adminPassword = password;
init(hubConfig);
}

private void init(HubConfig hubConfig) {
this.hubConfig = hubConfig;
config = new ManageConfig(hubConfig.host, 8002, hubConfig.adminUsername, hubConfig.adminPassword);
client = new ManageClient(config);
}

public void setAssetInstallTimeFile(File assetInstallTimeFile) {
this.assetInstallTimeFile = assetInstallTimeFile;
}

/**
* Determines if the data hub is installed in MarkLogic
* @return true if installed, false otherwise
*/
public boolean isInstalled() {
ServerManager sm = new ServerManager(client);
static final private Logger LOGGER = LoggerFactory.getLogger(DataHub.class);

private ManageConfig config;
private ManageClient client;

private File assetInstallTimeFile = new File("./assetInstallTime.properties");
private HubConfig hubConfig;

public DataHub(HubConfig hubConfig) {
init(hubConfig);
}

public DataHub(String host, String username, String password) {
hubConfig = new HubConfig();
hubConfig.host = host;
hubConfig.adminUsername = username;
hubConfig.adminPassword = password;
init(hubConfig);
}

private void init(HubConfig hubConfig) {
this.hubConfig = hubConfig;
config = new ManageConfig(hubConfig.host, 8002, hubConfig.adminUsername, hubConfig.adminPassword);
client = new ManageClient(config);
}

public void setAssetInstallTimeFile(File assetInstallTimeFile) {
this.assetInstallTimeFile = assetInstallTimeFile;
}

/**
* Determines if the data hub is installed in MarkLogic
*
* @return true if installed, false otherwise
*/
public boolean isInstalled() {
ServerManager sm = new ServerManager(client);
DatabaseManager dm = new DatabaseManager(client);

ResourcesFragment srf = sm.getAsXml();
Expand Down Expand Up @@ -152,9 +153,9 @@ public boolean isInstalled() {
boolean forestsOk = (stagingForestsExist && finalForestsExist && tracingForestsExist);

return (appserversOk && dbsOk && forestsOk);
}
}

/**
/**
* Validates the MarkLogic server to ensure compatibility with the hub
* @throws ServerValidationException if the server is not compatible
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ public EntityModel createEntity(String entityName, String entityFilePath, SyncSt
EntityModel entityModel = new EntityModel();
entityModel.setEntityName(entityName);
//this will be updated after traversing its modules
entityModel.setSynched(this.entitiesInServer.containsKey(entityName));

FlowModelFactory flowModelFactory = new FlowModelFactory(
this.entitiesInServer.get(entityName), entityName);
Expand Down Expand Up @@ -97,11 +96,9 @@ private void setEntityModules(EntityModel entityModel, String entityFilePath,
for (String folderName : folderNames) {
if (folderName.equalsIgnoreCase(RestModelFactory.REST_FOLDER_NAME)) {
restModel = restModelFactory.createRest(modulesParentDirectory, syncStatusService);
entityModel.setSynched(entityModel.isSynched() && restModel.isSynched());
} else {
FlowModel flowModel = flowModelFactory.createFlow(modulesParentDirectory,
folderName, flowType, syncStatusService);
entityModel.setSynched(entityModel.isSynched() && flowModel.isSynched());
flows.add(flowModel);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public FlowModel createNewFlow(File userPluginDirPath, String flowName,
FlowModel flowModel = new FlowModel();
flowModel.setEntityName(entityName);
flowModel.setFlowName(flowName);
flowModel.setSynched(false);

Scaffolding.createFlow(entityName, flowName, flowType, pluginFormat,
dataFormat, userPluginDirPath);
Expand Down Expand Up @@ -72,7 +71,6 @@ public FlowModel createFlow(String parentDirPath, String flowName,
&& flowType.equals(flow.getType())) {
synched = syncStatusService.isDirectorySynched(absolutePath);
}
flowModel.setSynched(synched);
return flowModel;
}
}
27 changes: 0 additions & 27 deletions quick-start/src/main/java/com/marklogic/hub/model/EntityModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ public class EntityModel {
private String entityName;
private List<FlowModel> inputFlows;
private List<FlowModel> harmonizeFlows;
private boolean isSynched;
private RestModel inputRest;
private RestModel harmonizeRest;

Expand Down Expand Up @@ -61,30 +60,6 @@ public void setHarmonizeFlows(List<FlowModel> harmonizeFlows) {
this.harmonizeFlows = harmonizeFlows;
}

public boolean isSynched() {
return isSynched;
}

public void setSynched(boolean isSynched) {
this.isSynched = isSynched;
}

public void setInputFlowsSynched(boolean synched) {
if (inputFlows != null) {
for (FlowModel model : inputFlows) {
model.setSynched(synched);
}
}
}

public void setHarmonizeFlowsSynched(boolean synched) {
if (harmonizeFlows != null) {
for (FlowModel model : harmonizeFlows) {
model.setSynched(synched);
}
}
}

public RestModel getInputRest() {
return inputRest;
}
Expand All @@ -107,8 +82,6 @@ public String toString() {
sb.append("{");
sb.append("entityName=");
sb.append(entityName);
sb.append("isSynched=");
sb.append(isSynched);
sb.append("}");

return sb.toString();
Expand Down
13 changes: 1 addition & 12 deletions quick-start/src/main/java/com/marklogic/hub/model/FlowModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ public class FlowModel {

private String entityName;
private String flowName;
private boolean isSynched;
private TreeData treeData;

public String getEntityName() {
Expand All @@ -24,14 +23,6 @@ public void setFlowName(String flowName) {
this.flowName = flowName;
}

public boolean isSynched() {
return isSynched;
}

public void setSynched(boolean isSynched) {
this.isSynched = isSynched;
}

public TreeData getTreeData() {
return treeData;
}
Expand All @@ -46,10 +37,8 @@ public String toString() {
sb.append("{");
sb.append("entityName=");
sb.append(entityName);
sb.append("flowName=");
sb.append(" flowName=");
sb.append(flowName);
sb.append("isSynched=");
sb.append(isSynched);
sb.append("}");

return sb.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ public void install() throws DataHubException {
}

public void installUserModules() throws DataHubException {
LOGGER.debug("installUserModules");
DataHub dataHub = getDataHub();
try {
LOGGER.debug("pluginDir:" + environmentConfiguration.getUserPluginDir());
dataHub.installUserModules(environmentConfiguration.getUserPluginDir());
} catch(Throwable e) {
throw new DataHubException(e.getMessage(), e);
Expand Down
Loading

0 comments on commit cd693b3

Please sign in to comment.