mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-08-30 02:37:16 +00:00
JSON'ed [UIxParentFolderActions createFolder]
This commit is contained in:
@@ -1,8 +1,6 @@
|
|||||||
/* UIxParentFolderActions.m - this file is part of SOGo
|
/* UIxParentFolderActions.m - this file is part of SOGo
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007 Inverse inc.
|
* Copyright (C) 2007-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
|
||||||
@@ -27,9 +25,13 @@
|
|||||||
#import <NGObjWeb/WOResponse.h>
|
#import <NGObjWeb/WOResponse.h>
|
||||||
#import <NGObjWeb/WORequest.h>
|
#import <NGObjWeb/WORequest.h>
|
||||||
|
|
||||||
#import <UI/Common/WODirectAction+SOGo.h>
|
|
||||||
#import <SoObjects/SOGo/SOGoParentFolder.h>
|
#import <SoObjects/SOGo/SOGoParentFolder.h>
|
||||||
|
|
||||||
|
#import <SOGo/NSDictionary+Utilities.h>
|
||||||
|
#import <SOGo/NSString+Utilities.h>
|
||||||
|
|
||||||
|
#import <UI/Common/WODirectAction+SOGo.h>
|
||||||
|
|
||||||
#import "UIxParentFolderActions.h"
|
#import "UIxParentFolderActions.h"
|
||||||
|
|
||||||
@implementation UIxParentFolderActions
|
@implementation UIxParentFolderActions
|
||||||
@@ -38,8 +40,13 @@
|
|||||||
{
|
{
|
||||||
WOResponse *response;
|
WOResponse *response;
|
||||||
NSString *name, *nameInContainer;
|
NSString *name, *nameInContainer;
|
||||||
|
NSDictionary *params, *data;
|
||||||
|
WORequest *request;
|
||||||
|
|
||||||
name = [[context request] formValueForKey: @"name"];
|
request = [context request];
|
||||||
|
params = [[request contentAsString] objectFromJSONString];
|
||||||
|
|
||||||
|
name = [params objectForKey: @"name"];
|
||||||
nameInContainer = nil;
|
nameInContainer = nil;
|
||||||
|
|
||||||
if ([name length] > 0)
|
if ([name length] > 0)
|
||||||
@@ -50,19 +57,24 @@
|
|||||||
nameInContainer: &nameInContainer];
|
nameInContainer: &nameInContainer];
|
||||||
if (!response)
|
if (!response)
|
||||||
{
|
{
|
||||||
response = [self responseWithStatus: 201];
|
data = [NSDictionary dictionaryWithObjectsAndKeys: nameInContainer, @"id", nil];
|
||||||
[response setHeader: @"text/plain; charset=us-ascii"
|
response = [self responseWithStatus: 201
|
||||||
forKey: @"content-type"];
|
andString: [data jsonRepresentation]];
|
||||||
[response appendContentString: nameInContainer];
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
response = [NSException exceptionWithHTTPStatus: 409
|
{
|
||||||
reason: @"That name already exists"];
|
data = [NSDictionary dictionaryWithObjectsAndKeys: @"That name already exists", @"error", nil];
|
||||||
|
response = [self responseWithStatus: 409
|
||||||
|
andString: [data jsonRepresentation]];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
response = [NSException exceptionWithHTTPStatus: 400
|
{
|
||||||
reason: @"The name is missing"];
|
data = [NSDictionary dictionaryWithObjectsAndKeys: @"The name is missing", @"error", nil];
|
||||||
|
response = [self responseWithStatus: 400
|
||||||
|
andString: [data jsonRepresentation]];
|
||||||
|
}
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user