Search in sources :

Example 11 with Property

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);
                }
            }
        }
    }
}
Also used : JsonElement(com.google.gson.JsonElement) Property(com.willshex.blogwt.shared.api.datatype.Property)

Example 12 with Property

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;
    }
}
Also used : Widget(com.google.gwt.user.client.ui.Widget) Property(com.willshex.blogwt.shared.api.datatype.Property)

Example 13 with Property

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");
}
Also used : Field(com.willshex.blogwt.shared.api.datatype.Field) ServiceException(com.willshex.gson.web.service.server.ServiceException) Property(com.willshex.blogwt.shared.api.datatype.Property)

Example 14 with Property

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;
}
Also used : Manifest(java.util.jar.Manifest) Property(com.willshex.blogwt.shared.api.datatype.Property) ServletException(javax.servlet.ServletException) ArchiveEntry(com.willshex.blogwt.shared.api.datatype.ArchiveEntry) Page(com.willshex.blogwt.shared.api.datatype.Page) Session(com.willshex.blogwt.shared.api.datatype.Session) JsonableHelper.jsonForJsVar(com.willshex.blogwt.shared.helper.JsonableHelper.jsonForJsVar) PageServiceProvider(com.willshex.blogwt.server.service.page.PageServiceProvider) HTTPMethod(com.google.appengine.api.urlfetch.HTTPMethod) HashMap(java.util.HashMap) PropertyServiceProvider(com.willshex.blogwt.server.service.property.PropertyServiceProvider) Tag(com.willshex.blogwt.shared.api.datatype.Tag) Level(java.util.logging.Level) HttpServletRequest(javax.servlet.http.HttpServletRequest) Post(com.willshex.blogwt.shared.api.datatype.Post) InlineHelper(com.willshex.blogwt.server.helper.InlineHelper) Map(java.util.Map) HttpHelper(com.willshex.blogwt.server.helper.HttpHelper) TagServiceProvider(com.willshex.blogwt.server.service.tag.TagServiceProvider) ArchiveEntryServiceProvider(com.willshex.blogwt.server.service.archiveentry.ArchiveEntryServiceProvider) PersistenceHelper(com.willshex.blogwt.server.helper.PersistenceHelper) HttpServletResponse(javax.servlet.http.HttpServletResponse) IOException(java.io.IOException) Logger(java.util.logging.Logger) InputStreamReader(java.io.InputStreamReader) Attributes(java.util.jar.Attributes) Collectors(java.util.stream.Collectors) PropertyHelper(com.willshex.blogwt.shared.helper.PropertyHelper) WebServlet(javax.servlet.annotation.WebServlet) IPropertyService(com.willshex.blogwt.server.service.property.IPropertyService) ContextAwareServlet(com.willshex.server.ContextAwareServlet) List(java.util.List) PageSortType(com.willshex.blogwt.shared.api.datatype.PageSortType) BufferedReader(java.io.BufferedReader) ServletHelper(com.willshex.blogwt.server.helper.ServletHelper) Attributes(java.util.jar.Attributes) IOException(java.io.IOException) Manifest(java.util.jar.Manifest) Property(com.willshex.blogwt.shared.api.datatype.Property)

Example 15 with Property

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;
}
Also used : ArrayList(java.util.ArrayList) InputValidationException(com.willshex.gson.web.service.server.InputValidationException) Property(com.willshex.blogwt.shared.api.datatype.Property) HashSet(java.util.HashSet)

Aggregations

Property (com.willshex.blogwt.shared.api.datatype.Property)19 JsonElement (com.google.gson.JsonElement)4 InputValidationException (com.willshex.gson.web.service.server.InputValidationException)4 IPropertyService (com.willshex.blogwt.server.service.property.IPropertyService)2 HTTPMethod (com.google.appengine.api.urlfetch.HTTPMethod)1 JsonArray (com.google.gson.JsonArray)1 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)1 Widget (com.google.gwt.user.client.ui.Widget)1 SyndFeed (com.rometools.rome.feed.synd.SyndFeed)1 FeedException (com.rometools.rome.io.FeedException)1 SyndFeedOutput (com.rometools.rome.io.SyndFeedOutput)1 GetPropertiesFailure (com.willshex.blogwt.client.api.blog.event.GetPropertiesEventHandler.GetPropertiesFailure)1 GetPropertiesSuccess (com.willshex.blogwt.client.api.blog.event.GetPropertiesEventHandler.GetPropertiesSuccess)1 UpdatePropertiesFailure (com.willshex.blogwt.client.api.blog.event.UpdatePropertiesEventHandler.UpdatePropertiesFailure)1 UpdatePropertiesSuccess (com.willshex.blogwt.client.api.blog.event.UpdatePropertiesEventHandler.UpdatePropertiesSuccess)1 HttpHelper (com.willshex.blogwt.server.helper.HttpHelper)1 InlineHelper (com.willshex.blogwt.server.helper.InlineHelper)1 PersistenceHelper (com.willshex.blogwt.server.helper.PersistenceHelper)1 ServletHelper (com.willshex.blogwt.server.helper.ServletHelper)1 ArchiveEntryServiceProvider (com.willshex.blogwt.server.service.archiveentry.ArchiveEntryServiceProvider)1