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); } }
protected String[] getIntraUris(long companyId, long userId) { try { String[] intraUris = ExpandoValueLocalServiceUtil.getData( companyId, User.class.getName(), ExpandoTableConstants.DEFAULT_TABLE_NAME, BookmarkConstants.EXPANDO_COLUMN_VGR_LABELED_URI, userId, new String[0]); return intraUris; } catch (PortalException e) { LOGGER.error(e.getMessage(), e); } catch (SystemException e) { LOGGER.error(e.getMessage(), e); } return new String[0]; }
private void setBannedStatus() { // check the ban status and store in the banned field if (currentUser != null) { try { banned = MBBanLocalServiceUtil.hasBan(scopeGroupId, Long.valueOf(currentUser)); } catch (final SystemException e) { LOG.error("Cannot check ban status for user " + currentUser, e); e.printStackTrace(); } } }
@Override public boolean isUserPrioCouncilMember(long userId, long groupId) { boolean isUserPrioCouncilMember = false; boolean checkInheritedRoles = true; try { isUserPrioCouncilMember = userGroupRoleLocalService.hasUserGroupRole(userId, groupId, IdeaServiceConstants.ROLE_NAME_COMMUNITY_PRIO_COUNCIL, checkInheritedRoles); } catch (PortalException e) { LOGGER.error(e.getMessage(), e); } catch (SystemException e) { LOGGER.error(e.getMessage(), e); } return isUserPrioCouncilMember; }
@Override public LinkedList<String> getInternalIdeaUsersToEmail(Idea idea) { LinkedList<String> toEmail = new LinkedList<String>(); // toEmail.add(idea.getIdeaPerson().getEmail()); try { toEmail = getUserGroupRoleByRoleAndGroup(idea, toEmail, IdeaServiceConstants.ROLE_NAME_COMMUNITY_INNOVATIONSSLUSSEN); toEmail = getUserGroupRoleByRoleAndGroup(idea, toEmail, IdeaServiceConstants.ROLE_NAME_COMMUNITY_IDEA_TRANSPORTER); } catch (PortalException e) { e.printStackTrace(); } catch (SystemException e) { e.printStackTrace(); } return toEmail; }
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 boolean isUserIdeaTransporter(long userId, long groupId) { boolean isUserIdeaTransporter = false; boolean checkInheritedRoles = true; try { isUserIdeaTransporter = userGroupRoleLocalService.hasUserGroupRole(userId, groupId, IdeaServiceConstants.ROLE_NAME_COMMUNITY_IDEA_TRANSPORTER, checkInheritedRoles); } catch (PortalException e) { LOGGER.error(e.getMessage(), e); } catch (SystemException e) { LOGGER.error(e.getMessage(), e); } return isUserIdeaTransporter; }
public static boolean usesScreennameOnTori( final com.liferay.portal.model.User liferayUser) { boolean result = false; try { if (liferayUser != null) { result = ExpandoValueLocalServiceUtil.getData( liferayUser.getCompanyId(), com.liferay.portal.model.User.class.getName(), "CUSTOM_FIELDS", SCREENNAME_EXPANDO_COLUMN_NAME, liferayUser.getUserId(), false); } } catch (PortalException e) { e.printStackTrace(); } catch (SystemException e) { e.printStackTrace(); } return result; }
@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); } }
@Override public boolean isUserInnovationsslussenEmployee(long userId, long groupId) { boolean isUserInnovationsslussenEmployee = false; boolean checkInheritedRoles = true; try { isUserInnovationsslussenEmployee = userGroupRoleLocalService.hasUserGroupRole(userId, groupId, IdeaServiceConstants.ROLE_NAME_COMMUNITY_INNOVATIONSSLUSSEN, checkInheritedRoles); } catch (PortalException e) { LOGGER.error(e.getMessage(), e); } catch (SystemException e) { LOGGER.error(e.getMessage(), e); } return isUserInnovationsslussenEmployee; }
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"); }
public static List<String> getRegularRoleNames() { List<String> roleNames = new ArrayList<String>(); try { List<Role> roles = RoleLocalServiceUtil.getRoles(PortalUtil.getDefaultCompanyId()); for (Role r : roles) { if (r.getType() == RoleConstants.TYPE_REGULAR) { roleNames.add(r.getName()); } } } catch (SystemException e) { logger.log(Level.SEVERE, e.getMessage(), e); } return roleNames; } }
private String _resolveFile(String location) { if (!location.startsWith("///")) { throw new IllegalArgumentException( StringBundler.concat( "Invalid file location ", location, " because only local ", "file URIs starting with file:/// are supported")); } try { return StringUtil.read(new FileInputStream(location.substring(2))); } catch (IOException ioe) { throw new SystemException("Unable to read file " + location, ioe); } }
/** * Get {@link SocialRequest}s where the given {@link User} is the user who is asked to establish a relation by the * requesting part. * * @param user the requested {@link User} * @param cachedResult whether a cached result is acceptable * @return a list of {@link SocialRequest}s */ // Note: the cachedResult parameter is handled by NotificationsCacheAspect public List<SocialRequest> getUserRequests(User user, boolean cachedResult) { try { List<SocialRequest> receiverUserRequests = socialRequestLocalService.getReceiverUserRequests( user.getUserId(), SocialRequestConstants.STATUS_PENDING, 0, getUserRequestsCount( user, SocialRequestConstants.STATUS_PENDING)); return receiverUserRequests; } catch (SystemException e) { LOGGER.error(e.getMessage(), e); return null; } }
@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 FileEntry updateFileEntry( long userId, long fileEntryId, String sourceFileName, String mimeType, String title, String description, String changeLog, boolean majorVersion, File file, ServiceContext serviceContext) throws PortalException { InputStream is = null; long size = 0; try { is = new FileInputStream(file); size = file.length(); return updateFileEntry( userId, fileEntryId, sourceFileName, mimeType, title, description, changeLog, majorVersion, is, size, serviceContext); } catch (IOException ioe) { throw new SystemException(ioe); } finally { if (is != null) { try { is.close(); } catch (IOException ioe) { } } } }
@Override public FileEntry addFileEntry( long userId, long folderId, String sourceFileName, String mimeType, String title, String description, String changeLog, File file, ServiceContext serviceContext) throws PortalException { InputStream is = null; long size = 0; try { is = new FileInputStream(file); size = file.length(); return addFileEntry( userId, folderId, sourceFileName, mimeType, title, description, changeLog, is, size, serviceContext); } catch (IOException ioe) { throw new SystemException(ioe); } finally { if (is != null) { try { is.close(); } catch (IOException ioe) { } } } }
throw new SystemException( counterClass.getName() + " is unable to increment " + throw 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(); }
public static Object invoke(MethodKey methodKey, Object... arguments) throws Exception { Thread currentThread = Thread.currentThread(); ClassLoader contextClassLoader = currentThread.getContextClassLoader(); try { currentThread.setContextClassLoader( PortalClassLoaderUtil.getClassLoader()); MethodHandler methodHandler = new MethodHandler( methodKey, arguments); return methodHandler.invoke(); } catch (InvocationTargetException ite) { Throwable cause = ite.getCause(); if (cause instanceof Error) { throw new SystemException(ite); } throw (Exception)cause; } finally { currentThread.setContextClassLoader(contextClassLoader); } }