PackageParticipant participant = new PackageParticipant();
participant.setProcessDefId(processDefId);
participant.setParticipantId(participantId);
AppDefinition appDef = appService.getAppDefinition(appId, version);
PackageDefinition packageDef = appDef.getPackageDefinition();
if (PackageParticipant.TYPE_PLUGIN.equals(type)) {
if (pluginProperties == null) {
//request params
Map<String, String> propertyMap = new HashMap();
Enumeration<String> e = request.getParameterNames();
while (e.hasMoreElements()) {
String paramName = e.nextElement();
if (!paramName.startsWith("param_")) {
String[] paramValue = (String[]) request.getParameterValues(paramName);
propertyMap.put(paramName, CsvUtil.getDeliminatedString(paramValue));
}
}
// form csv properties
StringWriter sw = new StringWriter();
try {
CSVWriter writer = new CSVWriter(sw);
Iterator it = propertyMap.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, String> pairs = (Map.Entry) it.next();
writer.writeNext(new String[]{pairs.getKey(), pairs.getValue()});
}
writer.close();
} catch (Exception ex) {
LogUtil.error(getClass().getName(), ex, "");
}
String pluginProps = sw.toString();
participant.setPluginProperties(pluginProps);
} else {
PackageParticipant participantExisting = packageDef.getPackageParticipant(processDefId, participantId);
String oldJson = "";
if (participantExisting != null && PackageParticipant.TYPE_PLUGIN.equals(participantExisting.getType())) {
oldJson = participantExisting.getPluginProperties();
}
participant.setPluginProperties(PropertyUtil.propertiesJsonStoreProcessing(oldJson, pluginProperties));
}
} else if ((PackageParticipant.TYPE_GROUP.equals(type) || PackageParticipant.TYPE_USER.equals(type)) && packageDef != null) {
//Using Set to prevent duplicate value
Set values = new HashSet();
StringTokenizer valueToken = new StringTokenizer(value, ",");
while (valueToken.hasMoreTokens()) {
values.add((String) valueToken.nextElement());
}
PackageParticipant participantExisting = packageDef.getPackageParticipant(processDefId, participantId);
if (participantExisting != null && participantExisting.getValue() != null) {
StringTokenizer existingValueToken = (type.equals(participantExisting.getType())) ? new StringTokenizer(participantExisting.getValue().replaceAll(";", ","), ",") : null;
while (existingValueToken != null && existingValueToken.hasMoreTokens()) {
values.add((String) existingValueToken.nextElement());