/** * Returns the video descriptor * * @return Video descriptor * @throws RemoteException * @see VideoDescriptor */ public VideoDescriptor getVideoDescriptor() throws RemoteException { try { final VideoStreamingSession session = mRichcallService.getVideoSharingSession(mSharingId); if (session == null) { return mPersistentStorage.getVideoDescriptor(); } IVideoPlayer player = session.getPlayer(); if (player != null) { VideoCodec codec = player.getCodec(); return new VideoDescriptor(codec.getWidth(), codec.getHeight()); } VideoContent content = (VideoContent) session.getContent(); return new VideoDescriptor(content.getWidth(), content.getHeight()); } catch (ServerApiBaseException e) { if (!e.shouldNotBeLogged()) { sLogger.error(ExceptionUtil.getFullStackTrace(e)); } throw e; } catch (Exception e) { sLogger.error(ExceptionUtil.getFullStackTrace(e)); throw new ServerApiGenericException(e); } }
@Test public void 테스트_getStackTraceString() { Exception e = new InvalidClassException("e"); assertThat(ExceptionUtil.createStacktrace(null)).isNull(); assertThat(ExceptionUtil.createStacktrace(e)).isNotNull(); }
/** Saves the current Settings properties to the config file */ public static void saveSettings() { if (!CONFIG_FILE_LOCATION.exists()) { try { LOGGER.debug( "Trying to create new settings file at {}", CONFIG_FILE_LOCATION.getAbsolutePath()); CONFIG_FILE_LOCATION.createNewFile(); } catch (IOException e) { LOGGER.error( "Could not create settings file at {}", CONFIG_FILE_LOCATION.getAbsolutePath(), e); throw ExceptionUtil.getRuntimeException( "exceptions.settings.create", e, CONFIG_FILE_LOCATION.getAbsolutePath()); } } Properties properties = getAsProperties(settings); try { LOGGER.debug("Saving properties to settings file"); properties.store( new FileOutputStream(CONFIG_FILE_LOCATION), "Settings file for YouTrack worklog viewer"); } catch (IOException e) { LOGGER.error("Could not save settings to {}", CONFIG_FILE_LOCATION.getAbsolutePath(), e); throw ExceptionUtil.getRuntimeException( "exceptions.settings.write", e, CONFIG_FILE_LOCATION.getAbsolutePath()); } }
/** * Return the video encoding (eg. H.264) * * @return Encoding * @throws RemoteException */ public String getVideoEncoding() throws RemoteException { try { final VideoStreamingSession session = mRichcallService.getVideoSharingSession(mSharingId); if (session == null) { return mPersistentStorage.getVideoEncoding(); } IVideoPlayer player = session.getPlayer(); if (player == null) { throw new ServerApiGenericException( "Cannot get video encoding for session with sharing ID:".concat(mSharingId)); } VideoCodec codec = player.getCodec(); if (codec == null) { throw new ServerApiGenericException( "Cannot get video codec for session with sharing ID:".concat(mSharingId)); } return codec.getEncoding(); } catch (ServerApiBaseException e) { if (!e.shouldNotBeLogged()) { sLogger.error(ExceptionUtil.getFullStackTrace(e)); } throw e; } catch (Exception e) { sLogger.error(ExceptionUtil.getFullStackTrace(e)); throw new ServerApiGenericException(e); } }
/** * Returns the state of the geoloc sharing * * @return State * @throws RemoteException */ public int getState() throws RemoteException { try { GeolocTransferSession session = mRichcallService.getGeolocTransferSession(mSharingId); if (session == null) { return mPersistentStorage.getState().toInt(); } if (session.isGeolocTransferred()) { return State.TRANSFERRED.toInt(); } SipDialogPath dialogPath = session.getDialogPath(); if (dialogPath != null && dialogPath.isSessionEstablished()) { return State.STARTED.toInt(); } else if (session.isInitiatedByRemote()) { if (session.isSessionAccepted()) { return State.ACCEPTING.toInt(); } return State.INVITED.toInt(); } return State.INITIATING.toInt(); } catch (ServerApiBaseException e) { if (!e.shouldNotBeLogged()) { sLogger.error(ExceptionUtil.getFullStackTrace(e)); } throw e; } catch (Exception e) { sLogger.error(ExceptionUtil.getFullStackTrace(e)); throw new ServerApiGenericException(e); } }
@Test public void 테스트_getExceptionType() { Exception e = new IllegalArgumentException("e"); assertThat(ExceptionUtil.createExceptionType(null)).isNull(); assertThat(ExceptionUtil.createExceptionType(e)).isNotNull(); }
AmsJsonErrorMessageException( HttpStatus statusCode, String statusText, String body, Charset charsetl) { this.statusCode = statusCode; this.statusText = statusText; this.charsetl = charsetl; this.body = body; this.errorMessage = ExceptionUtil.getErrorMessageFromJsonString(body); this.errors = ExceptionUtil.extractedErrors(errorMessage); }
/** * Returns the sharing ID of the geoloc sharing * * @return Sharing ID * @throws RemoteException */ public String getSharingId() throws RemoteException { try { return mSharingId; } catch (ServerApiBaseException e) { if (!e.shouldNotBeLogged()) { sLogger.error(ExceptionUtil.getFullStackTrace(e)); } throw e; } catch (Exception e) { sLogger.error(ExceptionUtil.getFullStackTrace(e)); throw new ServerApiGenericException(e); } }
@Override public void setImageResizeOption(int option) throws RemoteException { try { mRcsSettings.setImageResizeOption(ImageResizeOption.valueOf(option)); } catch (ServerApiBaseException e) { if (!e.shouldNotBeLogged()) { mLogger.error(ExceptionUtil.getFullStackTrace(e)); } throw e; } catch (Exception e) { mLogger.error(ExceptionUtil.getFullStackTrace(e)); throw new ServerApiGenericException(e); } }
@Override public void rethrowAsCore() throws CoreException { if (hasErrors()) { if (recorded.size() == 1) { throw ExceptionUtil.coreException(recorded.get(0)); } else { StringBuffer msg = new StringBuffer("Multiple problems: \n"); IStatus[] children = new IStatus[recorded.size()]; int i = 0; for (IStatus e : recorded) { if (i < 3) { msg.append(e.getMessage() + "\n"); } else if (i == 3) { msg.append("...more errors..."); } children[i++] = e; } IStatus status = new MultiStatus(GradleCore.PLUGIN_ID, 666, children, msg.toString(), null); throw new CoreException(status); } } else if (recorded.size() > 0) { // no errors but has some recorded stuff. Log this stuff to the error log rather than simply // discarding it. for (IStatus e : recorded) { GradleCore.log(e); } } }
@Override public int getMaxFileTransfers() throws RemoteException { try { return mRcsSettings.getMaxFileTransferSessions(); } catch (ServerApiBaseException e) { if (!e.shouldNotBeLogged()) { mLogger.error(ExceptionUtil.getFullStackTrace(e)); } throw e; } catch (Exception e) { mLogger.error(ExceptionUtil.getFullStackTrace(e)); throw new ServerApiGenericException(e); } }
@Override public int getImageResizeOption() throws RemoteException { try { return mRcsSettings.getImageResizeOption().toInt(); } catch (ServerApiBaseException e) { if (!e.shouldNotBeLogged()) { mLogger.error(ExceptionUtil.getFullStackTrace(e)); } throw e; } catch (Exception e) { mLogger.error(ExceptionUtil.getFullStackTrace(e)); throw new ServerApiGenericException(e); } }
@Override public boolean isAutoAcceptEnabled() throws RemoteException { try { return mRcsSettings.isFileTransferAutoAccepted(); } catch (ServerApiBaseException e) { if (!e.shouldNotBeLogged()) { mLogger.error(ExceptionUtil.getFullStackTrace(e)); } throw e; } catch (Exception e) { mLogger.error(ExceptionUtil.getFullStackTrace(e)); throw new ServerApiGenericException(e); } }
public boolean offer(T element) { try { _zkClient.createPersistentSequential(_root + "/" + ELEMENT_NAME + "-", element); } catch (Exception e) { throw ExceptionUtil.convertToRuntimeException(e); } return true; }
@Override public boolean isGroupFileTransferSupported() throws RemoteException { try { return mRcsSettings.getMyCapabilities().isFileTransferHttpSupported() && mRcsSettings.isGroupChatActivated(); } catch (ServerApiBaseException e) { if (!e.shouldNotBeLogged()) { mLogger.error(ExceptionUtil.getFullStackTrace(e)); } throw e; } catch (Exception e) { mLogger.error(ExceptionUtil.getFullStackTrace(e)); throw new ServerApiGenericException(e); } }
/** * Returns the duration of the video sharing * * @return Duration in milliseconds * @throws RemoteException */ public long getDuration() throws RemoteException { try { final VideoStreamingSession session = mRichcallService.getVideoSharingSession(mSharingId); if (session == null) { return mPersistentStorage.getDuration(); } return mStartTime > 0 ? System.currentTimeMillis() - mStartTime : 0; } catch (ServerApiBaseException e) { if (!e.shouldNotBeLogged()) { sLogger.error(ExceptionUtil.getFullStackTrace(e)); } throw e; } catch (Exception e) { sLogger.error(ExceptionUtil.getFullStackTrace(e)); throw new ServerApiGenericException(e); } }
@Override public void onReplicationEvent(WanReplicationEvent replicationEvent) { Object eventObject = replicationEvent.getEventObject(); if (eventObject instanceof MapReplicationUpdate) { MapReplicationUpdate replicationUpdate = (MapReplicationUpdate) eventObject; EntryView entryView = replicationUpdate.getEntryView(); MapMergePolicy mergePolicy = replicationUpdate.getMergePolicy(); String mapName = replicationUpdate.getMapName(); MapContainer mapContainer = getMapContainer(mapName); MergeOperation operation = new MergeOperation( mapName, toData(entryView.getKey(), mapContainer.getPartitioningStrategy()), entryView, mergePolicy); try { int partitionId = nodeEngine.getPartitionService().getPartitionId(entryView.getKey()); Future f = nodeEngine .getOperationService() .invokeOnPartition(SERVICE_NAME, operation, partitionId); f.get(); } catch (Throwable t) { throw ExceptionUtil.rethrow(t); } } else if (eventObject instanceof MapReplicationRemove) { MapReplicationRemove replicationRemove = (MapReplicationRemove) eventObject; WanOriginatedDeleteOperation operation = new WanOriginatedDeleteOperation( replicationRemove.getMapName(), replicationRemove.getKey()); try { int partitionId = nodeEngine.getPartitionService().getPartitionId(replicationRemove.getKey()); Future f = nodeEngine .getOperationService() .invokeOnPartition(SERVICE_NAME, operation, partitionId); f.get(); } catch (Throwable t) { throw ExceptionUtil.rethrow(t); } } }
/** * Returns the local timestamp of when the geoloc sharing was initiated for outgoing geoloc * sharing or the local timestamp of when the geoloc sharing invitation was received for incoming * geoloc sharings. * * @return long * @throws RemoteException */ public long getTimestamp() throws RemoteException { try { GeolocTransferSession session = mRichcallService.getGeolocTransferSession(mSharingId); if (session == null) { return mPersistentStorage.getTimestamp(); } return session.getTimestamp(); } catch (ServerApiBaseException e) { if (!e.shouldNotBeLogged()) { sLogger.error(ExceptionUtil.getFullStackTrace(e)); } throw e; } catch (Exception e) { sLogger.error(ExceptionUtil.getFullStackTrace(e)); throw new ServerApiGenericException(e); } }
/** * Returns the reason code of the state of the geoloc sharing * * @return ReasonCode * @throws RemoteException */ public int getReasonCode() throws RemoteException { try { GeolocTransferSession session = mRichcallService.getGeolocTransferSession(mSharingId); if (session == null) { return mPersistentStorage.getReasonCode().toInt(); } return ReasonCode.UNSPECIFIED.toInt(); } catch (ServerApiBaseException e) { if (!e.shouldNotBeLogged()) { sLogger.error(ExceptionUtil.getFullStackTrace(e)); } throw e; } catch (Exception e) { sLogger.error(ExceptionUtil.getFullStackTrace(e)); throw new ServerApiGenericException(e); } }
/** * Returns the remote contact ID * * @return ContactId * @throws RemoteException */ public ContactId getRemoteContact() throws RemoteException { try { VideoStreamingSession session = mRichcallService.getVideoSharingSession(mSharingId); if (session == null) { return mPersistentStorage.getRemoteContact(); } return session.getRemoteContact(); } catch (ServerApiBaseException e) { if (!e.shouldNotBeLogged()) { sLogger.error(ExceptionUtil.getFullStackTrace(e)); } throw e; } catch (Exception e) { sLogger.error(ExceptionUtil.getFullStackTrace(e)); throw new ServerApiGenericException(e); } }
/** * 得到属性文件的值 * * @param fileName 从根目录开始。例如:"/conf/jdbc.properties"或"conf/jdbc.properties" * @param name 属性文件key * @return */ public static String getProperty(String fileName, String name) { fileName = checkAndModifyPath(fileName); ClassLoader cl = PropertyUtil.class.getClassLoader(); InputStream is = null; String str = null; try { is = new FileInputStream(URLDecoder.decode(cl.getResource(fileName).getFile(), "utf-8")); if (is != null) { Properties props = new Properties(); try { props.load(is); } catch (IOException e) { props = null; throw ExceptionUtil.convertExceptionToUnchecked(e); } if (props != null) { str = props.getProperty(name); if (str != null) { str = str.trim(); } } } } catch (FileNotFoundException e1) { e1.printStackTrace(); throw ExceptionUtil.convertExceptionToUnchecked(e1); } catch (UnsupportedEncodingException e) { e.printStackTrace(); throw ExceptionUtil.convertExceptionToUnchecked(e); } finally { if (is != null) { try { is.close(); } catch (IOException e) { e.printStackTrace(); } } } return str; }
@Override public void setAutoAccept(boolean enable) throws RemoteException { try { if (!mRcsSettings.isFtAutoAcceptedModeChangeable()) { throw new ServerApiUnsupportedOperationException("Auto accept mode is not changeable"); } mRcsSettings.setFileTransferAutoAccepted(enable); if (!enable) { /* If AA is disabled in normal conditions then it must be disabled while roaming. */ mRcsSettings.setFileTransferAutoAcceptedInRoaming(false); } } catch (ServerApiBaseException e) { if (!e.shouldNotBeLogged()) { mLogger.error(ExceptionUtil.getFullStackTrace(e)); } throw e; } catch (Exception e) { mLogger.error(ExceptionUtil.getFullStackTrace(e)); throw new ServerApiGenericException(e); } }
/** * Returns the direction of the sharing (incoming or outgoing) * * @return Direction * @throws RemoteException * @see Direction */ public int getDirection() throws RemoteException { try { GeolocTransferSession session = mRichcallService.getGeolocTransferSession(mSharingId); if (session == null) { return mPersistentStorage.getDirection().toInt(); } if (session.isInitiatedByRemote()) { return Direction.INCOMING.toInt(); } return Direction.OUTGOING.toInt(); } catch (ServerApiBaseException e) { if (!e.shouldNotBeLogged()) { sLogger.error(ExceptionUtil.getFullStackTrace(e)); } throw e; } catch (Exception e) { sLogger.error(ExceptionUtil.getFullStackTrace(e)); throw new ServerApiGenericException(e); } }
@Override public void setAutoAcceptInRoaming(boolean enable) throws RemoteException { try { if (!mRcsSettings.isFtAutoAcceptedModeChangeable()) { throw new ServerApiUnsupportedOperationException( "Auto accept mode in roaming is not changeable"); } if (!mRcsSettings.isFileTransferAutoAccepted()) { throw new ServerApiPermissionDeniedException( "Auto accept mode in normal conditions must be enabled"); } mRcsSettings.setFileTransferAutoAcceptedInRoaming(enable); } catch (ServerApiBaseException e) { if (!e.shouldNotBeLogged()) { mLogger.error(ExceptionUtil.getFullStackTrace(e)); } throw e; } catch (Exception e) { mLogger.error(ExceptionUtil.getFullStackTrace(e)); throw new ServerApiGenericException(e); } }
public T poll() { while (true) { Element<T> element = getFirstElement(); if (element == null) { return null; } try { _zkClient.delete(element.getName()); return element.getData(); } catch (ZkNoNodeException e) { // somebody else picked up the element first, so we have to // retry with the new first element } catch (Exception e) { throw ExceptionUtil.convertToRuntimeException(e); } } }
public MapMergePolicy getMergePolicy(String mergePolicyName) { MapMergePolicy mergePolicy = mergePolicyMap.get(mergePolicyName); if (mergePolicy == null && mergePolicyName != null) { try { // check if user has entered custom class name instead of policy name mergePolicy = ClassLoaderUtil.newInstance(nodeEngine.getConfigClassLoader(), mergePolicyName); mergePolicyMap.put(mergePolicyName, mergePolicy); } catch (Exception e) { logger.severe(e); throw ExceptionUtil.rethrow(e); } } if (mergePolicy == null) { return mergePolicyMap.get(MapConfig.DEFAULT_MAP_MERGE_POLICY); } return mergePolicy; }
/** * Loads the user settings for the config file if present if not it returns the default settings * * @return the loaded Settings object */ public static Settings loadSettings() { if (settings == null) { settings = new Settings(); if (CONFIG_FILE_LOCATION.exists()) { LOGGER.debug("Loading configuration from {}", CONFIG_FILE_LOCATION.getAbsolutePath()); Properties properties = new Properties(); try { properties.load(new FileInputStream(CONFIG_FILE_LOCATION)); applyFromPropertiesToSettings(settings, properties); } catch (IOException e) { LOGGER.error( "Could not read settings from {}", CONFIG_FILE_LOCATION.getAbsolutePath(), e); throw ExceptionUtil.getRuntimeException( "exceptions.settings.read", e, CONFIG_FILE_LOCATION.getAbsolutePath()); } } } return settings; }
@SuppressWarnings("unchecked") private Element<T> getFirstElement() { try { while (true) { List<String> list = _zkClient.getChildren(_root); if (list.size() == 0) { return null; } String elementName = getSmallestElement(list); try { return new Element<T>( _root + "/" + elementName, (T) _zkClient.readData(_root + "/" + elementName)); } catch (ZkNoNodeException e) { // somebody else picked up the element first, so we have to // retry with the new first element } } } catch (Exception e) { throw ExceptionUtil.convertToRuntimeException(e); } }
private ThreadUtil() { throw ExceptionUtil.nonInstantiableClass(getClass()); }
private static Properties getAsProperties(Settings settings) { Properties properties = new Properties(); properties.setProperty(WINDOW_X_PROPERTY, String.valueOf(settings.getWindowX())); properties.setProperty(WINDOW_Y_PROPERTY, String.valueOf(settings.getWindowY())); properties.setProperty(WINDOW_WIDTH_PROPERTY, String.valueOf(settings.getWindowWidth())); properties.setProperty(WINDOW_HEIGHT_PROPERTY, String.valueOf(settings.getWindowHeight())); properties.setProperty(WORK_HOURS_PROPERTY, String.valueOf(settings.getWorkHoursADay())); properties.setProperty( SHOW_ALL_WORKLOGS_PROPERTY, String.valueOf(settings.isShowAllWorklogs())); properties.setProperty(SHOW_STATISTICS_PROPERTY, String.valueOf(settings.isShowStatistics())); properties.setProperty(AUTOLOAD_DATA_PROPERTY, String.valueOf(settings.isLoadDataAtStartup())); properties.setProperty( SHOW_DECIMAL_HOURS_IN_EXCEL_REPORT, String.valueOf(settings.isShowDecimalHourTimesInExcelReport())); if (StringUtils.isNotBlank(settings.getYoutrackUrl())) { properties.setProperty(YOUTRACK_URL_PROPERTY, settings.getYoutrackUrl()); } if (StringUtils.isNotBlank(settings.getYoutrackOAuthHubUrl())) { properties.setProperty(YOUTRACK_OAUTH_HUB_URL, settings.getYoutrackOAuthHubUrl()); } if (StringUtils.isNotBlank(settings.getYoutrackUsername())) { properties.setProperty(YOUTRACK_USERNAME_PROPERTY, settings.getYoutrackUsername()); } properties.setProperty( YOUTRACK_AUTHENITCATION_METHOD_PROPERTY, settings.getYouTrackAuthenticationMethod().name()); if (StringUtils.isNotBlank(settings.getYoutrackOAuthServiceId())) { properties.setProperty( YOUTRACK_OAUTH_SERVICE_ID_PROPERTY, settings.getYoutrackOAuthServiceId()); } if (StringUtils.isNotBlank(settings.getYoutrackOAuthServiceSecret())) { try { properties.setProperty( YOUTRACK_OAUTH_SERVICE_SECRET, EncryptionUtil.encryptCleartextString(settings.getYoutrackOAuthServiceSecret())); } catch (GeneralSecurityException e) { LOGGER.error("Could not encrypt oauth service secret for settings file", e); throw ExceptionUtil.getIllegalStateException("exceptions.settings.oauthsecret.encrypt", e); } } if (StringUtils.isNotBlank(settings.getYoutrackPassword())) { try { properties.setProperty( YOUTRACK_PASSWORD_PROPERTY, EncryptionUtil.encryptCleartextString(settings.getYoutrackPassword())); } catch (GeneralSecurityException e) { LOGGER.error("Could not encrypt password for settings file", e); throw ExceptionUtil.getIllegalStateException("exceptions.settings.password.encrypt", e); } } if (settings.getLastUsedReportTimerange() != null) { properties.setProperty( AUTOLOAD_DATA_TIMERANGE_PROPERTY, settings.getLastUsedReportTimerange().name()); } properties.setProperty(COLLAPSE_STATE_PROPERTY, String.valueOf(settings.collapseState)); properties.setProperty(HIGHLIGHT_STATE_PROPERTY, String.valueOf(settings.highlightState)); return properties; }