String maxPhotoSizeMb = getParam("maxPhotoSizeMb");
String photoSubmissionEnabled = getParam("photoSubmissionEnabled");
String recaptchaPrivateKey = getParam("recaptchaPrivateKey");
String recaptchaPublicKey = getParam("recaptchaPublicKey");
AdminConfig adminConfig = adminConfigDao.getAdminConfig();
// Use the name of the App Engine isntance for the client id.
adminConfig.setClientId(Util.CLIENT_ID_PREFIX + SystemProperty.applicationId.get());
if (developerKey != null) {
adminConfig.setDeveloperKey(developerKey);
}
if (defaultTag != null) {
adminConfig.setDefaultTag(defaultTag);
}
if (linkBackText != null) {
adminConfig.setLinkBackText(linkBackText);
}
if (!util.isNullOrEmpty(moderationMode)) {
adminConfig.setModerationMode(Integer.parseInt(moderationMode));
}
if (!util.isNullOrEmpty(brandingMode)) {
adminConfig.setBrandingMode(Integer.parseInt(brandingMode));
}
if (!util.isNullOrEmpty(submissionMode)) {
adminConfig.setSubmissionMode(Integer.parseInt(submissionMode));
}
if (newSubmissionAddress != null) {
adminConfig.setNewSubmissionAddress(newSubmissionAddress);
}
if (loginInstruction != null) {
adminConfig.setLoginInstruction(loginInstruction);
}
if (postSubmitMessage != null) {
adminConfig.setPostSubmitMessage(postSubmitMessage);
}
if (moderationEmail != null) {
adminConfig.setModerationEmail(moderationEmail.equalsIgnoreCase("true"));
}
if (fromAddress != null) {
adminConfig.setFromAddress(fromAddress);
}
if (approvalEmailText != null) {
adminConfig.setApprovalEmailText(approvalEmailText);
}
if (rejectionEmailText != null) {
adminConfig.setRejectionEmailText(rejectionEmailText);
}
if (privateKeyBytes != null) {
privateKeyBytes = privateKeyBytes.replace("-----BEGIN PRIVATE KEY-----", "");
privateKeyBytes = privateKeyBytes.replace("-----END PRIVATE KEY-----", "");
privateKeyBytes = privateKeyBytes.replace("\n", "");
try {
adminConfig.setPrivateKeyBytes(Base64.decode(privateKeyBytes));
} catch (Base64DecoderException e) {
LOG.log(Level.WARNING, "", e);
adminConfig.setPrivateKeyBytes(new byte[0]);
}
}
if (maxPhotoSizeMb != null) {
adminConfig.setMaxPhotoSizeMb(Integer.parseInt(maxPhotoSizeMb));
}
if (photoSubmissionEnabled != null) {
adminConfig.setPhotoSubmissionEnabled(photoSubmissionEnabled.equalsIgnoreCase("true"));
}
if (recaptchaPrivateKey != null) {
adminConfig.setRecaptchaPrivateKey(recaptchaPrivateKey);
}
if (recaptchaPublicKey != null) {
adminConfig.setRecaptchaPublicKey(recaptchaPublicKey);
}
adminConfig.setUpdated(new Date());
adminConfig = adminConfigDao.save(adminConfig);
return json;
}