Skip to content

Commit

Permalink
[Fixes #12657] Refactor supported types
Browse files Browse the repository at this point in the history
  • Loading branch information
mattiagiupponi committed Oct 17, 2024
1 parent e253dda commit 9a46a38
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 10 deletions.
9 changes: 0 additions & 9 deletions geonode/upload/handlers/common/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from geonode.upload.handlers.utils import UploadSourcesEnum
from geonode.upload.models import ResourceHandlerInfo
from geonode.upload.handlers.xml.serializer import MetadataFileSerializer
from geonode.upload.utils import ImporterRequestAction as ira
from geonode.upload.orchestrator import orchestrator
from django.shortcuts import get_object_or_404
from geonode.layers.models import Dataset
Expand All @@ -35,14 +34,6 @@ class MetadataFileHandler(BaseHandler):
It must provide the task_lists required to comple the upload
"""

TASKS = {
ira.RESOURCE_METADATA_UPLOAD.value: ("start_import", "geonode.upload.import_resource"),
ira.ROLLBACK.value: (
"start_rollback",
"geonode.upload.rollback",
),
}

@staticmethod
def can_handle(_data) -> bool:
"""
Expand Down
4 changes: 4 additions & 0 deletions geonode/upload/handlers/remote/tiles3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@

class RemoteTiles3DResourceHandler(BaseRemoteResourceHandler, Tiles3DFileHandler):

@property
def supported_file_extension_config(self):
return {}

@staticmethod
def has_serializer(data) -> bool:
if "url" in data and "3dtiles" in data.get("type", "").lower():
Expand Down
6 changes: 6 additions & 0 deletions geonode/upload/handlers/shapefile/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ class ShapeFileHandler(BaseVectorFileHandler):
"start_rollback",
"geonode.upload.rollback",
),
ira.REPLACE.value: (
"start_import",
"geonode.upload.import_resource",
"geonode.upload.publish_resource",
"geonode.upload.create_geonode_resource",
),
}

@property
Expand Down
9 changes: 9 additions & 0 deletions geonode/upload/handlers/sld/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from geonode.upload.handlers.common.metadata import MetadataFileHandler
from geonode.upload.handlers.sld.exceptions import InvalidSldException
from owslib.etree import etree as dlxml
from geonode.upload.utils import ImporterRequestAction as ira

logger = logging.getLogger("importer")

Expand All @@ -32,6 +33,14 @@ class SLDFileHandler(MetadataFileHandler):
It must provide the task_lists required to comple the upload
"""

TASKS = {
ira.RESOURCE_SLD_UPLOAD.value: ("start_import", "geonode.upload.import_resource"),
ira.ROLLBACK.value: (
"start_rollback",
"geonode.upload.rollback",
),
}

@property
def supported_file_extension_config(self):
return {
Expand Down
8 changes: 8 additions & 0 deletions geonode/upload/handlers/xml/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from geonode.upload.handlers.common.metadata import MetadataFileHandler
from geonode.upload.handlers.xml.exceptions import InvalidXmlException
from owslib.etree import etree as dlxml
from geonode.upload.utils import ImporterRequestAction as ira

logger = logging.getLogger("importer")

Expand All @@ -32,6 +33,13 @@ class XMLFileHandler(MetadataFileHandler):
It must provide the task_lists required to comple the upload
"""

TASKS = {
ira.RESOURCE_METADATA_UPLOAD.value: ("start_import", "geonode.upload.import_resource"),
ira.ROLLBACK.value: (
"start_rollback",
"geonode.upload.rollback",
),
}
@property
def supported_file_extension_config(self):
return {
Expand Down
1 change: 1 addition & 0 deletions geonode/upload/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def get_max_upload_parallelism_limit(slug):
class ImporterRequestAction(enum.Enum):
ROLLBACK = _("rollback")
RESOURCE_METADATA_UPLOAD = _("resource_metadata_upload")
RESOURCE_SLD_UPLOAD = _("resource_sld_upload")
REPLACE = _("replace")


Expand Down
2 changes: 1 addition & 1 deletion geonode/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1727,7 +1727,7 @@ def get_supported_datasets_file_types():
"required_ext": ["zip"],
"optional_ext": ["xml", "sld"],
},
"action": ["upload"],
"action": ["upload", "replace"],
"type": "archive",
}
]
Expand Down

0 comments on commit 9a46a38

Please sign in to comment.