protected static void logAndThrow(String s, Throwable t) throws IDCreateException { IDCreateException e = null; if (t != null) { e = new IDCreateException(s + ": " + t.getClass().getName() + ": " //$NON-NLS-1$ //$NON-NLS-2$ + t.getMessage(), t); } else { e = new IDCreateException(s); } Activator.getDefault().log( new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, s, e)); throw e; }
return new DownloadStatus(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_INVALID_LOCATION, NLS.bind(Messages.TransportErrorTranslator_UnknownHost, toDownload), t); if (t instanceof IDCreateException) { IStatus status = ((IDCreateException) t).getStatus(); if (status != null && status.getException() != null) t = status.getException();
return new DownloadStatus(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_INVALID_LOCATION, NLS.bind(Messages.TransportErrorTranslator_UnknownHost, toDownload), t); if (t instanceof IDCreateException) { IStatus status = ((IDCreateException) t).getStatus(); if (status != null && status.getException() != null) t = status.getException();
protected static void logAndThrow(String s, Throwable t) throws IDCreateException { IDCreateException e = null; if (t != null) { e = new IDCreateException(s + ": " + t.getClass().getName() + ": " //$NON-NLS-1$ //$NON-NLS-2$ + t.getMessage(), t); } else { e = new IDCreateException(s); } Activator.getDefault().log( new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, s, e)); throw e; }
return new DownloadStatus(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_INVALID_LOCATION, NLS.bind(Messages.TransportErrorTranslator_UnknownHost, toDownload), t); if (t instanceof IDCreateException) { IStatus status = ((IDCreateException) t).getStatus(); if (status != null && status.getException() != null) t = status.getException();
public ID createStringID(String idstring) throws IDCreateException { if (idstring == null) throw new IDCreateException("StringID cannot be null"); //$NON-NLS-1$ return createID(new StringID.StringIDNamespace(), new String[] { idstring }); }
return new DownloadStatus(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_INVALID_LOCATION, NLS.bind(Messages.TransportErrorTranslator_UnknownHost, toDownload), t); if (t instanceof IDCreateException) { IStatus status = ((IDCreateException) t).getStatus(); if (status != null && status.getException() != null) t = status.getException();
public ID createInstance(Object[] parameters) throws IDCreateException { try { String init = getInitStringFromExternalForm(parameters); if (init != null) return new URIID(this, new URI(init)); if (parameters[0] instanceof URI) return new URIID(this, (URI) parameters[0]); if (parameters[0] instanceof String) return new URIID(this, new URI((String) parameters[0])); throw new IDCreateException("Cannot create URIID"); } catch (Exception e) { throw new IDCreateException(URIIDNamespace.this.getName() + " createInstance()", e); //$NON-NLS-1$ } }
return new DownloadStatus(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_INVALID_LOCATION, NLS.bind(Messages.TransportErrorTranslator_UnknownHost, toDownload), t); if (t instanceof IDCreateException) { IStatus status = ((IDCreateException) t).getStatus(); if (status != null && status.getException() != null) t = status.getException();
public ID createStringID(String idstring) throws IDCreateException { if (idstring == null) throw new IDCreateException("StringID cannot be null"); //$NON-NLS-1$ return createID(new StringID.StringIDNamespace(), new String[] { idstring }); }
return new DownloadStatus(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_INVALID_LOCATION, NLS.bind(Messages.TransportErrorTranslator_UnknownHost, toDownload), t); if (t instanceof IDCreateException) { IStatus status = ((IDCreateException) t).getStatus(); if (status != null && status.getException() != null) t = status.getException();
public ID createID(String namespaceName, Object[] args) throws IDCreateException { Namespace n = getNamespaceByName(namespaceName); if (n == null) throw new IDCreateException( "Namespace " + namespaceName + " not found"); //$NON-NLS-1$ return createID(n, args); }
public ID createInstance(Object[] parameters) throws IDCreateException { try { String init = getInitStringFromExternalForm(parameters); if (init != null) return new URIID(this, new URI(init)); if (parameters[0] instanceof URI) return new URIID(this, (URI) parameters[0]); if (parameters[0] instanceof String) return new URIID(this, new URI((String) parameters[0])); throw new IDCreateException("Cannot create URIID"); } catch (Exception e) { throw new IDCreateException(URIIDNamespace.this.getName() + " createInstance()", e); //$NON-NLS-1$ } }
public ID createID(String namespaceName, Object[] args) throws IDCreateException { Namespace n = getNamespaceByName(namespaceName); if (n == null) throw new IDCreateException( "Namespace " + namespaceName + " not found"); //$NON-NLS-1$ return createID(n, args); }
public ID createInstance(Object[] args) throws IDCreateException { try { String init = getInitFromExternalForm(args); if (init != null) return new FileTransferID(this, new URI(init)); if (args[0] instanceof URL) return new FileTransferID(this, (URL) args[0]); if (args[0] instanceof String) return new FileTransferID(this, new URI((String) args[0])); if (args[0] instanceof URI) return new FileTransferID(this, (URI) args[0]); } catch (Exception e) { throw new IDCreateException(Messages.FileTransferNamespace_Exception_Create_Instance, e); } throw new IDCreateException(Messages.FileTransferNamespace_Exception_Create_Instance_Failed); }
/** * Protected constructor for factory-based construction * * @param n * the Namespace this identity will belong to * @param provider * the name of the algorithm to use. See {@link SecureRandom} * @param byteLength * the length of the target number (in bytes) */ protected GUID(Namespace n, String algo, String provider, int byteLength) throws IDCreateException { super(n, ""); //$NON-NLS-1$ // Get SecureRandom instance for class try { getRandom(algo, provider); } catch (Exception e) { throw new IDCreateException( "GUID creation failure: " + e.getMessage()); //$NON-NLS-1$ } // make sure we have reasonable byteLength if (byteLength <= 0) byteLength = 1; byte[] newBytes = new byte[byteLength]; // Fill up random bytes random.nextBytes(newBytes); // Set value value = Base64.encode(newBytes); }
/** * Protected constructor for factory-based construction * * @param n * the Namespace this identity will belong to * @param provider * the name of the algorithm to use. See {@link SecureRandom} * @param byteLength * the length of the target number (in bytes) */ protected GUID(Namespace n, String algo, String provider, int byteLength) throws IDCreateException { super(n, ""); //$NON-NLS-1$ // Get SecureRandom instance for class try { getRandom(algo, provider); } catch (Exception e) { throw new IDCreateException( "GUID creation failure: " + e.getMessage()); //$NON-NLS-1$ } // make sure we have reasonable byteLength if (byteLength <= 0) byteLength = 1; byte[] newBytes = new byte[byteLength]; // Fill up random bytes random.nextBytes(newBytes); // Set value value = Base64.encode(newBytes); }
/** * @param args * must not be <code>null></code> * @return ID created. Will not be <code>null</code>. * @throws IDCreateException * never thrown */ public ID createInstance(Object[] args) throws IDCreateException { try { String init = getInitStringFromExternalForm(args); if (init != null) return new LongID(this, Long.decode(init)); return new LongID(this, (Long) args[0]); } catch (Exception e) { throw new IDCreateException(getName() + " createInstance()", e); //$NON-NLS-1$ } }
/** * @param args * must not be <code>null></code> * @return ID created. Will not be <code>null</code>. * @throws IDCreateException * never thrown */ public ID createInstance(Object[] args) throws IDCreateException { try { String init = getInitStringFromExternalForm(args); if (init != null) return new LongID(this, Long.decode(init)); return new LongID(this, (Long) args[0]); } catch (Exception e) { throw new IDCreateException(getName() + " createInstance()", e); //$NON-NLS-1$ } }
@Override public ID createInstance(Object[] parameters) throws IDCreateException { try { String init = getInitStringFromExternalForm(parameters); if (init != null) return new UuID(this, UUID.fromString(init)); if (parameters != null && parameters.length > 0) { if (parameters[0] instanceof String) return new UuID(this, UUID.fromString((String) parameters[0])); else if (parameters[0] instanceof URI) return new UuID(this, UUID.fromString(((URI) parameters[0]) .getSchemeSpecificPart())); else if (parameters[0] instanceof UUID) return new UuID(this, (UUID) parameters[0]); } // If we get here, then use random return new UuID(this, UUID.randomUUID()); } catch (Exception e) { throw new IDCreateException(UuIDNamespace.this.getName() + " createInstance()", e); //$NON-NLS-1$ } }