Skip to content

Commit

Permalink
feat: Implement Notes/Content insert image option - EXO-74754 - Meeds…
Browse files Browse the repository at this point in the history
  • Loading branch information
sofyenne committed Nov 27, 2024
1 parent 8e311e5 commit 1a82a5b
Show file tree
Hide file tree
Showing 17 changed files with 285 additions and 345 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@
import io.meeds.notes.rest.model.FeaturedImageEntity;
import io.meeds.notes.rest.model.PageEntity;
import io.meeds.notes.rest.model.PagePropertiesEntity;
import org.apache.commons.lang3.StringUtils;
import org.exoplatform.wiki.model.DraftPage;
import org.exoplatform.wiki.model.Page;
import org.exoplatform.wiki.service.plugin.WikiDraftPageAttachmentPlugin;
import org.exoplatform.wiki.service.plugin.WikiPageAttachmentPlugin;

public class EntityBuilder {

Expand Down Expand Up @@ -104,6 +107,11 @@ public static DraftPage toDraftPage(DraftPageEntity draftPageEntity) {
draftPage.setTargetPageId(draftPageEntity.getTargetPageId());
draftPage.setNewPage(draftPageEntity.isNewPage());
draftPage.setProperties(toNotePageProperties(draftPageEntity.getProperties()));
if (StringUtils.isNotEmpty(draftPageEntity.getTargetPageId())) {
draftPage.setAttachmentObjectType(WikiPageAttachmentPlugin.OBJECT_TYPE);
} else {
draftPage.setAttachmentObjectType(WikiDraftPageAttachmentPlugin.OBJECT_TYPE);
}
return draftPage;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ public class JPADataStorage implements DataStorage {
public static final String WIKI_TYPE_DRAFT = "draft";

public static final String WIKI_FILES_NAMESPACE_NAME = "wiki";
public static final String WIKI_FILES_NAMESPACE_DESCRIPTION = "wiki application files";

private WikiDAO wikiDAO;
private PageDAO pageDAO;
Expand Down Expand Up @@ -1591,13 +1590,13 @@ public PageVersion getPageVersionById(long versionId) {
return EntityConverter.convertPageVersionEntityToPageVersion(pageVersionDAO.find(versionId));
}

@Override
public PageVersion updatePageVersionContent(long versionId, String content) {
PageVersionEntity pageVersionEntity = pageVersionDAO.find(versionId);
pageVersionEntity.setContent(content);
pageVersionEntity.setUpdatedDate(new Date(System.currentTimeMillis()));
return EntityConverter.convertPageVersionEntityToPageVersion(pageVersionDAO.update(pageVersionEntity));
}
@Override
public Page updatePageContent(Page page, String content) {
PageEntity pageTobeUpdated = fetchPageEntity(page);
pageTobeUpdated.setContent(content);
pageTobeUpdated.setUpdatedDate(new Date(System.currentTimeMillis()));
return convertPageEntityToPage(pageDAO.update(pageTobeUpdated));
}

@Override
public DraftPage updateDraftContent(long draftId, String content) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import io.meeds.notes.model.NotePageProperties;
import io.meeds.notes.rest.model.PagePropertiesEntity;
import org.exoplatform.social.metadata.model.MetadataItem;
import org.exoplatform.wiki.service.BreadcrumbData;

Expand Down Expand Up @@ -107,6 +106,8 @@ public class Page {

private NotePageProperties properties;

private String attachmentObjectType;

public Page(String name) {
this.name = name;
}
Expand All @@ -121,4 +122,8 @@ public boolean isDraftPage() {
return false;
}

public String getAttachmentObjectType() {
return attachmentObjectType != null ? attachmentObjectType : "wikiPage";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -320,13 +320,13 @@ public default List<Attachment> getAttachmentsOfPage(Page page, boolean loadCont
PageVersion getPageVersionById(long versionId);

/**
* Updates page version content by its given id
* Updates page content by its given id
*
* @param versionId page version id
* @param page page to be updated
* @param content page version content
* @return {@link PageVersion}
* @return {@link Page}
*/
PageVersion updatePageVersionContent(long versionId, String content) throws WikiException;
Page updatePageContent(Page page, String content) throws WikiException;

/**
* Updates draft page content by its given id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,18 +465,6 @@ List<BreadcrumbData> getBreadCrumb(String noteType,
*/
void createVersionOfNote(Page note, String userName) throws WikiException;

/**
* Creates a version of a note. This method only tag the current note data as
* a new version, it does not update the note data
*
* @param note The note
* @param objectType The object type to link to the page version's content images
* @param draftId The ID of the latest draft, used as the source ID to move content images to the new version
* @param userName The author name
* @throws WikiException if an error occured
*/
void createVersionOfNote(Page note, String userName, String objectType, String draftId) throws WikiException;

/**
* Restores a version of a note
*
Expand Down Expand Up @@ -603,6 +591,7 @@ DraftPage createDraftForExistPage(DraftPage draftNoteToSave,
String revision,
long currentTimeMillis,
String username) throws WikiException;

/**
* Creates a draft for a new page
*
Expand Down
Loading

0 comments on commit 1a82a5b

Please sign in to comment.