Added the GRSF_Admin (manage context) and GRSF (public context) contexts in web.xml for production environment. Better checks for status field in manage context
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/grsf-publisher-ws@139705 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
2df95eb79f
commit
d3f3eeddd9
|
@ -155,12 +155,23 @@ public class GrsfPublisherFisheryService {
|
|||
|
||||
}else{
|
||||
|
||||
// validate the record if it is a GRSF one and set the record type
|
||||
if(sourceInPath.equals(Sources.GRSF)){
|
||||
record.setRecordType(Record_Type.AGGREGATED);
|
||||
CommonServiceUtils.validateAggregatedRecord(record);
|
||||
}else
|
||||
record.setRecordType(Record_Type.ORIGINAL);
|
||||
// validate the record if it is a GRSF one and set the record type and in manage context
|
||||
// Status field is needed only in the Manage context
|
||||
String contextFromStatus = HelperMethods.getContextTypeFromStatus(record.getStatus(), context, contextServlet);
|
||||
if(contextFromStatus == null)
|
||||
throw new Exception("Please verify that the record you are publishing contains the 'status' "
|
||||
+ "field if you are in the Manage VRE. This field is not needed in the Public VRE. "
|
||||
+ " The current Manage context is " + (String)contextServlet.getInitParameter(HelperMethods.MANAGE_CONTEX_KEY)
|
||||
+ " The current Public context is " + (String)contextServlet.getInitParameter(HelperMethods.PUBLIC_CONTEX_KEY)
|
||||
);
|
||||
|
||||
if(contextFromStatus.equals(HelperMethods.MANAGE_CONTEX_KEY)){
|
||||
if(sourceInPath.equals(Sources.GRSF)){
|
||||
record.setRecordType(Record_Type.AGGREGATED);
|
||||
CommonServiceUtils.validateAggregatedRecord(record);
|
||||
}else
|
||||
record.setRecordType(Record_Type.ORIGINAL);
|
||||
}
|
||||
|
||||
// set the type
|
||||
record.setProductType(Product_Type.FISHERY.getOrigName());
|
||||
|
|
|
@ -150,12 +150,23 @@ public class GrsfPublisherStockService {
|
|||
|
||||
}else{
|
||||
|
||||
// validate the record if it is a GRSF one and set the record type
|
||||
if(sourceInPath.equals(Sources.GRSF)){
|
||||
record.setRecordType(Record_Type.AGGREGATED);
|
||||
CommonServiceUtils.validateAggregatedRecord(record);
|
||||
}else
|
||||
record.setRecordType(Record_Type.ORIGINAL);
|
||||
// validate the record if it is a GRSF one and set the record type and in manage context
|
||||
// Status field is needed only in the Manage context
|
||||
String contextFromStatus = HelperMethods.getContextTypeFromStatus(record.getStatus(), context, contextServlet);
|
||||
if(contextFromStatus == null)
|
||||
throw new Exception("Please verify that the record you are publishing contains the 'status' "
|
||||
+ "field if you are in the Manage VRE. This field is not needed in the Public VRE. "
|
||||
+ " The current Manage context is " + (String)contextServlet.getInitParameter(HelperMethods.MANAGE_CONTEX_KEY)
|
||||
+ " The current Public context is " + (String)contextServlet.getInitParameter(HelperMethods.PUBLIC_CONTEX_KEY)
|
||||
);
|
||||
|
||||
if(contextFromStatus.equals(HelperMethods.MANAGE_CONTEX_KEY)){
|
||||
if(sourceInPath.equals(Sources.GRSF)){
|
||||
record.setRecordType(Record_Type.AGGREGATED);
|
||||
CommonServiceUtils.validateAggregatedRecord(record);
|
||||
}else
|
||||
record.setRecordType(Record_Type.ORIGINAL);
|
||||
}
|
||||
|
||||
// set the type
|
||||
record.setProductType(Product_Type.STOCK.getOrigName());
|
||||
|
|
|
@ -8,12 +8,15 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
||||
import org.gcube.common.homelibrary.home.workspace.exceptions.InsufficientPrivilegesException;
|
||||
import org.gcube.common.homelibrary.home.workspace.exceptions.ItemAlreadyExistException;
|
||||
import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalFile;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Status;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.DataCatalogue;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.DataCatalogueFactory;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.DataCatalogueImpl;
|
||||
|
@ -37,8 +40,8 @@ public abstract class HelperMethods {
|
|||
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(HelperMethods.class);
|
||||
|
||||
// to be retrieved from the web.xml
|
||||
public static final String PENDING_CONTEX_KEY = "PendingContext";
|
||||
public static final String CONFIRMED_CONTEX_KEY = "ConfirmedContext";
|
||||
public static final String MANAGE_CONTEX_KEY = "ManageVRE";
|
||||
public static final String PUBLIC_CONTEX_KEY = "PublicVRE";
|
||||
private static final String CSV_MIME = "text/csv";
|
||||
private static final String PATH_SEPARATOR = "/";
|
||||
|
||||
|
@ -93,28 +96,37 @@ public abstract class HelperMethods {
|
|||
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Return the context in which the user wants to publish by the status information
|
||||
// * @param status
|
||||
// * @param contextServlet
|
||||
// * @return
|
||||
// */
|
||||
// public static String getContextFromStatus(Status status, ServletContext contextServlet) {
|
||||
//
|
||||
// String toReturn = null;
|
||||
// switch(status){
|
||||
// case Confirmed :
|
||||
// toReturn = (String)contextServlet.getInitParameter(CONFIRMED_CONTEX_KEY);
|
||||
// break;
|
||||
// case Pending:
|
||||
// toReturn = (String)contextServlet.getInitParameter(PENDING_CONTEX_KEY);
|
||||
// break;
|
||||
// default: break;
|
||||
//
|
||||
// }
|
||||
// logger.debug("Context evaluated is " + toReturn);
|
||||
// return toReturn;
|
||||
// }
|
||||
/**
|
||||
* Return the context in which the user wants to publish by the status information
|
||||
* @param status
|
||||
* @param contextServlet
|
||||
* @return
|
||||
*/
|
||||
|
||||
public static String getContextTypeFromStatus(Status status, String scope, ServletContext contextServlet) {
|
||||
|
||||
String toReturn = null;
|
||||
|
||||
switch(status){
|
||||
case Confirmed:
|
||||
case Pending:
|
||||
case Rejected:
|
||||
if(scope.equals((String)contextServlet.getInitParameter(MANAGE_CONTEX_KEY)))
|
||||
toReturn = MANAGE_CONTEX_KEY;
|
||||
else
|
||||
toReturn = null; // wrong context ...
|
||||
break;
|
||||
default:
|
||||
if(scope.equals((String)contextServlet.getInitParameter(PUBLIC_CONTEX_KEY)))
|
||||
toReturn = PUBLIC_CONTEX_KEY;
|
||||
else
|
||||
toReturn = null; // wrong context ...
|
||||
break;
|
||||
}
|
||||
|
||||
logger.debug("Context type evaluated is " + toReturn);
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the name the product will have
|
||||
|
|
|
@ -29,18 +29,18 @@
|
|||
</welcome-file-list>
|
||||
|
||||
<context-param>
|
||||
<description>Scope of pending products</description>
|
||||
<param-name>PendingContext</param-name>
|
||||
<!-- <param-value>/d4science.research-infrastructures.eu/FARM/GRSF</param-value> -->
|
||||
<description>Scope of pending products under manage activities</description>
|
||||
<param-name>ManageVRE</param-name>
|
||||
<!-- <param-value>/d4science.research-infrastructures.eu/FARM/GRSF_Admin</param-value> -->
|
||||
<param-value>/gcube/devNext/NextNext</param-value>
|
||||
<!-- <param-value>/gcube/preprod/Dorne</param-value> -->
|
||||
</context-param>
|
||||
|
||||
<context-param>
|
||||
<description>Scope of confirmed products</description>
|
||||
<param-name>ConfirmedContext</param-name>
|
||||
<!-- <param-value>/d4science.research-infrastructures.eu/FARM/GRSFAccepted</param-value> -->
|
||||
<description>Scope of products no longer under manage activities</description>
|
||||
<param-name>PublicVRE</param-name>
|
||||
<!-- <param-value>/d4science.research-infrastructures.eu/FARM/GRSF</param-value> -->
|
||||
<param-value>/gcube/devNext/NextNext</param-value>
|
||||
<!-- <param-value>/gcube/preprod/Dorne</param-value> -->
|
||||
<!-- <param-value>/gcube/preprod/preVRE</param-value> -->
|
||||
</context-param>
|
||||
</web-app>
|
||||
|
|
Loading…
Reference in New Issue