Package org.jets3t.service.model

Examples of org.jets3t.service.model.S3Object


     * @throws Exception
     */
    private S3Object prepareUploadObject(String targetKey, File file, String aclString, EncryptionUtil encryptionUtil)
        throws Exception
    {       
        S3Object newObject = ObjectUtils
            .createObjectForUpload(targetKey, file, encryptionUtil, isGzipEnabled, null);
       
        if ("PUBLIC_READ".equalsIgnoreCase(aclString)) {
            newObject.setAcl(AccessControlList.REST_CANNED_PUBLIC_READ);                       
        } else if ("PUBLIC_READ_WRITE".equalsIgnoreCase(aclString)) {
            newObject.setAcl(AccessControlList.REST_CANNED_PUBLIC_READ_WRITE);           
        } else if ("PRIVATE".equalsIgnoreCase(aclString)) {
            // Private is the default, no need to add an ACL
        } else {
            throw new Exception("Invalid value for ACL string: " + aclString);
        }
View Full Code Here


        // Delete objects on S3 that don't correspond with local files.
        List objectsToDelete = new ArrayList();
        Iterator serverOnlyIter = disrepancyResults.onlyOnServerKeys.iterator();
        while (serverOnlyIter.hasNext()) {
            String keyPath = (String) serverOnlyIter.next();
            S3Object s3Object = (S3Object) s3ObjectsMap.get(keyPath);

            if (isKeepFiles || isNoDelete) {
                printOutputLine("d " + keyPath, false);               
            } else {
                printOutputLine("D " + keyPath, false);
View Full Code Here

       
        // Upload/update files.
        Iterator s3KeyIter = sortedS3ObjectKeys.iterator();
        while (s3KeyIter.hasNext()) {
            String keyPath = (String) s3KeyIter.next();
            S3Object s3Object = (S3Object) s3ObjectsMap.get(keyPath);
           
            if (disrepancyResults.onlyOnServerKeys.contains(keyPath)) {
                printOutputLine("N " + keyPath, false);
                DownloadPackage downloadPackage = ObjectUtils.createPackageForDownload(
                    s3Object, new File(localDirectory, keyPath), isGzipEnabled, isEncryptionEnabled, cryptoPassword);
View Full Code Here

                String targetDirs[] = objectPath.split(Constants.FILE_PATH_DELIM);
                StringBuffer currentDirPathBuf = new StringBuffer();
                for (int i = 0; i < targetDirs.length; i++) {
                    currentDirPathBuf.append(targetDirs[i]);
                   
                    S3Object dirObject = new S3Object(currentDirPathBuf.toString());
                    dirObject.setContentType(Mimetypes.MIMETYPE_JETS3T_DIRECTORY);
                    s3Service.putObject(bucket, dirObject);
                    currentDirPathBuf.append(Constants.FILE_PATH_DELIM);
                }
            } catch (Exception e) {
                throw new SynchronizeException("Unable to create S3 path: " + objectPath, e);
View Full Code Here

                log.debug("Computing MD5 hash for file: " + file);
                byte[] fileHash = ServiceUtils.computeMD5Hash(
                    new ProgressMonitoredInputStream( // Report on MD5 hash progress.
                        new FileInputStream(file), progressWatcher));
               
                S3Object object = new S3Object(null, file);
                object.setMd5Hash(fileHash);
                objectsForUpload[i] = object;
            }
           
            // Obtain Gatekeeper response.
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    progressStatusTextLabel.setText(
                        replaceMessageVariables(uploaderProperties.getStringProperty("screen.4.connectingMessage",
                        "Missing property 'screen.4.connectingMessage'")));
                    progressBar.setValue(0);
                };
            });                
           
            GatekeeperMessage gatekeeperMessage = null;
           
            try {
                gatekeeperMessage = retrieveGatekeeperResponse(objectsForUpload);               
            } catch (Exception e) {
                log.info("Upload request was denied", e);               
                failWithFatalError(ERROR_CODE__UPLOAD_REQUEST_DECLINED);
                return;
            }
            // If we get a null response, presume the error has already been handled.
            if (gatekeeperMessage == null) {
                return;
            }
           
            log.debug("Gatekeeper response properties: " + gatekeeperMessage.encodeToProperties());
           
            XmlGenerator xmlGenerator = new XmlGenerator();
            xmlGenerator.addApplicationProperties(gatekeeperMessage.getApplicationProperties());
            xmlGenerator.addMessageProperties(gatekeeperMessage.getMessageProperties());
                                   
            SignedUrlAndObject[] uploadItems = prepareSignedObjects(
                objectsForUpload, gatekeeperMessage.getSignatureRequests(), xmlGenerator);
           
            if (s3ServiceMulti == null) {
                s3ServiceMulti = new S3ServiceMulti(
                    new RestS3Service(null, APPLICATION_DESCRIPTION, this), this);
            }
                     
            /*
             * Prepare XML Summary document for upload, if the summary option is set.
             */
            includeXmlSummaryDoc = uploaderProperties.getBoolProperty("xmlSummary", false);
            S3Object summaryXmlObject = null;
            if (includeXmlSummaryDoc) {
                String priorTransactionId = gatekeeperMessage.getMessageProperties().getProperty(
                    GatekeeperMessage.PROPERTY_TRANSACTION_ID);
                if (priorTransactionId == null) {
                    failWithFatalError(ERROR_CODE__TRANSACTION_ID_REQUIRED_TO_CREATE_XML_SUMMARY);
                    return;
                }
               
                summaryXmlObject = new S3Object(
                    null, priorTransactionId + ".xml", xmlGenerator.generateXml());
                summaryXmlObject.setContentType(Mimetypes.MIMETYPE_XML);
                summaryXmlObject.addMetadata(GatekeeperMessage.PROPERTY_TRANSACTION_ID, priorTransactionId);
                summaryXmlObject.addMetadata(GatekeeperMessage.SUMMARY_DOCUMENT_METADATA_FLAG, "true");                
            }
           
            // PUT the user's selected files in S3.
            uploadCancelled = false;
            uploadingFinalObject = (!includeXmlSummaryDoc);
View Full Code Here

    private S3Object[] getSelectedObjects() {
        int viewRows[] = objectsTable.getSelectedRows();
        if (viewRows.length == 0) {
            return new S3Object[] {};
        } else {
            S3Object objects[] = new S3Object[viewRows.length];
            for (int i = 0; i < viewRows.length; i++) {
                int modelRow = objectTableModelSorter.modelIndex(viewRows[i]);
                objects[i] = objectTableModel.getObject(modelRow);
            }
            return objects;
View Full Code Here

            int objectIndex = 0;
            for (Iterator iter = fileKeysForUpload.iterator(); iter.hasNext();) {
                String fileKey = iter.next().toString();
                File file = (File) uploadingFilesMap.get(fileKey);
                                               
                S3Object newObject = ObjectUtils
                    .createObjectForUpload(fileKey, file,
                        (cockpitPreferences.isUploadEncryptionActive() ? encryptionUtil : null),
                        cockpitPreferences.isUploadCompressionActive(), progressWatcher);
               
                String aclPreferenceString = cockpitPreferences.getUploadACLPermission();
                if (CockpitPreferences.UPLOAD_ACL_PERMISSION_PRIVATE.equals(aclPreferenceString)) {
                    // Objects are private by default, nothing more to do.
                } else if (CockpitPreferences.UPLOAD_ACL_PERMISSION_PUBLIC_READ.equals(aclPreferenceString)) {
                    newObject.setAcl(AccessControlList.REST_CANNED_PUBLIC_READ);
                } else if (CockpitPreferences.UPLOAD_ACL_PERMISSION_PUBLIC_READ_WRITE.equals(aclPreferenceString)) {
                    newObject.setAcl(AccessControlList.REST_CANNED_PUBLIC_READ_WRITE);                   
                } else {
                    log.warn("Ignoring unrecognised upload ACL permission setting: " + aclPreferenceString);                   
                }
               
                statusText[0] = "Prepared " + (objectIndex + 1)
View Full Code Here

        if (objects.length != 1) {
            log.warn("Ignoring Generate Public URL object command, can only operate on a single object");
            return;           
        }
        S3Object currentObject = objects[0];

        SignedGetUrlDialog dialog = new SignedGetUrlDialog(ownerFrame, null);
        dialog.setVisible(true);
       
        boolean okClicked = dialog.getOkClicked();
        boolean isVirtualHost = dialog.isVirtualHost();
        String expiryTimeStr = dialog.getExpiryTime();
        dialog.dispose();
       
        if (!okClicked) {
            return;
        }
       
        try {
            // Determine expiry time for URL
            double hoursFromNow = Double.parseDouble(expiryTimeStr);
            int secondsFromNow = (int) (hoursFromNow * 60 * 60);
            Calendar cal = Calendar.getInstance();
            cal.add(Calendar.SECOND, secondsFromNow);
            long secondsSinceEpoch = cal.getTimeInMillis() / 1000;
                       
            // Generate URL
            String signedUrl = S3Service.createSignedUrl("GET",
                getCurrentSelectedBucket().getName(), currentObject.getKey(), null,
                null, s3ServiceMulti.getAWSCredentials(), secondsSinceEpoch, isVirtualHost);
           
            // Display signed URL
            JOptionPane.showInputDialog(ownerFrame,
                "URL for '" + currentObject.getKey() + "'."
                + "\n This URL will be valid until approximately " + cal.getTime()
                + "\n(Amazon's server time may be ahead of or behind your computer's clock)",
                "Signed URL", JOptionPane.INFORMATION_MESSAGE, null, null, signedUrl);

        } catch (NumberFormatException e) {
View Full Code Here

        if (objects.length != 1) {
            log.warn("Ignoring Generate Public URL object command, can only operate on a single object");
            return;           
        }
        S3Object currentObject = objects[0];

        // Generate URL
        String torrentUrl = S3Service.createTorrentUrl(
            getCurrentSelectedBucket().getName(), currentObject.getKey());
       
        // Display signed URL
        JOptionPane.showInputDialog(ownerFrame,
            "Torrent URL for '" + currentObject.getKey() + "'.",
            "Torrent URL", JOptionPane.INFORMATION_MESSAGE, null, null, torrentUrl);
    }   
View Full Code Here

            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    synchronized (s3ServiceMulti) {
                        // Retain selected status of objects for downloads or properties
                        for (int i = 0; i < event.getCompletedObjects().length; i++) {
                            S3Object object = event.getCompletedObjects()[i];
                            object.setOwner(getCurrentSelectedBucket().getOwner());
                            int modelIndex = objectTableModel.addObject(object);
                            log.debug("Updated table with " + object.getKey() + ", content-type=" + object.getContentType());
   
                            if (isDownloadingObjects) {
                                s3DownloadObjectsMap.put(object.getKey(), object);
                                log.debug("Updated object download list with " + object.getKey()
                                    + ", content-type=" + object.getContentType());
                            } else if (isUploadingFiles) {
                                s3ExistingObjectsMap.put(object.getKey(), object);
                                log.debug("Updated object upload list with " + object.getKey()
                                    + ", content-type=" + object.getContentType());                           
                            }
                           
                            int viewIndex = objectTableModelSorter.viewIndex(modelIndex);
                            if (isDownloadingObjects || isViewingObjectProperties) {
                                objectsTable.addRowSelectionInterval(viewIndex, viewIndex);
View Full Code Here

TOP

Related Classes of org.jets3t.service.model.S3Object

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.