public static PID pidFromFilename(String filename) throws MalformedPidException { try { return PID.fromFilename(filename); } catch (MalformedPIDException e) { throw new MalformedPidException(e.getMessage()); } }
private static char getNormalizedHexChar(char c) throws MalformedPIDException { if (c >= '0' && c <= '9') { return c; } if (c >= 'A' && c <= 'F') { return c; } if (c >= 'a' && c <= 'f') { return Character.toUpperCase(c); } throw new MalformedPIDException("Bad hex-digit in PID object-id: " + c); }
public static PID getPID(String pidString) throws MalformedPidException { try { return new PID(pidString); } catch (MalformedPIDException e) { throw new MalformedPidException(e.getMessage()); } }
private static char getNormalizedHexChar(char c) throws MalformedPIDException { if (c >= '0' && c <= '9') { return c; } if (c >= 'A' && c <= 'F') { return c; } if (c >= 'a' && c <= 'f') { return Character.toUpperCase(c); } throw new MalformedPIDException("Bad hex-digit in PID object-id: " + c); }
public static PID pidFromFilename(String filename) throws MalformedPidException { try { return PID.fromFilename(filename); } catch (MalformedPIDException e) { throw new MalformedPidException(e.getMessage()); } }
/** * Return the normalized form of the given pid string, or throw a * MalformedPIDException. * @param pidString * @return String normalized version of the pid * @throws MalformedPIDException */ public static String normalize(String pidString) throws MalformedPIDException { if (pidString == null) { throw new MalformedPIDException("PID is null."); } return normalize(pidString, 0, pidString.length()); }
public static PID getPID(String pidString) throws MalformedPidException { try { return new PID(pidString); } catch (MalformedPIDException e) { throw new MalformedPidException(e.getMessage()); } }
/** * Return the normalized form of the given pid string, or throw a * MalformedPIDException. * @param pidString * @return String normalized version of the pid * @throws MalformedPIDException */ public static String normalize(String pidString) throws MalformedPIDException { if (pidString == null) { throw new MalformedPIDException("PID is null."); } return normalize(pidString, 0, pidString.length()); }
/** * Factory method that throws an unchecked exception if it's not * well-formed. * @param pidString the String value of the PID * @return PID */ public static PID getInstance(String pidString) { try { return new PID(pidString); } catch (MalformedPIDException e) { throw new FaultException("Malformed PID: " + e.getMessage(), e); } }
inObjectID = true; } else { throw new MalformedPIDException("Error in PID after first '%': expected '3a' or '3A', but saw '3" + c + "'."); throw new MalformedPIDException("Error in PID after first '%': expected '3a' or '3A', but saw '" + pidString.substring(i, i + 2) + "'."); throw new MalformedPIDException("Error in PID after first '%': expected '3a' or '3A', but saw '" + pidString.substring(i + 1) + "'."); throw new MalformedPIDException("PID namespace-id cannot contain '" + c + "' character."); out.append(new char[]{'%', h1, h2}); } else { throw new MalformedPIDException("PID object-id ended early: need at least 2 chars after '%'."); throw new MalformedPIDException("PID object-id cannot contain '" + c + "' character."); throw new MalformedPIDException("PID delimiter (:) is missing."); throw new MalformedPIDException("PID namespace-id cannot be empty."); throw new MalformedPIDException("PID object-id cannot be empty."); throw new MalformedPIDException("PID length exceeds " + MAX_LENGTH + ".");
/** * Factory method that throws an unchecked exception if it's not * well-formed. * @param pidString the String value of the PID * @return PID */ public static PID getInstance(String pidString) { try { return new PID(pidString); } catch (MalformedPIDException e) { throw new FaultException("Malformed PID: " + e.getMessage(), e); } }
inObjectID = true; } else { throw new MalformedPIDException("Error in PID after first '%': expected '3a' or '3A', but saw '3" + c + "'."); throw new MalformedPIDException("Error in PID after first '%': expected '3a' or '3A', but saw '" + pidString.substring(i, i + 2) + "'."); throw new MalformedPIDException("Error in PID after first '%': expected '3a' or '3A', but saw '" + pidString.substring(i + 1) + "'."); throw new MalformedPIDException("PID namespace-id cannot contain '" + c + "' character."); out.append(new char[]{'%', h1, h2}); } else { throw new MalformedPIDException("PID object-id ended early: need at least 2 chars after '%'."); throw new MalformedPIDException("PID object-id cannot contain '" + c + "' character."); throw new MalformedPIDException("PID delimiter (:) is missing."); throw new MalformedPIDException("PID namespace-id cannot be empty."); throw new MalformedPIDException("PID object-id cannot be empty."); throw new MalformedPIDException("PID length exceeds " + MAX_LENGTH + ".");
/** * Generate a new pid that is guaranteed to be unique, within the given * namespace. */ public synchronized PID generatePID(String namespace) throws IOException { int i = getHighestID(namespace); i++; try { m_lastPID = new PID(namespace + ":" + i); } catch (MalformedPIDException e) { throw new IOException(e.getMessage()); } setHighestID(namespace, i); return m_lastPID; }
/** * Generate a new pid that is guaranteed to be unique, within the given * namespace. */ public synchronized PID generatePID(String namespace) throws IOException { int i = getHighestID(namespace); i++; try { m_lastPID = new PID(namespace + ":" + i); } catch (MalformedPIDException e) { throw new IOException(e.getMessage()); } setHighestID(namespace, i); return m_lastPID; }
} catch (MalformedPIDException e) { throw new PolicyStoreException("Invalid policy name '" + name + "'. Could not create a valid PID from this name: " + e.getMessage(), e);
/** * Cause the given PID to never be generated by the PID generator. */ public synchronized void neverGeneratePID(String pid) throws IOException { logger.debug("Never generating PID: {}", pid); try { PID p = new PID(pid); String ns = p.getNamespaceId(); int id = Integer.parseInt(p.getObjectId()); if (id > getHighestID(ns)) { setHighestID(ns, id); } } catch (MalformedPIDException mpe) { throw new IOException(mpe.getMessage()); } catch (NumberFormatException nfe) { // if the id part is not numeric, we already know we'll // never generate that id because all generated ids are numeric. } }
/** * Cause the given PID to never be generated by the PID generator. */ public synchronized void neverGeneratePID(String pid) throws IOException { logger.debug("Never generating PID: {}", pid); try { PID p = new PID(pid); String ns = p.getNamespaceId(); int id = Integer.parseInt(p.getObjectId()); if (id > getHighestID(ns)) { setHighestID(ns, id); } } catch (MalformedPIDException mpe) { throw new IOException(mpe.getMessage()); } catch (NumberFormatException nfe) { // if the id part is not numeric, we already know we'll // never generate that id because all generated ids are numeric. } }
System.out.println("ERROR: " + e.getMessage());
System.out.println("ERROR: " + e.getMessage());
pid = new PID(feed.getId().toString()); } catch (MalformedPIDException e) { throw new ObjectIntegrityException(e.getMessage(), e);