-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…-io/MIPs#145 (#1211) Implement notes/content insert image option.
- Loading branch information
Showing
23 changed files
with
1,057 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
238 changes: 215 additions & 23 deletions
238
notes-service/src/main/java/org/exoplatform/wiki/service/impl/NoteServiceImpl.java
Large diffs are not rendered by default.
Oops, something went wrong.
83 changes: 83 additions & 0 deletions
83
...vice/src/main/java/org/exoplatform/wiki/service/plugin/WikiDraftPageAttachmentPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/** | ||
* This file is part of the Meeds project (https://meeds.io/). | ||
* | ||
* Copyright (C) 2020 - 2024 Meeds Association [email protected] | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
package org.exoplatform.wiki.service.plugin; | ||
|
||
import org.exoplatform.commons.exception.ObjectNotFoundException; | ||
import org.exoplatform.services.security.Identity; | ||
import org.exoplatform.social.attachment.AttachmentPlugin; | ||
import org.exoplatform.social.core.manager.IdentityManager; | ||
import org.exoplatform.social.core.space.spi.SpaceService; | ||
import org.exoplatform.wiki.model.DraftPage; | ||
import org.exoplatform.wiki.service.NoteService; | ||
import org.exoplatform.wiki.utils.Utils; | ||
|
||
public class WikiDraftPageAttachmentPlugin extends AttachmentPlugin { | ||
|
||
private final NoteService noteService; | ||
|
||
private final SpaceService spaceService; | ||
|
||
public static final String OBJECT_TYPE = "wikiDraft"; | ||
|
||
public WikiDraftPageAttachmentPlugin(NoteService noteService, SpaceService spaceService, IdentityManager identityManager) { | ||
this.noteService = noteService; | ||
this.spaceService = spaceService; | ||
} | ||
|
||
@Override | ||
public String getObjectType() { | ||
return OBJECT_TYPE; | ||
} | ||
|
||
@Override | ||
public boolean hasAccessPermission(Identity identity, String draftId) { | ||
try { | ||
DraftPage draftPage = noteService.getDraftNoteById(draftId, identity.getUserId()); | ||
return draftPage != null && draftPage.isCanView(); | ||
} catch (Exception e) { | ||
return false; | ||
} | ||
} | ||
|
||
@Override | ||
public boolean hasEditPermission(Identity identity, String draftId) throws ObjectNotFoundException { | ||
try { | ||
DraftPage draftPage = noteService.getDraftNoteById(draftId, identity.getUserId()); | ||
return draftPage != null && draftPage.isCanManage(); | ||
} catch (Exception e) { | ||
return false; | ||
} | ||
} | ||
|
||
@Override | ||
public long getAudienceId(String s) throws ObjectNotFoundException { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public long getSpaceId(String draftId) throws ObjectNotFoundException { | ||
try { | ||
String username = Utils.getCurrentUser(); | ||
DraftPage draftPage = noteService.getDraftNoteById(draftId, username); | ||
return Long.parseLong(spaceService.getSpaceByGroupId(draftPage.getWikiOwner()).getId()); | ||
} catch (Exception exception) { | ||
return 0; | ||
} | ||
} | ||
} |
83 changes: 83 additions & 0 deletions
83
...ce/src/main/java/org/exoplatform/wiki/service/plugin/WikiPageVersionAttachmentPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/** | ||
* This file is part of the Meeds project (https://meeds.io/). | ||
* | ||
* Copyright (C) 2020 - 2024 Meeds Association [email protected] | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
package org.exoplatform.wiki.service.plugin; | ||
|
||
import org.exoplatform.commons.exception.ObjectNotFoundException; | ||
import org.exoplatform.services.security.Identity; | ||
import org.exoplatform.social.attachment.AttachmentPlugin; | ||
import org.exoplatform.social.core.space.spi.SpaceService; | ||
import org.exoplatform.wiki.model.Page; | ||
import org.exoplatform.wiki.model.PageVersion; | ||
import org.exoplatform.wiki.service.NoteService; | ||
|
||
public class WikiPageVersionAttachmentPlugin extends AttachmentPlugin { | ||
|
||
private final NoteService noteService; | ||
|
||
private final SpaceService spaceService; | ||
|
||
public static final String OBJECT_TYPE = "wikiPageVersion"; | ||
|
||
public WikiPageVersionAttachmentPlugin(NoteService noteService, SpaceService spaceService) { | ||
this.noteService = noteService; | ||
this.spaceService = spaceService; | ||
} | ||
|
||
@Override | ||
public String getObjectType() { | ||
return OBJECT_TYPE; | ||
} | ||
|
||
@Override | ||
public boolean hasAccessPermission(Identity identity, String versionId) { | ||
try { | ||
PageVersion pageVersion = noteService.getPageVersionById(Long.parseLong(versionId)); | ||
Page note = noteService.getNoteById(pageVersion.getParent().getId(),identity); | ||
return pageVersion != null && note != null && note.isCanView(); | ||
} catch (Exception e) { | ||
return false; | ||
} | ||
} | ||
|
||
@Override | ||
public boolean hasEditPermission(Identity identity, String versionId) throws ObjectNotFoundException { | ||
try { | ||
PageVersion pageVersion = noteService.getPageVersionById(Long.parseLong(versionId)); | ||
Page note = noteService.getNoteById(pageVersion.getParent().getId(),identity); | ||
return pageVersion != null && note != null && note.isCanManage(); | ||
} catch (Exception e) { | ||
return false; | ||
} | ||
} | ||
|
||
@Override | ||
public long getAudienceId(String s) throws ObjectNotFoundException { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public long getSpaceId(String versionId) throws ObjectNotFoundException { | ||
try { | ||
PageVersion pageVersion = noteService.getPageVersionById(Long.parseLong(versionId)); | ||
return Long.parseLong(spaceService.getSpaceByGroupId(pageVersion.getWikiOwner()).getId()); | ||
} catch (Exception exception) { | ||
return 0; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.