|
|
|
@ -28,10 +28,28 @@ import com.liferay.portal.kernel.util.MimeTypesUtil;
|
|
|
|
|
import com.liferay.portal.kernel.util.StreamUtil; |
|
|
|
|
import com.liferay.portal.kernel.util.StringPool; |
|
|
|
|
import com.liferay.portal.kernel.util.StringUtil; |
|
|
|
|
import com.liferay.portal.kernel.util.Validator; |
|
|
|
|
import com.liferay.portal.model.Role; |
|
|
|
|
import com.liferay.portal.model.RoleConstants; |
|
|
|
|
import com.liferay.portal.model.User; |
|
|
|
|
import com.liferay.portal.security.auth.PrincipalThreadLocal; |
|
|
|
|
import com.liferay.portal.security.permission.ActionKeys; |
|
|
|
|
import com.liferay.portal.security.permission.PermissionChecker; |
|
|
|
|
import com.liferay.portal.security.permission.PermissionCheckerFactoryUtil; |
|
|
|
|
import com.liferay.portal.security.permission.PermissionThreadLocal; |
|
|
|
|
import com.liferay.portal.service.RoleLocalServiceUtil; |
|
|
|
|
import com.liferay.portal.service.ServiceContext; |
|
|
|
|
import com.liferay.portal.service.UserLocalServiceUtil; |
|
|
|
|
import com.liferay.portlet.documentlibrary.DuplicateFileException; |
|
|
|
|
import com.liferay.portlet.documentlibrary.NoSuchFileEntryException; |
|
|
|
|
import com.liferay.portlet.documentlibrary.service.DLAppHelperLocalServiceUtil; |
|
|
|
|
import com.liferay.portlet.documentlibrary.service.DLAppLocalServiceUtil; |
|
|
|
|
import com.liferay.portlet.documentlibrary.service.DLAppServiceUtil; |
|
|
|
|
import com.liferay.portlet.documentlibrary.service.DLContentLocalServiceUtil; |
|
|
|
|
import com.liferay.portlet.documentlibrary.service.DLFileEntryLocalServiceUtil; |
|
|
|
|
import com.liferay.portlet.documentlibrary.util.DLAppHelperThreadLocal; |
|
|
|
|
import com.liferay.portlet.documentlibrary.util.DLProcessorRegistryUtil; |
|
|
|
|
import com.liferay.portlet.trash.service.TrashEntryLocalServiceUtil; |
|
|
|
|
|
|
|
|
|
import it.tref.liferay.portos.report.html.core.HtmlToPdfEngine; |
|
|
|
|
import it.tref.liferay.portos.report.jasper.core.provider.JasperPdfProvider; |
|
|
|
@ -110,7 +128,6 @@ public class ReportTaskManagerServiceImpl extends ReportTaskManagerServiceBaseIm
|
|
|
|
|
fileEntryTemplate.getFileEntryId(), fileEntryTemplate.getVersion(), false); |
|
|
|
|
|
|
|
|
|
// generazione report
|
|
|
|
|
|
|
|
|
|
if (reportType.equals(ReportType.JRXML_TO_PDF)) { |
|
|
|
|
|
|
|
|
|
// Object dataSource = reportDto.getDataSource();
|
|
|
|
@ -168,20 +185,44 @@ public class ReportTaskManagerServiceImpl extends ReportTaskManagerServiceBaseIm
|
|
|
|
|
|
|
|
|
|
// recupero folder dove inserire report generato
|
|
|
|
|
|
|
|
|
|
Folder folder = DLAppLocalServiceUtil.getFolder(reportDto.getFolderId()); |
|
|
|
|
long folderId = reportDto.getFolderId(); |
|
|
|
|
Folder folder = DLAppLocalServiceUtil.getFolder(folderId); |
|
|
|
|
long groupId = folder.getGroupId(); |
|
|
|
|
long repositoryId = folder.getRepositoryId(); |
|
|
|
|
|
|
|
|
|
String title = reportDto.getFileName(); |
|
|
|
|
String sourceFileName = title + StringPool.PERIOD + "pdf"; |
|
|
|
|
String mimeType = MimeTypesUtil.getContentType(sourceFileName); |
|
|
|
|
String fileName = title + StringPool.PERIOD + "pdf"; |
|
|
|
|
String mimeType = MimeTypesUtil.getContentType(fileName); |
|
|
|
|
|
|
|
|
|
// se è già presente lo cancello
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
FileEntry fileEntry = dlAppLocalService.getFileEntry(folder.getGroupId(), |
|
|
|
|
folder.getFolderId(), title); |
|
|
|
|
dlAppLocalService.deleteFileEntry(fileEntry.getFileEntryId()); |
|
|
|
|
} catch (PortalException e) { |
|
|
|
|
} |
|
|
|
|
// FileEntry fileEntry = null;
|
|
|
|
|
// try {
|
|
|
|
|
// fileEntry =
|
|
|
|
|
// DLAppLocalServiceUtil.getFileEntry(groupId,
|
|
|
|
|
// folderId,
|
|
|
|
|
// title);
|
|
|
|
|
// } catch (PortalException e) {
|
|
|
|
|
// }
|
|
|
|
|
// if (Validator.isNotNull(fileEntry)) {
|
|
|
|
|
// _log.info("Cancello file entry " +
|
|
|
|
|
// fileEntry.getFileEntryId());
|
|
|
|
|
//
|
|
|
|
|
// Role role = RoleLocalServiceUtil.getRole(companyId,
|
|
|
|
|
// RoleConstants.ADMINISTRATOR);
|
|
|
|
|
// User user =
|
|
|
|
|
// UserLocalServiceUtil.getRoleUsers(role.getRoleId(), 0,
|
|
|
|
|
// 1).get(0);
|
|
|
|
|
// PermissionChecker permissionChecker =
|
|
|
|
|
// PermissionCheckerFactoryUtil.create(user);
|
|
|
|
|
//
|
|
|
|
|
// PrincipalThreadLocal.setName(user.getUserId());
|
|
|
|
|
// PermissionThreadLocal.setPermissionChecker(permissionChecker);
|
|
|
|
|
//
|
|
|
|
|
// DLAppServiceUtil.deleteFileEntry(fileEntry.getFileEntryId());
|
|
|
|
|
// DLAppLocalServiceUtil.deleteFileEntry(fileEntry.getFileEntryId());
|
|
|
|
|
//
|
|
|
|
|
// DLAppHelperLocalServiceUtil.deleteFileEntry(fileEntry);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// inserimento con permessi di view per site member
|
|
|
|
|
|
|
|
|
@ -190,19 +231,23 @@ public class ReportTaskManagerServiceImpl extends ReportTaskManagerServiceBaseIm
|
|
|
|
|
serviceContext.setUserId(userId); |
|
|
|
|
serviceContext.setGroupPermissions(new String[] { ActionKeys.VIEW }); |
|
|
|
|
|
|
|
|
|
_log.info("addFileEntry userId=" + serviceContext.getUserId() + ", repositoryId=" |
|
|
|
|
+ folder.getRepositoryId() + ", folderId=" + folder.getFolderId() |
|
|
|
|
+ ", sourceFileName=" + sourceFileName + ", mimeType=" + mimeType + ", title=" |
|
|
|
|
_log.info("addFileEntry userId=" + userId + ", repositoryId=" + repositoryId + ", folderId=" |
|
|
|
|
+ folderId + ", sourceFileName=" + fileName + ", mimeType=" + mimeType + ", title=" |
|
|
|
|
+ title); |
|
|
|
|
FileEntry fileEntry = dlAppLocalService.addFileEntry(serviceContext.getUserId(), |
|
|
|
|
folder.getRepositoryId(), folder.getFolderId(), sourceFileName, mimeType, title, |
|
|
|
|
StringPool.BLANK, StringPool.BLANK, bytes, serviceContext); |
|
|
|
|
|
|
|
|
|
FileEntry fileEntry = null; |
|
|
|
|
try { |
|
|
|
|
fileEntry = DLAppLocalServiceUtil.getFileEntry(groupId, folderId, title); |
|
|
|
|
fileEntry = DLAppLocalServiceUtil.updateFileEntry(userId, fileEntry.getFileEntryId(), |
|
|
|
|
fileName, mimeType, title, StringPool.BLANK, StringPool.BLANK, false, bytes, |
|
|
|
|
serviceContext); |
|
|
|
|
} catch (PortalException e) { |
|
|
|
|
fileEntry = DLAppLocalServiceUtil.addFileEntry(userId, repositoryId, folderId, fileName, |
|
|
|
|
mimeType, title, StringPool.BLANK, StringPool.BLANK, bytes, serviceContext); |
|
|
|
|
} |
|
|
|
|
fileEntryIds = ArrayUtil.append(fileEntryIds, fileEntry.getFileEntryId()); |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
|
|
throw new SystemException(e); |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return fileEntryIds; |
|
|
|
|