#23941 Added beans
This commit is contained in:
parent
e487edcce0
commit
d15fdacb08
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package org.gcube.application.geoportalcommon.shared.geoportal.view;
|
package org.gcube.application.geoportalcommon.shared.geoportal.view;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class FilesetDV implements Serializable {
|
public class FilesetDV implements Serializable {
|
||||||
|
@ -10,25 +11,46 @@ public class FilesetDV implements Serializable {
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -2587586022638697113L;
|
private static final long serialVersionUID = -2587586022638697113L;
|
||||||
|
|
||||||
private List<PayloadDV> listPayload;
|
private String name;
|
||||||
|
private List<PayloadDV> listPayloads;
|
||||||
|
|
||||||
public FilesetDV() {
|
public FilesetDV() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PayloadDV> getListPayload() {
|
public String getName() {
|
||||||
return listPayload;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setListPayload(List<PayloadDV> listPayload) {
|
public void setName(String name) {
|
||||||
this.listPayload = listPayload;
|
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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
builder.append("FilesetDV [listPayload=");
|
builder.append("FilesetDV [name=");
|
||||||
builder.append(listPayload);
|
builder.append(name);
|
||||||
|
builder.append(", listPayloads=");
|
||||||
|
builder.append(listPayloads);
|
||||||
builder.append("]");
|
builder.append("]");
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,12 @@ import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
|
||||||
public class ProjectView {
|
public class ProjectView {
|
||||||
|
|
||||||
private ProjectDV theProjectDV;
|
private ProjectDV theProjectDV;
|
||||||
|
//The DocumentDV (contained in the ProjectDV) is listed in SectionView
|
||||||
private List<SectionView> listSections = new ArrayList<SectionView>();
|
private List<SectionView> listSections = new ArrayList<SectionView>();
|
||||||
|
|
||||||
|
private long centroidLong;
|
||||||
|
private long centroidLat;
|
||||||
|
|
||||||
public ProjectView() {
|
public ProjectView() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ public class SectionView implements Serializable {
|
||||||
private static final long serialVersionUID = -687500472291023073L;
|
private static final long serialVersionUID = -687500472291023073L;
|
||||||
private String sectionTitle;
|
private String sectionTitle;
|
||||||
|
|
||||||
private List<SubDocumentView> listSubDocuments = new ArrayList<SubDocumentView>();
|
private List<SubDocumentView> listSubDocuments;
|
||||||
|
|
||||||
public SectionView() {
|
public SectionView() {
|
||||||
|
|
||||||
|
@ -23,6 +23,10 @@ public class SectionView implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addSubDocument(SubDocumentView subDocumentView) {
|
public void addSubDocument(SubDocumentView subDocumentView) {
|
||||||
|
|
||||||
|
if (listSubDocuments == null)
|
||||||
|
listSubDocuments = new ArrayList<SubDocumentView>();
|
||||||
|
|
||||||
listSubDocuments.add(subDocumentView);
|
listSubDocuments.add(subDocumentView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue