List of usage examples for org.apache.commons.lang.builder ToStringBuilder reflectionToString
public static String reflectionToString(Object object, ToStringStyle style)
Forwards to ReflectionToStringBuilder
.
From source file:org.jtalks.tests.jcommune.webdriver.User.java
@Override public String toString() { return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE) .replace(getClass().getSimpleName(), "User"); }
From source file:org.kuali.rice.krms.test.ValidationIntegrationTest.java
private void print(EngineResults engineResults) { System.out.println(ToStringBuilder.reflectionToString(engineResults, ToStringStyle.MULTI_LINE_STYLE)); }
From source file:org.mule.module.gcm.CcsConnector.java
/** * Connect and authenticate to the CSS server. * //from w ww.jav a2 s .c o m * @param projectId The project ID (aka sender ID). * @throws ConnectionException throw in case connecting to the CCS server fails. */ @Connect public void connect(@ConnectionKey final String projectId) throws ConnectionException { this.projectId = projectId; try { final ConnectionConfiguration config = new ConnectionConfiguration("gcm.googleapis.com", 5235); config.setCompressionEnabled(true); config.setSASLAuthenticationEnabled(true); config.setSocketFactory(SSLSocketFactory.getDefault()); xmppConnection = new XMPPConnection(config); xmppConnection.connect(); if (!xmppConnection.isConnected()) { throw new ConnectionException(ConnectionExceptionCode.CANNOT_REACH, null, "XMPP connection failed to: " + ToStringBuilder.reflectionToString(config, ToStringStyle.SHORT_PREFIX_STYLE)); } } catch (final XMPPException xmppe) { throw new ConnectionException(ConnectionExceptionCode.CANNOT_REACH, null, xmppe.getMessage(), xmppe); } try { xmppConnection.login(getLoginUser(), getApiKey()); xmppConnection.getChatManager().addChatListener(new ChatManagerListener() { @Override public void chatCreated(final Chat chat, final boolean createdLocally) { if (!createdLocally) { CcsConnector.this.chat = chat; chat.addMessageListener(new MessageListener() { @Override public void processMessage(final Chat chat, final Message message) { try { handleInboundMessage(message); } catch (final Exception e) { logger.error("Failed to handle inbound message: " + message, e); } } }); } } }); } catch (final XMPPException xmppe) { throw new ConnectionException(ConnectionExceptionCode.INCORRECT_CREDENTIALS, null, xmppe.getMessage(), xmppe); } }
From source file:org.mule.module.redis.RedisModule.java
@PostConstruct public void initializeJedis() { jedisPool = new JedisPool(poolConfig, host, port, connectionTimeout, password); LOGGER.info(String.format(/*from w ww.j a v a2 s. c om*/ "Redis connector ready, host: %s, port: %d, timeout: %d, password: %s, pool config: %s", host, port, connectionTimeout, StringUtils.repeat("*", StringUtils.length(password)), ToStringBuilder.reflectionToString(poolConfig, ToStringStyle.SHORT_PREFIX_STYLE))); }
From source file:org.opencastproject.publication.youtube.YouTubeV3PublicationServiceImpl.java
/** * Publishes the element to the publication channel and returns a reference to the published version of the element. * * @param job/*from w ww . ja v a 2 s .c o m*/ * the associated job * @param mediaPackage * the mediapackage * @param elementId * the mediapackage element id to publish * @return the published element * @throws PublicationException * if publication fails */ private Publication publish(final Job job, final MediaPackage mediaPackage, final String elementId) throws PublicationException { if (mediaPackage == null) { throw new IllegalArgumentException("Mediapackage must be specified"); } else if (elementId == null) { throw new IllegalArgumentException("Mediapackage ID must be specified"); } final MediaPackageElement element = mediaPackage.getElementById(elementId); if (element == null) { throw new IllegalArgumentException("Mediapackage element must be specified"); } if (element.getIdentifier() == null) { throw new IllegalArgumentException("Mediapackage element must have an identifier"); } if (element.getMimeType().toString().matches("text/xml")) { throw new IllegalArgumentException("Mediapackage element cannot be XML"); } try { // create context strategy for publication final YouTubePublicationAdapter c = new YouTubePublicationAdapter(mediaPackage, workspace); final File file = workspace.get(element.getURI()); final String episodeName = c.getEpisodeName(); final UploadProgressListener operationProgressListener = new UploadProgressListener(mediaPackage, file); final String privacyStatus = makeVideosPrivate ? "private" : "public"; final VideoUpload videoUpload = new VideoUpload(truncateTitleToMaxFieldLength(episodeName, false), c.getEpisodeDescription(), privacyStatus, file, operationProgressListener, tags); final Video video = youTubeService.addVideoToMyChannel(videoUpload); final int timeoutMinutes = 60; final long startUploadMilliseconds = new Date().getTime(); while (!operationProgressListener.isComplete()) { Thread.sleep(POLL_MILLISECONDS); final long howLongWaitingMinutes = (new Date().getTime() - startUploadMilliseconds) / 60000; if (howLongWaitingMinutes > timeoutMinutes) { throw new PublicationException( "Upload to YouTube exceeded " + timeoutMinutes + " minutes for episode " + episodeName); } } String playlistName = StringUtils .trimToNull(truncateTitleToMaxFieldLength(mediaPackage.getSeriesTitle(), true)); playlistName = (playlistName == null) ? this.defaultPlaylist : playlistName; final Playlist playlist; final Playlist existingPlaylist = youTubeService.getMyPlaylistByTitle(playlistName); if (existingPlaylist == null) { playlist = youTubeService.createPlaylist(playlistName, c.getContextDescription(), mediaPackage.getSeries()); } else { playlist = existingPlaylist; } youTubeService.addPlaylistItem(playlist.getId(), video.getId()); // Create new publication element final URL url = new URL("http://www.youtube.com/watch?v=" + video.getId()); return PublicationImpl.publication(UUID.randomUUID().toString(), CHANNEL_NAME, url.toURI(), MimeTypes.parseMimeType(MIME_TYPE)); } catch (Exception e) { logger.error("failed publishing to Youtube", e); logger.warn("Error publishing {}, {}", element, e.getMessage()); if (e instanceof PublicationException) { throw (PublicationException) e; } else { throw new PublicationException("YouTube publish failed on job: " + ToStringBuilder.reflectionToString(job, ToStringStyle.MULTI_LINE_STYLE), e); } } }
From source file:org.opencastproject.publication.youtube.YouTubeV3PublicationServiceImpl.java
/** * Retracts the mediapackage from YouTube. * * @param job//w ww.j a v a2 s . c o m * the associated job * @param mediaPackage * the mediapackage * @throws PublicationException * if retract did not work */ private Publication retract(final Job job, final MediaPackage mediaPackage) throws PublicationException { logger.info("Retract video from YouTube: {}", mediaPackage); Publication youtube = null; for (Publication publication : mediaPackage.getPublications()) { if (CHANNEL_NAME.equals(publication.getChannel())) { youtube = publication; break; } } if (youtube == null) { return null; } final YouTubePublicationAdapter contextStrategy = new YouTubePublicationAdapter(mediaPackage, workspace); final String episodeName = contextStrategy.getEpisodeName(); try { retract(mediaPackage.getSeriesTitle(), episodeName); } catch (final Exception e) { logger.error("Failure retracting YouTube media {}", e.getMessage()); throw new PublicationException("YouTube media retract failed on job: " + ToStringBuilder.reflectionToString(job, ToStringStyle.MULTI_LINE_STYLE), e); } return youtube; }
From source file:org.openehr.am.parser.Parsed.java
public String toString() { return ToStringBuilder.reflectionToString(this, style); }
From source file:org.openvpms.component.business.domain.im.archetype.descriptor.AssertionDescriptor.java
@Override public String toString() { return ToStringBuilder.reflectionToString(this, STYLE); }
From source file:org.powerassert.synthetic.ExpressionRenderer.java
private String renderValue(Object value) { String str;// w w w .j a v a 2 s. c o m if (value == null) str = "null"; else if (value.getClass().isArray()) { // recursive string join str = "["; for (Object o : toArray(value)) { str += renderValue(o) + ", "; } str = (str.length() > 1 ? str.substring(0, str.length() - 2) : "") + "]"; } else { try { if (value.getClass().getMethod("toString").getDeclaringClass() == Object.class) { str = ToStringBuilder.reflectionToString(value, ToStringStyle.SHORT_PREFIX_STYLE); } else str = value.toString(); } catch (NoSuchMethodException e) { str = value.toString(); } } return showTypes && value != null ? str + " (" + value.getClass().getName() + ")" : str; }
From source file:org.raml.jaxrs.codegen.core.AbstractGenerator.java
private void addJsr303Annotations(final AbstractParam parameter, final JVar argumentVariable) { if (isNotBlank(parameter.getPattern())) { LOGGER.info("Pattern constraint ignored for parameter: " + ToStringBuilder.reflectionToString(parameter, SHORT_PREFIX_STYLE)); }/* w w w . j a v a 2 s. com*/ final Integer minLength = parameter.getMinLength(); final Integer maxLength = parameter.getMaxLength(); if ((minLength != null) || (maxLength != null)) { final JAnnotationUse sizeAnnotation = argumentVariable.annotate(Size.class); if (minLength != null) { sizeAnnotation.param("min", minLength); } if (maxLength != null) { sizeAnnotation.param("max", maxLength); } } final BigDecimal minimum = parameter.getMinimum(); if (minimum != null) { addMinMaxConstraint(parameter, "minimum", Min.class, minimum, argumentVariable); } final BigDecimal maximum = parameter.getMaximum(); if (maximum != null) { addMinMaxConstraint(parameter, "maximum", Max.class, maximum, argumentVariable); } if (parameter.isRequired()) { argumentVariable.annotate(NotNull.class); } }