use of com.willshex.blogwt.shared.api.datatype.Property in project blogwt by billy1380.
the class UpdatePropertiesRequest method fromJson.
@Override
public void fromJson(JsonObject jsonObject) {
super.fromJson(jsonObject);
if (jsonObject.has("properties")) {
JsonElement jsonProperties = jsonObject.get("properties");
if (jsonProperties != null) {
properties = new ArrayList<Property>();
Property item = null;
for (int i = 0; i < jsonProperties.getAsJsonArray().size(); i++) {
if (jsonProperties.getAsJsonArray().get(i) != null) {
(item = new Property()).fromJson(jsonProperties.getAsJsonArray().get(i).getAsJsonObject());
properties.add(item);
}
}
}
}
}
use of com.willshex.blogwt.shared.api.datatype.Property in project blogwt by billy1380.
the class PropertiesPage method addProperties.
/**
*/
private void addProperties() {
boolean first = true;
Widget w;
List<Property> values;
propertyLookup = PropertyHelper.toLookup(values = PropertyHelper.properties());
for (Property property : values) {
pnlProperties.add(w = widget(property, first));
if (propertyWidgets == null) {
propertyWidgets = new ArrayList<Widget>();
}
propertyWidgets.add(w);
first = false;
}
}
use of com.willshex.blogwt.shared.api.datatype.Property in project blogwt by billy1380.
the class SubmitFormActionHandler method handle.
/* (non-Javadoc)
*
* @see
* com.willshex.gson.web.service.server.ActionHandler#handle(com.willshex.
* gson.web.service.shared.Request,
* com.willshex.gson.web.service.shared.Response) */
@Override
protected void handle(SubmitFormRequest input, SubmitFormResponse output) throws Exception {
// send an email with the submitted fields
ApiValidator.request(input, SubmitFormRequest.class);
ApiValidator.accessCode(input.accessCode, "input.accessCode");
if (input.session != null) {
output.session = input.session = SessionValidator.lookupCheckAndExtend(input.session, "input.session");
}
input.form = FormValidator.validate(input.form, "input.form");
Property email = PropertyServiceProvider.provide().getNamedProperty(PropertyHelper.INCOMING_EMAIL);
Property title = PropertyServiceProvider.provide().getNamedProperty(PropertyHelper.TITLE);
StringBuffer body = new StringBuffer();
for (Field field : input.form.fields) {
if (field.type != FieldTypeType.FieldTypeTypeCaptcha) {
body.append(field.name);
body.append(":");
body.append(field.value);
body.append("\n\n");
}
}
if (!EmailHelper.sendEmail(email.value, title.value, "[" + input.form.name + "] Form Submitted", body.toString(), false))
ApiValidator.throwServiceError(ServiceException.class, ApiError.FailedToSendEmail, "input.form");
}
use of com.willshex.blogwt.shared.api.datatype.Property in project blogwt by billy1380.
the class MainServlet method appendProperties.
/**
* @param scriptVariables
* @return
*/
private List<Property> appendProperties(StringBuffer scriptVariables) {
List<Property> properties = PropertyServiceProvider.provide().getProperties(0, 10000, null, null);
String build = null;
try {
Manifest m = new Manifest(getServletContext().getResourceAsStream("/META-INF/MANIFEST.MF"));
Attributes a = m.getMainAttributes();
build = a.getValue("Implementation-Build");
} catch (IOException | NullPointerException e) {
if (LOG.isLoggable(Level.FINE)) {
LOG.log(Level.FINE, "Could not retrieve version number", e);
}
}
final String version = build == null ? "none" : build;
properties.add(new Property().name(PropertyHelper.VERSION).type("string").value(version));
if (properties.size() >= 0) {
scriptVariables.append("var properties='[").append(String.join(",", properties.stream().filter(p -> !PropertyHelper.isSecretProperty(p)).map(p -> jsonForJsVar(slim(p))).collect(Collectors.toList()))).append("]';");
}
return properties;
}
use of com.willshex.blogwt.shared.api.datatype.Property in project blogwt by billy1380.
the class PropertyValidator method setup.
public static List<Property> setup(Collection<Property> properties, String name) throws ServiceException {
if (properties == null)
ApiValidator.throwServiceError(InputValidationException.class, ApiError.InvalidValueNull, TYPE + "[]: " + name);
HashSet<String> notFound = new HashSet<String>();
notFound.add(PropertyHelper.TITLE);
notFound.add(PropertyHelper.EXTENDED_TITLE);
notFound.add(PropertyHelper.COPYRIGHT_HOLDER);
notFound.add(PropertyHelper.COPYRIGHT_URL);
List<Property> setupProperties = new ArrayList<Property>();
for (Property property : properties) {
switch(property.name) {
case PropertyHelper.TITLE:
case PropertyHelper.EXTENDED_TITLE:
case PropertyHelper.COPYRIGHT_HOLDER:
case PropertyHelper.COPYRIGHT_URL:
notFound.remove(property.name);
setupProperties.add(property);
break;
}
}
if (notFound.size() != 0)
ApiValidator.throwServiceError(InputValidationException.class, ApiError.MissingProperties, name + "(" + StringUtils.join(notFound) + ")");
validateAll(setupProperties, name);
return setupProperties;
}
Aggregations