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