Commit 54f8b301 authored by Elias Englmeier's avatar Elias Englmeier
Browse files

title pic and additional pics are now deleted properly

parent 2607536a
......@@ -145,6 +145,13 @@ public class IdeasLocalServiceImpl extends IdeasLocalServiceBaseImpl {
public void addTitlePictureToExistingIdea(long ideasId, long pictureId, String pictureRef){
try {
Ideas i = IdeasUtil.findByPrimaryKey(ideasId);
try {
DLAppLocalServiceUtil.deleteFileEntry(i.getTitleFileRef());
} catch (PortalException e) {
//Case no pic to delete so just continue.
}
i.setTitleImgRef(pictureRef);
i.setTitleFileRef(pictureId);
i.persist();
......@@ -159,6 +166,15 @@ public class IdeasLocalServiceImpl extends IdeasLocalServiceBaseImpl {
Ideas i = IdeasUtil.findByPrimaryKey(ideasId);
//Case override
if(i.getAdditionalPictureRefs().split(",").length >= 2){
try {
//Try deleting any exisiting pictures. This is currently limited to exaclty two pictures as requested by UniKassel.
DLAppLocalServiceUtil.deleteFileEntry(Long.parseLong(i.getAdditionalPictureRefs().split(",")[0]));
DLAppLocalServiceUtil.deleteFileEntry(Long.parseLong(i.getAdditionalPictureRefs().split(",")[1]));
} catch (PortalException e) {
//Case no pic to delete so just continue.
}
i.setAdditionalPictureRefs("");
i.setAdditionalPictures("");
i.persist();
......@@ -271,6 +287,13 @@ public class IdeasLocalServiceImpl extends IdeasLocalServiceBaseImpl {
LayoutFriendlyURLLocalServiceUtil.deleteLayoutFriendlyURL(l);
}
}
//TODO also delete all additional pics
if(idea.getAdditionalPictureRefs().split(",").length > 1){
DLAppLocalServiceUtil.deleteFileEntry(Long.parseLong(idea.getAdditionalPictureRefs().split(",")[0]));
DLAppLocalServiceUtil.deleteFileEntry(Long.parseLong(idea.getAdditionalPictureRefs().split(",")[1]));
}else if(idea.getAdditionalPictureRefs() != null && !idea.getAdditionalPictureRefs().equals("")){
DLAppLocalServiceUtil.deleteFileEntry(Long.parseLong(idea.getAdditionalPictureRefs().split(",")[0]));
}
//delete title pic file
if(idea.getTitleFileRef() > 0)
DLAppLocalServiceUtil.deleteFileEntry(idea.getTitleFileRef());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment