Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit fbc4c6e

Browse files
committed
#75 Finish mimetypes
1 parent 8c4a23e commit fbc4c6e

File tree

8 files changed

+97
-3
lines changed

8 files changed

+97
-3
lines changed

CHANGELOG.mdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## 2.0rc3 - TBD
44

55
* [#74](https://github.com/rjrudin/ml-app-deployer/issues/74) New command for verifying that MarkLogic version is at least 8
6+
* [#75](https://github.com/rjrudin/ml-app-deployer/issues/75) Added mimetypes support
67

78
## 2.0rc2 - 2016-01-03
89

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ if (project.hasProperty("myBintrayUser")) {
5959
licenses = ['Apache-2.0']
6060
vcsUrl = 'https://github.com/rjrudin/' + project.name + '.git'
6161
version {
62-
name = "2.0rc2"
62+
name = "2.0rc3"
6363
released = new Date()
6464
}
6565
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
group=com.marklogic
22
publishUrl=file:../gh-pages-marklogic-java/releases
33
javadocsDir=../gh-pages-marklogic-java/javadocs
4-
version=2.0rc2
4+
version=2.0rc3
55

66

77
# Old CHANGELOG

src/main/java/com/marklogic/appdeployer/command/SortOrderConstants.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ public abstract class SortOrderConstants {
1212
public static Integer DEPLOY_CERTIFICATE_AUTHORITIES = 60;
1313
public static Integer DEPLOY_EXTERNAL_SECURITY = 70;
1414
public static Integer DEPLOY_PROTECTED_COLLECTIONS = 80;
15-
15+
public static Integer DEPLOY_MIMETYPES = 90;
16+
1617
public static Integer DEPLOY_TRIGGERS_DATABASE = 100;
1718
public static Integer DEPLOY_SCHEMAS_DATABASE = 100;
1819
public static Integer DEPLOY_CONTENT_DATABASES = 120;
@@ -53,6 +54,8 @@ public abstract class SortOrderConstants {
5354
// Undo constants
5455
public static Integer DELETE_GROUPS = 10000;
5556

57+
public static Integer DELETE_MIMETYPES = 9500;
58+
5659
public static Integer DELETE_USERS = 9000;
5760
public static Integer DELETE_CERTIFICATE_TEMPLATES = 9010;
5861
public static Integer DELETE_CERTIFICATE_AUTHORITIES = 9020;
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.marklogic.appdeployer.command.mimetypes;
2+
3+
import java.io.File;
4+
5+
import com.marklogic.appdeployer.command.AbstractResourceCommand;
6+
import com.marklogic.appdeployer.command.CommandContext;
7+
import com.marklogic.appdeployer.command.SortOrderConstants;
8+
import com.marklogic.mgmt.ResourceManager;
9+
import com.marklogic.mgmt.SaveReceipt;
10+
import com.marklogic.mgmt.mimetypes.MimetypeManager;
11+
12+
public class DeployMimetypesCommand extends AbstractResourceCommand {
13+
14+
public DeployMimetypesCommand() {
15+
setExecuteSortOrder(SortOrderConstants.DEPLOY_MIMETYPES);
16+
setUndoSortOrder(SortOrderConstants.DELETE_MIMETYPES);
17+
setRestartAfterDelete(true);
18+
}
19+
20+
@Override
21+
protected File[] getResourceDirs(CommandContext context) {
22+
return new File[] { new File(context.getAppConfig().getConfigDir().getBaseDir(), "mimetypes") };
23+
}
24+
25+
@Override
26+
protected ResourceManager getResourceManager(CommandContext context) {
27+
return new MimetypeManager(context.getManageClient());
28+
}
29+
30+
/**
31+
* As of ML 8.0-4, any time a mimetype is created or updated, ML must be restarted.
32+
*/
33+
@Override
34+
protected void afterResourceSaved(ResourceManager mgr, CommandContext context, File resourceFile,
35+
SaveReceipt receipt) {
36+
logger.info("Waiting for restart after saving mimetype");
37+
context.getAdminManager().waitForRestart();
38+
}
39+
40+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.marklogic.mgmt.mimetypes;
2+
3+
import com.marklogic.mgmt.AbstractResourceManager;
4+
import com.marklogic.mgmt.ManageClient;
5+
6+
public class MimetypeManager extends AbstractResourceManager {
7+
8+
public MimetypeManager(ManageClient client) {
9+
super(client);
10+
}
11+
12+
@Override
13+
protected String getIdFieldName() {
14+
return "name";
15+
}
16+
17+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.marklogic.appdeployer.command.mimetypes;
2+
3+
import com.marklogic.appdeployer.command.AbstractManageResourceTest;
4+
import com.marklogic.appdeployer.command.Command;
5+
import com.marklogic.mgmt.ResourceManager;
6+
import com.marklogic.mgmt.mimetypes.MimetypeManager;
7+
8+
public class ManageMimetypesTest extends AbstractManageResourceTest {
9+
10+
@Override
11+
protected ResourceManager newResourceManager() {
12+
return new MimetypeManager(manageClient);
13+
}
14+
15+
@Override
16+
protected Command newCommand() {
17+
return new DeployMimetypesCommand();
18+
}
19+
20+
@Override
21+
protected String[] getResourceNames() {
22+
return new String[] { "text/gradle" };
23+
}
24+
25+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "text/gradle",
3+
"extension": [
4+
"gradle",
5+
"grdle"
6+
],
7+
"format": "text"
8+
}

0 commit comments

Comments
 (0)