xdi2.core.exceptions.Xdi2RuntimeException类的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(9.9k)|赞(0)|评价(0)|浏览(151)

本文整理了Java中xdi2.core.exceptions.Xdi2RuntimeException类的一些代码示例,展示了Xdi2RuntimeException类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Xdi2RuntimeException类的具体详情如下:
包路径:xdi2.core.exceptions.Xdi2RuntimeException
类名称:Xdi2RuntimeException

Xdi2RuntimeException介绍

暂无

代码示例

代码示例来源:origin: projectdanube/xdi2

@Override
public InterceptorResult before(Message message, ExecutionContext executionContext, ExecutionResult executionResult) throws Xdi2MessagingException {
  throw new Xdi2RuntimeException("Not implemented.");
}

代码示例来源: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

@Override
public void beginTransaction() {
  log.trace("beginTransaction()");
  if (this.transaction) throw new Xdi2RuntimeException("Already have an open transaction.");
  if (log.isDebugEnabled()) log.debug("Beginning Transaction...");
  try {
    this.load();
    this.transaction = true;
  } catch (Exception ex) {
    throw new Xdi2RuntimeException("Cannot begin transaction: " + ex.getMessage(), ex);
  }
  if (log.isDebugEnabled()) log.debug("Began transaction...");
}

代码示例来源: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 static String literalFromDigest(String input, String algorithm) {
  byte[] output;
  try {
    MessageDigest digest = MessageDigest.getInstance(algorithm);
    digest.update(input.getBytes(Charset.forName("UTF-8")));
    output = digest.digest();
  } catch (Exception ex) {
    throw new Xdi2RuntimeException(ex.getMessage(), ex);
  }
  String hex = new String(Hex.encodeHex(output));
  String literal = ":" + algorithm.toLowerCase().replace("-", "") + ":" + hex;
  return literal;
}

代码示例来源: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

public Graph createMessageDeferredPushResultGraph(Message message) {
  if (message == null) throw new NullPointerException();
  if (this.isFinished()) throw new Xdi2RuntimeException("Execution result has already been finished.", this.resultGraphFinishedEx);
  if (! this.messageDeferredPushResultGraphs.containsKey(message)) throw new Xdi2RuntimeException("No message deferred push result graph for message" + message);
  if (this.messageDeferredPushResultGraphs.get(message) != null) throw new Xdi2RuntimeException("Message deferred push result graph for message " + message + " has already been created.");
  Graph messageDeferredPushResultGraph = MemoryGraphFactory.getInstance().openGraph();
  this.messageDeferredPushResultGraphs.put(message, messageDeferredPushResultGraph);
  return messageDeferredPushResultGraph;
}

代码示例来源: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

void jsonDelete(String id) {
  if (log.isTraceEnabled()) log.trace("delete( " + id + " )");
  if (this.getLogEnabled()) this.logBuffer.append("delete( " + id + " )\n");
  try {
    this.jsonStore.delete(id);
    if (this.useCache) {
      for (Iterator<Entry<String, JsonObject>> iterator = this.jsonObjectsCached.entrySet().iterator(); iterator.hasNext(); ) {
        if (iterator.next().getKey().startsWith(id)) iterator.remove();
      }
    }
  } catch (IOException ex) {
    throw new Xdi2RuntimeException("Cannot delete JSON " + id + ": " + ex.getMessage(), ex);
  }
}

代码示例来源:origin: projectdanube/xdi2

void jsonSave(String id, JsonObject jsonObject) {
  if (log.isTraceEnabled()) log.trace("save( " + id + " , " + jsonObject + " )");
  if (this.getLogEnabled()) this.logBuffer.append("save( " + id + " , " + jsonObject + " )\n");
  try {
    this.jsonStore.save(id, jsonObject);
    if (this.useCache) {
      this.jsonObjectsCached.put(id, jsonObject);
    }
  } catch (IOException ex) {
    throw new Xdi2RuntimeException("Cannot save JSON at " + id + ": " + ex.getMessage(), ex);
  }
}

代码示例来源:origin: projectdanube/xdi2

@Override
public void save(MemoryGraph memoryGraph) {
  try {
    File file = new File(this.path);
    if (! file.exists()) {
      if (log.isDebugEnabled()) log.debug("File " + file.getAbsolutePath() + " does not exist. Creating file.");
      file.createNewFile();
    }
    if (log.isDebugEnabled()) log.debug("Saving file " + file.getAbsolutePath());
    Writer writer = new FileWriter(this.path);
    this.xdiWriter.write(memoryGraph, writer);
    writer.close();
  } catch (Exception ex) {
    throw new Xdi2RuntimeException("Cannot save file at " + this.path, ex);
  }
}

相关文章

Xdi2RuntimeException类方法