本文整理汇总了Java中com.helger.commons.state.ESuccess.FAILURE属性的典型用法代码示例。如果您正苦于以下问题:Java ESuccess.FAILURE属性的具体用法?Java ESuccess.FAILURE怎么用?Java ESuccess.FAILURE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.helger.commons.state.ESuccess
的用法示例。
在下文中一共展示了ESuccess.FAILURE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: _checkMPCOfPMode
/**
* Checks if the MPC that is contained in the PMode is valid.
*
* @param aPModeLeg
* the leg to get the MPCID
* @param aMPCMgr
* the MPC-Manager to search for the MPCID in the persisted data
* @param aLocale
* Locale to be used for the error messages
* @param aErrorList
* to write errors to if they occur
* @return Success if everything is all right, else Failure
*/
@Nonnull
private static ESuccess _checkMPCOfPMode (@Nonnull final PModeLeg aPModeLeg,
@Nonnull final MPCManager aMPCMgr,
@Nonnull final Locale aLocale,
@Nonnull final ErrorList aErrorList)
{
// Check if MPC is contained in PMode and if so, if it is valid
if (aPModeLeg.getBusinessInfo () != null)
{
final String sPModeMPC = aPModeLeg.getBusinessInfo ().getMPCID ();
if (sPModeMPC != null && !aMPCMgr.containsWithID (sPModeMPC))
{
s_aLogger.warn ("Error processing the usermessage, PMode-MPC ID '" + sPModeMPC + "' is invalid!");
aErrorList.add (EEbmsError.EBMS_PROCESSING_MODE_MISMATCH.getAsError (aLocale));
return ESuccess.FAILURE;
}
}
return ESuccess.SUCCESS;
}
示例2: runAtomic
/**
* Run the provided action within a locked section.
*
* @param aRunnable
* Callback to be executed
* @return {@link ESuccess#FAILURE} if the index is just closing
* @throws IOException
* may be thrown by the callback
*/
@Nonnull
public ESuccess runAtomic (@Nonnull final IThrowingRunnable <IOException> aRunnable) throws IOException
{
m_aLock.lock ();
try
{
if (isClosing ())
return ESuccess.FAILURE;
aRunnable.run ();
}
finally
{
m_aLock.unlock ();
}
return ESuccess.SUCCESS;
}
示例3: addServiceGroupToIndex
@Nonnull
public ESuccess addServiceGroupToIndex (@Nonnull final IParticipantIdentifier aParticipantID)
{
ValueEnforcer.notNull (aParticipantID, "ParticipantID");
final String sParticipantID = aParticipantID.getURIEncoded ();
final HttpPut aPut = new HttpPut (m_sPDIndexerURL);
aPut.setEntity (new StringEntity (sParticipantID, StandardCharsets.UTF_8));
try
{
if (executeRequest (aPut, new PDClientResponseHandler ()).isSuccess ())
{
s_aLogger.info ("Added service group '" +
sParticipantID +
"' to PEPPOL Directory index. May take some time until it shows up.");
return ESuccess.SUCCESS;
}
}
catch (final Throwable t)
{
m_aExceptionHdl.onException (aParticipantID, "addServiceGroupToIndex", t);
}
return ESuccess.FAILURE;
}
示例4: deleteServiceGroupFromIndex
@Nonnull
public ESuccess deleteServiceGroupFromIndex (@Nonnull final IParticipantIdentifier aParticipantID)
{
ValueEnforcer.notNull (aParticipantID, "ParticipantID");
final HttpDelete aDelete = new HttpDelete (m_sPDIndexerURL + aParticipantID.getURIPercentEncoded ());
try
{
if (executeRequest (aDelete, new PDClientResponseHandler ()).isSuccess ())
{
final String sParticipantID = aParticipantID.getURIEncoded ();
s_aLogger.info ("Removed service group '" +
sParticipantID +
"' from PEPPOL Directory index. May take some time until it is removed.");
return ESuccess.SUCCESS;
}
}
catch (final Throwable t)
{
m_aExceptionHdl.onException (aParticipantID, "deleteServiceGroupFromIndex", t);
}
return ESuccess.FAILURE;
}
示例5: write
@Nonnull
public final ESuccess write (@Nonnull final JAXBTYPE aObject,
@Nonnull final IJAXBMarshaller <JAXBTYPE> aMarshallerFunc)
{
ValueEnforcer.notNull (aObject, "Object");
ValueEnforcer.notNull (aMarshallerFunc, "MarshallerFunc");
try
{
final Marshaller aMarshaller = _createMarshaller ();
customizeMarshaller (aMarshaller);
final JAXBElement <JAXBTYPE> aJAXBElement = m_aJAXBElementWrapper.apply (aObject);
aMarshallerFunc.doMarshal (aMarshaller, aJAXBElement);
return ESuccess.SUCCESS;
}
catch (final JAXBException ex)
{
handleWriteException (ex);
}
return ESuccess.FAILURE;
}
示例6: writeTo
/**
* Write the current workbook to an output stream.
*
* @param aOS
* The output stream to write to. May not be <code>null</code>. Is
* automatically closed independent of the success state.
* @return {@link ESuccess}
*/
@Nonnull
public ESuccess writeTo (@Nonnull @WillClose final OutputStream aOS)
{
try
{
ValueEnforcer.notNull (aOS, "OutputStream");
if (m_nCreatedCellStyles > 0 && s_aLogger.isDebugEnabled ())
s_aLogger.debug ("Writing Excel workbook with " + m_nCreatedCellStyles + " different cell styles");
m_aWB.write (aOS);
return ESuccess.SUCCESS;
}
catch (final IOException ex)
{
if (!StreamHelper.isKnownEOFException (ex))
s_aLogger.error ("Failed to write Excel workbook to output stream " + aOS, ex);
return ESuccess.FAILURE;
}
finally
{
StreamHelper.close (aOS);
}
}
示例7: writeToFile
/**
* Write a Micro Node to a file.
*
* @param aNode
* The node to be serialized. May be any kind of node (incl.
* documents). May not be <code>null</code>.
* @param aFile
* The file to write to. May not be <code>null</code>.
* @param aSettings
* The settings to be used for the creation. May not be
* <code>null</code>.
* @return {@link ESuccess}
*/
@Nonnull
public static ESuccess writeToFile (@Nonnull final IMicroNode aNode,
@Nonnull final File aFile,
@Nonnull final IXMLWriterSettings aSettings)
{
ValueEnforcer.notNull (aFile, "File");
final OutputStream aOS = FileHelper.getOutputStream (aFile);
if (aOS == null)
return ESuccess.FAILURE;
// No need to wrap the OS in a BufferedOutputStream as inside, it is later
// on wrapped in a BufferedWriter
return writeToStream (aNode, aOS, aSettings);
}
示例8: release
@Nonnull
public static ESuccess release (@Nullable final FileLock aFileLock)
{
if (aFileLock != null)
{
try
{
aFileLock.release ();
return ESuccess.SUCCESS;
}
catch (final IOException ex)
{
s_aLogger.error ("Failed to release object " + aFileLock, ex instanceof IMockException ? null : ex);
}
}
return ESuccess.FAILURE;
}
示例9: changeParent
@Nonnull
public final ESuccess changeParent (@Nonnull final ITEMTYPE aNewParent)
{
ValueEnforcer.notNull (aNewParent, "NewParent");
// no change so far
if (getParent () == aNewParent)
return ESuccess.SUCCESS;
// cannot make a child of this, this' new parent.
final ITEMTYPE aThis = thisAsT ();
if (aNewParent.isSameOrChildOf (aThis))
return ESuccess.FAILURE;
// add this to the new parent
if (getParent ().removeChild (aThis).isUnchanged ())
throw new IllegalStateException ("Failed to remove this from parent!");
// Remember new parent!
m_aParent = aNewParent;
return ESuccess.valueOfChange (aNewParent.internalAddChild (aThis));
}
示例10: sleep
/**
* Sleep the current thread for a certain amount of time
*
* @param nMilliseconds
* The milliseconds to sleep. Must be ≥ 0.
* @return {@link ESuccess#SUCCESS} if sleeping was not interrupted,
* {@link ESuccess#FAILURE} if sleeping was interrupted
*/
@Nonnull
public static ESuccess sleep (@Nonnegative final long nMilliseconds)
{
ValueEnforcer.isGE0 (nMilliseconds, "MilliSeconds");
try
{
Thread.sleep (nMilliseconds);
return ESuccess.SUCCESS;
}
catch (final InterruptedException ex)
{
return ESuccess.FAILURE;
}
}
示例11: setDefaultDateTimeZoneID
/**
* Set the default date time zone to use. This effects all objects created via
* {@link PDTFactory} as well as the default JDK TimeZone.
*
* @param sDateTimeZoneID
* Must be a valid, non-<code>null</code> time zone.
* @return {@link ESuccess}
*/
@Nonnull
public static ESuccess setDefaultDateTimeZoneID (@Nonnull @Nonempty final String sDateTimeZoneID)
{
ValueEnforcer.notEmpty (sDateTimeZoneID, "DateTimeZoneID");
try
{
// Try to resolve ID -> throws exception if unknown
final ZoneId aDefaultZoneId = ZoneId.of (sDateTimeZoneID);
// getTimeZone falls back to GMT if unknown
final TimeZone aDefaultTimeZone = TimeZone.getTimeZone (aDefaultZoneId);
s_aDefaultZoneId = aDefaultZoneId;
TimeZone.setDefault (aDefaultTimeZone);
return ESuccess.SUCCESS;
}
catch (final DateTimeException ex)
{
// time zone ID is unknown
s_aLogger.warn ("Unsupported ZoneId '" + sDateTimeZoneID + "'", ex);
return ESuccess.FAILURE;
}
}
示例12: closeWithoutFlush
/**
* Close the passed object, without trying to call flush on it.
*
* @param aCloseable
* The object to be closed. May be <code>null</code>.
* @return {@link ESuccess#SUCCESS} if the object was successfully closed.
*/
@Nonnull
public static ESuccess closeWithoutFlush (@Nullable @WillClose final AutoCloseable aCloseable)
{
if (aCloseable != null)
{
try
{
// close stream
aCloseable.close ();
return ESuccess.SUCCESS;
}
catch (final Exception ex)
{
if (!isKnownEOFException (ex))
s_aLogger.error ("Failed to close object " + aCloseable.getClass ().getName (),
ex instanceof IMockException ? null : ex);
}
}
return ESuccess.FAILURE;
}
示例13: handleResponse
@Nullable
public ESuccess handleResponse (final HttpResponse aHttpResponse) throws ClientProtocolException, IOException
{
final StatusLine aStatusLine = aHttpResponse.getStatusLine ();
// Check result
if (aStatusLine.getStatusCode () >= 200 && aStatusLine.getStatusCode () < 300)
return ESuccess.SUCCESS;
// Not found
if (aStatusLine.getStatusCode () == 404)
return ESuccess.FAILURE;
// Unexpected
final HttpEntity aEntity = aHttpResponse.getEntity ();
String sContent = null;
if (aEntity != null)
{
ContentType aContentType = ContentType.get (aEntity);
if (aContentType == null)
aContentType = ContentType.DEFAULT_TEXT;
// Default to UTF-8 internally
Charset aCharset = aContentType.getCharset ();
if (aCharset == null)
aCharset = StandardCharsets.UTF_8;
sContent = EntityUtils.toString (aEntity, aCharset);
}
String sMessage = aStatusLine.getReasonPhrase () + " [" + aStatusLine.getStatusCode () + "]";
if (sContent != null)
sMessage += "\nResponse content: " + sContent;
throw new HttpResponseException (aStatusLine.getStatusCode (), sMessage);
}
示例14: close
@Nonnull
public static ESuccess close (@Nullable final Channel aChannel)
{
if (aChannel != null && aChannel.isOpen ())
return StreamHelper.close (aChannel);
return ESuccess.FAILURE;
}
示例15: write
@Nonnull
public ESuccess write (@Nonnull final JAXBTYPE aJAXBDocument,
@Nonnull final IJAXBMarshaller <JAXBTYPE> aMarshallerFunc)
{
ValueEnforcer.notNull (aJAXBDocument, "JAXBDocument");
ValueEnforcer.notNull (aMarshallerFunc, "MarshallerFunc");
// Avoid class cast exception later on
if (!m_aDocType.getImplementationClass ().getPackage ().equals (aJAXBDocument.getClass ().getPackage ()))
{
s_aLogger.error ("You cannot write a '" +
aJAXBDocument.getClass () +
"' as a " +
m_aDocType.getImplementationClass ().getPackage ().getName ());
return ESuccess.FAILURE;
}
try
{
final Marshaller aMarshaller = createMarshaller ();
// Customize on demand
final Consumer <? super Marshaller> aCustomizer = getMarshallerCustomizer ();
if (aCustomizer != null)
aCustomizer.accept (aMarshaller);
// start marshalling
final JAXBElement <JAXBTYPE> aJAXBElement = createJAXBElement (aJAXBDocument);
aMarshallerFunc.doMarshal (aMarshaller, aJAXBElement);
return ESuccess.SUCCESS;
}
catch (final JAXBException ex)
{
exceptionCallbacks ().forEach (x -> x.onException (ex));
}
return ESuccess.FAILURE;
}