Revision fb27f368 pithos-macos/PithosObjectNode.m
b/pithos-macos/PithosObjectNode.m | ||
---|---|---|
2 | 2 |
// PithosObjectNode.m |
3 | 3 |
// pithos-macos |
4 | 4 |
// |
5 |
// Copyright 2011-2012 GRNET S.A. All rights reserved.
|
|
5 |
// Copyright 2011-2013 GRNET S.A. All rights reserved.
|
|
6 | 6 |
// |
7 | 7 |
// Redistribution and use in source and binary forms, with or |
8 | 8 |
// without modification, are permitted provided that the following |
... | ... | |
48 | 48 |
#import "PithosObjectNodeInfoController.h" |
49 | 49 |
|
50 | 50 |
@implementation PithosObjectNode |
51 |
@synthesize pithos, pithosContainer, pithosObject, versions, applyMetadataObjectRequest, refreshMetadataObjectRequest, refreshVersionsObjectRequest;
|
|
51 |
@synthesize pithosContainer, pithosObject, versions, applyMetadataObjectRequest, refreshMetadataObjectRequest, refreshVersionsObjectRequest; |
|
52 | 52 |
@synthesize isPublic, translatedModifiedBy, translatedPermissions; |
53 | 53 |
|
54 | 54 |
#pragma mark - |
55 | 55 |
#pragma mark Object Lifecycle |
56 | 56 |
|
57 | 57 |
- (id)initWithPithosAccountManager:(PithosAccount *)aPithosAccountManager |
58 |
andPithos:(ASIPithos *)aPithos |
|
59 | 58 |
pithosContainer:(ASIPithosContainer *)aPithosContainer |
60 | 59 |
pithosObject:(ASIPithosObject *)aPithosObject { |
61 | 60 |
if ((self = [super initWithPithosAccountManager:aPithosAccountManager])) { |
62 |
pithos = aPithos; |
|
63 | 61 |
isLeafItem = YES; |
64 | 62 |
self.pithosContainer = aPithosContainer; |
65 | 63 |
self.pithosObject = aPithosObject; |
... | ... | |
121 | 119 |
#pragma mark - |
122 | 120 |
#pragma mark Properties |
123 | 121 |
|
124 |
- (void)setPithos:(ASIPithos *)aPithos { |
|
125 |
if (aPithos && ![aPithos isEqualTo:pithos]) { |
|
126 |
pithos = aPithos; |
|
127 |
url = nil; |
|
128 |
} |
|
129 |
} |
|
130 |
|
|
131 | 122 |
- (NSString *)url { |
132 |
if (url == nil) |
|
133 |
url = [[NSString alloc] initWithFormat:@"object %@/%@/%@%@", |
|
134 |
(sharingAccount ? [pithos storageURLWithAuthUser:sharingAccount] : pithos.storageURL), |
|
135 |
pithosContainer.name, |
|
136 |
pithosObject.name, |
|
137 |
(shared ? @"?shared" : @"")]; |
|
138 |
return url; |
|
123 |
return [NSString stringWithFormat:@"@object@%@/%@/%@%@", |
|
124 |
(sharingAccount ? sharingAccount : pithosAccountManager.pithos.authUser), |
|
125 |
pithosContainer.name, |
|
126 |
pithosObject.name, |
|
127 |
(shared ? @"?shared" : @"")]; |
|
139 | 128 |
} |
140 | 129 |
|
141 | 130 |
- (NSArray *)children { |
... | ... | |
280 | 269 |
if (applyMetadataObjectRequest == nil) { |
281 | 270 |
[[pithosNodeInfoController window] makeFirstResponder:nil]; |
282 | 271 |
if (sharingAccount) { |
283 |
self.applyMetadataObjectRequest = [ASIPithosObjectRequest updateObjectMetadataRequestWithPithos:pithos |
|
272 |
self.applyMetadataObjectRequest = [ASIPithosObjectRequest updateObjectMetadataRequestWithPithos:pithosAccountManager.pithos
|
|
284 | 273 |
containerName:pithosContainer.name |
285 | 274 |
objectName:pithosObject.name |
286 | 275 |
contentEncoding:nil |
... | ... | |
290 | 279 |
isPublic:(isPublic ? ASIPithosObjectRequestPublicTrue : ASIPithosObjectRequestPublicFalse) |
291 | 280 |
metadata:pithosObject.metadata |
292 | 281 |
update:NO]; |
293 |
[applyMetadataObjectRequest setRequestUserFromDefaultTo:sharingAccount withPithos:pithos]; |
|
282 |
[applyMetadataObjectRequest setRequestUserFromDefaultTo:sharingAccount withPithos:pithosAccountManager.pithos];
|
|
294 | 283 |
} else { |
295 | 284 |
NSMutableArray *permissions = [NSMutableArray array]; |
296 | 285 |
if (translatedPermissions.count) { |
... | ... | |
410 | 399 |
} |
411 | 400 |
pithosObject.permissions = permissions; |
412 | 401 |
|
413 |
self.applyMetadataObjectRequest = [ASIPithosObjectRequest updateObjectMetadataRequestWithPithos:pithos |
|
402 |
self.applyMetadataObjectRequest = [ASIPithosObjectRequest updateObjectMetadataRequestWithPithos:pithosAccountManager.pithos
|
|
414 | 403 |
containerName:pithosContainer.name |
415 | 404 |
objectName:pithosObject.name |
416 | 405 |
contentEncoding:pithosObject.contentEncoding |
... | ... | |
438 | 427 |
- (void)refreshInfo { |
439 | 428 |
@synchronized(self) { |
440 | 429 |
if (refreshMetadataObjectRequest == nil) { |
441 |
self.refreshMetadataObjectRequest = [ASIPithosObjectRequest objectMetadataRequestWithPithos:pithos |
|
430 |
self.refreshMetadataObjectRequest = [ASIPithosObjectRequest objectMetadataRequestWithPithos:pithosAccountManager.pithos
|
|
442 | 431 |
containerName:pithosContainer.name |
443 | 432 |
objectName:pithosObject.name]; |
444 | 433 |
if (sharingAccount) |
445 |
[refreshMetadataObjectRequest setRequestUserFromDefaultTo:sharingAccount withPithos:pithos]; |
|
434 |
[refreshMetadataObjectRequest setRequestUserFromDefaultTo:sharingAccount withPithos:pithosAccountManager.pithos];
|
|
446 | 435 |
refreshMetadataObjectRequest.delegate = self; |
447 | 436 |
refreshMetadataObjectRequest.didFinishSelector = @selector(performRequestFinishedDelegateInBackground:); |
448 | 437 |
refreshMetadataObjectRequest.didFailSelector = @selector(performRequestFailedDelegateInBackground:); |
... | ... | |
466 | 455 |
- (void)refreshVersions { |
467 | 456 |
@synchronized(self) { |
468 | 457 |
if (refreshVersionsObjectRequest == nil) { |
469 |
self.refreshVersionsObjectRequest = [ASIPithosObjectRequest objectVersionsRequestWithPithos:pithos |
|
458 |
self.refreshVersionsObjectRequest = [ASIPithosObjectRequest objectVersionsRequestWithPithos:pithosAccountManager.pithos
|
|
470 | 459 |
containerName:pithosContainer.name |
471 | 460 |
objectName:pithosObject.name]; |
472 | 461 |
if (sharingAccount) |
473 |
[refreshVersionsObjectRequest setRequestUserFromDefaultTo:sharingAccount withPithos:pithos]; |
|
462 |
[refreshVersionsObjectRequest setRequestUserFromDefaultTo:sharingAccount withPithos:pithosAccountManager.pithos];
|
|
474 | 463 |
refreshVersionsObjectRequest.delegate = self; |
475 | 464 |
refreshVersionsObjectRequest.didFinishSelector = @selector(performRequestFinishedDelegateInBackground:); |
476 | 465 |
refreshVersionsObjectRequest.didFailSelector = @selector(performRequestFailedDelegateInBackground:); |
Also available in: Unified diff