http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/pst/src/main/java/org/waveprotocol/pst/style/PstStyler.java ---------------------------------------------------------------------- diff --git a/pst/src/main/java/org/waveprotocol/pst/style/PstStyler.java b/pst/src/main/java/org/waveprotocol/pst/style/PstStyler.java new file mode 100644 index 0000000..9522120 --- /dev/null +++ b/pst/src/main/java/org/waveprotocol/pst/style/PstStyler.java @@ -0,0 +1,513 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.waveprotocol.pst.style; + +import com.google.common.base.Joiner; +import com.google.common.base.Preconditions; +import com.google.common.base.Strings; +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; +import com.google.common.io.CharStreams; +import com.google.common.io.Files; + +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.nio.charset.Charset; +import java.util.ArrayDeque; +import java.util.Iterator; +import java.util.List; + +/** + * A code styler using a Builder approach to configure styles using smaller + * reformatting components. + * + * TODO(kalman): take string literals into account. + * + * @author [email protected] (Benjamin Kalman) + */ +public final class PstStyler implements Styler { + + private static final String BACKUP_SUFFIX = ".prePstStyler"; + private static final String INDENT = " "; + private static final String[] ATOMIC_TOKENS = new String[] { + "} else {", + "} else if (", + "for (", + "/*-{", + "}-*/", + }; + + /** + * Builder for a series of composed style components. + */ + private static class StyleBuilder { + + /** + * Styles a single line, outputting generated lines to a generator. + * The styler may output anywhere between 0 and infinite lines. + */ + private interface LineStyler { + void next(String line, LineGenerator generator); + } + + /** + * Generates lines to some output sink. + */ + private interface LineGenerator { + void yield(CharSequence s); + } + + /** + * A pipeline of line stylers as a single line generator. + */ + private static final class LinePipeline implements LineGenerator { + private final LineStyler lineStyler; + private final LineGenerator next; + + private LinePipeline(LineStyler lineStyler, LineGenerator next) { + this.lineStyler = lineStyler; + this.next = next; + } + + /** + * Constructs a pipeline of line stylers. + * + * @param ls the line stylers to place in the pipeline + * @param sink the line generator at the end of the pipeline + * @return the head of the pipeline + */ + public static LinePipeline construct(Iterable<LineStyler> ls, LineGenerator sink) { + return new LinePipeline(head(ls), + (Iterables.size(ls) == 1) ? sink : construct(tail(ls), sink)); + } + + private static LineStyler head(Iterable<LineStyler> ls) { + return ls.iterator().next(); + } + + private static Iterable<LineStyler> tail(final Iterable<LineStyler> ls) { + return new Iterable<LineStyler>() { + @Override public Iterator<LineStyler> iterator() { + Iterator<LineStyler> tail = ls.iterator(); + tail.next(); + return tail; + } + }; + } + + @Override + public void yield(CharSequence s) { + lineStyler.next(s.toString(), next); + } + } + + /** + * Generates lines into a list. + */ + private static final class ListGenerator implements LineGenerator { + private final List<String> list = Lists.newArrayList(); + + @Override + public void yield(CharSequence s) { + list.add(s.toString()); + } + + public List<String> getList() { + return list; + } + } + + /** + * Maintains some helpful state across a styling. + */ + private abstract class StatefulLineStyler implements LineStyler { + private boolean inShortComment = false; + private boolean inLongComment = false; + private boolean inStartOfComment = false; + private boolean previousWasComment = false; + private int lineNumber = 0; + + protected boolean inComment() { + return inShortComment || inLongComment; + } + + protected boolean inStartOfComment() { + return inStartOfComment; + } + + protected boolean inLongComment() { + return inLongComment; + } + + protected int getLineNumber() { + return lineNumber; + } + + protected boolean previousWasComment() { + return previousWasComment; + } + + @Override + public final void next(String line, LineGenerator generator) { + lineNumber++; + // TODO(kalman): JSNI? + if (line.matches("^[ \t]*/\\*.*")) { + inLongComment = true; + inStartOfComment = true; + } + if (line.matches("^[ \t]*//.*")) { + inShortComment = true; + inStartOfComment = true; + } + doNext(line, generator); + previousWasComment = inShortComment || inLongComment; + if (line.contains("*/")) { + inLongComment = false; + } + inShortComment = false; + inStartOfComment = false; + } + + abstract void doNext(String line, LineGenerator generator); + } + + private final List<LineStyler> lineStylers = Lists.newArrayList(); + + /** + * Applies the state of the styler to a list of lines. + * + * @return the styled lines + */ + public List<String> apply(List<String> lines) { + ListGenerator result = new ListGenerator(); + LinePipeline pipeline = LinePipeline.construct(lineStylers, result); + for (String line : lines) { + pipeline.yield(line); + } + return result.getList(); + } + + public StyleBuilder addNewLineBefore(final char newLineBefore) { + lineStylers.add(new StatefulLineStyler() { + @Override public void doNext(String line, LineGenerator generator) { + // TODO(kalman): this is heavy-handed; be fine-grained and just don't + // split over tokens (need regexp, presumably). + if (inComment() || containsAtomicToken(line)) { + generator.yield(line); + return; + } + + StringBuilder s = new StringBuilder(); + for (char c : line.toCharArray()) { + if (c == newLineBefore) { + generator.yield(s); + s = new StringBuilder(); + } + s.append(c); + } + generator.yield(s); + } + }); + return this; + } + + public StyleBuilder addNewLineAfter(final char newLineAfter) { + lineStylers.add(new StatefulLineStyler() { + @Override public void doNext(String line, LineGenerator generator) { + // TODO(kalman): same as above. + if (inComment() || containsAtomicToken(line)) { + generator.yield(line); + return; + } + + StringBuilder s = new StringBuilder(); + for (char c : line.toCharArray()) { + s.append(c); + if (c == newLineAfter) { + generator.yield(s); + s = new StringBuilder(); + } + } + generator.yield(s); + } + }); + return this; + } + + public StyleBuilder trim() { + lineStylers.add(new LineStyler() { + @Override public void next(String line, LineGenerator generator) { + generator.yield(line.trim()); + } + }); + return this; + } + + public StyleBuilder removeRepeatedSpacing() { + lineStylers.add(new LineStyler() { + @Override public void next(String line, LineGenerator generator) { + generator.yield(line.replaceAll("[ \t]+", " ")); + } + }); + return this; + } + + public StyleBuilder stripBlankLines() { + lineStylers.add(new LineStyler() { + @Override public void next(String line, LineGenerator generator) { + if (!line.isEmpty()) { + generator.yield(line); + } + } + }); + return this; + } + + public StyleBuilder stripInitialBlankLine() { + lineStylers.add(new LineStyler() { + boolean firstLine = true; + @Override public void next(String line, LineGenerator generator) { + if (!firstLine || !line.isEmpty()) { + generator.yield(line); + } + firstLine = false; + } + }); + return this; + } + + public StyleBuilder stripDuplicateBlankLines() { + lineStylers.add(new LineStyler() { + boolean previousWasEmpty = false; + @Override public void next(String line, LineGenerator generator) { + if (!previousWasEmpty || !line.isEmpty()) { + generator.yield(line); + } + previousWasEmpty = line.isEmpty(); + } + }); + return this; + } + + public StyleBuilder indentBraces() { + lineStylers.add(new StatefulLineStyler() { + private int indentLevel = 0; + + @Override public void doNext(String line, LineGenerator generator) { + if (!ignore(line) && line.contains("}")) { + indentLevel--; + Preconditions.checkState(indentLevel >= 0, + "Indentation level reached < 0 on line " + getLineNumber() + " (" + line + ")"); + } + String result = ""; + if (!line.isEmpty()) { + result = Strings.repeat(INDENT, indentLevel) + line; + } + if (!ignore(line) && line.contains("{")) { + indentLevel++; + } + generator.yield(result.toString()); + } + + private boolean ignore(String line) { + // Ignore self-closing braces. + return line.contains("{") + && line.contains("}") + && line.indexOf('{') < line.lastIndexOf('}'); + } + }); + return this; + } + + public StyleBuilder indentLongComments() { + lineStylers.add(new StatefulLineStyler() { + @Override void doNext(String line, LineGenerator generator) { + if (inLongComment() && !inStartOfComment()) { + generator.yield(" " + line); + } else { + generator.yield(line); + } + } + }); + return this; + } + + public StyleBuilder doubleIndentUnfinishedLines() { + lineStylers.add(new StatefulLineStyler() { + boolean previousUnfinished = false; + + @Override public void doNext(String line, LineGenerator generator) { + generator.yield((previousUnfinished ? Strings.repeat(INDENT, 2) : "") + line); + previousUnfinished = + !inComment() && + !line.matches("^.*[;{},\\-/]$") && // Ends with an expected character. + !line.contains("@Override") && // or an annotation. + !line.isEmpty() && + !line.contains("//"); // Single-line comment. + } + }); + return this; + } + + public StyleBuilder addBlankLineBeforeMatching(final String regex) { + lineStylers.add(new StatefulLineStyler() { + @Override public void doNext(String line, LineGenerator generator) { + if ((!inComment() || inStartOfComment()) && line.matches(regex)) { + generator.yield(""); + } + generator.yield(line); + } + }); + return this; + } + + public StyleBuilder addBlankLineBeforeClasslikeWithNoPrecedingComment() { + lineStylers.add(new StatefulLineStyler() { + @Override public void doNext(String line, LineGenerator generator) { + if (!previousWasComment() + && line.matches(".*\\b(class|interface|enum)\\b.*")) { + generator.yield(""); + } + generator.yield(line); + } + }); + return this; + } + + public StyleBuilder addBlankLineAfterBraceUnlessInMethod() { + lineStylers.add(new StatefulLineStyler() { + // true for every level of braces that is a class-like construct + ArrayDeque<Boolean> stack = new ArrayDeque<Boolean>(); + boolean sawClasslike = false; + + @Override public void doNext(String line, LineGenerator generator) { + if (inComment()) { + generator.yield(line); + } else if (line.endsWith("}") && !line.contains("{")) { + generator.yield(line); + stack.pop(); + if (!stack.isEmpty() && stack.peek()) { + generator.yield(""); + } + } else { + // Perhaps we could match anonymous classes by adding "new" here, + // but this is not currently needed. + if (line.matches(".*\\b(class|interface|enum)\\b.*")) { + sawClasslike = true; + } + if (line.endsWith("{")) { + if (line.contains("}")) { + stack.pop(); + } + stack.push(sawClasslike); + sawClasslike = false; + } else if (line.endsWith(";")) { + sawClasslike = false; + } + generator.yield(line); + } + } + }); + return this; + } + + public StyleBuilder addBlankLineAfterMatching(final String regex) { + lineStylers.add(new StatefulLineStyler() { + boolean previousLineMatched = false; + + @Override public void doNext(String line, LineGenerator generator) { + if (previousLineMatched) { + generator.yield(""); + } + generator.yield(line); + previousLineMatched = line.matches(regex); + } + }); + return this; + } + + private boolean containsAtomicToken(String line) { + for (String token : ATOMIC_TOKENS) { + if (line.contains(token)) { + return true; + } + } + return false; + } + } + + @Override + public void style(File f, boolean saveBackup) { + List<String> lines = null; + try { + lines = CharStreams.readLines(new FileReader(f)); + } catch (IOException e) { + System.err.println("Couldn't find file " + f.getName() + " to style: " + e.getMessage()); + return; + } + + Joiner newlineJoiner = Joiner.on('\n'); + + if (saveBackup) { + File backup = new File(f.getAbsolutePath() + BACKUP_SUFFIX); + try { + Files.write(newlineJoiner.join(lines), backup, Charset.defaultCharset()); + } catch (IOException e) { + System.err.println("Couldn't write backup " + backup.getName() + ": " + e.getMessage()); + return; + } + } + + try { + Files.write(newlineJoiner.join(styleLines(lines)), f, Charset.defaultCharset()); + } catch (IOException e) { + System.err.println("Couldn't write styled file " + f.getName() + ": " + e.getMessage()); + return; + } + } + + private List<String> styleLines(List<String> lines) { + return new StyleBuilder() + .trim() + .removeRepeatedSpacing() + .addNewLineBefore('}') + .addNewLineAfter('{') + .addNewLineAfter('}') + .addNewLineAfter(';') + .trim() + .removeRepeatedSpacing() + .stripBlankLines() + .trim() + .indentBraces() + .indentLongComments() + .addBlankLineBeforeMatching("[ \t]*@Override.*") + .addBlankLineBeforeMatching(".*/\\*\\*.*") + .addBlankLineAfterMatching("package.*") + .addBlankLineBeforeMatching("package.*") + .addBlankLineBeforeClasslikeWithNoPrecedingComment() + .addBlankLineAfterBraceUnlessInMethod() + .stripDuplicateBlankLines() + .doubleIndentUnfinishedLines() + .stripInitialBlankLine() + // TODO: blank line before first method or constructor if that has no javadoc + .apply(lines); + } +}
http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/pst/src/main/java/org/waveprotocol/pst/style/Styler.java ---------------------------------------------------------------------- diff --git a/pst/src/main/java/org/waveprotocol/pst/style/Styler.java b/pst/src/main/java/org/waveprotocol/pst/style/Styler.java new file mode 100644 index 0000000..910bc28 --- /dev/null +++ b/pst/src/main/java/org/waveprotocol/pst/style/Styler.java @@ -0,0 +1,45 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.waveprotocol.pst.style; + +import java.io.File; + +/** + * Styles a source file. + * + * @author [email protected] (Benjamin Kalman) + */ +public interface Styler { + + /** + * Styles a source file. + * + * @param f the file to style + * @param saveBackup whether to save a backup + */ + void style(File f, boolean saveBackup); + + /** + * No-op implementation. + */ + Styler EMPTY = new Styler() { + @Override public void style(File f, boolean saveBackup) {} + }; +} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/pst/src/main/java/org/waveprotocol/pst/testing/RandomProtobufGenerator.java ---------------------------------------------------------------------- diff --git a/pst/src/main/java/org/waveprotocol/pst/testing/RandomProtobufGenerator.java b/pst/src/main/java/org/waveprotocol/pst/testing/RandomProtobufGenerator.java new file mode 100644 index 0000000..333b0e9 --- /dev/null +++ b/pst/src/main/java/org/waveprotocol/pst/testing/RandomProtobufGenerator.java @@ -0,0 +1,170 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.waveprotocol.pst.testing; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.protobuf.ByteString; +import com.google.protobuf.Descriptors.Descriptor; +import com.google.protobuf.Descriptors.EnumDescriptor; +import com.google.protobuf.Descriptors.EnumValueDescriptor; +import com.google.protobuf.Descriptors.FieldDescriptor; +import com.google.protobuf.GeneratedMessage; +import com.google.protobuf.Message.Builder; + +import java.util.List; +import java.util.Map; +import java.util.Random; + +/** + * Generates random protocol buffers with all fields given a value. + * + * @author [email protected] (Benjamin Kalman) + */ +public final class RandomProtobufGenerator<E extends GeneratedMessage> { + + private static final int MAX_LIST_LENGTH = 10; + private static final int MAX_STRING_LENGTH = 10; + + private final Random random; + private final GeneratedMessage instance; + private final Map<Descriptor, GeneratedMessage> moreInstances; + + private RandomProtobufGenerator(Random random, GeneratedMessage instance, + Map<Descriptor, GeneratedMessage> moreInstances) { + this.random = random; + this.instance = instance; + this.moreInstances = moreInstances; + } + + /** + * Creates a random protobuf generator, for a main type (instance) and a list + * of any extra instances that will be needed to generate that instance. + * + * @param random random number generator + * @param instance the protobuf instance used as a template to generate more + * random protobuf + * @param moreInstances protobuf templates for any inner messages the + * protobuf depends on + * @return the random protobuf generator + */ + public static <T extends GeneratedMessage> RandomProtobufGenerator<T> create(Random random, + GeneratedMessage instance, GeneratedMessage... moreInstances) { + // NOTE: it would be nice to determine this internally e.g. through (java or proto) reflection. + Map<Descriptor, GeneratedMessage> moreInstancesMap = Maps.newHashMap(); + for (GeneratedMessage gm : moreInstances) { + moreInstancesMap.put(gm.getDescriptorForType(), gm); + } + return new RandomProtobufGenerator<T>(random, instance, moreInstancesMap); + } + + /** + * Generates a random protocol buffer, filling in all fields and giving + * repeated values 0..n items. + */ + public E generate() { + return generate(0); + } + + /** + * Generates a random protocol buffer, filling in all required fields but + * with a p chance of not setting an optional field and p chance of having + * an empty repeated field. + */ + @SuppressWarnings("unchecked") + public E generate(double p) { + Builder builder = instance.newBuilderForType(); + Descriptor descriptor = instance.getDescriptorForType(); + for (FieldDescriptor field : descriptor.getFields()) { + if (!field.isRequired() && random.nextDouble() < p) { + continue; + } + builder.setField(field, getRandomValue(field, p)); + } + return (E) builder.build(); + } + + private Object getRandomValue(FieldDescriptor field, double p) { + if (field.isRepeated()) { + List<Object> values = Lists.newArrayList(); + for (int i = 0, length = random.nextInt(MAX_LIST_LENGTH); i < length; i++) { + values.add(getRandomSingleValue(field, p)); + } + return values; + } else { + return getRandomSingleValue(field, p); + } + } + + private Object getRandomSingleValue(FieldDescriptor field, double p) { + switch (field.getJavaType()) { + case BOOLEAN: + return random.nextBoolean(); + case BYTE_STRING: + return getRandomByteString(); + case DOUBLE: + return random.nextDouble(); + case ENUM: + return getRandomEnum(field.getEnumType()); + case FLOAT: + return random.nextFloat(); + case INT: + return random.nextInt(); + case LONG: + return random.nextLong(); + case MESSAGE: + return getRandomMessage(field, p); + case STRING: + return getRandomString(); + default: + return null; + } + } + + private ByteString getRandomByteString() { + byte[] bytes = new byte[32]; + random.nextBytes(bytes); + return ByteString.copyFrom(bytes); + } + + private EnumValueDescriptor getRandomEnum(EnumDescriptor enumD) { + List<EnumValueDescriptor> values = enumD.getValues(); + return values.get(random.nextInt(values.size())); + } + + private GeneratedMessage getRandomMessage(FieldDescriptor field, double p) { + GeneratedMessage instance = moreInstances.get(field.getMessageType()); + if (instance == null) { + throw new IllegalArgumentException("Couldn't find instance for message " + + field.getMessageType().getFullName()); + } + return new RandomProtobufGenerator<GeneratedMessage>(random, instance, moreInstances) + .generate(p); + } + + private String getRandomString() { + String alphabet = "abc{}[]<>\\\"'"; + StringBuilder s = new StringBuilder(); + for (int i = 0, length = random.nextInt(MAX_STRING_LENGTH); i < length; i++) { + s.append(alphabet.charAt(random.nextInt(alphabet.length()))); + } + return s.toString(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/reference.conf ---------------------------------------------------------------------- diff --git a/reference.conf b/reference.conf deleted file mode 100644 index 04753c4..0000000 --- a/reference.conf +++ /dev/null @@ -1,257 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -# Configuration for the Wave in a Box server - - -core { - # Domain name of the wave server. - wave_server_domain : "local.net" - - # A comma separated list of address on which to listen for connections. - # Each address is a comma separated host:port pair. - http_frontend_addresses : ["localhost:9898"] - - # The public address - a comma separated host:port pair, i.e. example.com:80 - http_frontend_public_address : "" - - # An optional host:port address on which to listen for websocket connections. - # Defaults to http_websocket_public_address. - # If no value is set for http_websocket_public_address it defaults to the first address specified - # by http_frontend_public_address. - http_websocket_public_address : "" - - # An optional host:port address for which the client is told to attempt websocket connections. - # If no value is set for http_websocket_presented_address it defaults to http_websocket_public_address. - http_websocket_presented_address : "" - - # The address of Apache Shindig gadgets server patched to support Wave gadgets. - # See https://cwiki.apache.org/confluence/display/WAVE/Gadgets+with+your+own+Gadget+Server - gadget_server_hostname : "gmodules.com" - - # The gadget serer port. - gadget_server_port : 80 - - # A comma separated list of webApp source directories - resource_bases : ["./war"] - - # Settings for the different persistence stores. Currently supported: memory, file, mongodb. - signer_info_store_type : file - - # The location where signer info certificate data is stored on disk. This should be changed. - # Note: This is only used when using the file signer info store. It is ignored - # for other data store types. - signer_info_store_directory : _certificates - - # Currently supported attachment types: mongodb, disk - attachment_store_type : disk - - # The location where attachments are stored on disk. This should be changed. - # Note: This is only used when using the disk attachment store. It is ignored - # for other data store types. - attachment_store_directory : _attachments - - # Directory that holds the thumbnails for attachments. - # Icon must be in PNG format, and named as MIME type with replacing '/' to '_'. - # For example thumbnail file for ZIP format (MIME type application/zip) must be named application_zip. - thumbnail_patterns_directory : _thumbnail_patterns - - # Currently supported account store types: fake, memory, file, mongodb - account_store_type : file - - # The location where accounts are stored on disk. This should be changed. - # Note: This is only used when using the file account store. It is ignored - # for other data store types. - account_store_directory : _accounts - - # Currently supported delta store types: memory, file, mongodb. - # Note: file system support is experimental. Your server may crash. And the file format is - # not stable and shouldn't be relied upon for long-term storage yet; upcoming changes will - # require you to blow away your data. - delta_store_type : file - - # The location where deltas are stored on disk. This should be changed. - # Note: This is only used when using the file delta store. It is ignored - # for other data store types. - delta_store_directory : _deltas - - # The location where user sessions are persisted on disk. This allow to restore user sessions - # between restarts. - sessions_store_directory : _sessions - - # Currently supported search types: memory, lucene, solr. - search_type : memory - - # The location where search indexes are stored on disk. - # Note: This is only used when using the lucene search type. It is ignored - # for other search types. - index_directory : _indexes - - # Currently supported profile fetcher types: gravatar, initials. - profile_fetcher_type : initials - - # The Solr endpoint url. - solr_base_url : "http://localhost:8983/solr" - - # Enables server side profiling. To display the stats press ctrl+alt+ctrl in the web client. - # Default value: true - enable_profiling : true - - # Mongodb connection options - # Only used if some of the *_store_type properties are set to 'mongodb' - - # Server's host name or IP address. - mongodb_host : "127.0.0.1" - - # Server's port. Default value: 27017 - mongodb_port : 27017 - - # Database's name. Default name: wiab - mongodb_database : wiab -} - -network { - # Max age of session cookie in seconds. - # -1 means cookie lives in the browser current session only. - session_cookie_max_age : -1 - - # The time in ms that the websocket connection can be idle before closing - websocket_max_idle_time : 0 - - # Maximum websocket message size to be received in MB - websocket_max_message_size : 2 -} - -administration { - # Note: the default value for admin is an invalid user id that cannot be registered. - # To become an admin: Register a user and set its address as the value below. - # Admin has a privilege to change passwords of other users using an agent robot. - admin_user : "@" - - # The wave id of the welcome template wave. (Without domain, for example: w+Fxjs_-ZPmmA). - # If filled in then a copy of this wave (actually only the root blip) will be - # automatically added to the inbox of every new user. - welcome_wave_id : "" - - # Set true to prevent anyone registering on your server. - # When true, only the admin user can use the RegistrationRobot to add new accounts - disable_registration : false - - # Disable login page - useful to force x509-only authentication - disable_loginpage : false - - # Google Analytics account. - analytics_account : "" -} - -threads { - # The number of threads to listen on wavelet updates. Default value: 1 - listener_executor_thread_count : 1 - - # The number of threads for loading wavelets. Default value: 1 - wavelet_load_executor_thread_count : 1 - - # The number of threads to persist deltas. Default value: 1 - delta_persist_executor_thread_count : 1 - - # The number of threads to perform post wavelet loading logic. Default value: 1 - storage_continuation_executor_thread_count : 1 - - # The number of threads for looking up the wavelet ids - # while creating a list of all wavelets in the persistent storage. Default value: 1 - lookup_executor_thread_count : 1 - - # The number of threads for making search/update requests to Solr. Default value: 1 - solr_thread_count : 1 - - # The number of threads for making for retrieving contacts. - contact_executor_thread_count : 1 -} - -security { - # Enable SSL for all address/port combinations listed (makes the next 2 settings non-optional). - enable_ssl : false - - # Path to keystore containg the ssl certificates to server - # Note: this is only used when enable_ssl set to true. - ssl_keystore_path : wiab.ks - - # Password to the keystore. - # Note: this is only used when enable_ssl set to true. - ssl_keystore_password : changeme - - # Enable client x509 cert. authentication? - enable_clientauth : false - - # Domain of the email to look for as email field of x509 client auth certificates when using client authentication - clientauth_cert_domain : "" -} - -federation { - # Federation Configuration for the Wave in a Box server - enable_federation : false - - # These will probably need to be changed - xmpp_server_secret : secret - - # The PKCS#8-PEM-encoded private key. - certificate_private_key : "local.net.key" - - # The list of file names that have the certificates of this signer. - # The first file name must have the signer's target certificate. The certificates can be DER or PEM encoded. - # The order of certificates is important. Place intermediate certs - # after "${wave_server_domain}.crt". Please refer to - # http://www.waveprotocol.org/federation/certificates - # for more details. - certificate_files : ["local.net.crt","sub.class1.server.ca.pem","ca.pem"] - - # The domain for which the certificate was issued. - certificate_domain : "local.net" - - xmpp_component_name : wave - - # This server's local JID - xmpp_jid : "wave.local.net" - - xmpp_server_description : "Wave in a Box" - - disco_info_category : "collaboration" - - disco_info_type : "apache-wave" - - xmpp_server_hostname : "local.net" - - xmpp_server_component_port : 5275 - - # How long to cache failed disco results. - xmpp_disco_failed_expiry : 300s - - # How long to cache successful disco results. - xmpp_disco_successful_expiry : 7200s - - disco_expiration : 6h - - # Set XMPP_SERVER_IP to localhost if the XMPP and Wave in a Box servers are - # running on the same host - xmpp_server_ip : localhost - - # Set true to disable the verification of signed deltas - waveserver_disable_verification : true - - # Set true to disable the verification of signers (certificates) - waveserver_disable_signer_verification : true -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/release/artifact-sign.sh ---------------------------------------------------------------------- diff --git a/release/artifact-sign.sh b/release/artifact-sign.sh deleted file mode 100755 index 004d5f0..0000000 --- a/release/artifact-sign.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/zsh - -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - - -#Assumes it is being run in the base directory. - -PRE="dist/apache-wave-" -for f in $PRE*; do -gpg --armor --output $f.asc --detach-sig $f -gpg --print-md SHA512 $f > $f.sha -done \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/run-data-migration.sh ---------------------------------------------------------------------- diff --git a/run-data-migration.sh b/run-data-migration.sh deleted file mode 100755 index b48eb22..0000000 --- a/run-data-migration.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -# This script will start the data migration between two different store types -# Initially this tool is intended to migrate deltas from file to mongodb store -# Run "ant dist-server" before to use this script - -# The version of Wave in a Box, extracted from the build.properties file -WAVEINABOX_VERSION=`sed "s/[\\t ]*=[\\t ]*/=/g" build.properties | grep ^waveinabox.version= | cut -f2 -d=` -echo wave-in-a-box-server-$WAVEINABOX_VERSION.jar - -exec java -cp dist/wave-in-a-box-server-$WAVEINABOX_VERSION.jar org.waveprotocol.box.server.DataMigrationTool $* http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/run-export.sh ---------------------------------------------------------------------- diff --git a/run-export.sh b/run-export.sh deleted file mode 100644 index 3d4b8e6..0000000 --- a/run-export.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -# This script will start the Wave Import. - -# The version of Wave in a Box, extracted from the build.properties file -WAVEINABOX_VERSION=`sed "s/[\\t ]*=[\\t ]*/=/g" build.properties | grep ^waveinabox.version= | cut -f2 -d=` - -exec java -cp dist/wave-in-a-box-export-import-$WAVEINABOX_VERSION.jar org.waveprotocol.box.expimp.WaveExport $* http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/run-import.sh ---------------------------------------------------------------------- diff --git a/run-import.sh b/run-import.sh deleted file mode 100644 index f21d040..0000000 --- a/run-import.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -# This script will start the Wave Import. - -# The version of Wave in a Box, extracted from the build.properties file -WAVEINABOX_VERSION=`sed "s/[\\t ]*=[\\t ]*/=/g" build.properties | grep ^waveinabox.version= | cut -f2 -d=` - -exec java -cp dist/wave-in-a-box-export-import-$WAVEINABOX_VERSION.jar org.waveprotocol.box.expimp.WaveImport $* http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/run-server.bat ---------------------------------------------------------------------- diff --git a/run-server.bat b/run-server.bat deleted file mode 100644 index f70f6d3..0000000 --- a/run-server.bat +++ /dev/null @@ -1,24 +0,0 @@ -echo off -rem Licensed to the Apache Software Foundation (ASF) under one or more -rem contributor license agreements. See the NOTICE file distributed with -rem this work for additional information regarding copyright ownership. -rem The ASF licenses this file to You under the Apache License, Version 2.0 -rem (the "License"); you may not use this file except in compliance with -rem the License. You may obtain a copy of the License at -rem -rem http://www.apache.org/licenses/LICENSE-2.0 -rem -rem Unless required by applicable law or agreed to in writing, software -rem distributed under the License is distributed on an "AS IS" BASIS, -rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -rem See the License for the specific language governing permissions and -rem limitations under the License. - -for /F "tokens=1* delims==" %%A IN (build.properties) DO ( - IF "%%A"=="waveinabox.version" set WAVEINABOX_VERSION=%%B - IF "%%A"=="name" set NAME=%%B - ) -echo on - -java -Djava.util.logging.config.file=wiab-logging.conf -Djava.security.auth.login.config=jaas.config -Dwave.server.config=server.config -jar dist/%NAME%-server-%WAVEINABOX_VERSION%.jar -pause http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/run-server.sh ---------------------------------------------------------------------- diff --git a/run-server.sh b/run-server.sh deleted file mode 100755 index f733bad..0000000 --- a/run-server.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -# This script will start the Wave in a Box server. - -# The version of Wave in a Box, extracted from the build.properties file -WAVEINABOX_VERSION=`sed "s/[\\t ]*=[\\t ]*/=/g" build.properties | grep ^waveinabox.version= | cut -f2 -d=` -NAME=`sed "s/[\\t ]*=[\\t ]*/=/g" build.properties | grep ^name= | cut -f2 -d=` - -. process-script-args.sh - -exec java $DEBUG_FLAGS \ - -Djava.util.logging.config.file=wiab-logging.conf \ - -Djava.security.auth.login.config=jaas.config \ - -Dwave.server.config=server.config \ - -jar dist/$NAME-server-$WAVEINABOX_VERSION.jar http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/run-solr.bat ---------------------------------------------------------------------- diff --git a/run-solr.bat b/run-solr.bat deleted file mode 100644 index 95d9a29..0000000 --- a/run-solr.bat +++ /dev/null @@ -1,26 +0,0 @@ -echo off -rem Licensed to the Apache Software Foundation (ASF) under one or more -rem contributor license agreements. See the NOTICE file distributed with -rem this work for additional information regarding copyright ownership. -rem The ASF licenses this file to You under the Apache License, Version 2.0 -rem (the "License"); you may not use this file except in compliance with -rem the License. You may obtain a copy of the License at -rem -rem http://www.apache.org/licenses/LICENSE-2.0 -rem -rem Unless required by applicable law or agreed to in writing, software -rem distributed under the License is distributed on an "AS IS" BASIS, -rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -rem See the License for the specific language governing permissions and -rem limitations under the License. - -if not exist "third_party\solr\solr-4.9.1\example" ( - echo "Please download Solr by running: ant get-third-party-solr-dep " - echo "Or download it manually from http://apache.spd.co.il/lucene/solr/4.9.1/ into third_party\solr and unzip there." - pause - exit 1 -) - -cd third_party\solr\solr-4.9.1\example -java -jar start.jar -pause http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/run-solr.sh ---------------------------------------------------------------------- diff --git a/run-solr.sh b/run-solr.sh deleted file mode 100755 index 4edc87f..0000000 --- a/run-solr.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -# This script will start the Solr server. - -# Make sure the third_party/solr/solr-4.9.1/example folder exists. -if [ ! -d third_party/solr/solr-4.9.1/example ]; then - echo "Please download Solr by running: ant get-third-party-solr-dep " - echo "Or download it manually from http://apache.spd.co.il/lucene/solr/4.9.1/ into third_party/solr and unzip there." - exit 1 -fi - -cd third_party/solr/solr-4.9.1/example -exec java -jar start.jar http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/server-config.xml ---------------------------------------------------------------------- diff --git a/server-config.xml b/server-config.xml deleted file mode 100644 index fa80815..0000000 --- a/server-config.xml +++ /dev/null @@ -1,65 +0,0 @@ -<!-- - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - --> -<project name="server config" basedir="." default="prosody-config"> - <description>Creates the server configuration file.</description> - - <property name="wave_server_domain" value="local.net" /> - <property name="xmpp_server_secret" value="opensesame" /> - <property name="certificate_private_key" value="${wave_server_domain}.key" /> - <property name="certificate_files" value="${wave_server_domain}.crt,sub.class1.server.ca.pem,ca.pem" /> - <property name="certificate_domain" value="${wave_server_domain}" /> - <property name="xmpp_component_name" value="wave" /> - <property name="xmpp_jid" value="${xmpp_component_name}.${wave_server_domain}" /> - <property name="xmpp_server_description" value=""Wave in a Box"" /> - <property name="xmpp_server_hostname" value="${wave_server_domain}" /> - <property name="xmpp_server_component_port" value="5275" /> - <property name="xmpp_server_to_server_port" value="5269" /> - <property name="xmpp_server_ping" value="wavesandbox.com" /> - <property name="xmpp_server_ip" value="${xmpp_server_hostname}" /> - <property name="waveserver_disable_verification" value="false" /> - <property name="waveserver_disable_signer_verification" value="false" /> - - - <target name="prosody-config" - description="Run to create the prosody configuration files. - ant -f server-config.xml prosody-config"> - <echo>Generating ${certificate_domain}.cfg.lua</echo> - <copy file="${certificate_domain}.cfg.lua" - tofile="${certificate_domain}.cfg.lua.old" - overwrite="true" - failonerror="false" /> - <copy file="prosody.cfg.lua.example" tofile="${certificate_domain}.cfg.lua" overwrite="true"> - <filterchain> - <replacetokens> - <token key="BASEDIR" value="${basedir}" /> - <token key="XMPP_SERVER_SECRET" value="${xmpp_server_secret}" /> - <token key="CERTIFICATE_PRIVATE_KEY" value="${certificate_private_key}" /> - <token key="CERTIFICATE_DOMAIN" value="${certificate_domain}" /> - <token key="XMPP_JID" value="${xmpp_jid}" /> - <token key="XMPP_SERVER_DESCRIPTION" value="${xmpp_server_description}" /> - <token key="XMPP_SERVER_COMPONENT_PORT" value="${xmpp_server_component_port}" /> - <token key="XMPP_SERVER_TO_SERVER_PORT" value="${xmpp_server_to_server_port}" /> - </replacetokens> - </filterchain> - </copy> - <echo>Please, manually copy ${certificate_domain}.cfg.lua to your prosody configuration directory.</echo> - <echo>E.g. sudo cp ${certificate_domain}.cfg.lua /etc/prosody/conf.d/${certificate_domain}.cfg.lua</echo> - <echo>Additionally, ensure your ${certificate_domain} SRV record points to port ${xmpp_server_to_server_port}</echo> - </target> -</project> http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/settings.gradle ---------------------------------------------------------------------- diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..cf6215d --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +include "wave", "pst", "wave-proto" \ No newline at end of file
