use of com.liferay.portal.kernel.model.Repository in project index-checker by jorgediaz-lr.
the class OutputUtils method servePortletFileEntry.
public static void servePortletFileEntry(String portletId, String title, ResourceRequest request, ResourceResponse response) throws IOException {
try {
Repository repository = getPortletRepository(portletId);
FileEntry fileEntry = getPortletFileEntry(repository, title);
InputStream inputStream = fileEntry.getContentStream();
PortletResponseUtil.sendFile(request, response, title, inputStream, -1, fileEntry.getMimeType(), "attachment");
} catch (NoSuchFileEntryException nsfe) {
if (_log.isWarnEnabled()) {
_log.warn(nsfe.getMessage());
}
response.setProperty(ResourceResponse.HTTP_STATUS_CODE, String.valueOf(HttpServletResponse.SC_NOT_FOUND));
} catch (Exception e) {
_log.error(e, e);
response.setProperty(ResourceResponse.HTTP_STATUS_CODE, String.valueOf(HttpServletResponse.SC_INTERNAL_SERVER_ERROR));
}
}
use of com.liferay.portal.kernel.model.Repository in project index-checker by jorgediaz-lr.
the class OutputUtils method addPortletOutputFileEntry.
public static FileEntry addPortletOutputFileEntry(String portletId, long userId, String outputContent) {
if (Validator.isNull(outputContent)) {
return null;
}
try {
InputStream inputStream = new ByteArrayInputStream(outputContent.getBytes(StringPool.UTF8));
Repository repository = getPortletRepository(portletId);
cleanupPortletFileEntries(repository, 8 * 60);
String fileName = portletId + "_output_" + userId + "_" + System.currentTimeMillis() + ".csv";
return addPortletFileEntry(repository, inputStream, userId, fileName, "text/plain");
} catch (Exception e) {
_log.error(e, e);
return null;
}
}
use of com.liferay.portal.kernel.model.Repository in project index-checker by jorgediaz-lr.
the class DLFileEntryPermissionsHelper method _isHiddenFolder.
private boolean _isHiddenFolder(long groupId, long repositoryId) {
try {
if (groupId == repositoryId) {
return false;
}
Repository repository = RepositoryLocalServiceUtil.fetchRepository(repositoryId);
if (repository == null) {
return false;
}
DLFolder dlFolder = DLFolderLocalServiceUtil.fetchDLFolder(repository.getDlFolderId());
if (dlFolder == null) {
return false;
}
return dlFolder.isHidden();
} catch (SystemException se) {
_log.error(se);
return false;
}
}
use of com.liferay.portal.kernel.model.Repository in project index-checker by jorgediaz-lr.
the class OutputUtils method getPortletRepository.
public static Repository getPortletRepository(String portletId) throws PortalException {
List<Company> companies = CompanyLocalServiceUtil.getCompanies(false);
Company company = companies.get(0);
Group group = GroupServiceUtil.getCompanyGroup(company.getCompanyId());
Repository repository = PortletFileRepositoryUtil.fetchPortletRepository(group.getGroupId(), portletId);
if (repository == null) {
repository = PortletFileRepositoryUtil.addPortletRepository(group.getGroupId(), portletId, new ServiceContext());
}
return repository;
}
Aggregations