Skip to content
Snippets Groups Projects
Commit f0f534e4 authored by juanf's avatar juanf
Browse files

SSDM-3733 : New V3 API Call to retrieve session information

SVN: 36683
parent 659e98f3
No related branches found
No related tags found
No related merge requests found
......@@ -94,6 +94,7 @@ import ch.ethz.sis.openbis.generic.asapi.v3.dto.service.CustomASServiceExecution
import ch.ethz.sis.openbis.generic.asapi.v3.dto.service.fetchoptions.CustomASServiceFetchOptions;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.service.id.ICustomASServiceId;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.service.search.CustomASServiceSearchCriteria;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.session.SessionInformation;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.space.Space;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.space.create.SpaceCreation;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.space.delete.SpaceDeletionOptions;
......@@ -142,6 +143,7 @@ import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.method.IGetExperimen
import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.method.IGetMaterialMethodExecutor;
import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.method.IGetProjectMethodExecutor;
import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.method.IGetSampleMethodExecutor;
import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.method.IGetSessionInformationExecutor;
import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.method.IGetSpaceMethodExecutor;
import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.method.IGetTagMethodExecutor;
import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.method.IGetVocabularyTermMethodExecutor;
......@@ -358,6 +360,9 @@ public class ApplicationServerApi extends AbstractServer<IApplicationServerApi>
@Autowired
private IUnarchiveDataSetMethodExecutor unarchiveDataSetExecutor;
@Autowired
private IGetSessionInformationExecutor getSessionInformationExecutor;
// Default constructor needed by Spring
public ApplicationServerApi()
{
......@@ -892,6 +897,14 @@ public class ApplicationServerApi extends AbstractServer<IApplicationServerApi>
unarchiveDataSetExecutor.unarchive(sessionToken, dataSetIds, options);
}
@Override
@Transactional(readOnly = true)
@RolesAllowed({ RoleWithHierarchy.SPACE_OBSERVER, RoleWithHierarchy.SPACE_ETL_SERVER })
public SessionInformation getSessionInformation(String sessionToken)
{
return getSessionInformationExecutor.getSessionInformation(sessionToken);
}
@Override
public IApplicationServerApi createLogger(IInvocationLoggerContext context)
{
......@@ -909,5 +922,4 @@ public class ApplicationServerApi extends AbstractServer<IApplicationServerApi>
{
return 0;
}
}
......@@ -90,6 +90,7 @@ import ch.ethz.sis.openbis.generic.asapi.v3.dto.service.CustomASServiceExecution
import ch.ethz.sis.openbis.generic.asapi.v3.dto.service.fetchoptions.CustomASServiceFetchOptions;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.service.id.ICustomASServiceId;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.service.search.CustomASServiceSearchCriteria;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.session.SessionInformation;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.space.Space;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.space.create.SpaceCreation;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.space.delete.SpaceDeletionOptions;
......@@ -527,4 +528,11 @@ public class ApplicationServerApiLogger extends AbstractServerLogger implements
logAccess(sessionToken, "unarchive-data-sets", "DATA_SET_IDS(%s) UNARCHIVE_OPTIONS(%s)", abbreviate(dataSetIds), options);
}
@Override
public SessionInformation getSessionInformation(String sessionToken)
{
logAccess(sessionToken, "session-info");
return null;
}
}
package ch.ethz.sis.openbis.generic.server.asapi.v3.executor.method;
import org.springframework.stereotype.Component;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.person.Person;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.session.SessionInformation;
import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.IOperationContext;
import ch.systemsx.cisd.openbis.generic.shared.dto.IAuthSession;
import ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE;
@Component
public class GetSessionInformationExecutor extends AbstractMethodExecutor implements IGetSessionInformationExecutor
{
@Override
public SessionInformation getSessionInformation(final String sessionToken)
{
return executeInContext(sessionToken, new IMethodAction<SessionInformation>()
{
@Override
public SessionInformation execute(IOperationContext context)
{
IAuthSession session = null;
try
{
session = context.getSession();
} catch (Exception ex)
{
// Ignore, if session is no longer available and error is thrown
}
SessionInformation sessionInfo = null;
if (session != null)
{
sessionInfo = new SessionInformation();
sessionInfo.setUserName(session.getUserName());
sessionInfo.setHomeGroupCode(session.tryGetHomeGroupCode());
PersonPE personPE = session.tryGetPerson();
Person person = new Person();
person.setFirstName(personPE.getFirstName());
person.setLastName(personPE.getLastName());
person.setUserId(personPE.getUserId());
person.setEmail(personPE.getEmail());
person.setRegistrationDate(personPE.getRegistrationDate());
person.setActive(personPE.isActive());
sessionInfo.setPerson(person);
PersonPE creatorPersonPE = session.tryGetCreatorPerson();
Person creatorPerson = new Person();
creatorPerson.setFirstName(creatorPersonPE.getFirstName());
creatorPerson.setLastName(creatorPersonPE.getLastName());
creatorPerson.setUserId(creatorPersonPE.getUserId());
creatorPerson.setEmail(creatorPersonPE.getEmail());
creatorPerson.setRegistrationDate(creatorPersonPE.getRegistrationDate());
creatorPerson.setActive(creatorPersonPE.isActive());
sessionInfo.setCreatorPerson(creatorPerson);
}
return sessionInfo;
}
});
}
}
package ch.ethz.sis.openbis.generic.server.asapi.v3.executor.method;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.session.SessionInformation;
public interface IGetSessionInformationExecutor
{
public SessionInformation getSessionInformation(final String sessionToken);
}
......@@ -89,6 +89,7 @@ import ch.ethz.sis.openbis.generic.asapi.v3.dto.service.CustomASServiceExecution
import ch.ethz.sis.openbis.generic.asapi.v3.dto.service.fetchoptions.CustomASServiceFetchOptions;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.service.id.ICustomASServiceId;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.service.search.CustomASServiceSearchCriteria;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.session.SessionInformation;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.space.Space;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.space.create.SpaceCreation;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.space.delete.SpaceDeletionOptions;
......@@ -140,6 +141,8 @@ public interface IApplicationServerApi extends IRpcService
public void logout(String sessionToken);
public SessionInformation getSessionInformation(String sessionToken);
public List<SpacePermId> createSpaces(String sessionToken, List<SpaceCreation> newSpaces);
public List<ProjectPermId> createProjects(String sessionToken, List<ProjectCreation> newProjects);
......
package ch.ethz.sis.openbis.generic.asapi.v3.dto.session;
import java.io.Serializable;
import com.fasterxml.jackson.annotation.JsonProperty;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.person.Person;
import ch.systemsx.cisd.base.annotation.JsonObject;
@JsonObject("as.dto.session.SessionInformation")
public class SessionInformation implements Serializable
{
private static final long serialVersionUID = 1L;
@JsonProperty
private String homeGroupCode;
@JsonProperty
private String userName;
@JsonProperty
private Person person;
@JsonProperty
private Person creatorPerson;
public String getHomeGroupCode()
{
return homeGroupCode;
}
public void setHomeGroupCode(String homeGroupCode)
{
this.homeGroupCode = homeGroupCode;
}
public String getUserName()
{
return userName;
}
public void setUserName(String userName)
{
this.userName = userName;
}
public Person getPerson()
{
return person;
}
public void setPerson(Person person)
{
this.person = person;
}
public Person getCreatorPerson()
{
return creatorPerson;
}
public void setCreatorPerson(Person creatorPerson)
{
this.creatorPerson = creatorPerson;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment