From db21c7f83a0445b1ca5f7e3845226d7d050a3578 Mon Sep 17 00:00:00 2001 From: Miltiadis Vasilakis Date: Wed, 9 Nov 2011 22:47:40 +0200 Subject: [PATCH] Added container policy functionality. --- Classes/AccountManager.h | 2 + Classes/AccountManager.m | 26 +++ Classes/Container.h | 10 + Classes/Container.m | 9 + Classes/ContainerDetailViewController.m | 45 ++++- Classes/EditPolicyViewController.h | 71 +++++++ Classes/EditPolicyViewController.m | 305 +++++++++++++++++++++++++++++++ Classes/EditPolicyViewController.xib | 201 ++++++++++++++++++++ Classes/OpenStackRequest.h | 2 + Classes/OpenStackRequest.m | 11 ++ OpenStack.xcodeproj/project.pbxproj | 10 + 11 files changed, 684 insertions(+), 8 deletions(-) create mode 100644 Classes/EditPolicyViewController.h create mode 100644 Classes/EditPolicyViewController.m create mode 100644 Classes/EditPolicyViewController.xib diff --git a/Classes/AccountManager.h b/Classes/AccountManager.h index cc93d0d..e8a2351 100755 --- a/Classes/AccountManager.h +++ b/Classes/AccountManager.h @@ -65,7 +65,9 @@ - (void)writeObjectMetadata:(Container *)container object:(StorageObject *)object; - (void)deleteObject:(Container *)container object:(StorageObject *)object; +// container actions - (void)updateCDNContainer:(Container *)container; +- (void)writeContainerPolicy:(Container *)container; // load balancing diff --git a/Classes/AccountManager.m b/Classes/AccountManager.m index 0f78fa7..616f69b 100755 --- a/Classes/AccountManager.m +++ b/Classes/AccountManager.m @@ -678,6 +678,32 @@ [[NSNotificationCenter defaultCenter] postNotification:notification]; } +- (void)writeContainerPolicy:(Container *)container { + OpenStackRequest *request = [OpenStackRequest writeContainerPolicyRequest:self.account container:container]; + + request.delegate = self; + request.didFinishSelector = @selector(writeContainerPolicySucceeded:); + request.didFailSelector = @selector(writeContainerPolicyFailed:); + request.userInfo = [NSDictionary dictionaryWithObject:container forKey:@"container"]; + [request startAsynchronous]; +} + +- (void)writeContainerPolicySucceeded:(OpenStackRequest *)request { + if ([request isSuccess]) { + NSNotification *notification = [NSNotification notificationWithName:@"writeContainerPolicySucceeded" object:[request.userInfo objectForKey:@"container"] userInfo:[NSDictionary dictionaryWithObject:request forKey:@"request"]]; + [[NSNotificationCenter defaultCenter] postNotification:notification]; + } else { + NSNotification *notification = [NSNotification notificationWithName:@"writeContainerPolicyFailed" object:[request.userInfo objectForKey:@"container"] userInfo:[NSDictionary dictionaryWithObject:request forKey:@"request"]]; + [[NSNotificationCenter defaultCenter] postNotification:notification]; + } +} + +- (void)writeContainerPolicyFailed:(OpenStackRequest *)request { + NSNotification *notification = [NSNotification notificationWithName:@"writeContainerPolicyFailed" object:[request.userInfo objectForKey:@"container"] userInfo:[NSDictionary dictionaryWithObject:request forKey:@"request"]]; + [[NSNotificationCenter defaultCenter] postNotification:notification]; +} + + #pragma mark - #pragma mark Load Balancing diff --git a/Classes/Container.h b/Classes/Container.h index 3b7a2c8..44c96fb 100755 --- a/Classes/Container.h +++ b/Classes/Container.h @@ -17,6 +17,10 @@ NSUInteger count; unsigned long long bytes; + // policy + NSString *versioning; + NSUInteger quota; + // metadata NSMutableDictionary *metadata; @@ -43,8 +47,14 @@ @property (nonatomic, retain) NSString *name; @property (nonatomic, assign) NSUInteger count; @property (nonatomic, assign) unsigned long long bytes; + +//metadata @property (nonatomic, retain) NSMutableDictionary *metadata; +//policy +@property (nonatomic, retain) NSString *versioning; +@property (nonatomic) NSUInteger quota; + -(NSString *)humanizedSize; // CDN container attributes diff --git a/Classes/Container.m b/Classes/Container.m index 46f37d3..9cb2628 100755 --- a/Classes/Container.m +++ b/Classes/Container.m @@ -17,6 +17,11 @@ // regular container attributes @synthesize name, count, bytes; + +//policy +@synthesize versioning, quota; + +//metdata @synthesize metadata; // CDN container attributes @@ -82,6 +87,10 @@ // regular attributes container.name = [dict objectForKey:@"name"]; + //policy + container.versioning = [dict objectForKey:@"x_container_policy_versioning"]; + container.quota = [[dict objectForKey:@"x_container_policy_quota"] integerValue]; + // metadata container.metadata = [NSMutableDictionary dictionary]; for (NSString *key in dict) { diff --git a/Classes/ContainerDetailViewController.m b/Classes/ContainerDetailViewController.m index 7877821..c312605 100755 --- a/Classes/ContainerDetailViewController.m +++ b/Classes/ContainerDetailViewController.m @@ -17,15 +17,17 @@ #import "UserAgentACLViewController.h" #import "ContainersViewController.h" #import "EditMetadataViewController.h" +#import "EditPolicyViewController.h" #import "Folder.h" #define kOverview 0 #define kMetadata 1 -#define kCDNAccess 2 -#define kCDNAttributes 3 -#define kLogRetention 4 -#define kReferrerACL 5 -#define kUserAgentACL 6 +#define kPolicy 2 +#define kCDNAccess 3 +#define kCDNAttributes 4 +#define kLogRetention 5 +#define kReferrerACL 6 +#define kUserAgentACL 7 #define maxMetadataViewableLength 12 @@ -97,7 +99,7 @@ cdnURLActionSheet = [[UIActionSheet alloc] initWithTitle:container.cdnURL delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Copy to Pasteboard", nil]; deleteActionSheet = [[UIActionSheet alloc] initWithTitle:@"Are you sure you want to delete this container? This operation cannot be undone." delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Delete Container" otherButtonTitles:nil]; - deleteSection = container.cdnEnabled ? 7 : 2; + deleteSection = container.cdnEnabled ? 8 : 3; } - (void)viewWillAppear:(BOOL)animated { @@ -214,9 +216,9 @@ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { if (self.container) { if (transitioning) { - return container.cdnEnabled ? 3 : 8; + return container.cdnEnabled ? 4 : 9; } else { - return container.cdnEnabled ? 8 : 3; + return container.cdnEnabled ? 9 : 4; } } else { return 0; @@ -229,6 +231,8 @@ return 2; } else if (section == kMetadata) { return 1 + [container.metadata count]; + } else if (section == kPolicy) { + return 3; } else { return 1; } @@ -361,6 +365,23 @@ cell.textLabel.text = metadataKeyCellText; cell.detailTextLabel.text = metadataValueCellText; } + } else if (indexPath.section == kPolicy) { + if (indexPath.row == 0) { + cell.textLabel.text = @"Versioning"; + cell.detailTextLabel.text = container.versioning; + cell.accessoryType = UITableViewCellAccessoryNone; + } + else if (indexPath.row == 1) { + cell.textLabel.text = @"Quota"; + cell.detailTextLabel.text = [NSString stringWithFormat:@"%u", container.quota]; + cell.accessoryType = UITableViewCellAccessoryNone; + } + else { + cell.textLabel.text = @"Edit policy"; + cell.detailTextLabel.text = @""; + cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; + cell.selectionStyle = UITableViewCellSelectionStyleBlue; + } } else if (indexPath.section == deleteSection) { return [self tableView:tableView deleteCellForRowAtIndexPath:indexPath]; } else if (indexPath.section == kLogRetention) { @@ -424,6 +445,14 @@ [self.navigationController pushViewController:vc animated:YES]; [vc release]; + } else if (indexPath.section == kPolicy) { + EditPolicyViewController *vc = [[EditPolicyViewController alloc] initWithNibName:@"EditPolicyViewController" bundle:nil]; + + vc.account = account; + vc.container = container; + + [self.navigationController pushViewController:vc animated:YES]; + [vc release]; } else if (indexPath.section == deleteSection) { if (self.container.count == 0 || ([self.container.rootFolder.folders count] + [self.container.rootFolder.objects count] == 0)) { [deleteActionSheet showInView:self.view]; diff --git a/Classes/EditPolicyViewController.h b/Classes/EditPolicyViewController.h new file mode 100644 index 0000000..3758ffe --- /dev/null +++ b/Classes/EditPolicyViewController.h @@ -0,0 +1,71 @@ +// +// EditPolicyViewController.h +// pithos-ios +// +// Copyright 2011 GRNET S.A. All rights reserved. +// +// Redistribution and use in source and binary forms, with or +// without modification, are permitted provided that the following +// conditions are met: +// +// 1. Redistributions of source code must retain the above +// copyright notice, this list of conditions and the following +// disclaimer. +// +// 2. Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials +// provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS +// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +// USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +// AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +// The views and conclusions contained in the software and +// documentation are those of the authors and should not be +// interpreted as representing official policies, either expressed +// or implied, of GRNET S.A. + +#import +#import "OpenStackAccount.h" +#import "Container.h" +#import "ActivityIndicatorView.h" + + + +@interface EditPolicyViewController : UITableViewController { + OpenStackAccount *account; + Container *container; + + BOOL autoVersioning; + BOOL manualVersioning; + BOOL noVersioning; + + id successObserver; + id failureObserver; + + NSString *oldVersioning; + NSUInteger oldQuota; + + ActivityIndicatorView *activityIndicatorView; +} + +@property (nonatomic, retain) OpenStackAccount *account; +@property (nonatomic, retain) Container *container; + +@property (nonatomic, retain) NSString *oldVersioning; +@property (nonatomic) NSUInteger oldQuota; + +//Helper Methods +- (void) configVersioningVariables; + +@end diff --git a/Classes/EditPolicyViewController.m b/Classes/EditPolicyViewController.m new file mode 100644 index 0000000..bff4d59 --- /dev/null +++ b/Classes/EditPolicyViewController.m @@ -0,0 +1,305 @@ +// +// EditPolicyViewController.m +// pithos-ios +// +// Copyright 2011 GRNET S.A. All rights reserved. +// +// Redistribution and use in source and binary forms, with or +// without modification, are permitted provided that the following +// conditions are met: +// +// 1. Redistributions of source code must retain the above +// copyright notice, this list of conditions and the following +// disclaimer. +// +// 2. Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials +// provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS +// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +// USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +// AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +// The views and conclusions contained in the software and +// documentation are those of the authors and should not be +// interpreted as representing official policies, either expressed +// or implied, of GRNET S.A. + +#import "EditPolicyViewController.h" +#import "UIViewController+Conveniences.h" +#import "AccountManager.h" + +#define kVersioning 0 +#define kQuota 1 +#define kSavePolicy 2 + +@implementation EditPolicyViewController + +@synthesize account, container; +@synthesize oldVersioning, oldQuota; + +- (void)dealloc +{ + [account release]; + [container release]; + [oldVersioning release]; + [super dealloc]; +} + +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; + +} + +#pragma mark - Helper Methods + +- (void) configVersioningVariables +{ + if ([container.versioning rangeOfString:@"auto"].location != NSNotFound) { + autoVersioning = YES; + manualVersioning = NO; + noVersioning = NO; + } + else if ([container.versioning rangeOfString:@"manual"].location != NSNotFound) { + autoVersioning = NO; + manualVersioning = YES; + noVersioning = NO; + } + else if ([container.versioning rangeOfString:@"none"].location != NSNotFound) { + autoVersioning = NO; + manualVersioning = NO; + noVersioning = YES; + } +} + +#pragma mark - View lifecycle + +- (void)viewDidLoad +{ + [super viewDidLoad]; + [self configVersioningVariables]; + self.navigationItem.title = @"Edit policy"; +} + +- (void)viewDidUnload +{ + [super viewDidUnload]; +} + +- (void)viewWillAppear:(BOOL)animated +{ + [super viewWillAppear:animated]; + +} + +- (void)viewDidAppear:(BOOL)animated +{ + [super viewDidAppear:animated]; +} + +- (void)viewWillDisappear:(BOOL)animated +{ + [super viewWillDisappear:animated]; +} + +- (void)viewDidDisappear:(BOOL)animated +{ + [super viewDidDisappear:animated]; +} + +- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { + return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) || (toInterfaceOrientation == UIInterfaceOrientationPortrait); +} + +#pragma mark - Table view data source + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView +{ + return 3; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section +{ + if (section == kVersioning) + return 2; + else + return 1; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath +{ + static NSString *CellIdentifier = @"Cell"; + + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; + if (cell == nil) { + cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; + } + + if (indexPath.section == kVersioning) { + cell.selectionStyle = UITableViewCellSelectionStyleNone; + if (indexPath.row == 0) { + cell.textLabel.text = @"Auto"; + if (autoVersioning) + cell.accessoryType = UITableViewCellAccessoryCheckmark; + else + cell.accessoryType = UITableViewCellAccessoryNone; + } + else if (indexPath.row == 1) { + cell.textLabel.text = @"Manual"; + if (manualVersioning) + cell.accessoryType = UITableViewCellAccessoryCheckmark; + else + cell.accessoryType = UITableViewCellAccessoryNone; + } + else if (indexPath.row == 2) { + cell.textLabel.text = @"None"; + if (noVersioning) + cell.accessoryType = UITableViewCellAccessoryCheckmark; + else + cell.accessoryType = UITableViewCellAccessoryNone; + } + } + else if (indexPath.section == kQuota) { + CGRect bounds = [cell.contentView bounds]; + CGRect rect = CGRectInset(bounds, 20.0, 10.0); + UITextField *textField = [[UITextField alloc] initWithFrame:rect]; + [textField setFrame:rect]; + [textField setClearButtonMode:UITextFieldViewModeWhileEditing]; + [textField setBackgroundColor:[UIColor whiteColor]]; + [textField setOpaque:YES]; + [textField setAutocorrectionType:UITextAutocorrectionTypeNo]; + [textField setAutocapitalizationType:UITextAutocapitalizationTypeNone]; + [textField setDelegate:self]; + + cell.selectionStyle = UITableViewCellSelectionStyleNone; + textField.text = [NSString stringWithFormat:@"%u", container.quota]; + [cell.contentView addSubview:textField]; + + cell.accessoryType = UITableViewCellAccessoryNone; + } + else if (indexPath.section == kSavePolicy) { + cell.textLabel.text = @"Save"; + cell.accessoryType = UITableViewCellAccessoryNone; + cell.selectionStyle = UITableViewCellSelectionStyleBlue; + } + + return cell; +} + +- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section +{ + if (section == kVersioning) + return @"Versioning"; + else if (section == kQuota) + return @"Quota"; + else + return nil; +} + + +#pragma mark - Table view delegate + +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath +{ + if (indexPath.section == kVersioning) { + if (indexPath.row == 0) { + if (!autoVersioning) { + autoVersioning = YES; + manualVersioning = NO; + noVersioning = NO; + } + } + else if (indexPath.row == 1) { + if (!manualVersioning) { + autoVersioning = NO; + manualVersioning = YES; + noVersioning = NO; + } + } + else if (indexPath.row == 2) { + if (!noVersioning) { + autoVersioning = NO; + manualVersioning = NO; + noVersioning = NO; + } + } + [self.tableView reloadData]; + } + else if (indexPath.section == kSavePolicy) { + self.oldVersioning = container.versioning; + + if (autoVersioning) + container.versioning = @"auto"; + else if (manualVersioning) + container.versioning = @"manual"; + else if (noVersioning) + container.versioning = @"none"; + + NSString *activityMessage = @"Applying policy..."; + activityIndicatorView = [[ActivityIndicatorView alloc] initWithFrame:[ActivityIndicatorView frameForText:activityMessage] text:activityMessage]; + [activityIndicatorView addToView:self.view]; + + [self.account.manager writeContainerPolicy:container]; + + successObserver = [[NSNotificationCenter defaultCenter] addObserverForName:@"writeContainerPolicySucceeded" + object:container + queue:[NSOperationQueue mainQueue] + usingBlock:^(NSNotification *notification) + { + [activityIndicatorView removeFromSuperviewAndRelease]; + [self.tableView deselectRowAtIndexPath:indexPath animated:YES]; + [[NSNotificationCenter defaultCenter] removeObserver:successObserver]; + }]; + failureObserver = [[NSNotificationCenter defaultCenter] addObserverForName:@"writeContainerPolicyFailed" + object:container + queue:[NSOperationQueue mainQueue] + usingBlock:^(NSNotification *notification) + { + container.versioning = self.oldVersioning; + container.quota = self.oldQuota; + [self configVersioningVariables]; + [self.tableView reloadData]; + + [activityIndicatorView removeFromSuperviewAndRelease]; + [self.tableView deselectRowAtIndexPath:indexPath animated:YES]; + [self.tableView reloadData]; + [self alert:@"There was a problem applying the policy." request:[notification.userInfo objectForKey:@"request"]]; + [[NSNotificationCenter defaultCenter] removeObserver:failureObserver]; + }]; + } +} + +#pragma mark - Textfield delegate + +- (void)textFieldDidEndEditing:(UITextField *)textField +{ + if ([textField.text length] == 0 + || [[textField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] length] == 0) { + textField.text = @"0"; + [self.tableView reloadData]; + } + self.oldQuota = container.quota; + self.container.quota = [textField.text integerValue]; + +} + + +- (BOOL)textFieldShouldReturn:(UITextField *)textField +{ + [textField resignFirstResponder]; + return YES; +} + + +@end diff --git a/Classes/EditPolicyViewController.xib b/Classes/EditPolicyViewController.xib new file mode 100644 index 0000000..15e1d19 --- /dev/null +++ b/Classes/EditPolicyViewController.xib @@ -0,0 +1,201 @@ + + + + 1056 + 10K549 + 1306 + 1038.36 + 461.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 301 + + + YES + IBProxyObject + IBUITableView + + + YES + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + YES + + YES + + + + + YES + + IBFilesOwner + IBCocoaTouchFramework + + + IBFirstResponder + IBCocoaTouchFramework + + + + 274 + {{0, 20}, {320, 460}} + + + + 10 + + 549453824 + {84, 1} + + YES + + YES + + + + TU0AKgAAAVjFzNT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/ +y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/ +xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/ +xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/ +xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/ +xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P8ADQEAAAMAAAABAFQAAAEB +AAMAAAABAAEAAAECAAMAAAAEAAAB+gEDAAMAAAABAAEAAAEGAAMAAAABAAIAAAERAAQAAAABAAAACAES +AAMAAAABAAEAAAEVAAMAAAABAAQAAAEWAAMAAAABAAEAAAEXAAQAAAABAAABUAEcAAMAAAABAAEAAAFS +AAMAAAABAAEAAAFTAAMAAAAEAAACAgAAAAAACAAIAAgACAABAAEAAQABA + + + + + + 3 + MCAwAA + + + groupTableViewBackgroundColor + + NO + YES + NO + + IBCocoaTouchFramework + NO + 1 + 1 + 0 + YES + 44 + 10 + 10 + + + + + YES + + + view + + + + 5 + + + + dataSource + + + + 6 + + + + delegate + + + + 7 + + + + + YES + + 0 + + + + + + -1 + + + File's Owner + + + -2 + + + + + 4 + + + + + + + YES + + YES + -1.CustomClassName + -2.CustomClassName + 4.IBEditorWindowLastContentRect + 4.IBPluginDependency + + + YES + EditPolicyViewController + UIResponder + {{329, 504}, {320, 480}} + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + YES + + + + + + YES + + + + + 7 + + + + YES + + EditPolicyViewController + UITableViewController + + IBProjectSource + ./Classes/EditPolicyViewController.h + + + + + 0 + IBCocoaTouchFramework + + com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 + + + YES + 3 + 301 + + diff --git a/Classes/OpenStackRequest.h b/Classes/OpenStackRequest.h index 32e2b1f..8b6b0d9 100755 --- a/Classes/OpenStackRequest.h +++ b/Classes/OpenStackRequest.h @@ -125,6 +125,8 @@ + (OpenStackRequest *)writeObjectMetadataRequest:(OpenStackAccount *)account container:(Container *)container object:(StorageObject *)object; + (OpenStackRequest *)deleteObjectRequest:(OpenStackAccount *)account container:(Container *)container object:(StorageObject *)object; +#pragma mark - Container Requests ++ (OpenStackRequest *)writeContainerPolicyRequest:(OpenStackAccount *)account container:(Container *)container; @end diff --git a/Classes/OpenStackRequest.m b/Classes/OpenStackRequest.m index 24ea7ea..3727417 100755 --- a/Classes/OpenStackRequest.m +++ b/Classes/OpenStackRequest.m @@ -687,6 +687,17 @@ static NSRecursiveLock *accessDetailsLock = nil; } } ++ (OpenStackRequest *)writeContainerPolicyRequest:(OpenStackAccount *)account container:(Container *)container +{ + OpenStackRequest *request = [OpenStackRequest filesRequest:account method:@"PUT" path:[[NSString stringWithFormat:@"/%@", container.name] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; + + [request.requestHeaders setObject:container.versioning forKey:@"X-Container-Policy-Versioning"]; + [request.requestHeaders setObject:[NSString stringWithFormat:@"%lu", container.quota] forKey:@"X-Container-Policy-Quota"]; + + return request; +} + + #pragma mark - #pragma mark Memory Management diff --git a/OpenStack.xcodeproj/project.pbxproj b/OpenStack.xcodeproj/project.pbxproj index 10a4954..fbe1a65 100755 --- a/OpenStack.xcodeproj/project.pbxproj +++ b/OpenStack.xcodeproj/project.pbxproj @@ -11,6 +11,8 @@ 1D60589B0D05DD56006BFB54 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; }; 2485477B1446D36800E48921 /* EditPermissionsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 248547791446D36800E48921 /* EditPermissionsViewController.m */; }; 2485477C1446D36800E48921 /* EditPermissionsViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2485477A1446D36800E48921 /* EditPermissionsViewController.xib */; }; + 2485478914473CBB00E48921 /* EditPolicyViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2485478714473CBA00E48921 /* EditPolicyViewController.m */; }; + 2485478A14473CBB00E48921 /* EditPolicyViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2485478814473CBB00E48921 /* EditPolicyViewController.xib */; }; 24A18E22143DB870003232F1 /* EditMetadataViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 24A18E20143DB870003232F1 /* EditMetadataViewController.m */; }; 24A18E23143DB870003232F1 /* EditMetadataViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 24A18E21143DB870003232F1 /* EditMetadataViewController.xib */; }; 24A18E56143F0429003232F1 /* FolderDetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 24A18E54143F0428003232F1 /* FolderDetailViewController.m */; }; @@ -1079,6 +1081,9 @@ 248547781446D36700E48921 /* EditPermissionsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EditPermissionsViewController.h; sourceTree = ""; }; 248547791446D36800E48921 /* EditPermissionsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EditPermissionsViewController.m; sourceTree = ""; }; 2485477A1446D36800E48921 /* EditPermissionsViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = EditPermissionsViewController.xib; sourceTree = ""; }; + 2485478614473CBA00E48921 /* EditPolicyViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EditPolicyViewController.h; sourceTree = ""; }; + 2485478714473CBA00E48921 /* EditPolicyViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EditPolicyViewController.m; sourceTree = ""; }; + 2485478814473CBB00E48921 /* EditPolicyViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = EditPolicyViewController.xib; sourceTree = ""; }; 24A18E1F143DB86F003232F1 /* EditMetadataViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EditMetadataViewController.h; sourceTree = ""; }; 24A18E20143DB870003232F1 /* EditMetadataViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EditMetadataViewController.m; sourceTree = ""; }; 24A18E21143DB870003232F1 /* EditMetadataViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = EditMetadataViewController.xib; sourceTree = ""; }; @@ -3130,6 +3135,9 @@ 2788941712C28C66006448E2 /* ContainerDetailViewController.h */, 2788941812C28C66006448E2 /* ContainerDetailViewController.m */, 2788941912C28C66006448E2 /* ContainerDetailViewController.xib */, + 2485478614473CBA00E48921 /* EditPolicyViewController.h */, + 2485478714473CBA00E48921 /* EditPolicyViewController.m */, + 2485478814473CBB00E48921 /* EditPolicyViewController.xib */, ); name = "Object Storage"; sourceTree = ""; @@ -3690,6 +3698,7 @@ 24A18E23143DB870003232F1 /* EditMetadataViewController.xib in Resources */, 24A18E57143F0429003232F1 /* FolderDetailViewController.xib in Resources */, 2485477C1446D36800E48921 /* EditPermissionsViewController.xib in Resources */, + 2485478A14473CBB00E48921 /* EditPolicyViewController.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -4211,6 +4220,7 @@ 24A18E22143DB870003232F1 /* EditMetadataViewController.m in Sources */, 24A18E56143F0429003232F1 /* FolderDetailViewController.m in Sources */, 2485477B1446D36800E48921 /* EditPermissionsViewController.m in Sources */, + 2485478914473CBB00E48921 /* EditPolicyViewController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; -- 1.7.10.4