chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1425870 [4/13] - in /chemistry/objectivecmis/trunk: ./ ObjectiveCMIS.xcodeproj/ ObjectiveCMIS.xcodeproj/project.xcworkspace/ ObjectiveCMIS/ ObjectiveCMIS/Bindings/ ObjectiveCMIS/Bindings/AtomPub/ ObjectiveCMIS/Bindings/AtomPub/AtomPubParse...
Date Wed, 26 Dec 2012 10:48:37 GMT
Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISRepositoryInfoParser.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISRepositoryInfoParser.m?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISRepositoryInfoParser.m (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISRepositoryInfoParser.m Wed Dec 26 10:48:33 2012
@@ -0,0 +1,206 @@
+/*
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+ */
+
+#import "CMISRepositoryInfoParser.h"
+#import "CMISAtomPubConstants.h"
+#import "CMISAtomCollection.h"
+
+@interface CMISRepositoryInfoParser ()
+
+@property (nonatomic, strong, readwrite) CMISRepositoryInfo *currentRepositoryInfo;
+
+@property (nonatomic, weak) id<NSXMLParserDelegate, CMISRepositoryInfoParserDelegate> parentDelegate;
+@property (nonatomic, strong) NSMutableString *currentString;
+@property (nonatomic, strong) CMISAtomCollection *currentCollection;
+
+// TODO Temporary object, replace with CMISRepositoryCapabilities object or similar when available
+@property (nonatomic, strong) id currentCapabilities;
+
+@property (nonatomic, assign) BOOL isParsingExtensionElement;
+@end
+
+@implementation CMISRepositoryInfoParser
+
+@synthesize currentRepositoryInfo = _currentRepositoryInfo;
+@synthesize parentDelegate = _parentDelegate;
+@synthesize currentString = _currentString;
+@synthesize currentCollection = _currentCollection;
+@synthesize currentCapabilities = _currentCapabilities;
+@synthesize isParsingExtensionElement = _isParsingExtensionElement;
+
+
+- (id)initRepositoryInfoParserWithParentDelegate:(id<NSXMLParserDelegate, CMISRepositoryInfoParserDelegate>)parentDelegate parser:(NSXMLParser *)parser
+{
+    self = [super init];
+    if (self)
+    {
+        self.currentString = [[NSMutableString alloc] init];
+        self.currentRepositoryInfo = [[CMISRepositoryInfo alloc] init];
+        self.parentDelegate = parentDelegate;
+        
+        self.isParsingExtensionElement = NO;
+        
+        [self pushNewCurrentExtensionData:self.currentRepositoryInfo];
+        
+        [parser setDelegate:self];
+    }
+    return self;
+}
+
++ (id)repositoryInfoParserWithParentDelegate:(id<NSXMLParserDelegate, CMISRepositoryInfoParserDelegate>)parentDelegate parser:(NSXMLParser *)parser
+{
+    return [[self alloc] initRepositoryInfoParserWithParentDelegate:parentDelegate parser:parser];
+}
+
+#pragma mark -
+#pragma mark NSXMLParser delegate methods
+
+- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict 
+{
+    self.currentString = [[NSMutableString alloc] init];
+    
+    if ([namespaceURI isEqualToString:kCMISNamespaceCmis])
+    {
+        if ([elementName isEqualToString:kCMISCoreCapabilities])
+        {
+            self.currentCapabilities = [NSMutableDictionary dictionaryWithCapacity:14];
+        }
+    }
+    else if ( ![namespaceURI isEqualToString:kCMISNamespaceCmis] && ![namespaceURI isEqualToString:kCMISNamespaceApp] 
+              && ![namespaceURI isEqualToString:kCMISNamespaceAtom] && ![namespaceURI isEqualToString:kCMISNamespaceCmisRestAtom]) 
+    {
+        self.isParsingExtensionElement = YES;
+        self.childParserDelegate = [CMISAtomPubExtensionElementParser extensionElementParserWithElementName:elementName namespaceUri:namespaceURI attributes:attributeDict parentDelegate:self parser:parser];
+    }
+    
+    // TODO Parse ACL Capabilities
+}
+
+- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string 
+{
+    // Simply add the parsed string to the current string
+    // Do not add any logic here, since the parser splits up data rather easily
+    // (eg when an ampersand is used within a url, it will split it up and call this this method a few times)
+    [self.currentString appendString:string];
+}
+
+
+- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName 
+{
+    if ([namespaceURI isEqualToString:kCMISNamespaceCmis])
+    {
+        if ([elementName isEqualToString:kCMISCoreRepositoryId])
+        {
+            self.currentRepositoryInfo.identifier = self.currentString;
+        }
+        else if ([elementName isEqualToString:kCMISCoreRepositoryName])
+        {
+            self.currentRepositoryInfo.name = self.currentString;
+        }
+        else if ([elementName isEqualToString:kCMISCoreRepositoryDescription])
+        {
+            self.currentRepositoryInfo.desc = self.currentString;
+        }
+        else if ([elementName isEqualToString:kCMISCoreVendorName])
+        {
+            self.currentRepositoryInfo.vendorName = self.currentString;
+        }
+        else if ([elementName isEqualToString:kCMISCoreProductName])
+        {
+            self.currentRepositoryInfo.productName = self.currentString;
+        }
+        else if ([elementName isEqualToString:kCMISCoreProductVersion])
+        {
+            self.currentRepositoryInfo.productVersion = self.currentString;
+        }
+        else if ([elementName isEqualToString:kCMISCoreRootFolderId])
+        {
+            self.currentRepositoryInfo.rootFolderId = self.currentString;
+        }
+        else if ([elementName isEqualToString:kCMISCoreCmisVersionSupported])
+        {
+            self.currentRepositoryInfo.cmisVersionSupported = self.currentString;
+        }
+        else if ([elementName hasPrefix:_kCMISCoreCapabilityPrefix] && self.currentCapabilities)
+        {
+            [self.currentCapabilities setValue:self.currentString forKeyPath:elementName];
+        }
+        else if ([elementName isEqualToString:kCMISCoreCapabilities])
+        {
+            self.currentRepositoryInfo.repositoryCapabilities = self.currentCapabilities;
+            self.currentCapabilities = nil;
+        }
+        else if ([elementName isEqualToString:kCMISCoreAclCapability] || [elementName isEqualToString:kCMISCorePermission]
+                 || [elementName isEqualToString:kCMISCorePermissions]|| [elementName isEqualToString:kCMISCoreMapping]
+                 || [elementName isEqualToString:kCMISCoreKey]|| [elementName isEqualToString:kCMISCoreSupportedPermissions]
+                 || [elementName isEqualToString:kCMISCorePropagation] || [elementName isEqualToString:kCMISCoreDescription])
+        {
+            
+            // TODO Handle ACL Capability tree
+        }
+        else 
+        {
+            /*
+             TODO Parse these into the repoItem object
+                kCMISCoreSupportedPermissions;
+                kCMISCorePropagation;
+                kCMISCoreCmisVersionSupported;
+                kCMISCoreChangesIncomplete;
+                kCMISCoreChangesOnType;
+                kCMISCorePrincipalAnonymous;
+                kCMISCorePrincipalAnyone;
+             */
+            
+            //log(@"TODO Cmis-Core Element was ignored: ElementName=%@, Value=%@",elementName, self.currentString);
+        } 
+    }
+    else if ([namespaceURI isEqualToString:kCMISNamespaceCmisRestAtom])
+    {
+        if ([elementName isEqualToString:kCMISRestAtomRepositoryInfo] && self.parentDelegate)
+        {
+            // Finished parsing Properties & its ExtensionData
+            [self saveCurrentExtensionsAndPushPreviousExtensionData];
+
+            // Reset the parser's delegate to its parent since we're done with the repositoryInfo node
+            [self.parentDelegate repositoryInfoParser:self didFinishParsingRepositoryInfo:self.currentRepositoryInfo];
+            parser.delegate = self.parentDelegate;
+            self.parentDelegate = nil;
+        }
+    }
+    else if ([namespaceURI isEqualToString:kCMISNamespaceApp] || [namespaceURI isEqualToString:kCMISNamespaceAtom])
+    {
+        log(@"WARNING: We should not get here");
+    }
+    else if (self.isParsingExtensionElement)
+    {
+        self.isParsingExtensionElement = NO;
+    }
+    
+    self.currentString = nil;
+}
+
+#pragma mark -
+#pragma mark CMISAtomPubExtensionElementParserDelegate Methods
+
+- (void)extensionElementParser:(CMISAtomPubExtensionElementParser *)parser didFinishParsingExtensionElement:(CMISExtensionElement *)extensionElement
+{
+    if (self.currentExtensions == nil)
+    {
+        self.currentExtensions = [[NSMutableArray alloc] init];
+    }
+    
+    [self.currentExtensions addObject:extensionElement];
+}
+
+@end

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISRepositoryInfoParser.m
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISServiceDocumentParser.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISServiceDocumentParser.h?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISServiceDocumentParser.h (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISServiceDocumentParser.h Wed Dec 26 10:48:33 2012
@@ -0,0 +1,26 @@
+/*
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+ */
+
+#import <Foundation/Foundation.h>
+#import "CMISRepositoryInfoParser.h"
+
+@interface CMISServiceDocumentParser : NSObject <NSXMLParserDelegate, CMISRepositoryInfoParserDelegate>
+
+// Available after parsing the service document
+@property (nonatomic, strong, readonly) NSArray *workspaces;
+
+- (id)initWithData:(NSData*)atomData;
+- (BOOL)parseAndReturnError:(NSError **)error;
+
+@end

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISServiceDocumentParser.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISServiceDocumentParser.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISServiceDocumentParser.m?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISServiceDocumentParser.m (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISServiceDocumentParser.m Wed Dec 26 10:48:33 2012
@@ -0,0 +1,210 @@
+/*
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+ */
+
+#import "CMISServiceDocumentParser.h"
+#import "CMISWorkspace.h"
+#import "CMISAtomCollection.h"
+#import "CMISAtomLink.h"
+#import "CMISAtomPubConstants.h"
+#import "CMISLinkRelations.h"
+
+@interface CMISServiceDocumentParser ()
+
+@property (nonatomic, strong) NSData *atomData;
+@property (nonatomic, strong) NSMutableArray *internalWorkspaces;
+
+@property (nonatomic, strong) NSMutableString *currentString;
+@property (nonatomic, strong) CMISWorkspace *currentWorkSpace;
+@property (nonatomic, strong) CMISAtomCollection *currentCollection;
+@property (nonatomic, strong) NSMutableSet *currentAtomLinks;
+@property (nonatomic, strong) NSString *currentTemplate;
+@property (nonatomic, strong) NSString *currentType;
+@property (nonatomic, strong) NSString *currentMediaType;
+@property (nonatomic, strong) id<NSXMLParserDelegate> childParserDelegate;
+
+@end
+
+
+@implementation CMISServiceDocumentParser
+
+@synthesize atomData = _atomData;
+@synthesize internalWorkspaces = _internalWorkspaces;
+
+@synthesize currentString = _currentString;
+@synthesize currentWorkSpace = _currentWorkSpace;
+@synthesize currentCollection = _currentCollection;
+@synthesize currentAtomLinks = _currentAtomLinks;
+@synthesize currentTemplate = _currentTemplate;
+@synthesize currentType = _currentType;
+@synthesize currentMediaType = _currentMediaType;
+@synthesize childParserDelegate = _childParserDelegate;
+
+
+- (id)initWithData:(NSData*)atomData
+{
+    self = [super init];
+    if (self)
+    {
+        self.atomData = atomData;
+    }
+    
+    return self;
+}
+
+- (BOOL)parseAndReturnError:(NSError **)error;
+{
+    BOOL parseSuccessful = YES;
+    
+    // create the array to hold the workspaces we find
+    self.internalWorkspaces = [NSMutableArray array];
+    
+    // parse the AtomPub data
+    NSXMLParser *parser = [[NSXMLParser alloc] initWithData:self.atomData];
+    [parser setShouldProcessNamespaces:YES];
+    [parser setDelegate:self];
+    parseSuccessful = [parser parse];
+    
+    if (!parseSuccessful)
+    {
+        log(@"Parsing error : %@", [parser parserError]);
+        if (*error) {
+            *error = [parser parserError];
+        }
+    }
+    return parseSuccessful;
+}
+
+- (NSArray *)workspaces
+{
+    return [NSArray arrayWithArray:self.internalWorkspaces];
+}
+
+#pragma mark -
+#pragma mark NSXMLParser delegate methods
+
+- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict 
+{
+    self.currentString = [[NSMutableString alloc] init];
+
+    if ([elementName isEqualToString:kCMISAppWorkspace])
+    {
+        self.currentWorkSpace = [[CMISWorkspace alloc] init];
+    }
+    else if ([elementName isEqualToString:kCMISRestAtomRepositoryInfo])
+    {
+        self.childParserDelegate = [CMISRepositoryInfoParser repositoryInfoParserWithParentDelegate:self parser:parser];
+    }
+    else if ([elementName isEqualToString:kCMISAppCollection])
+    {
+        self.currentCollection = [[CMISAtomCollection alloc] init];
+        self.currentCollection.href = [attributeDict objectForKey:kCMISAtomLinkAttrHref];
+    }
+    else if ([elementName isEqualToString:kCMISAtomLink])
+    {
+        if (self.currentAtomLinks == nil)
+        {
+            self.currentAtomLinks = [[NSMutableSet alloc] init];
+        }
+        
+        CMISAtomLink *atomLink = [[CMISAtomLink alloc] initWithRelation:[attributeDict objectForKey:kCMISAtomLinkAttrRel]  
+                                                                   type:[attributeDict objectForKey:kCMISAtomLinkAttrType] 
+                                                                   href:[attributeDict objectForKey:kCMISAtomLinkAttrHref]];
+        [self.currentAtomLinks addObject:atomLink];
+    }
+}
+
+- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string 
+{
+    // Simply add the parsed string to the current string
+    // Do not add any logic here, since the parser splits up data rather easily
+    // (eg when an ampersand is used within a url, it will split it up and call this this method a few times)
+    [self.currentString appendString:string];
+}
+
+
+- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName 
+{
+    // TODO: parser needs refactoring!
+
+    if ([elementName isEqualToString:kCMISAppWorkspace])
+    {
+        self.currentWorkSpace.linkRelations = [[CMISLinkRelations alloc] initWithLinkRelationSet:[self.currentAtomLinks copy]];
+        self.currentAtomLinks = nil;
+        
+        [self.internalWorkspaces addObject:self.currentWorkSpace];
+    }
+    else if ([elementName isEqualToString:kCMISRestAtomUritemplate])
+    {
+        if ([self.currentType isEqualToString:kCMISUriTemplateObjectById])
+        {
+            self.currentWorkSpace.objectByIdUriTemplate = self.currentTemplate;
+        }
+        else if ([self.currentType isEqualToString:kCMISUriTemplateObjectByPath])
+        {
+            self.currentWorkSpace.objectByPathUriTemplate = self.currentTemplate;
+        }
+        else if ([self.currentType isEqualToString:kCMISUriTemplateTypeById])
+        {
+            self.currentWorkSpace.typeByIdUriTemplate = self.currentTemplate;
+        }
+        else if ([self.currentType isEqualToString:kCMISUriTemplateQuery])
+        {
+            self.currentWorkSpace.queryUriTemplate = self.currentTemplate;
+        }
+    }
+    else if ([elementName isEqualToString:kCMISRestAtomTemplate])
+    {
+        self.currentTemplate = self.currentString;
+    }
+    else if ([elementName isEqualToString:kCMISRestAtomType])
+    {
+        self.currentType = self.currentString;
+    }
+    else if ([elementName isEqualToString:kCMISRestAtomMediaType])
+    {
+        self.currentMediaType = self.currentString;
+    }
+    else if ([elementName isEqualToString:kCMISAppCollection])
+    {
+        if (self.currentWorkSpace.collections == nil)
+        {
+            self.currentWorkSpace.collections = [[NSMutableArray alloc] init];
+        }
+        [self.currentWorkSpace.collections addObject:self.currentCollection];
+        self.currentCollection = nil;
+    }
+    else if ([elementName isEqualToString:kCMISAtomTitle])
+    {
+        self.currentCollection.title = self.currentString;
+    }
+    else if ([elementName isEqualToString:kCMISAppAccept])
+    {
+        self.currentCollection.accept = self.currentString;
+    }
+    else if ([elementName isEqualToString:kCMISRestAtomCollectionType])
+    {
+        self.currentCollection.type = self.currentString;
+    }
+
+    self.currentString = nil;
+}
+
+#pragma mark -
+#pragma mark CMISRepositoryInfoParserDelegate methods
+- (void)repositoryInfoParser:(CMISRepositoryInfoParser *)repositoryInfoParser didFinishParsingRepositoryInfo:(CMISRepositoryInfo *)repositoryInfo
+{
+    self.currentWorkSpace.repositoryInfo = repositoryInfo;
+}
+
+@end

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISServiceDocumentParser.m
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISTypeDefinitionAtomEntryParser.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISTypeDefinitionAtomEntryParser.h?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISTypeDefinitionAtomEntryParser.h (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISTypeDefinitionAtomEntryParser.h Wed Dec 26 10:48:33 2012
@@ -0,0 +1,31 @@
+/*
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+ */
+
+#import <Foundation/Foundation.h>
+#import "CMISPropertyDefinitionParser.h"
+
+@class CMISTypeDefinition;
+
+// TODO: should we merge this parser with the generic AtomEntry parser?
+@interface CMISTypeDefinitionAtomEntryParser : NSObject <NSXMLParserDelegate, CMISPropertyDefinitionDelegate>
+
+/**
+* Available after a successful parse.
+*/
+@property (nonatomic, strong, readonly) CMISTypeDefinition *typeDefinition;
+
+- (id)initWithData:(NSData *)atomData;
+- (BOOL)parseAndReturnError:(NSError **)error;
+
+@end
\ No newline at end of file

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISTypeDefinitionAtomEntryParser.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISTypeDefinitionAtomEntryParser.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISTypeDefinitionAtomEntryParser.m?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISTypeDefinitionAtomEntryParser.m (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISTypeDefinitionAtomEntryParser.m Wed Dec 26 10:48:33 2012
@@ -0,0 +1,227 @@
+/*
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+ */
+
+#import "CMISTypeDefinitionAtomEntryParser.h"
+#import "CMISTypeDefinition.h"
+#import "CMISAtomPubConstants.h"
+#import "CMISConstants.h"
+
+@interface CMISTypeDefinitionAtomEntryParser ()
+
+@property(nonatomic, strong, readwrite) CMISTypeDefinition *typeDefinition;
+@property(readwrite) BOOL isParsingTypeDefinition;
+@property(nonatomic, strong, readwrite) NSData *atomData;
+@property(nonatomic, strong, readwrite) NSString *currentString;
+
+@property (nonatomic, strong) id<NSXMLParserDelegate> childParserDelegate;
+
+@end
+
+
+@implementation CMISTypeDefinitionAtomEntryParser
+
+@synthesize typeDefinition = _typeDefinition;
+@synthesize isParsingTypeDefinition = _isParsingTypeDefinition;
+@synthesize atomData = _atomData;
+@synthesize currentString = _currentString;
+@synthesize childParserDelegate = _childParserDelegate;
+
+- (id)initWithData:(NSData *)atomData
+{
+    self = [self init];
+    if (self)
+    {
+        self.atomData = atomData;
+    }
+
+    return self;
+}
+
+- (BOOL)parseAndReturnError:(NSError **)error
+{
+    BOOL parseSuccessful = YES;
+
+    // parse the AtomPub data
+    NSXMLParser *parser = [[NSXMLParser alloc] initWithData:self.atomData];
+    [parser setShouldProcessNamespaces:YES];
+    [parser setDelegate:self];
+
+    parseSuccessful = [parser parse];
+
+    if (!parseSuccessful)
+    {
+        if (error)
+        {
+            *error = [parser parserError];
+        }
+    }
+
+    return parseSuccessful;
+}
+
+- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
+{
+    if ([elementName isEqualToString:kCMISRestAtomType])
+    {
+        self.typeDefinition = [[CMISTypeDefinition alloc] init];
+        self.isParsingTypeDefinition = YES;
+    }
+    else if ([elementName isEqualToString:kCMISCorePropertyStringDefinition]
+             || [elementName isEqualToString:kCMISCorePropertyIdDefinition]
+             || [elementName isEqualToString:kCMISCorePropertyBooleanDefinition]
+             || [elementName isEqualToString:kCMISCorePropertyIntegerDefinition]
+             || [elementName isEqualToString:kCMISCorePropertyDateTimeDefinition]
+             || [elementName isEqualToString:kCMISCorePropertyDecimalDefinition])
+    {
+        self.childParserDelegate = [CMISPropertyDefinitionParser parserForPropertyDefinition:elementName withParentDelegate:self parser:parser];
+    }
+}
+
+
+- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
+{
+    NSString *cleanedString = [string stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
+    if (!self.currentString)
+    {
+        self.currentString = cleanedString;
+    }
+    else {
+        self.currentString = [self.currentString stringByAppendingString:cleanedString];
+    }
+}
+
+- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
+{
+    if ([elementName isEqualToString:kCMISRestAtomType])
+    {
+        self.isParsingTypeDefinition = NO;
+    }
+    else if ([elementName isEqualToString:kCMISCoreId])
+    {
+        if (self.isParsingTypeDefinition)
+        {
+            self.typeDefinition.id = self.currentString;
+        }
+    }
+    else if ([elementName isEqualToString:kCMISCoreLocalName])
+    {
+        if (self.isParsingTypeDefinition)
+        {
+            self.typeDefinition.localName = self.currentString;
+        }
+    }
+    else if ([elementName isEqualToString:kCMISCoreLocalNamespace])
+    {
+        if (self.isParsingTypeDefinition)
+        {
+            self.typeDefinition.localNameSpace = self.currentString;
+        }
+    }
+    else if ([elementName isEqualToString:kCMISCoreDisplayName])
+    {
+        if (self.isParsingTypeDefinition)
+        {
+            self.typeDefinition.displayName = self.currentString;
+        }
+    }
+    else if ([elementName isEqualToString:kCMISCoreQueryName])
+    {
+        if (self.isParsingTypeDefinition)
+        {
+            self.typeDefinition.queryName = self.currentString;
+        }
+    }
+    else if ([elementName isEqualToString:kCMISCoreDescription])
+    {
+        if (self.isParsingTypeDefinition)
+        {
+            self.typeDefinition.description = self.currentString;
+        }
+    }
+    else if ([elementName isEqualToString:kCMISCoreBaseId])
+    {
+        if (self.isParsingTypeDefinition)
+        {
+            if ([self.currentString isEqualToString:kCMISPropertyObjectTypeIdValueDocument])
+            {
+                self.typeDefinition.baseTypeId = CMISBaseTypeDocument;
+            }
+            else if ([self.currentString isEqualToString:kCMISPropertyObjectTypeIdValueFolder])
+            {
+                self.typeDefinition.baseTypeId = CMISBaseTypeFolder;
+            }
+        }
+    }
+    else if ([elementName isEqualToString:kCMISCoreCreatable])
+    {
+        if (self.isParsingTypeDefinition)
+        {
+            self.typeDefinition.isCreatable = [self.currentString.lowercaseString isEqualToString:kCMISAtomEntryValueTrue];
+        }
+    }
+    else if ([elementName isEqualToString:kCMISCoreFileable])
+    {
+        if (self.isParsingTypeDefinition)
+        {
+            self.typeDefinition.isFileable = [self.currentString.lowercaseString isEqualToString:kCMISAtomEntryValueTrue];
+        }
+    }
+    else if ([elementName isEqualToString:kCMISCoreQueryable])
+    {
+        if (self.isParsingTypeDefinition)
+        {
+            self.typeDefinition.isQueryable = [self.currentString.lowercaseString isEqualToString:kCMISAtomEntryValueTrue];
+        }
+    }
+    else if ([elementName isEqualToString:kCMISCoreFullTextIndexed])
+    {
+        if (self.isParsingTypeDefinition)
+        {
+            self.typeDefinition.isFullTextIndexed = [self.currentString.lowercaseString isEqualToString:kCMISAtomEntryValueTrue];
+        }
+    }
+    else if ([elementName isEqualToString:kCMISCoreIncludedInSupertypeQuery])
+    {
+        if (self.isParsingTypeDefinition)
+        {
+            self.typeDefinition.isIncludedInSupertypeQuery = [self.currentString.lowercaseString isEqualToString:kCMISAtomEntryValueTrue];
+        }
+    }
+    else if ([elementName isEqualToString:kCMISCoreControllableACL])
+    {
+        if (self.isParsingTypeDefinition)
+        {
+            self.typeDefinition.isControllableAcl = [self.currentString.lowercaseString isEqualToString:kCMISAtomEntryValueTrue];
+        }
+    }
+    else if ([elementName isEqualToString:kCMISCoreControllablePolicy])
+    {
+        if (self.isParsingTypeDefinition)
+        {
+            self.typeDefinition.isControllablePolicy = [self.currentString.lowercaseString isEqualToString:kCMISAtomEntryValueTrue];
+        }
+    }
+
+    self.currentString = nil;
+}
+
+#pragma mark CMISPropertyDefinitionDelegate delegates
+
+- (void)propertyDefinitionParser:(id)propertyDefinitionParser didFinishParsingPropertyDefinition:(CMISPropertyDefinition *)propertyDefinition
+{
+    [self.typeDefinition addPropertyDefinition:propertyDefinition];
+}
+
+
+@end
\ No newline at end of file

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISTypeDefinitionAtomEntryParser.m
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CmisAtomEntryWriter.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CmisAtomEntryWriter.h?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CmisAtomEntryWriter.h (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CmisAtomEntryWriter.h Wed Dec 26 10:48:33 2012
@@ -0,0 +1,48 @@
+/*
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+ */
+
+
+#import <Foundation/Foundation.h>
+
+@class CMISProperties;
+
+
+@interface CMISAtomEntryWriter : NSObject
+
+@property (nonatomic, strong) NSString *contentFilePath;
+@property (nonatomic, strong) NSInputStream *inputStream;
+@property (nonatomic, strong) NSString *mimeType;
+@property (nonatomic, strong) CMISProperties *cmisProperties;
+
+/**
+ * If YES: the xml will be created and stored fully in-memory.
+ * If NO: the xml will be streamed to a file on disk.
+ *
+ * Defaults to YES;
+ */
+@property BOOL generateXmlInMemory;
+
+/**
+* Generates the atom entry XML for the given properties on this class.
+*
+* NOTE: if <code>generateXmlInMemory</code> boolean is set to NO, a filepath pointing to a file
+* containing the generated atom entry is returned.
+* Callers are responsible to remove the file again if not needed anymore.
+*
+* If set to YES, the return value of this method is the XML is its whole.
+*
+*/
+- (NSString *)generateAtomEntryXml;
+
+@end
\ No newline at end of file

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CmisAtomEntryWriter.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CmisAtomEntryWriter.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CmisAtomEntryWriter.m?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CmisAtomEntryWriter.m (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CmisAtomEntryWriter.m Wed Dec 26 10:48:33 2012
@@ -0,0 +1,341 @@
+/*
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+ */
+
+
+#import "CMISAtomEntryWriter.h"
+#import "CMISBase64Encoder.h"
+#import "CMISConstants.h"
+#import "CMISFileUtil.h"
+#import "CMISProperties.h"
+#import "CMISDateUtil.h"
+
+
+@implementation NSString (XMLEntities)
+
+- (NSString*)stringByAddingXMLEntities {
+    if ([self rangeOfCharacterFromSet:[NSCharacterSet characterSetWithCharactersInString:@"&<>\"'"] options:NSLiteralSearch].location != NSNotFound) {
+        NSMutableString *mutableString = [self mutableCopy];
+
+        [mutableString replaceOccurrencesOfString:@"&" withString:@"&amp;" options:NSLiteralSearch range:NSMakeRange(0, mutableString.length)];
+        [mutableString replaceOccurrencesOfString:@"<" withString:@"&lt;" options:NSLiteralSearch range:NSMakeRange(0, mutableString.length)];
+        [mutableString replaceOccurrencesOfString:@">" withString:@"&gt;" options:NSLiteralSearch range:NSMakeRange(0, mutableString.length)];
+        [mutableString replaceOccurrencesOfString:@"\"" withString:@"&quot;" options:NSLiteralSearch range:NSMakeRange(0, mutableString.length)];
+        [mutableString replaceOccurrencesOfString:@"'" withString:@"&apos;" options:NSLiteralSearch range:NSMakeRange(0, mutableString.length)];
+    
+        return mutableString;
+        
+    } else {
+        return self;
+    }
+}
+
+@end
+
+@interface CMISAtomEntryWriter ()
+
+@property (nonatomic, strong) NSMutableString *internalXml;
+@property (nonatomic, strong) NSString *internalFilePath;
+
+@end
+
+@implementation CMISAtomEntryWriter
+
+// Exposed properties
+@synthesize contentFilePath = _contentFilePath;
+@synthesize inputStream = _inputStream;
+@synthesize mimeType = _mimeType;
+@synthesize cmisProperties = _cmisProperties;
+@synthesize generateXmlInMemory = _generateXmlInMemory;
+
+// Internal properties
+@synthesize internalXml = _internalXml;
+@synthesize internalFilePath = _internalFilePath;
+
+
+- (NSString *)generateAtomEntryXml
+{
+    [self addEntryStartElement];
+
+    if (self.contentFilePath || self.inputStream)
+    {
+        [self addContent];
+    }
+
+    [self addProperties];
+
+    // Return result
+    if (self.generateXmlInMemory)
+    {
+        return self.internalXml;
+    }
+    else
+    {
+        return self.internalFilePath;
+    }
+}
+
+- (void)addEntryStartElement
+{
+    NSString *atomEntryXmlStart = [NSString stringWithFormat:
+           @"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+            "<entry xmlns=\"http://www.w3.org/2005/Atom\" xmlns:cmis=\"http://docs.oasis-open.org/ns/cmis/core/200908/\" xmlns:cmisra=\"http://docs.oasis-open.org/ns/cmis/restatom/200908/\"  >"
+                "<id>urn:uuid:00000000-0000-0000-0000-00000000000</id>"
+                "<title>%@</title>",
+            [self.cmisProperties propertyValueForId:kCMISPropertyName]];
+
+    [self appendStringToReturnResult:atomEntryXmlStart];
+}
+
+- (void)addContent
+{
+    NSString *contentXMLStart = [NSString stringWithFormat:@"<cmisra:content>""<cmisra:mediatype>%@</cmisra:mediatype>""<cmisra:base64>", self.mimeType];
+    [self appendStringToReturnResult:contentXMLStart];
+
+    // Generate the base64 representation of the content
+    if (self.contentFilePath) {
+        if (self.generateXmlInMemory) {
+            NSString *encodedContent = [CMISBase64Encoder encodeContentOfFile:self.contentFilePath];
+            [self appendToInMemoryXml:encodedContent];
+        } else {
+            [CMISBase64Encoder encodeContentOfFile:self.contentFilePath andAppendToFile:self.internalFilePath];
+        }
+    } else if (self.inputStream) {
+        if (self.generateXmlInMemory)
+        {
+            NSString *encodedContent = [CMISBase64Encoder encodeContentFromInputStream:self.inputStream];
+            [self appendToInMemoryXml:encodedContent];
+        } else {
+            [CMISBase64Encoder encodeContentFromInputStream:self.inputStream andAppendToFile:self.internalFilePath];
+        }
+    }
+
+    NSString *contentXMLEnd = @"</cmisra:base64></cmisra:content>";
+    [self appendStringToReturnResult:contentXMLEnd];
+}
+
+- (void)addProperties
+{
+    [self appendStringToReturnResult:@"<cmisra:object><cmis:properties>"];
+
+    // TODO: support for multi valued properties
+    for (id propertyKey in self.cmisProperties.propertiesDictionary)
+    {
+        CMISPropertyData *propertyData = [self.cmisProperties propertyForId:propertyKey];
+        switch (propertyData.type)
+        {
+            case CMISPropertyTypeString:
+            {
+                [self appendStringToReturnResult:[NSString stringWithFormat:@"<cmis:propertyString propertyDefinitionId=\"%@\">",
+                                                  [propertyData.identifier stringByAddingXMLEntities]]];
+                
+                for (NSString *propertyStringValue in propertyData.values) {
+                    [self appendStringToReturnResult:[NSString stringWithFormat:@"<cmis:value>%@</cmis:value>", [propertyStringValue stringByAddingXMLEntities]]];
+                }
+
+                [self appendStringToReturnResult:@"</cmis:propertyString>"];
+                break;
+            }
+            case CMISPropertyTypeInteger:
+            {
+                [self appendStringToReturnResult:[NSString stringWithFormat:@"<cmis:propertyInteger propertyDefinitionId=\"%@\">",
+                                                  [propertyData.identifier stringByAddingXMLEntities]]];
+
+                for (NSNumber *propertyIntegerValue in propertyData.values) {
+                    [self appendStringToReturnResult:[NSString stringWithFormat:@"<cmis:value>%@</cmis:value>", propertyIntegerValue.stringValue]];
+                }
+
+                [self appendStringToReturnResult:@"</cmis:propertyInteger>"];
+                break;
+            }
+            case CMISPropertyTypeDecimal:
+            {
+                [self appendStringToReturnResult:[NSString stringWithFormat:@"<cmis:propertyDecimal propertyDefinitionId=\"%@\">",
+                                                  [propertyData.identifier stringByAddingXMLEntities]]];
+                
+                for (NSNumber *propertyDecimalValue in propertyData.values) {
+                    [self appendStringToReturnResult:[NSString stringWithFormat:@"<cmis:value>%@</cmis:value>", propertyDecimalValue.stringValue]];
+                }
+                
+                [self appendStringToReturnResult:@"</cmis:propertyDecimal>"];
+                break;
+            }
+            case CMISPropertyTypeBoolean:
+            {
+                [self appendStringToReturnResult:[NSString stringWithFormat:@"<cmis:propertyBoolean propertyDefinitionId=\"%@\">",
+                                                  [propertyData.identifier stringByAddingXMLEntities]]];
+                
+                for (NSNumber *propertyBooleanValue in propertyData.values) {
+                    [self appendStringToReturnResult:[NSString stringWithFormat:@"<cmis:value>%@</cmis:value>",
+                                                      propertyBooleanValue.boolValue ? @"true" : @"false"]];
+                }
+                
+                [self appendStringToReturnResult:@"</cmis:propertyBoolean>"];
+                break;
+            }
+            case CMISPropertyTypeId:
+            {
+                [self appendStringToReturnResult:[NSString stringWithFormat:@"<cmis:propertyId propertyDefinitionId=\"%@\">",
+                                                  [propertyData.identifier stringByAddingXMLEntities]]];
+                
+                for (NSString *propertyIdValue in propertyData.values) {
+                    [self appendStringToReturnResult:[NSString stringWithFormat:@"<cmis:value>%@</cmis:value>", [propertyIdValue stringByAddingXMLEntities]]];
+                }
+                
+                [self appendStringToReturnResult:@"</cmis:propertyId>"];
+                break;
+            }
+            case CMISPropertyTypeDateTime:
+            {
+                [self appendStringToReturnResult:[NSString stringWithFormat:@"<cmis:propertyDateTime propertyDefinitionId=\"%@\">",
+                                                  [propertyData.identifier stringByAddingXMLEntities]]];
+                
+                for (NSDate *propertyDateTimeValue in propertyData.values) {
+                    [self appendStringToReturnResult:[NSString stringWithFormat:@"<cmis:value>%@</cmis:value>", [CMISDateUtil stringFromDate:propertyDateTimeValue]]];
+                }
+                
+                [self appendStringToReturnResult:@"</cmis:propertyDateTime>"];
+                break;
+            }
+            case CMISPropertyTypeUri:
+            {
+                [self appendStringToReturnResult:[NSString stringWithFormat:@"<cmis:propertyUri propertyDefinitionId=\"%@\">",
+                                                  [propertyData.identifier stringByAddingXMLEntities]]];
+                
+                for (NSURL *propertyUriValue in propertyData.values) {
+                    [self appendStringToReturnResult:[NSString stringWithFormat:@"<cmis:value>%@</cmis:value>", [[propertyUriValue path] stringByAddingXMLEntities]]];
+                }
+                
+                [self appendStringToReturnResult:@"</cmis:propertyUri>"];
+                break;
+            }
+            case CMISPropertyTypeHtml:
+            {
+                [self appendStringToReturnResult:[NSString stringWithFormat:@"<cmis:propertyHtml propertyDefinitionId=\"%@\">",
+                                                  [propertyData.identifier stringByAddingXMLEntities]]];
+                
+                for (NSString *propertyHtmlValue in propertyData.values) {
+                    [self appendStringToReturnResult:[NSString stringWithFormat:@"<cmis:value>%@</cmis:value>", [propertyHtmlValue stringByAddingXMLEntities]]];
+                }
+                
+                [self appendStringToReturnResult:@"</cmis:propertyHtml>"];
+                break;
+            }
+            default:
+            {
+                log(@"Property type did not match: %u", propertyData.type);
+                break;
+            }
+        }
+    }
+
+    // Add extensions to properties
+    if (self.cmisProperties.extensions != nil)
+    {
+        [self addExtensionElements:self.cmisProperties.extensions];
+    }
+
+    [self appendStringToReturnResult:@"</cmis:properties></cmisra:object></entry>"];
+}
+
+- (void) addExtensionElements:(NSArray *)extensionElements
+{
+    for (CMISExtensionElement *extensionElement in extensionElements)
+    {
+        // Opening XML tag
+        [self appendStringToReturnResult:[NSString stringWithFormat:@"<%@ xmlns=\"%@\"", extensionElement.name, extensionElement.namespaceUri]];
+
+        // Attributes
+        if (extensionElement.attributes != nil)
+        {
+            for (NSString *attributeName in extensionElement.attributes)
+            {
+                [self appendStringToReturnResult:[NSString stringWithFormat:@" %@=\"%@\"",
+                                                  [attributeName stringByAddingXMLEntities],
+                                                  [[extensionElement.attributes objectForKey:attributeName] stringByAddingXMLEntities]]];
+            }
+        }
+        [self appendStringToReturnResult:@">"];
+
+        // Value
+        if (extensionElement.value != nil)
+        {
+            [self appendStringToReturnResult:[extensionElement.value stringByAddingXMLEntities]];
+        }
+
+        // Children
+        if (extensionElement.children != nil && extensionElement.children.count > 0)
+        {
+            [self addExtensionElements:extensionElement.children];
+        }
+
+        // Closing XML tag
+        [self appendStringToReturnResult:[NSString stringWithFormat:@"</%@>", extensionElement.name]];
+    }
+}
+
+#pragma mark Helper methods
+
+- (void)appendStringToReturnResult:(NSString *)string
+{
+    if (self.generateXmlInMemory)
+    {
+        [self appendToInMemoryXml:string];
+    }
+    else
+    {
+        [self appendToFile:string];
+    }
+}
+
+- (void)appendToInMemoryXml:(NSString *)string
+{
+    if (self.internalXml == nil)
+    {
+        self.internalXml = [[NSMutableString alloc] initWithString:string];
+    }
+    else
+    {
+        [self.internalXml appendString:string];
+    }
+}
+
+
+- (void)appendToFile:(NSString *)string
+{
+    if (self.internalFilePath == nil)
+    {
+        // Store the file in the temporary folder
+        NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
+        [formatter setDateFormat:@"yyyy-MM-dd'T'HH-mm-ss-Z'"];
+        self.internalFilePath = [NSString stringWithFormat:@"%@/%@-%@",
+                        NSTemporaryDirectory(),
+                        [self.cmisProperties propertyValueForId:kCMISPropertyName],
+                        [formatter stringFromDate:[NSDate date]]];
+
+        BOOL fileCreated = [[NSFileManager defaultManager] createFileAtPath:self.internalFilePath
+                                                                   contents:[string dataUsingEncoding:NSUTF8StringEncoding]
+                                                                 attributes:nil];
+        if (!fileCreated)
+        {
+            log(@"Error: could not create file %@", self.internalFilePath);
+        }
+    }
+    else {
+        [FileUtil appendToFileAtPath:self.internalFilePath data:[string dataUsingEncoding:NSUTF8StringEncoding]];
+    }
+
+}
+
+
+@end
\ No newline at end of file

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CmisAtomEntryWriter.m
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubBaseService+Protected.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubBaseService%2BProtected.h?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubBaseService+Protected.h (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubBaseService+Protected.h Wed Dec 26 10:48:33 2012
@@ -0,0 +1,62 @@
+/*
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+ */
+
+#import <Foundation/Foundation.h>
+#import "CMISAtomPubBaseService.h"
+#import "CMISObjectByIdUriBuilder.h"
+
+@class CMISObjectData;
+
+@interface CMISAtomPubBaseService (Protected)
+
+- (void)fetchRepositoryInfoWithCompletionBlock:(void (^)(NSError *error))completionBlock;
+
+- (void)retrieveCMISWorkspacesWithCompletionBlock:(void (^)(NSArray *workspaces, NSError *error))completionBlock;
+
+/** Convenience method with all the defaults for the retrieval parameters */
+- (void)retrieveObjectInternal:(NSString *)objectId completionBlock:(void (^)(CMISObjectData *objectData, NSError *error))completionBlock;
+
+/** Full-blown object retrieval version */
+- (void)retrieveObjectInternal:(NSString *)objectId
+                         withReturnVersion:(CMISReturnVersion)cmisReturnVersion
+                                withFilter:(NSString *)filter
+                   andIncludeRelationShips:(CMISIncludeRelationship)includeRelationship
+                       andIncludePolicyIds:(BOOL)includePolicyIds
+                        andRenditionFilder:(NSString *)renditionFilter
+                             andIncludeACL:(BOOL)includeACL
+                andIncludeAllowableActions:(BOOL)includeAllowableActions
+               completionBlock:(void (^)(CMISObjectData *objectData, NSError *error))completionBlock;
+
+- (void)retrieveObjectByPathInternal:(NSString *)path
+                          withFilter:(NSString *)filter
+             andIncludeRelationShips:(CMISIncludeRelationship)includeRelationship
+                 andIncludePolicyIds:(BOOL)includePolicyIds
+                  andRenditionFilder:(NSString *)renditionFilter
+                       andIncludeACL:(BOOL)includeACL
+          andIncludeAllowableActions:(BOOL)includeAllowableActions
+                     completionBlock:(void (^)(CMISObjectData *objectData, NSError *error))completionBlock;
+
+- (void)retrieveFromCache:(NSString *)cacheKey
+          completionBlock:(void (^)(id object, NSError *error))completionBlock;
+
+- (void)loadLinkForObjectId:(NSString *)objectId
+                andRelation:(NSString *)rel
+            completionBlock:(void (^)(NSString *link, NSError *error))completionBlock;
+
+- (void)loadLinkForObjectId:(NSString *)objectId
+                andRelation:(NSString *)rel
+                    andType:(NSString *)type
+            completionBlock:(void (^)(NSString *link, NSError *error))completionBlock;
+
+@end

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubBaseService+Protected.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubBaseService.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubBaseService.h?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubBaseService.h (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubBaseService.h Wed Dec 26 10:48:33 2012
@@ -0,0 +1,26 @@
+/*
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+ */
+
+#import <Foundation/Foundation.h>
+#import "CMISSessionParameters.h"
+#import "CMISBindingSession.h"
+
+@interface CMISAtomPubBaseService : NSObject
+
+@property (nonatomic, strong, readonly) CMISBindingSession *bindingSession;
+@property (nonatomic, strong, readonly) NSURL *atomPubUrl;
+
+- (id)initWithBindingSession:(CMISBindingSession *)session;
+- (void)clearCacheFromService;
+@end

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubBaseService.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubBaseService.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubBaseService.m?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubBaseService.m (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubBaseService.m Wed Dec 26 10:48:33 2012
@@ -0,0 +1,304 @@
+/*
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+ */
+
+#import "CMISAtomPubBaseService.h"
+#import "CMISAtomPubBaseService+Protected.h"
+#import "CMISHttpUtil.h"
+#import "CMISHttpResponse.h"
+#import "CMISServiceDocumentParser.h"
+#import "CMISConstants.h"
+#import "CMISAtomEntryParser.h"
+#import "CMISWorkspace.h"
+#import "CMISErrors.h"
+#import "CMISObjectByPathUriBuilder.h"
+#import "CMISTypeByIdUriBuilder.h"
+#import "CMISLinkCache.h"
+
+@interface CMISAtomPubBaseService ()
+
+@property (nonatomic, strong, readwrite) CMISBindingSession *bindingSession;
+@property (nonatomic, strong, readwrite) NSURL *atomPubUrl;
+
+@end
+
+@implementation CMISAtomPubBaseService
+
+@synthesize bindingSession = _bindingSession;
+@synthesize atomPubUrl = _atomPubUrl;
+
+- (id)initWithBindingSession:(CMISBindingSession *)session
+{
+    self = [super init];
+    if (self)
+    {
+        self.bindingSession = session;
+        
+        // pull out and cache all the useful objects for this binding
+        self.atomPubUrl = [session objectForKey:kCMISBindingSessionKeyAtomPubUrl];
+    }
+    return self;
+}
+
+
+#pragma mark -
+#pragma mark Protected methods
+
+- (void)retrieveFromCache:(NSString *)cacheKey completionBlock:(void (^)(id object, NSError *error))completionBlock
+{
+    id object = [self.bindingSession objectForKey:cacheKey];
+
+    if (object) {
+        completionBlock(object, nil);
+    } else {
+         // if object is nil, first populate cache
+        [self fetchRepositoryInfoWithCompletionBlock:^(NSError *error) {
+            id object = [self.bindingSession objectForKey:cacheKey];
+            if (!object && !error) {
+                // TODO: proper error initialisation
+                error = [[NSError alloc] init];
+                log(@"Could not get object from cache with key '%@'", cacheKey);
+            }
+            completionBlock(object, error);
+        }];
+    }
+}
+
+- (void)fetchRepositoryInfoWithCompletionBlock:(void (^)(NSError *error))completionBlock
+{
+    [self retrieveCMISWorkspacesWithCompletionBlock:^(NSArray *cmisWorkSpaces, NSError *error) {
+        if (!error) {
+            BOOL repositoryFound = NO;
+            for (CMISWorkspace *workspace in cmisWorkSpaces) {
+                if ([workspace.repositoryInfo.identifier isEqualToString:self.bindingSession.repositoryId])
+                {
+                    repositoryFound = YES;
+                    
+                    // Cache collections
+                    [self.bindingSession setObject:[workspace collectionHrefForCollectionType:kCMISAtomCollectionQuery] forKey:kCMISBindingSessionKeyQueryCollection];
+                    
+                    
+                    // Cache uri's and uri templates
+                    CMISObjectByIdUriBuilder *objectByIdUriBuilder = [[CMISObjectByIdUriBuilder alloc] initWithTemplateUrl:workspace.objectByIdUriTemplate];
+                    [self.bindingSession setObject:objectByIdUriBuilder forKey:kCMISBindingSessionKeyObjectByIdUriBuilder];
+                    
+                    CMISObjectByPathUriBuilder *objectByPathUriBuilder = [[CMISObjectByPathUriBuilder alloc] initWithTemplateUrl:workspace.objectByPathUriTemplate];
+                    [self.bindingSession setObject:objectByPathUriBuilder forKey:kCMISBindingSessionKeyObjectByPathUriBuilder];
+                    
+                    CMISTypeByIdUriBuilder *typeByIdUriBuilder = [[CMISTypeByIdUriBuilder alloc] initWithTemplateUrl:workspace.typeByIdUriTemplate];
+                    [self.bindingSession setObject:typeByIdUriBuilder forKey:kCMISBindingSessionKeyTypeByIdUriBuilder];
+                    
+                    [self.bindingSession setObject:workspace.queryUriTemplate forKey:kCMISBindingSessionKeyQueryUri];
+
+                    break;
+                }
+            }
+            
+            if (!repositoryFound) {
+                log(@"No matching repository found for repository id %@", self.bindingSession.repositoryId);
+                // TODO: populate error properly
+                NSString *detailedDescription = [NSString stringWithFormat:@"No matching repository found for repository id %@", self.bindingSession.repositoryId];
+                error = [CMISErrors createCMISErrorWithCode:kCMISErrorCodeNoRepositoryFound withDetailedDescription:detailedDescription];
+            }
+        }
+        completionBlock(error);
+    }];
+}
+
+- (void)retrieveCMISWorkspacesWithCompletionBlock:(void (^)(NSArray *workspaces, NSError *error))completionBlock
+{
+    if ([self.bindingSession objectForKey:kCMISSessionKeyWorkspaces]) {
+        completionBlock([self.bindingSession objectForKey:kCMISSessionKeyWorkspaces], nil);
+    } else {
+        [HttpUtil invokeGET:self.atomPubUrl
+                withSession:self.bindingSession
+            completionBlock:^(CMISHttpResponse *httpResponse, NSError *error) {
+                if (httpResponse) {
+                    NSData *data = httpResponse.data;
+                    // Uncomment to see the service document
+                    //        NSString *dataString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
+                    //        log(@"Service document: %@", dataString);
+                    
+                    // Parse the cmis service document
+                    if (data) {
+                        CMISServiceDocumentParser *parser = [[CMISServiceDocumentParser alloc] initWithData:data];
+                        NSError *error = nil;
+                        if ([parser parseAndReturnError:&error]) {
+                            [self.bindingSession setObject:parser.workspaces forKey:kCMISSessionKeyWorkspaces];
+                        } else {
+                            log(@"Error while parsing service document: %@", error.description);
+                        }
+                        completionBlock(parser.workspaces, error);
+                    }
+                } else {
+                    completionBlock(nil, error);
+                }
+            }];
+    }
+}
+
+- (void)retrieveObjectInternal:(NSString *)objectId completionBlock:(void (^)(CMISObjectData *objectData, NSError *error))completionBlock
+{
+    [self retrieveObjectInternal:objectId withReturnVersion:NOT_PROVIDED withFilter:@"" andIncludeRelationShips:CMISIncludeRelationshipNone
+             andIncludePolicyIds:NO andRenditionFilder:nil andIncludeACL:NO
+      andIncludeAllowableActions:YES completionBlock:completionBlock];
+}
+
+
+- (void)retrieveObjectInternal:(NSString *)objectId
+             withReturnVersion:(CMISReturnVersion)returnVersion
+                    withFilter:(NSString *)filter
+       andIncludeRelationShips:(CMISIncludeRelationship)includeRelationship
+           andIncludePolicyIds:(BOOL)includePolicyIds
+            andRenditionFilder:(NSString *)renditionFilter
+                 andIncludeACL:(BOOL)includeACL
+    andIncludeAllowableActions:(BOOL)includeAllowableActions
+               completionBlock:(void (^)(CMISObjectData *objectData, NSError *error))completionBlock
+{
+    [self retrieveFromCache:kCMISBindingSessionKeyObjectByIdUriBuilder completionBlock:^(id object, NSError *error) {
+        CMISObjectByIdUriBuilder *objectByIdUriBuilder = object;
+        objectByIdUriBuilder.objectId = objectId;
+        objectByIdUriBuilder.filter = filter;
+        objectByIdUriBuilder.includeACL = includeACL;
+        objectByIdUriBuilder.includeAllowableActions = includeAllowableActions;
+        objectByIdUriBuilder.includePolicyIds = includePolicyIds;
+        objectByIdUriBuilder.includeRelationships = includeRelationship;
+        objectByIdUriBuilder.renditionFilter = renditionFilter;
+        objectByIdUriBuilder.returnVersion = returnVersion;
+        NSURL *objectIdUrl = [objectByIdUriBuilder buildUrl];
+        
+        // Execute actual call
+        [HttpUtil invokeGET:objectIdUrl
+                withSession:self.bindingSession
+            completionBlock:^(CMISHttpResponse *httpResponse, NSError *error) {
+                if (httpResponse) {
+                    if (httpResponse.statusCode == 200 && httpResponse.data) {
+                        CMISObjectData *objectData = nil;
+                        NSError *error = nil;
+                        CMISAtomEntryParser *parser = [[CMISAtomEntryParser alloc] initWithData:httpResponse.data];
+                        if ([parser parseAndReturnError:&error]) {
+                            objectData = parser.objectData;
+                            
+                            // Add links to link cache
+                            CMISLinkCache *linkCache = [self linkCache];
+                            [linkCache addLinks:objectData.linkRelations forObjectId:objectData.identifier];
+                        }
+                        completionBlock(objectData, error);
+                    }
+                } else {
+                    completionBlock(nil, error);
+                }
+            }];
+    }];
+}
+
+- (void)retrieveObjectByPathInternal:(NSString *)path
+                          withFilter:(NSString *)filter
+             andIncludeRelationShips:(CMISIncludeRelationship)includeRelationship
+                 andIncludePolicyIds:(BOOL)includePolicyIds
+                  andRenditionFilder:(NSString *)renditionFilter
+                       andIncludeACL:(BOOL)includeACL
+          andIncludeAllowableActions:(BOOL)includeAllowableActions
+                     completionBlock:(void (^)(CMISObjectData *objectData, NSError *error))completionBlock
+{
+    [self retrieveFromCache:kCMISBindingSessionKeyObjectByPathUriBuilder completionBlock:^(id object, NSError *error) {
+        CMISObjectByPathUriBuilder *objectByPathUriBuilder = object;
+        objectByPathUriBuilder.path = path;
+        objectByPathUriBuilder.filter = filter;
+        objectByPathUriBuilder.includeACL = includeACL;
+        objectByPathUriBuilder.includeAllowableActions = includeAllowableActions;
+        objectByPathUriBuilder.includePolicyIds = includePolicyIds;
+        objectByPathUriBuilder.includeRelationships = includeRelationship;
+        objectByPathUriBuilder.renditionFilter = renditionFilter;
+        
+        // Execute actual call
+        [HttpUtil invokeGET:[objectByPathUriBuilder buildUrl]
+                withSession:self.bindingSession
+            completionBlock:^(CMISHttpResponse *httpResponse, NSError *error) {
+                if (httpResponse) {
+                    if (httpResponse.statusCode == 200 && httpResponse.data != nil) {
+                        CMISObjectData *objectData = nil;
+                        NSError *error = nil;
+                        CMISAtomEntryParser *parser = [[CMISAtomEntryParser alloc] initWithData:httpResponse.data];
+                        if ([parser parseAndReturnError:&error]) {
+                            objectData = parser.objectData;
+                            
+                            // Add links to link cache
+                            CMISLinkCache *linkCache = [self linkCache];
+                            [linkCache addLinks:objectData.linkRelations forObjectId:objectData.identifier];
+                        }
+                        completionBlock(objectData, error);
+                    }
+                } else {
+                    completionBlock(nil, error);
+                }
+            }];
+    }];
+}
+
+- (CMISLinkCache *)linkCache{
+    CMISLinkCache *linkCache = [self.bindingSession objectForKey:kCMISBindingSessionKeyLinkCache];
+    if (linkCache == nil)
+    {
+        linkCache = [[CMISLinkCache alloc] initWithBindingSession:self.bindingSession];
+        [self.bindingSession setObject:linkCache forKey:kCMISBindingSessionKeyLinkCache];
+    }
+    return linkCache;
+}
+
+- (void)clearCacheFromService
+{
+    CMISLinkCache *linkCache = [self.bindingSession objectForKey:kCMISBindingSessionKeyLinkCache];
+    if (linkCache != nil)
+    {
+        [linkCache removeAllLinks];
+    }    
+}
+
+
+- (void)loadLinkForObjectId:(NSString *)objectId
+                andRelation:(NSString *)rel
+            completionBlock:(void (^)(NSString *link, NSError *error))completionBlock
+{
+    [self loadLinkForObjectId:objectId andRelation:rel andType:nil completionBlock:completionBlock];
+}
+
+
+- (void)loadLinkForObjectId:(NSString *)objectId andRelation:(NSString *)rel andType:(NSString *)type completionBlock:(void (^)(NSString *link, NSError *error))completionBlock
+{
+    CMISLinkCache *linkCache = [self linkCache];
+    
+    // Fetch link from cache
+    NSString *link = [linkCache linkForObjectId:objectId andRelation:rel andType:type];
+    if (link) {
+        completionBlock(link, nil);
+    } else {
+        // Fetch object, which will trigger the caching of the links
+        [self retrieveObjectInternal:objectId completionBlock:^(CMISObjectData *objectData, NSError *error) {
+            if (error) {
+                log(@"Could not retrieve object with id %@", objectId);
+                completionBlock(nil, [CMISErrors cmisError:error withCMISErrorCode:kCMISErrorCodeObjectNotFound]);
+            } else {
+                NSString *link = [linkCache linkForObjectId:objectId andRelation:rel andType:type];
+                if (link == nil) {
+                    completionBlock(nil, [CMISErrors createCMISErrorWithCode:kCMISErrorCodeObjectNotFound
+                                                     withDetailedDescription:[NSString stringWithFormat:@"Could not find link '%@' for object with id %@", rel, objectId]]);
+                } else {
+                    completionBlock(link, nil);
+                }
+            }
+        }];
+    }
+}
+
+@end

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubBaseService.m
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubBinding.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubBinding.h?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubBinding.h (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubBinding.h Wed Dec 26 10:48:33 2012
@@ -0,0 +1,23 @@
+/*
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+ */
+
+#import <Foundation/Foundation.h>
+#import "CMISBinding.h"
+#import "CMISSessionParameters.h"
+
+@interface CMISAtomPubBinding : NSObject <CMISBinding>
+
+- (id)initWithSessionParameters:(CMISSessionParameters *)sessionParameters;
+
+@end

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubBinding.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubBinding.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubBinding.m?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubBinding.m (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubBinding.m Wed Dec 26 10:48:33 2012
@@ -0,0 +1,86 @@
+/*
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+ */
+
+#import "CMISAtomPubBinding.h"
+#import "CMISBindingSession.h"
+#import "CMISAtomPubRepositoryService.h"
+#import "CMISAtomPubObjectService.h"
+#import "CMISAtomPubNavigationService.h"
+#import "CMISAtomPubVersioningService.h"
+#import "CMISAtomPubDiscoveryService.h"
+
+@interface CMISAtomPubBinding ()
+
+@property (nonatomic, strong) CMISBindingSession *session;
+@property (nonatomic, strong, readwrite) id<CMISAclService> aclService;
+@property (nonatomic, strong, readwrite) id<CMISDiscoveryService> discoveryService;
+@property (nonatomic, strong, readwrite) id<CMISMultiFilingService> multiFilingService;
+@property (nonatomic, strong, readwrite) id<CMISObjectService> objectService;
+@property (nonatomic, strong, readwrite) id<CMISPolicyService> policyService;
+@property (nonatomic, strong, readwrite) id<CMISRelationshipService> relationshipService;
+@property (nonatomic, strong, readwrite) id<CMISRepositoryService> repositoryService;
+@property (nonatomic, strong, readwrite) id<CMISNavigationService> navigationService;
+@property (nonatomic, strong, readwrite) id<CMISVersioningService> versioningService;
+
+@end
+
+@implementation CMISAtomPubBinding
+
+@synthesize session = _session;
+@synthesize aclService = _aclService;
+@synthesize discoveryService = _discoveryService;
+@synthesize multiFilingService = _multiFilingService;
+@synthesize objectService = _objectService;
+@synthesize policyService = _policyService;
+@synthesize relationshipService = _relationshipService;
+@synthesize repositoryService = _repositoryService;
+@synthesize navigationService = _navigationService;
+@synthesize versioningService = _versioningService;
+
+- (id)initWithSessionParameters:(CMISSessionParameters *)sessionParameters
+{
+    self = [super init];
+    if (self)
+    {
+        self.session = [[CMISBindingSession alloc] initWithSessionParameters:sessionParameters];
+        
+        self.repositoryService = [[CMISAtomPubRepositoryService alloc] initWithBindingSession:self.session];
+        self.objectService = [[CMISAtomPubObjectService alloc] initWithBindingSession:self.session];
+        self.navigationService = [[CMISAtomPubNavigationService alloc] initWithBindingSession:self.session];
+        self.versioningService = [[CMISAtomPubVersioningService alloc] initWithBindingSession:self.session];
+        self.discoveryService = [[CMISAtomPubDiscoveryService alloc] initWithBindingSession:self.session];
+    }
+    return self;
+}
+
+- (void)clearAllCaches
+{
+    [(CMISAtomPubRepositoryService *)self.repositoryService clearCacheFromService];
+    [(CMISAtomPubObjectService *)self.objectService clearCacheFromService];
+    [(CMISAtomPubNavigationService *)self.navigationService clearCacheFromService];
+    [(CMISAtomPubVersioningService *)self.versioningService clearCacheFromService];
+    [(CMISAtomPubDiscoveryService *)self.discoveryService clearCacheFromService];
+}
+
+- (void)clearCacheForRepositoryId:(NSString*)repositoryId
+{
+    // do nothing for now
+}
+
+- (void)close
+{
+    [self clearAllCaches];
+}
+
+@end

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubBinding.m
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubDiscoveryService.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubDiscoveryService.h?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubDiscoveryService.h (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubDiscoveryService.h Wed Dec 26 10:48:33 2012
@@ -0,0 +1,23 @@
+/*
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+ */
+
+#import <Foundation/Foundation.h>
+#import "CMISAtomPubBaseService.h"
+
+
+@interface CMISAtomPubDiscoveryService : CMISAtomPubBaseService <CMISDiscoveryService>
+
+
+
+@end
\ No newline at end of file

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubDiscoveryService.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubDiscoveryService.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubDiscoveryService.m?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubDiscoveryService.m (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubDiscoveryService.m Wed Dec 26 10:48:33 2012
@@ -0,0 +1,89 @@
+/*
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+ */
+
+#import "CMISAtomPubDiscoveryService.h"
+#import "CMISQueryAtomEntryWriter.h"
+#import "CMISHttpUtil.h"
+#import "CMISHttpResponse.h"
+#import "CMISAtomPubConstants.h"
+#import "CMISAtomFeedParser.h"
+#import "CMISObjectList.h"
+#import "CMISErrors.h"
+
+@implementation CMISAtomPubDiscoveryService
+
+
+- (void)query:(NSString *)statement searchAllVersions:(BOOL)searchAllVersions
+                                 includeRelationShips:(CMISIncludeRelationship)includeRelationships
+                                      renditionFilter:(NSString *)renditionFilter
+                            includeAllowableActions:(BOOL)includeAllowableActions
+                                           maxItems:(NSNumber *)maxItems
+                                          skipCount:(NSNumber *)skipCount
+                                    completionBlock:(void (^)(CMISObjectList *objectList, NSError *error))completionBlock;
+{
+    // Validate params
+    if (statement == nil)
+    {
+        log(@"Must provide 'statement' parameter when executing a cmis query");
+        completionBlock(nil, [CMISErrors createCMISErrorWithCode:kCMISErrorCodeInvalidArgument withDetailedDescription:nil]);
+        return;
+    }
+    
+    // Validate query uri
+    NSString *queryUrlString = [self.bindingSession objectForKey:kCMISBindingSessionKeyQueryCollection];
+    if (queryUrlString == nil)
+    {
+        log(@"Unknown repository or query not supported!");
+        completionBlock(nil, [CMISErrors createCMISErrorWithCode:kCMISErrorCodeObjectNotFound withDetailedDescription:nil]);
+        return;
+    }
+    
+    NSURL *queryURL = [NSURL URLWithString:queryUrlString];
+    // Build XML for query
+    CMISQueryAtomEntryWriter *atomEntryWriter = [[CMISQueryAtomEntryWriter alloc] init];
+    atomEntryWriter.statement = statement;
+    atomEntryWriter.searchAllVersions = searchAllVersions;
+    atomEntryWriter.includeAllowableActions = includeAllowableActions;
+    atomEntryWriter.includeRelationships = includeRelationships;
+    atomEntryWriter.renditionFilter = renditionFilter;
+    atomEntryWriter.maxItems = maxItems;
+    atomEntryWriter.skipCount = skipCount;
+    
+    // Execute HTTP call
+    [HttpUtil invokePOST:queryURL
+             withSession:self.bindingSession
+                    body:[[atomEntryWriter generateAtomEntryXML] dataUsingEncoding:NSUTF8StringEncoding]
+                 headers:[NSDictionary dictionaryWithObject:kCMISMediaTypeQuery forKey:@"Content-type"]
+         completionBlock:^(CMISHttpResponse *httpResponse, NSError *error) {
+             if (httpResponse) {
+                 CMISAtomFeedParser *feedParser = [[CMISAtomFeedParser alloc] initWithData:httpResponse.data];
+                 NSError *error = nil;
+                 if ([feedParser parseAndReturnError:&error]) {
+                     NSString *nextLink = [feedParser.linkRelations linkHrefForRel:kCMISLinkRelationNext];
+                     
+                     CMISObjectList *objectList = [[CMISObjectList alloc] init];
+                     objectList.hasMoreItems = (nextLink != nil);
+                     objectList.numItems = feedParser.numItems;
+                     objectList.objects = feedParser.entries;
+                     completionBlock(objectList, nil);
+                 } else {
+                     completionBlock(nil, [CMISErrors cmisError:error withCMISErrorCode:kCMISErrorCodeRuntime]);
+                 }
+             } else {
+                 completionBlock(nil, [CMISErrors cmisError:error withCMISErrorCode:kCMISErrorCodeConnection]);
+             }
+         }];
+}
+
+@end
\ No newline at end of file

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubDiscoveryService.m
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubNavigationService.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubNavigationService.h?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubNavigationService.h (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubNavigationService.h Wed Dec 26 10:48:33 2012
@@ -0,0 +1,19 @@
+/*
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+ */
+
+#import "CMISAtomPubBaseService.h"
+
+@interface CMISAtomPubNavigationService : CMISAtomPubBaseService <CMISNavigationService>
+
+@end

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubNavigationService.h
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message