CCM NG/ccm-cms: Several bug fixes and improvments for assets, especially binary assets
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4886 8810af33-2d31-482b-a856-94f89814c4df
parent
ea175fc8ec
commit
01e0e68ac3
|
|
@ -71,6 +71,9 @@
|
||||||
<Logger name="org.libreccm.security.OneTimeAuthTokenCleaner"
|
<Logger name="org.libreccm.security.OneTimeAuthTokenCleaner"
|
||||||
level="debug">
|
level="debug">
|
||||||
</Logger>
|
</Logger>
|
||||||
|
<Logger name="org.libreccm.security.PermissionManager"
|
||||||
|
level="debug">
|
||||||
|
</Logger>
|
||||||
<Logger name="org.libreccm.security.Shiro"
|
<Logger name="org.libreccm.security.Shiro"
|
||||||
level="debug">
|
level="debug">
|
||||||
</Logger>
|
</Logger>
|
||||||
|
|
|
||||||
|
|
@ -340,6 +340,11 @@ public abstract class AbstractAssetForm<T extends Asset>
|
||||||
|
|
||||||
if (selectedAsset.isPresent()) {
|
if (selectedAsset.isPresent()) {
|
||||||
|
|
||||||
|
name.setValue(state,
|
||||||
|
selectedAsset
|
||||||
|
.get()
|
||||||
|
.getDisplayName());
|
||||||
|
|
||||||
title.setValue(state,
|
title.setValue(state,
|
||||||
selectedAsset
|
selectedAsset
|
||||||
.get()
|
.get()
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,6 @@ public class ImageForm extends AbstractBinaryAssetForm<Image> {
|
||||||
//
|
//
|
||||||
// return image;
|
// return image;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateAsset(final Asset asset,
|
protected void updateAsset(final Asset asset,
|
||||||
final FormSectionEvent event)
|
final FormSectionEvent event)
|
||||||
|
|
@ -144,8 +143,18 @@ public class ImageForm extends AbstractBinaryAssetForm<Image> {
|
||||||
|
|
||||||
final Image image = (Image) asset;
|
final Image image = (Image) asset;
|
||||||
|
|
||||||
|
if (height.getValue(state) == null
|
||||||
|
|| ((String) height.getValue(state)).trim().isEmpty()) {
|
||||||
|
image.setHeight(-1);
|
||||||
|
} else {
|
||||||
image.setHeight(Long.parseLong((String) height.getValue(state)));
|
image.setHeight(Long.parseLong((String) height.getValue(state)));
|
||||||
|
}
|
||||||
|
if (width.getValue(state) == null
|
||||||
|
|| ((String) width.getValue(state)).trim().isEmpty()) {
|
||||||
|
image.setWidth(-1);
|
||||||
|
} else {
|
||||||
image.setWidth(Long.parseLong((String) width.getValue(state)));
|
image.setWidth(Long.parseLong((String) width.getValue(state)));
|
||||||
|
}
|
||||||
|
|
||||||
updateData(image, state);
|
updateData(image, state);
|
||||||
}
|
}
|
||||||
|
|
@ -172,5 +181,4 @@ public class ImageForm extends AbstractBinaryAssetForm<Image> {
|
||||||
// protected BinaryAsset createBinaryAsset(final PageState state) {
|
// protected BinaryAsset createBinaryAsset(final PageState state) {
|
||||||
// return new Image();
|
// return new Image();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,12 +69,10 @@ public class BinaryAsset extends Asset implements Serializable {
|
||||||
private LocalizedString description;
|
private LocalizedString description;
|
||||||
|
|
||||||
@Column(name = "FILENAME", length = 512, nullable = false)
|
@Column(name = "FILENAME", length = 512, nullable = false)
|
||||||
@NotEmpty
|
|
||||||
private String fileName;
|
private String fileName;
|
||||||
|
|
||||||
@Column(name = "MIME_TYPE", length = 512, nullable = false)
|
@Column(name = "MIME_TYPE", length = 512, nullable = false)
|
||||||
@Convert(converter = MimeTypeConverter.class)
|
@Convert(converter = MimeTypeConverter.class)
|
||||||
@NotNull
|
|
||||||
private MimeType mimeType;
|
private MimeType mimeType;
|
||||||
|
|
||||||
@Column(name = "ASSET_DATA")
|
@Column(name = "ASSET_DATA")
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,9 @@ public class AssetManager {
|
||||||
asset.getTitle().addValue(locale, title);
|
asset.getTitle().addValue(locale, title);
|
||||||
assetRepo.save(asset);
|
assetRepo.save(asset);
|
||||||
|
|
||||||
categoryManager.addObjectToCategory(asset, folder);
|
categoryManager.addObjectToCategory(asset,
|
||||||
|
folder,
|
||||||
|
CmsConstants.CATEGORIZATION_TYPE_FOLDER);
|
||||||
permissionManager.copyPermissions(folder, asset, true);
|
permissionManager.copyPermissions(folder, asset, true);
|
||||||
|
|
||||||
return asset;
|
return asset;
|
||||||
|
|
|
||||||
|
|
@ -25,16 +25,18 @@ import org.libreccm.categorization.Categorization;
|
||||||
import org.libreccm.categorization.Category;
|
import org.libreccm.categorization.Category;
|
||||||
import org.libreccm.categorization.CategoryManager;
|
import org.libreccm.categorization.CategoryManager;
|
||||||
import org.libreccm.categorization.ObjectNotAssignedToCategoryException;
|
import org.libreccm.categorization.ObjectNotAssignedToCategoryException;
|
||||||
import org.libreccm.core.CcmObject;
|
|
||||||
import org.libreccm.core.CcmObjectRepository;
|
import org.libreccm.core.CcmObjectRepository;
|
||||||
import org.libreccm.core.UnexpectedErrorException;
|
import org.libreccm.core.UnexpectedErrorException;
|
||||||
import org.libreccm.security.AuthorizationRequired;
|
import org.libreccm.security.AuthorizationRequired;
|
||||||
|
import org.libreccm.security.Permission;
|
||||||
import org.libreccm.security.PermissionChecker;
|
import org.libreccm.security.PermissionChecker;
|
||||||
|
import org.libreccm.security.PermissionManager;
|
||||||
import org.libreccm.security.RequiresPrivilege;
|
import org.libreccm.security.RequiresPrivilege;
|
||||||
import org.libreccm.security.Role;
|
import org.libreccm.security.Role;
|
||||||
import org.libreccm.security.Shiro;
|
import org.libreccm.security.Shiro;
|
||||||
import org.libreccm.security.User;
|
import org.libreccm.security.User;
|
||||||
import org.librecms.contentsection.privileges.AssetPrivileges;
|
import org.librecms.contentsection.privileges.AssetPrivileges;
|
||||||
|
import org.librecms.contentsection.rs.Assets;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -62,25 +64,28 @@ public class AssetRepository
|
||||||
.getLogger(AssetRepository.class);
|
.getLogger(AssetRepository.class);
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private Shiro shiro;
|
private AssetManager assetManager;
|
||||||
|
|
||||||
@Inject
|
|
||||||
private PermissionChecker permissionChecker;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private EntityManager entityManager;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private CcmObjectRepository ccmObjectRepo;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private CategoryManager categoryManager;
|
private CategoryManager categoryManager;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private CcmObjectRepository ccmObjectRepo;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private EntityManager entityManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private FolderRepository folderRepo;
|
private FolderRepository folderRepo;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private AssetManager assetManager;
|
private PermissionChecker permissionChecker;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private PermissionManager permissionManager;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private Shiro shiro;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long getEntityId(final Asset asset) {
|
public Long getEntityId(final Asset asset) {
|
||||||
|
|
@ -193,6 +198,13 @@ public class AssetRepository
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final List<Permission> permissions = asset.getPermissions();
|
||||||
|
for (final Permission permission : permissions) {
|
||||||
|
permissionManager.revokePrivilege(permission.getGrantedPrivilege(),
|
||||||
|
permission.getGrantee(),
|
||||||
|
asset);
|
||||||
|
}
|
||||||
|
|
||||||
ccmObjectRepo.delete(asset);
|
ccmObjectRepo.delete(asset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -542,7 +554,7 @@ public class AssetRepository
|
||||||
Asset.class)
|
Asset.class)
|
||||||
.setParameter("folder", folder)
|
.setParameter("folder", folder)
|
||||||
.setParameter("name", name);
|
.setParameter("name", name);
|
||||||
// setAuthorizationParameters(query);
|
setAuthorizationParameters(query);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return Optional.of(query.getSingleResult());
|
return Optional.of(query.getSingleResult());
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
ALTER TABLE ccm_cms.binary_assets ALTER COLUMN mime_type SET NULL;
|
||||||
|
ALTER TABLE ccm_cms.binary_assets ALTER COLUMN filename SET NULL;
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
ALTER TABLE ccm_cms.binary_assets ALTER COLUMN mime_type DROP NOT NULL;
|
||||||
|
ALTER TABLE ccm_cms.binary_assets ALTER COLUMN filename DROP NOT NULL;
|
||||||
|
|
@ -385,3 +385,4 @@ image_step.description=Attach images
|
||||||
related_info_step_description=Add related information
|
related_info_step_description=Add related information
|
||||||
cms.ui.authoring.file_upload.auto_detect=(Auto-Detect)
|
cms.ui.authoring.file_upload.auto_detect=(Auto-Detect)
|
||||||
cms.ui.upload_new_content=Upload new content
|
cms.ui.upload_new_content=Upload new content
|
||||||
|
cms.ui.asset.name=Name
|
||||||
|
|
|
||||||
|
|
@ -382,3 +382,4 @@ image_step.description=Bilder hinzuf\u00fcgen
|
||||||
related_info_step_description=Weiterf\u00fchrende Informationen hinzuf\u00fcgen
|
related_info_step_description=Weiterf\u00fchrende Informationen hinzuf\u00fcgen
|
||||||
cms.ui.authoring.file_upload.auto_detect=(Automatisch erkennen)
|
cms.ui.authoring.file_upload.auto_detect=(Automatisch erkennen)
|
||||||
cms.ui.upload_new_content=Neuen Inhalt hochladen
|
cms.ui.upload_new_content=Neuen Inhalt hochladen
|
||||||
|
cms.ui.asset.name=Name
|
||||||
|
|
|
||||||
|
|
@ -341,3 +341,4 @@ image_step.description=Attach images
|
||||||
related_info_step_description=Add related information
|
related_info_step_description=Add related information
|
||||||
cms.ui.authoring.file_upload.auto_detect=(Auto-Detect)
|
cms.ui.authoring.file_upload.auto_detect=(Auto-Detect)
|
||||||
cms.ui.upload_new_content=Upload new content
|
cms.ui.upload_new_content=Upload new content
|
||||||
|
cms.ui.asset.name=Name
|
||||||
|
|
|
||||||
|
|
@ -170,8 +170,8 @@ create schema CCM_CORE;
|
||||||
|
|
||||||
create table CCM_CMS.BINARY_ASSETS (
|
create table CCM_CMS.BINARY_ASSETS (
|
||||||
ASSET_DATA blob,
|
ASSET_DATA blob,
|
||||||
FILENAME varchar(512) not null,
|
FILENAME varchar(512),
|
||||||
MIME_TYPE varchar(512) not null,
|
MIME_TYPE varchar(512),
|
||||||
DATA_SIZE bigint,
|
DATA_SIZE bigint,
|
||||||
OBJECT_ID bigint not null,
|
OBJECT_ID bigint not null,
|
||||||
primary key (OBJECT_ID)
|
primary key (OBJECT_ID)
|
||||||
|
|
|
||||||
|
|
@ -170,8 +170,8 @@ create schema CCM_CORE;
|
||||||
|
|
||||||
create table CCM_CMS.BINARY_ASSETS (
|
create table CCM_CMS.BINARY_ASSETS (
|
||||||
ASSET_DATA oid,
|
ASSET_DATA oid,
|
||||||
FILENAME varchar(512) not null,
|
FILENAME varchar(512),
|
||||||
MIME_TYPE varchar(512) not null,
|
MIME_TYPE varchar(512),
|
||||||
DATA_SIZE int8,
|
DATA_SIZE int8,
|
||||||
OBJECT_ID int8 not null,
|
OBJECT_ID int8 not null,
|
||||||
primary key (OBJECT_ID)
|
primary key (OBJECT_ID)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue