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 name The name (URL stub) of the new content item.
|
||||
* @param section The content section in which the item is
|
||||
* generated.
|
||||
* @param section The content section in which the item is generated.
|
||||
* @param folder The folder in which in the item is stored.
|
||||
* @param workflowTemplate The template for the workflow to apply to the new
|
||||
* item.
|
||||
|
|
@ -264,9 +263,8 @@ public class ContentItemManager {
|
|||
*
|
||||
* @param item The item to copy.
|
||||
* @param targetFolder The folder in which the copy is created. If the
|
||||
* target folder is the same folder as the folder of the
|
||||
* original item an index is appended to the name of the
|
||||
* item.
|
||||
* target folder is the same folder as the folder of the original item an
|
||||
* index is appended to the name of the item.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void copy(final ContentItem item, final Category targetFolder) {
|
||||
|
|
@ -302,9 +300,6 @@ public class ContentItemManager {
|
|||
|
||||
copy.setContentType(contentType.get());
|
||||
|
||||
final Workflow workflow = workflowManager.createWorkflow(contentType
|
||||
.get().getDefaultWorkflow());
|
||||
|
||||
if (draftItem.getWorkflow() != null) {
|
||||
final WorkflowTemplate template = draftItem.getWorkflow()
|
||||
.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) {
|
||||
|
|
@ -705,9 +712,9 @@ public class ContentItemManager {
|
|||
* @param type Type of the content item.
|
||||
*
|
||||
* @return The live version of an item. If the item provided is already the
|
||||
* live version the provided item is returned, otherwise the live
|
||||
* version is returned. If there is no live version an empty
|
||||
* {@link Optional} is returned.
|
||||
* live version the provided item is returned, otherwise the live version is
|
||||
* returned. If there is no live version an empty {@link Optional} is
|
||||
* returned.
|
||||
*/
|
||||
public <T extends ContentItem> Optional<T> getLiveVersion(
|
||||
final ContentItem item,
|
||||
|
|
@ -747,10 +754,10 @@ public class ContentItemManager {
|
|||
* @param type Type of the item.
|
||||
*
|
||||
* @return The draft version of the provided content item. If the provided
|
||||
* item is the draft version the provided item is simply returned.
|
||||
* Otherwise the draft version is retrieved from the database and is
|
||||
* returned. Each content item has a draft version (otherwise
|
||||
* something is seriously wrong with the database) this method will
|
||||
* item is the draft version the provided item is simply returned. Otherwise
|
||||
* the draft version is retrieved from the database and is returned. Each
|
||||
* content item has a draft version (otherwise something is seriously wrong
|
||||
* with the database) this method will
|
||||
* <b>never</b> return {@code null}.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
|
|
|
|||
Loading…
Reference in New Issue