Search in sources :

Example 1 with RemoteTransfer

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);
}
Also used : Account(org.jbei.ice.storage.model.Account) RemoteTransfer(org.jbei.ice.lib.net.RemoteTransfer) PartData(org.jbei.ice.lib.dto.entry.PartData) Entries(org.jbei.ice.lib.entry.Entries) Folder(org.jbei.ice.storage.model.Folder)

Example 2 with RemoteTransfer

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());
}
Also used : EntrySelection(org.jbei.ice.lib.entry.EntrySelection) RemoteTransfer(org.jbei.ice.lib.net.RemoteTransfer) PartData(org.jbei.ice.lib.dto.entry.PartData) FolderDetails(org.jbei.ice.lib.dto.folder.FolderDetails)

Aggregations

PartData (org.jbei.ice.lib.dto.entry.PartData)2 RemoteTransfer (org.jbei.ice.lib.net.RemoteTransfer)2 FolderDetails (org.jbei.ice.lib.dto.folder.FolderDetails)1 Entries (org.jbei.ice.lib.entry.Entries)1 EntrySelection (org.jbei.ice.lib.entry.EntrySelection)1 Account (org.jbei.ice.storage.model.Account)1 Folder (org.jbei.ice.storage.model.Folder)1