1 /* libcmis 2 * Version: MPL 1.1 / GPLv2+ / LGPLv2+ 3 * 4 * The contents of this file are subject to the Mozilla Public License Version 5 * 1.1 (the "License"); you may not use this file except in compliance with 6 * the License or as specified alternatively below. You may obtain a copy of 7 * the License at http://www.mozilla.org/MPL/ 8 * 9 * Software distributed under the License is distributed on an "AS IS" basis, 10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 * for the specific language governing rights and limitations under the 12 * License. 13 * 14 * Major Contributor(s): 15 * Copyright (C) 2013 Cao Cuong Ngo <cao.cuong.ngo@gmail.com> 16 * 17 * 18 * All Rights Reserved. 19 * 20 * For minor contributions see the git repository. 21 * 22 * Alternatively, the contents of this file may be used under the terms of 23 * either the GNU General Public License Version 2 or later (the "GPLv2+"), or 24 * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"), 25 * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable 26 * instead of those above. 27 */ 28 #ifndef _GDRIVE_UTILS_HXX_ 29 #define _GDRIVE_UTILS_HXX_ 30 31 #include <string> 32 33 #include <libcmis/property.hxx> 34 35 #include "json-utils.hxx" 36 37 static const std::string GDRIVE_FOLDER_MIME_TYPE = "application/vnd.google-apps.folder" ; 38 static const std::string GDRIVE_UPLOAD_LINK = "https://www.googleapis.com/upload/drive/v3/files/"; 39 static const std::string GDRIVE_METADATA_LINK = "https://www.googleapis.com/drive/v3/files/"; 40 41 class GdriveUtils 42 { 43 public : 44 45 // Convert a GDrive Property key to a CMIS key 46 static std::string toCmisKey( const std::string& key); 47 48 // Convert a CMIS key to GDrive key 49 static std::string toGdriveKey( const std::string& key ); 50 51 // Convert CMIS properties to GDrive properties 52 static Json toGdriveJson( const libcmis::PropertyPtrMap& properties ); 53 54 // Check if a property is updatable 55 static bool checkUpdatable( const std::string& key); 56 57 // Check if a property has multiple values 58 static bool checkMultiValued( const std::string& key); 59 60 // Create a Json array from a ParentId 61 static Json createJsonFromParentId( const std::string& parentId ); 62 63 // Parse a Gdrive property value to CMIS values 64 static std::vector< std::string > parseGdriveProperty( std::string key, Json jsonValue ); 65 }; 66 67 #endif 68