Skip to content

#32152 trying a defensive map to avoid to save the file assets contai… #32153

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions dotCMS/src/main/java/com/dotmarketing/beans/Permission.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.dotmarketing.beans;

import com.dotmarketing.portlets.containers.model.FileAssetContainer;
import com.dotmarketing.portlets.contentlet.model.Contentlet;
import com.dotmarketing.portlets.templates.model.FileAssetTemplate;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonSetter;
Expand Down Expand Up @@ -173,6 +176,13 @@ public void setType ( String type ) {
*/
type = IHTMLPage.class.getCanonicalName();
}

if ( type != null && (type.equals( FileAssetContainer.class.getCanonicalName())
|| type.equals( FileAssetTemplate.class.getCanonicalName() )) ) {
// file asset container/template are contentlets, so we have to map to contentlet
type = Contentlet.class.getCanonicalName();
}

this.type = type;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.dotmarketing.exception.DotSecurityException;
import com.dotmarketing.portlets.contentlet.model.Contentlet;
import com.dotmarketing.portlets.fileassets.business.FileAsset;
import com.dotmarketing.portlets.templates.model.Template;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.vavr.control.Try;

Expand Down Expand Up @@ -97,6 +98,12 @@ public void setContainerStructuresAssets(List<FileAsset> containerStructuresAsse
this.containerStructuresAssets = containerStructuresAssets.stream().map(f->f.getInode()).filter(Objects::nonNull).collect(Collectors.toList());
}

// we override it, in order to do the permissionable behind a contentlet object
@Override
public String getPermissionType() {
return Contentlet.class.getCanonicalName();
}

public void addMetaData(final String key, final Object value) {

this.metaDataMap.put (key, value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ public SystemContainer() {
super.setMaxContentlets(DEFAULT_MAX_CONTENTS);
}

// we override it, in order to do the permissionable behind a container object
@Override
public String getPermissionType() {
return Container.class.getCanonicalName();
}

@Override
public void setIdentifier(String identifier) {
Logger.debug(this, () -> "System Container ID cannot be overridden.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.dotmarketing.business.Versionable;
import com.dotmarketing.exception.DotDataException;
import com.dotmarketing.exception.DotSecurityException;
import com.dotmarketing.portlets.contentlet.model.Contentlet;
import com.dotmarketing.portlets.fileassets.business.FileAsset;
import com.dotmarketing.portlets.templates.business.FileAssetTemplateUtil;
import com.fasterxml.jackson.annotation.JsonIgnore;
Expand Down Expand Up @@ -41,6 +42,12 @@ public FileAssetTemplate() {
this.metaDataMap = new HashMap<>();
}

// we override it, in order to do the permissionable behind a contentlet object
@Override
public String getPermissionType() {
return Contentlet.class.getCanonicalName();
}

@JsonIgnore
public FileAsset getBodyAsset() {
return body;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.dotmarketing.beans.Host;
import com.dotmarketing.business.APILocator;
import com.dotmarketing.business.Theme;
import com.dotmarketing.portlets.containers.model.Container;
import com.dotmarketing.util.Logger;

import java.util.Date;
Expand Down Expand Up @@ -39,6 +40,12 @@ public SystemTemplate() {
super.setDrawed(true);
}

// we override it, in order to do the permissionable behind a template object
@Override
public String getPermissionType() {
return Template.class.getCanonicalName();
}

@Override
public void setIdentifier(String identifier) {
Logger.debug(this, () -> "System Template ID cannot be overridden.");
Expand Down
4 changes: 2 additions & 2 deletions dotcms-postman/src/main/resources/postman/GraphQLTests.json
Original file line number Diff line number Diff line change
Expand Up @@ -2155,7 +2155,7 @@
" pm.expect(container1.parentPermissionable.hostName, 'FAILED:[container1.parentPermissionable.hostName]').equal(\"demo.dotcms.com\");",
" pm.expect(container1.path, 'FAILED:[container1.path]').equal(\"//demo.dotcms.com/application/containers/default/\");",
" pm.expect(container1.permissionId, 'FAILED:[container1.permissionId]').equal(\"69b3d24d-7e80-4be6-b04a-d352d16493ee\");",
" pm.expect(container1.permissionType, 'FAILED:[container1.permissionType]').equal(\"com.dotmarketing.portlets.containers.model.FileAssetContainer\");",
" pm.expect(container1.permissionType, 'FAILED:[container1.permissionType]').equal(\"com.dotmarketing.portlets.contentlet.model.Contentlet\");",
" pm.expect(container1.postLoop, 'FAILED:[container1.postLoop]').equal(\"#dotParse(\\\"//demo.dotcms.com/application/containers/default/postloop.vtl\\\")\");",
" pm.expect(container1.preLoop, 'FAILED:[container1.preLoop]').equal(\"#dotParse(\\\"//demo.dotcms.com/application/containers/default/preloop.vtl\\\")\");",
" pm.expect(container1.showOnMenu, 'FAILED:[container1.showOnMenu]').equal(false);",
Expand Down Expand Up @@ -12403,4 +12403,4 @@
}
}
]
}
}
Loading