aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sdc-distribution-ci/src/main/java/org/openecomp/test/AdvanceCallBack.java4
-rw-r--r--sdc-distribution-client/src/main/java/org/openecomp/sdc/api/results/IDistributionClientDownloadResult.java18
-rw-r--r--sdc-distribution-client/src/main/java/org/openecomp/sdc/impl/DistributionClientDownloadResultImpl.java10
-rw-r--r--sdc-distribution-client/src/main/java/org/openecomp/sdc/impl/mock/DistributionClientDownloadResultStubImpl.java6
-rw-r--r--sdc-distribution-client/src/test/java/org/openecomp/sdc/impl/DistributionClientDownloadResultTest.java55
5 files changed, 91 insertions, 2 deletions
diff --git a/sdc-distribution-ci/src/main/java/org/openecomp/test/AdvanceCallBack.java b/sdc-distribution-ci/src/main/java/org/openecomp/test/AdvanceCallBack.java
index d5ef6cd..f78a38b 100644
--- a/sdc-distribution-ci/src/main/java/org/openecomp/test/AdvanceCallBack.java
+++ b/sdc-distribution-ci/src/main/java/org/openecomp/test/AdvanceCallBack.java
@@ -58,8 +58,8 @@ public class AdvanceCallBack extends SimpleCallback{
protected void saveArtifactPayloadToDisk(IDistributionClientDownloadResult downloadResult) {
System.out.println("################ Downloaded Artifact Payload Start ################");
- String fileName = downloadResult.getArtifactName().replaceAll("attachment; filename=","");
- saveFile(downloadResult.getArtifactPayload(), fileName.replaceAll("\"", ""));
+ String fileName = downloadResult.getArtifactFilename();
+ saveFile(downloadResult.getArtifactPayload(), fileName);
System.out.println("################ Downloaded Artifact Payload End ################");
}
diff --git a/sdc-distribution-client/src/main/java/org/openecomp/sdc/api/results/IDistributionClientDownloadResult.java b/sdc-distribution-client/src/main/java/org/openecomp/sdc/api/results/IDistributionClientDownloadResult.java
index e101636..6030b9e 100644
--- a/sdc-distribution-client/src/main/java/org/openecomp/sdc/api/results/IDistributionClientDownloadResult.java
+++ b/sdc-distribution-client/src/main/java/org/openecomp/sdc/api/results/IDistributionClientDownloadResult.java
@@ -22,6 +22,24 @@ package org.openecomp.sdc.api.results;
/**Distribution Client Result For Download API*/
public interface IDistributionClientDownloadResult extends IDistributionClientResult{
+
+
byte[] getArtifactPayload();
+
+
+ /**
+ * @deprecated
+ * This method is deprecated and will be removed in 1710.
+ * It returns <b>attachment; filename="filename"</b> rather than <b>"filename"</b>.
+ * Please use {@link #getArtifactFilename()}.
+ * @return
+ */
+ @Deprecated
String getArtifactName();
+
+ /**
+ * Returns the filename of the artifact.
+ * @return the filename of the artifact.
+ */
+ String getArtifactFilename();
}
diff --git a/sdc-distribution-client/src/main/java/org/openecomp/sdc/impl/DistributionClientDownloadResultImpl.java b/sdc-distribution-client/src/main/java/org/openecomp/sdc/impl/DistributionClientDownloadResultImpl.java
index b69cb24..0fa918a 100644
--- a/sdc-distribution-client/src/main/java/org/openecomp/sdc/impl/DistributionClientDownloadResultImpl.java
+++ b/sdc-distribution-client/src/main/java/org/openecomp/sdc/impl/DistributionClientDownloadResultImpl.java
@@ -61,4 +61,14 @@ public class DistributionClientDownloadResultImpl extends DistributionClientRes
this.artifactName = artifactName;
}
+ @Override
+ public String getArtifactFilename() {
+ //Fix of bug 292443 in TDP
+ if (artifactName == null || !artifactName.matches("attachment;\\s*filename=\".*?\"")){
+ return artifactName;
+ }
+ String fileName = "filename=\"";
+ return artifactName.substring(artifactName.indexOf(fileName)+fileName.length(), artifactName.lastIndexOf("\""));
+ }
+
}
diff --git a/sdc-distribution-client/src/main/java/org/openecomp/sdc/impl/mock/DistributionClientDownloadResultStubImpl.java b/sdc-distribution-client/src/main/java/org/openecomp/sdc/impl/mock/DistributionClientDownloadResultStubImpl.java
index d69451a..aff0d0e 100644
--- a/sdc-distribution-client/src/main/java/org/openecomp/sdc/impl/mock/DistributionClientDownloadResultStubImpl.java
+++ b/sdc-distribution-client/src/main/java/org/openecomp/sdc/impl/mock/DistributionClientDownloadResultStubImpl.java
@@ -69,4 +69,10 @@ public class DistributionClientDownloadResultStubImpl extends DistributionClient
return "MackArtifactName";
}
+ @Override
+ public String getArtifactFilename() {
+ // TODO Auto-generated method stub
+ return "MackArtifactName";
+ }
+
}
diff --git a/sdc-distribution-client/src/test/java/org/openecomp/sdc/impl/DistributionClientDownloadResultTest.java b/sdc-distribution-client/src/test/java/org/openecomp/sdc/impl/DistributionClientDownloadResultTest.java
new file mode 100644
index 0000000..8f8fca2
--- /dev/null
+++ b/sdc-distribution-client/src/test/java/org/openecomp/sdc/impl/DistributionClientDownloadResultTest.java
@@ -0,0 +1,55 @@
+package org.openecomp.sdc.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openecomp.sdc.utils.DistributionActionResultEnum;
+
+
+public class DistributionClientDownloadResultTest {
+
+ public static DistributionClientDownloadResultImpl distributionClientDownloadResult;
+
+ @BeforeClass
+ public static void init(){
+ distributionClientDownloadResult = new DistributionClientDownloadResultImpl(DistributionActionResultEnum.SUCCESS, "");
+ }
+
+ @Test
+ public void testNonHeaderFilename(){
+ distributionClientDownloadResult.setArtifactName("service-BkPerformanceSrvs-csar.csar");
+ assertEquals("service-BkPerformanceSrvs-csar.csar", distributionClientDownloadResult.getArtifactFilename());
+ }
+
+ @Test
+ public void testNullFilename(){
+ distributionClientDownloadResult.setArtifactName(null);
+ assertNull(distributionClientDownloadResult.getArtifactFilename());
+ }
+
+ @Test
+ public void testFilenameFromHeaderNoSpace(){
+ distributionClientDownloadResult.setArtifactName("attachment;filename=\"service-BkPerformanceSrvs-csar.csar\"");
+ assertEquals("service-BkPerformanceSrvs-csar.csar", distributionClientDownloadResult.getArtifactFilename());
+ }
+
+ @Test
+ public void testFilenameFromHeaderOneSpace(){
+ distributionClientDownloadResult.setArtifactName("attachment; filename=\"service-BkPerformanceSrvs-csar.csar\"");
+ assertEquals("service-BkPerformanceSrvs-csar.csar", distributionClientDownloadResult.getArtifactFilename());
+ }
+
+ @Test
+ public void testFilenameFromHeaderManySpaces(){
+ distributionClientDownloadResult.setArtifactName("attachment; filename=\"service-BkPerformanceSrvs-csar.csar\"");
+ assertEquals("service-BkPerformanceSrvs-csar.csar", distributionClientDownloadResult.getArtifactFilename());
+ }
+
+ @Test
+ public void testFilenameEmpty(){
+ distributionClientDownloadResult.setArtifactName("attachment; filename=\"\"");
+ assertEquals("", distributionClientDownloadResult.getArtifactFilename());
+ }
+}