use of org.jbei.ice.lib.net.RemoteTransfer in project ice by JBEI.
the class TransferTask method execute.
public void execute() {
RemoteTransfer transfer = new RemoteTransfer();
Account account = DAOFactory.getAccountDAO().getByEmail(userId);
if (account.getType() != AccountType.ADMIN)
return;
Entries retriever = new Entries(account.getEmail());
List<Long> entries = retriever.getEntriesFromSelectionContext(entrySelection);
Logger.info(userId + ": requesting transfer to " + remoteId);
List<PartData> dataList = transfer.getPartsForTransfer(entries);
List<Long> remoteIds = transfer.transferEntries(remoteId, dataList);
// check folder
if (StringUtils.isEmpty(this.entrySelection.getFolderId()))
return;
// create remoteFolder
long folderId = Long.decode(this.entrySelection.getFolderId());
Folder folder = DAOFactory.getFolderDAO().get(folderId);
Logger.info("Adding " + remoteIds.size() + " transferred entries to remote folder");
transfer.transferFolder(remoteId, folder.toDataTransferObject(), remoteIds);
}
use of org.jbei.ice.lib.net.RemoteTransfer in project ice by JBEI.
the class FolderContents method addToRemoteFolder.
// transfer entries to remote partner and add to folder
protected void addToRemoteFolder(Account account, Folder folder, List<Long> entries) {
RemoteAccessModel remoteAccessModel = remoteAccessModelDAO.getByFolder(account, folder);
if (remoteAccessModel == null) {
Logger.error("Could not retrieve remote access for folder " + folder.getId());
return;
}
RemotePartner remotePartner = remoteAccessModel.getRemoteClientModel().getRemotePartner();
RemoteTransfer remoteTransfer = new RemoteTransfer();
List<PartData> results = remoteTransfer.getPartsForTransfer(entries);
List<Long> remoteIds = remoteTransfer.transferEntries(remotePartner.getId(), results);
FolderDetails remoteFolder = new FolderDetails();
remoteFolder.setId(Long.decode(remoteAccessModel.getIdentifier()));
// add transferred entries to the folder
EntrySelection selection = new EntrySelection();
selection.getEntries().addAll(remoteIds);
selection.getDestination().add(remoteFolder);
selection.setSelectionType(EntrySelectionType.FOLDER);
String token = remoteAccessModel.getToken();
remoteContact.addTransferredEntriesToFolder(remotePartner.getUrl(), account.getEmail(), selection, remoteFolder.getId(), token, remotePartner.getApiKey());
}
Aggregations