edu.internet2.middleware.grouper.grouperUi.serviceLogic.UiV2ProvisionerConfiguration Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of grouper-ui Show documentation
Show all versions of grouper-ui Show documentation
Internet2 Groups Management User Interface
The newest version!
package edu.internet2.middleware.grouper.grouperUi.serviceLogic;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import edu.internet2.middleware.grouper.Group;
import edu.internet2.middleware.grouper.GroupFinder;
import edu.internet2.middleware.grouper.GrouperSession;
import edu.internet2.middleware.grouper.Stem;
import edu.internet2.middleware.grouper.StemFinder;
import edu.internet2.middleware.grouper.app.config.GrouperConfigurationModuleAttribute;
import edu.internet2.middleware.grouper.app.provisioning.GrouperProvisioner;
import edu.internet2.middleware.grouper.app.provisioning.GrouperProvisioningDiagnosticsContainer;
import edu.internet2.middleware.grouper.app.provisioning.GrouperProvisioningError;
import edu.internet2.middleware.grouper.app.provisioning.GrouperProvisioningErrorSummary;
import edu.internet2.middleware.grouper.app.provisioning.GrouperProvisioningService;
import edu.internet2.middleware.grouper.app.provisioning.GrouperProvisioningSettings;
import edu.internet2.middleware.grouper.app.provisioning.GrouperProvisioningType;
import edu.internet2.middleware.grouper.app.provisioning.GrouperSyncLogWithOwner;
import edu.internet2.middleware.grouper.app.provisioning.ProvisionerStartWithBase;
import edu.internet2.middleware.grouper.app.provisioning.ProvisioningConfiguration;
import edu.internet2.middleware.grouper.audit.AuditEntry;
import edu.internet2.middleware.grouper.audit.AuditTypeBuiltin;
import edu.internet2.middleware.grouper.cfg.dbConfig.ConfigItemFormElement;
import edu.internet2.middleware.grouper.changeLog.esb.consumer.ProvisioningMessage;
import edu.internet2.middleware.grouper.grouperUi.beans.api.GuiGroup;
import edu.internet2.middleware.grouper.grouperUi.beans.api.GuiStem;
import edu.internet2.middleware.grouper.grouperUi.beans.json.GuiPaging;
import edu.internet2.middleware.grouper.grouperUi.beans.json.GuiResponseJs;
import edu.internet2.middleware.grouper.grouperUi.beans.json.GuiScreenAction;
import edu.internet2.middleware.grouper.grouperUi.beans.json.GuiScreenAction.GuiMessageType;
import edu.internet2.middleware.grouper.grouperUi.beans.ui.GrouperRequestContainer;
import edu.internet2.middleware.grouper.grouperUi.beans.ui.GuiProvisionerActivity;
import edu.internet2.middleware.grouper.grouperUi.beans.ui.GuiProvisionerConfiguration;
import edu.internet2.middleware.grouper.grouperUi.beans.ui.GuiProvisionerLog;
import edu.internet2.middleware.grouper.grouperUi.beans.ui.GuiProvisioningAssignment;
import edu.internet2.middleware.grouper.grouperUi.beans.ui.ProvisionerConfigurationContainer;
import edu.internet2.middleware.grouper.grouperUi.beans.ui.TextContainer;
import edu.internet2.middleware.grouper.hibernate.AuditControl;
import edu.internet2.middleware.grouper.hibernate.GrouperTransactionType;
import edu.internet2.middleware.grouper.hibernate.HibernateHandler;
import edu.internet2.middleware.grouper.hibernate.HibernateHandlerBean;
import edu.internet2.middleware.grouper.hibernate.HibernateSession;
import edu.internet2.middleware.grouper.internal.dao.GrouperDAOException;
import edu.internet2.middleware.grouper.internal.dao.QueryOptions;
import edu.internet2.middleware.grouper.internal.util.GrouperUuid;
import edu.internet2.middleware.grouper.ui.GrouperUiFilter;
import edu.internet2.middleware.grouper.ui.tags.GrouperPagingTag2;
import edu.internet2.middleware.grouper.ui.util.GrouperUiConfig;
import edu.internet2.middleware.grouper.util.GrouperCallable;
import edu.internet2.middleware.grouper.util.GrouperFuture;
import edu.internet2.middleware.grouper.util.GrouperUtil;
import edu.internet2.middleware.grouperClient.collections.MultiKey;
import edu.internet2.middleware.grouperClient.jdbc.tableSync.GcGrouperSync;
import edu.internet2.middleware.grouperClient.jdbc.tableSync.GcGrouperSyncDao;
import edu.internet2.middleware.grouperClient.jdbc.tableSync.GcGrouperSyncErrorCode;
import edu.internet2.middleware.grouperClient.jdbc.tableSync.GcGrouperSyncGroup;
import edu.internet2.middleware.grouperClient.jdbc.tableSync.GcGrouperSyncJob;
import edu.internet2.middleware.grouperClient.jdbc.tableSync.GcGrouperSyncMember;
import edu.internet2.middleware.grouperClient.jdbc.tableSync.GcGrouperSyncMembership;
import edu.internet2.middleware.grouperClient.util.ExpirableCache;
import edu.internet2.middleware.subject.Subject;
public class UiV2ProvisionerConfiguration {
/** logger */
protected static final Log LOG = edu.internet2.middleware.grouper.util.GrouperUtil.getLog(UiV2ProvisionerConfiguration.class);
/**
* keep an expirble cache of diagnostic progress for 5 hours (longest a diagnostics is expected). This has multikey of session id and some random uuid
* uniquely identifies this diagnostics request as opposed to other diagnostics in other tabs
*/
private static ExpirableCache diagnosticsThreadProgress = new ExpirableCache(300);
/**
* start diagnostics
* @param request
* @param response
*/
public void diagnostics(HttpServletRequest request, HttpServletResponse response) {
final Subject loggedInSubject = GrouperUiFilter.retrieveSubjectLoggedIn();
GrouperSession grouperSession = null;
Map debugMap = new LinkedHashMap();
long startNanos = System.nanoTime();
debugMap.put("method", "diagnostics");
GuiResponseJs guiResponseJs = GuiResponseJs.retrieveGuiResponseJs();
try {
grouperSession = GrouperSession.start(loggedInSubject);
ProvisionerConfigurationContainer provisionerConfigurationContainer = GrouperRequestContainer.retrieveFromRequestOrCreate().getProvisionerConfigurationContainer();
if (!provisionerConfigurationContainer.isCanViewProvisionerConfiguration()) {
throw new RuntimeException("Not allowed!!!!!");
}
String provisionerConfigId = request.getParameter("provisionerConfigId");
if (StringUtils.isBlank(provisionerConfigId)) {
throw new RuntimeException("provisionerConfigId cannot be blank");
}
GrouperRequestContainer grouperRequestContainer = GrouperRequestContainer.retrieveFromRequestOrCreate();
GrouperProvisioner provisioner = GrouperProvisioner.retrieveProvisioner(provisionerConfigId);
if (provisioner == null) {
throw new RuntimeException("No provisioner found for "+provisionerConfigId);
}
provisioner.initialize(GrouperProvisioningType.diagnostics);
final GrouperProvisioningDiagnosticsContainer grouperProvisioningDiagnosticsContainer = provisioner.retrieveGrouperProvisioningDiagnosticsContainer();
grouperRequestContainer.setGrouperProvisioningDiagnosticsContainer(grouperProvisioningDiagnosticsContainer);
GrouperProvisioner grouperProvisioner = GrouperProvisioner.retrieveProvisioner(provisionerConfigId);
ProvisioningConfiguration provisionerConfiguration = grouperProvisioner.getControllerForProvisioningConfiguration();
GuiProvisionerConfiguration guiProvisioningConfiguration = GuiProvisionerConfiguration.convertFromProvisioningConfiguration(provisionerConfiguration);
provisionerConfigurationContainer.setGuiProvisionerConfiguration(guiProvisioningConfiguration);
String initted = request.getParameter("provisionerInitted");
if (!GrouperUtil.booleanValue(initted, false)) {
grouperProvisioningDiagnosticsContainer.initFromConfiguration();
guiResponseJs.addAction(GuiScreenAction.newInnerHtmlFromJsp("#grouperMainContentDivId",
"/WEB-INF/grouperUi2/provisionerConfigs/provisionerDiagnosticsInit.jsp"));
return;
}
String sessionId = request.getSession().getId();
debugMap.put("sessionId", GrouperUtil.abbreviate(sessionId, 8));
// uniquely identifies this diagnostics as opposed to other diagnostics in other tabs
String uniqueDiagnosticsId = GrouperUuid.getUuid();
debugMap.put("uniqueDiagnosticsId", GrouperUtil.abbreviate(uniqueDiagnosticsId, 8));
grouperProvisioningDiagnosticsContainer.setUniqueDiagnosticsId(uniqueDiagnosticsId);
{
//deal with inputs and configuration
{
boolean diagnosticsGroupsAllSelectName = GrouperUtil.booleanValue(request.getParameter("diagnosticsGroupsAllSelectName[]"), false);
if (diagnosticsGroupsAllSelectName && provisioner.retrieveGrouperProvisioningBehavior().isSelectGroupsAll()) {
grouperProvisioningDiagnosticsContainer.getGrouperProvisioningDiagnosticsSettings().setDiagnosticsGroupsAllSelect(diagnosticsGroupsAllSelectName);
}
}
{
boolean diagnosticsEntitiesAllSelectName = GrouperUtil.booleanValue(request.getParameter("diagnosticsEntitiesAllSelectName[]"), false);
if (diagnosticsEntitiesAllSelectName && provisioner.retrieveGrouperProvisioningBehavior().isSelectEntitiesAll()) {
grouperProvisioningDiagnosticsContainer.getGrouperProvisioningDiagnosticsSettings().setDiagnosticsEntitiesAllSelect(diagnosticsEntitiesAllSelectName);
}
}
{
boolean diagnosticsMembershipsAllSelectName = GrouperUtil.booleanValue(request.getParameter("diagnosticsMembershipsAllSelectName[]"), false);
if (diagnosticsMembershipsAllSelectName && provisioner.retrieveGrouperProvisioningBehavior().isSelectMembershipsAll()) {
grouperProvisioningDiagnosticsContainer.getGrouperProvisioningDiagnosticsSettings().setDiagnosticsMembershipsAllSelect(diagnosticsMembershipsAllSelectName);
}
}
{
String diagnosticsGroupNameName = request.getParameter("diagnosticsGroupNameName");
grouperProvisioningDiagnosticsContainer.getGrouperProvisioningDiagnosticsSettings().setDiagnosticsGroupName(diagnosticsGroupNameName);
}
{
String diagnosticsSubjectIdOrIdentifierName = request.getParameter("diagnosticsSubjectIdOrIdentifierName");
grouperProvisioningDiagnosticsContainer.getGrouperProvisioningDiagnosticsSettings().setDiagnosticsSubjectIdOrIdentifier(diagnosticsSubjectIdOrIdentifierName);
}
{
boolean diagnosticsGroupsInsertName = GrouperUtil.booleanValue(request.getParameter("diagnosticsGroupsInsertName[]"), false);
if (diagnosticsGroupsInsertName && provisioner.retrieveGrouperProvisioningBehavior().isInsertGroups()) {
grouperProvisioningDiagnosticsContainer.getGrouperProvisioningDiagnosticsSettings().setDiagnosticsGroupInsert(diagnosticsGroupsInsertName);
}
}
{
boolean diagnosticsGroupsDeleteName = GrouperUtil.booleanValue(request.getParameter("diagnosticsGroupsDeleteName[]"), false);
if (diagnosticsGroupsDeleteName && provisioner.retrieveGrouperProvisioningBehavior().isDeleteGroups()) {
grouperProvisioningDiagnosticsContainer.getGrouperProvisioningDiagnosticsSettings().setDiagnosticsGroupDelete(diagnosticsGroupsDeleteName);
}
}
{
boolean diagnosticsEntitiesInsertName = GrouperUtil.booleanValue(request.getParameter("diagnosticsEntitiesInsertName[]"), false);
if (diagnosticsEntitiesInsertName && provisioner.retrieveGrouperProvisioningBehavior().isInsertEntities()) {
grouperProvisioningDiagnosticsContainer.getGrouperProvisioningDiagnosticsSettings().setDiagnosticsEntityInsert(diagnosticsEntitiesInsertName);
}
}
{
boolean diagnosticsEntitiesDeleteName = GrouperUtil.booleanValue(request.getParameter("diagnosticsEntitiesDeleteName[]"), false);
if (diagnosticsEntitiesDeleteName && provisioner.retrieveGrouperProvisioningBehavior().isDeleteEntities()) {
grouperProvisioningDiagnosticsContainer.getGrouperProvisioningDiagnosticsSettings().setDiagnosticsEntityDelete(diagnosticsEntitiesDeleteName);
}
}
{
boolean diagnosticsMembershipInsertName = GrouperUtil.booleanValue(request.getParameter("diagnosticsMembershipInsertName[]"), false);
if (diagnosticsMembershipInsertName) {
grouperProvisioningDiagnosticsContainer.getGrouperProvisioningDiagnosticsSettings().setDiagnosticsMembershipInsert(diagnosticsMembershipInsertName);
}
}
{
boolean diagnosticsMembershipDeleteName = GrouperUtil.booleanValue(request.getParameter("diagnosticsMembershipDeleteName[]"), false);
if (diagnosticsMembershipDeleteName) {
grouperProvisioningDiagnosticsContainer.getGrouperProvisioningDiagnosticsSettings().setDiagnosticsMembershipDelete(diagnosticsMembershipDeleteName);
}
}
}
MultiKey diagnosticsMultiKey = new MultiKey(sessionId, uniqueDiagnosticsId);
diagnosticsThreadProgress.put(diagnosticsMultiKey, provisioner);
GrouperCallable grouperCallable = new GrouperCallable("grouperProvisioningDiagnostics") {
@Override
public Void callLogic() {
try {
provisioner.provision(GrouperProvisioningType.diagnostics);
} catch (RuntimeException re) {
provisioner.retrieveGrouperProvisioningDiagnosticsContainer().getProgressBean().setHasException(true);
provisioner.retrieveGrouperProvisioningDiagnosticsContainer().getProgressBean().setException(re);
// log this since the thread will just end and will never get logged
LOG.error("error", re);
} finally {
// we done
provisioner.retrieveGrouperProvisioningDiagnosticsContainer().getProgressBean().setComplete(true);
}
return null;
}
};
// see if running in thread
boolean useThreads = GrouperUiConfig.retrieveConfig().propertyValueBooleanRequired("uiV2.provisioning.diagnostics.useThread");
debugMap.put("useThreads", useThreads);
if (useThreads) {
GrouperFuture grouperFuture = GrouperUtil.executorServiceSubmit(GrouperUtil.retrieveExecutorService(), grouperCallable);
Integer waitForCompleteForSeconds = GrouperUiConfig.retrieveConfig().propertyValueInt("uiV2.provisioning.diagnostics.progressStartsInSeconds");
debugMap.put("waitForCompleteForSeconds", waitForCompleteForSeconds);
GrouperFuture.waitForJob(grouperFuture, waitForCompleteForSeconds);
debugMap.put("threadAlive", !grouperFuture.isDone());
} else {
grouperCallable.callLogic();
}
guiResponseJs.addAction(GuiScreenAction.newInnerHtmlFromJsp("#grouperMainContentDivId",
"/WEB-INF/grouperUi2/provisionerConfigs/provisionerDiagnosticsWrapper.jsp"));
diagnosticsStatusHelper(sessionId, uniqueDiagnosticsId, provisionerConfigId);
} finally {
GrouperSession.stopQuietly(grouperSession);
}
}
/**
* get diagnostics status
* @param request
* @param response
*/
public void diagnosticsStatus(HttpServletRequest request, HttpServletResponse response) {
final Subject loggedInSubject = GrouperUiFilter.retrieveSubjectLoggedIn();
GrouperSession grouperSession = null;
try {
grouperSession = GrouperSession.start(loggedInSubject);
ProvisionerConfigurationContainer provisionerConfigurationContainer = GrouperRequestContainer.retrieveFromRequestOrCreate().getProvisionerConfigurationContainer();
if (!provisionerConfigurationContainer.isCanViewProvisionerConfiguration()) {
throw new RuntimeException("Not allowed!!!!!");
}
String provisionerConfigId = request.getParameter("provisionerConfigId");
if (StringUtils.isBlank(provisionerConfigId)) {
throw new RuntimeException("provisionerConfigId cannot be blank");
}
String sessionId = request.getSession().getId();
String uniqueDiagnosticsId = request.getParameter("uniqueDiagnosticsId");
diagnosticsStatusHelper(sessionId, uniqueDiagnosticsId, provisionerConfigId);
} finally {
GrouperSession.stopQuietly(grouperSession);
}
}
/**
* get diagnostics status
* @param request
* @param response
*/
private void diagnosticsStatusHelper(String sessionId, String uniqueDiagnosticsId, String provisionerConfigId) {
Map debugMap = new LinkedHashMap();
debugMap.put("method", "diagnosticsStatusHelper");
debugMap.put("provisionerConfigId", provisionerConfigId);
debugMap.put("sessionId", GrouperUtil.abbreviate(sessionId, 8));
long startNanos = System.nanoTime();
try {
GuiResponseJs guiResponseJs = GuiResponseJs.retrieveGuiResponseJs();
MultiKey diagnosticsMultiKey = new MultiKey(sessionId, uniqueDiagnosticsId);
GrouperProvisioner provisioner = diagnosticsThreadProgress.get(diagnosticsMultiKey);
if (provisioner == null) return;
GrouperProvisioningDiagnosticsContainer diagnosticsContainer = provisioner.retrieveGrouperProvisioningDiagnosticsContainer();
GrouperRequestContainer.retrieveFromRequestOrCreate().setGrouperProvisioningDiagnosticsContainer(diagnosticsContainer);
//show the diagnostics screen
guiResponseJs.addAction(GuiScreenAction.newInnerHtmlFromJsp("#id_"+uniqueDiagnosticsId,
"/WEB-INF/grouperUi2/provisionerConfigs/provisionerDiagnostics.jsp"));
debugMap.put("percentComplete", diagnosticsContainer.getProgressBean().getPercentComplete());
debugMap.put("progressCompleteRecords", diagnosticsContainer.getProgressBean().getProgressCompleteRecords());
debugMap.put("progressTotalRecords", diagnosticsContainer.getProgressBean().getProgressTotalRecords());
if (diagnosticsContainer != null) {
// endless loop?
if (diagnosticsContainer.getProgressBean().isThisLastStatus()) {
return;
}
if (diagnosticsContainer.getProgressBean().isHasException()) {
guiResponseJs.addAction(GuiScreenAction.newMessage(GuiMessageType.error,
TextContainer.retrieveFromRequest().getText().get("grouperProvisioningDiagnosticsException")));
// it has an exception, leave it be
diagnosticsThreadProgress.put(diagnosticsMultiKey, null);
return;
}
// kick it off again?
debugMap.put("complete", diagnosticsContainer.getProgressBean().isComplete());
if (!diagnosticsContainer.getProgressBean().isComplete()) {
int progressRefreshSeconds = GrouperUiConfig.retrieveConfig().propertyValueInt("uiV2.provisioning.diagnostics.progressRefreshSeconds");
progressRefreshSeconds = Math.max(progressRefreshSeconds, 1);
progressRefreshSeconds *= 1000;
guiResponseJs.addAction(GuiScreenAction.newScript("setTimeout(function() {ajax('../app/UiV2ProvisionerConfiguration.diagnosticsStatus?uniqueDiagnosticsId=" + uniqueDiagnosticsId + "&provisionerConfigId="+provisionerConfigId+"')}, " + progressRefreshSeconds + ")"));
} else {
// it is complete, leave it be
diagnosticsThreadProgress.put(diagnosticsMultiKey, null);
}
}
} catch (RuntimeException re) {
debugMap.put("exception", GrouperUtil.getFullStackTrace(re));
throw re;
} finally {
if (LOG.isDebugEnabled()) {
debugMap.put("tookMillis", (System.nanoTime()-startNanos)/1000000);
LOG.debug(GrouperUtil.mapToString(debugMap));
}
}
}
/**
* view configured provisioner configurations
* @param request
* @param response
*/
public void viewProvisionerConfigurations(final HttpServletRequest request, final HttpServletResponse response) {
final Subject loggedInSubject = GrouperUiFilter.retrieveSubjectLoggedIn();
GrouperSession grouperSession = null;
final GuiResponseJs guiResponseJs = GuiResponseJs.retrieveGuiResponseJs();
try {
grouperSession = GrouperSession.start(loggedInSubject);
ProvisionerConfigurationContainer provisionerConfigurationContainer = GrouperRequestContainer.retrieveFromRequestOrCreate().getProvisionerConfigurationContainer();
if (!provisionerConfigurationContainer.isCanViewProvisionerConfiguration()) {
throw new RuntimeException("Not allowed!!!!!");
}
String sessionId = request.getSession().getId();
String uniqueDiagnosticsId = request.getParameter("uniqueDiagnosticsId");
if (StringUtils.isNotBlank(uniqueDiagnosticsId)) {
MultiKey diagnosticsMultiKey = new MultiKey(sessionId, uniqueDiagnosticsId);
diagnosticsThreadProgress.put(diagnosticsMultiKey, null);
}
List provisionerConfigurations = ProvisioningConfiguration.retrieveAllViewableProvisioningConfigurations(loggedInSubject);
List guiProvisionerConfigurations = GuiProvisionerConfiguration.convertFromProvisioningConfiguration(provisionerConfigurations);
provisionerConfigurationContainer.setGuiProvisionerConfigurations(guiProvisionerConfigurations);
guiResponseJs.addAction(GuiScreenAction.newInnerHtmlFromJsp("#grouperMainContentDivId",
"/WEB-INF/grouperUi2/provisionerConfigs/provisionerConfigs.jsp"));
} finally {
GrouperSession.stopQuietly(grouperSession);
}
}
/**
* view details of one provisioner configuration
* @param request
* @param response
*/
public void viewProvisionerConfigDetails(final HttpServletRequest request, final HttpServletResponse response) {
final Subject loggedInSubject = GrouperUiFilter.retrieveSubjectLoggedIn();
GrouperSession grouperSession = null;
final GuiResponseJs guiResponseJs = GuiResponseJs.retrieveGuiResponseJs();
try {
grouperSession = GrouperSession.start(loggedInSubject);
ProvisionerConfigurationContainer provisionerConfigurationContainer = GrouperRequestContainer.retrieveFromRequestOrCreate().getProvisionerConfigurationContainer();
String provisionerConfigId = request.getParameter("provisionerConfigId");
if (StringUtils.isBlank(provisionerConfigId)) {
throw new RuntimeException("provisionerConfigId cannot be blank");
}
if (!provisionerConfigurationContainer.isCanViewProvisionerConfiguration(provisionerConfigId)) {
throw new RuntimeException("Not allowed!!!!!");
}
GrouperProvisioner grouperProvisioner = GrouperProvisioner.retrieveProvisioner(provisionerConfigId);
ProvisioningConfiguration provisionerConfiguration = grouperProvisioner.getControllerForProvisioningConfiguration();
GuiProvisionerConfiguration guiProvisioningConfiguration = GuiProvisionerConfiguration.convertFromProvisioningConfiguration(provisionerConfiguration);
provisionerConfigurationContainer.setGuiProvisionerConfiguration(guiProvisioningConfiguration);
guiResponseJs.addAction(GuiScreenAction.newInnerHtmlFromJsp("#grouperMainContentDivId",
"/WEB-INF/grouperUi2/provisionerConfigs/provisionerConfigDetails.jsp"));
} finally {
GrouperSession.stopQuietly(grouperSession);
}
}
/**
* view provisioner jobs
* @param request
* @param response
*/
public void viewProvisionerJobs(final HttpServletRequest request, final HttpServletResponse response) {
final Subject loggedInSubject = GrouperUiFilter.retrieveSubjectLoggedIn();
GrouperSession grouperSession = null;
final GuiResponseJs guiResponseJs = GuiResponseJs.retrieveGuiResponseJs();
try {
grouperSession = GrouperSession.start(loggedInSubject);
ProvisionerConfigurationContainer provisionerConfigurationContainer = GrouperRequestContainer.retrieveFromRequestOrCreate().getProvisionerConfigurationContainer();
String provisionerConfigId = request.getParameter("provisionerConfigId");
if (StringUtils.isBlank(provisionerConfigId)) {
throw new RuntimeException("provisionerConfigId cannot be blank");
}
if (!provisionerConfigurationContainer.isCanViewProvisionerConfiguration(provisionerConfigId)) {
throw new RuntimeException("Not allowed!!!!!");
}
GrouperProvisioner grouperProvisioner = GrouperProvisioner.retrieveProvisioner(provisionerConfigId);
ProvisioningConfiguration provisionerConfiguration = grouperProvisioner.getControllerForProvisioningConfiguration();
GuiProvisionerConfiguration guiProvisioningConfiguration = GuiProvisionerConfiguration.convertFromProvisioningConfiguration(provisionerConfiguration);
provisionerConfigurationContainer.setGuiProvisionerConfiguration(guiProvisioningConfiguration);
List grouperSyncJobs = GrouperProvisioningService.retrieveGcGroupSyncJobs(provisionerConfigId);
provisionerConfigurationContainer.setProvisionerJobs(grouperSyncJobs);
guiResponseJs.addAction(GuiScreenAction.newInnerHtmlFromJsp("#grouperMainContentDivId",
"/WEB-INF/grouperUi2/provisionerConfigs/provisionerConfigJobs.jsp"));
} finally {
GrouperSession.stopQuietly(grouperSession);
}
}
/**
* view provisioner job details
* @param request
* @param response
*/
public void viewProvisionerJobDetails(final HttpServletRequest request, final HttpServletResponse response) {
final Subject loggedInSubject = GrouperUiFilter.retrieveSubjectLoggedIn();
GrouperSession grouperSession = null;
final GuiResponseJs guiResponseJs = GuiResponseJs.retrieveGuiResponseJs();
try {
grouperSession = GrouperSession.start(loggedInSubject);
ProvisionerConfigurationContainer provisionerConfigurationContainer = GrouperRequestContainer.retrieveFromRequestOrCreate().getProvisionerConfigurationContainer();
String provisionerConfigId = request.getParameter("provisionerConfigId");
String provisionerJobId = request.getParameter("provisionerJobId");
if (StringUtils.isBlank(provisionerConfigId)) {
throw new RuntimeException("provisionerConfigId cannot be blank");
}
if (StringUtils.isBlank(provisionerJobId)) {
throw new RuntimeException("provisionerJobId cannot be blank");
}
if (!provisionerConfigurationContainer.isCanViewProvisionerConfiguration(provisionerConfigId)) {
throw new RuntimeException("Not allowed!!!!!");
}
GrouperProvisioner grouperProvisioner = GrouperProvisioner.retrieveProvisioner(provisionerConfigId);
ProvisioningConfiguration provisionerConfiguration = grouperProvisioner.getControllerForProvisioningConfiguration();
GuiProvisionerConfiguration guiProvisioningConfiguration = GuiProvisionerConfiguration.convertFromProvisioningConfiguration(provisionerConfiguration);
provisionerConfigurationContainer.setGuiProvisionerConfiguration(guiProvisioningConfiguration);
GcGrouperSync gcGrouperSync = GcGrouperSyncDao.retrieveByProvisionerName(null, provisionerConfigId);
if (gcGrouperSync == null) {
throw new RuntimeException("Invalid provisionerConfigId: "+provisionerConfigId);
}
GcGrouperSyncJob grouperSyncJob = gcGrouperSync.getGcGrouperSyncJobDao().jobRetrieveById(provisionerJobId);
if (grouperSyncJob == null) {
throw new RuntimeException("Invalid provisionerJobId: "+provisionerJobId);
}
provisionerConfigurationContainer.setGrouperSyncJob(grouperSyncJob);
guiResponseJs.addAction(GuiScreenAction.newInnerHtmlFromJsp("#grouperMainContentDivId",
"/WEB-INF/grouperUi2/provisionerConfigs/provisionerConfigJobDetails.jsp"));
} finally {
GrouperSession.stopQuietly(grouperSession);
}
}
/**
* user clicked on view provisioner activity action. show screen so user can pick Group, Entity or Membership
* @param request
* @param response
*/
public void viewProvisionerActivity(final HttpServletRequest request, final HttpServletResponse response) {
final Subject loggedInSubject = GrouperUiFilter.retrieveSubjectLoggedIn();
GrouperSession grouperSession = null;
final GuiResponseJs guiResponseJs = GuiResponseJs.retrieveGuiResponseJs();
try {
grouperSession = GrouperSession.start(loggedInSubject);
ProvisionerConfigurationContainer provisionerConfigurationContainer = GrouperRequestContainer.retrieveFromRequestOrCreate().getProvisionerConfigurationContainer();
String provisionerConfigId = request.getParameter("provisionerConfigId");
if (StringUtils.isBlank(provisionerConfigId)) {
throw new RuntimeException("provisionerConfigId cannot be blank");
}
if (!provisionerConfigurationContainer.isCanViewProvisionerConfiguration(provisionerConfigId)) {
throw new RuntimeException("Not allowed!!!!!");
}
GrouperProvisioner grouperProvisioner = GrouperProvisioner.retrieveProvisioner(provisionerConfigId);
ProvisioningConfiguration provisionerConfiguration = grouperProvisioner.getControllerForProvisioningConfiguration();
GuiProvisionerConfiguration guiProvisioningConfiguration = GuiProvisionerConfiguration.convertFromProvisioningConfiguration(provisionerConfiguration);
provisionerConfigurationContainer.setGuiProvisionerConfiguration(guiProvisioningConfiguration);
guiResponseJs.addAction(GuiScreenAction.newInnerHtmlFromJsp("#grouperMainContentDivId",
"/WEB-INF/grouperUi2/provisionerConfigs/provisionerConfigViewActivity.jsp"));
} finally {
GrouperSession.stopQuietly(grouperSession);
}
}
/**
* user clicked on view errors action. Show page that presents with filter
* @param request
* @param response
*/
public void viewProvisionerErrors(final HttpServletRequest request, final HttpServletResponse response) {
final Subject loggedInSubject = GrouperUiFilter.retrieveSubjectLoggedIn();
GrouperSession grouperSession = null;
final GuiResponseJs guiResponseJs = GuiResponseJs.retrieveGuiResponseJs();
try {
grouperSession = GrouperSession.start(loggedInSubject);
ProvisionerConfigurationContainer provisionerConfigurationContainer = GrouperRequestContainer.retrieveFromRequestOrCreate().getProvisionerConfigurationContainer();
String provisionerConfigId = request.getParameter("provisionerConfigId");
if (StringUtils.isBlank(provisionerConfigId)) {
throw new RuntimeException("provisionerConfigId cannot be blank");
}
if (!provisionerConfigurationContainer.isCanViewProvisionerConfiguration(provisionerConfigId)) {
throw new RuntimeException("Not allowed!!!!!");
}
GrouperProvisioner grouperProvisioner = GrouperProvisioner.retrieveProvisioner(provisionerConfigId);
ProvisioningConfiguration provisionerConfiguration = grouperProvisioner.getControllerForProvisioningConfiguration();
GuiProvisionerConfiguration guiProvisioningConfiguration = GuiProvisionerConfiguration.convertFromProvisioningConfiguration(provisionerConfiguration);
provisionerConfigurationContainer.setGuiProvisionerConfiguration(guiProvisioningConfiguration);
guiResponseJs.addAction(GuiScreenAction.newInnerHtmlFromJsp("#grouperMainContentDivId",
"/WEB-INF/grouperUi2/provisionerConfigs/provisionerConfigViewErrors.jsp"));
} finally {
GrouperSession.stopQuietly(grouperSession);
}
}
/**
* user submitted view provisioner errors form. show errors for the selected filters
* @param request
* @param response
*/
public void viewProvisionerErrorsSubmit(final HttpServletRequest request, final HttpServletResponse response) {
final Subject loggedInSubject = GrouperUiFilter.retrieveSubjectLoggedIn();
GrouperSession grouperSession = null;
final GuiResponseJs guiResponseJs = GuiResponseJs.retrieveGuiResponseJs();
try {
grouperSession = GrouperSession.start(loggedInSubject);
ProvisionerConfigurationContainer provisionerConfigurationContainer = GrouperRequestContainer.retrieveFromRequestOrCreate().getProvisionerConfigurationContainer();
String provisionerConfigId = request.getParameter("provisionerConfigId");
if (StringUtils.isBlank(provisionerConfigId)) {
throw new RuntimeException("provisionerConfigId cannot be blank");
}
if (!provisionerConfigurationContainer.isCanViewProvisionerConfiguration(provisionerConfigId)) {
throw new RuntimeException("Not allowed!!!!!");
}
String provisionerConfigObjectType = request.getParameter("provisionerConfigObjectType");
String provisionerConfigErrorType = request.getParameter("provisionerConfigErrorType");
String provisionerConfigErrorDuration = request.getParameter("provisionerConfigErrorDuration");
String provisionerConfigErrorGroup = request.getParameter("provisionerConfigErrorGroup");
String provisionerConfigErrorEntity = request.getParameter("provisionerConfigErrorEntity");
GrouperProvisioner grouperProvisioner = GrouperProvisioner.retrieveProvisioner(provisionerConfigId);
ProvisioningConfiguration provisionerConfiguration = grouperProvisioner.getControllerForProvisioningConfiguration();
GuiProvisionerConfiguration guiProvisioningConfiguration = GuiProvisionerConfiguration.convertFromProvisioningConfiguration(provisionerConfiguration);
provisionerConfigurationContainer.setGuiProvisionerConfiguration(guiProvisioningConfiguration);
GrouperProvisioningErrorSummary provisioningErrorSummary = GrouperProvisioningService.retrieveProvisioningErrorSummary(provisionerConfigId, provisionerConfigObjectType,
StringUtils.isBlank(provisionerConfigErrorType)? null: GcGrouperSyncErrorCode.valueOf(provisionerConfigErrorType),
provisionerConfigErrorDuration, provisionerConfigErrorGroup, provisionerConfigErrorEntity);
provisionerConfigurationContainer.setGrouperProvisioningErrorSummary(provisioningErrorSummary);
List provisioningErrors = GrouperProvisioningService.retrieveProvisioningErrors(provisionerConfigId, provisionerConfigObjectType,
StringUtils.isBlank(provisionerConfigErrorType)? null: GcGrouperSyncErrorCode.valueOf(provisionerConfigErrorType),
provisionerConfigErrorDuration, provisionerConfigErrorGroup, provisionerConfigErrorEntity);
provisionerConfigurationContainer.setGrouperProvisioningErrors(provisioningErrors);
provisionerConfigurationContainer.setProvisionerConfigObjectType(provisionerConfigObjectType);
provisionerConfigurationContainer.setProvisionerConfigErrorDuration(provisionerConfigErrorDuration);
provisionerConfigurationContainer.setProvisionerConfigErrorGroup(provisionerConfigErrorGroup);
provisionerConfigurationContainer.setProvisionerConfigErrorEntity(provisionerConfigErrorEntity);
provisionerConfigurationContainer.setSelectedErrorCode(provisionerConfigErrorType);
guiResponseJs.addAction(GuiScreenAction.newInnerHtmlFromJsp("#grouperMainContentDivId",
"/WEB-INF/grouperUi2/provisionerConfigs/provisionerConfigViewErrors.jsp"));
} finally {
GrouperSession.stopQuietly(grouperSession);
}
}
/**
* user submitted view provisioner activity form. show activity for the selected object type
* @param request
* @param response
*/
public void viewProvisionerActivitySubmit(final HttpServletRequest request, final HttpServletResponse response) {
final Subject loggedInSubject = GrouperUiFilter.retrieveSubjectLoggedIn();
GrouperSession grouperSession = null;
final GuiResponseJs guiResponseJs = GuiResponseJs.retrieveGuiResponseJs();
try {
grouperSession = GrouperSession.start(loggedInSubject);
ProvisionerConfigurationContainer provisionerConfigurationContainer = GrouperRequestContainer.retrieveFromRequestOrCreate().getProvisionerConfigurationContainer();
String provisionerConfigId = request.getParameter("provisionerConfigId");
String provisionerConfigObjectType = request.getParameter("provisionerConfigObjectType");
if (StringUtils.isBlank(provisionerConfigId)) {
throw new RuntimeException("provisionerConfigId cannot be blank");
}
if (!provisionerConfigurationContainer.isCanViewProvisionerConfiguration(provisionerConfigId)) {
throw new RuntimeException("Not allowed!!!!!");
}
GrouperProvisioner grouperProvisioner = GrouperProvisioner.retrieveProvisioner(provisionerConfigId);
ProvisioningConfiguration provisionerConfiguration = grouperProvisioner.getControllerForProvisioningConfiguration();
GuiProvisionerConfiguration guiProvisioningConfiguration = GuiProvisionerConfiguration.convertFromProvisioningConfiguration(provisionerConfiguration);
provisionerConfigurationContainer.setGuiProvisionerConfiguration(guiProvisioningConfiguration);
if (StringUtils.isBlank(provisionerConfigObjectType)) {
List activityForGroup = GrouperProvisioningService.retrieveRecentActivityForGroup(provisionerConfigId);
provisionerConfigurationContainer.setActivityForGroup(activityForGroup);
List activityForMember = GrouperProvisioningService.retrieveRecentActivityForMember(provisionerConfigId);
provisionerConfigurationContainer.setActivityForMember(activityForMember);
List activityForMembership = GrouperProvisioningService.retrieveRecentActivityForMembership(provisionerConfigId);
provisionerConfigurationContainer.setActivityForMembership(activityForMembership);
List provisionerActivity = GuiProvisionerActivity.convertFromGcGrouperSyncObjects(activityForGroup, activityForMember, activityForMembership);
provisionerConfigurationContainer.setProvisionerActivity(provisionerActivity);
} else if (provisionerConfigObjectType.equals("group")) {
List activityForGroup = GrouperProvisioningService.retrieveRecentActivityForGroup(provisionerConfigId);
provisionerConfigurationContainer.setActivityForGroup(activityForGroup);
List provisionerActivity = GuiProvisionerActivity.convertFromGcGrouperSyncObjects(activityForGroup, null, null);
provisionerConfigurationContainer.setProvisionerActivity(provisionerActivity);
} else if (provisionerConfigObjectType.equals("entity")) {
List activityForMember = GrouperProvisioningService.retrieveRecentActivityForMember(provisionerConfigId);
provisionerConfigurationContainer.setActivityForMember(activityForMember);
List provisionerActivity = GuiProvisionerActivity.convertFromGcGrouperSyncObjects(null, activityForMember, null);
provisionerConfigurationContainer.setProvisionerActivity(provisionerActivity);
} else if (provisionerConfigObjectType.equals("membership")) {
List activityForMembership = GrouperProvisioningService.retrieveRecentActivityForMembership(provisionerConfigId);
provisionerConfigurationContainer.setActivityForMembership(activityForMembership);
List provisionerActivity = GuiProvisionerActivity.convertFromGcGrouperSyncObjects(null, null, activityForMembership);
provisionerConfigurationContainer.setProvisionerActivity(provisionerActivity);
} else {
throw new RuntimeException("invalid provisionerConfigObjectType: "+provisionerConfigObjectType);
}
provisionerConfigurationContainer.setProvisionerConfigObjectType(provisionerConfigObjectType);
guiResponseJs.addAction(GuiScreenAction.newInnerHtmlFromJsp("#grouperMainContentDivId",
"/WEB-INF/grouperUi2/provisionerConfigs/provisionerConfigViewActivity.jsp"));
} finally {
GrouperSession.stopQuietly(grouperSession);
}
}
/**
* view provisioner logs
* @param request
* @param response
*/
public void viewProvisionerLogs(final HttpServletRequest request, final HttpServletResponse response) {
final Subject loggedInSubject = GrouperUiFilter.retrieveSubjectLoggedIn();
GrouperSession grouperSession = null;
final GuiResponseJs guiResponseJs = GuiResponseJs.retrieveGuiResponseJs();
try {
grouperSession = GrouperSession.start(loggedInSubject);
ProvisionerConfigurationContainer provisionerConfigurationContainer = GrouperRequestContainer.retrieveFromRequestOrCreate().getProvisionerConfigurationContainer();
String provisionerConfigId = request.getParameter("provisionerConfigId");
if (StringUtils.isBlank(provisionerConfigId)) {
throw new RuntimeException("provisionerConfigId cannot be blank");
}
if (!provisionerConfigurationContainer.isCanViewProvisionerConfiguration(provisionerConfigId)) {
throw new RuntimeException("Not allowed!!!!!");
}
GrouperProvisioner grouperProvisioner = GrouperProvisioner.retrieveProvisioner(provisionerConfigId);
ProvisioningConfiguration provisionerConfiguration = grouperProvisioner.getControllerForProvisioningConfiguration();
GuiProvisionerConfiguration guiProvisioningConfiguration = GuiProvisionerConfiguration.convertFromProvisioningConfiguration(provisionerConfiguration);
provisionerConfigurationContainer.setGuiProvisionerConfiguration(guiProvisioningConfiguration);
GuiPaging guiPaging = provisionerConfigurationContainer.getGuiPaging();
QueryOptions queryOptions = new QueryOptions();
GrouperPagingTag2.processRequest(request, guiPaging, queryOptions, "uiV2.provisioning.logs.default.page.size");
List grouperSyncLogsWithOwner = GrouperProvisioningService.retrieveGcGrouperSyncLogs(provisionerConfigId, queryOptions);
List guiProvisionerLogs = GuiProvisionerLog.convertFromGcGrouperSyncWithOwner(grouperSyncLogsWithOwner);
provisionerConfigurationContainer.setGuiProvisionerLogs(guiProvisionerLogs);
guiPaging.setTotalRecordCount(queryOptions.getQueryPaging().getTotalRecordCount());
guiResponseJs.addAction(GuiScreenAction.newInnerHtmlFromJsp("#grouperMainContentDivId",
"/WEB-INF/grouperUi2/provisionerConfigs/provisionerConfigLogs.jsp"));
} finally {
GrouperSession.stopQuietly(grouperSession);
}
}
/**
* view provisionable groups
* @param request
* @param response
*/
public void groupsProvisionable(final HttpServletRequest request, final HttpServletResponse response) {
final Subject loggedInSubject = GrouperUiFilter.retrieveSubjectLoggedIn();
GrouperSession grouperSession = null;
final GuiResponseJs guiResponseJs = GuiResponseJs.retrieveGuiResponseJs();
try {
grouperSession = GrouperSession.start(loggedInSubject);
ProvisionerConfigurationContainer provisionerConfigurationContainer = GrouperRequestContainer.retrieveFromRequestOrCreate().getProvisionerConfigurationContainer();
String provisionerConfigId = request.getParameter("provisionerConfigId");
if (StringUtils.isBlank(provisionerConfigId)) {
throw new RuntimeException("provisionerConfigId cannot be blank");
}
if (!provisionerConfigurationContainer.isCanViewProvisionerConfiguration(provisionerConfigId)) {
throw new RuntimeException("Not allowed!!!!!");
}
MultiKey totalCountAndListOfGroups = GrouperProvisioningService.retrieveGroupsProvisionable(provisionerConfigId, 1000);
int totalGroups = (Integer)totalCountAndListOfGroups.getKey(0);
List grouperSyncGroups = (List)totalCountAndListOfGroups.getKey(1);
List guiGroups = new ArrayList<>();
GroupFinder groupFinder = new GroupFinder();
Map groupIdToGroup = new HashMap<>();
for (GcGrouperSyncGroup gcGrouperSyncGroup: grouperSyncGroups) {
String groupId = gcGrouperSyncGroup.getGroupId();
if (StringUtils.isNotBlank(groupId)) {
groupFinder.addGroupId(groupId);
}
}
Set groups = groupFinder.findGroups();
for (Group group: GrouperUtil.nonNull(groups)) {
groupIdToGroup.put(group.getId(), group);
}
for (GcGrouperSyncGroup gcGrouperSyncGroup: grouperSyncGroups) {
String groupId = gcGrouperSyncGroup.getGroupId();
if (StringUtils.isNotBlank(groupId)) {
Group group = groupIdToGroup.get(groupId);
GuiGroup guiGroup = new GuiGroup(group);
guiGroups.add(guiGroup);
}
}
GrouperProvisioner grouperProvisioner = GrouperProvisioner.retrieveProvisioner(provisionerConfigId);
ProvisioningConfiguration provisionerConfiguration = grouperProvisioner.getControllerForProvisioningConfiguration();
GuiProvisionerConfiguration guiProvisioningConfiguration = GuiProvisionerConfiguration.convertFromProvisioningConfiguration(provisionerConfiguration);
provisionerConfigurationContainer.setGuiProvisionerConfiguration(guiProvisioningConfiguration);
provisionerConfigurationContainer.setGuiGroupsProvisionable(guiGroups);
provisionerConfigurationContainer.setTotalProvisionableGroups(totalGroups);
guiResponseJs.addAction(GuiScreenAction.newInnerHtmlFromJsp("#grouperMainContentDivId",
"/WEB-INF/grouperUi2/provisionerConfigs/groupsProvisionable.jsp"));
} finally {
GrouperSession.stopQuietly(grouperSession);
}
}
/**
* view provisionable groups
* @param request
* @param response
*/
public void viewAssignments(final HttpServletRequest request, final HttpServletResponse response) {
final Subject loggedInSubject = GrouperUiFilter.retrieveSubjectLoggedIn();
GrouperSession grouperSession = null;
final GuiResponseJs guiResponseJs = GuiResponseJs.retrieveGuiResponseJs();
try {
grouperSession = GrouperSession.start(loggedInSubject);
ProvisionerConfigurationContainer provisionerConfigurationContainer = GrouperRequestContainer.retrieveFromRequestOrCreate().getProvisionerConfigurationContainer();
String provisionerConfigId = request.getParameter("provisionerConfigId");
if (StringUtils.isBlank(provisionerConfigId)) {
throw new RuntimeException("provisionerConfigId cannot be blank");
}
if (!provisionerConfigurationContainer.isCanViewProvisionerConfiguration(provisionerConfigId)) {
throw new RuntimeException("Not allowed!!!!!");
}
List