public MustComplyWithModelListeners( long userId, ModelListenerException modelListenerException) { super( String.format( "Password must comply with model listeners: " + modelListenerException.getMessage()), PASSWORD_INVALID); this.userId = userId; this.modelListenerException = modelListenerException; }
public MustProduceValidFriendlyURL( long userId, String screenName, int exceptionType) { super( String.format( "Screen name %s for user %s must produce a valid " + "friendly URL", screenName, userId), new GroupFriendlyURLException(exceptionType)); this.userId = userId; this.screenName = screenName; this.exceptionType = exceptionType; }
private Object _getProperty(String key) { try { Method method = _methods.get(key); if (method == null) { return null; } return method.invoke(_configurationBean); } catch (InvocationTargetException ite) { throw new SystemException("Unable to read property " + key, ite); } catch (IllegalAccessException iae) { throw new SystemException("Unable to read property " + key, iae); } }
public static FileEntry addTempFileEntry( long groupId, long userId, String folderName, String fileName, File file, String mimeType) throws PortalException { try (InputStream inputStream = new FileInputStream(file)) { return addTempFileEntry( groupId, userId, folderName, fileName, inputStream, mimeType); } catch (IOException ioe) { throw new PortalException(ioe); } }
public static void validateSupportCookie(HttpServletRequest request) throws CookieNotSupportedException { if (_SESSION_ENABLE_PERSISTENT_COOKIES && _SESSION_TEST_COOKIE_SUPPORT) { String cookieSupport = getCookie(request, COOKIE_SUPPORT, false); if (Validator.isNull(cookieSupport)) { throw new CookieNotSupportedException(); } } }
protected Object executeDynamicQuery( Method dynamicQueryMethod, Object... arguments) throws PortalException { try { return dynamicQueryMethod.invoke(_baseLocalService, arguments); } catch (InvocationTargetException ite) { Throwable throwable = ite.getCause(); if (throwable instanceof PortalException) { throw (PortalException)throwable; } else if (throwable instanceof SystemException) { throw (SystemException)throwable; } throw new SystemException(ite); } catch (Exception e) { throw new SystemException(e); } }
@Override public void setBaseLocalService(BaseLocalService baseLocalService) { _baseLocalService = baseLocalService; Class<?> clazz = _baseLocalService.getClass(); try { _dynamicQueryMethod = clazz.getMethod( "dynamicQuery", DynamicQuery.class); _dynamicQueryCountMethod = clazz.getMethod( "dynamicQueryCount", DynamicQuery.class, Projection.class); } catch (NoSuchMethodException nsme) { throw new SystemException(nsme); } }
public static InetAddress getLocalInetAddress() throws Exception { Enumeration<NetworkInterface> enu1 = NetworkInterface.getNetworkInterfaces(); while (enu1.hasMoreElements()) { NetworkInterface networkInterface = enu1.nextElement(); Enumeration<InetAddress> enu2 = networkInterface.getInetAddresses(); while (enu2.hasMoreElements()) { InetAddress inetAddress = enu2.nextElement(); if (!inetAddress.isLoopbackAddress() && (inetAddress instanceof Inet4Address)) { return inetAddress; } } } throw new SystemException("No local internet address"); }
@Override protected boolean containsTableMapping( long leftPrimaryKey, long rightPrimaryKey, boolean updateCache) { List<Integer> counts = null; try { counts = getTableMappingSqlQuery.execute( leftPrimaryKey, rightPrimaryKey); } catch (Exception e) { throw new SystemException(e); } if (counts.isEmpty()) { return false; } int count = counts.get(0); if (count == 0) { return false; } return true; }
@Override public SystemException processException(Exception e) { if (!(e instanceof ORMException)) { _log.error("Caught unexpected exception", e); } else if (_log.isDebugEnabled()) { _log.debug(e, e); } return new SystemException(e); }
@Override public void moveTrashEntry( long userId, long classPK, long containerModelId, ServiceContext serviceContext) throws PortalException { if (isRestorable(classPK)) { restoreTrashEntry(userId, classPK); } Class<?> clazz = getClass(); _log.error("moveTrashEntry() is not implemented in " + clazz.getName()); throw new SystemException(); }
/** * Returns the file as a byte array. * * @param companyId the primary key of the company * @param repositoryId the primary key of the data repository (optionally * {@link com.liferay.portal.kernel.model.CompanyConstants#SYSTEM}) * @param fileName the file's name * @return Returns the byte array with the file's name */ @Override public byte[] getFileAsBytes( long companyId, long repositoryId, String fileName) throws PortalException { try { InputStream is = getFileAsStream(companyId, repositoryId, fileName); return FileUtil.getBytes(is); } catch (IOException ioe) { throw new SystemException(ioe); } }
/** * Returns the file as a byte array. * * @param companyId the primary key of the company * @param repositoryId the primary key of the data repository (optionally * {@link com.liferay.portal.kernel.model.CompanyConstants#SYSTEM}) * @param fileName the file's name * @param versionLabel the file's version label * @return Returns the byte array with the file's name */ @Override public byte[] getFileAsBytes( long companyId, long repositoryId, String fileName, String versionLabel) throws PortalException { try { InputStream is = getFileAsStream( companyId, repositoryId, fileName, versionLabel); return FileUtil.getBytes(is); } catch (IOException ioe) { throw new SystemException(ioe); } }
/** * Adds a file based on a byte array. * * @param companyId the primary key of the company * @param repositoryId the primary key of the data repository (optionally * {@link com.liferay.portal.kernel.model.CompanyConstants#SYSTEM}) * @param fileName the file name * @param bytes the files's data */ @Override public void addFile( long companyId, long repositoryId, String fileName, byte[] bytes) throws PortalException { try (UnsyncByteArrayInputStream unsyncByteArrayInputStream = new UnsyncByteArrayInputStream(bytes)) { addFile( companyId, repositoryId, fileName, unsyncByteArrayInputStream); } catch (IOException ioe) { throw new SystemException("Unable to read bytes", ioe); } }
/** * Updates a file based on a byte array. * * @param companyId the primary key of the company * @param repositoryId the primary key of the data repository (optionally * {@link com.liferay.portal.kernel.model.CompanyConstants#SYSTEM}) * @param fileName the file name * @param versionLabel the file's new version label * @param bytes the new file's data */ @Override public void updateFile( long companyId, long repositoryId, String fileName, String versionLabel, byte[] bytes) throws PortalException { try (UnsyncByteArrayInputStream unsyncByteArrayInputStream = new UnsyncByteArrayInputStream(bytes)) { updateFile( companyId, repositoryId, fileName, versionLabel, unsyncByteArrayInputStream); } catch (IOException ioe) { throw new SystemException("Unable to read bytes", ioe); } }
@Override public void scan(File file) throws AntivirusScannerException { try (InputStream inputStream = new FileInputStream(file)) { scan(inputStream); } catch (FileNotFoundException fnfe) { throw new SystemException("Unable to scan file", fnfe); } catch (IOException ioe) { if (_log.isWarnEnabled()) { _log.warn(ioe, ioe); } } }
@Override public void scan(InputStream inputStream) throws AntivirusScannerException { File file = null; try { file = FileUtil.createTempFile(_ANTIVIRUS_EXTENSION); FileUtil.write(file, inputStream); scan(file); } catch (IOException ioe) { throw new SystemException("Unable to write temporary file", ioe); } finally { if (file != null) { file.delete(); } } }
private String _resolveResource(String location) { ResourceRetriever resourceRetriever = _resourceManager.getResourceRetriever(location); try { return StringUtil.read(resourceRetriever.getInputStream()); } catch (IOException ioe) { throw new SystemException( "Unable to read resource " + location, ioe); } }
protected void removeDefaultValue( PortletRequest portletRequest, PortletPreferences portletPreferences, String key, String defaultValue) { String value = getParameter(portletRequest, key); if (defaultValue.equals(value) || StringUtil.equalsIgnoreBreakLine(defaultValue, value)) { try { portletPreferences.reset(key); } catch (ReadOnlyException roe) { throw new SystemException(roe); } } }
@Override public void scan(byte[] bytes) throws AntivirusScannerException { File file = null; try { file = FileUtil.createTempFile(_ANTIVIRUS_EXTENSION); FileUtil.write(file, bytes); scan(file); } catch (IOException ioe) { throw new SystemException("Unable to write temporary file", ioe); } finally { if (file != null) { file.delete(); } } }