当前位置: 首页>>代码示例>>Java>>正文


Java DropboxException类代码示例

本文整理汇总了Java中com.dropbox.client2.exception.DropboxException的典型用法代码示例。如果您正苦于以下问题:Java DropboxException类的具体用法?Java DropboxException怎么用?Java DropboxException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DropboxException类属于com.dropbox.client2.exception包,在下文中一共展示了DropboxException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: copy

import com.dropbox.client2.exception.DropboxException; //导入依赖的package包/类
public boolean copy(String srcPath, String dstPath) throws IOException {

		/*
		 * If destination path exists, delete it first. This is a workaround for
		 * encfs-java behavior without chainedNameIV, the file is
		 * touched/created before calling into this function causing the Dropbox
		 * API to return 403 Forbidden thinking that the file already exists.
		 */
		System.out.println("test if exist:"+getAbsolutePath( dstPath));
		if (exists( dstPath)) {
			delete(dstPath);
		}

		try {
			api.copy(getAbsolutePath(srcPath), getAbsolutePath(dstPath));
		} catch (DropboxException e) {
			handleDropboxException(e);
		}

		return true;
	}
 
开发者ID:starn,项目名称:encdroidMC,代码行数:22,代码来源:FileProvider4.java

示例2: createFile

import com.dropbox.client2.exception.DropboxException; //导入依赖的package包/类
public EncFSFileInfo createFile(String path) throws IOException {
	Entry entry;

	try {
		entry = api.putFileOverwrite(getAbsolutePath(path), new FileInputStream(
				"/dev/zero"), 0, null);
	} catch (DropboxException e) {
		handleDropboxException(e);
		return null;
	}

	if (entry != null) {
		return entryToFileInfo(entry);
	}

	return null;
}
 
开发者ID:starn,项目名称:encdroidMC,代码行数:18,代码来源:FileProvider4.java

示例3: fsList

import com.dropbox.client2.exception.DropboxException; //导入依赖的package包/类
public List<EncFSFileInfo> fsList(String path) throws IOException {
	try {
		List<EncFSFileInfo> list = new ArrayList<EncFSFileInfo>();

		Entry dirEnt = api.metadata(getAbsolutePath(path), 0, null, true, null);

		if (!dirEnt.isDir) {
			IOException ioe = new IOException(path + " is not a directory");
			throw ioe;
		}

		// Add entries to list
		for (Entry childEnt : dirEnt.contents) {
			list.add(entryToFileInfo(childEnt));
		}

		return list;
	} catch (DropboxException e) {
		handleDropboxException(e);
		return null;
	}
}
 
开发者ID:starn,项目名称:encdroidMC,代码行数:23,代码来源:FileProvider4.java

示例4: isLinked

import com.dropbox.client2.exception.DropboxException; //导入依赖的package包/类
public boolean isLinked(Activity activity) {
		try {

		AppKeyPair appKeys = new AppKeyPair(StaticConfig.dropboxAppKey, StaticConfig.dropboxAppSecret);
		AndroidAuthSession session = new AndroidAuthSession(appKeys, AccessType.DROPBOX);
		api = new DropboxAPI<AndroidAuthSession>(session);		
//		
		KeyValueBean loginPwd = getLoginPwd(activity);
		AccessTokenPair atp = new AccessTokenPair(loginPwd.getKey(),loginPwd.getValue());
		api.getSession().setAccessTokenPair(atp);
//		return api.getSession().isLinked();
		api.metadata("/", 1, null, false, null);
		return true;
		}
		catch (DropboxException e){
			return false;
		}
		

	}
 
开发者ID:starn,项目名称:encdroidMC,代码行数:21,代码来源:FileProvider4.java

示例5: initialize

