
com.liferay.portal.scheduler.JobStateSerializeUtil Maven / Gradle / Ivy
/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portal.scheduler;
import com.liferay.portal.kernel.scheduler.JobState;
import com.liferay.portal.kernel.scheduler.TriggerState;
import com.liferay.portal.kernel.util.ObjectValuePair;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* @author Tina Tian
*/
public class JobStateSerializeUtil {
public static JobState deserialize(Map jobStateMap) {
Object object = jobStateMap.get(_VERSION_FIELD);
if (!(object instanceof Integer)) {
throw new IllegalStateException(
"Unable to find JobState version number");
}
int version = (Integer)object;
if (version == 1) {
return _deserialize_1(jobStateMap);
}
else {
throw new IllegalStateException(
"Unable to deserialize field for job state with version " +
version);
}
}
public static Map serialize(JobState jobState) {
switch (JobState.VERSION) {
case 1:
return _serialize_1(jobState);
default:
throw new IllegalStateException(
"Unable to serialize field for job state with version " +
JobState.VERSION);
}
}
private static JobState _deserialize_1(Map jobStateMap) {
TriggerState triggerState = null;
String triggerStateString = (String)jobStateMap.get(
_TRIGGER_STATE_FIELD);
try {
triggerState = TriggerState.valueOf(triggerStateString);
}
catch (IllegalArgumentException iae) {
throw new IllegalStateException(
"Invalid value " + triggerStateString, iae);
}
int exceptionsMaxSize = (Integer)jobStateMap.get(
_EXCEPTIONS_MAX_SIZE_FIELD);
Map triggerDates = (Map)jobStateMap.get(
_TRIGGER_DATES_FIELD);
JobState jobState = null;
if (triggerDates != null) {
jobState = new JobState(
triggerState, exceptionsMaxSize, triggerDates);
}
else {
jobState = new JobState(triggerState, exceptionsMaxSize);
}
ArrayList
© 2015 - 2025 Weber Informatics LLC | Privacy Policy