Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
EricWittmann committed Apr 11, 2014
1 parent 5fc0674 commit 9372eaf
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
Expand Up @@ -34,6 +34,21 @@
*/
public class ArtifactType {

/**
* Returns true if the given artifact type is valid. It must be alphanumeric only.
* @param artifactType the artifact type
* @return true if valid
*/
public static final boolean isValid(String artifactType) {
for (int i = 0; i < artifactType.length(); i++) {
char c = artifactType.charAt(i);
if (!(Character.isLetter(c) || Character.isDigit(c))) {
return false;
}
}
return true;
}

public static final ArtifactType Document() {
return new ArtifactType(ArtifactTypeEnum.Document, "application/octet-stream"); //$NON-NLS-1$
}
Expand Down Expand Up @@ -383,10 +398,20 @@ public String toString() {
.getType(), getMimeType());
}

/**
* Sets the extended type.
* @param extendedType
*/
public void setExtendedType(String extendedType) {
if (!isValid(extendedType)) {
throw new RuntimeException(Messages.i18n.format("ArtifactType.InvalidExtendedType", extendedType));
}
this.extendedType = extendedType;
}

/**
* Gets the extended artifact type.
*/
public String getExtendedType() {
return extendedType;
}
Expand Down
Expand Up @@ -30,4 +30,5 @@ XPATH_ARGS_EXPECTED=Expected function arguments.
XPATH_UNTERMINATED_ARG_LIST=Unterminated argument list.
XPATH_TOK_MISSING_QUOTE=No matching closing quote was found.
INVALID_ONTOLOGY_ID=The ontology ID was invalid: {0}
INVALID_CLASS_ID=An ontology class ID [{0}] was invalid.
INVALID_CLASS_ID=An ontology class ID [{0}] was invalid.
ArtifactType.InvalidExtendedType=Invalid extended artifact type: {0}
Expand Up @@ -34,20 +34,19 @@ public class AbstractShellCommandReaderTest {
*/
@Test
public void filterLine() {
String line="maven:deploy ${dtgov-workflow-jar} ${dt-workflows-groupId}:1.2.1-SNAPSHOT KieJarArchive";
Map<String, String> properties=new HashMap<String, String>();
String line = "maven:deploy ${dtgov-workflow-jar} ${dt-workflows-groupId}:1.2.1-SNAPSHOT KieJarArchive";
Map<String, String> properties = new HashMap<String, String>();
properties.put("dtgov-workflow-jar", "/home/test/dtgov-workflows.jar");
properties.put("dt-workflows-groupId", "org.overlord.dtgov:dtgov-workflows");
String filtered = AbstractShellCommandReader.filterLine(line, properties);
Assert.assertTrue(!filtered.contains("${"));
// Tested the filter by Map of properties
Assert.assertEquals("maven:deploy /home/test/dtgov-workflows.jar org.overlord.dtgov:dtgov-workflows:1.2.1-SNAPSHOT KieJarArchive", filtered);

line = "maven:deploy ${dtgov-workflow-jar} ${dt-workflows-groupId}:1.2.1-SNAPSHOT KieJarArchive";
properties.clear();
System.setProperty("dtgov-workflow-jar", "/home/test/dtgov-workflows.jar");
System.setProperty("dt-workflows-groupId", "org.overlord.dtgov:dtgov-workflows");
filtered = AbstractShellCommandReader.filterLine(line, properties);
Assert.assertTrue(!filtered.contains("${"));
Assert.assertEquals("maven:deploy /home/test/dtgov-workflows.jar org.overlord.dtgov:dtgov-workflows:1.2.1-SNAPSHOT KieJarArchive", filtered);
}

}
Expand Up @@ -114,7 +114,7 @@
"import-dialog.cancel" : "Cancel",
"import-dialog.change" : "Change",
"import-dialog.dialog.import.message" : "Choose a file to upload (may be a simple file or an S-RAMP package).",
"import-dialog.dialog.import.message-2" : " Choose the artifact type (optional - only specify for custom artifact types - if ommitted, the server will do its best to guess the type). ",
"import-dialog.dialog.import.message-2" : " Choose a custom (alphanumerical) artifact type. OPTIONAL: only specify for custom artifact types - if ommitted, the server will do its best to guess the type. ",
"import-dialog.dialog.import.title" : "Import Artifact(s)",
"import-dialog.import" : "Import",
"import-dialog.remove" : "Remove",
Expand Down

0 comments on commit 9372eaf

Please sign in to comment.