Kanagaraj M has uploaded a new change for review.
Change subject: engine: fix gluster hook conten-type detection
......................................................................
engine: fix gluster hook conten-type detection
The hook will be considered as human readable('TEXT')
if mime-type has 'text' in type part. And the sub-type part will be ignored.
Modified the GlusterHookContentQuery to check server hook's content
type if serverId is provided.
Change-Id: I191d8f233c965c6b34a652fa07b2c60ef5ee6194
Bug-Url: https://bugzilla.redhat.com/973091
Signed-off-by: Kanagaraj M <[email protected]>
---
M
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GetGlusterHookContentQuery.java
M
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterHookContentType.java
M
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterHookEntity.java
M
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/GlusterHooksListReturnForXmlRpc.java
4 files changed, 32 insertions(+), 20 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/08/15708/1
diff --git
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GetGlusterHookContentQuery.java
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GetGlusterHookContentQuery.java
index 0cbdb15..64dfa2a 100644
---
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GetGlusterHookContentQuery.java
+++
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GetGlusterHookContentQuery.java
@@ -4,6 +4,7 @@
import org.apache.commons.codec.binary.StringUtils;
import
org.ovirt.engine.core.common.businessentities.gluster.GlusterHookContentType;
import org.ovirt.engine.core.common.businessentities.gluster.GlusterHookEntity;
+import org.ovirt.engine.core.common.businessentities.gluster.GlusterServerHook;
import
org.ovirt.engine.core.common.queries.gluster.GlusterHookContentQueryParameters;
import org.ovirt.engine.core.common.vdscommands.VDSCommandType;
import org.ovirt.engine.core.common.vdscommands.VDSReturnValue;
@@ -23,20 +24,26 @@
GlusterHookEntity hook =
getGlusterHookDao().getById(getParameters().getGlusterHookId());
String content = "";
- if (hook.getContentType().equals(GlusterHookContentType.BINARY)) {
- getQueryReturnValue().setReturnValue(content);
- return;
- }
if (getParameters().getGlusterServerId() == null) {
- content =
getGlusterHookDao().getGlusterHookContent(getParameters().getGlusterHookId());
- } else {
- VDSReturnValue returnValue =
- runVdsCommand(VDSCommandType.GetGlusterHookContent,
- new
GlusterHookVDSParameters(getParameters().getGlusterServerId(),
- hook.getGlusterCommand(),
- hook.getStage(),
- hook.getName()));
- content = (String) returnValue.getReturnValue();
+ if (hook.getContentType().equals(GlusterHookContentType.TEXT)) {
+ content =
getGlusterHookDao().getGlusterHookContent(getParameters().getGlusterHookId());
+ }
+ }
+ else {
+ GlusterServerHook serverHook =
+ getGlusterHookDao().getGlusterServerHook(hook.getId(),
getParameters().getGlusterServerId());
+
+ if (serverHook != null && serverHook.getContentType() ==
GlusterHookContentType.TEXT) {
+ VDSReturnValue returnValue =
+ runVdsCommand(VDSCommandType.GetGlusterHookContent,
+ new
GlusterHookVDSParameters(getParameters().getGlusterServerId(),
+ hook.getGlusterCommand(),
+ hook.getStage(),
+ hook.getName()));
+ if (returnValue.getSucceeded()) {
+ content = (String) returnValue.getReturnValue();
+ }
+ }
}
content = StringUtils.newStringUtf8(Base64.decodeBase64(content));
diff --git
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterHookContentType.java
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterHookContentType.java
index 4159fd2..8e9fe00 100644
---
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterHookContentType.java
+++
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterHookContentType.java
@@ -14,6 +14,14 @@
/**
* Hook Binary Content Type
*/
- BINARY
+ BINARY;
+ public static GlusterHookContentType fromMimeType(String contentType) {
+ if (contentType != null &&
contentType.toLowerCase().startsWith("text/")) {
+ return GlusterHookContentType.TEXT;
+ }
+ else {
+ return GlusterHookContentType.BINARY;
+ }
+ }
}
diff --git
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterHookEntity.java
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterHookEntity.java
index 00a191c..4ca18a8 100644
---
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterHookEntity.java
+++
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterHookEntity.java
@@ -113,11 +113,7 @@
public void setContentType(String contentType) {
if (contentType != null) {
- if (contentType.toLowerCase().contains("binary")) {
- this.contentType = GlusterHookContentType.BINARY;
- } else {
- this.contentType = GlusterHookContentType.TEXT;
- }
+ this.contentType =
GlusterHookContentType.fromMimeType(contentType);
}
}
diff --git
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/GlusterHooksListReturnForXmlRpc.java
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/GlusterHooksListReturnForXmlRpc.java
index 11641f0..869420f 100644
---
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/GlusterHooksListReturnForXmlRpc.java
+++
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/GlusterHooksListReturnForXmlRpc.java
@@ -4,6 +4,7 @@
import java.util.List;
import java.util.Map;
+import
org.ovirt.engine.core.common.businessentities.gluster.GlusterHookContentType;
import org.ovirt.engine.core.common.businessentities.gluster.GlusterHookEntity;
import org.ovirt.engine.core.vdsbroker.irsbroker.StatusReturnForXmlRpc;
@@ -43,7 +44,7 @@
hook.setGlusterCommand(map.get(COMMAND).toString());
hook.setStage(map.get(LEVEL).toString());
hook.setChecksum(map.get(CHECKSUM).toString());
- hook.setContentType(map.get(CONTENT_TYPE).toString());
+
hook.setContentType(GlusterHookContentType.fromMimeType(map.get(CONTENT_TYPE).toString()));
hook.setStatus(map.get(HOOK_STATUS).toString());
return hook;
}
--
To view, visit http://gerrit.ovirt.org/15708
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I191d8f233c965c6b34a652fa07b2c60ef5ee6194
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Kanagaraj M <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches