Created
July 16, 2016 16:58
-
-
Save jottley/23a93ac8f29e91db87379ccf14097d38 to your computer and use it in GitHub Desktop.
Rough Stub update action Dropbox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright (C) 2005-2015 Alfresco Software Limited. | |
* | |
* This file is part of Alfresco | |
* | |
* Alfresco is free software: you can redistribute it and/or modify it under the | |
* terms of the GNU Lesser General Public License as published by the Free | |
* Software Foundation, either version 3 of the License, or (at your option) any | |
* later version. | |
* | |
* Alfresco is distributed in the hope that it will be useful, but WITHOUT ANY | |
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | |
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | |
* details. | |
* | |
* You should have received a copy of the GNU Lesser General Public License | |
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. | |
*/ | |
/** | |
* @author Jared Ottley <jared.ottley@alfresco.com> | |
*/ | |
LockStatus lockStatus = lockService.getLockStatus(actionedUponNodeRef); | |
if (lockStatus.equals(LockStatus.NO_LOCK) || lockStatus.equals(LockStatus.LOCK_EXPIRED)) | |
{ | |
Map<String, NodeRef> syncedUsers = dropboxService.getSyncedUsers(actionedUponNodeRef); | |
// Look for changes in dropbox before we start syncing Alfresco changes | |
Map<String, Metadata> workingMap = new HashMap<String, Metadata>(); | |
for (final Map.Entry<String, NodeRef> syncedUser : syncedUsers.entrySet()) | |
{ | |
Metadata metadata = AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Metadata>() | |
{ | |
@Override | |
public Metadata doWork() | |
throws Exception | |
{ | |
Metadata metadata = dropboxService.getMetadata(actionedUponNodeRef); | |
if (nodeService.getProperty(syncedUser.getValue(), DropboxConstants.Model.PROP_REV).toString().equals(metadata.getRev())) | |
{ | |
return null; | |
} | |
else | |
{ | |
return metadata; | |
} | |
} | |
}, syncedUser.getKey()); | |
if (metadata != null) | |
{ | |
workingMap.put(syncedUser.getKey(), metadata); | |
} | |
} | |
// Get the current out of sync file from users dropbox sorted by last mod time (oldest to newest) | |
Map<String, DropboxFile> tempFileMap; | |
if (workingMap.size() > 1) | |
{ | |
tempFileMap = new TreeMap(metadata_comparator); | |
for (Map.Entry<String, Metadata> work : workingMap.entrySet()) | |
{ | |
DropboxFile dropboxFile = AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<DropboxFile>() | |
{ | |
@Override | |
public DropboxFile doWork() | |
throws Exception | |
{ | |
return null; | |
} | |
}, work.getKey()); | |
tempFileMap.put(work.getKey(), dropboxFile); | |
} | |
} | |
//update alfresco in order | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment