Republish working
parent
cfe8810666
commit
e81b3fbd4a
|
|
@ -27,6 +27,7 @@ import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
|
@ -122,11 +123,17 @@ public class Lifecycle implements Identifiable, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getEndDateTime() {
|
public Date getEndDateTime() {
|
||||||
return new Date(endDateTime.getTime());
|
return Optional
|
||||||
|
.ofNullable(endDateTime)
|
||||||
|
.map(date -> new Date(date.getTime()))
|
||||||
|
.orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEndDateTime(final Date endDateTime) {
|
public void setEndDateTime(final Date endDateTime) {
|
||||||
this.endDateTime = new Date(endDateTime.getTime());
|
this.endDateTime = Optional
|
||||||
|
.ofNullable(endDateTime)
|
||||||
|
.map(date -> new Date(date.getTime()))
|
||||||
|
.orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getListener() {
|
public String getListener() {
|
||||||
|
|
|
||||||
|
|
@ -417,6 +417,50 @@ public class PublishStep extends AbstractMvcAuthoringStep {
|
||||||
return buildRedirectPathForStep();
|
return buildRedirectPathForStep();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/republish")
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
public String republish() {
|
||||||
|
try {
|
||||||
|
init();
|
||||||
|
} catch (ContentSectionNotFoundException ex) {
|
||||||
|
return ex.showErrorMessage();
|
||||||
|
} catch (DocumentNotFoundException ex) {
|
||||||
|
return ex.showErrorMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
final ContentItem document = getDocument();
|
||||||
|
if (!itemManager.isLive(document)) {
|
||||||
|
models.put("republishNoneLive", true);
|
||||||
|
models.put("document", itemManager.getItemPath(document));
|
||||||
|
return TEMPLATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
final ContentItem live = itemManager
|
||||||
|
.getLiveVersion(document, document.getClass())
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new UnexpectedErrorException(
|
||||||
|
String.format(
|
||||||
|
"ContentItem %s is reported as live by "
|
||||||
|
+ "ContentItemManager#isLive"
|
||||||
|
+ "but has no live version.",
|
||||||
|
document.getUuid()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
final Lifecycle lifecycle = live.getLifecycle();
|
||||||
|
final LifecycleDefinition definition = lifecycle.getDefinition();
|
||||||
|
final Date startDateTime = lifecycle.getStartDateTime();
|
||||||
|
final Date endDateTime = lifecycle.getEndDateTime();
|
||||||
|
|
||||||
|
itemManager.publish(
|
||||||
|
document, definition, startDateTime, endDateTime
|
||||||
|
);
|
||||||
|
|
||||||
|
return buildRedirectPathForStep();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unpublishes the current content item.
|
* Unpublishes the current content item.
|
||||||
*
|
*
|
||||||
|
|
@ -433,7 +477,7 @@ public class PublishStep extends AbstractMvcAuthoringStep {
|
||||||
} catch (DocumentNotFoundException ex) {
|
} catch (DocumentNotFoundException ex) {
|
||||||
return ex.showErrorMessage();
|
return ex.showErrorMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
final ContentItem document = getDocument();
|
final ContentItem document = getDocument();
|
||||||
if (!itemPermissionChecker.canPublishItems(document)) {
|
if (!itemPermissionChecker.canPublishItems(document)) {
|
||||||
return documentUi.showAccessDenied(
|
return documentUi.showAccessDenied(
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="d-flex">
|
<div class="d-flex">
|
||||||
<form action="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@publish"
|
<form action="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@publish/republish"
|
||||||
class="mr-3"
|
class="mr-3"
|
||||||
method="post">
|
method="post">
|
||||||
<button class="btn btn-primary"
|
<button class="btn btn-primary"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue