Skip to content

Commit

Permalink
LPS-56374 Ensure that only one version exists in Live
Browse files Browse the repository at this point in the history
  • Loading branch information
Tamas Molnar authored and brianchandotcom committed Jun 15, 2015
1 parent 83e707c commit 854d87e
Showing 1 changed file with 11 additions and 0 deletions.
Expand Up @@ -18,6 +18,7 @@
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.lar.BaseStagedModelDataHandler;
import com.liferay.portal.kernel.lar.ExportImportPathUtil;
import com.liferay.portal.kernel.lar.ExportImportThreadLocal;
import com.liferay.portal.kernel.lar.PortletDataContext;
import com.liferay.portal.kernel.lar.PortletDataException;
import com.liferay.portal.kernel.lar.StagedModelDataHandlerUtil;
Expand Down Expand Up @@ -448,12 +449,14 @@ protected void doImportStagedModel(
boolean indexEnabled = serviceContext.isIndexingEnabled();

boolean updateFileEntry = false;
boolean deleteFileEntry = false;

if (!Validator.equals(
fileVersion.getUuid(),
latestExistingFileVersion.getUuid())) {

updateFileEntry = true;
deleteFileEntry = true;
}
else {
InputStream existingFileVersionInputStream = null;
Expand Down Expand Up @@ -528,6 +531,14 @@ protected void doImportStagedModel(

indexer.reindex(liferayFileEntry.getModel());
}

if (deleteFileEntry &&
ExportImportThreadLocal.isStagingInProcess()) {

DLAppServiceUtil.deleteFileVersion(
latestExistingFileVersion.getFileEntryId(),
latestExistingFileVersion.getVersion());
}
}
finally {
serviceContext.setIndexingEnabled(indexEnabled);
Expand Down

0 comments on commit 854d87e

Please sign in to comment.