Search in sources :

Example 11 with VlException

use of nl.uva.vlet.exception.VlException in project lobcder by skoulouzis.

the class GridHelper method initGridProxy.

public static void initGridProxy(String vo, String password, VRSContext context, boolean destroyCert) throws Exception {
    InitGlobalVFS();
    if (context == null) {
        context = new VFSClient().getVRSContext();
    // context = VRS.getDefaultVRSContext();
    }
    GridProxy gridProxy = context.getGridProxy();
    if (destroyCert) {
        gridProxy.destroy();
        gridProxy = null;
    }
    if (gridProxy == null || gridProxy.isValid() == false) {
        // context.setProperty("grid.proxy.location", Constants.PROXY_FILE);
        // context.setProperty("grid.certificate.location", Global.getUserHome() + "/.globus");
        // context.setProperty("grid.proxy.lifetime", "100");
        context.setProperty("grid.proxy.voName", vo);
        gridProxy = context.getGridProxy();
        // if (gridProxy.isValid() == false) {
        gridProxy.setEnableVOMS(true);
        gridProxy.setDefaultVOName(vo);
        gridProxy.createWithPassword(password);
        if (gridProxy.isValid() == false) {
            throw new VlException("Created Proxy is not Valid!");
        // }
        }
    }
    if (!new File(Constants.PROXY_FILE).exists()) {
        gridProxy.saveProxyTo(Constants.PROXY_FILE);
    }
}
Also used : VFSClient(nl.uva.vlet.vfs.VFSClient) GridProxy(nl.uva.vlet.util.cog.GridProxy) VlException(nl.uva.vlet.exception.VlException) File(java.io.File)

Example 12 with VlException

use of nl.uva.vlet.exception.VlException in project lobcder by skoulouzis.

the class CachePDRI method putData.

@Override
public void putData(InputStream data) throws IOException, FileNotFoundException {
    // asyncPut.run();
    if (!getEncrypted()) {
        try {
            setResourceContent(data);
        } catch (VlException ex) {
            throw new IOException(ex);
        }
    } else {
        try {
            OutputStream out = new FileOutputStream(file);
            DesEncrypter encrypter = new DesEncrypter(getKeyInt());
            encrypter.decrypt(getData(), out);
        } catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | InvalidAlgorithmParameterException ex) {
            throw new IOException(ex);
        }
    }
}
Also used : InvalidAlgorithmParameterException(java.security.InvalidAlgorithmParameterException) VlException(nl.uva.vlet.exception.VlException) NoSuchPaddingException(javax.crypto.NoSuchPaddingException) DesEncrypter(nl.uva.cs.lobcder.util.DesEncrypter) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) InvalidKeyException(java.security.InvalidKeyException)

Example 13 with VlException

use of nl.uva.vlet.exception.VlException in project lobcder by skoulouzis.

the class GetTask method run.

@Override
public void run() {
    double start = System.currentTimeMillis();
    FileOutputStream out = null;
    File f = null;
    try {
        f = new File("/tmp/deleteme" + this.hashCode());
        // f.deleteOnExit();
        out = new FileOutputStream(f);
        CircularStreamBufferTransferer cBuff = new CircularStreamBufferTransferer((512 * 1024), cl.getFile(vrl).getInputStream(), out);
        cBuff.startTransfer((long) -1);
        double elapsed = System.currentTimeMillis() - start;
        System.err.println("Speed: " + (f.length() / elapsed));
        sleeTime = 5;
    } catch (Exception ex) {
        try {
            // 
            if (reconnectAttemts < 10) {
                sleeTime = sleeTime + 20;
                System.err.println("Reconnecting: " + reconnectAttemts + " sleep: " + sleeTime);
                Thread.sleep(sleeTime);
                reconnect();
                run();
            } else {
            // Logger.getLogger(TestDrivers.class.getName()).log(Level.SEVERE, null, ex);
            }
        } catch (InterruptedException ex1) {
            Logger.getLogger(GetTask.class.getName()).log(Level.SEVERE, null, ex1);
        // 
        } catch (VlException ex1) {
            Logger.getLogger(GetTask.class.getName()).log(Level.SEVERE, null, ex1);
        }
    } finally {
        try {
            out.close();
        } catch (IOException ex) {
            Logger.getLogger(TestDrivers.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
Also used : CircularStreamBufferTransferer(nl.uva.vlet.io.CircularStreamBufferTransferer) FileOutputStream(java.io.FileOutputStream) VlException(nl.uva.vlet.exception.VlException) IOException(java.io.IOException) File(java.io.File) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) VlException(nl.uva.vlet.exception.VlException)

Example 14 with VlException

use of nl.uva.vlet.exception.VlException in project lobcder by skoulouzis.

the class TestDrivers method main.

public static void main(String[] args) {
    try {
        String propBasePath = "etc" + File.separator + "test.proprties";
        Properties prop = getTestProperties(propBasePath);
        vrl = prop.getProperty("driver.test.vrl", "sftp://localhost/" + System.getProperty("user.home") + "/tmp");
        username = prop.getProperty("driver.test.username", System.getProperty("user.name"));
        password = prop.getProperty("driver.test.password");
        testURL = prop.getProperty("webdav.test.url");
        TestDrivers t = new TestDrivers();
        t.test();
    } catch (InterruptedException ex) {
        Logger.getLogger(TestDrivers.class.getName()).log(Level.SEVERE, null, ex);
    } catch (VlException ex) {
        Logger.getLogger(TestDrivers.class.getName()).log(Level.SEVERE, null, ex);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(TestDrivers.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(TestDrivers.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
        VRS.exit();
        System.exit(0);
    }
}
Also used : VlException(nl.uva.vlet.exception.VlException) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) Properties(java.util.Properties)

Aggregations

VlException (nl.uva.vlet.exception.VlException)14 File (java.io.File)6 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)6 GridProxy (nl.uva.vlet.util.cog.GridProxy)5 IOException (java.io.IOException)4 MalformedURLException (java.net.MalformedURLException)4 VRL (nl.uva.vlet.vrl.VRL)4 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)3 InvalidKeyException (java.security.InvalidKeyException)3 NoSuchPaddingException (javax.crypto.NoSuchPaddingException)3 VFSClient (nl.uva.vlet.vfs.VFSClient)3 FileNotFoundException (java.io.FileNotFoundException)2 FileOutputStream (java.io.FileOutputStream)2 URISyntaxException (java.net.URISyntaxException)2 JAXBException (javax.xml.bind.JAXBException)2 DesEncrypter (nl.uva.cs.lobcder.util.DesEncrypter)2 GetMethod (org.apache.commons.httpclient.methods.GetMethod)2 Test (org.junit.Test)2 java.io (java.io)1 InputStream (java.io.InputStream)1