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