edu.internet2.middleware.grouperBox.GrouperBoxLoader Maven / Gradle / Ivy
package edu.internet2.middleware.grouperBox;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
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 org.apache.commons.lang3.StringUtils;
import org.quartz.DisallowConcurrentExecution;
import com.box.sdk.BoxUser;
import edu.internet2.middleware.grouper.GrouperSession;
import edu.internet2.middleware.grouper.app.loader.GrouperLoader;
import edu.internet2.middleware.grouper.app.loader.GrouperLoaderConfig;
import edu.internet2.middleware.grouper.app.loader.OtherJobBase;
import edu.internet2.middleware.grouper.app.loader.OtherJobLogUpdater;
import edu.internet2.middleware.grouper.app.loader.db.Hib3GrouperLoaderLog;
import edu.internet2.middleware.grouper.misc.GrouperStartup;
import edu.internet2.middleware.grouper.util.GrouperUtil;
import edu.internet2.middleware.grouperClient.jdbc.GcDbAccess;
@DisallowConcurrentExecution
public class GrouperBoxLoader extends OtherJobBase {
public static Timestamp convertDateToTimestampRoundToSecond(Date date) {
Timestamp createdAtTimestamp = null;
if (date != null) {
long millis = date.getTime();
// round to nearset second
millis = 1000L * ((millis + 500)/1000L);
createdAtTimestamp = new Timestamp(millis);
}
return createdAtTimestamp;
}
public static void main(String args[]) {
GrouperStartup.startup();
GrouperSession grouperSession = GrouperSession.startRootSession();
GrouperLoader.runOnceByJobName(grouperSession, "OTHER_JOB_boxLoader");
}
/**
*
*/
private Map debugMap = new LinkedHashMap();
private Map eppnToSubjectId = null;
public void retrieveEppns() {
this.debugMap.put("state", "retrieveEppns");
String eppnQuery = "select ps.penn_id, ps.eppn from person_source ps where eppn is not null";
GrouperUtil.assertion(!StringUtils.isBlank(this.jobName), "jobName cant be blank");
GrouperLoaderConfig.retrieveConfig().propertyValueString("otherJob." + this.jobName + ".subjectIdToEppnQuery", eppnQuery);
List