attempting to use correct ids vs paths for windows w/ burnettk

This commit is contained in:
jasquat 2023-01-09 17:18:54 -05:00
parent 30e5f44bf8
commit 4fd716f10f
1 changed files with 10 additions and 8 deletions

View File

@ -39,6 +39,11 @@ class ProcessModelService(FileSystemService):
GROUP_SCHEMA = ProcessGroupSchema()
PROCESS_MODEL_SCHEMA = ProcessModelInfoSchema()
@classmethod
def path_to_id(cls, path: str) -> str:
"""Replace the os path separator for the standard id separator."""
return path.replace(os.sep, '/')
@classmethod
def is_group(cls, path: str) -> bool:
"""Is_group."""
@ -228,7 +233,8 @@ class ProcessModelService(FileSystemService):
user = UserService.current_user()
new_process_model_list = []
for process_model in process_models:
uri = f"/v1.0/process-instances/{process_model.id.replace('/', ':')}"
modified_process_model_id = ProcessModelInfo.modify_process_identifier_for_path_param(process_model.id)
uri = f"/v1.0/process-instances/{modified_process_model_id}"
has_permission = AuthorizationService.user_has_permission(
user=user, permission="create", target_uri=uri
)
@ -410,7 +416,7 @@ class ProcessModelService(FileSystemService):
data = json.load(cat_json)
# we don't store `id` in the json files, so we add it back in here
relative_path = os.path.relpath(dir_path, FileSystemService.root_path())
data["id"] = relative_path
data["id"] = cls.path_to_id(relative_path)
process_group = ProcessGroup(**data)
if process_group is None:
raise ApiError(
@ -421,7 +427,7 @@ class ProcessModelService(FileSystemService):
),
)
else:
process_group_id = dir_path.replace(FileSystemService.root_path(), "")
process_group_id = cls.path_to_id(dir_path.replace(FileSystemService.root_path(), ""))
process_group = ProcessGroup(
id="",
display_name=process_group_id,
@ -474,11 +480,7 @@ class ProcessModelService(FileSystemService):
data.pop("process_group_id")
# we don't save `id` in the json file, so we add it back in here.
relative_path = os.path.relpath(path, FileSystemService.root_path())
# even on windows, use forward slashes for ids
relative_path = relative_path.replace("\\", "/")
data["id"] = relative_path
data["id"] = cls.path_to_id(relative_path)
process_model_info = ProcessModelInfo(**data)
if process_model_info is None:
raise ApiError(