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-94f89814c4dfpull/2/head
parent
d6f519c156
commit
7f3e020c31
|
|
@ -71,6 +71,9 @@
|
|||
<Logger name="org.libreccm.security.OneTimeAuthTokenCleaner"
|
||||
level="debug">
|
||||
</Logger>
|
||||
<Logger name="org.libreccm.security.PermissionManager"
|
||||
level="debug">
|
||||
</Logger>
|
||||
<Logger name="org.libreccm.security.Shiro"
|
||||
level="debug">
|
||||
</Logger>
|
||||
|
|
|
|||
|
|
@ -340,6 +340,11 @@ public abstract class AbstractAssetForm<T extends Asset>
|
|||
|
||||
if (selectedAsset.isPresent()) {
|
||||
|
||||
name.setValue(state,
|
||||
selectedAsset
|
||||
.get()
|
||||
.getDisplayName());
|
||||
|
||||
title.setValue(state,
|
||||
selectedAsset
|
||||
.get()
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ public class ImageForm extends AbstractBinaryAssetForm<Image> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Class<Image> getAssetClass() {
|
||||
return Image.class;
|
||||
|
|
@ -132,7 +132,6 @@ public class ImageForm extends AbstractBinaryAssetForm<Image> {
|
|||
//
|
||||
// return image;
|
||||
// }
|
||||
|
||||
@Override
|
||||
protected void updateAsset(final Asset asset,
|
||||
final FormSectionEvent event)
|
||||
|
|
@ -144,8 +143,18 @@ public class ImageForm extends AbstractBinaryAssetForm<Image> {
|
|||
|
||||
final Image image = (Image) asset;
|
||||
|
||||
image.setHeight(Long.parseLong((String) height.getValue(state)));
|
||||
image.setWidth(Long.parseLong((String) width.getValue(state)));
|
||||
if (height.getValue(state) == null
|
||||
|| ((String) height.getValue(state)).trim().isEmpty()) {
|
||||
image.setHeight(-1);
|
||||
} else {
|
||||
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)));
|
||||
}
|
||||
|
||||
updateData(image, state);
|
||||
}
|
||||
|
|
@ -172,5 +181,4 @@ public class ImageForm extends AbstractBinaryAssetForm<Image> {
|
|||
// protected BinaryAsset createBinaryAsset(final PageState state) {
|
||||
// return new Image();
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,12 +69,10 @@ public class BinaryAsset extends Asset implements Serializable {
|
|||
private LocalizedString description;
|
||||
|
||||
@Column(name = "FILENAME", length = 512, nullable = false)
|
||||
@NotEmpty
|
||||
private String fileName;
|
||||
|
||||
@Column(name = "MIME_TYPE", length = 512, nullable = false)
|
||||
@Convert(converter = MimeTypeConverter.class)
|
||||
@NotNull
|
||||
private MimeType mimeType;
|
||||
|
||||
@Column(name = "ASSET_DATA")
|
||||
|
|
|
|||
|
|
@ -117,7 +117,9 @@ public class AssetManager {
|
|||
asset.getTitle().addValue(locale, title);
|
||||
assetRepo.save(asset);
|
||||
|
||||
categoryManager.addObjectToCategory(asset, folder);
|
||||
categoryManager.addObjectToCategory(asset,
|
||||
folder,
|
||||
CmsConstants.CATEGORIZATION_TYPE_FOLDER);
|
||||
permissionManager.copyPermissions(folder, asset, true);
|
||||
|
||||
return asset;
|
||||
|
|
|
|||
|
|
@ -25,16 +25,18 @@ import org.libreccm.categorization.Categorization;
|
|||
import org.libreccm.categorization.Category;
|
||||
import org.libreccm.categorization.CategoryManager;
|
||||
import org.libreccm.categorization.ObjectNotAssignedToCategoryException;
|
||||
import org.libreccm.core.CcmObject;
|
||||
import org.libreccm.core.CcmObjectRepository;
|
||||
import org.libreccm.core.UnexpectedErrorException;
|
||||
import org.libreccm.security.AuthorizationRequired;
|
||||
import org.libreccm.security.Permission;
|
||||
import org.libreccm.security.PermissionChecker;
|
||||
import org.libreccm.security.PermissionManager;
|
||||
import org.libreccm.security.RequiresPrivilege;
|
||||
import org.libreccm.security.Role;
|
||||
import org.libreccm.security.Shiro;
|
||||
import org.libreccm.security.User;
|
||||
import org.librecms.contentsection.privileges.AssetPrivileges;
|
||||
import org.librecms.contentsection.rs.Assets;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
|
@ -62,25 +64,28 @@ public class AssetRepository
|
|||
.getLogger(AssetRepository.class);
|
||||
|
||||
@Inject
|
||||
private Shiro shiro;
|
||||
|
||||
@Inject
|
||||
private PermissionChecker permissionChecker;
|
||||
|
||||
@Inject
|
||||
private EntityManager entityManager;
|
||||
|
||||
@Inject
|
||||
private CcmObjectRepository ccmObjectRepo;
|
||||
private AssetManager assetManager;
|
||||
|
||||
@Inject
|
||||
private CategoryManager categoryManager;
|
||||
|
||||
@Inject
|
||||
private CcmObjectRepository ccmObjectRepo;
|
||||
|
||||
@Inject
|
||||
private EntityManager entityManager;
|
||||
|
||||
@Inject
|
||||
private FolderRepository folderRepo;
|
||||
|
||||
@Inject
|
||||
private AssetManager assetManager;
|
||||
private PermissionChecker permissionChecker;
|
||||
|
||||
@Inject
|
||||
private PermissionManager permissionManager;
|
||||
|
||||
@Inject
|
||||
private Shiro shiro;
|
||||
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -542,7 +554,7 @@ public class AssetRepository
|
|||
Asset.class)
|
||||
.setParameter("folder", folder)
|
||||
.setParameter("name", name);
|
||||
// setAuthorizationParameters(query);
|
||||
setAuthorizationParameters(query);
|
||||
|
||||
try {
|
||||
return Optional.of(query.getSingleResult());
|
||||
|
|
@ -594,7 +606,7 @@ public class AssetRepository
|
|||
}
|
||||
|
||||
if (folder.isPresent()) {
|
||||
LOGGER.debug("transaction is active? {}",
|
||||
LOGGER.debug("transaction is active? {}",
|
||||
entityManager.isJoinedToTransaction());
|
||||
LOGGER.debug("Folder for path {} found...", path);
|
||||
// LOGGER.debug("Assets in the folder:");
|
||||
|
|
|
|||
|
|
@ -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
|
||||
cms.ui.authoring.file_upload.auto_detect=(Auto-Detect)
|
||||
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
|
||||
cms.ui.authoring.file_upload.auto_detect=(Automatisch erkennen)
|
||||
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
|
||||
cms.ui.authoring.file_upload.auto_detect=(Auto-Detect)
|
||||
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 (
|
||||
ASSET_DATA blob,
|
||||
FILENAME varchar(512) not null,
|
||||
MIME_TYPE varchar(512) not null,
|
||||
FILENAME varchar(512),
|
||||
MIME_TYPE varchar(512),
|
||||
DATA_SIZE bigint,
|
||||
OBJECT_ID bigint not null,
|
||||
primary key (OBJECT_ID)
|
||||
|
|
|
|||
|
|
@ -170,8 +170,8 @@ create schema CCM_CORE;
|
|||
|
||||
create table CCM_CMS.BINARY_ASSETS (
|
||||
ASSET_DATA oid,
|
||||
FILENAME varchar(512) not null,
|
||||
MIME_TYPE varchar(512) not null,
|
||||
FILENAME varchar(512),
|
||||
MIME_TYPE varchar(512),
|
||||
DATA_SIZE int8,
|
||||
OBJECT_ID int8 not null,
|
||||
primary key (OBJECT_ID)
|
||||
|
|
|
|||
Loading…
Reference in New Issue