本文整理了Java中xdi2.core.exceptions.Xdi2RuntimeException.<init>()
方法的一些代码示例,展示了Xdi2RuntimeException.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Xdi2RuntimeException.<init>()
方法的具体详情如下:
包路径:xdi2.core.exceptions.Xdi2RuntimeException
类名称:Xdi2RuntimeException
方法名:<init>
暂无
代码示例来源:origin: projectdanube/xdi2
public void addException(Throwable ex) {
if (ex == null) throw new NullPointerException();
if (this.isFinished()) throw new Xdi2RuntimeException("Execution result has already been finished.", this.resultGraphFinishedEx);
if (this.ex != null) throw new Xdi2RuntimeException("Already have an exception.");
this.ex = ex;
}
代码示例来源:origin: projectdanube/xdi2
public Graph getFinishedOperationResultGraph(Operation operation) {
if (operation == null) throw new NullPointerException();
if (! this.isFinished()) throw new Xdi2RuntimeException("Execution result has not been finished yet.", this.resultGraphFinishedEx);
if (! this.operationResultGraphs.containsKey(operation)) throw new Xdi2RuntimeException("No operation result graph for operation " + operation);
return this.operationResultGraphs.get(operation);
}
代码示例来源:origin: projectdanube/xdi2
public Graph getFinishedMessageDeferredPushResultGraph(Message message) {
if (message == null) throw new NullPointerException();
if (! this.isFinished()) throw new Xdi2RuntimeException("Execution result has not been finished yet.", this.resultGraphFinishedEx);
if (! this.messageDeferredPushResultGraphs.containsKey(message)) throw new Xdi2RuntimeException("No message deferred push result graph for message " + message);
return this.messageDeferredPushResultGraphs.get(message);
}
代码示例来源:origin: projectdanube/xdi2
public static Date stringToTimestamp(String string) {
if (string == null) return null;
if (string.charAt(string.length() - 1) == 'Z') string = string.substring(0, string.length() - 1) + "UTC";
for (DateFormat dateFormat : XDITimestampsConstants.FORMATS_TIMESTAMP) {
try {
return dateFormat.parse(string);
} catch (ParseException ex) {
continue;
}
}
throw new Xdi2RuntimeException("Cannot parse timestamp: " + string);
}
代码示例来源:origin: projectdanube/xdi2
@Override
public void commitTransaction() {
log.trace("commitTransaction()");
if (! this.transaction) throw new Xdi2RuntimeException("No open transaction.");
try {
this.save();
this.transaction = false;
} catch (Exception ex) {
throw new Xdi2RuntimeException("Cannot commit transaction: " + ex.getMessage(), ex);
}
if (log.isDebugEnabled()) log.debug("Committed transaction...");
}
代码示例来源:origin: projectdanube/xdi2
private void load() {
this.properties = new Properties();
try {
File file = new File(this.path);
if (! file.exists()) return;
Reader reader = new FileReader(this.path);
this.properties.load(reader);
reader.close();
} catch (Exception ex) {
throw new Xdi2RuntimeException("Cannot load properties file at " + this.path, ex);
}
}
代码示例来源:origin: projectdanube/xdi2
private void save() {
try {
File file = new File(this.path);
if (! file.exists()) file.createNewFile();
Writer writer = new FileWriter(file);
this.properties.store(writer, null);
writer.close();
} catch (Exception ex) {
throw new Xdi2RuntimeException("Cannot save properties file at " + this.path, ex);
}
}
代码示例来源:origin: projectdanube/xdi2
@Override
public void rollbackTransaction() {
log.trace("rollbackTransaction()");
if (! this.transaction) throw new Xdi2RuntimeException("No open transaction.");
try {
this.load();
this.transaction = false;
} catch (Exception ex) {
throw new Xdi2RuntimeException("Cannot roll back transaction: " + ex.getMessage(), ex);
}
if (log.isDebugEnabled()) log.debug("Rolled back transaction...");
}
代码示例来源:origin: projectdanube/xdi2
@Override
public PublicKey convert(String string) {
PublicKey publicKey;
try {
X509EncodedKeySpec keySpec = new X509EncodedKeySpec(Base64.decodeBase64(string.getBytes(Charset.forName("UTF-8"))));
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
publicKey = keyFactory.generatePublic(keySpec);
} catch (GeneralSecurityException ex) {
throw new Xdi2RuntimeException("Invalid RSA public key " + string + ": " + ex.getMessage(), ex);
}
return publicKey;
}
}
代码示例来源:origin: projectdanube/xdi2
private static String filename(String prefix, String id) {
StringBuilder buffer = new StringBuilder();
try {
if (prefix != null) {
buffer.append(URLEncoder.encode(prefix, "UTF-8"));
buffer.append("-");
}
buffer.append(Hex.encodeHex(id.getBytes(Charset.forName("UTF-8"))));
} catch (UnsupportedEncodingException ex) {
throw new Xdi2RuntimeException(ex.getMessage(), ex);
}
return buffer.toString();
}
代码示例来源:origin: projectdanube/xdi2
public Graph createOperationResultGraph(Operation operation) {
if (operation == null) throw new NullPointerException();
if (this.isFinished()) throw new Xdi2RuntimeException("Execution result has already been finished.", this.resultGraphFinishedEx);
if (! this.operationResultGraphs.containsKey(operation)) throw new Xdi2RuntimeException("No operation result graph for operation " + operation);
if (this.operationResultGraphs.get(operation) != null) throw new Xdi2RuntimeException("Operation result graph for operation " + operation + " has already been created.");
Graph operationResultGraph = MemoryGraphFactory.getInstance().openGraph();
this.operationResultGraphs.put(operation, operationResultGraph);
return operationResultGraph;
}
代码示例来源:origin: projectdanube/xdi2
@Override
public boolean[] evaluateInternal(PolicyEvaluationContext policyEvaluationContext) {
Iterator<Condition> conditions = this.getConditions();
if (conditions == null) throw new Xdi2RuntimeException("Missing or invalid condition in $true operator.");
List<Boolean> values = new ArrayList<Boolean> ();
while (conditions.hasNext()) values.add(Boolean.valueOf(true == conditions.next().evaluate(policyEvaluationContext)));
boolean[] result = new boolean[values.size()];
for (int i=0; i<values.size(); i++) result[i] = values.get(i).booleanValue();
return result;
}
}
代码示例来源:origin: projectdanube/xdi2
@Override
public boolean[] evaluateInternal(PolicyEvaluationContext policyEvaluationContext) {
Iterator<Condition> conditions = this.getConditions();
if (conditions == null) throw new Xdi2RuntimeException("Missing or invalid condition in $false operator.");
List<Boolean> values = new ArrayList<Boolean> ();
while (conditions.hasNext()) values.add(Boolean.valueOf(false == conditions.next().evaluate(policyEvaluationContext)));
boolean[] result = new boolean[values.size()];
for (int i=0; i<values.size(); i++) result[i] = values.get(i).booleanValue();
return result;
}
}
代码示例来源:origin: projectdanube/xdi2
private void processSend(MessageBase<?> forwardingMessageOrMessageTemplate, SendOperation operation, Graph operationResultGraph, ExecutionContext executionContext) throws Xdi2MessagingException {
if (forwardingMessageOrMessageTemplate instanceof Message) {
this.processSendMessage((Message) forwardingMessageOrMessageTemplate, operation, operationResultGraph, executionContext);
} else if (forwardingMessageOrMessageTemplate instanceof MessageTemplate) {
this.processSendMessageTemplate((MessageTemplate) forwardingMessageOrMessageTemplate, operation, operationResultGraph, executionContext);
} else {
throw new Xdi2RuntimeException("Unexpected message (template): " + forwardingMessageOrMessageTemplate.getClass().getSimpleName());
}
}
代码示例来源:origin: projectdanube/xdi2
/**
* Returns an XSD data type for an XDI address.
*/
public static String xsdTypeFromDataTypeXDIAddress(XDIAddress dataTypeXDIAddress) {
if (XDIAddressUtil.startsWithXDIAddress(dataTypeXDIAddress, XDI_ADD_DATATYPE_XSD) == null) throw new Xdi2RuntimeException("Invalid XSD data type address: " + dataTypeXDIAddress);
XDIAddress xsdTypeXDIAddress = dataTypeXDIAddress;
return xsdTypeXDIAddress.toString().substring(1).replace(XDIConstants.CS_CLASS_RESERVED.toString(), ":");
}
代码示例来源:origin: projectdanube/xdi2
public static Object stringToLiteralData(String string) {
if (string == null) throw new NullPointerException();
if (string.isEmpty()) throw new IllegalArgumentException("Invalid empty literal string.");
try {
JsonArray jsonArray = gson.getAdapter(JsonArray.class).fromJson("[" + string + "]");
return jsonElementToLiteralData(jsonArray.get(0));
} catch (IOException ex) {
throw new Xdi2RuntimeException("Invalid literal string \"" + string + "\": " + ex.getMessage(), ex);
}
}
代码示例来源:origin: projectdanube/xdi2
@Override
public String toString(String format, Properties parameters) {
if (format == null) format = XDIWriterRegistry.getDefault().getFormat();
XDIWriter writer = XDIWriterRegistry.forFormat(format, parameters);
if (writer == null) throw new Xdi2RuntimeException("Unknown format for XDI serialization: " + format);
StringWriter buffer = new StringWriter();
try {
writer.write(this, buffer);
} catch (IOException ex) {
return "[Exception: " + ex.getMessage() + "]";
}
return buffer.toString();
}
代码示例来源:origin: projectdanube/xdi2
@Override
public void load(MemoryGraph memoryGraph) {
memoryGraph.clear();
try {
if (log.isDebugEnabled()) log.debug("Loading URL " + this.getUrl());
InputStream stream = this.getUrl().openStream();
this.xdiReader.read(memoryGraph, stream);
stream.close();
} catch (Exception ex) {
throw new Xdi2RuntimeException("Cannot load URL at " + this.getUrl(), ex);
}
}
代码示例来源:origin: projectdanube/xdi2
/**
* Returns an XSD data type for a JSON data type.
*/
public static String jsonTypeFromDataTypeXDIAddress(XDIAddress dataTypeXDIAddress) {
if (XDIAddressUtil.startsWithXDIAddress(dataTypeXDIAddress, XDI_ADD_DATATYPE_JSON) == null) throw new Xdi2RuntimeException("Invalid JSON data type address: " + dataTypeXDIAddress);
XDIAddress jsonTypeXDIAddress = XDIAddressUtil.localXDIAddress(dataTypeXDIAddress, - XDI_ADD_DATATYPE_JSON.getNumXDIArcs());
return jsonTypeXDIAddress.toString().substring(1);
}
代码示例来源:origin: projectdanube/xdi2
private void initDefault() {
try {
this.registryCache = CacheManager.getInstance().getCache("registry-cache");
this.authorityCache = CacheManager.getInstance().getCache("authority-cache");
} catch (CacheException ex) {
throw new Xdi2RuntimeException("Cannot initialize cache: " + ex.getMessage(), ex);
}
}
内容来源于网络,如有侵权,请联系作者删除!