Skip to content

Commit

Permalink
[Fix_#3569] Refining uriToPath usage
Browse files Browse the repository at this point in the history
  • Loading branch information
fjtirado committed Jul 11, 2024
1 parent 41d5ee2 commit dcead23
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,5 @@ protected static String trimScheme(String uri, String scheme) {
return str;
}

protected static String removeSlash(String str) {
while (str.startsWith("/")) {
str = str.substring(1);
}
return str;
}

protected abstract byte[] loadURI();
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ static String uriToPath(String uri) {
return removeSlash(trimScheme(uri, URIContentLoaderType.CLASSPATH.scheme()));
}

private static String removeSlash(String str) {
while (str.startsWith("/")) {
str = str.substring(1);
}
return str;
}

@Override
public URIContentLoaderType type() {
return URIContentLoaderType.CLASSPATH;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@ public static String readString(URIContentLoader loader) {
return new String(readAllBytes(loader));
}

public static String getFileName(String uri) {
URIContentLoaderType type = URIContentLoaderType.from(uri);
String path = type.uriToPath(uri);
return type.lastPart(path);
}

public static String readString(Builder builder) {
return readString(builder.build());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.util.Optional;
import java.util.Set;

import org.kie.kogito.serverless.workflow.io.URIContentLoaderFactory;
import org.kie.kogito.serverless.workflow.io.URIContentLoaderType;
import org.kie.kogito.serverless.workflow.parser.ParserContext;

import io.serverlessworkflow.api.Workflow;
Expand All @@ -33,7 +33,8 @@ public class FileNameWorkflowOperationIdFactory extends AbstractWorkflowOperatio

@Override
public String getFileName(Workflow workflow, FunctionDefinition function, Optional<ParserContext> context, String uri, String operation, String service) {
return URIContentLoaderFactory.getFileName(uri);
URIContentLoaderType type = URIContentLoaderType.from(uri);
return type.lastPart(type.uriToPath(uri));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class URIWorkflowOperationIdFactory extends AbstractWorkflowOperationIdFa

@Override
public String getFileName(Workflow workflow, FunctionDefinition function, Optional<ParserContext> context, String uri, String operation, String service) {
return URIContentLoaderType.from(uri).uriToPath(uri).toString();
return URIContentLoaderType.from(uri).uriToPath(uri);
}

@Override
Expand Down

0 comments on commit dcead23

Please sign in to comment.