import com.dropbox.client2.exception.DropboxException; //导入依赖的package包/类
private void initialize(String token) {
    LogUtil.log(getClass().getSimpleName(), "initialize()");

    AppKeyPair appKeys = new AppKeyPair(APP_KEY, APP_SECRET);
    AndroidAuthSession session = new AndroidAuthSession(appKeys, ACCESS_TYPE);

    mDBApi = new DropboxAPI<>(session);

    if ( token == null )
        token = Settings.getDropboxSyncToken();

    if ( token != null )
        mDBApi.getSession().setOAuth2AccessToken(token);

    if (!doesFolderExist(getBaseFilePath())) {
        try {
            createFileStructure();
        } catch (DropboxException e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:timothymiko,项目名称:narrate-android,代码行数:23,代码来源:DropboxSyncService.java

示例6: createFileStructure

import com.dropbox.client2.exception.DropboxException; //导入依赖的package包/类
private void createFileStructure() throws DropboxException {

        /**
         * Creates the following folders:
         *  - /basePath
         *  - /basePath/entries
         *  - /basePath/photos
         *  - /basePath/entries/deleted
         *  - /basePath/photos/deleted
         */

        List<String> folders = new ArrayList<>();
        String basepath = getBaseFilePath();

        folders.add(basepath);
        folders.add(basepath + ENTRIES);
        folders.add(basepath + DELETED_ENTRIES);
        folders.add(basepath + PHOTOS);
        folders.add(basepath + DELETED_PHOTOS);

        for (String folder : folders)
            createFolder(folder);
    }
 
开发者ID:timothymiko,项目名称:narrate-android,代码行数:24,代码来源:DropboxSyncService.java

示例7: doInBackground

import com.dropbox.client2.exception.DropboxException; //导入依赖的package包/类
@Override
protected List<Entry> doInBackground(Object... params) { //TODO: error handling!!!
    Entry someFiles = null;
    try {
        someFiles = LibraryActivity.this.mApi
                .metadata((mLimiter == null ? "/" : (String) mLimiter.data), 0, null, true,
                        null);
    } catch (DropboxException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    List<Entry> sortingBuffer = someFiles.contents;
    Collections.sort(someFiles.contents, new Comparator<Entry>() {
        @Override
        public int compare(Entry lhs, Entry rhs) {
            if (lhs.isDir && !rhs.isDir) {
                return -1;
            } else if (!lhs.isDir && rhs.isDir) {
                return 1;
            } else {
                return lhs.fileName().compareToIgnoreCase(rhs.fileName());
            }
        }
    });
    return sortingBuffer;
}
 
开发者ID:owoc,项目名称:teardrop,代码行数:27,代码来源:LibraryActivity.java

示例8: uploadFile

import com.dropbox.client2.exception.DropboxException; //导入依赖的package包/类
/**
 * A helper method that uploads a file whose path is passed as parameter to Dropbox.
 *
 * @param path Path to the file that should be uploaded to Dropbox.
 * @throws FileNotFoundException If {@code file} does not exist.
 * @throws DropboxException      If a Dropbox related exception occurs.
 */
private void uploadFile(String path) throws FileNotFoundException, DropboxException {
    File file = new File(path);
    FileInputStream inputStream = null;
    try {
        inputStream = new FileInputStream(file);
        DropboxAPI.Entry response = dropboxApi.putFile('/' + file.getName(), inputStream, file.length(), null, null);
        Log.i(TAG, "uploadFile() :: The uploaded file's rev is: " + response.rev);
    } finally {
        if (inputStream != null) {
            try {
                inputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
 
开发者ID:dbaldwin,项目名称:DroidMapper,代码行数:25,代码来源:DropboxUploaderThread.java

示例9: testRemoteFileMissing

import com.dropbox.client2.exception.DropboxException; //导入依赖的package包/类
public void testRemoteFileMissing() {
    DropboxAPI<?> dropboxapi = new DropboxAPIStub() {
        public DropboxAPI.Entry metadata(String arg0, int arg1,
                String arg2, boolean arg3, String arg4)
                throws DropboxException {
            throw notFoundException();
        }
    };

    DropboxFileDownloader downloader = new DropboxFileDownloader(
            dropboxapi, dropboxFiles1);

    downloader.pullFiles();
    assertEquals("Status should be SUCCESS", DropboxFileStatus.SUCCESS,
            downloader.getStatus());
    assertEquals("Should have 1 file", 1, downloader.getFiles().size());
    assertEquals("Status should be NOT_FOUND", DropboxFileStatus.NOT_FOUND,
            dbFile1.getStatus());
}
 
开发者ID:GoogleCloudPlatform,项目名称:endpoints-codelab-android,代码行数:20,代码来源:DropboxFileDownloaderTest.java

示例10: testRemoteFileDeleted

import com.dropbox.client2.exception.DropboxException; //导入依赖的package包/类
public void testRemoteFileDeleted() {
    DropboxAPI<?> dropboxapi = new DropboxAPIStub() {
        public DropboxAPI.Entry metadata(String arg0, int arg1,
                String arg2, boolean arg3, String arg4)
                throws DropboxException {
            return create_metadata(remoterev1, true);
        }
    };

    DropboxFileDownloader downloader = new DropboxFileDownloader(
            dropboxapi, dropboxFiles1);

    downloader.pullFiles();
    assertEquals("Status should be SUCCESS", DropboxFileStatus.SUCCESS,
            downloader.getStatus());
    assertEquals("Should have 1 file", 1, downloader.getFiles().size());
    assertEquals("Status should be NOT_FOUND", DropboxFileStatus.NOT_FOUND,
            dbFile1.getStatus());
}
 
开发者ID:GoogleCloudPlatform,项目名称:endpoints-codelab-android,代码行数:20,代码来源:DropboxFileDownloaderTest.java

示例11: testBothFilesMissing

import com.dropbox.client2.exception.DropboxException; //导入依赖的package包/类
public void testBothFilesMissing() {
    DropboxAPI<?> dropboxapi = new DropboxAPIStub() {
        public DropboxAPI.Entry metadata(String arg0, int arg1,
                String arg2, boolean arg3, String arg4)
                throws DropboxException {
            throw notFoundException();
        }
    };

    DropboxFileDownloader downloader = new DropboxFileDownloader(
            dropboxapi, dropboxFiles2);

    downloader.pullFiles();
    assertEquals("Status should be SUCCESS", DropboxFileStatus.SUCCESS,
            downloader.getStatus());
    assertEquals("Should have 2 files", 2, downloader.getFiles().size());
    assertEquals("Status should be NOT_FOUND", DropboxFileStatus.NOT_FOUND,
            dbFile1.getStatus());
    assertEquals("Status should be NOT_FOUND", DropboxFileStatus.NOT_FOUND,
            dbFile2.getStatus());
}
 
开发者ID:GoogleCloudPlatform,项目名称:endpoints-codelab-android,代码行数:22,代码来源:DropboxFileDownloaderTest.java

示例12: createPhotoFolder

import com.dropbox.client2.exception.DropboxException; //导入依赖的package包/类
/**
 * Creates a directory for photos if one does not already exist. If the folder already exists, this call will
 * do nothing.
 *
 * @param dropboxApi the {@link DropboxAPI}.
 * @return true if the directory is created or it already exists; false otherwise.
 */
private boolean createPhotoFolder(DropboxAPI<AndroidAuthSession> dropboxApi) {
    boolean folderCreated = false;
    if (dropboxApi != null) {
        try {
            dropboxApi.createFolder(mContext.getString(R.string.wings_dropbox__photo_folder));
            folderCreated = true;
        } catch (DropboxException e) {
            // Consider the folder created if the folder already exists.
            if (e instanceof DropboxServerException) {
                folderCreated = DropboxServerException._403_FORBIDDEN == ((DropboxServerException) e).error;
            }
        }
    }
    return folderCreated;
}
 
开发者ID:groundupworks,项目名称:wings,代码行数:23,代码来源:DropboxEndpoint.java

示例13: getFilesInDir

import com.dropbox.client2.exception.DropboxException; //导入依赖的package包/类
public Set<String> getFilesInDir(String dirName, String query)
{
    Set<String> retVal = null;

    if( isConnected() ) {
        try {
            Log.d(TAG, "Getting files in: " + dirName);

            DropboxAPI.Entry entries = mDBApi.metadata("/" + dirName, MAX_DROPBOX_FILES, null, true, null);

            // Move list of files into hashset
            retVal = new HashSet<String>();
            for( DropboxAPI.Entry entry : entries.contents )
            {
                retVal.add( entry.fileName() );
            }
        } catch( DropboxException e )
        {
            e.printStackTrace();
        }
    }
    return retVal;
}
 
开发者ID:bright-tools,项目名称:androidphotobackup,代码行数:24,代码来源:DropBoxWrapper.java

示例14: fileExists

import com.dropbox.client2.exception.DropboxException; //导入依赖的package包/类
public boolean fileExists(String fileName)
{
    boolean retVal = false;
    if( isConnected() ) {
        try {
            DropboxAPI.Entry existingEntry = mDBApi.metadata("/" + fileName, 1, null, false, null);
            if ((!existingEntry.isDir) && (!existingEntry.isDeleted)) {
                retVal = true;
            }
        } catch( DropboxException e )
        {
            e.printStackTrace();
        }
    }
    return retVal;
}
 
开发者ID:bright-tools,项目名称:androidphotobackup,代码行数:17,代码来源:DropBoxWrapper.java

示例15: authorize

import com.dropbox.client2.exception.DropboxException; //导入依赖的package包/类
private boolean authorize() {
	try {
		//construct app authorization URL
		this.auth = this.session.getAuthInfo("http://www.google.com");
		System.out.println("url: " + this.auth.url);
		//launch browser for user to approve app
		BareBonesBrowserLaunch.openURL(this.auth.url);

		return true;
	} catch (DropboxException ex) {
		// TODO Auto-generated catch block
		Logger.getLogger(DBApi.class.getName()).log(Level.SEVERE, null, ex);
		return false;
	}

}
 
开发者ID:kevincon,项目名称:lightningrod,代码行数:17,代码来源:DBApi.java


注:本文中的com.dropbox.client2.exception.DropboxException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。