This repository has been archived by the owner on Sep 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
97 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/main/java/com/marklogic/appdeployer/command/mimetypes/DeployMimetypesCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.marklogic.appdeployer.command.mimetypes; | ||
|
||
import java.io.File; | ||
|
||
import com.marklogic.appdeployer.command.AbstractResourceCommand; | ||
import com.marklogic.appdeployer.command.CommandContext; | ||
import com.marklogic.appdeployer.command.SortOrderConstants; | ||
import com.marklogic.mgmt.ResourceManager; | ||
import com.marklogic.mgmt.SaveReceipt; | ||
import com.marklogic.mgmt.mimetypes.MimetypeManager; | ||
|
||
public class DeployMimetypesCommand extends AbstractResourceCommand { | ||
|
||
public DeployMimetypesCommand() { | ||
setExecuteSortOrder(SortOrderConstants.DEPLOY_MIMETYPES); | ||
setUndoSortOrder(SortOrderConstants.DELETE_MIMETYPES); | ||
setRestartAfterDelete(true); | ||
} | ||
|
||
@Override | ||
protected File[] getResourceDirs(CommandContext context) { | ||
return new File[] { new File(context.getAppConfig().getConfigDir().getBaseDir(), "mimetypes") }; | ||
} | ||
|
||
@Override | ||
protected ResourceManager getResourceManager(CommandContext context) { | ||
return new MimetypeManager(context.getManageClient()); | ||
} | ||
|
||
/** | ||
* As of ML 8.0-4, any time a mimetype is created or updated, ML must be restarted. | ||
*/ | ||
@Override | ||
protected void afterResourceSaved(ResourceManager mgr, CommandContext context, File resourceFile, | ||
SaveReceipt receipt) { | ||
logger.info("Waiting for restart after saving mimetype"); | ||
context.getAdminManager().waitForRestart(); | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/marklogic/mgmt/mimetypes/MimetypeManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.marklogic.mgmt.mimetypes; | ||
|
||
import com.marklogic.mgmt.AbstractResourceManager; | ||
import com.marklogic.mgmt.ManageClient; | ||
|
||
public class MimetypeManager extends AbstractResourceManager { | ||
|
||
public MimetypeManager(ManageClient client) { | ||
super(client); | ||
} | ||
|
||
@Override | ||
protected String getIdFieldName() { | ||
return "name"; | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
src/test/java/com/marklogic/appdeployer/command/mimetypes/ManageMimetypesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.marklogic.appdeployer.command.mimetypes; | ||
|
||
import com.marklogic.appdeployer.command.AbstractManageResourceTest; | ||
import com.marklogic.appdeployer.command.Command; | ||
import com.marklogic.mgmt.ResourceManager; | ||
import com.marklogic.mgmt.mimetypes.MimetypeManager; | ||
|
||
public class ManageMimetypesTest extends AbstractManageResourceTest { | ||
|
||
@Override | ||
protected ResourceManager newResourceManager() { | ||
return new MimetypeManager(manageClient); | ||
} | ||
|
||
@Override | ||
protected Command newCommand() { | ||
return new DeployMimetypesCommand(); | ||
} | ||
|
||
@Override | ||
protected String[] getResourceNames() { | ||
return new String[] { "text/gradle" }; | ||
} | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
src/test/resources/sample-app/src/main/ml-config/mimetypes/gradle.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "text/gradle", | ||
"extension": [ | ||
"gradle", | ||
"grdle" | ||
], | ||
"format": "text" | ||
} |