This commit is contained in:
Francesco Mangiacrapa 2022-10-07 18:38:31 +02:00
parent e487edcce0
commit d15fdacb08
4 changed files with 133 additions and 9 deletions

View File

@ -0,0 +1,94 @@
package org.gcube.application.geoportalcommon.geoportal.access;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class GeportalCheckAccessPolicy.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Oct 7, 2022
*/
public class GeportalCheckAccessPolicy {
private static final Logger LOG = LoggerFactory.getLogger(GeportalCheckAccessPolicy.class);
/**
* The Enum ACCESS_POLICY.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Sep 8, 2021
*/
public static enum ACCESS_POLICY {
OPEN, RESTICTED
}
/**
* Checks if is open access.
*
* @param policy the policy
* @return true, if is open access
*/
private static boolean isOpenAccess(String policy) {
if (policy == null || policy.equalsIgnoreCase(ACCESS_POLICY.OPEN.name())) {
return true;
}
return false;
}
/**
* Checks if is restricted access.
*
* @param policy the policy
* @return true, if is restricted access
*/
private static boolean isRestrictedAccess(String policy) {
if (policy == null || policy.equalsIgnoreCase(ACCESS_POLICY.RESTICTED.name())) {
return true;
}
return false;
}
/**
* Checks if is accessible accoding to access policies.
*
* @param policy the policy
* @param myLogin the my login
* @return true, if is accessible
*/
public static boolean isAccessible(String policy, String myLogin) {
boolean bool = isOpenAccess(policy);
if (bool) {
// is open access
return true;
}
// From here managing is NOT OPEN access
if (myLogin == null || myLogin.isEmpty()) {
// here is not open and the user is not authenticated
return false;
}
// Here the login is not null, so checking if the access to item is RESTICTED
bool = isRestrictedAccess(policy);
if (bool) {
// is restricted access
return true;
}
// Here the user is authenticated, but the policy is not managed, so returning
// true
return true;
}
}

View File

@ -1,6 +1,7 @@
package org.gcube.application.geoportalcommon.shared.geoportal.view;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
public class FilesetDV implements Serializable {
@ -10,25 +11,46 @@ public class FilesetDV implements Serializable {
*/
private static final long serialVersionUID = -2587586022638697113L;
private List<PayloadDV> listPayload;
private String name;
private List<PayloadDV> listPayloads;
public FilesetDV() {
}
public List<PayloadDV> getListPayload() {
return listPayload;
public String getName() {
return name;
}
public void setListPayload(List<PayloadDV> listPayload) {
this.listPayload = listPayload;
public void setName(String name) {
this.name = name;
}
public List<PayloadDV> getListPayload() {
return listPayloads;
}
public void addPayloadDV(PayloadDV payloadDV) {
if (listPayloads == null)
listPayloads = new ArrayList<PayloadDV>();
listPayloads.add(payloadDV);
}
public void addListPayloadsDV(List<PayloadDV> listPayloadsDV) {
if (listPayloads == null)
listPayloads = new ArrayList<PayloadDV>();
listPayloads.addAll(listPayloadsDV);
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("FilesetDV [listPayload=");
builder.append(listPayload);
builder.append("FilesetDV [name=");
builder.append(name);
builder.append(", listPayloads=");
builder.append(listPayloads);
builder.append("]");
return builder.toString();
}

View File

@ -8,8 +8,12 @@ import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
public class ProjectView {
private ProjectDV theProjectDV;
//The DocumentDV (contained in the ProjectDV) is listed in SectionView
private List<SectionView> listSections = new ArrayList<SectionView>();
private long centroidLong;
private long centroidLat;
public ProjectView() {
}

View File

@ -12,7 +12,7 @@ public class SectionView implements Serializable {
private static final long serialVersionUID = -687500472291023073L;
private String sectionTitle;
private List<SubDocumentView> listSubDocuments = new ArrayList<SubDocumentView>();
private List<SubDocumentView> listSubDocuments;
public SectionView() {
@ -23,6 +23,10 @@ public class SectionView implements Serializable {
}
public void addSubDocument(SubDocumentView subDocumentView) {
if (listSubDocuments == null)
listSubDocuments = new ArrayList<SubDocumentView>();
listSubDocuments.add(subDocumentView);
}