task_21379 #3
|
@ -176,7 +176,7 @@ public class WsThreddsWidget implements HasWsSyncNotificationListner {
|
|||
|
||||
//at least one THREDDS rights is assigned
|
||||
GWT.log("Performing isItemSynched: "+folder.getFolderId());
|
||||
WsThreddsWidget.wsThreddsSyncService.isItemSynched(folder.getFolderId(), new AsyncCallback<WsThreddsSynchFolderDescriptor>() {
|
||||
WsThreddsWidget.wsThreddsSyncService.getConfiguration(folder.getFolderId(), new AsyncCallback<WsThreddsSynchFolderDescriptor>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(WsThreddsSynchFolderDescriptor result) {
|
||||
|
|
|
@ -16,6 +16,7 @@ import com.google.gwt.user.client.rpc.RemoteService;
|
|||
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
|
||||
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Interface ThreddsWorkspaceSyncService.
|
||||
*
|
||||
|
@ -25,15 +26,16 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
|
|||
@RemoteServiceRelativePath("wsthreddssync")
|
||||
public interface ThreddsWorkspaceSyncService extends RemoteService {
|
||||
|
||||
|
||||
/**
|
||||
* Checks if is item synched.
|
||||
* Gets the configuration.
|
||||
*
|
||||
* @param folderId the folder id
|
||||
* @return the ws thredds synch folder descriptor
|
||||
* @return the configuration
|
||||
* @throws WorkspaceFolderLocked the workspace folder locked
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
WsThreddsSynchFolderDescriptor isItemSynched(String folderId) throws WorkspaceFolderLocked, Exception;
|
||||
WsThreddsSynchFolderDescriptor getConfiguration(String folderId) throws WorkspaceFolderLocked, Exception;
|
||||
|
||||
/**
|
||||
* Do sync folder.
|
||||
|
@ -85,9 +87,8 @@ public interface ThreddsWorkspaceSyncService extends RemoteService {
|
|||
/**
|
||||
* Gets the list of Scopes (Root-VO, VOs and VREs) for user and the Thredds roles that user has in them.
|
||||
*
|
||||
* @param user the user
|
||||
* @return the VREs and Thredds roles for a given user
|
||||
* @throws Exception
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
Map<String, GatewayRolesThredds> getScopesWithThreddsRolesForLoggedUser() throws Exception;
|
||||
}
|
||||
|
|
|
@ -13,68 +13,59 @@ import org.gcube.portlets.widgets.wsthreddssync.shared.WsThreddsSynchFolderDescr
|
|||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
|
||||
|
||||
/**
|
||||
* The Interface ThreddsWorkspaceSyncServiceAsync.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Mar 8, 2018
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Mar 8, 2018
|
||||
*/
|
||||
public interface ThreddsWorkspaceSyncServiceAsync
|
||||
{
|
||||
|
||||
/**
|
||||
* Utility class to get the RPC Async interface from client-side code.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Mar 8, 2018
|
||||
*/
|
||||
public static final class Util
|
||||
{
|
||||
private static ThreddsWorkspaceSyncServiceAsync instance;
|
||||
|
||||
/**
|
||||
* Gets the single instance of Util.
|
||||
*
|
||||
* @return single instance of Util
|
||||
*/
|
||||
public static final ThreddsWorkspaceSyncServiceAsync getInstance()
|
||||
{
|
||||
if ( instance == null )
|
||||
{
|
||||
instance = (ThreddsWorkspaceSyncServiceAsync) GWT.create( ThreddsWorkspaceSyncService.class );
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new util.
|
||||
*/
|
||||
private Util()
|
||||
{
|
||||
// Utility class should not be instantiated
|
||||
}
|
||||
}
|
||||
|
||||
public interface ThreddsWorkspaceSyncServiceAsync {
|
||||
|
||||
/**
|
||||
* Checks if is item synched.
|
||||
* Utility class to get the RPC Async interface from client-side code.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Mar 8, 2018
|
||||
*/
|
||||
public static final class Util {
|
||||
private static ThreddsWorkspaceSyncServiceAsync instance;
|
||||
|
||||
/**
|
||||
* Gets the single instance of Util.
|
||||
*
|
||||
* @return single instance of Util
|
||||
*/
|
||||
public static final ThreddsWorkspaceSyncServiceAsync getInstance() {
|
||||
if (instance == null) {
|
||||
instance = (ThreddsWorkspaceSyncServiceAsync) GWT.create(ThreddsWorkspaceSyncService.class);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new util.
|
||||
*/
|
||||
private Util() {
|
||||
// Utility class should not be instantiated
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the configuration.
|
||||
*
|
||||
* @param folderId the folder id
|
||||
* @param callback the callback
|
||||
* @return the configuration
|
||||
*/
|
||||
void isItemSynched(String folderId, AsyncCallback<WsThreddsSynchFolderDescriptor> callback);
|
||||
|
||||
void getConfiguration(String folderId, AsyncCallback<WsThreddsSynchFolderDescriptor> callback);
|
||||
|
||||
/**
|
||||
* Do sync folder.
|
||||
*
|
||||
* @param folderId the folder id
|
||||
* @param folderId the folder id
|
||||
* @param clientConfig the client config
|
||||
* @param callback the callback
|
||||
* @param callback the callback
|
||||
*/
|
||||
void doSyncFolder(String folderId, WsThreddsSynchFolderConfiguration clientConfig, AsyncCallback<ThSyncStatus> callback);
|
||||
|
||||
void doSyncFolder(String folderId, WsThreddsSynchFolderConfiguration clientConfig,
|
||||
AsyncCallback<ThSyncStatus> callback);
|
||||
|
||||
/**
|
||||
* Monitor sync status.
|
||||
|
@ -84,8 +75,6 @@ public interface ThreddsWorkspaceSyncServiceAsync
|
|||
*/
|
||||
void monitorSyncStatus(String folderId, AsyncCallback<ThSyncStatus> callback);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the list of scopes for logged user.
|
||||
*
|
||||
|
@ -97,13 +86,12 @@ public interface ThreddsWorkspaceSyncServiceAsync
|
|||
/**
|
||||
* Gets the available catalogues for scope.
|
||||
*
|
||||
* @param scope the scope
|
||||
* @param scope the scope
|
||||
* @param callback the callback
|
||||
* @return the available catalogues for scope
|
||||
*/
|
||||
void getAvailableCataloguesForScope(String scope, AsyncCallback<List<ThCatalogueBean>> callback);
|
||||
|
||||
|
||||
/**
|
||||
* Do un sync folder.
|
||||
*
|
||||
|
@ -112,6 +100,5 @@ public interface ThreddsWorkspaceSyncServiceAsync
|
|||
*/
|
||||
void doUnSyncFolder(String folderId, AsyncCallback<Boolean> callback);
|
||||
|
||||
|
||||
void getScopesWithThreddsRolesForLoggedUser(AsyncCallback<Map<String, GatewayRolesThredds>> callback);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
package org.gcube.portlets.widgets.wsthreddssync.server;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
|
@ -20,6 +21,7 @@ import org.gcube.portal.wssynclibrary.shared.thredds.ThSyncStatus;
|
|||
import org.gcube.portal.wssynclibrary.shared.thredds.ThSynchFolderConfiguration;
|
||||
import org.gcube.portal.wssynclibrary.thredds.WorkspaceThreddsSynchronize;
|
||||
import org.gcube.usecases.ws.thredds.faults.WorkspaceNotSynchedException;
|
||||
import org.gcube.usecases.ws.thredds.model.ContainerType;
|
||||
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -116,28 +118,44 @@ public class SyncronizeWithThredds {
|
|||
/**
|
||||
* Checks if is item synched.
|
||||
*
|
||||
* @param folderId the folder id
|
||||
* @param scope the scope
|
||||
* @param userToken the user token
|
||||
* @return the th sync folder descriptor
|
||||
* @param folderId the folder id
|
||||
* @param scope the scope
|
||||
* @param userToken the user token
|
||||
* @param itemProperties the item properties
|
||||
* @param itemType the item type
|
||||
* @return true, if is item synched
|
||||
* @throws ItemNotSynched the item not synched
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public ThSyncFolderDescriptor isItemSynched(String folderId, String scope, String userToken)
|
||||
throws ItemNotSynched, Exception {
|
||||
public boolean isItemSynched(String folderId, String scope, String userToken, Map<String, Object> itemProperties,
|
||||
ContainerType itemType) throws ItemNotSynched, Exception {
|
||||
|
||||
setContextParameters(scope, userToken);
|
||||
return workspaceThreddsSynchronize.isItemSynched(folderId, itemProperties, itemType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the configuration.
|
||||
*
|
||||
* @param folderId the folder id
|
||||
* @param scope the scope
|
||||
* @param userToken the user token
|
||||
* @return the configuration
|
||||
* @throws ItemNotSynched the item not synched
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public ThSyncFolderDescriptor getConfiguration(String folderId, String scope, String userToken)
|
||||
throws ItemNotSynched, Exception {
|
||||
|
||||
ThSyncFolderDescriptor config = null;
|
||||
try {
|
||||
setContextParameters(scope, userToken);
|
||||
config = workspaceThreddsSynchronize.getConfiguration(folderId);
|
||||
|
||||
} catch (WorkspaceNotSynchedException e) {
|
||||
logger.debug("WorkspaceNotSynchedException catched, the item id: " + folderId + " is not synched");
|
||||
throw new ItemNotSynched("the item id: " + folderId + " is not synched");
|
||||
logger.debug("WorkspaceNotSynchedException catched. The item with id: " + folderId + " is not synched");
|
||||
} catch (Exception e) {
|
||||
logger.debug("Error on getting configuration for the item id: " + folderId
|
||||
+ ", returning null (means not synched)");
|
||||
return null;
|
||||
logger.error("Error on reading the configuration for id: " + folderId, e);
|
||||
}
|
||||
|
||||
return config;
|
||||
|
@ -384,19 +402,4 @@ public class SyncronizeWithThredds {
|
|||
workspaceThreddsSynchronize.registerCallbackForId(folderId);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Gets the sync status info.
|
||||
// *
|
||||
// * @param itemId the item id
|
||||
// * @param scope the scope
|
||||
// * @param userToken the user token
|
||||
// * @return the sync status info
|
||||
// * @throws Exception the exception
|
||||
// */
|
||||
// public Sync_Status getSyncStatusInfo(String itemId, String scope, String userToken) throws Exception {
|
||||
// setContextParameters(scope, userToken);
|
||||
// return workspaceThreddsSynchronize.getInfoAfterCheck(itemId);
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ public class ThreddsWorkspaceSyncServiceImpl extends RemoteServiceServlet implem
|
|||
*/
|
||||
// UPDATED
|
||||
@Override
|
||||
public WsThreddsSynchFolderDescriptor isItemSynched(String folderId) throws WorkspaceFolderLocked, Exception {
|
||||
public WsThreddsSynchFolderDescriptor getConfiguration(String folderId) throws WorkspaceFolderLocked, Exception {
|
||||
logger.debug("called isItemSynched for folderId: " + folderId);
|
||||
|
||||
try {
|
||||
|
@ -129,7 +129,7 @@ public class ThreddsWorkspaceSyncServiceImpl extends RemoteServiceServlet implem
|
|||
String wsScope = PortalContext.getConfiguration().getCurrentScope(this.getThreadLocalRequest());
|
||||
String wsUserToken = PortalContext.getConfiguration().getCurrentUserToken(wsScope, user.getUsername());
|
||||
|
||||
ThSyncFolderDescriptor theConfig = getSyncService().isItemSynched(folderId,wsScope,wsUserToken);
|
||||
ThSyncFolderDescriptor theConfig = getSyncService().getConfiguration(folderId,wsScope,wsUserToken);
|
||||
|
||||
if (theConfig != null) {
|
||||
logger.info("Folder id: " + folderId + " is synched");
|
||||
|
@ -205,7 +205,7 @@ public class ThreddsWorkspaceSyncServiceImpl extends RemoteServiceServlet implem
|
|||
GCubeUser user = PortalContext.getConfiguration().getCurrentUser(this.getThreadLocalRequest());
|
||||
String wsScope = PortalContext.getConfiguration().getCurrentScope(this.getThreadLocalRequest());
|
||||
String wsUserToken = PortalContext.getConfiguration().getCurrentUserToken(wsScope, user.getUsername());
|
||||
ThSyncFolderDescriptor foldeDesr = getSyncService().isItemSynched(folderId,wsScope,wsUserToken);
|
||||
ThSyncFolderDescriptor foldeDesr = getSyncService().getConfiguration(folderId,wsScope,wsUserToken);
|
||||
return getSyncService().doUnSync(folderId, true, foldeDesr.getConfiguration(), this.getThreadLocalRequest(),
|
||||
user);
|
||||
} catch (Exception e) {
|
||||
|
|
Loading…
Reference in New Issue