Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jgambarios committed Mar 12, 2019
1 parent 0621472 commit 5fe4523
Showing 1 changed file with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import com.dotmarketing.exception.DotRuntimeException;
import com.dotmarketing.exception.DotSecurityException;
import com.dotmarketing.factories.MultiTreeAPI;
import com.dotmarketing.portlets.containers.model.Container;
import com.dotmarketing.portlets.containers.model.FileAssetContainer;
import com.dotmarketing.portlets.contentlet.business.ContentletAPI;
import com.dotmarketing.portlets.contentlet.business.DotContentletStateException;
import com.dotmarketing.portlets.contentlet.business.HostAPI;
Expand All @@ -34,15 +36,14 @@
import com.liferay.portal.PortalException;
import com.liferay.portal.SystemException;
import com.liferay.portal.model.User;
import org.jetbrains.annotations.NotNull;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import org.jetbrains.annotations.NotNull;

/**
* Provides the utility methods that interact with HTML Pages in dotCMS. These methods are used by
Expand Down Expand Up @@ -238,12 +239,30 @@ protected void updateMultiTrees(final IHTMLPage page, final PageForm pageForm) t
multiTreeAPI.saveMultiTrees(pageIdentifier, multiTrees);
}

private String getNewUUID(final PageForm pageForm, final String containerId, final String uniqueId) {
private String getNewUUID(final PageForm pageForm, final String containerId,
final String uniqueId)
throws DotDataException, DotSecurityException {

//If we have a FileAssetContainer we may need to search also by path
String containerPath = null;
final Container foundContainer = APILocator.getContainerAPI()
.getWorkingContainerById(containerId, userAPI.getSystemUser(), false);
if (foundContainer instanceof FileAssetContainer) {
containerPath = FileAssetContainer.class.cast(foundContainer).getPath();
}

if (ContainerUUID.UUID_DEFAULT_VALUE.equals(uniqueId)) {
String newlyContainerUUID = pageForm.getNewlyContainerUUID(containerId);
return newlyContainerUUID != null ? newlyContainerUUID : ContainerUUID.UUID_DEFAULT_VALUE;
if (newlyContainerUUID == null && containerPath != null) {//Searching also by path if nothing found
newlyContainerUUID = pageForm.getNewlyContainerUUID(containerPath);
}
return newlyContainerUUID != null ? newlyContainerUUID
: ContainerUUID.UUID_DEFAULT_VALUE;
} else {
ContainerUUIDChanged change = pageForm.getChange(containerId, uniqueId);
if (change == null && containerPath != null) {//Searching also by path if nothing found
change = pageForm.getChange(containerPath, uniqueId);
}
return change != null ? change.getNew().getUUID() : ContainerUUID.UUID_DEFAULT_VALUE;
}
}
Expand Down

0 comments on commit 5fe4523

Please sign in to comment.