private void removeEntry(String rowKey, String tableName) { try { CloudTableClient tableClient = getTableClient(); Album specificAlbum = tableClient .execute(tableName, TableOperation.retrieve("1", rowKey, Album.class)) .getResultAsType(); tableClient.execute(tableName, TableOperation.delete(specificAlbum)); } catch (Exception e) { System.out.print("Exception encountered: "); System.out.println(e.getMessage()); } }
private void insertEntry(Album album) throws StorageException, Exception { CloudTableClient tableClient = getTableClient(); CloudTable table = tableClient.getTableReference(this.tableName); table.createIfNotExist(); TableOperation insertAlbum1 = TableOperation.insert(album); tableClient.execute(this.tableName, insertAlbum1); }
private Album getAlbumInfo(String rowKey, String tableName) { try { CloudTableClient tableClient = getTableClient(); Album specificAlbum = tableClient .execute(tableName, TableOperation.retrieve("1", rowKey, Album.class)) .getResultAsType(); return specificAlbum; } catch (StorageException storageException) { System.out.print("StorageException encountered: "); System.out.println(storageException.getMessage()); return null; } catch (Exception e) { System.out.print("Exception encountered:\n"); System.out.println( "Exception class: " + e.getClass() + "\nException message: " + e.getMessage() + "\nStack trace: " + e.getStackTrace()); return null; } }
@Override public List<Album> listAlbums() { try { CloudTableClient tableClient = getTableClient(); // Create a filter condition where the partition key is "Smith". String partitionFilter = TableQuery.generateFilterCondition( TableConstants.PARTITION_KEY, QueryComparisons.EQUAL, "1"); // Specify a partition query, using "Smith" as the partition key filter. TableQuery<Album> partitionQuery = TableQuery.from(this.tableName, Album.class).where(partitionFilter); return convertToList(tableClient.execute(partitionQuery)); // Loop through the results, displaying information about the entity. // for (Album album : tableClient.execute(partitionQuery)) { // System.out.println(album.getPartitionKey() + " " + album.getRowKey() + // "\t" + album.getTitle() + "\t" + album.getDescription() + "\t" + album.getMail() // + "\t" + album.getPath()); } catch (Exception e) { System.out.print("Exception encountered: ma khoobim shoma chetor? "); System.out.println(e.getMessage()); return null; } }