Browse files

LPS-26344 Ensure trash bin works with Staging

  • Loading branch information...
1 parent 7ba4af9 commit bf531f702087ee51e2367ef81ae275b3c4f29cc7 @juliocamarero juliocamarero committed with brianchandotcom Apr 18, 2012
View
14 portal-impl/src/com/liferay/portlet/blogs/lar/BlogsPortletDataHandlerImpl.java
@@ -201,7 +201,9 @@ protected void exportEntry(
return;
}
- if (entry.getStatus() != WorkflowConstants.STATUS_APPROVED) {
+ if (entry.getStatus() != WorkflowConstants.STATUS_APPROVED &&
+ entry.getStatus() != WorkflowConstants.STATUS_IN_TRASH) {
+
return;
}
@@ -329,7 +331,9 @@ protected void importEntry(
ServiceContext serviceContext = portletDataContext.createServiceContext(
entryElement, entry, _NAMESPACE);
- if (status != WorkflowConstants.STATUS_APPROVED) {
+ if ((status != WorkflowConstants.STATUS_APPROVED) &&
+ (status != WorkflowConstants.STATUS_IN_TRASH)) {
+
serviceContext.setWorkflowAction(
WorkflowConstants.ACTION_SAVE_DRAFT);
}
@@ -366,6 +370,12 @@ protected void importEntry(
entry.isSmallImage(), entry.getSmallImageURL(),
smallImageFileName, smallImageInputStream,
serviceContext);
+
+ if (status == WorkflowConstants.STATUS_IN_TRASH) {
+ importedEntry =
+ BlogsEntryLocalServiceUtil.moveEntryToTrash(
+ userId, importedEntry);
+ }
}
else {
importedEntry = BlogsEntryLocalServiceUtil.updateEntry(
View
7 portal-impl/src/com/liferay/portlet/blogs/service/impl/BlogsEntryLocalServiceImpl.java
@@ -736,7 +736,7 @@ public void moveEntriesToTrash(long groupId, long userId)
}
}
- public void moveEntryToTrash(long userId, BlogsEntry entry)
+ public BlogsEntry moveEntryToTrash(long userId, BlogsEntry entry)
throws PortalException, SystemException {
int oldStatus = entry.getStatus();
@@ -793,14 +793,15 @@ public void moveEntryToTrash(long userId, BlogsEntry entry)
entry.getCompanyId(), entry.getGroupId(),
BlogsEntry.class.getName(), entry.getEntryId(), oldStatus, null);
+ return entry;
}
- public void moveEntryToTrash(long userId, long entryId)
+ public BlogsEntry moveEntryToTrash(long userId, long entryId)
throws PortalException, SystemException {
BlogsEntry entry = blogsEntryPersistence.findByPrimaryKey(entryId);
- moveEntryToTrash(userId, entry);
+ return moveEntryToTrash(userId, entry);
}
public void restoreEntryFromTrash(long userId, long entryId)
View
12 portal-impl/src/com/liferay/portlet/documentlibrary/lar/DLPortletDataHandlerImpl.java
@@ -58,6 +58,7 @@
import com.liferay.portlet.documentlibrary.model.DLFolder;
import com.liferay.portlet.documentlibrary.model.DLFolderConstants;
import com.liferay.portlet.documentlibrary.service.DLAppLocalServiceUtil;
+import com.liferay.portlet.documentlibrary.service.DLAppServiceUtil;
import com.liferay.portlet.documentlibrary.service.DLFileEntryMetadataLocalServiceUtil;
import com.liferay.portlet.documentlibrary.service.DLFileEntryTypeLocalServiceUtil;
import com.liferay.portlet.documentlibrary.service.DLFileEntryTypeServiceUtil;
@@ -107,7 +108,9 @@ public static void exportFileEntry(
FileVersion fileVersion = fileEntry.getFileVersion();
- if (fileVersion.getStatus() != WorkflowConstants.STATUS_APPROVED) {
+ if ((fileVersion.getStatus() != WorkflowConstants.STATUS_APPROVED ) &&
+ (fileVersion.getStatus() != WorkflowConstants.STATUS_IN_TRASH)) {
+
return;
}
@@ -365,6 +368,13 @@ public static void importFileEntry(
titleWithExtension, fileEntry.getMimeType(),
fileEntry.getTitle(), fileEntry.getDescription(), null, is,
fileEntry.getSize(), serviceContext);
+
+ if (fileVersion.getStatus() ==
+ WorkflowConstants.STATUS_IN_TRASH) {
+
+ importedFileEntry = DLAppServiceUtil.moveFileEntryToTrash(
+ importedFileEntry.getFileEntryId());
+ }
}
else {
FileVersion latestExistingFileVersion =
View
4 ...mpl/src/com/liferay/portlet/documentlibrary/service/impl/DLAppHelperLocalServiceImpl.java
@@ -305,7 +305,7 @@ public void moveFileEntry(FileEntry fileEntry)
}
}
- public void moveFileEntryToTrash(long userId, FileEntry fileEntry)
+ public FileEntry moveFileEntryToTrash(long userId, FileEntry fileEntry)
throws PortalException, SystemException {
DLFileEntry dlFileEntry = (DLFileEntry)fileEntry.getModel();
@@ -344,6 +344,8 @@ public void moveFileEntryToTrash(long userId, FileEntry fileEntry)
fileEntry.getCompanyId(), fileEntry.getGroupId(),
DLFileEntryConstants.getClassName(), fileEntry.getFileEntryId(),
oldStatus, null);
+
+ return fileEntry;
}
public void moveFolder(Folder folder)
View
5 portal-impl/src/com/liferay/portlet/documentlibrary/service/impl/DLAppServiceImpl.java
@@ -1957,7 +1957,7 @@ public FileEntry moveFileEntry(
* @throws PortalException if the file entry could not be found
* @throws SystemException if a system exception occurred
*/
- public void moveFileEntryToTrash(long fileEntryId)
+ public FileEntry moveFileEntryToTrash(long fileEntryId)
throws PortalException, SystemException {
Repository repository = getRepository(0, fileEntryId, 0);
@@ -1973,7 +1973,8 @@ public void moveFileEntryToTrash(long fileEntryId)
DLFileEntryPermission.check(
getPermissionChecker(), fileEntry, ActionKeys.DELETE);
- dlAppHelperLocalService.moveFileEntryToTrash(getUserId(), fileEntry);
+ return dlAppHelperLocalService.moveFileEntryToTrash(
+ getUserId(), fileEntry);
}
/**
View
7 portal-impl/src/com/liferay/portlet/trash/service/impl/TrashEntryLocalServiceImpl.java
@@ -18,6 +18,7 @@
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.UnicodeProperties;
import com.liferay.portal.util.PortalUtil;
+import com.liferay.portlet.trash.NoSuchEntryException;
import com.liferay.portlet.trash.model.TrashEntry;
import com.liferay.portlet.trash.model.impl.TrashEntryImpl;
import com.liferay.portlet.trash.service.base.TrashEntryLocalServiceBaseImpl;
@@ -96,7 +97,11 @@ public void deleteEntry(String className, long classPK)
long classNameId = PortalUtil.getClassNameId(className);
- trashEntryPersistence.removeByC_C(classNameId, classPK);
+ try {
+ trashEntryPersistence.removeByC_C(classNameId, classPK);
+ }
+ catch(NoSuchEntryException nsee) {
+ }
}
/**
View
8 portal-service/src/com/liferay/portal/kernel/workflow/WorkflowConstants.java
@@ -63,6 +63,8 @@
public static final String LABEL_EXPIRED = "expired";
+ public static final String LABEL_IN_TRASH = "in-trash";
+
public static final String LABEL_INACTIVE = "inactive";
public static final String LABEL_INCOMPLETE = "incomplete";
@@ -105,6 +107,9 @@ else if (status == STATUS_DRAFT) {
else if (status == STATUS_EXPIRED) {
return LABEL_EXPIRED;
}
+ else if (status == STATUS_IN_TRASH) {
+ return LABEL_IN_TRASH;
+ }
else if (status == STATUS_INACTIVE) {
return LABEL_INACTIVE;
}
@@ -138,6 +143,9 @@ else if (label.equals(LABEL_EXPIRED)) {
else if (label.equals(LABEL_INACTIVE)) {
return STATUS_INACTIVE;
}
+ else if (label.equals(LABEL_IN_TRASH)) {
+ return STATUS_IN_TRASH;
+ }
else if (label.equals(LABEL_INCOMPLETE)) {
return STATUS_INCOMPLETE;
}
View
24 portal-web/docroot/html/portlet/trash/view.jsp
@@ -17,9 +17,31 @@
<%@ include file="/html/portlet/trash/init.jsp" %>
<%
+String tabs1 = ParamUtil.getString(request, "tabs1", "staging");
+
+long groupId = themeDisplay.getScopeGroupId();
+
+Group group = GroupLocalServiceUtil.getGroup(groupId);
+
+if (group.isStagingGroup() && tabs1.equals("live")) {
+ groupId = group.getLiveGroupId();
+}
+
+PortletURL portletURL = renderResponse.createRenderURL();
+
+portletURL.setParameter("struts_action", "/trash/view");
+portletURL.setParameter("tabs1", tabs1);
+
boolean aproximate = false;
%>
+<c:if test="<%= group.isStagingGroup() %>">
+ <liferay-ui:tabs
+ names="staging,live"
+ url="<%= portletURL.toString() %>"
+ />
+</c:if>
+
<portlet:actionURL var="editTrashEntryURL">
<portlet:param name="struts_action" value="/trash/edit_entry" />
</portlet:actionURL>
@@ -38,7 +60,7 @@ boolean aproximate = false;
<liferay-ui:search-container-results>
<%
- Object[] entries = TrashEntryServiceUtil.getEntries(themeDisplay.getScopeGroupId(), searchContainer.getStart(), searchContainer.getEnd());
+ Object[] entries = TrashEntryServiceUtil.getEntries(groupId, searchContainer.getStart(), searchContainer.getEnd());
pageContext.setAttribute("results", entries[0]);
pageContext.setAttribute("total", entries[1]);

0 comments on commit bf531f7

Please sign in to comment.