CCM NG: ContentItemManager bug fixes for copy method
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4298 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
d8afacc16c
commit
02064601f8
|
|
@ -151,8 +151,7 @@ public class ContentItemManager {
|
||||||
*
|
*
|
||||||
* @param <T> The type of the content item.
|
* @param <T> The type of the content item.
|
||||||
* @param name The name (URL stub) of the new content item.
|
* @param name The name (URL stub) of the new content item.
|
||||||
* @param section The content section in which the item is
|
* @param section The content section in which the item is generated.
|
||||||
* generated.
|
|
||||||
* @param folder The folder in which in the item is stored.
|
* @param folder The folder in which in the item is stored.
|
||||||
* @param workflowTemplate The template for the workflow to apply to the new
|
* @param workflowTemplate The template for the workflow to apply to the new
|
||||||
* item.
|
* item.
|
||||||
|
|
@ -264,9 +263,8 @@ public class ContentItemManager {
|
||||||
*
|
*
|
||||||
* @param item The item to copy.
|
* @param item The item to copy.
|
||||||
* @param targetFolder The folder in which the copy is created. If the
|
* @param targetFolder The folder in which the copy is created. If the
|
||||||
* target folder is the same folder as the folder of the
|
* target folder is the same folder as the folder of the original item an
|
||||||
* original item an index is appended to the name of the
|
* index is appended to the name of the item.
|
||||||
* item.
|
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void copy(final ContentItem item, final Category targetFolder) {
|
public void copy(final ContentItem item, final Category targetFolder) {
|
||||||
|
|
@ -302,9 +300,6 @@ public class ContentItemManager {
|
||||||
|
|
||||||
copy.setContentType(contentType.get());
|
copy.setContentType(contentType.get());
|
||||||
|
|
||||||
final Workflow workflow = workflowManager.createWorkflow(contentType
|
|
||||||
.get().getDefaultWorkflow());
|
|
||||||
|
|
||||||
if (draftItem.getWorkflow() != null) {
|
if (draftItem.getWorkflow() != null) {
|
||||||
final WorkflowTemplate template = draftItem.getWorkflow()
|
final WorkflowTemplate template = draftItem.getWorkflow()
|
||||||
.getTemplate();
|
.getTemplate();
|
||||||
|
|
@ -450,6 +445,18 @@ public class ContentItemManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (targetFolder.equals(getItemFolder(item).orElse(null))) {
|
||||||
|
final long number = contentItemRepo.countFilterByFolderAndName(
|
||||||
|
targetFolder, String.format("%s_copy",
|
||||||
|
item.getDisplayName()));
|
||||||
|
final long index = number + 1;
|
||||||
|
copy.setDisplayName(String.format("%s_copy%d",
|
||||||
|
copy.getDisplayName(),
|
||||||
|
index));
|
||||||
|
}
|
||||||
|
|
||||||
|
contentItemRepo.save(copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean propertyIsExcluded(final String name) {
|
private boolean propertyIsExcluded(final String name) {
|
||||||
|
|
@ -705,9 +712,9 @@ public class ContentItemManager {
|
||||||
* @param type Type of the content item.
|
* @param type Type of the content item.
|
||||||
*
|
*
|
||||||
* @return The live version of an item. If the item provided is already the
|
* @return The live version of an item. If the item provided is already the
|
||||||
* live version the provided item is returned, otherwise the live
|
* live version the provided item is returned, otherwise the live version is
|
||||||
* version is returned. If there is no live version an empty
|
* returned. If there is no live version an empty {@link Optional} is
|
||||||
* {@link Optional} is returned.
|
* returned.
|
||||||
*/
|
*/
|
||||||
public <T extends ContentItem> Optional<T> getLiveVersion(
|
public <T extends ContentItem> Optional<T> getLiveVersion(
|
||||||
final ContentItem item,
|
final ContentItem item,
|
||||||
|
|
@ -747,10 +754,10 @@ public class ContentItemManager {
|
||||||
* @param type Type of the item.
|
* @param type Type of the item.
|
||||||
*
|
*
|
||||||
* @return The draft version of the provided content item. If the provided
|
* @return The draft version of the provided content item. If the provided
|
||||||
* item is the draft version the provided item is simply returned.
|
* item is the draft version the provided item is simply returned. Otherwise
|
||||||
* Otherwise the draft version is retrieved from the database and is
|
* the draft version is retrieved from the database and is returned. Each
|
||||||
* returned. Each content item has a draft version (otherwise
|
* content item has a draft version (otherwise something is seriously wrong
|
||||||
* something is seriously wrong with the database) this method will
|
* with the database) this method will
|
||||||
* <b>never</b> return {@code null}.
|
* <b>never</b> return {@code null}.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue