Fixed Charset Export to UTF8
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@120101 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
87acfdc5fc
commit
6dc39716fb
|
@ -750,6 +750,17 @@ public interface TDGWTService extends RemoteService {
|
|||
throws TDGWTServiceException;
|
||||
|
||||
// Export CSV
|
||||
/**
|
||||
* Available charset for export
|
||||
*
|
||||
* @return
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
public AvailableCharsetList getAvailableCharsetForExport()
|
||||
throws TDGWTServiceException;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Start CSV Export and invokes the client library
|
||||
*
|
||||
|
|
|
@ -266,7 +266,6 @@ public interface TDGWTServiceAsync {
|
|||
AsyncCallback<String> callback);
|
||||
|
||||
// Import CSV
|
||||
|
||||
void setCSVSession(CSVImportSession csvImportSession,
|
||||
AsyncCallback<Void> callback);
|
||||
|
||||
|
@ -285,6 +284,8 @@ public interface TDGWTServiceAsync {
|
|||
AsyncCallback<String> callback);
|
||||
|
||||
// Export CSV
|
||||
void getAvailableCharsetForExport(AsyncCallback<AvailableCharsetList> callback);
|
||||
|
||||
void startCSVExport(CSVExportSession csvExportSession,
|
||||
AsyncCallback<String> callback);
|
||||
|
||||
|
|
|
@ -105,6 +105,7 @@ import org.gcube.data.analysis.tabulardata.service.tabular.metadata.ValidSinceMe
|
|||
import org.gcube.data.analysis.tabulardata.service.tabular.metadata.ValidUntilMetadata;
|
||||
import org.gcube.data.analysis.tabulardata.service.template.TemplateId;
|
||||
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTService;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.encoding.EncodingPGSupported;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.file.CSVFileUploadSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.file.CodelistMappingFileUploadSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.file.FileUtil;
|
||||
|
@ -4074,6 +4075,23 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
String defaultEncoding = Charset.defaultCharset().displayName();
|
||||
ArrayList<String> charsetList = new ArrayList<String>(Charset
|
||||
.availableCharsets().keySet());
|
||||
|
||||
return new AvailableCharsetList(charsetList, defaultEncoding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AvailableCharsetList getAvailableCharsetForExport()
|
||||
throws TDGWTServiceException {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
if (session == null) {
|
||||
throw new TDGWTServiceException(
|
||||
"Error retrieving the session: null");
|
||||
}
|
||||
logger.info("Session:" + session.getId());
|
||||
ArrayList<String> charsetList = EncodingPGSupported
|
||||
.getEncodidingStringList();
|
||||
String defaultEncoding = EncodingPGSupported.getDefaultEncoding();
|
||||
|
||||
return new AvailableCharsetList(charsetList, defaultEncoding);
|
||||
}
|
||||
|
||||
|
@ -4896,20 +4914,24 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
/**
|
||||
*
|
||||
* @param trId
|
||||
* @param session TODO
|
||||
* @param session
|
||||
* TODO
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
protected void checkTRId(TRId trId, HttpSession session) throws TDGWTServiceException {
|
||||
protected void checkTRId(TRId trId, HttpSession session)
|
||||
throws TDGWTServiceException {
|
||||
if (trId == null) {
|
||||
ResourceBundle messages = getResourceBundle(session);
|
||||
logger.error("TRId is null");
|
||||
throw new TDGWTServiceException(messages.getString(TDGWTServiceMessagesConstants.noValidTabularResourceIdPresent));
|
||||
throw new TDGWTServiceException(
|
||||
messages.getString(TDGWTServiceMessagesConstants.noValidTabularResourceIdPresent));
|
||||
}
|
||||
|
||||
if (trId.getId() == null || trId.getId().isEmpty()) {
|
||||
ResourceBundle messages = getResourceBundle(session);
|
||||
logger.error("TRId not valid: " + trId);
|
||||
throw new TDGWTServiceException(messages.getString(TDGWTServiceMessagesConstants.noValidTabularResourceIdPresent));
|
||||
throw new TDGWTServiceException(
|
||||
messages.getString(TDGWTServiceMessagesConstants.noValidTabularResourceIdPresent));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4919,14 +4941,15 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
* @param session
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
protected void checkTabularResourceLocked(TabularResource tabularResource, HttpSession session)
|
||||
throws TDGWTServiceException {
|
||||
protected void checkTabularResourceLocked(TabularResource tabularResource,
|
||||
HttpSession session) throws TDGWTServiceException {
|
||||
try {
|
||||
|
||||
if (tabularResource.isLocked()) {
|
||||
ResourceBundle messages = getResourceBundle(session);
|
||||
logger.error("Tabular Resource Is Locked!");
|
||||
throw new TDGWTIsLockedException(messages.getString(TDGWTServiceMessagesConstants.tabularResourceIsLocked));
|
||||
throw new TDGWTIsLockedException(
|
||||
messages.getString(TDGWTServiceMessagesConstants.tabularResourceIsLocked));
|
||||
}
|
||||
} catch (TDGWTServiceException e) {
|
||||
throw e;
|
||||
|
@ -4941,20 +4964,21 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
/**
|
||||
*
|
||||
*
|
||||
* @param session TODO
|
||||
* @param session
|
||||
* TODO
|
||||
* @param service
|
||||
* @param trId
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
protected void checkTabularResourceIsFinal(TabularResource tabularResource, HttpSession session)
|
||||
throws TDGWTServiceException {
|
||||
protected void checkTabularResourceIsFinal(TabularResource tabularResource,
|
||||
HttpSession session) throws TDGWTServiceException {
|
||||
try {
|
||||
|
||||
|
||||
|
||||
if (tabularResource.isFinalized()) {
|
||||
ResourceBundle messages = getResourceBundle(session);
|
||||
logger.error("Tabular Resource Is Final!");
|
||||
throw new TDGWTIsFinalException(messages.getString(TDGWTServiceMessagesConstants.tabularResourceIsFinal));
|
||||
throw new TDGWTIsFinalException(
|
||||
messages.getString(TDGWTServiceMessagesConstants.tabularResourceIsFinal));
|
||||
}
|
||||
|
||||
} catch (TDGWTServiceException e) {
|
||||
|
@ -4969,13 +4993,14 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
/**
|
||||
*
|
||||
* @param session TODO
|
||||
* @param session
|
||||
* TODO
|
||||
* @param service
|
||||
* @param trId
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
protected void checkTabularResourceIsFlow(TabularResource tabularResource, HttpSession session)
|
||||
throws TDGWTServiceException {
|
||||
protected void checkTabularResourceIsFlow(TabularResource tabularResource,
|
||||
HttpSession session) throws TDGWTServiceException {
|
||||
try {
|
||||
|
||||
if (tabularResource.getTabularResourceType().compareTo(
|
||||
|
@ -5542,7 +5567,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
aslSession.getUsername(), aslSession.getScope()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
checkTRId(replaceColumnByExpressionSession.getColumn().getTrId(), null);
|
||||
checkTRId(replaceColumnByExpressionSession.getColumn().getTrId(),
|
||||
null);
|
||||
|
||||
TabularResourceId tabularResourceId = new TabularResourceId(
|
||||
Long.valueOf(replaceColumnByExpressionSession.getColumn()
|
||||
|
@ -9322,7 +9348,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
public String startChartTopRating(
|
||||
ChartTopRatingSession chartTopRatingSession)
|
||||
throws TDGWTServiceException {
|
||||
HttpSession session=null;
|
||||
HttpSession session = null;
|
||||
try {
|
||||
session = this.getThreadLocalRequest().getSession();
|
||||
SessionUtil
|
||||
|
@ -9388,7 +9414,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
@Override
|
||||
public void saveResource(SaveResourceSession saveResourceSession)
|
||||
throws TDGWTServiceException {
|
||||
HttpSession session=null;
|
||||
HttpSession session = null;
|
||||
try {
|
||||
session = this.getThreadLocalRequest().getSession();
|
||||
SessionUtil.setSaveResourceSession(session, saveResourceSession);
|
||||
|
@ -9578,7 +9604,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
public String startGeospatialCreateCoordinates(
|
||||
GeospatialCreateCoordinatesSession geospatialCreateCoordinatesSession)
|
||||
throws TDGWTServiceException {
|
||||
HttpSession session=null;
|
||||
HttpSession session = null;
|
||||
try {
|
||||
session = this.getThreadLocalRequest().getSession();
|
||||
SessionUtil.setGeospatialCreateCoordinatesSession(session,
|
||||
|
@ -9655,7 +9681,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
public String startGeospatialDownscaleCSquare(
|
||||
GeospatialDownscaleCSquareSession geospatialDownscaleCSquareSession)
|
||||
throws TDGWTServiceException {
|
||||
HttpSession session=null;
|
||||
HttpSession session = null;
|
||||
try {
|
||||
session = this.getThreadLocalRequest().getSession();
|
||||
SessionUtil.setGeospatialDownscaleCSquareSession(session,
|
||||
|
@ -9731,7 +9757,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
public String startGeometryCreatePoint(
|
||||
GeometryCreatePointSession geometryCreatePointSession)
|
||||
throws TDGWTServiceException {
|
||||
HttpSession session=null;
|
||||
HttpSession session = null;
|
||||
try {
|
||||
session = this.getThreadLocalRequest().getSession();
|
||||
SessionUtil.setGeometryCreatePointSession(session,
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
package org.gcube.portlets.user.td.gwtservice.server.encoding;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author giancarlo email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public enum EncodingPGSupported {
|
||||
BIG5, EUC_CN, EUC_JP, EUC_JIS_2004, EUC_KR, EUC_TW, GB18030,
|
||||
GBK, ISO_8859_5, ISO_8859_6, ISO_8859_7, ISO_8859_8, JOHAB,
|
||||
KOI8R, KOI8U, LATIN1, LATIN2, LATIN3, LATIN4, LATIN5,
|
||||
LATIN6, LATIN7, LATIN8, LATIN9, LATIN10, MULE_INTERNAL,
|
||||
SJIS, SHIFT_JIS_2004, SQL_ASCII, UHC, UTF8,
|
||||
WIN866, WIN874, WIN1250, WIN1251, WIN1252, WIN1253, WIN1254,
|
||||
WIN1255, WIN1256, WIN1257, WIN1258;
|
||||
|
||||
private static ArrayList<String> encodingStringList;
|
||||
|
||||
static {
|
||||
encodingStringList = new ArrayList<String>();
|
||||
for (EncodingPGSupported r : values()) {
|
||||
encodingStringList.add(r.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public static ArrayList<String> getEncodidingStringList() {
|
||||
return encodingStringList;
|
||||
}
|
||||
|
||||
public static String getDefaultEncoding() {
|
||||
return UTF8.toString();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue