#pragma mark -
#pragma mark Properties
+- (void)setPithos:(ASIPithos *)aPithos {
+ if (aPithos && ![aPithos isEqualTo:pithos]) {
+ [pithos release];
+ pithos = [aPithos retain];
+ [url release];
+ url = nil;
+ }
+}
+
- (NSString *)url {
if (url == nil)
url = [[NSString alloc] initWithFormat:@"object %@/%@/%@%@",
[[NSNotificationCenter defaultCenter] postNotificationName:@"PithosBrowserRefreshNeeeded" object:self];
}
+- (void)setLimitedPithosObject:(ASIPithosObject *)aPithosObject {
+ if (![pithosObject isEqualTo:aPithosObject]) {
+ self.pithosObject.subdir = aPithosObject.subdir;
+ self.pithosObject.name = aPithosObject.name;
+ self.pithosObject.hash = aPithosObject.hash;
+ self.pithosObject.objectHash = aPithosObject.objectHash;
+ self.pithosObject.UUID = aPithosObject.UUID;
+ self.pithosObject.bytes = aPithosObject.bytes;
+ self.pithosObject.contentType = aPithosObject.contentType;
+ self.pithosObject.lastModified = aPithosObject.lastModified;
+ self.pithosObject.version = aPithosObject.version;
+ self.pithosObject.versionTimestamp = aPithosObject.versionTimestamp;
+ self.pithosObject.modifiedBy = aPithosObject.modifiedBy;
+ self.pithosObject.sharedBy = aPithosObject.sharedBy;
+ self.pithosObject.allowedTo = aPithosObject.allowedTo;
+ if (!pithosNodeInfoController) {
+ self.pithosObject.sharing = aPithosObject.sharing;
+ self.pithosObject.publicURI = aPithosObject.publicURI;
+ self.pithosObject = pithosObject;
+ }
+ }
+}
+
#pragma mark -
#pragma mark ASIHTTPRequestDelegate
- (void)objectRequestFailed:(ASIPithosObjectRequest *)request {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- if ([request isEqualTo:applyMetadataObjectRequest]) {
- [PithosUtilities httpRequestErrorAlertWithRequest:applyMetadataObjectRequest];
- @synchronized(self) {
- [applyMetadataObjectRequest release];
- applyMetadataObjectRequest = nil;
+ NSUInteger retries = [[request.userInfo objectForKey:@"retries"] unsignedIntegerValue];
+ if (retries > 0) {
+ ASIPithosObjectRequest *newRequest = (ASIPithosObjectRequest *)[PithosUtilities copyRequest:request];
+ [(NSMutableDictionary *)(newRequest.userInfo)setObject:[NSNumber numberWithUnsignedInteger:(--retries)] forKey:@"retries"];
+ if ([request isEqualTo:applyMetadataObjectRequest]) {
+ @synchronized(self) {
+ [applyMetadataObjectRequest release];
+ applyMetadataObjectRequest = newRequest;
+ }
+ } else if ([request isEqualTo:refreshMetadataObjectRequest]) {
+ @synchronized(self) {
+ [refreshMetadataObjectRequest release];
+ refreshMetadataObjectRequest = newRequest;
+ }
}
- } else if ([request isEqualTo:refreshMetadataObjectRequest]) {
- [PithosUtilities httpRequestErrorAlertWithRequest:refreshMetadataObjectRequest];
- @synchronized(self) {
- [refreshMetadataObjectRequest release];
- refreshMetadataObjectRequest = nil;
+ [[PithosUtilities prepareRequest:newRequest priority:[[newRequest.userInfo objectForKey:@"priority"] integerValue]] startAsynchronous];
+ } else {
+ if ([request isEqualTo:applyMetadataObjectRequest]) {
+ dispatch_async(dispatch_get_main_queue(), ^{
+ [PithosUtilities httpRequestErrorAlertWithRequest:applyMetadataObjectRequest];
+ });
+ @synchronized(self) {
+ [applyMetadataObjectRequest release];
+ applyMetadataObjectRequest = nil;
+ }
+ } else if ([request isEqualTo:refreshMetadataObjectRequest]) {
+ dispatch_async(dispatch_get_main_queue(), ^{
+ [PithosUtilities httpRequestErrorAlertWithRequest:refreshMetadataObjectRequest];
+ });
+ @synchronized(self) {
+ [refreshMetadataObjectRequest release];
+ refreshMetadataObjectRequest = nil;
+ }
}
}
[pool drain];
#pragma mark Actions
- (void)showPithosNodeInfo:(id)sender {
- if (!pithosNodeInfoController)
+ if (!pithosNodeInfoController) {
pithosNodeInfoController = [[PithosObjectNodeInfoController alloc] initWithPithosNode:self];
+ [self refreshInfo];
+ }
[pithosNodeInfoController showWindow:sender];
[[pithosNodeInfoController window] makeKeyAndOrderFront:sender];
[NSApp activateIgnoringOtherApps:YES];