Refactored GCSFolder: -writeContent and fixed sogo-tool restore
parent
f43341c100
commit
cde1db9324
|
@ -118,13 +118,10 @@
|
|||
|
||||
- (NSException *) writeContent: (NSString *) _content
|
||||
fromComponent: (id) theComponent
|
||||
container: (id) theContainer
|
||||
toName: (NSString *) _name
|
||||
baseVersion: (unsigned int *) _baseVersion;
|
||||
|
||||
- (NSException *) writeContent: (NSString *) _content
|
||||
fromComponent: (id) theComponent
|
||||
toName: (NSString *) _name;
|
||||
|
||||
- (NSException *) deleteContentWithName: (NSString *) _name;
|
||||
- (NSException *) deleteAllContent;
|
||||
|
||||
|
|
|
@ -882,7 +882,8 @@ andAttribute: (EOAttribute *)_attribute
|
|||
|
||||
- (NSException *) writeContent: (NSString *) _content
|
||||
fromComponent: (id) theComponent
|
||||
toName: (NSString *) _name
|
||||
container: (id) theContainer
|
||||
toName: (NSString *) _name
|
||||
baseVersion: (unsigned int *) _baseVersion
|
||||
{
|
||||
EOAdaptorChannel *storeChannel, *quickChannel;
|
||||
|
@ -943,7 +944,7 @@ andAttribute: (EOAttribute *)_attribute
|
|||
|| *_baseVersion == [storedVersion unsignedIntValue])
|
||||
{
|
||||
/* extract quick info */
|
||||
quickRow = [theComponent performSelector: @selector(quickRecordForContainer:) withObject: self];
|
||||
quickRow = [theComponent performSelector: @selector(quickRecordForContainer:) withObject: theContainer];
|
||||
if (quickRow)
|
||||
{
|
||||
[quickRow setObject:_name forKey:@"c_name"];
|
||||
|
@ -1099,16 +1100,6 @@ andAttribute: (EOAttribute *)_attribute
|
|||
return error;
|
||||
}
|
||||
|
||||
|
||||
- (NSException *)writeContent:(NSString *)_content
|
||||
fromComponent: (id) theComponent
|
||||
toName:(NSString *)_name
|
||||
{
|
||||
/* this method does not check for concurrent writes */
|
||||
unsigned int v = 0;
|
||||
return [self writeContent:_content fromComponent: theComponent toName:_name baseVersion:&v];
|
||||
}
|
||||
|
||||
- (NSException *)deleteContentWithName:(NSString *)_name {
|
||||
EOAdaptorChannel *storeChannel, *quickChannel;
|
||||
EOAdaptorContext *adaptorCtx;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 2006-2011 Inverse inc.
|
||||
Copyright (C) 2006-2014 Inverse inc.
|
||||
Copyright (C) 2004-2005 SKYRIX Software AG
|
||||
|
||||
This file is part of SOGo.
|
||||
|
|
|
@ -221,6 +221,7 @@
|
|||
{
|
||||
ex = [folder writeContent: newContent
|
||||
fromComponent: theComponent
|
||||
container: container
|
||||
toName: nameInContainer
|
||||
baseVersion: &version];
|
||||
if (ex)
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
/* SOGoToolRestore.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2009-2012 Inverse inc.
|
||||
*
|
||||
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
* Copyright (C) 2009-2014 Inverse inc.
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -43,6 +41,10 @@
|
|||
#import <SOGo/SOGoUserProfile.h>
|
||||
#import <SOGo/SOGoUserSettings.h>
|
||||
|
||||
#import <NGCards/iCalCalendar.h>
|
||||
#import <NGCards/NGVCard.h>
|
||||
#import <NGCards/NGVList.h>
|
||||
|
||||
#import "SOGoTool.h"
|
||||
|
||||
/* TODO:
|
||||
|
@ -116,6 +118,29 @@ typedef enum SOGoToolRestoreMode {
|
|||
" sogo-tool restore -p /tmp/foo bob\n");
|
||||
}
|
||||
|
||||
- (Class) parsingClassForContent: (NSString *) theContent
|
||||
{
|
||||
CardGroup *cardEntry;
|
||||
NSString *firstTag;
|
||||
Class objectClass;
|
||||
|
||||
objectClass = Nil;
|
||||
|
||||
cardEntry = [CardGroup parseSingleFromSource: theContent];
|
||||
if (cardEntry)
|
||||
{
|
||||
firstTag = [[cardEntry tag] uppercaseString];
|
||||
if ([firstTag isEqualToString: @"VCARD"])
|
||||
objectClass = [NGVCard class];
|
||||
else if ([firstTag isEqualToString: @"VLIST"])
|
||||
objectClass = [NGVList class];
|
||||
else
|
||||
objectClass = [iCalCalendar class];
|
||||
}
|
||||
|
||||
return objectClass;
|
||||
}
|
||||
|
||||
- (BOOL) checkDirectory
|
||||
{
|
||||
NSFileManager *fm;
|
||||
|
@ -347,11 +372,12 @@ typedef enum SOGoToolRestoreMode {
|
|||
- (BOOL) restoreRecords: (NSArray *) records
|
||||
ofFolder: (GCSFolder *) gcsFolder
|
||||
{
|
||||
NSAutoreleasePool *pool;
|
||||
NSDictionary *existingRecords, *currentRecord;
|
||||
NSString *cName, *cContent;
|
||||
int count, max;
|
||||
NSAutoreleasePool *pool;
|
||||
|
||||
unsigned int version;
|
||||
int count, max;
|
||||
BOOL rc;
|
||||
|
||||
if (records)
|
||||
|
@ -375,6 +401,8 @@ typedef enum SOGoToolRestoreMode {
|
|||
NSLog (@"restoring record '%@'", cName);
|
||||
cContent = [currentRecord objectForKey: @"c_content"];
|
||||
[gcsFolder writeContent: cContent
|
||||
fromComponent: [[self parsingClassForContent: cContent] parseSingleFromSource: cContent]
|
||||
container: nil
|
||||
toName: cName
|
||||
baseVersion: &version];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue