Revision 919cb043 pithos-macos/PithosSubdirNode.m
b/pithos-macos/PithosSubdirNode.m | ||
---|---|---|
2 | 2 |
// PithosSubdirNode.m |
3 | 3 |
// pithos-macos |
4 | 4 |
// |
5 |
// Copyright 2011 GRNET S.A. All rights reserved. |
|
5 |
// Copyright 2011-2012 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 |
... | ... | |
37 | 37 |
|
38 | 38 |
#import "PithosSubdirNode.h" |
39 | 39 |
#import "ASIPithosRequest.h" |
40 |
#import "ASIPithos.h" |
|
40 | 41 |
#import "ASIPithosObjectRequest.h" |
41 | 42 |
#import "ASIPithosContainer.h" |
42 | 43 |
#import "ASIPithosObject.h" |
... | ... | |
58 | 59 |
#pragma mark - |
59 | 60 |
#pragma mark Object Lifecycle |
60 | 61 |
|
61 |
- (id)initWithPithosContainer:(ASIPithosContainer *)aPithosContainer pithosObject:(ASIPithosObject *)aPithosObject { |
|
62 |
- (id)initWithPithos:(ASIPithos *)aPithos |
|
63 |
pithosContainer:(ASIPithosContainer *)aPithosContainer |
|
64 |
pithosObject:(ASIPithosObject *)aPithosObject { |
|
62 | 65 |
if ((self = [super init])) { |
66 |
self.pithos = aPithos; |
|
63 | 67 |
self.pithosContainer = aPithosContainer; |
64 | 68 |
self.pithosObject = aPithosObject; |
65 | 69 |
childrenUpdatedNotificationName = @"PithosSubdirNodeChildrenUpdated"; |
... | ... | |
83 | 87 |
- (NSString *)url { |
84 | 88 |
if (url == nil) |
85 | 89 |
url = [[NSString alloc] initWithFormat:@"subdir %@/%@/%@%@", |
86 |
(sharingAccount ? [ASIPithosRequest storageURLWithAuthUser:sharingAccount] : [ASIPithosRequest storageURL]),
|
|
90 |
(sharingAccount ? [pithos storageURLWithAuthUser:sharingAccount] : pithos.storageURL),
|
|
87 | 91 |
pithosContainer.name, |
88 | 92 |
prefix, |
89 | 93 |
(shared ? @"?shared" : @"")]; |
... | ... | |
188 | 192 |
if (pithosObject.subdir) { |
189 | 193 |
BOOL createObject = NO; |
190 | 194 |
NSAlert *alert; |
191 |
ASIPithosObjectRequest *request = [ASIPithosObjectRequest objectMetadataRequestWithContainerName:pithosContainer.name |
|
192 |
objectName:prefix]; |
|
195 |
ASIPithosObjectRequest *request = [ASIPithosObjectRequest objectMetadataRequestWithPithos:pithos |
|
196 |
containerName:pithosContainer.name |
|
197 |
objectName:prefix]; |
|
193 | 198 |
[[PithosUtilities prepareRequest:request] startAsynchronous]; |
194 | 199 |
while (![request isFinished]) { |
195 | 200 |
usleep(1); |
... | ... | |
209 | 214 |
[alert addButtonWithTitle:@"Cancel"]; |
210 | 215 |
NSInteger choice = [alert runModal]; |
211 | 216 |
if (choice == NSAlertFirstButtonReturn) { |
212 |
request = [ASIPithosObjectRequest deleteObjectRequestWithContainerName:pithosContainer.name |
|
213 |
objectName:prefix]; |
|
217 |
request = [ASIPithosObjectRequest deleteObjectRequestWithPithos:pithos |
|
218 |
containerName:pithosContainer.name |
|
219 |
objectName:prefix]; |
|
214 | 220 |
[[PithosUtilities prepareRequest:request] startAsynchronous]; |
215 | 221 |
while (![request isFinished]) { |
216 | 222 |
usleep(1); |
... | ... | |
239 | 245 |
} |
240 | 246 |
if (createObject) { |
241 | 247 |
[[pithosNodeInfoController window] makeFirstResponder:nil]; |
242 |
applyMetadataObjectRequest = [[ASIPithosObjectRequest writeObjectDataRequestWithContainerName:pithosContainer.name |
|
243 |
objectName:prefix |
|
244 |
eTag:nil |
|
245 |
contentType:@"application/directory" |
|
246 |
contentEncoding:pithosObject.contentEncoding |
|
247 |
contentDisposition:pithosObject.contentDisposition |
|
248 |
manifest:pithosObject.manifest |
|
249 |
sharing:pithosObject.sharing |
|
250 |
isPublic:(isPublic ? ASIPithosObjectRequestPublicTrue : ASIPithosObjectRequestPublicFalse) |
|
251 |
metadata:pithosObject.metadata |
|
252 |
data:[NSData data]] retain]; |
|
248 |
applyMetadataObjectRequest = [[ASIPithosObjectRequest writeObjectDataRequestWithPithos:pithos |
|
249 |
containerName:pithosContainer.name |
|
250 |
objectName:prefix |
|
251 |
eTag:nil |
|
252 |
contentType:@"application/directory" |
|
253 |
contentEncoding:pithosObject.contentEncoding |
|
254 |
contentDisposition:pithosObject.contentDisposition |
|
255 |
manifest:pithosObject.manifest |
|
256 |
sharing:pithosObject.sharing |
|
257 |
isPublic:(isPublic ? ASIPithosObjectRequestPublicTrue : ASIPithosObjectRequestPublicFalse) |
|
258 |
metadata:pithosObject.metadata |
|
259 |
data:[NSData data]] retain]; |
|
253 | 260 |
pithosObject.subdir = NO; |
254 | 261 |
applyMetadataObjectRequest.delegate = self; |
255 | 262 |
applyMetadataObjectRequest.didFinishSelector = @selector(performRequestFinishedDelegateInBackground:); |
... | ... | |
265 | 272 |
} else { |
266 | 273 |
[[pithosNodeInfoController window] makeFirstResponder:nil]; |
267 | 274 |
if (sharingAccount) { |
268 |
applyMetadataObjectRequest = [[ASIPithosObjectRequest updateObjectMetadataRequestWithContainerName:pithosContainer.name |
|
269 |
objectName:pithosObject.name |
|
270 |
contentEncoding:nil |
|
271 |
contentDisposition:nil |
|
272 |
manifest:nil |
|
273 |
sharing:nil |
|
274 |
isPublic:(isPublic ? ASIPithosObjectRequestPublicTrue : ASIPithosObjectRequestPublicFalse) |
|
275 |
metadata:pithosObject.metadata |
|
276 |
update:NO] retain]; |
|
277 |
[applyMetadataObjectRequest setRequestUserFromDefaultTo:sharingAccount]; |
|
275 |
applyMetadataObjectRequest = [[ASIPithosObjectRequest updateObjectMetadataRequestWithPithos:pithos |
|
276 |
containerName:pithosContainer.name |
|
277 |
objectName:pithosObject.name |
|
278 |
contentEncoding:nil |
|
279 |
contentDisposition:nil |
|
280 |
manifest:nil |
|
281 |
sharing:nil |
|
282 |
isPublic:(isPublic ? ASIPithosObjectRequestPublicTrue : ASIPithosObjectRequestPublicFalse) |
|
283 |
metadata:pithosObject.metadata |
|
284 |
update:NO] retain]; |
|
285 |
[applyMetadataObjectRequest setRequestUserFromDefaultTo:sharingAccount withPithos:pithos]; |
|
278 | 286 |
} else { |
279 |
applyMetadataObjectRequest = [[ASIPithosObjectRequest updateObjectMetadataRequestWithContainerName:pithosContainer.name |
|
280 |
objectName:pithosObject.name |
|
281 |
contentEncoding:pithosObject.contentEncoding |
|
282 |
contentDisposition:pithosObject.contentDisposition |
|
283 |
manifest:pithosObject.manifest |
|
284 |
sharing:(pithosObject.sharing ? pithosObject.sharing : @"") |
|
285 |
isPublic:(isPublic ? ASIPithosObjectRequestPublicTrue : ASIPithosObjectRequestPublicFalse) |
|
286 |
metadata:pithosObject.metadata |
|
287 |
update:NO] retain]; |
|
287 |
applyMetadataObjectRequest = [[ASIPithosObjectRequest updateObjectMetadataRequestWithPithos:pithos |
|
288 |
containerName:pithosContainer.name |
|
289 |
objectName:pithosObject.name |
|
290 |
contentEncoding:pithosObject.contentEncoding |
|
291 |
contentDisposition:pithosObject.contentDisposition |
|
292 |
manifest:pithosObject.manifest |
|
293 |
sharing:(pithosObject.sharing ? pithosObject.sharing : @"") |
|
294 |
isPublic:(isPublic ? ASIPithosObjectRequestPublicTrue : ASIPithosObjectRequestPublicFalse) |
|
295 |
metadata:pithosObject.metadata |
|
296 |
update:NO] retain]; |
|
288 | 297 |
} |
289 | 298 |
applyMetadataObjectRequest.delegate = self; |
290 | 299 |
applyMetadataObjectRequest.didFinishSelector = @selector(performRequestFinishedDelegateInBackground:); |
... | ... | |
306 | 315 |
if (pithosObject.subdir) { |
307 | 316 |
self.pithosObject = [ASIPithosObject subdirWithName:pithosObject.name]; |
308 | 317 |
} else if (refreshMetadataObjectRequest == nil) { |
309 |
refreshMetadataObjectRequest = [[ASIPithosObjectRequest objectMetadataRequestWithContainerName:pithosContainer.name |
|
310 |
objectName:prefix] retain]; |
|
318 |
refreshMetadataObjectRequest = [[ASIPithosObjectRequest objectMetadataRequestWithPithos:pithos |
|
319 |
containerName:pithosContainer.name |
|
320 |
objectName:prefix] retain]; |
|
311 | 321 |
if (sharingAccount) |
312 |
[refreshMetadataObjectRequest setRequestUserFromDefaultTo:sharingAccount]; |
|
322 |
[refreshMetadataObjectRequest setRequestUserFromDefaultTo:sharingAccount withPithos:pithos];
|
|
313 | 323 |
refreshMetadataObjectRequest.delegate = self; |
314 | 324 |
refreshMetadataObjectRequest.didFinishSelector = @selector(performRequestFinishedDelegateInBackground:); |
315 | 325 |
refreshMetadataObjectRequest.didFailSelector = @selector(performRequestFailedDelegateInBackground:); |
Also available in: Unified diff