repo_name
stringlengths 7
104
| file_path
stringlengths 13
198
| context
stringlengths 67
7.15k
| import_statement
stringlengths 16
4.43k
| code
stringlengths 40
6.98k
| prompt
stringlengths 227
8.27k
| next_line
stringlengths 8
795
|
---|---|---|---|---|---|---|
ozwolf-software/raml-mock-server | src/test/java/net/ozwolf/mockserver/raml/handlers/ZipArchiveHandlerTest.java | // Path: src/test/java/net/ozwolf/mockserver/raml/util/Fixtures.java
// public static File zipFixture(String path) throws ZipException {
// File source = new File(path);
// File target = new File("target/archives/zip-archive-test.zip");
// if (target.exists() && !target.delete())
// throw new RuntimeException("Unable to delete old zip file target");
//
// if (!target.getParentFile().exists() && !target.getParentFile().mkdirs())
// throw new RuntimeException("Unable to create directories for zip file target");
//
// ZipFile zipFile = new ZipFile(target);
// ZipParameters parameters = new ZipParameters();
// parameters.setIncludeRootFolder(false);
// zipFile.createZipFileFromFolder(source, parameters, false, -1);
//
// return target;
// }
| import net.lingala.zip4j.exception.ZipException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import java.io.File;
import static net.ozwolf.mockserver.raml.util.Fixtures.zipFixture;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when; | package net.ozwolf.mockserver.raml.handlers;
public class ZipArchiveHandlerTest {
@Rule
public ExpectedException exception = ExpectedException.none();
@Test
public void shouldTakeZipFileAndUnpack() throws ZipException { | // Path: src/test/java/net/ozwolf/mockserver/raml/util/Fixtures.java
// public static File zipFixture(String path) throws ZipException {
// File source = new File(path);
// File target = new File("target/archives/zip-archive-test.zip");
// if (target.exists() && !target.delete())
// throw new RuntimeException("Unable to delete old zip file target");
//
// if (!target.getParentFile().exists() && !target.getParentFile().mkdirs())
// throw new RuntimeException("Unable to create directories for zip file target");
//
// ZipFile zipFile = new ZipFile(target);
// ZipParameters parameters = new ZipParameters();
// parameters.setIncludeRootFolder(false);
// zipFile.createZipFileFromFolder(source, parameters, false, -1);
//
// return target;
// }
// Path: src/test/java/net/ozwolf/mockserver/raml/handlers/ZipArchiveHandlerTest.java
import net.lingala.zip4j.exception.ZipException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import java.io.File;
import static net.ozwolf.mockserver.raml.util.Fixtures.zipFixture;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
package net.ozwolf.mockserver.raml.handlers;
public class ZipArchiveHandlerTest {
@Rule
public ExpectedException exception = ExpectedException.none();
@Test
public void shouldTakeZipFileAndUnpack() throws ZipException { | File zip = zipFixture("src/test/resources/apispecs-test"); |
ozwolf-software/raml-mock-server | src/main/java/net/ozwolf/mockserver/raml/internal/domain/body/DefaultBodySpecification.java | // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/BodySpecification.java
// public interface BodySpecification {
// MediaType getContentType();
//
// ValidationErrors validate(String body);
// }
//
// Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/ValidationErrors.java
// public class ValidationErrors {
// private final List<String> messages;
//
// public ValidationErrors() {
// this.messages = newArrayList();
// }
//
// public void addMessage(String error, Object... formattedParameters) {
// this.messages.add(String.format(error, formattedParameters));
// }
//
// public void combineWith(ValidationErrors errors) {
// this.messages.addAll(errors.getMessages());
// }
//
// public boolean isInError() {
// return !this.messages.isEmpty();
// }
//
// public List<String> getMessages() {
// return messages;
// }
// }
| import net.ozwolf.mockserver.raml.internal.domain.BodySpecification;
import net.ozwolf.mockserver.raml.internal.domain.ValidationErrors;
import javax.ws.rs.core.MediaType; | package net.ozwolf.mockserver.raml.internal.domain.body;
public class DefaultBodySpecification implements BodySpecification {
private final MediaType mediaType;
public DefaultBodySpecification(MediaType mediaType) {
this.mediaType = mediaType;
}
@Override | // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/BodySpecification.java
// public interface BodySpecification {
// MediaType getContentType();
//
// ValidationErrors validate(String body);
// }
//
// Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/ValidationErrors.java
// public class ValidationErrors {
// private final List<String> messages;
//
// public ValidationErrors() {
// this.messages = newArrayList();
// }
//
// public void addMessage(String error, Object... formattedParameters) {
// this.messages.add(String.format(error, formattedParameters));
// }
//
// public void combineWith(ValidationErrors errors) {
// this.messages.addAll(errors.getMessages());
// }
//
// public boolean isInError() {
// return !this.messages.isEmpty();
// }
//
// public List<String> getMessages() {
// return messages;
// }
// }
// Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/body/DefaultBodySpecification.java
import net.ozwolf.mockserver.raml.internal.domain.BodySpecification;
import net.ozwolf.mockserver.raml.internal.domain.ValidationErrors;
import javax.ws.rs.core.MediaType;
package net.ozwolf.mockserver.raml.internal.domain.body;
public class DefaultBodySpecification implements BodySpecification {
private final MediaType mediaType;
public DefaultBodySpecification(MediaType mediaType) {
this.mediaType = mediaType;
}
@Override | public ValidationErrors validate(String body) { |
ozwolf-software/raml-mock-server | src/test/java/net/ozwolf/mockserver/raml/internal/domain/body/JsonBodySpecificationTest.java | // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/ValidationErrors.java
// public class ValidationErrors {
// private final List<String> messages;
//
// public ValidationErrors() {
// this.messages = newArrayList();
// }
//
// public void addMessage(String error, Object... formattedParameters) {
// this.messages.add(String.format(error, formattedParameters));
// }
//
// public void combineWith(ValidationErrors errors) {
// this.messages.addAll(errors.getMessages());
// }
//
// public boolean isInError() {
// return !this.messages.isEmpty();
// }
//
// public List<String> getMessages() {
// return messages;
// }
// }
//
// Path: src/test/java/net/ozwolf/mockserver/raml/util/Fixtures.java
// public static String fixture(String resource) throws IOException {
// return IOUtils.toString(Fixtures.class.getClassLoader().getResourceAsStream(resource))
// .replaceAll("\r\n", "\n");
// }
| import net.ozwolf.mockserver.raml.internal.domain.ValidationErrors;
import org.junit.Test;
import org.raml.model.MimeType;
import java.io.IOException;
import static net.ozwolf.mockserver.raml.util.Fixtures.fixture;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when; | package net.ozwolf.mockserver.raml.internal.domain.body;
public class JsonBodySpecificationTest {
@Test
public void shouldValidateSchemaAndEntityAsCorrect() throws IOException { | // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/ValidationErrors.java
// public class ValidationErrors {
// private final List<String> messages;
//
// public ValidationErrors() {
// this.messages = newArrayList();
// }
//
// public void addMessage(String error, Object... formattedParameters) {
// this.messages.add(String.format(error, formattedParameters));
// }
//
// public void combineWith(ValidationErrors errors) {
// this.messages.addAll(errors.getMessages());
// }
//
// public boolean isInError() {
// return !this.messages.isEmpty();
// }
//
// public List<String> getMessages() {
// return messages;
// }
// }
//
// Path: src/test/java/net/ozwolf/mockserver/raml/util/Fixtures.java
// public static String fixture(String resource) throws IOException {
// return IOUtils.toString(Fixtures.class.getClassLoader().getResourceAsStream(resource))
// .replaceAll("\r\n", "\n");
// }
// Path: src/test/java/net/ozwolf/mockserver/raml/internal/domain/body/JsonBodySpecificationTest.java
import net.ozwolf.mockserver.raml.internal.domain.ValidationErrors;
import org.junit.Test;
import org.raml.model.MimeType;
import java.io.IOException;
import static net.ozwolf.mockserver.raml.util.Fixtures.fixture;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
package net.ozwolf.mockserver.raml.internal.domain.body;
public class JsonBodySpecificationTest {
@Test
public void shouldValidateSchemaAndEntityAsCorrect() throws IOException { | String schema = fixture("apispecs-test/schemas/greeting-response.json"); |
ozwolf-software/raml-mock-server | src/test/java/net/ozwolf/mockserver/raml/internal/domain/body/JsonBodySpecificationTest.java | // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/ValidationErrors.java
// public class ValidationErrors {
// private final List<String> messages;
//
// public ValidationErrors() {
// this.messages = newArrayList();
// }
//
// public void addMessage(String error, Object... formattedParameters) {
// this.messages.add(String.format(error, formattedParameters));
// }
//
// public void combineWith(ValidationErrors errors) {
// this.messages.addAll(errors.getMessages());
// }
//
// public boolean isInError() {
// return !this.messages.isEmpty();
// }
//
// public List<String> getMessages() {
// return messages;
// }
// }
//
// Path: src/test/java/net/ozwolf/mockserver/raml/util/Fixtures.java
// public static String fixture(String resource) throws IOException {
// return IOUtils.toString(Fixtures.class.getClassLoader().getResourceAsStream(resource))
// .replaceAll("\r\n", "\n");
// }
| import net.ozwolf.mockserver.raml.internal.domain.ValidationErrors;
import org.junit.Test;
import org.raml.model.MimeType;
import java.io.IOException;
import static net.ozwolf.mockserver.raml.util.Fixtures.fixture;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when; | package net.ozwolf.mockserver.raml.internal.domain.body;
public class JsonBodySpecificationTest {
@Test
public void shouldValidateSchemaAndEntityAsCorrect() throws IOException {
String schema = fixture("apispecs-test/schemas/greeting-response.json");
String response = fixture("apispecs-test/examples/greeting-response.json");
MimeType mimeType = mock(MimeType.class);
when(mimeType.getSchema()).thenReturn(schema);
| // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/ValidationErrors.java
// public class ValidationErrors {
// private final List<String> messages;
//
// public ValidationErrors() {
// this.messages = newArrayList();
// }
//
// public void addMessage(String error, Object... formattedParameters) {
// this.messages.add(String.format(error, formattedParameters));
// }
//
// public void combineWith(ValidationErrors errors) {
// this.messages.addAll(errors.getMessages());
// }
//
// public boolean isInError() {
// return !this.messages.isEmpty();
// }
//
// public List<String> getMessages() {
// return messages;
// }
// }
//
// Path: src/test/java/net/ozwolf/mockserver/raml/util/Fixtures.java
// public static String fixture(String resource) throws IOException {
// return IOUtils.toString(Fixtures.class.getClassLoader().getResourceAsStream(resource))
// .replaceAll("\r\n", "\n");
// }
// Path: src/test/java/net/ozwolf/mockserver/raml/internal/domain/body/JsonBodySpecificationTest.java
import net.ozwolf.mockserver.raml.internal.domain.ValidationErrors;
import org.junit.Test;
import org.raml.model.MimeType;
import java.io.IOException;
import static net.ozwolf.mockserver.raml.util.Fixtures.fixture;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
package net.ozwolf.mockserver.raml.internal.domain.body;
public class JsonBodySpecificationTest {
@Test
public void shouldValidateSchemaAndEntityAsCorrect() throws IOException {
String schema = fixture("apispecs-test/schemas/greeting-response.json");
String response = fixture("apispecs-test/examples/greeting-response.json");
MimeType mimeType = mock(MimeType.class);
when(mimeType.getSchema()).thenReturn(schema);
| ValidationErrors errors = new JsonBodySpecification("Response Body", mimeType).validate(response); |
ozwolf-software/raml-mock-server | src/test/java/net/ozwolf/mockserver/raml/specification/RemoteSpecificationTest.java | // Path: src/main/java/net/ozwolf/mockserver/raml/handlers/ZipArchiveHandler.java
// public class ZipArchiveHandler implements RamlResourceHandler {
// private final File targetDirectory;
// private final File specificationFile;
//
// /**
// * Create a new ZIP archive remote resource handler.
// *
// * @param targetDirectory The directory to unpack the ZIP archive into.
// * @param specificationFile The root RAML specification file to expect (sans path)
// */
// public ZipArchiveHandler(File targetDirectory, File specificationFile) {
// this.targetDirectory = targetDirectory;
// this.specificationFile = specificationFile;
// }
//
// /**
// * Retrieve the specification file from the remote resource.
// *
// * @param file The downloaded file resource
// * @return The RAML specification file
// * @throws java.lang.IllegalAccessError Target directory could not be created.
// * @throws java.lang.IllegalArgumentException The target directory is not a directory
// * @throws java.lang.IllegalStateException The target directory could not be written to or the specification file was not found.
// */
// @Override
// public File handle(File file) {
// try {
// String targetPath = FilenameUtils.separatorsToUnix(targetDirectory.getPath());
// if (!targetDirectory.exists() && !targetDirectory.mkdirs())
// throw new IllegalAccessError(String.format("Could not create [ %s ] directory.", targetPath));
//
// if (targetDirectory.exists() && !targetDirectory.isDirectory())
// throw new IllegalArgumentException(String.format("[ %s ] is not a directory.", targetPath));
//
// if (targetDirectory.exists() && !targetDirectory.canWrite())
// throw new IllegalStateException(String.format("Cannot write to [ %s ].", targetPath));
//
// ZipFile zipFile = new ZipFile(file);
// zipFile.extractAll(targetDirectory.getPath());
//
// if (!specificationFile.exists() || !specificationFile.canRead())
// throw new IllegalStateException(String.format("Could not find or access [ %s ].", FilenameUtils.separatorsToUnix(specificationFile.getPath())));
//
// return specificationFile;
// } catch (ZipException e) {
// throw new RuntimeException(e);
// }
// }
//
// /**
// * Create a resource handler that expects a ZIP archive as the remote resource. Will unpack the zip archive into the target directory and will return a File object to the named specification file.
// *
// * @param targetDirectory The directory to unpack the ZIP archive to.
// * @param specificationFileName The name of the root RAML specification file (sans pathing)
// * @return The pointer to the RAML specification file.
// */
// public static RamlResourceHandler handler(String targetDirectory, String specificationFileName) {
// return new ZipArchiveHandler(new File(targetDirectory), Paths.get(targetDirectory, specificationFileName).toFile());
// }
// }
//
// Path: src/test/java/net/ozwolf/mockserver/raml/util/Fixtures.java
// public static File zipFixture(String path) throws ZipException {
// File source = new File(path);
// File target = new File("target/archives/zip-archive-test.zip");
// if (target.exists() && !target.delete())
// throw new RuntimeException("Unable to delete old zip file target");
//
// if (!target.getParentFile().exists() && !target.getParentFile().mkdirs())
// throw new RuntimeException("Unable to create directories for zip file target");
//
// ZipFile zipFile = new ZipFile(target);
// ZipParameters parameters = new ZipParameters();
// parameters.setIncludeRootFolder(false);
// zipFile.createZipFileFromFolder(source, parameters, false, -1);
//
// return target;
// }
| import net.lingala.zip4j.exception.ZipException;
import net.ozwolf.mockserver.raml.handlers.ZipArchiveHandler;
import org.junit.Test;
import org.raml.model.Raml;
import java.io.File;
import static net.ozwolf.mockserver.raml.util.Fixtures.zipFixture;
import static org.assertj.core.api.Assertions.assertThat; | package net.ozwolf.mockserver.raml.specification;
public class RemoteSpecificationTest {
@Test
public void shouldLoadRamlFromRemoteLocationAndUseProvidedFileHandler() throws ZipException { | // Path: src/main/java/net/ozwolf/mockserver/raml/handlers/ZipArchiveHandler.java
// public class ZipArchiveHandler implements RamlResourceHandler {
// private final File targetDirectory;
// private final File specificationFile;
//
// /**
// * Create a new ZIP archive remote resource handler.
// *
// * @param targetDirectory The directory to unpack the ZIP archive into.
// * @param specificationFile The root RAML specification file to expect (sans path)
// */
// public ZipArchiveHandler(File targetDirectory, File specificationFile) {
// this.targetDirectory = targetDirectory;
// this.specificationFile = specificationFile;
// }
//
// /**
// * Retrieve the specification file from the remote resource.
// *
// * @param file The downloaded file resource
// * @return The RAML specification file
// * @throws java.lang.IllegalAccessError Target directory could not be created.
// * @throws java.lang.IllegalArgumentException The target directory is not a directory
// * @throws java.lang.IllegalStateException The target directory could not be written to or the specification file was not found.
// */
// @Override
// public File handle(File file) {
// try {
// String targetPath = FilenameUtils.separatorsToUnix(targetDirectory.getPath());
// if (!targetDirectory.exists() && !targetDirectory.mkdirs())
// throw new IllegalAccessError(String.format("Could not create [ %s ] directory.", targetPath));
//
// if (targetDirectory.exists() && !targetDirectory.isDirectory())
// throw new IllegalArgumentException(String.format("[ %s ] is not a directory.", targetPath));
//
// if (targetDirectory.exists() && !targetDirectory.canWrite())
// throw new IllegalStateException(String.format("Cannot write to [ %s ].", targetPath));
//
// ZipFile zipFile = new ZipFile(file);
// zipFile.extractAll(targetDirectory.getPath());
//
// if (!specificationFile.exists() || !specificationFile.canRead())
// throw new IllegalStateException(String.format("Could not find or access [ %s ].", FilenameUtils.separatorsToUnix(specificationFile.getPath())));
//
// return specificationFile;
// } catch (ZipException e) {
// throw new RuntimeException(e);
// }
// }
//
// /**
// * Create a resource handler that expects a ZIP archive as the remote resource. Will unpack the zip archive into the target directory and will return a File object to the named specification file.
// *
// * @param targetDirectory The directory to unpack the ZIP archive to.
// * @param specificationFileName The name of the root RAML specification file (sans pathing)
// * @return The pointer to the RAML specification file.
// */
// public static RamlResourceHandler handler(String targetDirectory, String specificationFileName) {
// return new ZipArchiveHandler(new File(targetDirectory), Paths.get(targetDirectory, specificationFileName).toFile());
// }
// }
//
// Path: src/test/java/net/ozwolf/mockserver/raml/util/Fixtures.java
// public static File zipFixture(String path) throws ZipException {
// File source = new File(path);
// File target = new File("target/archives/zip-archive-test.zip");
// if (target.exists() && !target.delete())
// throw new RuntimeException("Unable to delete old zip file target");
//
// if (!target.getParentFile().exists() && !target.getParentFile().mkdirs())
// throw new RuntimeException("Unable to create directories for zip file target");
//
// ZipFile zipFile = new ZipFile(target);
// ZipParameters parameters = new ZipParameters();
// parameters.setIncludeRootFolder(false);
// zipFile.createZipFileFromFolder(source, parameters, false, -1);
//
// return target;
// }
// Path: src/test/java/net/ozwolf/mockserver/raml/specification/RemoteSpecificationTest.java
import net.lingala.zip4j.exception.ZipException;
import net.ozwolf.mockserver.raml.handlers.ZipArchiveHandler;
import org.junit.Test;
import org.raml.model.Raml;
import java.io.File;
import static net.ozwolf.mockserver.raml.util.Fixtures.zipFixture;
import static org.assertj.core.api.Assertions.assertThat;
package net.ozwolf.mockserver.raml.specification;
public class RemoteSpecificationTest {
@Test
public void shouldLoadRamlFromRemoteLocationAndUseProvidedFileHandler() throws ZipException { | File zip = zipFixture("src/test/resources/apispecs-test"); |
ozwolf-software/raml-mock-server | src/test/java/net/ozwolf/mockserver/raml/specification/RemoteSpecificationTest.java | // Path: src/main/java/net/ozwolf/mockserver/raml/handlers/ZipArchiveHandler.java
// public class ZipArchiveHandler implements RamlResourceHandler {
// private final File targetDirectory;
// private final File specificationFile;
//
// /**
// * Create a new ZIP archive remote resource handler.
// *
// * @param targetDirectory The directory to unpack the ZIP archive into.
// * @param specificationFile The root RAML specification file to expect (sans path)
// */
// public ZipArchiveHandler(File targetDirectory, File specificationFile) {
// this.targetDirectory = targetDirectory;
// this.specificationFile = specificationFile;
// }
//
// /**
// * Retrieve the specification file from the remote resource.
// *
// * @param file The downloaded file resource
// * @return The RAML specification file
// * @throws java.lang.IllegalAccessError Target directory could not be created.
// * @throws java.lang.IllegalArgumentException The target directory is not a directory
// * @throws java.lang.IllegalStateException The target directory could not be written to or the specification file was not found.
// */
// @Override
// public File handle(File file) {
// try {
// String targetPath = FilenameUtils.separatorsToUnix(targetDirectory.getPath());
// if (!targetDirectory.exists() && !targetDirectory.mkdirs())
// throw new IllegalAccessError(String.format("Could not create [ %s ] directory.", targetPath));
//
// if (targetDirectory.exists() && !targetDirectory.isDirectory())
// throw new IllegalArgumentException(String.format("[ %s ] is not a directory.", targetPath));
//
// if (targetDirectory.exists() && !targetDirectory.canWrite())
// throw new IllegalStateException(String.format("Cannot write to [ %s ].", targetPath));
//
// ZipFile zipFile = new ZipFile(file);
// zipFile.extractAll(targetDirectory.getPath());
//
// if (!specificationFile.exists() || !specificationFile.canRead())
// throw new IllegalStateException(String.format("Could not find or access [ %s ].", FilenameUtils.separatorsToUnix(specificationFile.getPath())));
//
// return specificationFile;
// } catch (ZipException e) {
// throw new RuntimeException(e);
// }
// }
//
// /**
// * Create a resource handler that expects a ZIP archive as the remote resource. Will unpack the zip archive into the target directory and will return a File object to the named specification file.
// *
// * @param targetDirectory The directory to unpack the ZIP archive to.
// * @param specificationFileName The name of the root RAML specification file (sans pathing)
// * @return The pointer to the RAML specification file.
// */
// public static RamlResourceHandler handler(String targetDirectory, String specificationFileName) {
// return new ZipArchiveHandler(new File(targetDirectory), Paths.get(targetDirectory, specificationFileName).toFile());
// }
// }
//
// Path: src/test/java/net/ozwolf/mockserver/raml/util/Fixtures.java
// public static File zipFixture(String path) throws ZipException {
// File source = new File(path);
// File target = new File("target/archives/zip-archive-test.zip");
// if (target.exists() && !target.delete())
// throw new RuntimeException("Unable to delete old zip file target");
//
// if (!target.getParentFile().exists() && !target.getParentFile().mkdirs())
// throw new RuntimeException("Unable to create directories for zip file target");
//
// ZipFile zipFile = new ZipFile(target);
// ZipParameters parameters = new ZipParameters();
// parameters.setIncludeRootFolder(false);
// zipFile.createZipFileFromFolder(source, parameters, false, -1);
//
// return target;
// }
| import net.lingala.zip4j.exception.ZipException;
import net.ozwolf.mockserver.raml.handlers.ZipArchiveHandler;
import org.junit.Test;
import org.raml.model.Raml;
import java.io.File;
import static net.ozwolf.mockserver.raml.util.Fixtures.zipFixture;
import static org.assertj.core.api.Assertions.assertThat; | package net.ozwolf.mockserver.raml.specification;
public class RemoteSpecificationTest {
@Test
public void shouldLoadRamlFromRemoteLocationAndUseProvidedFileHandler() throws ZipException {
File zip = zipFixture("src/test/resources/apispecs-test");
File targetDirectory = new File("target/specifications/test-service");
File specificationFile = new File("target/specifications/test-service/apispecs.raml");
| // Path: src/main/java/net/ozwolf/mockserver/raml/handlers/ZipArchiveHandler.java
// public class ZipArchiveHandler implements RamlResourceHandler {
// private final File targetDirectory;
// private final File specificationFile;
//
// /**
// * Create a new ZIP archive remote resource handler.
// *
// * @param targetDirectory The directory to unpack the ZIP archive into.
// * @param specificationFile The root RAML specification file to expect (sans path)
// */
// public ZipArchiveHandler(File targetDirectory, File specificationFile) {
// this.targetDirectory = targetDirectory;
// this.specificationFile = specificationFile;
// }
//
// /**
// * Retrieve the specification file from the remote resource.
// *
// * @param file The downloaded file resource
// * @return The RAML specification file
// * @throws java.lang.IllegalAccessError Target directory could not be created.
// * @throws java.lang.IllegalArgumentException The target directory is not a directory
// * @throws java.lang.IllegalStateException The target directory could not be written to or the specification file was not found.
// */
// @Override
// public File handle(File file) {
// try {
// String targetPath = FilenameUtils.separatorsToUnix(targetDirectory.getPath());
// if (!targetDirectory.exists() && !targetDirectory.mkdirs())
// throw new IllegalAccessError(String.format("Could not create [ %s ] directory.", targetPath));
//
// if (targetDirectory.exists() && !targetDirectory.isDirectory())
// throw new IllegalArgumentException(String.format("[ %s ] is not a directory.", targetPath));
//
// if (targetDirectory.exists() && !targetDirectory.canWrite())
// throw new IllegalStateException(String.format("Cannot write to [ %s ].", targetPath));
//
// ZipFile zipFile = new ZipFile(file);
// zipFile.extractAll(targetDirectory.getPath());
//
// if (!specificationFile.exists() || !specificationFile.canRead())
// throw new IllegalStateException(String.format("Could not find or access [ %s ].", FilenameUtils.separatorsToUnix(specificationFile.getPath())));
//
// return specificationFile;
// } catch (ZipException e) {
// throw new RuntimeException(e);
// }
// }
//
// /**
// * Create a resource handler that expects a ZIP archive as the remote resource. Will unpack the zip archive into the target directory and will return a File object to the named specification file.
// *
// * @param targetDirectory The directory to unpack the ZIP archive to.
// * @param specificationFileName The name of the root RAML specification file (sans pathing)
// * @return The pointer to the RAML specification file.
// */
// public static RamlResourceHandler handler(String targetDirectory, String specificationFileName) {
// return new ZipArchiveHandler(new File(targetDirectory), Paths.get(targetDirectory, specificationFileName).toFile());
// }
// }
//
// Path: src/test/java/net/ozwolf/mockserver/raml/util/Fixtures.java
// public static File zipFixture(String path) throws ZipException {
// File source = new File(path);
// File target = new File("target/archives/zip-archive-test.zip");
// if (target.exists() && !target.delete())
// throw new RuntimeException("Unable to delete old zip file target");
//
// if (!target.getParentFile().exists() && !target.getParentFile().mkdirs())
// throw new RuntimeException("Unable to create directories for zip file target");
//
// ZipFile zipFile = new ZipFile(target);
// ZipParameters parameters = new ZipParameters();
// parameters.setIncludeRootFolder(false);
// zipFile.createZipFileFromFolder(source, parameters, false, -1);
//
// return target;
// }
// Path: src/test/java/net/ozwolf/mockserver/raml/specification/RemoteSpecificationTest.java
import net.lingala.zip4j.exception.ZipException;
import net.ozwolf.mockserver.raml.handlers.ZipArchiveHandler;
import org.junit.Test;
import org.raml.model.Raml;
import java.io.File;
import static net.ozwolf.mockserver.raml.util.Fixtures.zipFixture;
import static org.assertj.core.api.Assertions.assertThat;
package net.ozwolf.mockserver.raml.specification;
public class RemoteSpecificationTest {
@Test
public void shouldLoadRamlFromRemoteLocationAndUseProvidedFileHandler() throws ZipException {
File zip = zipFixture("src/test/resources/apispecs-test");
File targetDirectory = new File("target/specifications/test-service");
File specificationFile = new File("target/specifications/test-service/apispecs.raml");
| RemoteSpecification specification = new RemoteSpecification("my-service", zip.toURI().toString(), new ZipArchiveHandler(targetDirectory, specificationFile)); |
ozwolf-software/raml-mock-server | src/test/java/net/ozwolf/mockserver/raml/RamlSpecificationRuleIntegrationTest.java | // Path: src/main/java/net/ozwolf/mockserver/raml/specification/ClassPathSpecification.java
// public class ClassPathSpecification extends RamlSpecification {
// private final String resource;
//
// /**
// * Create a new RAML specification
// *
// * @param name The name of specification
// * @param resource The ClassPath resource to load
// */
// public ClassPathSpecification(String name, String resource) {
// super(name);
// this.resource = resource;
// }
//
// @Override
// protected Raml getRaml() {
// InputStream stream = getClass().getClassLoader().getResourceAsStream(resource);
// if (stream == null)
// throw new IllegalStateException(String.format("[ %s ] resource does not exist", resource));
//
// return new RamlDocumentBuilder().build(resource);
// }
// }
//
// Path: src/test/java/net/ozwolf/mockserver/raml/util/Fixtures.java
// public static String fixture(String resource) throws IOException {
// return IOUtils.toString(Fixtures.class.getClassLoader().getResourceAsStream(resource))
// .replaceAll("\r\n", "\n");
// }
| import net.ozwolf.mockserver.raml.specification.ClassPathSpecification;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.JerseyClientBuilder;
import org.json.JSONException;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.mockserver.client.server.MockServerClient;
import org.mockserver.junit.MockServerRule;
import org.mockserver.model.Header;
import org.mockserver.model.Parameter;
import org.skyscreamer.jsonassert.JSONAssert;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.IOException;
import static net.ozwolf.mockserver.raml.util.Fixtures.fixture;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockserver.model.HttpRequest.request;
import static org.mockserver.model.HttpResponse.response; | package net.ozwolf.mockserver.raml;
public class RamlSpecificationRuleIntegrationTest {
@Rule
public MockServerRule server = new MockServerRule(this, 5000);
@ClassRule
public final static RamlSpecificationsRule SPECIFICATIONS = new RamlSpecificationsRule()
.withSpecifications( | // Path: src/main/java/net/ozwolf/mockserver/raml/specification/ClassPathSpecification.java
// public class ClassPathSpecification extends RamlSpecification {
// private final String resource;
//
// /**
// * Create a new RAML specification
// *
// * @param name The name of specification
// * @param resource The ClassPath resource to load
// */
// public ClassPathSpecification(String name, String resource) {
// super(name);
// this.resource = resource;
// }
//
// @Override
// protected Raml getRaml() {
// InputStream stream = getClass().getClassLoader().getResourceAsStream(resource);
// if (stream == null)
// throw new IllegalStateException(String.format("[ %s ] resource does not exist", resource));
//
// return new RamlDocumentBuilder().build(resource);
// }
// }
//
// Path: src/test/java/net/ozwolf/mockserver/raml/util/Fixtures.java
// public static String fixture(String resource) throws IOException {
// return IOUtils.toString(Fixtures.class.getClassLoader().getResourceAsStream(resource))
// .replaceAll("\r\n", "\n");
// }
// Path: src/test/java/net/ozwolf/mockserver/raml/RamlSpecificationRuleIntegrationTest.java
import net.ozwolf.mockserver.raml.specification.ClassPathSpecification;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.JerseyClientBuilder;
import org.json.JSONException;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.mockserver.client.server.MockServerClient;
import org.mockserver.junit.MockServerRule;
import org.mockserver.model.Header;
import org.mockserver.model.Parameter;
import org.skyscreamer.jsonassert.JSONAssert;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.IOException;
import static net.ozwolf.mockserver.raml.util.Fixtures.fixture;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockserver.model.HttpRequest.request;
import static org.mockserver.model.HttpResponse.response;
package net.ozwolf.mockserver.raml;
public class RamlSpecificationRuleIntegrationTest {
@Rule
public MockServerRule server = new MockServerRule(this, 5000);
@ClassRule
public final static RamlSpecificationsRule SPECIFICATIONS = new RamlSpecificationsRule()
.withSpecifications( | new ClassPathSpecification("my-service", "apispecs-test/apispecs.raml") |
ozwolf-software/raml-mock-server | src/test/java/net/ozwolf/mockserver/raml/RamlSpecificationRuleIntegrationTest.java | // Path: src/main/java/net/ozwolf/mockserver/raml/specification/ClassPathSpecification.java
// public class ClassPathSpecification extends RamlSpecification {
// private final String resource;
//
// /**
// * Create a new RAML specification
// *
// * @param name The name of specification
// * @param resource The ClassPath resource to load
// */
// public ClassPathSpecification(String name, String resource) {
// super(name);
// this.resource = resource;
// }
//
// @Override
// protected Raml getRaml() {
// InputStream stream = getClass().getClassLoader().getResourceAsStream(resource);
// if (stream == null)
// throw new IllegalStateException(String.format("[ %s ] resource does not exist", resource));
//
// return new RamlDocumentBuilder().build(resource);
// }
// }
//
// Path: src/test/java/net/ozwolf/mockserver/raml/util/Fixtures.java
// public static String fixture(String resource) throws IOException {
// return IOUtils.toString(Fixtures.class.getClassLoader().getResourceAsStream(resource))
// .replaceAll("\r\n", "\n");
// }
| import net.ozwolf.mockserver.raml.specification.ClassPathSpecification;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.JerseyClientBuilder;
import org.json.JSONException;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.mockserver.client.server.MockServerClient;
import org.mockserver.junit.MockServerRule;
import org.mockserver.model.Header;
import org.mockserver.model.Parameter;
import org.skyscreamer.jsonassert.JSONAssert;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.IOException;
import static net.ozwolf.mockserver.raml.util.Fixtures.fixture;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockserver.model.HttpRequest.request;
import static org.mockserver.model.HttpResponse.response; | new ClassPathSpecification("my-service", "apispecs-test/apispecs.raml")
);
@Test
public void shouldCorrectlyVerifyMockServerExpectationsAgainstRamlSpecification() throws IOException {
MockServerClient mockClient = new MockServerClient("localhost", 5000);
mockClient.when(
request()
.withPath("/hello/John")
.withMethod("GET")
.withHeader(new Header(HttpHeaders.ACCEPT, MediaType.TEXT_PLAIN))
).respond(
response()
.withStatusCode(200)
.withHeader(new Header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN))
.withBody("Hello John!")
);
Client client = new JerseyClientBuilder().withConfig(new ClientConfig()).build();
String response = client.target("http://localhost:5000/hello/John")
.request()
.header(HttpHeaders.ACCEPT, MediaType.TEXT_PLAIN)
.get(String.class);
assertThat(response).isEqualTo("Hello John!");
RamlSpecification.Result result = SPECIFICATIONS.get("my-service").obeyedBy(mockClient);
assertFalse(result.isValid()); | // Path: src/main/java/net/ozwolf/mockserver/raml/specification/ClassPathSpecification.java
// public class ClassPathSpecification extends RamlSpecification {
// private final String resource;
//
// /**
// * Create a new RAML specification
// *
// * @param name The name of specification
// * @param resource The ClassPath resource to load
// */
// public ClassPathSpecification(String name, String resource) {
// super(name);
// this.resource = resource;
// }
//
// @Override
// protected Raml getRaml() {
// InputStream stream = getClass().getClassLoader().getResourceAsStream(resource);
// if (stream == null)
// throw new IllegalStateException(String.format("[ %s ] resource does not exist", resource));
//
// return new RamlDocumentBuilder().build(resource);
// }
// }
//
// Path: src/test/java/net/ozwolf/mockserver/raml/util/Fixtures.java
// public static String fixture(String resource) throws IOException {
// return IOUtils.toString(Fixtures.class.getClassLoader().getResourceAsStream(resource))
// .replaceAll("\r\n", "\n");
// }
// Path: src/test/java/net/ozwolf/mockserver/raml/RamlSpecificationRuleIntegrationTest.java
import net.ozwolf.mockserver.raml.specification.ClassPathSpecification;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.JerseyClientBuilder;
import org.json.JSONException;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.mockserver.client.server.MockServerClient;
import org.mockserver.junit.MockServerRule;
import org.mockserver.model.Header;
import org.mockserver.model.Parameter;
import org.skyscreamer.jsonassert.JSONAssert;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.IOException;
import static net.ozwolf.mockserver.raml.util.Fixtures.fixture;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockserver.model.HttpRequest.request;
import static org.mockserver.model.HttpResponse.response;
new ClassPathSpecification("my-service", "apispecs-test/apispecs.raml")
);
@Test
public void shouldCorrectlyVerifyMockServerExpectationsAgainstRamlSpecification() throws IOException {
MockServerClient mockClient = new MockServerClient("localhost", 5000);
mockClient.when(
request()
.withPath("/hello/John")
.withMethod("GET")
.withHeader(new Header(HttpHeaders.ACCEPT, MediaType.TEXT_PLAIN))
).respond(
response()
.withStatusCode(200)
.withHeader(new Header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN))
.withBody("Hello John!")
);
Client client = new JerseyClientBuilder().withConfig(new ClientConfig()).build();
String response = client.target("http://localhost:5000/hello/John")
.request()
.header(HttpHeaders.ACCEPT, MediaType.TEXT_PLAIN)
.get(String.class);
assertThat(response).isEqualTo("Hello John!");
RamlSpecification.Result result = SPECIFICATIONS.get("my-service").obeyedBy(mockClient);
assertFalse(result.isValid()); | assertThat(result.getFormattedErrorMessage()).isEqualTo(fixture("fixtures/expected-obey-errors-get-hello-john.txt")); |
ozwolf-software/raml-mock-server | src/test/java/net/ozwolf/mockserver/raml/util/ValidatorFactory.java | // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/ValidationErrors.java
// public class ValidationErrors {
// private final List<String> messages;
//
// public ValidationErrors() {
// this.messages = newArrayList();
// }
//
// public void addMessage(String error, Object... formattedParameters) {
// this.messages.add(String.format(error, formattedParameters));
// }
//
// public void combineWith(ValidationErrors errors) {
// this.messages.addAll(errors.getMessages());
// }
//
// public boolean isInError() {
// return !this.messages.isEmpty();
// }
//
// public List<String> getMessages() {
// return messages;
// }
// }
//
// Path: src/main/java/net/ozwolf/mockserver/raml/internal/validator/Validator.java
// public interface Validator {
// ValidationErrors validate();
// }
| import net.ozwolf.mockserver.raml.internal.domain.ValidationErrors;
import net.ozwolf.mockserver.raml.internal.validator.Validator;
import org.apache.commons.lang.StringUtils;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when; | package net.ozwolf.mockserver.raml.util;
public class ValidatorFactory {
public static Validator validator(String errorMessage) {
Validator validator = mock(Validator.class); | // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/ValidationErrors.java
// public class ValidationErrors {
// private final List<String> messages;
//
// public ValidationErrors() {
// this.messages = newArrayList();
// }
//
// public void addMessage(String error, Object... formattedParameters) {
// this.messages.add(String.format(error, formattedParameters));
// }
//
// public void combineWith(ValidationErrors errors) {
// this.messages.addAll(errors.getMessages());
// }
//
// public boolean isInError() {
// return !this.messages.isEmpty();
// }
//
// public List<String> getMessages() {
// return messages;
// }
// }
//
// Path: src/main/java/net/ozwolf/mockserver/raml/internal/validator/Validator.java
// public interface Validator {
// ValidationErrors validate();
// }
// Path: src/test/java/net/ozwolf/mockserver/raml/util/ValidatorFactory.java
import net.ozwolf.mockserver.raml.internal.domain.ValidationErrors;
import net.ozwolf.mockserver.raml.internal.validator.Validator;
import org.apache.commons.lang.StringUtils;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
package net.ozwolf.mockserver.raml.util;
public class ValidatorFactory {
public static Validator validator(String errorMessage) {
Validator validator = mock(Validator.class); | ValidationErrors errors = new ValidationErrors(); |
arnowelzel/periodical | app/src/main/java/de/arnowelzel/android/periodical/MainActivityApp.java | // Path: app/src/main/java/de/arnowelzel/android/periodical/PeriodicalDatabase.java
// final static int PERIOD_CONFIRMED = 2;
//
// Path: app/src/main/java/de/arnowelzel/android/periodical/PeriodicalDatabase.java
// final static int PERIOD_START = 1;
| import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.backup.BackupManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import androidx.annotation.NonNull;
import com.google.android.material.navigation.NavigationView;
import com.yariksoffice.lingver.Lingver;
import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.webkit.WebView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ViewFlipper;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;
import static de.arnowelzel.android.periodical.PeriodicalDatabase.DayEntry.PERIOD_CONFIRMED;
import static de.arnowelzel.android.periodical.PeriodicalDatabase.DayEntry.PERIOD_START; | int idButton = v.getId();
int nButtonClicked = 0;
int calButtonIds[];
if (viewCurrent == R.id.calendar) {
calButtonIds = this.calButtonIds;
} else {
calButtonIds = calButtonIds_2;
}
while (nButtonClicked < 42) {
if (calButtonIds[nButtonClicked] == idButton)
break;
nButtonClicked++;
}
final int day = nButtonClicked - firstDayOfWeek + 2;
// If "direct details" is set by the user, just open the details
PreferenceUtils preferences = new PreferenceUtils(context);
if (preferences.getBoolean("direct_details", false)) {
showDetailsActivity(yearCurrent, monthCurrent, day);
} else {
// Set or remove entry with confirmation
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(getResources()
.getString(R.string.calendaraction_title));
final GregorianCalendar date = new GregorianCalendar(yearCurrent, monthCurrent - 1, day);
int type = dbMain.getEntryType(date); | // Path: app/src/main/java/de/arnowelzel/android/periodical/PeriodicalDatabase.java
// final static int PERIOD_CONFIRMED = 2;
//
// Path: app/src/main/java/de/arnowelzel/android/periodical/PeriodicalDatabase.java
// final static int PERIOD_START = 1;
// Path: app/src/main/java/de/arnowelzel/android/periodical/MainActivityApp.java
import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.backup.BackupManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import androidx.annotation.NonNull;
import com.google.android.material.navigation.NavigationView;
import com.yariksoffice.lingver.Lingver;
import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.webkit.WebView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ViewFlipper;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;
import static de.arnowelzel.android.periodical.PeriodicalDatabase.DayEntry.PERIOD_CONFIRMED;
import static de.arnowelzel.android.periodical.PeriodicalDatabase.DayEntry.PERIOD_START;
int idButton = v.getId();
int nButtonClicked = 0;
int calButtonIds[];
if (viewCurrent == R.id.calendar) {
calButtonIds = this.calButtonIds;
} else {
calButtonIds = calButtonIds_2;
}
while (nButtonClicked < 42) {
if (calButtonIds[nButtonClicked] == idButton)
break;
nButtonClicked++;
}
final int day = nButtonClicked - firstDayOfWeek + 2;
// If "direct details" is set by the user, just open the details
PreferenceUtils preferences = new PreferenceUtils(context);
if (preferences.getBoolean("direct_details", false)) {
showDetailsActivity(yearCurrent, monthCurrent, day);
} else {
// Set or remove entry with confirmation
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(getResources()
.getString(R.string.calendaraction_title));
final GregorianCalendar date = new GregorianCalendar(yearCurrent, monthCurrent - 1, day);
int type = dbMain.getEntryType(date); | if (type != PERIOD_START && type != PERIOD_CONFIRMED) { |
arnowelzel/periodical | app/src/main/java/de/arnowelzel/android/periodical/MainActivityApp.java | // Path: app/src/main/java/de/arnowelzel/android/periodical/PeriodicalDatabase.java
// final static int PERIOD_CONFIRMED = 2;
//
// Path: app/src/main/java/de/arnowelzel/android/periodical/PeriodicalDatabase.java
// final static int PERIOD_START = 1;
| import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.backup.BackupManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import androidx.annotation.NonNull;
import com.google.android.material.navigation.NavigationView;
import com.yariksoffice.lingver.Lingver;
import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.webkit.WebView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ViewFlipper;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;
import static de.arnowelzel.android.periodical.PeriodicalDatabase.DayEntry.PERIOD_CONFIRMED;
import static de.arnowelzel.android.periodical.PeriodicalDatabase.DayEntry.PERIOD_START; | int idButton = v.getId();
int nButtonClicked = 0;
int calButtonIds[];
if (viewCurrent == R.id.calendar) {
calButtonIds = this.calButtonIds;
} else {
calButtonIds = calButtonIds_2;
}
while (nButtonClicked < 42) {
if (calButtonIds[nButtonClicked] == idButton)
break;
nButtonClicked++;
}
final int day = nButtonClicked - firstDayOfWeek + 2;
// If "direct details" is set by the user, just open the details
PreferenceUtils preferences = new PreferenceUtils(context);
if (preferences.getBoolean("direct_details", false)) {
showDetailsActivity(yearCurrent, monthCurrent, day);
} else {
// Set or remove entry with confirmation
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(getResources()
.getString(R.string.calendaraction_title));
final GregorianCalendar date = new GregorianCalendar(yearCurrent, monthCurrent - 1, day);
int type = dbMain.getEntryType(date); | // Path: app/src/main/java/de/arnowelzel/android/periodical/PeriodicalDatabase.java
// final static int PERIOD_CONFIRMED = 2;
//
// Path: app/src/main/java/de/arnowelzel/android/periodical/PeriodicalDatabase.java
// final static int PERIOD_START = 1;
// Path: app/src/main/java/de/arnowelzel/android/periodical/MainActivityApp.java
import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.backup.BackupManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import androidx.annotation.NonNull;
import com.google.android.material.navigation.NavigationView;
import com.yariksoffice.lingver.Lingver;
import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.webkit.WebView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ViewFlipper;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;
import static de.arnowelzel.android.periodical.PeriodicalDatabase.DayEntry.PERIOD_CONFIRMED;
import static de.arnowelzel.android.periodical.PeriodicalDatabase.DayEntry.PERIOD_START;
int idButton = v.getId();
int nButtonClicked = 0;
int calButtonIds[];
if (viewCurrent == R.id.calendar) {
calButtonIds = this.calButtonIds;
} else {
calButtonIds = calButtonIds_2;
}
while (nButtonClicked < 42) {
if (calButtonIds[nButtonClicked] == idButton)
break;
nButtonClicked++;
}
final int day = nButtonClicked - firstDayOfWeek + 2;
// If "direct details" is set by the user, just open the details
PreferenceUtils preferences = new PreferenceUtils(context);
if (preferences.getBoolean("direct_details", false)) {
showDetailsActivity(yearCurrent, monthCurrent, day);
} else {
// Set or remove entry with confirmation
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(getResources()
.getString(R.string.calendaraction_title));
final GregorianCalendar date = new GregorianCalendar(yearCurrent, monthCurrent - 1, day);
int type = dbMain.getEntryType(date); | if (type != PERIOD_START && type != PERIOD_CONFIRMED) { |
arnowelzel/periodical | app/src/main/java/de/arnowelzel/android/periodical/ListActivity.java | // Path: app/src/main/java/de/arnowelzel/android/periodical/PeriodicalDatabase.java
// public static class DayEntry {
// final static int EMPTY = 0;
// final static int PERIOD_START = 1;
// final static int PERIOD_CONFIRMED = 2;
// final static int PERIOD_PREDICTED = 3;
// final static int FERTILITY_PREDICTED = 4;
// final static int OVULATION_PREDICTED = 5;
// final static int FERTILITY_FUTURE = 6;
// final static int OVULATION_FUTURE = 7;
// final static int INFERTILE_PREDICTED = 8;
// final static int INFERTILE_FUTURE = 9;
// int type;
// final GregorianCalendarExt date;
// int dayofcycle;
// int intensity;
// String notes;
// List<Integer> symptoms;
//
// /**
// * Construct a new day entry with parameters
// *
// * @param type Entry type (DayEntry.EMPTY, DayEntry.PERIOD_START, DayEntry.PERIOD_CONFIRMED, ...)
// * @param date Entry date
// * @param dayofcycle Day within current cycle (beginning with 1)
// * @param intensity Intensity of the period (1-4)
// */
// DayEntry(int type, GregorianCalendar date, int dayofcycle, int intensity) {
// this.type = type;
// this.date = new GregorianCalendarExt();
// this.date.setTime(date.getTime());
// this.dayofcycle = dayofcycle;
// this.intensity = intensity;
// this.notes = "";
// this.symptoms = new ArrayList<>();
// }
//
// /**
// * Construct a new day entry
// */
// DayEntry() {
// this.type = EMPTY;
// this.date = new GregorianCalendarExt();
// this.dayofcycle = 0;
// this.intensity = 1;
// this.notes = "";
// this.symptoms = new ArrayList<>();
// }
// }
| import android.widget.ListView;
import java.util.Calendar;
import java.util.Iterator;
import de.arnowelzel.android.periodical.PeriodicalDatabase.DayEntry;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.preference.PreferenceManager; | /*
* Periodical list activity
* Copyright (C) 2012-2020 Arno Welzel
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.arnowelzel.android.periodical;
/**
* Activity to handle the "List" command
*/
public class ListActivity extends AppCompatActivity implements AdapterView.OnItemClickListener {
/**
* Database for calendar data
*/
private PeriodicalDatabase dbMain;
/**
* Called when activity starts
*/
@SuppressLint("NewApi")
@Override
public void onCreate(Bundle savedInstanceState) {
final Context context = getApplicationContext();
assert context != null;
super.onCreate(savedInstanceState);
int maximumcyclelength;
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
try {
maximumcyclelength = Integer.parseInt(preferences.getString("maximum_cycle_length", "183"));
} catch (NumberFormatException e) {
maximumcyclelength = 183;
}
// Set up database and string array for the list
dbMain = new PeriodicalDatabase(context);
dbMain.loadRawData();
String[] entries = new String[dbMain.dayEntries.size()];
java.text.DateFormat dateFormat = android.text.format.DateFormat
.getDateFormat(context); | // Path: app/src/main/java/de/arnowelzel/android/periodical/PeriodicalDatabase.java
// public static class DayEntry {
// final static int EMPTY = 0;
// final static int PERIOD_START = 1;
// final static int PERIOD_CONFIRMED = 2;
// final static int PERIOD_PREDICTED = 3;
// final static int FERTILITY_PREDICTED = 4;
// final static int OVULATION_PREDICTED = 5;
// final static int FERTILITY_FUTURE = 6;
// final static int OVULATION_FUTURE = 7;
// final static int INFERTILE_PREDICTED = 8;
// final static int INFERTILE_FUTURE = 9;
// int type;
// final GregorianCalendarExt date;
// int dayofcycle;
// int intensity;
// String notes;
// List<Integer> symptoms;
//
// /**
// * Construct a new day entry with parameters
// *
// * @param type Entry type (DayEntry.EMPTY, DayEntry.PERIOD_START, DayEntry.PERIOD_CONFIRMED, ...)
// * @param date Entry date
// * @param dayofcycle Day within current cycle (beginning with 1)
// * @param intensity Intensity of the period (1-4)
// */
// DayEntry(int type, GregorianCalendar date, int dayofcycle, int intensity) {
// this.type = type;
// this.date = new GregorianCalendarExt();
// this.date.setTime(date.getTime());
// this.dayofcycle = dayofcycle;
// this.intensity = intensity;
// this.notes = "";
// this.symptoms = new ArrayList<>();
// }
//
// /**
// * Construct a new day entry
// */
// DayEntry() {
// this.type = EMPTY;
// this.date = new GregorianCalendarExt();
// this.dayofcycle = 0;
// this.intensity = 1;
// this.notes = "";
// this.symptoms = new ArrayList<>();
// }
// }
// Path: app/src/main/java/de/arnowelzel/android/periodical/ListActivity.java
import android.widget.ListView;
import java.util.Calendar;
import java.util.Iterator;
import de.arnowelzel.android.periodical.PeriodicalDatabase.DayEntry;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.preference.PreferenceManager;
/*
* Periodical list activity
* Copyright (C) 2012-2020 Arno Welzel
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.arnowelzel.android.periodical;
/**
* Activity to handle the "List" command
*/
public class ListActivity extends AppCompatActivity implements AdapterView.OnItemClickListener {
/**
* Database for calendar data
*/
private PeriodicalDatabase dbMain;
/**
* Called when activity starts
*/
@SuppressLint("NewApi")
@Override
public void onCreate(Bundle savedInstanceState) {
final Context context = getApplicationContext();
assert context != null;
super.onCreate(savedInstanceState);
int maximumcyclelength;
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
try {
maximumcyclelength = Integer.parseInt(preferences.getString("maximum_cycle_length", "183"));
} catch (NumberFormatException e) {
maximumcyclelength = 183;
}
// Set up database and string array for the list
dbMain = new PeriodicalDatabase(context);
dbMain.loadRawData();
String[] entries = new String[dbMain.dayEntries.size()];
java.text.DateFormat dateFormat = android.text.format.DateFormat
.getDateFormat(context); | Iterator<DayEntry> dayIterator = dbMain.dayEntries.iterator(); |
arnowelzel/periodical | app/src/main/java/de/arnowelzel/android/periodical/CalendarCell.java | // Path: app/src/main/java/de/arnowelzel/android/periodical/PeriodicalDatabase.java
// public static class DayEntry {
// final static int EMPTY = 0;
// final static int PERIOD_START = 1;
// final static int PERIOD_CONFIRMED = 2;
// final static int PERIOD_PREDICTED = 3;
// final static int FERTILITY_PREDICTED = 4;
// final static int OVULATION_PREDICTED = 5;
// final static int FERTILITY_FUTURE = 6;
// final static int OVULATION_FUTURE = 7;
// final static int INFERTILE_PREDICTED = 8;
// final static int INFERTILE_FUTURE = 9;
// int type;
// final GregorianCalendarExt date;
// int dayofcycle;
// int intensity;
// String notes;
// List<Integer> symptoms;
//
// /**
// * Construct a new day entry with parameters
// *
// * @param type Entry type (DayEntry.EMPTY, DayEntry.PERIOD_START, DayEntry.PERIOD_CONFIRMED, ...)
// * @param date Entry date
// * @param dayofcycle Day within current cycle (beginning with 1)
// * @param intensity Intensity of the period (1-4)
// */
// DayEntry(int type, GregorianCalendar date, int dayofcycle, int intensity) {
// this.type = type;
// this.date = new GregorianCalendarExt();
// this.date.setTime(date.getTime());
// this.dayofcycle = dayofcycle;
// this.intensity = intensity;
// this.notes = "";
// this.symptoms = new ArrayList<>();
// }
//
// /**
// * Construct a new day entry
// */
// DayEntry() {
// this.type = EMPTY;
// this.date = new GregorianCalendarExt();
// this.dayofcycle = 0;
// this.intensity = 1;
// this.notes = "";
// this.symptoms = new ArrayList<>();
// }
// }
| import android.annotation.SuppressLint;
import android.text.format.DateUtils;
import de.arnowelzel.android.periodical.PeriodicalDatabase.DayEntry;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.Paint.Align;
import android.graphics.Paint.Style;
import android.graphics.Rect;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.Surface;
import android.view.WindowManager;
import android.widget.Button; | private final Bitmap bitmapIntercourse;
/**
* Bitmap for entries with flag "intercourse" (black variant)
*/
private final Bitmap bitmapIntercourseBlack;
/**
* Bitmap for entries with flag "notes"
*/
private final Bitmap bitmapNotes;
/**
* Bitmap for entries with flag "notes" (black variant)
*/
private final Bitmap bitmapNotesBlack;
/**
* Paint for bitmaps
*/
private final Paint paintBitmap;
/* Current view orientation (portrait, landscape) */
private int orientation;
/**
* Constructor
*
* @param context Application context
* @param attrs Resource attributes
*/
public CalendarCell(Context context, AttributeSet attrs) {
super(context, attrs);
| // Path: app/src/main/java/de/arnowelzel/android/periodical/PeriodicalDatabase.java
// public static class DayEntry {
// final static int EMPTY = 0;
// final static int PERIOD_START = 1;
// final static int PERIOD_CONFIRMED = 2;
// final static int PERIOD_PREDICTED = 3;
// final static int FERTILITY_PREDICTED = 4;
// final static int OVULATION_PREDICTED = 5;
// final static int FERTILITY_FUTURE = 6;
// final static int OVULATION_FUTURE = 7;
// final static int INFERTILE_PREDICTED = 8;
// final static int INFERTILE_FUTURE = 9;
// int type;
// final GregorianCalendarExt date;
// int dayofcycle;
// int intensity;
// String notes;
// List<Integer> symptoms;
//
// /**
// * Construct a new day entry with parameters
// *
// * @param type Entry type (DayEntry.EMPTY, DayEntry.PERIOD_START, DayEntry.PERIOD_CONFIRMED, ...)
// * @param date Entry date
// * @param dayofcycle Day within current cycle (beginning with 1)
// * @param intensity Intensity of the period (1-4)
// */
// DayEntry(int type, GregorianCalendar date, int dayofcycle, int intensity) {
// this.type = type;
// this.date = new GregorianCalendarExt();
// this.date.setTime(date.getTime());
// this.dayofcycle = dayofcycle;
// this.intensity = intensity;
// this.notes = "";
// this.symptoms = new ArrayList<>();
// }
//
// /**
// * Construct a new day entry
// */
// DayEntry() {
// this.type = EMPTY;
// this.date = new GregorianCalendarExt();
// this.dayofcycle = 0;
// this.intensity = 1;
// this.notes = "";
// this.symptoms = new ArrayList<>();
// }
// }
// Path: app/src/main/java/de/arnowelzel/android/periodical/CalendarCell.java
import android.annotation.SuppressLint;
import android.text.format.DateUtils;
import de.arnowelzel.android.periodical.PeriodicalDatabase.DayEntry;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.Paint.Align;
import android.graphics.Paint.Style;
import android.graphics.Rect;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.Surface;
import android.view.WindowManager;
import android.widget.Button;
private final Bitmap bitmapIntercourse;
/**
* Bitmap for entries with flag "intercourse" (black variant)
*/
private final Bitmap bitmapIntercourseBlack;
/**
* Bitmap for entries with flag "notes"
*/
private final Bitmap bitmapNotes;
/**
* Bitmap for entries with flag "notes" (black variant)
*/
private final Bitmap bitmapNotesBlack;
/**
* Paint for bitmaps
*/
private final Paint paintBitmap;
/* Current view orientation (portrait, landscape) */
private int orientation;
/**
* Constructor
*
* @param context Application context
* @param attrs Resource attributes
*/
public CalendarCell(Context context, AttributeSet attrs) {
super(context, attrs);
| type = DayEntry.EMPTY; |
arnowelzel/periodical | app/src/main/java/de/arnowelzel/android/periodical/DetailsActivity.java | // Path: app/src/main/java/de/arnowelzel/android/periodical/PeriodicalDatabase.java
// final static int PERIOD_CONFIRMED = 2;
//
// Path: app/src/main/java/de/arnowelzel/android/periodical/PeriodicalDatabase.java
// final static int PERIOD_START = 1;
| import android.app.backup.BackupManager;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.AppCompatCheckBox;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.MenuItem;
import android.view.View;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.MultiAutoCompleteTextView;
import android.widget.RadioButton;
import android.widget.TextView;
import java.text.DateFormat;
import java.util.Locale;
import static de.arnowelzel.android.periodical.PeriodicalDatabase.DayEntry.PERIOD_CONFIRMED;
import static de.arnowelzel.android.periodical.PeriodicalDatabase.DayEntry.PERIOD_START; |
// Set up view
setContentView(R.layout.activity_details);
// Activate "back button" in Action Bar
ActionBar actionBar = getSupportActionBar();
assert actionBar != null;
actionBar.setDisplayHomeAsUpEnabled(true);
// Get details
Intent intent = getIntent();
int year = intent.getIntExtra("year", 1970);
int month = intent.getIntExtra("month", 1);
int day = intent.getIntExtra("day", 1);
dbMain = new PeriodicalDatabase(context);
dbMain.loadCalculatedData();
entry = dbMain.getEntryWithDetails(year, month, day);
// Set header using the entry date
DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.LONG);
((TextView) findViewById(R.id.labelDetailsHeader)).setText(
String.format("%s", dateFormat.format(entry.date.getTime())));
// Set period status
RadioButton buttonPeriodYes = findViewById(R.id.periodYes);
RadioButton buttonPeriodNo = findViewById(R.id.periodNo);
boolean intensityEnabled = false;
switch (entry.type) { | // Path: app/src/main/java/de/arnowelzel/android/periodical/PeriodicalDatabase.java
// final static int PERIOD_CONFIRMED = 2;
//
// Path: app/src/main/java/de/arnowelzel/android/periodical/PeriodicalDatabase.java
// final static int PERIOD_START = 1;
// Path: app/src/main/java/de/arnowelzel/android/periodical/DetailsActivity.java
import android.app.backup.BackupManager;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.AppCompatCheckBox;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.MenuItem;
import android.view.View;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.MultiAutoCompleteTextView;
import android.widget.RadioButton;
import android.widget.TextView;
import java.text.DateFormat;
import java.util.Locale;
import static de.arnowelzel.android.periodical.PeriodicalDatabase.DayEntry.PERIOD_CONFIRMED;
import static de.arnowelzel.android.periodical.PeriodicalDatabase.DayEntry.PERIOD_START;
// Set up view
setContentView(R.layout.activity_details);
// Activate "back button" in Action Bar
ActionBar actionBar = getSupportActionBar();
assert actionBar != null;
actionBar.setDisplayHomeAsUpEnabled(true);
// Get details
Intent intent = getIntent();
int year = intent.getIntExtra("year", 1970);
int month = intent.getIntExtra("month", 1);
int day = intent.getIntExtra("day", 1);
dbMain = new PeriodicalDatabase(context);
dbMain.loadCalculatedData();
entry = dbMain.getEntryWithDetails(year, month, day);
// Set header using the entry date
DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.LONG);
((TextView) findViewById(R.id.labelDetailsHeader)).setText(
String.format("%s", dateFormat.format(entry.date.getTime())));
// Set period status
RadioButton buttonPeriodYes = findViewById(R.id.periodYes);
RadioButton buttonPeriodNo = findViewById(R.id.periodNo);
boolean intensityEnabled = false;
switch (entry.type) { | case PERIOD_START: |
arnowelzel/periodical | app/src/main/java/de/arnowelzel/android/periodical/DetailsActivity.java | // Path: app/src/main/java/de/arnowelzel/android/periodical/PeriodicalDatabase.java
// final static int PERIOD_CONFIRMED = 2;
//
// Path: app/src/main/java/de/arnowelzel/android/periodical/PeriodicalDatabase.java
// final static int PERIOD_START = 1;
| import android.app.backup.BackupManager;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.AppCompatCheckBox;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.MenuItem;
import android.view.View;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.MultiAutoCompleteTextView;
import android.widget.RadioButton;
import android.widget.TextView;
import java.text.DateFormat;
import java.util.Locale;
import static de.arnowelzel.android.periodical.PeriodicalDatabase.DayEntry.PERIOD_CONFIRMED;
import static de.arnowelzel.android.periodical.PeriodicalDatabase.DayEntry.PERIOD_START; | // Set up view
setContentView(R.layout.activity_details);
// Activate "back button" in Action Bar
ActionBar actionBar = getSupportActionBar();
assert actionBar != null;
actionBar.setDisplayHomeAsUpEnabled(true);
// Get details
Intent intent = getIntent();
int year = intent.getIntExtra("year", 1970);
int month = intent.getIntExtra("month", 1);
int day = intent.getIntExtra("day", 1);
dbMain = new PeriodicalDatabase(context);
dbMain.loadCalculatedData();
entry = dbMain.getEntryWithDetails(year, month, day);
// Set header using the entry date
DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.LONG);
((TextView) findViewById(R.id.labelDetailsHeader)).setText(
String.format("%s", dateFormat.format(entry.date.getTime())));
// Set period status
RadioButton buttonPeriodYes = findViewById(R.id.periodYes);
RadioButton buttonPeriodNo = findViewById(R.id.periodNo);
boolean intensityEnabled = false;
switch (entry.type) {
case PERIOD_START: | // Path: app/src/main/java/de/arnowelzel/android/periodical/PeriodicalDatabase.java
// final static int PERIOD_CONFIRMED = 2;
//
// Path: app/src/main/java/de/arnowelzel/android/periodical/PeriodicalDatabase.java
// final static int PERIOD_START = 1;
// Path: app/src/main/java/de/arnowelzel/android/periodical/DetailsActivity.java
import android.app.backup.BackupManager;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.AppCompatCheckBox;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.MenuItem;
import android.view.View;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.MultiAutoCompleteTextView;
import android.widget.RadioButton;
import android.widget.TextView;
import java.text.DateFormat;
import java.util.Locale;
import static de.arnowelzel.android.periodical.PeriodicalDatabase.DayEntry.PERIOD_CONFIRMED;
import static de.arnowelzel.android.periodical.PeriodicalDatabase.DayEntry.PERIOD_START;
// Set up view
setContentView(R.layout.activity_details);
// Activate "back button" in Action Bar
ActionBar actionBar = getSupportActionBar();
assert actionBar != null;
actionBar.setDisplayHomeAsUpEnabled(true);
// Get details
Intent intent = getIntent();
int year = intent.getIntExtra("year", 1970);
int month = intent.getIntExtra("month", 1);
int day = intent.getIntExtra("day", 1);
dbMain = new PeriodicalDatabase(context);
dbMain.loadCalculatedData();
entry = dbMain.getEntryWithDetails(year, month, day);
// Set header using the entry date
DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.LONG);
((TextView) findViewById(R.id.labelDetailsHeader)).setText(
String.format("%s", dateFormat.format(entry.date.getTime())));
// Set period status
RadioButton buttonPeriodYes = findViewById(R.id.periodYes);
RadioButton buttonPeriodNo = findViewById(R.id.periodNo);
boolean intensityEnabled = false;
switch (entry.type) {
case PERIOD_START: | case PERIOD_CONFIRMED: |
arnowelzel/periodical | app/src/main/java/de/arnowelzel/android/periodical/ListDetailsActivity.java | // Path: app/src/main/java/de/arnowelzel/android/periodical/PeriodicalDatabase.java
// public static class DayEntry {
// final static int EMPTY = 0;
// final static int PERIOD_START = 1;
// final static int PERIOD_CONFIRMED = 2;
// final static int PERIOD_PREDICTED = 3;
// final static int FERTILITY_PREDICTED = 4;
// final static int OVULATION_PREDICTED = 5;
// final static int FERTILITY_FUTURE = 6;
// final static int OVULATION_FUTURE = 7;
// final static int INFERTILE_PREDICTED = 8;
// final static int INFERTILE_FUTURE = 9;
// int type;
// final GregorianCalendarExt date;
// int dayofcycle;
// int intensity;
// String notes;
// List<Integer> symptoms;
//
// /**
// * Construct a new day entry with parameters
// *
// * @param type Entry type (DayEntry.EMPTY, DayEntry.PERIOD_START, DayEntry.PERIOD_CONFIRMED, ...)
// * @param date Entry date
// * @param dayofcycle Day within current cycle (beginning with 1)
// * @param intensity Intensity of the period (1-4)
// */
// DayEntry(int type, GregorianCalendar date, int dayofcycle, int intensity) {
// this.type = type;
// this.date = new GregorianCalendarExt();
// this.date.setTime(date.getTime());
// this.dayofcycle = dayofcycle;
// this.intensity = intensity;
// this.notes = "";
// this.symptoms = new ArrayList<>();
// }
//
// /**
// * Construct a new day entry
// */
// DayEntry() {
// this.type = EMPTY;
// this.date = new GregorianCalendarExt();
// this.dayofcycle = 0;
// this.intensity = 1;
// this.notes = "";
// this.symptoms = new ArrayList<>();
// }
// }
| import java.util.Calendar;
import java.util.Iterator;
import de.arnowelzel.android.periodical.PeriodicalDatabase.DayEntry;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import java.util.ArrayList; | /*
* Periodical list with details activity
* Copyright (C) 2012-2020 Arno Welzel
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.arnowelzel.android.periodical;
/**
* Activity to handle the "List, details" command
*/
public class ListDetailsActivity extends AppCompatActivity implements AdapterView.OnItemClickListener {
/**
* Database for calendar data
*/
private PeriodicalDatabase dbMain;
/**
* Called when activity starts
*/
@SuppressLint("NewApi")
@Override
public void onCreate(Bundle savedInstanceState) {
final Context context = getApplicationContext();
assert context != null;
super.onCreate(savedInstanceState);
// Set up database and string array for the list
dbMain = new PeriodicalDatabase(context);
dbMain.loadRawDataWithDetails();
| // Path: app/src/main/java/de/arnowelzel/android/periodical/PeriodicalDatabase.java
// public static class DayEntry {
// final static int EMPTY = 0;
// final static int PERIOD_START = 1;
// final static int PERIOD_CONFIRMED = 2;
// final static int PERIOD_PREDICTED = 3;
// final static int FERTILITY_PREDICTED = 4;
// final static int OVULATION_PREDICTED = 5;
// final static int FERTILITY_FUTURE = 6;
// final static int OVULATION_FUTURE = 7;
// final static int INFERTILE_PREDICTED = 8;
// final static int INFERTILE_FUTURE = 9;
// int type;
// final GregorianCalendarExt date;
// int dayofcycle;
// int intensity;
// String notes;
// List<Integer> symptoms;
//
// /**
// * Construct a new day entry with parameters
// *
// * @param type Entry type (DayEntry.EMPTY, DayEntry.PERIOD_START, DayEntry.PERIOD_CONFIRMED, ...)
// * @param date Entry date
// * @param dayofcycle Day within current cycle (beginning with 1)
// * @param intensity Intensity of the period (1-4)
// */
// DayEntry(int type, GregorianCalendar date, int dayofcycle, int intensity) {
// this.type = type;
// this.date = new GregorianCalendarExt();
// this.date.setTime(date.getTime());
// this.dayofcycle = dayofcycle;
// this.intensity = intensity;
// this.notes = "";
// this.symptoms = new ArrayList<>();
// }
//
// /**
// * Construct a new day entry
// */
// DayEntry() {
// this.type = EMPTY;
// this.date = new GregorianCalendarExt();
// this.dayofcycle = 0;
// this.intensity = 1;
// this.notes = "";
// this.symptoms = new ArrayList<>();
// }
// }
// Path: app/src/main/java/de/arnowelzel/android/periodical/ListDetailsActivity.java
import java.util.Calendar;
import java.util.Iterator;
import de.arnowelzel.android.periodical.PeriodicalDatabase.DayEntry;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import java.util.ArrayList;
/*
* Periodical list with details activity
* Copyright (C) 2012-2020 Arno Welzel
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.arnowelzel.android.periodical;
/**
* Activity to handle the "List, details" command
*/
public class ListDetailsActivity extends AppCompatActivity implements AdapterView.OnItemClickListener {
/**
* Database for calendar data
*/
private PeriodicalDatabase dbMain;
/**
* Called when activity starts
*/
@SuppressLint("NewApi")
@Override
public void onCreate(Bundle savedInstanceState) {
final Context context = getApplicationContext();
assert context != null;
super.onCreate(savedInstanceState);
// Set up database and string array for the list
dbMain = new PeriodicalDatabase(context);
dbMain.loadRawDataWithDetails();
| ArrayList<DayEntry> dayList = new ArrayList<>(); |
xiaoyaoyou1212/BLE | baseble/src/main/java/com/vise/baseble/common/BleConfig.java | // Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_CONN_TIME = 10000;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_MAX_CONNECT_COUNT = 5;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_OPERATE_TIME = 5000;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_RETRY_COUNT = 3;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_RETRY_INTERVAL = 1000;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_SCAN_REPEAT_INTERVAL = -1;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_SCAN_TIME = 20000;
| import static com.vise.baseble.common.BleConstant.DEFAULT_CONN_TIME;
import static com.vise.baseble.common.BleConstant.DEFAULT_MAX_CONNECT_COUNT;
import static com.vise.baseble.common.BleConstant.DEFAULT_OPERATE_TIME;
import static com.vise.baseble.common.BleConstant.DEFAULT_RETRY_COUNT;
import static com.vise.baseble.common.BleConstant.DEFAULT_RETRY_INTERVAL;
import static com.vise.baseble.common.BleConstant.DEFAULT_SCAN_REPEAT_INTERVAL;
import static com.vise.baseble.common.BleConstant.DEFAULT_SCAN_TIME; | package com.vise.baseble.common;
/**
* @Description: 蓝牙通信相关配置
* @author: <a href="http://xiaoyaoyou1212.360doc.com">DAWI</a>
* @date: 2017/10/16 11:46
*/
public class BleConfig {
private static BleConfig instance;
| // Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_CONN_TIME = 10000;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_MAX_CONNECT_COUNT = 5;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_OPERATE_TIME = 5000;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_RETRY_COUNT = 3;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_RETRY_INTERVAL = 1000;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_SCAN_REPEAT_INTERVAL = -1;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_SCAN_TIME = 20000;
// Path: baseble/src/main/java/com/vise/baseble/common/BleConfig.java
import static com.vise.baseble.common.BleConstant.DEFAULT_CONN_TIME;
import static com.vise.baseble.common.BleConstant.DEFAULT_MAX_CONNECT_COUNT;
import static com.vise.baseble.common.BleConstant.DEFAULT_OPERATE_TIME;
import static com.vise.baseble.common.BleConstant.DEFAULT_RETRY_COUNT;
import static com.vise.baseble.common.BleConstant.DEFAULT_RETRY_INTERVAL;
import static com.vise.baseble.common.BleConstant.DEFAULT_SCAN_REPEAT_INTERVAL;
import static com.vise.baseble.common.BleConstant.DEFAULT_SCAN_TIME;
package com.vise.baseble.common;
/**
* @Description: 蓝牙通信相关配置
* @author: <a href="http://xiaoyaoyou1212.360doc.com">DAWI</a>
* @date: 2017/10/16 11:46
*/
public class BleConfig {
private static BleConfig instance;
| private int scanTimeout = DEFAULT_SCAN_TIME;//扫描超时时间(毫秒) |
xiaoyaoyou1212/BLE | baseble/src/main/java/com/vise/baseble/common/BleConfig.java | // Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_CONN_TIME = 10000;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_MAX_CONNECT_COUNT = 5;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_OPERATE_TIME = 5000;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_RETRY_COUNT = 3;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_RETRY_INTERVAL = 1000;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_SCAN_REPEAT_INTERVAL = -1;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_SCAN_TIME = 20000;
| import static com.vise.baseble.common.BleConstant.DEFAULT_CONN_TIME;
import static com.vise.baseble.common.BleConstant.DEFAULT_MAX_CONNECT_COUNT;
import static com.vise.baseble.common.BleConstant.DEFAULT_OPERATE_TIME;
import static com.vise.baseble.common.BleConstant.DEFAULT_RETRY_COUNT;
import static com.vise.baseble.common.BleConstant.DEFAULT_RETRY_INTERVAL;
import static com.vise.baseble.common.BleConstant.DEFAULT_SCAN_REPEAT_INTERVAL;
import static com.vise.baseble.common.BleConstant.DEFAULT_SCAN_TIME; | package com.vise.baseble.common;
/**
* @Description: 蓝牙通信相关配置
* @author: <a href="http://xiaoyaoyou1212.360doc.com">DAWI</a>
* @date: 2017/10/16 11:46
*/
public class BleConfig {
private static BleConfig instance;
private int scanTimeout = DEFAULT_SCAN_TIME;//扫描超时时间(毫秒) | // Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_CONN_TIME = 10000;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_MAX_CONNECT_COUNT = 5;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_OPERATE_TIME = 5000;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_RETRY_COUNT = 3;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_RETRY_INTERVAL = 1000;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_SCAN_REPEAT_INTERVAL = -1;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_SCAN_TIME = 20000;
// Path: baseble/src/main/java/com/vise/baseble/common/BleConfig.java
import static com.vise.baseble.common.BleConstant.DEFAULT_CONN_TIME;
import static com.vise.baseble.common.BleConstant.DEFAULT_MAX_CONNECT_COUNT;
import static com.vise.baseble.common.BleConstant.DEFAULT_OPERATE_TIME;
import static com.vise.baseble.common.BleConstant.DEFAULT_RETRY_COUNT;
import static com.vise.baseble.common.BleConstant.DEFAULT_RETRY_INTERVAL;
import static com.vise.baseble.common.BleConstant.DEFAULT_SCAN_REPEAT_INTERVAL;
import static com.vise.baseble.common.BleConstant.DEFAULT_SCAN_TIME;
package com.vise.baseble.common;
/**
* @Description: 蓝牙通信相关配置
* @author: <a href="http://xiaoyaoyou1212.360doc.com">DAWI</a>
* @date: 2017/10/16 11:46
*/
public class BleConfig {
private static BleConfig instance;
private int scanTimeout = DEFAULT_SCAN_TIME;//扫描超时时间(毫秒) | private int connectTimeout = DEFAULT_CONN_TIME;//连接超时时间(毫秒) |
xiaoyaoyou1212/BLE | baseble/src/main/java/com/vise/baseble/common/BleConfig.java | // Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_CONN_TIME = 10000;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_MAX_CONNECT_COUNT = 5;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_OPERATE_TIME = 5000;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_RETRY_COUNT = 3;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_RETRY_INTERVAL = 1000;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_SCAN_REPEAT_INTERVAL = -1;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_SCAN_TIME = 20000;
| import static com.vise.baseble.common.BleConstant.DEFAULT_CONN_TIME;
import static com.vise.baseble.common.BleConstant.DEFAULT_MAX_CONNECT_COUNT;
import static com.vise.baseble.common.BleConstant.DEFAULT_OPERATE_TIME;
import static com.vise.baseble.common.BleConstant.DEFAULT_RETRY_COUNT;
import static com.vise.baseble.common.BleConstant.DEFAULT_RETRY_INTERVAL;
import static com.vise.baseble.common.BleConstant.DEFAULT_SCAN_REPEAT_INTERVAL;
import static com.vise.baseble.common.BleConstant.DEFAULT_SCAN_TIME; | package com.vise.baseble.common;
/**
* @Description: 蓝牙通信相关配置
* @author: <a href="http://xiaoyaoyou1212.360doc.com">DAWI</a>
* @date: 2017/10/16 11:46
*/
public class BleConfig {
private static BleConfig instance;
private int scanTimeout = DEFAULT_SCAN_TIME;//扫描超时时间(毫秒)
private int connectTimeout = DEFAULT_CONN_TIME;//连接超时时间(毫秒) | // Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_CONN_TIME = 10000;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_MAX_CONNECT_COUNT = 5;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_OPERATE_TIME = 5000;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_RETRY_COUNT = 3;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_RETRY_INTERVAL = 1000;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_SCAN_REPEAT_INTERVAL = -1;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_SCAN_TIME = 20000;
// Path: baseble/src/main/java/com/vise/baseble/common/BleConfig.java
import static com.vise.baseble.common.BleConstant.DEFAULT_CONN_TIME;
import static com.vise.baseble.common.BleConstant.DEFAULT_MAX_CONNECT_COUNT;
import static com.vise.baseble.common.BleConstant.DEFAULT_OPERATE_TIME;
import static com.vise.baseble.common.BleConstant.DEFAULT_RETRY_COUNT;
import static com.vise.baseble.common.BleConstant.DEFAULT_RETRY_INTERVAL;
import static com.vise.baseble.common.BleConstant.DEFAULT_SCAN_REPEAT_INTERVAL;
import static com.vise.baseble.common.BleConstant.DEFAULT_SCAN_TIME;
package com.vise.baseble.common;
/**
* @Description: 蓝牙通信相关配置
* @author: <a href="http://xiaoyaoyou1212.360doc.com">DAWI</a>
* @date: 2017/10/16 11:46
*/
public class BleConfig {
private static BleConfig instance;
private int scanTimeout = DEFAULT_SCAN_TIME;//扫描超时时间(毫秒)
private int connectTimeout = DEFAULT_CONN_TIME;//连接超时时间(毫秒) | private int operateTimeout = DEFAULT_OPERATE_TIME;//数据操作超时时间(毫秒) |
xiaoyaoyou1212/BLE | baseble/src/main/java/com/vise/baseble/common/BleConfig.java | // Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_CONN_TIME = 10000;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_MAX_CONNECT_COUNT = 5;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_OPERATE_TIME = 5000;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_RETRY_COUNT = 3;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_RETRY_INTERVAL = 1000;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_SCAN_REPEAT_INTERVAL = -1;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_SCAN_TIME = 20000;
| import static com.vise.baseble.common.BleConstant.DEFAULT_CONN_TIME;
import static com.vise.baseble.common.BleConstant.DEFAULT_MAX_CONNECT_COUNT;
import static com.vise.baseble.common.BleConstant.DEFAULT_OPERATE_TIME;
import static com.vise.baseble.common.BleConstant.DEFAULT_RETRY_COUNT;
import static com.vise.baseble.common.BleConstant.DEFAULT_RETRY_INTERVAL;
import static com.vise.baseble.common.BleConstant.DEFAULT_SCAN_REPEAT_INTERVAL;
import static com.vise.baseble.common.BleConstant.DEFAULT_SCAN_TIME; | package com.vise.baseble.common;
/**
* @Description: 蓝牙通信相关配置
* @author: <a href="http://xiaoyaoyou1212.360doc.com">DAWI</a>
* @date: 2017/10/16 11:46
*/
public class BleConfig {
private static BleConfig instance;
private int scanTimeout = DEFAULT_SCAN_TIME;//扫描超时时间(毫秒)
private int connectTimeout = DEFAULT_CONN_TIME;//连接超时时间(毫秒)
private int operateTimeout = DEFAULT_OPERATE_TIME;//数据操作超时时间(毫秒) | // Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_CONN_TIME = 10000;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_MAX_CONNECT_COUNT = 5;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_OPERATE_TIME = 5000;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_RETRY_COUNT = 3;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_RETRY_INTERVAL = 1000;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_SCAN_REPEAT_INTERVAL = -1;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_SCAN_TIME = 20000;
// Path: baseble/src/main/java/com/vise/baseble/common/BleConfig.java
import static com.vise.baseble.common.BleConstant.DEFAULT_CONN_TIME;
import static com.vise.baseble.common.BleConstant.DEFAULT_MAX_CONNECT_COUNT;
import static com.vise.baseble.common.BleConstant.DEFAULT_OPERATE_TIME;
import static com.vise.baseble.common.BleConstant.DEFAULT_RETRY_COUNT;
import static com.vise.baseble.common.BleConstant.DEFAULT_RETRY_INTERVAL;
import static com.vise.baseble.common.BleConstant.DEFAULT_SCAN_REPEAT_INTERVAL;
import static com.vise.baseble.common.BleConstant.DEFAULT_SCAN_TIME;
package com.vise.baseble.common;
/**
* @Description: 蓝牙通信相关配置
* @author: <a href="http://xiaoyaoyou1212.360doc.com">DAWI</a>
* @date: 2017/10/16 11:46
*/
public class BleConfig {
private static BleConfig instance;
private int scanTimeout = DEFAULT_SCAN_TIME;//扫描超时时间(毫秒)
private int connectTimeout = DEFAULT_CONN_TIME;//连接超时时间(毫秒)
private int operateTimeout = DEFAULT_OPERATE_TIME;//数据操作超时时间(毫秒) | private int connectRetryCount = DEFAULT_RETRY_COUNT;//连接重试次数 |
xiaoyaoyou1212/BLE | baseble/src/main/java/com/vise/baseble/common/BleConfig.java | // Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_CONN_TIME = 10000;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_MAX_CONNECT_COUNT = 5;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_OPERATE_TIME = 5000;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_RETRY_COUNT = 3;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_RETRY_INTERVAL = 1000;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_SCAN_REPEAT_INTERVAL = -1;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_SCAN_TIME = 20000;
| import static com.vise.baseble.common.BleConstant.DEFAULT_CONN_TIME;
import static com.vise.baseble.common.BleConstant.DEFAULT_MAX_CONNECT_COUNT;
import static com.vise.baseble.common.BleConstant.DEFAULT_OPERATE_TIME;
import static com.vise.baseble.common.BleConstant.DEFAULT_RETRY_COUNT;
import static com.vise.baseble.common.BleConstant.DEFAULT_RETRY_INTERVAL;
import static com.vise.baseble.common.BleConstant.DEFAULT_SCAN_REPEAT_INTERVAL;
import static com.vise.baseble.common.BleConstant.DEFAULT_SCAN_TIME; | package com.vise.baseble.common;
/**
* @Description: 蓝牙通信相关配置
* @author: <a href="http://xiaoyaoyou1212.360doc.com">DAWI</a>
* @date: 2017/10/16 11:46
*/
public class BleConfig {
private static BleConfig instance;
private int scanTimeout = DEFAULT_SCAN_TIME;//扫描超时时间(毫秒)
private int connectTimeout = DEFAULT_CONN_TIME;//连接超时时间(毫秒)
private int operateTimeout = DEFAULT_OPERATE_TIME;//数据操作超时时间(毫秒)
private int connectRetryCount = DEFAULT_RETRY_COUNT;//连接重试次数 | // Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_CONN_TIME = 10000;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_MAX_CONNECT_COUNT = 5;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_OPERATE_TIME = 5000;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_RETRY_COUNT = 3;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_RETRY_INTERVAL = 1000;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_SCAN_REPEAT_INTERVAL = -1;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_SCAN_TIME = 20000;
// Path: baseble/src/main/java/com/vise/baseble/common/BleConfig.java
import static com.vise.baseble.common.BleConstant.DEFAULT_CONN_TIME;
import static com.vise.baseble.common.BleConstant.DEFAULT_MAX_CONNECT_COUNT;
import static com.vise.baseble.common.BleConstant.DEFAULT_OPERATE_TIME;
import static com.vise.baseble.common.BleConstant.DEFAULT_RETRY_COUNT;
import static com.vise.baseble.common.BleConstant.DEFAULT_RETRY_INTERVAL;
import static com.vise.baseble.common.BleConstant.DEFAULT_SCAN_REPEAT_INTERVAL;
import static com.vise.baseble.common.BleConstant.DEFAULT_SCAN_TIME;
package com.vise.baseble.common;
/**
* @Description: 蓝牙通信相关配置
* @author: <a href="http://xiaoyaoyou1212.360doc.com">DAWI</a>
* @date: 2017/10/16 11:46
*/
public class BleConfig {
private static BleConfig instance;
private int scanTimeout = DEFAULT_SCAN_TIME;//扫描超时时间(毫秒)
private int connectTimeout = DEFAULT_CONN_TIME;//连接超时时间(毫秒)
private int operateTimeout = DEFAULT_OPERATE_TIME;//数据操作超时时间(毫秒)
private int connectRetryCount = DEFAULT_RETRY_COUNT;//连接重试次数 | private int connectRetryInterval = DEFAULT_RETRY_INTERVAL;//连接重试间隔(毫秒) |
xiaoyaoyou1212/BLE | baseble/src/main/java/com/vise/baseble/common/BleConfig.java | // Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_CONN_TIME = 10000;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_MAX_CONNECT_COUNT = 5;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_OPERATE_TIME = 5000;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_RETRY_COUNT = 3;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_RETRY_INTERVAL = 1000;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_SCAN_REPEAT_INTERVAL = -1;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_SCAN_TIME = 20000;
| import static com.vise.baseble.common.BleConstant.DEFAULT_CONN_TIME;
import static com.vise.baseble.common.BleConstant.DEFAULT_MAX_CONNECT_COUNT;
import static com.vise.baseble.common.BleConstant.DEFAULT_OPERATE_TIME;
import static com.vise.baseble.common.BleConstant.DEFAULT_RETRY_COUNT;
import static com.vise.baseble.common.BleConstant.DEFAULT_RETRY_INTERVAL;
import static com.vise.baseble.common.BleConstant.DEFAULT_SCAN_REPEAT_INTERVAL;
import static com.vise.baseble.common.BleConstant.DEFAULT_SCAN_TIME; | package com.vise.baseble.common;
/**
* @Description: 蓝牙通信相关配置
* @author: <a href="http://xiaoyaoyou1212.360doc.com">DAWI</a>
* @date: 2017/10/16 11:46
*/
public class BleConfig {
private static BleConfig instance;
private int scanTimeout = DEFAULT_SCAN_TIME;//扫描超时时间(毫秒)
private int connectTimeout = DEFAULT_CONN_TIME;//连接超时时间(毫秒)
private int operateTimeout = DEFAULT_OPERATE_TIME;//数据操作超时时间(毫秒)
private int connectRetryCount = DEFAULT_RETRY_COUNT;//连接重试次数
private int connectRetryInterval = DEFAULT_RETRY_INTERVAL;//连接重试间隔(毫秒)
private int operateRetryCount = DEFAULT_RETRY_COUNT;//数据操作重试次数
private int operateRetryInterval = DEFAULT_RETRY_INTERVAL;//数据操作重试间隔时间(毫秒) | // Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_CONN_TIME = 10000;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_MAX_CONNECT_COUNT = 5;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_OPERATE_TIME = 5000;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_RETRY_COUNT = 3;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_RETRY_INTERVAL = 1000;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_SCAN_REPEAT_INTERVAL = -1;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_SCAN_TIME = 20000;
// Path: baseble/src/main/java/com/vise/baseble/common/BleConfig.java
import static com.vise.baseble.common.BleConstant.DEFAULT_CONN_TIME;
import static com.vise.baseble.common.BleConstant.DEFAULT_MAX_CONNECT_COUNT;
import static com.vise.baseble.common.BleConstant.DEFAULT_OPERATE_TIME;
import static com.vise.baseble.common.BleConstant.DEFAULT_RETRY_COUNT;
import static com.vise.baseble.common.BleConstant.DEFAULT_RETRY_INTERVAL;
import static com.vise.baseble.common.BleConstant.DEFAULT_SCAN_REPEAT_INTERVAL;
import static com.vise.baseble.common.BleConstant.DEFAULT_SCAN_TIME;
package com.vise.baseble.common;
/**
* @Description: 蓝牙通信相关配置
* @author: <a href="http://xiaoyaoyou1212.360doc.com">DAWI</a>
* @date: 2017/10/16 11:46
*/
public class BleConfig {
private static BleConfig instance;
private int scanTimeout = DEFAULT_SCAN_TIME;//扫描超时时间(毫秒)
private int connectTimeout = DEFAULT_CONN_TIME;//连接超时时间(毫秒)
private int operateTimeout = DEFAULT_OPERATE_TIME;//数据操作超时时间(毫秒)
private int connectRetryCount = DEFAULT_RETRY_COUNT;//连接重试次数
private int connectRetryInterval = DEFAULT_RETRY_INTERVAL;//连接重试间隔(毫秒)
private int operateRetryCount = DEFAULT_RETRY_COUNT;//数据操作重试次数
private int operateRetryInterval = DEFAULT_RETRY_INTERVAL;//数据操作重试间隔时间(毫秒) | private int maxConnectCount = DEFAULT_MAX_CONNECT_COUNT;//最大连接数量 |
xiaoyaoyou1212/BLE | baseble/src/main/java/com/vise/baseble/common/BleConfig.java | // Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_CONN_TIME = 10000;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_MAX_CONNECT_COUNT = 5;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_OPERATE_TIME = 5000;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_RETRY_COUNT = 3;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_RETRY_INTERVAL = 1000;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_SCAN_REPEAT_INTERVAL = -1;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_SCAN_TIME = 20000;
| import static com.vise.baseble.common.BleConstant.DEFAULT_CONN_TIME;
import static com.vise.baseble.common.BleConstant.DEFAULT_MAX_CONNECT_COUNT;
import static com.vise.baseble.common.BleConstant.DEFAULT_OPERATE_TIME;
import static com.vise.baseble.common.BleConstant.DEFAULT_RETRY_COUNT;
import static com.vise.baseble.common.BleConstant.DEFAULT_RETRY_INTERVAL;
import static com.vise.baseble.common.BleConstant.DEFAULT_SCAN_REPEAT_INTERVAL;
import static com.vise.baseble.common.BleConstant.DEFAULT_SCAN_TIME; | package com.vise.baseble.common;
/**
* @Description: 蓝牙通信相关配置
* @author: <a href="http://xiaoyaoyou1212.360doc.com">DAWI</a>
* @date: 2017/10/16 11:46
*/
public class BleConfig {
private static BleConfig instance;
private int scanTimeout = DEFAULT_SCAN_TIME;//扫描超时时间(毫秒)
private int connectTimeout = DEFAULT_CONN_TIME;//连接超时时间(毫秒)
private int operateTimeout = DEFAULT_OPERATE_TIME;//数据操作超时时间(毫秒)
private int connectRetryCount = DEFAULT_RETRY_COUNT;//连接重试次数
private int connectRetryInterval = DEFAULT_RETRY_INTERVAL;//连接重试间隔(毫秒)
private int operateRetryCount = DEFAULT_RETRY_COUNT;//数据操作重试次数
private int operateRetryInterval = DEFAULT_RETRY_INTERVAL;//数据操作重试间隔时间(毫秒)
private int maxConnectCount = DEFAULT_MAX_CONNECT_COUNT;//最大连接数量
//yankee | // Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_CONN_TIME = 10000;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_MAX_CONNECT_COUNT = 5;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_OPERATE_TIME = 5000;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_RETRY_COUNT = 3;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_RETRY_INTERVAL = 1000;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_SCAN_REPEAT_INTERVAL = -1;
//
// Path: baseble/src/main/java/com/vise/baseble/common/BleConstant.java
// public static final int DEFAULT_SCAN_TIME = 20000;
// Path: baseble/src/main/java/com/vise/baseble/common/BleConfig.java
import static com.vise.baseble.common.BleConstant.DEFAULT_CONN_TIME;
import static com.vise.baseble.common.BleConstant.DEFAULT_MAX_CONNECT_COUNT;
import static com.vise.baseble.common.BleConstant.DEFAULT_OPERATE_TIME;
import static com.vise.baseble.common.BleConstant.DEFAULT_RETRY_COUNT;
import static com.vise.baseble.common.BleConstant.DEFAULT_RETRY_INTERVAL;
import static com.vise.baseble.common.BleConstant.DEFAULT_SCAN_REPEAT_INTERVAL;
import static com.vise.baseble.common.BleConstant.DEFAULT_SCAN_TIME;
package com.vise.baseble.common;
/**
* @Description: 蓝牙通信相关配置
* @author: <a href="http://xiaoyaoyou1212.360doc.com">DAWI</a>
* @date: 2017/10/16 11:46
*/
public class BleConfig {
private static BleConfig instance;
private int scanTimeout = DEFAULT_SCAN_TIME;//扫描超时时间(毫秒)
private int connectTimeout = DEFAULT_CONN_TIME;//连接超时时间(毫秒)
private int operateTimeout = DEFAULT_OPERATE_TIME;//数据操作超时时间(毫秒)
private int connectRetryCount = DEFAULT_RETRY_COUNT;//连接重试次数
private int connectRetryInterval = DEFAULT_RETRY_INTERVAL;//连接重试间隔(毫秒)
private int operateRetryCount = DEFAULT_RETRY_COUNT;//数据操作重试次数
private int operateRetryInterval = DEFAULT_RETRY_INTERVAL;//数据操作重试间隔时间(毫秒)
private int maxConnectCount = DEFAULT_MAX_CONNECT_COUNT;//最大连接数量
//yankee | private int scanRepeatInterval = DEFAULT_SCAN_REPEAT_INTERVAL;//每隔X时间重复扫描 (毫秒) |
xiaoyaoyou1212/BLE | baseble/src/main/java/com/vise/baseble/exception/OtherException.java | // Path: baseble/src/main/java/com/vise/baseble/common/BleExceptionCode.java
// public enum BleExceptionCode {
// TIMEOUT, //超时
// CONNECT_ERR, //连接异常
// GATT_ERR, //GATT异常
// INITIATED_ERR, //初始化异常
// OTHER_ERR //其他异常
// }
| import com.vise.baseble.common.BleExceptionCode; | package com.vise.baseble.exception;
/**
* @Description: 其他异常
* @author: <a href="http://www.xiaoyaoyou1212.com">DAWI</a>
* @date: 16/8/14 10:32.
*/
public class OtherException extends BleException {
public OtherException(String description) { | // Path: baseble/src/main/java/com/vise/baseble/common/BleExceptionCode.java
// public enum BleExceptionCode {
// TIMEOUT, //超时
// CONNECT_ERR, //连接异常
// GATT_ERR, //GATT异常
// INITIATED_ERR, //初始化异常
// OTHER_ERR //其他异常
// }
// Path: baseble/src/main/java/com/vise/baseble/exception/OtherException.java
import com.vise.baseble.common.BleExceptionCode;
package com.vise.baseble.exception;
/**
* @Description: 其他异常
* @author: <a href="http://www.xiaoyaoyou1212.com">DAWI</a>
* @date: 16/8/14 10:32.
*/
public class OtherException extends BleException {
public OtherException(String description) { | super(BleExceptionCode.OTHER_ERR, description); |
xiaoyaoyou1212/BLE | newapp/src/main/java/com/vise/bledemo/event/ScanEvent.java | // Path: baseble/src/main/java/com/vise/baseble/model/BluetoothLeDeviceStore.java
// public class BluetoothLeDeviceStore {
//
// private final Map<String, BluetoothLeDevice> mDeviceMap;
//
// public BluetoothLeDeviceStore() {
// mDeviceMap = new HashMap<>();
// }
//
// public void addDevice(BluetoothLeDevice device) {
// if (device == null) {
// return;
// }
// if (mDeviceMap.containsKey(device.getAddress())) {
// mDeviceMap.get(device.getAddress()).updateRssiReading(device.getTimestamp(), device.getRssi());
// } else {
// mDeviceMap.put(device.getAddress(), device);
// }
// }
//
// public void removeDevice(BluetoothLeDevice device) {
// if (device == null) {
// return;
// }
// if (mDeviceMap.containsKey(device.getAddress())) {
// mDeviceMap.remove(device.getAddress());
// }
// }
//
// public void clear() {
// mDeviceMap.clear();
// }
//
// public Map<String, BluetoothLeDevice> getDeviceMap() {
// return mDeviceMap;
// }
//
// public List<BluetoothLeDevice> getDeviceList() {
// final List<BluetoothLeDevice> methodResult = new ArrayList<>(mDeviceMap.values());
//
// Collections.sort(methodResult, new Comparator<BluetoothLeDevice>() {
//
// @Override
// public int compare(final BluetoothLeDevice arg0, final BluetoothLeDevice arg1) {
// return arg0.getAddress().compareToIgnoreCase(arg1.getAddress());
// }
// });
//
// return methodResult;
// }
//
// @Override
// public String toString() {
// return "BluetoothLeDeviceStore{" +
// "DeviceList=" + getDeviceList() +
// '}';
// }
// }
| import com.vise.baseble.model.BluetoothLeDeviceStore;
import com.vise.xsnow.event.IEvent; | package com.vise.bledemo.event;
public class ScanEvent implements IEvent {
private boolean isScanTimeout;
private boolean isScanFinish; | // Path: baseble/src/main/java/com/vise/baseble/model/BluetoothLeDeviceStore.java
// public class BluetoothLeDeviceStore {
//
// private final Map<String, BluetoothLeDevice> mDeviceMap;
//
// public BluetoothLeDeviceStore() {
// mDeviceMap = new HashMap<>();
// }
//
// public void addDevice(BluetoothLeDevice device) {
// if (device == null) {
// return;
// }
// if (mDeviceMap.containsKey(device.getAddress())) {
// mDeviceMap.get(device.getAddress()).updateRssiReading(device.getTimestamp(), device.getRssi());
// } else {
// mDeviceMap.put(device.getAddress(), device);
// }
// }
//
// public void removeDevice(BluetoothLeDevice device) {
// if (device == null) {
// return;
// }
// if (mDeviceMap.containsKey(device.getAddress())) {
// mDeviceMap.remove(device.getAddress());
// }
// }
//
// public void clear() {
// mDeviceMap.clear();
// }
//
// public Map<String, BluetoothLeDevice> getDeviceMap() {
// return mDeviceMap;
// }
//
// public List<BluetoothLeDevice> getDeviceList() {
// final List<BluetoothLeDevice> methodResult = new ArrayList<>(mDeviceMap.values());
//
// Collections.sort(methodResult, new Comparator<BluetoothLeDevice>() {
//
// @Override
// public int compare(final BluetoothLeDevice arg0, final BluetoothLeDevice arg1) {
// return arg0.getAddress().compareToIgnoreCase(arg1.getAddress());
// }
// });
//
// return methodResult;
// }
//
// @Override
// public String toString() {
// return "BluetoothLeDeviceStore{" +
// "DeviceList=" + getDeviceList() +
// '}';
// }
// }
// Path: newapp/src/main/java/com/vise/bledemo/event/ScanEvent.java
import com.vise.baseble.model.BluetoothLeDeviceStore;
import com.vise.xsnow.event.IEvent;
package com.vise.bledemo.event;
public class ScanEvent implements IEvent {
private boolean isScanTimeout;
private boolean isScanFinish; | private BluetoothLeDeviceStore bluetoothLeDeviceStore; |
xiaoyaoyou1212/BLE | baseble/src/main/java/com/vise/baseble/exception/handler/DefaultBleExceptionHandler.java | // Path: baseble/src/main/java/com/vise/baseble/exception/ConnectException.java
// public class ConnectException extends BleException {
// private BluetoothGatt bluetoothGatt;
// private int gattStatus;
//
// public ConnectException(BluetoothGatt bluetoothGatt, int gattStatus) {
// super(BleExceptionCode.CONNECT_ERR, "Connect Exception Occurred! ");
// this.bluetoothGatt = bluetoothGatt;
// this.gattStatus = gattStatus;
// }
//
// public int getGattStatus() {
// return gattStatus;
// }
//
// public ConnectException setGattStatus(int gattStatus) {
// this.gattStatus = gattStatus;
// return this;
// }
//
// public BluetoothGatt getBluetoothGatt() {
// return bluetoothGatt;
// }
//
// public ConnectException setBluetoothGatt(BluetoothGatt bluetoothGatt) {
// this.bluetoothGatt = bluetoothGatt;
// return this;
// }
//
// @Override
// public String toString() {
// return "ConnectException{" +
// "gattStatus=" + gattStatus +
// ", bluetoothGatt=" + bluetoothGatt +
// "} " + super.toString();
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/GattException.java
// public class GattException extends BleException {
// private int gattStatus;
//
// public GattException(int gattStatus) {
// super(BleExceptionCode.GATT_ERR, "Gatt Exception Occurred! ");
// this.gattStatus = gattStatus;
// }
//
// public int getGattStatus() {
// return gattStatus;
// }
//
// public GattException setGattStatus(int gattStatus) {
// this.gattStatus = gattStatus;
// return this;
// }
//
// @Override
// public String toString() {
// return "GattException{" +
// "gattStatus=" + gattStatus +
// '}' + super.toString();
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/InitiatedException.java
// public class InitiatedException extends BleException {
// public InitiatedException() {
// super(BleExceptionCode.INITIATED_ERR, "Initiated Exception Occurred! ");
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/OtherException.java
// public class OtherException extends BleException {
// public OtherException(String description) {
// super(BleExceptionCode.OTHER_ERR, description);
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/TimeoutException.java
// public class TimeoutException extends BleException {
// public TimeoutException() {
// super(BleExceptionCode.TIMEOUT, "Timeout Exception Occurred! ");
// }
// }
| import com.vise.baseble.exception.ConnectException;
import com.vise.baseble.exception.GattException;
import com.vise.baseble.exception.InitiatedException;
import com.vise.baseble.exception.OtherException;
import com.vise.baseble.exception.TimeoutException;
import com.vise.log.ViseLog; | package com.vise.baseble.exception.handler;
/**
* @Description: 异常默认处理
* @author: <a href="http://www.xiaoyaoyou1212.com">DAWI</a>
* @date: 16/8/14 10:35.
*/
public class DefaultBleExceptionHandler extends BleExceptionHandler {
@Override | // Path: baseble/src/main/java/com/vise/baseble/exception/ConnectException.java
// public class ConnectException extends BleException {
// private BluetoothGatt bluetoothGatt;
// private int gattStatus;
//
// public ConnectException(BluetoothGatt bluetoothGatt, int gattStatus) {
// super(BleExceptionCode.CONNECT_ERR, "Connect Exception Occurred! ");
// this.bluetoothGatt = bluetoothGatt;
// this.gattStatus = gattStatus;
// }
//
// public int getGattStatus() {
// return gattStatus;
// }
//
// public ConnectException setGattStatus(int gattStatus) {
// this.gattStatus = gattStatus;
// return this;
// }
//
// public BluetoothGatt getBluetoothGatt() {
// return bluetoothGatt;
// }
//
// public ConnectException setBluetoothGatt(BluetoothGatt bluetoothGatt) {
// this.bluetoothGatt = bluetoothGatt;
// return this;
// }
//
// @Override
// public String toString() {
// return "ConnectException{" +
// "gattStatus=" + gattStatus +
// ", bluetoothGatt=" + bluetoothGatt +
// "} " + super.toString();
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/GattException.java
// public class GattException extends BleException {
// private int gattStatus;
//
// public GattException(int gattStatus) {
// super(BleExceptionCode.GATT_ERR, "Gatt Exception Occurred! ");
// this.gattStatus = gattStatus;
// }
//
// public int getGattStatus() {
// return gattStatus;
// }
//
// public GattException setGattStatus(int gattStatus) {
// this.gattStatus = gattStatus;
// return this;
// }
//
// @Override
// public String toString() {
// return "GattException{" +
// "gattStatus=" + gattStatus +
// '}' + super.toString();
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/InitiatedException.java
// public class InitiatedException extends BleException {
// public InitiatedException() {
// super(BleExceptionCode.INITIATED_ERR, "Initiated Exception Occurred! ");
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/OtherException.java
// public class OtherException extends BleException {
// public OtherException(String description) {
// super(BleExceptionCode.OTHER_ERR, description);
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/TimeoutException.java
// public class TimeoutException extends BleException {
// public TimeoutException() {
// super(BleExceptionCode.TIMEOUT, "Timeout Exception Occurred! ");
// }
// }
// Path: baseble/src/main/java/com/vise/baseble/exception/handler/DefaultBleExceptionHandler.java
import com.vise.baseble.exception.ConnectException;
import com.vise.baseble.exception.GattException;
import com.vise.baseble.exception.InitiatedException;
import com.vise.baseble.exception.OtherException;
import com.vise.baseble.exception.TimeoutException;
import com.vise.log.ViseLog;
package com.vise.baseble.exception.handler;
/**
* @Description: 异常默认处理
* @author: <a href="http://www.xiaoyaoyou1212.com">DAWI</a>
* @date: 16/8/14 10:35.
*/
public class DefaultBleExceptionHandler extends BleExceptionHandler {
@Override | protected void onConnectException(ConnectException e) { |
xiaoyaoyou1212/BLE | baseble/src/main/java/com/vise/baseble/exception/handler/DefaultBleExceptionHandler.java | // Path: baseble/src/main/java/com/vise/baseble/exception/ConnectException.java
// public class ConnectException extends BleException {
// private BluetoothGatt bluetoothGatt;
// private int gattStatus;
//
// public ConnectException(BluetoothGatt bluetoothGatt, int gattStatus) {
// super(BleExceptionCode.CONNECT_ERR, "Connect Exception Occurred! ");
// this.bluetoothGatt = bluetoothGatt;
// this.gattStatus = gattStatus;
// }
//
// public int getGattStatus() {
// return gattStatus;
// }
//
// public ConnectException setGattStatus(int gattStatus) {
// this.gattStatus = gattStatus;
// return this;
// }
//
// public BluetoothGatt getBluetoothGatt() {
// return bluetoothGatt;
// }
//
// public ConnectException setBluetoothGatt(BluetoothGatt bluetoothGatt) {
// this.bluetoothGatt = bluetoothGatt;
// return this;
// }
//
// @Override
// public String toString() {
// return "ConnectException{" +
// "gattStatus=" + gattStatus +
// ", bluetoothGatt=" + bluetoothGatt +
// "} " + super.toString();
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/GattException.java
// public class GattException extends BleException {
// private int gattStatus;
//
// public GattException(int gattStatus) {
// super(BleExceptionCode.GATT_ERR, "Gatt Exception Occurred! ");
// this.gattStatus = gattStatus;
// }
//
// public int getGattStatus() {
// return gattStatus;
// }
//
// public GattException setGattStatus(int gattStatus) {
// this.gattStatus = gattStatus;
// return this;
// }
//
// @Override
// public String toString() {
// return "GattException{" +
// "gattStatus=" + gattStatus +
// '}' + super.toString();
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/InitiatedException.java
// public class InitiatedException extends BleException {
// public InitiatedException() {
// super(BleExceptionCode.INITIATED_ERR, "Initiated Exception Occurred! ");
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/OtherException.java
// public class OtherException extends BleException {
// public OtherException(String description) {
// super(BleExceptionCode.OTHER_ERR, description);
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/TimeoutException.java
// public class TimeoutException extends BleException {
// public TimeoutException() {
// super(BleExceptionCode.TIMEOUT, "Timeout Exception Occurred! ");
// }
// }
| import com.vise.baseble.exception.ConnectException;
import com.vise.baseble.exception.GattException;
import com.vise.baseble.exception.InitiatedException;
import com.vise.baseble.exception.OtherException;
import com.vise.baseble.exception.TimeoutException;
import com.vise.log.ViseLog; | package com.vise.baseble.exception.handler;
/**
* @Description: 异常默认处理
* @author: <a href="http://www.xiaoyaoyou1212.com">DAWI</a>
* @date: 16/8/14 10:35.
*/
public class DefaultBleExceptionHandler extends BleExceptionHandler {
@Override
protected void onConnectException(ConnectException e) {
ViseLog.e(e.getDescription());
}
@Override | // Path: baseble/src/main/java/com/vise/baseble/exception/ConnectException.java
// public class ConnectException extends BleException {
// private BluetoothGatt bluetoothGatt;
// private int gattStatus;
//
// public ConnectException(BluetoothGatt bluetoothGatt, int gattStatus) {
// super(BleExceptionCode.CONNECT_ERR, "Connect Exception Occurred! ");
// this.bluetoothGatt = bluetoothGatt;
// this.gattStatus = gattStatus;
// }
//
// public int getGattStatus() {
// return gattStatus;
// }
//
// public ConnectException setGattStatus(int gattStatus) {
// this.gattStatus = gattStatus;
// return this;
// }
//
// public BluetoothGatt getBluetoothGatt() {
// return bluetoothGatt;
// }
//
// public ConnectException setBluetoothGatt(BluetoothGatt bluetoothGatt) {
// this.bluetoothGatt = bluetoothGatt;
// return this;
// }
//
// @Override
// public String toString() {
// return "ConnectException{" +
// "gattStatus=" + gattStatus +
// ", bluetoothGatt=" + bluetoothGatt +
// "} " + super.toString();
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/GattException.java
// public class GattException extends BleException {
// private int gattStatus;
//
// public GattException(int gattStatus) {
// super(BleExceptionCode.GATT_ERR, "Gatt Exception Occurred! ");
// this.gattStatus = gattStatus;
// }
//
// public int getGattStatus() {
// return gattStatus;
// }
//
// public GattException setGattStatus(int gattStatus) {
// this.gattStatus = gattStatus;
// return this;
// }
//
// @Override
// public String toString() {
// return "GattException{" +
// "gattStatus=" + gattStatus +
// '}' + super.toString();
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/InitiatedException.java
// public class InitiatedException extends BleException {
// public InitiatedException() {
// super(BleExceptionCode.INITIATED_ERR, "Initiated Exception Occurred! ");
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/OtherException.java
// public class OtherException extends BleException {
// public OtherException(String description) {
// super(BleExceptionCode.OTHER_ERR, description);
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/TimeoutException.java
// public class TimeoutException extends BleException {
// public TimeoutException() {
// super(BleExceptionCode.TIMEOUT, "Timeout Exception Occurred! ");
// }
// }
// Path: baseble/src/main/java/com/vise/baseble/exception/handler/DefaultBleExceptionHandler.java
import com.vise.baseble.exception.ConnectException;
import com.vise.baseble.exception.GattException;
import com.vise.baseble.exception.InitiatedException;
import com.vise.baseble.exception.OtherException;
import com.vise.baseble.exception.TimeoutException;
import com.vise.log.ViseLog;
package com.vise.baseble.exception.handler;
/**
* @Description: 异常默认处理
* @author: <a href="http://www.xiaoyaoyou1212.com">DAWI</a>
* @date: 16/8/14 10:35.
*/
public class DefaultBleExceptionHandler extends BleExceptionHandler {
@Override
protected void onConnectException(ConnectException e) {
ViseLog.e(e.getDescription());
}
@Override | protected void onGattException(GattException e) { |
xiaoyaoyou1212/BLE | baseble/src/main/java/com/vise/baseble/exception/handler/DefaultBleExceptionHandler.java | // Path: baseble/src/main/java/com/vise/baseble/exception/ConnectException.java
// public class ConnectException extends BleException {
// private BluetoothGatt bluetoothGatt;
// private int gattStatus;
//
// public ConnectException(BluetoothGatt bluetoothGatt, int gattStatus) {
// super(BleExceptionCode.CONNECT_ERR, "Connect Exception Occurred! ");
// this.bluetoothGatt = bluetoothGatt;
// this.gattStatus = gattStatus;
// }
//
// public int getGattStatus() {
// return gattStatus;
// }
//
// public ConnectException setGattStatus(int gattStatus) {
// this.gattStatus = gattStatus;
// return this;
// }
//
// public BluetoothGatt getBluetoothGatt() {
// return bluetoothGatt;
// }
//
// public ConnectException setBluetoothGatt(BluetoothGatt bluetoothGatt) {
// this.bluetoothGatt = bluetoothGatt;
// return this;
// }
//
// @Override
// public String toString() {
// return "ConnectException{" +
// "gattStatus=" + gattStatus +
// ", bluetoothGatt=" + bluetoothGatt +
// "} " + super.toString();
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/GattException.java
// public class GattException extends BleException {
// private int gattStatus;
//
// public GattException(int gattStatus) {
// super(BleExceptionCode.GATT_ERR, "Gatt Exception Occurred! ");
// this.gattStatus = gattStatus;
// }
//
// public int getGattStatus() {
// return gattStatus;
// }
//
// public GattException setGattStatus(int gattStatus) {
// this.gattStatus = gattStatus;
// return this;
// }
//
// @Override
// public String toString() {
// return "GattException{" +
// "gattStatus=" + gattStatus +
// '}' + super.toString();
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/InitiatedException.java
// public class InitiatedException extends BleException {
// public InitiatedException() {
// super(BleExceptionCode.INITIATED_ERR, "Initiated Exception Occurred! ");
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/OtherException.java
// public class OtherException extends BleException {
// public OtherException(String description) {
// super(BleExceptionCode.OTHER_ERR, description);
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/TimeoutException.java
// public class TimeoutException extends BleException {
// public TimeoutException() {
// super(BleExceptionCode.TIMEOUT, "Timeout Exception Occurred! ");
// }
// }
| import com.vise.baseble.exception.ConnectException;
import com.vise.baseble.exception.GattException;
import com.vise.baseble.exception.InitiatedException;
import com.vise.baseble.exception.OtherException;
import com.vise.baseble.exception.TimeoutException;
import com.vise.log.ViseLog; | package com.vise.baseble.exception.handler;
/**
* @Description: 异常默认处理
* @author: <a href="http://www.xiaoyaoyou1212.com">DAWI</a>
* @date: 16/8/14 10:35.
*/
public class DefaultBleExceptionHandler extends BleExceptionHandler {
@Override
protected void onConnectException(ConnectException e) {
ViseLog.e(e.getDescription());
}
@Override
protected void onGattException(GattException e) {
ViseLog.e(e.getDescription());
}
@Override | // Path: baseble/src/main/java/com/vise/baseble/exception/ConnectException.java
// public class ConnectException extends BleException {
// private BluetoothGatt bluetoothGatt;
// private int gattStatus;
//
// public ConnectException(BluetoothGatt bluetoothGatt, int gattStatus) {
// super(BleExceptionCode.CONNECT_ERR, "Connect Exception Occurred! ");
// this.bluetoothGatt = bluetoothGatt;
// this.gattStatus = gattStatus;
// }
//
// public int getGattStatus() {
// return gattStatus;
// }
//
// public ConnectException setGattStatus(int gattStatus) {
// this.gattStatus = gattStatus;
// return this;
// }
//
// public BluetoothGatt getBluetoothGatt() {
// return bluetoothGatt;
// }
//
// public ConnectException setBluetoothGatt(BluetoothGatt bluetoothGatt) {
// this.bluetoothGatt = bluetoothGatt;
// return this;
// }
//
// @Override
// public String toString() {
// return "ConnectException{" +
// "gattStatus=" + gattStatus +
// ", bluetoothGatt=" + bluetoothGatt +
// "} " + super.toString();
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/GattException.java
// public class GattException extends BleException {
// private int gattStatus;
//
// public GattException(int gattStatus) {
// super(BleExceptionCode.GATT_ERR, "Gatt Exception Occurred! ");
// this.gattStatus = gattStatus;
// }
//
// public int getGattStatus() {
// return gattStatus;
// }
//
// public GattException setGattStatus(int gattStatus) {
// this.gattStatus = gattStatus;
// return this;
// }
//
// @Override
// public String toString() {
// return "GattException{" +
// "gattStatus=" + gattStatus +
// '}' + super.toString();
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/InitiatedException.java
// public class InitiatedException extends BleException {
// public InitiatedException() {
// super(BleExceptionCode.INITIATED_ERR, "Initiated Exception Occurred! ");
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/OtherException.java
// public class OtherException extends BleException {
// public OtherException(String description) {
// super(BleExceptionCode.OTHER_ERR, description);
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/TimeoutException.java
// public class TimeoutException extends BleException {
// public TimeoutException() {
// super(BleExceptionCode.TIMEOUT, "Timeout Exception Occurred! ");
// }
// }
// Path: baseble/src/main/java/com/vise/baseble/exception/handler/DefaultBleExceptionHandler.java
import com.vise.baseble.exception.ConnectException;
import com.vise.baseble.exception.GattException;
import com.vise.baseble.exception.InitiatedException;
import com.vise.baseble.exception.OtherException;
import com.vise.baseble.exception.TimeoutException;
import com.vise.log.ViseLog;
package com.vise.baseble.exception.handler;
/**
* @Description: 异常默认处理
* @author: <a href="http://www.xiaoyaoyou1212.com">DAWI</a>
* @date: 16/8/14 10:35.
*/
public class DefaultBleExceptionHandler extends BleExceptionHandler {
@Override
protected void onConnectException(ConnectException e) {
ViseLog.e(e.getDescription());
}
@Override
protected void onGattException(GattException e) {
ViseLog.e(e.getDescription());
}
@Override | protected void onTimeoutException(TimeoutException e) { |
xiaoyaoyou1212/BLE | baseble/src/main/java/com/vise/baseble/exception/handler/DefaultBleExceptionHandler.java | // Path: baseble/src/main/java/com/vise/baseble/exception/ConnectException.java
// public class ConnectException extends BleException {
// private BluetoothGatt bluetoothGatt;
// private int gattStatus;
//
// public ConnectException(BluetoothGatt bluetoothGatt, int gattStatus) {
// super(BleExceptionCode.CONNECT_ERR, "Connect Exception Occurred! ");
// this.bluetoothGatt = bluetoothGatt;
// this.gattStatus = gattStatus;
// }
//
// public int getGattStatus() {
// return gattStatus;
// }
//
// public ConnectException setGattStatus(int gattStatus) {
// this.gattStatus = gattStatus;
// return this;
// }
//
// public BluetoothGatt getBluetoothGatt() {
// return bluetoothGatt;
// }
//
// public ConnectException setBluetoothGatt(BluetoothGatt bluetoothGatt) {
// this.bluetoothGatt = bluetoothGatt;
// return this;
// }
//
// @Override
// public String toString() {
// return "ConnectException{" +
// "gattStatus=" + gattStatus +
// ", bluetoothGatt=" + bluetoothGatt +
// "} " + super.toString();
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/GattException.java
// public class GattException extends BleException {
// private int gattStatus;
//
// public GattException(int gattStatus) {
// super(BleExceptionCode.GATT_ERR, "Gatt Exception Occurred! ");
// this.gattStatus = gattStatus;
// }
//
// public int getGattStatus() {
// return gattStatus;
// }
//
// public GattException setGattStatus(int gattStatus) {
// this.gattStatus = gattStatus;
// return this;
// }
//
// @Override
// public String toString() {
// return "GattException{" +
// "gattStatus=" + gattStatus +
// '}' + super.toString();
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/InitiatedException.java
// public class InitiatedException extends BleException {
// public InitiatedException() {
// super(BleExceptionCode.INITIATED_ERR, "Initiated Exception Occurred! ");
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/OtherException.java
// public class OtherException extends BleException {
// public OtherException(String description) {
// super(BleExceptionCode.OTHER_ERR, description);
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/TimeoutException.java
// public class TimeoutException extends BleException {
// public TimeoutException() {
// super(BleExceptionCode.TIMEOUT, "Timeout Exception Occurred! ");
// }
// }
| import com.vise.baseble.exception.ConnectException;
import com.vise.baseble.exception.GattException;
import com.vise.baseble.exception.InitiatedException;
import com.vise.baseble.exception.OtherException;
import com.vise.baseble.exception.TimeoutException;
import com.vise.log.ViseLog; | package com.vise.baseble.exception.handler;
/**
* @Description: 异常默认处理
* @author: <a href="http://www.xiaoyaoyou1212.com">DAWI</a>
* @date: 16/8/14 10:35.
*/
public class DefaultBleExceptionHandler extends BleExceptionHandler {
@Override
protected void onConnectException(ConnectException e) {
ViseLog.e(e.getDescription());
}
@Override
protected void onGattException(GattException e) {
ViseLog.e(e.getDescription());
}
@Override
protected void onTimeoutException(TimeoutException e) {
ViseLog.e(e.getDescription());
}
@Override | // Path: baseble/src/main/java/com/vise/baseble/exception/ConnectException.java
// public class ConnectException extends BleException {
// private BluetoothGatt bluetoothGatt;
// private int gattStatus;
//
// public ConnectException(BluetoothGatt bluetoothGatt, int gattStatus) {
// super(BleExceptionCode.CONNECT_ERR, "Connect Exception Occurred! ");
// this.bluetoothGatt = bluetoothGatt;
// this.gattStatus = gattStatus;
// }
//
// public int getGattStatus() {
// return gattStatus;
// }
//
// public ConnectException setGattStatus(int gattStatus) {
// this.gattStatus = gattStatus;
// return this;
// }
//
// public BluetoothGatt getBluetoothGatt() {
// return bluetoothGatt;
// }
//
// public ConnectException setBluetoothGatt(BluetoothGatt bluetoothGatt) {
// this.bluetoothGatt = bluetoothGatt;
// return this;
// }
//
// @Override
// public String toString() {
// return "ConnectException{" +
// "gattStatus=" + gattStatus +
// ", bluetoothGatt=" + bluetoothGatt +
// "} " + super.toString();
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/GattException.java
// public class GattException extends BleException {
// private int gattStatus;
//
// public GattException(int gattStatus) {
// super(BleExceptionCode.GATT_ERR, "Gatt Exception Occurred! ");
// this.gattStatus = gattStatus;
// }
//
// public int getGattStatus() {
// return gattStatus;
// }
//
// public GattException setGattStatus(int gattStatus) {
// this.gattStatus = gattStatus;
// return this;
// }
//
// @Override
// public String toString() {
// return "GattException{" +
// "gattStatus=" + gattStatus +
// '}' + super.toString();
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/InitiatedException.java
// public class InitiatedException extends BleException {
// public InitiatedException() {
// super(BleExceptionCode.INITIATED_ERR, "Initiated Exception Occurred! ");
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/OtherException.java
// public class OtherException extends BleException {
// public OtherException(String description) {
// super(BleExceptionCode.OTHER_ERR, description);
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/TimeoutException.java
// public class TimeoutException extends BleException {
// public TimeoutException() {
// super(BleExceptionCode.TIMEOUT, "Timeout Exception Occurred! ");
// }
// }
// Path: baseble/src/main/java/com/vise/baseble/exception/handler/DefaultBleExceptionHandler.java
import com.vise.baseble.exception.ConnectException;
import com.vise.baseble.exception.GattException;
import com.vise.baseble.exception.InitiatedException;
import com.vise.baseble.exception.OtherException;
import com.vise.baseble.exception.TimeoutException;
import com.vise.log.ViseLog;
package com.vise.baseble.exception.handler;
/**
* @Description: 异常默认处理
* @author: <a href="http://www.xiaoyaoyou1212.com">DAWI</a>
* @date: 16/8/14 10:35.
*/
public class DefaultBleExceptionHandler extends BleExceptionHandler {
@Override
protected void onConnectException(ConnectException e) {
ViseLog.e(e.getDescription());
}
@Override
protected void onGattException(GattException e) {
ViseLog.e(e.getDescription());
}
@Override
protected void onTimeoutException(TimeoutException e) {
ViseLog.e(e.getDescription());
}
@Override | protected void onInitiatedException(InitiatedException e) { |
xiaoyaoyou1212/BLE | baseble/src/main/java/com/vise/baseble/exception/handler/DefaultBleExceptionHandler.java | // Path: baseble/src/main/java/com/vise/baseble/exception/ConnectException.java
// public class ConnectException extends BleException {
// private BluetoothGatt bluetoothGatt;
// private int gattStatus;
//
// public ConnectException(BluetoothGatt bluetoothGatt, int gattStatus) {
// super(BleExceptionCode.CONNECT_ERR, "Connect Exception Occurred! ");
// this.bluetoothGatt = bluetoothGatt;
// this.gattStatus = gattStatus;
// }
//
// public int getGattStatus() {
// return gattStatus;
// }
//
// public ConnectException setGattStatus(int gattStatus) {
// this.gattStatus = gattStatus;
// return this;
// }
//
// public BluetoothGatt getBluetoothGatt() {
// return bluetoothGatt;
// }
//
// public ConnectException setBluetoothGatt(BluetoothGatt bluetoothGatt) {
// this.bluetoothGatt = bluetoothGatt;
// return this;
// }
//
// @Override
// public String toString() {
// return "ConnectException{" +
// "gattStatus=" + gattStatus +
// ", bluetoothGatt=" + bluetoothGatt +
// "} " + super.toString();
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/GattException.java
// public class GattException extends BleException {
// private int gattStatus;
//
// public GattException(int gattStatus) {
// super(BleExceptionCode.GATT_ERR, "Gatt Exception Occurred! ");
// this.gattStatus = gattStatus;
// }
//
// public int getGattStatus() {
// return gattStatus;
// }
//
// public GattException setGattStatus(int gattStatus) {
// this.gattStatus = gattStatus;
// return this;
// }
//
// @Override
// public String toString() {
// return "GattException{" +
// "gattStatus=" + gattStatus +
// '}' + super.toString();
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/InitiatedException.java
// public class InitiatedException extends BleException {
// public InitiatedException() {
// super(BleExceptionCode.INITIATED_ERR, "Initiated Exception Occurred! ");
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/OtherException.java
// public class OtherException extends BleException {
// public OtherException(String description) {
// super(BleExceptionCode.OTHER_ERR, description);
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/TimeoutException.java
// public class TimeoutException extends BleException {
// public TimeoutException() {
// super(BleExceptionCode.TIMEOUT, "Timeout Exception Occurred! ");
// }
// }
| import com.vise.baseble.exception.ConnectException;
import com.vise.baseble.exception.GattException;
import com.vise.baseble.exception.InitiatedException;
import com.vise.baseble.exception.OtherException;
import com.vise.baseble.exception.TimeoutException;
import com.vise.log.ViseLog; | package com.vise.baseble.exception.handler;
/**
* @Description: 异常默认处理
* @author: <a href="http://www.xiaoyaoyou1212.com">DAWI</a>
* @date: 16/8/14 10:35.
*/
public class DefaultBleExceptionHandler extends BleExceptionHandler {
@Override
protected void onConnectException(ConnectException e) {
ViseLog.e(e.getDescription());
}
@Override
protected void onGattException(GattException e) {
ViseLog.e(e.getDescription());
}
@Override
protected void onTimeoutException(TimeoutException e) {
ViseLog.e(e.getDescription());
}
@Override
protected void onInitiatedException(InitiatedException e) {
ViseLog.e(e.getDescription());
}
@Override | // Path: baseble/src/main/java/com/vise/baseble/exception/ConnectException.java
// public class ConnectException extends BleException {
// private BluetoothGatt bluetoothGatt;
// private int gattStatus;
//
// public ConnectException(BluetoothGatt bluetoothGatt, int gattStatus) {
// super(BleExceptionCode.CONNECT_ERR, "Connect Exception Occurred! ");
// this.bluetoothGatt = bluetoothGatt;
// this.gattStatus = gattStatus;
// }
//
// public int getGattStatus() {
// return gattStatus;
// }
//
// public ConnectException setGattStatus(int gattStatus) {
// this.gattStatus = gattStatus;
// return this;
// }
//
// public BluetoothGatt getBluetoothGatt() {
// return bluetoothGatt;
// }
//
// public ConnectException setBluetoothGatt(BluetoothGatt bluetoothGatt) {
// this.bluetoothGatt = bluetoothGatt;
// return this;
// }
//
// @Override
// public String toString() {
// return "ConnectException{" +
// "gattStatus=" + gattStatus +
// ", bluetoothGatt=" + bluetoothGatt +
// "} " + super.toString();
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/GattException.java
// public class GattException extends BleException {
// private int gattStatus;
//
// public GattException(int gattStatus) {
// super(BleExceptionCode.GATT_ERR, "Gatt Exception Occurred! ");
// this.gattStatus = gattStatus;
// }
//
// public int getGattStatus() {
// return gattStatus;
// }
//
// public GattException setGattStatus(int gattStatus) {
// this.gattStatus = gattStatus;
// return this;
// }
//
// @Override
// public String toString() {
// return "GattException{" +
// "gattStatus=" + gattStatus +
// '}' + super.toString();
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/InitiatedException.java
// public class InitiatedException extends BleException {
// public InitiatedException() {
// super(BleExceptionCode.INITIATED_ERR, "Initiated Exception Occurred! ");
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/OtherException.java
// public class OtherException extends BleException {
// public OtherException(String description) {
// super(BleExceptionCode.OTHER_ERR, description);
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/TimeoutException.java
// public class TimeoutException extends BleException {
// public TimeoutException() {
// super(BleExceptionCode.TIMEOUT, "Timeout Exception Occurred! ");
// }
// }
// Path: baseble/src/main/java/com/vise/baseble/exception/handler/DefaultBleExceptionHandler.java
import com.vise.baseble.exception.ConnectException;
import com.vise.baseble.exception.GattException;
import com.vise.baseble.exception.InitiatedException;
import com.vise.baseble.exception.OtherException;
import com.vise.baseble.exception.TimeoutException;
import com.vise.log.ViseLog;
package com.vise.baseble.exception.handler;
/**
* @Description: 异常默认处理
* @author: <a href="http://www.xiaoyaoyou1212.com">DAWI</a>
* @date: 16/8/14 10:35.
*/
public class DefaultBleExceptionHandler extends BleExceptionHandler {
@Override
protected void onConnectException(ConnectException e) {
ViseLog.e(e.getDescription());
}
@Override
protected void onGattException(GattException e) {
ViseLog.e(e.getDescription());
}
@Override
protected void onTimeoutException(TimeoutException e) {
ViseLog.e(e.getDescription());
}
@Override
protected void onInitiatedException(InitiatedException e) {
ViseLog.e(e.getDescription());
}
@Override | protected void onOtherException(OtherException e) { |
xiaoyaoyou1212/BLE | baseble/src/main/java/com/vise/baseble/exception/GattException.java | // Path: baseble/src/main/java/com/vise/baseble/common/BleExceptionCode.java
// public enum BleExceptionCode {
// TIMEOUT, //超时
// CONNECT_ERR, //连接异常
// GATT_ERR, //GATT异常
// INITIATED_ERR, //初始化异常
// OTHER_ERR //其他异常
// }
| import com.vise.baseble.common.BleExceptionCode; | package com.vise.baseble.exception;
/**
* @Description: Gatt异常
* @author: <a href="http://www.xiaoyaoyou1212.com">DAWI</a>
* @date: 16/8/14 10:30.
*/
public class GattException extends BleException {
private int gattStatus;
public GattException(int gattStatus) { | // Path: baseble/src/main/java/com/vise/baseble/common/BleExceptionCode.java
// public enum BleExceptionCode {
// TIMEOUT, //超时
// CONNECT_ERR, //连接异常
// GATT_ERR, //GATT异常
// INITIATED_ERR, //初始化异常
// OTHER_ERR //其他异常
// }
// Path: baseble/src/main/java/com/vise/baseble/exception/GattException.java
import com.vise.baseble.common.BleExceptionCode;
package com.vise.baseble.exception;
/**
* @Description: Gatt异常
* @author: <a href="http://www.xiaoyaoyou1212.com">DAWI</a>
* @date: 16/8/14 10:30.
*/
public class GattException extends BleException {
private int gattStatus;
public GattException(int gattStatus) { | super(BleExceptionCode.GATT_ERR, "Gatt Exception Occurred! "); |
xiaoyaoyou1212/BLE | baseble/src/main/java/com/vise/baseble/exception/TimeoutException.java | // Path: baseble/src/main/java/com/vise/baseble/common/BleExceptionCode.java
// public enum BleExceptionCode {
// TIMEOUT, //超时
// CONNECT_ERR, //连接异常
// GATT_ERR, //GATT异常
// INITIATED_ERR, //初始化异常
// OTHER_ERR //其他异常
// }
| import com.vise.baseble.common.BleExceptionCode; | package com.vise.baseble.exception;
/**
* @Description: 超时异常
* @author: <a href="http://www.xiaoyaoyou1212.com">DAWI</a>
* @date: 16/8/14 10:29.
*/
public class TimeoutException extends BleException {
public TimeoutException() { | // Path: baseble/src/main/java/com/vise/baseble/common/BleExceptionCode.java
// public enum BleExceptionCode {
// TIMEOUT, //超时
// CONNECT_ERR, //连接异常
// GATT_ERR, //GATT异常
// INITIATED_ERR, //初始化异常
// OTHER_ERR //其他异常
// }
// Path: baseble/src/main/java/com/vise/baseble/exception/TimeoutException.java
import com.vise.baseble.common.BleExceptionCode;
package com.vise.baseble.exception;
/**
* @Description: 超时异常
* @author: <a href="http://www.xiaoyaoyou1212.com">DAWI</a>
* @date: 16/8/14 10:29.
*/
public class TimeoutException extends BleException {
public TimeoutException() { | super(BleExceptionCode.TIMEOUT, "Timeout Exception Occurred! "); |
xiaoyaoyou1212/BLE | baseble/src/main/java/com/vise/baseble/exception/handler/BleExceptionHandler.java | // Path: baseble/src/main/java/com/vise/baseble/exception/BleException.java
// public class BleException implements Serializable {
// private BleExceptionCode code;
// private String description;
//
// public BleException(BleExceptionCode code, String description) {
// this.code = code;
// this.description = description;
// }
//
// public BleExceptionCode getCode() {
// return code;
// }
//
// public BleException setCode(BleExceptionCode code) {
// this.code = code;
// return this;
// }
//
// public String getDescription() {
// return description;
// }
//
// public BleException setDescription(String description) {
// this.description = description;
// return this;
// }
//
// @Override
// public String toString() {
// return "BleException{" +
// "code=" + code +
// ", description='" + description + '\'' +
// '}';
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/ConnectException.java
// public class ConnectException extends BleException {
// private BluetoothGatt bluetoothGatt;
// private int gattStatus;
//
// public ConnectException(BluetoothGatt bluetoothGatt, int gattStatus) {
// super(BleExceptionCode.CONNECT_ERR, "Connect Exception Occurred! ");
// this.bluetoothGatt = bluetoothGatt;
// this.gattStatus = gattStatus;
// }
//
// public int getGattStatus() {
// return gattStatus;
// }
//
// public ConnectException setGattStatus(int gattStatus) {
// this.gattStatus = gattStatus;
// return this;
// }
//
// public BluetoothGatt getBluetoothGatt() {
// return bluetoothGatt;
// }
//
// public ConnectException setBluetoothGatt(BluetoothGatt bluetoothGatt) {
// this.bluetoothGatt = bluetoothGatt;
// return this;
// }
//
// @Override
// public String toString() {
// return "ConnectException{" +
// "gattStatus=" + gattStatus +
// ", bluetoothGatt=" + bluetoothGatt +
// "} " + super.toString();
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/GattException.java
// public class GattException extends BleException {
// private int gattStatus;
//
// public GattException(int gattStatus) {
// super(BleExceptionCode.GATT_ERR, "Gatt Exception Occurred! ");
// this.gattStatus = gattStatus;
// }
//
// public int getGattStatus() {
// return gattStatus;
// }
//
// public GattException setGattStatus(int gattStatus) {
// this.gattStatus = gattStatus;
// return this;
// }
//
// @Override
// public String toString() {
// return "GattException{" +
// "gattStatus=" + gattStatus +
// '}' + super.toString();
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/InitiatedException.java
// public class InitiatedException extends BleException {
// public InitiatedException() {
// super(BleExceptionCode.INITIATED_ERR, "Initiated Exception Occurred! ");
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/OtherException.java
// public class OtherException extends BleException {
// public OtherException(String description) {
// super(BleExceptionCode.OTHER_ERR, description);
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/TimeoutException.java
// public class TimeoutException extends BleException {
// public TimeoutException() {
// super(BleExceptionCode.TIMEOUT, "Timeout Exception Occurred! ");
// }
// }
| import com.vise.baseble.exception.BleException;
import com.vise.baseble.exception.ConnectException;
import com.vise.baseble.exception.GattException;
import com.vise.baseble.exception.InitiatedException;
import com.vise.baseble.exception.OtherException;
import com.vise.baseble.exception.TimeoutException; | package com.vise.baseble.exception.handler;
/**
* @Description: 异常处理
* @author: <a href="http://www.xiaoyaoyou1212.com">DAWI</a>
* @date: 16/8/14 10:35.
*/
public abstract class BleExceptionHandler {
public BleExceptionHandler handleException(BleException exception) {
if (exception != null) { | // Path: baseble/src/main/java/com/vise/baseble/exception/BleException.java
// public class BleException implements Serializable {
// private BleExceptionCode code;
// private String description;
//
// public BleException(BleExceptionCode code, String description) {
// this.code = code;
// this.description = description;
// }
//
// public BleExceptionCode getCode() {
// return code;
// }
//
// public BleException setCode(BleExceptionCode code) {
// this.code = code;
// return this;
// }
//
// public String getDescription() {
// return description;
// }
//
// public BleException setDescription(String description) {
// this.description = description;
// return this;
// }
//
// @Override
// public String toString() {
// return "BleException{" +
// "code=" + code +
// ", description='" + description + '\'' +
// '}';
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/ConnectException.java
// public class ConnectException extends BleException {
// private BluetoothGatt bluetoothGatt;
// private int gattStatus;
//
// public ConnectException(BluetoothGatt bluetoothGatt, int gattStatus) {
// super(BleExceptionCode.CONNECT_ERR, "Connect Exception Occurred! ");
// this.bluetoothGatt = bluetoothGatt;
// this.gattStatus = gattStatus;
// }
//
// public int getGattStatus() {
// return gattStatus;
// }
//
// public ConnectException setGattStatus(int gattStatus) {
// this.gattStatus = gattStatus;
// return this;
// }
//
// public BluetoothGatt getBluetoothGatt() {
// return bluetoothGatt;
// }
//
// public ConnectException setBluetoothGatt(BluetoothGatt bluetoothGatt) {
// this.bluetoothGatt = bluetoothGatt;
// return this;
// }
//
// @Override
// public String toString() {
// return "ConnectException{" +
// "gattStatus=" + gattStatus +
// ", bluetoothGatt=" + bluetoothGatt +
// "} " + super.toString();
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/GattException.java
// public class GattException extends BleException {
// private int gattStatus;
//
// public GattException(int gattStatus) {
// super(BleExceptionCode.GATT_ERR, "Gatt Exception Occurred! ");
// this.gattStatus = gattStatus;
// }
//
// public int getGattStatus() {
// return gattStatus;
// }
//
// public GattException setGattStatus(int gattStatus) {
// this.gattStatus = gattStatus;
// return this;
// }
//
// @Override
// public String toString() {
// return "GattException{" +
// "gattStatus=" + gattStatus +
// '}' + super.toString();
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/InitiatedException.java
// public class InitiatedException extends BleException {
// public InitiatedException() {
// super(BleExceptionCode.INITIATED_ERR, "Initiated Exception Occurred! ");
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/OtherException.java
// public class OtherException extends BleException {
// public OtherException(String description) {
// super(BleExceptionCode.OTHER_ERR, description);
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/TimeoutException.java
// public class TimeoutException extends BleException {
// public TimeoutException() {
// super(BleExceptionCode.TIMEOUT, "Timeout Exception Occurred! ");
// }
// }
// Path: baseble/src/main/java/com/vise/baseble/exception/handler/BleExceptionHandler.java
import com.vise.baseble.exception.BleException;
import com.vise.baseble.exception.ConnectException;
import com.vise.baseble.exception.GattException;
import com.vise.baseble.exception.InitiatedException;
import com.vise.baseble.exception.OtherException;
import com.vise.baseble.exception.TimeoutException;
package com.vise.baseble.exception.handler;
/**
* @Description: 异常处理
* @author: <a href="http://www.xiaoyaoyou1212.com">DAWI</a>
* @date: 16/8/14 10:35.
*/
public abstract class BleExceptionHandler {
public BleExceptionHandler handleException(BleException exception) {
if (exception != null) { | if (exception instanceof ConnectException) { |
xiaoyaoyou1212/BLE | baseble/src/main/java/com/vise/baseble/exception/handler/BleExceptionHandler.java | // Path: baseble/src/main/java/com/vise/baseble/exception/BleException.java
// public class BleException implements Serializable {
// private BleExceptionCode code;
// private String description;
//
// public BleException(BleExceptionCode code, String description) {
// this.code = code;
// this.description = description;
// }
//
// public BleExceptionCode getCode() {
// return code;
// }
//
// public BleException setCode(BleExceptionCode code) {
// this.code = code;
// return this;
// }
//
// public String getDescription() {
// return description;
// }
//
// public BleException setDescription(String description) {
// this.description = description;
// return this;
// }
//
// @Override
// public String toString() {
// return "BleException{" +
// "code=" + code +
// ", description='" + description + '\'' +
// '}';
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/ConnectException.java
// public class ConnectException extends BleException {
// private BluetoothGatt bluetoothGatt;
// private int gattStatus;
//
// public ConnectException(BluetoothGatt bluetoothGatt, int gattStatus) {
// super(BleExceptionCode.CONNECT_ERR, "Connect Exception Occurred! ");
// this.bluetoothGatt = bluetoothGatt;
// this.gattStatus = gattStatus;
// }
//
// public int getGattStatus() {
// return gattStatus;
// }
//
// public ConnectException setGattStatus(int gattStatus) {
// this.gattStatus = gattStatus;
// return this;
// }
//
// public BluetoothGatt getBluetoothGatt() {
// return bluetoothGatt;
// }
//
// public ConnectException setBluetoothGatt(BluetoothGatt bluetoothGatt) {
// this.bluetoothGatt = bluetoothGatt;
// return this;
// }
//
// @Override
// public String toString() {
// return "ConnectException{" +
// "gattStatus=" + gattStatus +
// ", bluetoothGatt=" + bluetoothGatt +
// "} " + super.toString();
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/GattException.java
// public class GattException extends BleException {
// private int gattStatus;
//
// public GattException(int gattStatus) {
// super(BleExceptionCode.GATT_ERR, "Gatt Exception Occurred! ");
// this.gattStatus = gattStatus;
// }
//
// public int getGattStatus() {
// return gattStatus;
// }
//
// public GattException setGattStatus(int gattStatus) {
// this.gattStatus = gattStatus;
// return this;
// }
//
// @Override
// public String toString() {
// return "GattException{" +
// "gattStatus=" + gattStatus +
// '}' + super.toString();
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/InitiatedException.java
// public class InitiatedException extends BleException {
// public InitiatedException() {
// super(BleExceptionCode.INITIATED_ERR, "Initiated Exception Occurred! ");
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/OtherException.java
// public class OtherException extends BleException {
// public OtherException(String description) {
// super(BleExceptionCode.OTHER_ERR, description);
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/TimeoutException.java
// public class TimeoutException extends BleException {
// public TimeoutException() {
// super(BleExceptionCode.TIMEOUT, "Timeout Exception Occurred! ");
// }
// }
| import com.vise.baseble.exception.BleException;
import com.vise.baseble.exception.ConnectException;
import com.vise.baseble.exception.GattException;
import com.vise.baseble.exception.InitiatedException;
import com.vise.baseble.exception.OtherException;
import com.vise.baseble.exception.TimeoutException; | package com.vise.baseble.exception.handler;
/**
* @Description: 异常处理
* @author: <a href="http://www.xiaoyaoyou1212.com">DAWI</a>
* @date: 16/8/14 10:35.
*/
public abstract class BleExceptionHandler {
public BleExceptionHandler handleException(BleException exception) {
if (exception != null) {
if (exception instanceof ConnectException) {
onConnectException((ConnectException) exception); | // Path: baseble/src/main/java/com/vise/baseble/exception/BleException.java
// public class BleException implements Serializable {
// private BleExceptionCode code;
// private String description;
//
// public BleException(BleExceptionCode code, String description) {
// this.code = code;
// this.description = description;
// }
//
// public BleExceptionCode getCode() {
// return code;
// }
//
// public BleException setCode(BleExceptionCode code) {
// this.code = code;
// return this;
// }
//
// public String getDescription() {
// return description;
// }
//
// public BleException setDescription(String description) {
// this.description = description;
// return this;
// }
//
// @Override
// public String toString() {
// return "BleException{" +
// "code=" + code +
// ", description='" + description + '\'' +
// '}';
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/ConnectException.java
// public class ConnectException extends BleException {
// private BluetoothGatt bluetoothGatt;
// private int gattStatus;
//
// public ConnectException(BluetoothGatt bluetoothGatt, int gattStatus) {
// super(BleExceptionCode.CONNECT_ERR, "Connect Exception Occurred! ");
// this.bluetoothGatt = bluetoothGatt;
// this.gattStatus = gattStatus;
// }
//
// public int getGattStatus() {
// return gattStatus;
// }
//
// public ConnectException setGattStatus(int gattStatus) {
// this.gattStatus = gattStatus;
// return this;
// }
//
// public BluetoothGatt getBluetoothGatt() {
// return bluetoothGatt;
// }
//
// public ConnectException setBluetoothGatt(BluetoothGatt bluetoothGatt) {
// this.bluetoothGatt = bluetoothGatt;
// return this;
// }
//
// @Override
// public String toString() {
// return "ConnectException{" +
// "gattStatus=" + gattStatus +
// ", bluetoothGatt=" + bluetoothGatt +
// "} " + super.toString();
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/GattException.java
// public class GattException extends BleException {
// private int gattStatus;
//
// public GattException(int gattStatus) {
// super(BleExceptionCode.GATT_ERR, "Gatt Exception Occurred! ");
// this.gattStatus = gattStatus;
// }
//
// public int getGattStatus() {
// return gattStatus;
// }
//
// public GattException setGattStatus(int gattStatus) {
// this.gattStatus = gattStatus;
// return this;
// }
//
// @Override
// public String toString() {
// return "GattException{" +
// "gattStatus=" + gattStatus +
// '}' + super.toString();
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/InitiatedException.java
// public class InitiatedException extends BleException {
// public InitiatedException() {
// super(BleExceptionCode.INITIATED_ERR, "Initiated Exception Occurred! ");
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/OtherException.java
// public class OtherException extends BleException {
// public OtherException(String description) {
// super(BleExceptionCode.OTHER_ERR, description);
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/TimeoutException.java
// public class TimeoutException extends BleException {
// public TimeoutException() {
// super(BleExceptionCode.TIMEOUT, "Timeout Exception Occurred! ");
// }
// }
// Path: baseble/src/main/java/com/vise/baseble/exception/handler/BleExceptionHandler.java
import com.vise.baseble.exception.BleException;
import com.vise.baseble.exception.ConnectException;
import com.vise.baseble.exception.GattException;
import com.vise.baseble.exception.InitiatedException;
import com.vise.baseble.exception.OtherException;
import com.vise.baseble.exception.TimeoutException;
package com.vise.baseble.exception.handler;
/**
* @Description: 异常处理
* @author: <a href="http://www.xiaoyaoyou1212.com">DAWI</a>
* @date: 16/8/14 10:35.
*/
public abstract class BleExceptionHandler {
public BleExceptionHandler handleException(BleException exception) {
if (exception != null) {
if (exception instanceof ConnectException) {
onConnectException((ConnectException) exception); | } else if (exception instanceof GattException) { |
xiaoyaoyou1212/BLE | baseble/src/main/java/com/vise/baseble/exception/handler/BleExceptionHandler.java | // Path: baseble/src/main/java/com/vise/baseble/exception/BleException.java
// public class BleException implements Serializable {
// private BleExceptionCode code;
// private String description;
//
// public BleException(BleExceptionCode code, String description) {
// this.code = code;
// this.description = description;
// }
//
// public BleExceptionCode getCode() {
// return code;
// }
//
// public BleException setCode(BleExceptionCode code) {
// this.code = code;
// return this;
// }
//
// public String getDescription() {
// return description;
// }
//
// public BleException setDescription(String description) {
// this.description = description;
// return this;
// }
//
// @Override
// public String toString() {
// return "BleException{" +
// "code=" + code +
// ", description='" + description + '\'' +
// '}';
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/ConnectException.java
// public class ConnectException extends BleException {
// private BluetoothGatt bluetoothGatt;
// private int gattStatus;
//
// public ConnectException(BluetoothGatt bluetoothGatt, int gattStatus) {
// super(BleExceptionCode.CONNECT_ERR, "Connect Exception Occurred! ");
// this.bluetoothGatt = bluetoothGatt;
// this.gattStatus = gattStatus;
// }
//
// public int getGattStatus() {
// return gattStatus;
// }
//
// public ConnectException setGattStatus(int gattStatus) {
// this.gattStatus = gattStatus;
// return this;
// }
//
// public BluetoothGatt getBluetoothGatt() {
// return bluetoothGatt;
// }
//
// public ConnectException setBluetoothGatt(BluetoothGatt bluetoothGatt) {
// this.bluetoothGatt = bluetoothGatt;
// return this;
// }
//
// @Override
// public String toString() {
// return "ConnectException{" +
// "gattStatus=" + gattStatus +
// ", bluetoothGatt=" + bluetoothGatt +
// "} " + super.toString();
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/GattException.java
// public class GattException extends BleException {
// private int gattStatus;
//
// public GattException(int gattStatus) {
// super(BleExceptionCode.GATT_ERR, "Gatt Exception Occurred! ");
// this.gattStatus = gattStatus;
// }
//
// public int getGattStatus() {
// return gattStatus;
// }
//
// public GattException setGattStatus(int gattStatus) {
// this.gattStatus = gattStatus;
// return this;
// }
//
// @Override
// public String toString() {
// return "GattException{" +
// "gattStatus=" + gattStatus +
// '}' + super.toString();
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/InitiatedException.java
// public class InitiatedException extends BleException {
// public InitiatedException() {
// super(BleExceptionCode.INITIATED_ERR, "Initiated Exception Occurred! ");
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/OtherException.java
// public class OtherException extends BleException {
// public OtherException(String description) {
// super(BleExceptionCode.OTHER_ERR, description);
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/TimeoutException.java
// public class TimeoutException extends BleException {
// public TimeoutException() {
// super(BleExceptionCode.TIMEOUT, "Timeout Exception Occurred! ");
// }
// }
| import com.vise.baseble.exception.BleException;
import com.vise.baseble.exception.ConnectException;
import com.vise.baseble.exception.GattException;
import com.vise.baseble.exception.InitiatedException;
import com.vise.baseble.exception.OtherException;
import com.vise.baseble.exception.TimeoutException; | package com.vise.baseble.exception.handler;
/**
* @Description: 异常处理
* @author: <a href="http://www.xiaoyaoyou1212.com">DAWI</a>
* @date: 16/8/14 10:35.
*/
public abstract class BleExceptionHandler {
public BleExceptionHandler handleException(BleException exception) {
if (exception != null) {
if (exception instanceof ConnectException) {
onConnectException((ConnectException) exception);
} else if (exception instanceof GattException) {
onGattException((GattException) exception); | // Path: baseble/src/main/java/com/vise/baseble/exception/BleException.java
// public class BleException implements Serializable {
// private BleExceptionCode code;
// private String description;
//
// public BleException(BleExceptionCode code, String description) {
// this.code = code;
// this.description = description;
// }
//
// public BleExceptionCode getCode() {
// return code;
// }
//
// public BleException setCode(BleExceptionCode code) {
// this.code = code;
// return this;
// }
//
// public String getDescription() {
// return description;
// }
//
// public BleException setDescription(String description) {
// this.description = description;
// return this;
// }
//
// @Override
// public String toString() {
// return "BleException{" +
// "code=" + code +
// ", description='" + description + '\'' +
// '}';
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/ConnectException.java
// public class ConnectException extends BleException {
// private BluetoothGatt bluetoothGatt;
// private int gattStatus;
//
// public ConnectException(BluetoothGatt bluetoothGatt, int gattStatus) {
// super(BleExceptionCode.CONNECT_ERR, "Connect Exception Occurred! ");
// this.bluetoothGatt = bluetoothGatt;
// this.gattStatus = gattStatus;
// }
//
// public int getGattStatus() {
// return gattStatus;
// }
//
// public ConnectException setGattStatus(int gattStatus) {
// this.gattStatus = gattStatus;
// return this;
// }
//
// public BluetoothGatt getBluetoothGatt() {
// return bluetoothGatt;
// }
//
// public ConnectException setBluetoothGatt(BluetoothGatt bluetoothGatt) {
// this.bluetoothGatt = bluetoothGatt;
// return this;
// }
//
// @Override
// public String toString() {
// return "ConnectException{" +
// "gattStatus=" + gattStatus +
// ", bluetoothGatt=" + bluetoothGatt +
// "} " + super.toString();
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/GattException.java
// public class GattException extends BleException {
// private int gattStatus;
//
// public GattException(int gattStatus) {
// super(BleExceptionCode.GATT_ERR, "Gatt Exception Occurred! ");
// this.gattStatus = gattStatus;
// }
//
// public int getGattStatus() {
// return gattStatus;
// }
//
// public GattException setGattStatus(int gattStatus) {
// this.gattStatus = gattStatus;
// return this;
// }
//
// @Override
// public String toString() {
// return "GattException{" +
// "gattStatus=" + gattStatus +
// '}' + super.toString();
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/InitiatedException.java
// public class InitiatedException extends BleException {
// public InitiatedException() {
// super(BleExceptionCode.INITIATED_ERR, "Initiated Exception Occurred! ");
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/OtherException.java
// public class OtherException extends BleException {
// public OtherException(String description) {
// super(BleExceptionCode.OTHER_ERR, description);
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/TimeoutException.java
// public class TimeoutException extends BleException {
// public TimeoutException() {
// super(BleExceptionCode.TIMEOUT, "Timeout Exception Occurred! ");
// }
// }
// Path: baseble/src/main/java/com/vise/baseble/exception/handler/BleExceptionHandler.java
import com.vise.baseble.exception.BleException;
import com.vise.baseble.exception.ConnectException;
import com.vise.baseble.exception.GattException;
import com.vise.baseble.exception.InitiatedException;
import com.vise.baseble.exception.OtherException;
import com.vise.baseble.exception.TimeoutException;
package com.vise.baseble.exception.handler;
/**
* @Description: 异常处理
* @author: <a href="http://www.xiaoyaoyou1212.com">DAWI</a>
* @date: 16/8/14 10:35.
*/
public abstract class BleExceptionHandler {
public BleExceptionHandler handleException(BleException exception) {
if (exception != null) {
if (exception instanceof ConnectException) {
onConnectException((ConnectException) exception);
} else if (exception instanceof GattException) {
onGattException((GattException) exception); | } else if (exception instanceof TimeoutException) { |
xiaoyaoyou1212/BLE | baseble/src/main/java/com/vise/baseble/exception/handler/BleExceptionHandler.java | // Path: baseble/src/main/java/com/vise/baseble/exception/BleException.java
// public class BleException implements Serializable {
// private BleExceptionCode code;
// private String description;
//
// public BleException(BleExceptionCode code, String description) {
// this.code = code;
// this.description = description;
// }
//
// public BleExceptionCode getCode() {
// return code;
// }
//
// public BleException setCode(BleExceptionCode code) {
// this.code = code;
// return this;
// }
//
// public String getDescription() {
// return description;
// }
//
// public BleException setDescription(String description) {
// this.description = description;
// return this;
// }
//
// @Override
// public String toString() {
// return "BleException{" +
// "code=" + code +
// ", description='" + description + '\'' +
// '}';
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/ConnectException.java
// public class ConnectException extends BleException {
// private BluetoothGatt bluetoothGatt;
// private int gattStatus;
//
// public ConnectException(BluetoothGatt bluetoothGatt, int gattStatus) {
// super(BleExceptionCode.CONNECT_ERR, "Connect Exception Occurred! ");
// this.bluetoothGatt = bluetoothGatt;
// this.gattStatus = gattStatus;
// }
//
// public int getGattStatus() {
// return gattStatus;
// }
//
// public ConnectException setGattStatus(int gattStatus) {
// this.gattStatus = gattStatus;
// return this;
// }
//
// public BluetoothGatt getBluetoothGatt() {
// return bluetoothGatt;
// }
//
// public ConnectException setBluetoothGatt(BluetoothGatt bluetoothGatt) {
// this.bluetoothGatt = bluetoothGatt;
// return this;
// }
//
// @Override
// public String toString() {
// return "ConnectException{" +
// "gattStatus=" + gattStatus +
// ", bluetoothGatt=" + bluetoothGatt +
// "} " + super.toString();
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/GattException.java
// public class GattException extends BleException {
// private int gattStatus;
//
// public GattException(int gattStatus) {
// super(BleExceptionCode.GATT_ERR, "Gatt Exception Occurred! ");
// this.gattStatus = gattStatus;
// }
//
// public int getGattStatus() {
// return gattStatus;
// }
//
// public GattException setGattStatus(int gattStatus) {
// this.gattStatus = gattStatus;
// return this;
// }
//
// @Override
// public String toString() {
// return "GattException{" +
// "gattStatus=" + gattStatus +
// '}' + super.toString();
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/InitiatedException.java
// public class InitiatedException extends BleException {
// public InitiatedException() {
// super(BleExceptionCode.INITIATED_ERR, "Initiated Exception Occurred! ");
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/OtherException.java
// public class OtherException extends BleException {
// public OtherException(String description) {
// super(BleExceptionCode.OTHER_ERR, description);
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/TimeoutException.java
// public class TimeoutException extends BleException {
// public TimeoutException() {
// super(BleExceptionCode.TIMEOUT, "Timeout Exception Occurred! ");
// }
// }
| import com.vise.baseble.exception.BleException;
import com.vise.baseble.exception.ConnectException;
import com.vise.baseble.exception.GattException;
import com.vise.baseble.exception.InitiatedException;
import com.vise.baseble.exception.OtherException;
import com.vise.baseble.exception.TimeoutException; | package com.vise.baseble.exception.handler;
/**
* @Description: 异常处理
* @author: <a href="http://www.xiaoyaoyou1212.com">DAWI</a>
* @date: 16/8/14 10:35.
*/
public abstract class BleExceptionHandler {
public BleExceptionHandler handleException(BleException exception) {
if (exception != null) {
if (exception instanceof ConnectException) {
onConnectException((ConnectException) exception);
} else if (exception instanceof GattException) {
onGattException((GattException) exception);
} else if (exception instanceof TimeoutException) {
onTimeoutException((TimeoutException) exception); | // Path: baseble/src/main/java/com/vise/baseble/exception/BleException.java
// public class BleException implements Serializable {
// private BleExceptionCode code;
// private String description;
//
// public BleException(BleExceptionCode code, String description) {
// this.code = code;
// this.description = description;
// }
//
// public BleExceptionCode getCode() {
// return code;
// }
//
// public BleException setCode(BleExceptionCode code) {
// this.code = code;
// return this;
// }
//
// public String getDescription() {
// return description;
// }
//
// public BleException setDescription(String description) {
// this.description = description;
// return this;
// }
//
// @Override
// public String toString() {
// return "BleException{" +
// "code=" + code +
// ", description='" + description + '\'' +
// '}';
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/ConnectException.java
// public class ConnectException extends BleException {
// private BluetoothGatt bluetoothGatt;
// private int gattStatus;
//
// public ConnectException(BluetoothGatt bluetoothGatt, int gattStatus) {
// super(BleExceptionCode.CONNECT_ERR, "Connect Exception Occurred! ");
// this.bluetoothGatt = bluetoothGatt;
// this.gattStatus = gattStatus;
// }
//
// public int getGattStatus() {
// return gattStatus;
// }
//
// public ConnectException setGattStatus(int gattStatus) {
// this.gattStatus = gattStatus;
// return this;
// }
//
// public BluetoothGatt getBluetoothGatt() {
// return bluetoothGatt;
// }
//
// public ConnectException setBluetoothGatt(BluetoothGatt bluetoothGatt) {
// this.bluetoothGatt = bluetoothGatt;
// return this;
// }
//
// @Override
// public String toString() {
// return "ConnectException{" +
// "gattStatus=" + gattStatus +
// ", bluetoothGatt=" + bluetoothGatt +
// "} " + super.toString();
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/GattException.java
// public class GattException extends BleException {
// private int gattStatus;
//
// public GattException(int gattStatus) {
// super(BleExceptionCode.GATT_ERR, "Gatt Exception Occurred! ");
// this.gattStatus = gattStatus;
// }
//
// public int getGattStatus() {
// return gattStatus;
// }
//
// public GattException setGattStatus(int gattStatus) {
// this.gattStatus = gattStatus;
// return this;
// }
//
// @Override
// public String toString() {
// return "GattException{" +
// "gattStatus=" + gattStatus +
// '}' + super.toString();
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/InitiatedException.java
// public class InitiatedException extends BleException {
// public InitiatedException() {
// super(BleExceptionCode.INITIATED_ERR, "Initiated Exception Occurred! ");
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/OtherException.java
// public class OtherException extends BleException {
// public OtherException(String description) {
// super(BleExceptionCode.OTHER_ERR, description);
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/TimeoutException.java
// public class TimeoutException extends BleException {
// public TimeoutException() {
// super(BleExceptionCode.TIMEOUT, "Timeout Exception Occurred! ");
// }
// }
// Path: baseble/src/main/java/com/vise/baseble/exception/handler/BleExceptionHandler.java
import com.vise.baseble.exception.BleException;
import com.vise.baseble.exception.ConnectException;
import com.vise.baseble.exception.GattException;
import com.vise.baseble.exception.InitiatedException;
import com.vise.baseble.exception.OtherException;
import com.vise.baseble.exception.TimeoutException;
package com.vise.baseble.exception.handler;
/**
* @Description: 异常处理
* @author: <a href="http://www.xiaoyaoyou1212.com">DAWI</a>
* @date: 16/8/14 10:35.
*/
public abstract class BleExceptionHandler {
public BleExceptionHandler handleException(BleException exception) {
if (exception != null) {
if (exception instanceof ConnectException) {
onConnectException((ConnectException) exception);
} else if (exception instanceof GattException) {
onGattException((GattException) exception);
} else if (exception instanceof TimeoutException) {
onTimeoutException((TimeoutException) exception); | } else if (exception instanceof InitiatedException) { |
xiaoyaoyou1212/BLE | baseble/src/main/java/com/vise/baseble/exception/handler/BleExceptionHandler.java | // Path: baseble/src/main/java/com/vise/baseble/exception/BleException.java
// public class BleException implements Serializable {
// private BleExceptionCode code;
// private String description;
//
// public BleException(BleExceptionCode code, String description) {
// this.code = code;
// this.description = description;
// }
//
// public BleExceptionCode getCode() {
// return code;
// }
//
// public BleException setCode(BleExceptionCode code) {
// this.code = code;
// return this;
// }
//
// public String getDescription() {
// return description;
// }
//
// public BleException setDescription(String description) {
// this.description = description;
// return this;
// }
//
// @Override
// public String toString() {
// return "BleException{" +
// "code=" + code +
// ", description='" + description + '\'' +
// '}';
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/ConnectException.java
// public class ConnectException extends BleException {
// private BluetoothGatt bluetoothGatt;
// private int gattStatus;
//
// public ConnectException(BluetoothGatt bluetoothGatt, int gattStatus) {
// super(BleExceptionCode.CONNECT_ERR, "Connect Exception Occurred! ");
// this.bluetoothGatt = bluetoothGatt;
// this.gattStatus = gattStatus;
// }
//
// public int getGattStatus() {
// return gattStatus;
// }
//
// public ConnectException setGattStatus(int gattStatus) {
// this.gattStatus = gattStatus;
// return this;
// }
//
// public BluetoothGatt getBluetoothGatt() {
// return bluetoothGatt;
// }
//
// public ConnectException setBluetoothGatt(BluetoothGatt bluetoothGatt) {
// this.bluetoothGatt = bluetoothGatt;
// return this;
// }
//
// @Override
// public String toString() {
// return "ConnectException{" +
// "gattStatus=" + gattStatus +
// ", bluetoothGatt=" + bluetoothGatt +
// "} " + super.toString();
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/GattException.java
// public class GattException extends BleException {
// private int gattStatus;
//
// public GattException(int gattStatus) {
// super(BleExceptionCode.GATT_ERR, "Gatt Exception Occurred! ");
// this.gattStatus = gattStatus;
// }
//
// public int getGattStatus() {
// return gattStatus;
// }
//
// public GattException setGattStatus(int gattStatus) {
// this.gattStatus = gattStatus;
// return this;
// }
//
// @Override
// public String toString() {
// return "GattException{" +
// "gattStatus=" + gattStatus +
// '}' + super.toString();
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/InitiatedException.java
// public class InitiatedException extends BleException {
// public InitiatedException() {
// super(BleExceptionCode.INITIATED_ERR, "Initiated Exception Occurred! ");
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/OtherException.java
// public class OtherException extends BleException {
// public OtherException(String description) {
// super(BleExceptionCode.OTHER_ERR, description);
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/TimeoutException.java
// public class TimeoutException extends BleException {
// public TimeoutException() {
// super(BleExceptionCode.TIMEOUT, "Timeout Exception Occurred! ");
// }
// }
| import com.vise.baseble.exception.BleException;
import com.vise.baseble.exception.ConnectException;
import com.vise.baseble.exception.GattException;
import com.vise.baseble.exception.InitiatedException;
import com.vise.baseble.exception.OtherException;
import com.vise.baseble.exception.TimeoutException; | package com.vise.baseble.exception.handler;
/**
* @Description: 异常处理
* @author: <a href="http://www.xiaoyaoyou1212.com">DAWI</a>
* @date: 16/8/14 10:35.
*/
public abstract class BleExceptionHandler {
public BleExceptionHandler handleException(BleException exception) {
if (exception != null) {
if (exception instanceof ConnectException) {
onConnectException((ConnectException) exception);
} else if (exception instanceof GattException) {
onGattException((GattException) exception);
} else if (exception instanceof TimeoutException) {
onTimeoutException((TimeoutException) exception);
} else if (exception instanceof InitiatedException) {
onInitiatedException((InitiatedException) exception);
} else { | // Path: baseble/src/main/java/com/vise/baseble/exception/BleException.java
// public class BleException implements Serializable {
// private BleExceptionCode code;
// private String description;
//
// public BleException(BleExceptionCode code, String description) {
// this.code = code;
// this.description = description;
// }
//
// public BleExceptionCode getCode() {
// return code;
// }
//
// public BleException setCode(BleExceptionCode code) {
// this.code = code;
// return this;
// }
//
// public String getDescription() {
// return description;
// }
//
// public BleException setDescription(String description) {
// this.description = description;
// return this;
// }
//
// @Override
// public String toString() {
// return "BleException{" +
// "code=" + code +
// ", description='" + description + '\'' +
// '}';
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/ConnectException.java
// public class ConnectException extends BleException {
// private BluetoothGatt bluetoothGatt;
// private int gattStatus;
//
// public ConnectException(BluetoothGatt bluetoothGatt, int gattStatus) {
// super(BleExceptionCode.CONNECT_ERR, "Connect Exception Occurred! ");
// this.bluetoothGatt = bluetoothGatt;
// this.gattStatus = gattStatus;
// }
//
// public int getGattStatus() {
// return gattStatus;
// }
//
// public ConnectException setGattStatus(int gattStatus) {
// this.gattStatus = gattStatus;
// return this;
// }
//
// public BluetoothGatt getBluetoothGatt() {
// return bluetoothGatt;
// }
//
// public ConnectException setBluetoothGatt(BluetoothGatt bluetoothGatt) {
// this.bluetoothGatt = bluetoothGatt;
// return this;
// }
//
// @Override
// public String toString() {
// return "ConnectException{" +
// "gattStatus=" + gattStatus +
// ", bluetoothGatt=" + bluetoothGatt +
// "} " + super.toString();
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/GattException.java
// public class GattException extends BleException {
// private int gattStatus;
//
// public GattException(int gattStatus) {
// super(BleExceptionCode.GATT_ERR, "Gatt Exception Occurred! ");
// this.gattStatus = gattStatus;
// }
//
// public int getGattStatus() {
// return gattStatus;
// }
//
// public GattException setGattStatus(int gattStatus) {
// this.gattStatus = gattStatus;
// return this;
// }
//
// @Override
// public String toString() {
// return "GattException{" +
// "gattStatus=" + gattStatus +
// '}' + super.toString();
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/InitiatedException.java
// public class InitiatedException extends BleException {
// public InitiatedException() {
// super(BleExceptionCode.INITIATED_ERR, "Initiated Exception Occurred! ");
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/OtherException.java
// public class OtherException extends BleException {
// public OtherException(String description) {
// super(BleExceptionCode.OTHER_ERR, description);
// }
// }
//
// Path: baseble/src/main/java/com/vise/baseble/exception/TimeoutException.java
// public class TimeoutException extends BleException {
// public TimeoutException() {
// super(BleExceptionCode.TIMEOUT, "Timeout Exception Occurred! ");
// }
// }
// Path: baseble/src/main/java/com/vise/baseble/exception/handler/BleExceptionHandler.java
import com.vise.baseble.exception.BleException;
import com.vise.baseble.exception.ConnectException;
import com.vise.baseble.exception.GattException;
import com.vise.baseble.exception.InitiatedException;
import com.vise.baseble.exception.OtherException;
import com.vise.baseble.exception.TimeoutException;
package com.vise.baseble.exception.handler;
/**
* @Description: 异常处理
* @author: <a href="http://www.xiaoyaoyou1212.com">DAWI</a>
* @date: 16/8/14 10:35.
*/
public abstract class BleExceptionHandler {
public BleExceptionHandler handleException(BleException exception) {
if (exception != null) {
if (exception instanceof ConnectException) {
onConnectException((ConnectException) exception);
} else if (exception instanceof GattException) {
onGattException((GattException) exception);
} else if (exception instanceof TimeoutException) {
onTimeoutException((TimeoutException) exception);
} else if (exception instanceof InitiatedException) {
onInitiatedException((InitiatedException) exception);
} else { | onOtherException((OtherException) exception); |
xiaoyaoyou1212/BLE | baseble/src/main/java/com/vise/baseble/exception/InitiatedException.java | // Path: baseble/src/main/java/com/vise/baseble/common/BleExceptionCode.java
// public enum BleExceptionCode {
// TIMEOUT, //超时
// CONNECT_ERR, //连接异常
// GATT_ERR, //GATT异常
// INITIATED_ERR, //初始化异常
// OTHER_ERR //其他异常
// }
| import com.vise.baseble.common.BleExceptionCode; | package com.vise.baseble.exception;
/**
* @Description: 初始化异常
* @author: <a href="http://www.xiaoyaoyou1212.com">DAWI</a>
* @date: 16/8/14 10:30.
*/
public class InitiatedException extends BleException {
public InitiatedException() { | // Path: baseble/src/main/java/com/vise/baseble/common/BleExceptionCode.java
// public enum BleExceptionCode {
// TIMEOUT, //超时
// CONNECT_ERR, //连接异常
// GATT_ERR, //GATT异常
// INITIATED_ERR, //初始化异常
// OTHER_ERR //其他异常
// }
// Path: baseble/src/main/java/com/vise/baseble/exception/InitiatedException.java
import com.vise.baseble.common.BleExceptionCode;
package com.vise.baseble.exception;
/**
* @Description: 初始化异常
* @author: <a href="http://www.xiaoyaoyou1212.com">DAWI</a>
* @date: 16/8/14 10:30.
*/
public class InitiatedException extends BleException {
public InitiatedException() { | super(BleExceptionCode.INITIATED_ERR, "Initiated Exception Occurred! "); |
xiaoyaoyou1212/BLE | baseble/src/main/java/com/vise/baseble/model/adrecord/AdRecordStore.java | // Path: baseble/src/main/java/com/vise/baseble/utils/AdRecordUtil.java
// public class AdRecordUtil {
// private AdRecordUtil() {
// // TO AVOID INSTANTIATION
// }
//
// public static String getRecordDataAsString(final AdRecord nameRecord) {
// if (nameRecord == null) {
// return "";
// }
// return new String(nameRecord.getData());
// }
//
// public static byte[] getServiceData(final AdRecord serviceData) {
// if (serviceData == null) {
// return null;
// }
// if (serviceData.getType() != AdRecord.BLE_GAP_AD_TYPE_SERVICE_DATA) return null;
//
// final byte[] raw = serviceData.getData();
// //Chop out the uuid
// return Arrays.copyOfRange(raw, 2, raw.length);
// }
//
// public static int getServiceDataUuid(final AdRecord serviceData) {
// if (serviceData == null) {
// return -1;
// }
// if (serviceData.getType() != AdRecord.BLE_GAP_AD_TYPE_SERVICE_DATA) return -1;
//
// final byte[] raw = serviceData.getData();
// //Find UUID data in byte array
// int uuid = (raw[1] & 0xFF) << 8;
// uuid += (raw[0] & 0xFF);
//
// return uuid;
// }
//
// /*
// * Read out all the AD structures from the raw scan record
// */
// public static List<AdRecord> parseScanRecordAsList(final byte[] scanRecord) {
// final List<AdRecord> records = new ArrayList<>();
//
// int index = 0;
// while (index < scanRecord.length) {
// final int length = scanRecord[index++];
// //Done once we run out of records
// if (length == 0) break;
//
// final int type = scanRecord[index] & 0xFF;
//
// //Done if our record isn't a valid type
// if (type == 0) break;
//
// final byte[] data = Arrays.copyOfRange(scanRecord, index + 1, index + length);
//
// records.add(new AdRecord(length, type, data));
//
// //Advance
// index += length;
// }
//
// return Collections.unmodifiableList(records);
// }
//
// public static Map<Integer, AdRecord> parseScanRecordAsMap(final byte[] scanRecord) {
// final Map<Integer, AdRecord> records = new HashMap<>();
//
// int index = 0;
// while (index < scanRecord.length) {
// final int length = scanRecord[index++];
// //Done once we run out of records
// if (length == 0) break;
//
// final int type = scanRecord[index] & 0xFF;
//
// //Done if our record isn't a valid type
// if (type == 0) break;
//
// final byte[] data = Arrays.copyOfRange(scanRecord, index + 1, index + length);
//
// records.put(type, new AdRecord(length, type, data));
//
// //Advance
// index += length;
// }
//
// return Collections.unmodifiableMap(records);
// }
//
// public static SparseArray<AdRecord> parseScanRecordAsSparseArray(final byte[] scanRecord) {
// final SparseArray<AdRecord> records = new SparseArray<>();
//
// int index = 0;
// while (index < scanRecord.length) {
// final int length = scanRecord[index++];
// //Done once we run out of records
// if (length == 0) break;
//
// final int type = scanRecord[index] & 0xFF;
//
// //Done if our record isn't a valid type
// if (type == 0) break;
//
// final byte[] data = Arrays.copyOfRange(scanRecord, index + 1, index + length);
//
// records.put(type, new AdRecord(length, type, data));
//
// //Advance
// index += length;
// }
//
// return records;
// }
// }
| import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.SparseArray;
import com.vise.baseble.utils.AdRecordUtil;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections; | package com.vise.baseble.model.adrecord;
/**
* @Description: 广播包解析仓库
* @author: <a href="http://www.xiaoyaoyou1212.com">DAWI</a>
* @date: 16/8/7 21:54.
*/
public class AdRecordStore implements Parcelable {
public static final Creator<AdRecordStore> CREATOR = new Creator<AdRecordStore>() {
public AdRecordStore createFromParcel(final Parcel in) {
return new AdRecordStore(in);
}
public AdRecordStore[] newArray(final int size) {
return new AdRecordStore[size];
}
};
private static final String RECORDS_ARRAY = "records_array";
private static final String LOCAL_NAME_COMPLETE = "local_name_complete";
private static final String LOCAL_NAME_SHORT = "local_name_short";
private final SparseArray<AdRecord> mAdRecords;
private final String mLocalNameComplete;
private final String mLocalNameShort;
public AdRecordStore(final Parcel in) {
final Bundle b = in.readBundle(getClass().getClassLoader());
mAdRecords = b.getSparseParcelableArray(RECORDS_ARRAY);
mLocalNameComplete = b.getString(LOCAL_NAME_COMPLETE);
mLocalNameShort = b.getString(LOCAL_NAME_SHORT);
}
/**
* Instantiates a new Bluetooth LE device Ad Record Store.
*
* @param adRecords the ad records
*/
public AdRecordStore(final SparseArray<AdRecord> adRecords) {
mAdRecords = adRecords; | // Path: baseble/src/main/java/com/vise/baseble/utils/AdRecordUtil.java
// public class AdRecordUtil {
// private AdRecordUtil() {
// // TO AVOID INSTANTIATION
// }
//
// public static String getRecordDataAsString(final AdRecord nameRecord) {
// if (nameRecord == null) {
// return "";
// }
// return new String(nameRecord.getData());
// }
//
// public static byte[] getServiceData(final AdRecord serviceData) {
// if (serviceData == null) {
// return null;
// }
// if (serviceData.getType() != AdRecord.BLE_GAP_AD_TYPE_SERVICE_DATA) return null;
//
// final byte[] raw = serviceData.getData();
// //Chop out the uuid
// return Arrays.copyOfRange(raw, 2, raw.length);
// }
//
// public static int getServiceDataUuid(final AdRecord serviceData) {
// if (serviceData == null) {
// return -1;
// }
// if (serviceData.getType() != AdRecord.BLE_GAP_AD_TYPE_SERVICE_DATA) return -1;
//
// final byte[] raw = serviceData.getData();
// //Find UUID data in byte array
// int uuid = (raw[1] & 0xFF) << 8;
// uuid += (raw[0] & 0xFF);
//
// return uuid;
// }
//
// /*
// * Read out all the AD structures from the raw scan record
// */
// public static List<AdRecord> parseScanRecordAsList(final byte[] scanRecord) {
// final List<AdRecord> records = new ArrayList<>();
//
// int index = 0;
// while (index < scanRecord.length) {
// final int length = scanRecord[index++];
// //Done once we run out of records
// if (length == 0) break;
//
// final int type = scanRecord[index] & 0xFF;
//
// //Done if our record isn't a valid type
// if (type == 0) break;
//
// final byte[] data = Arrays.copyOfRange(scanRecord, index + 1, index + length);
//
// records.add(new AdRecord(length, type, data));
//
// //Advance
// index += length;
// }
//
// return Collections.unmodifiableList(records);
// }
//
// public static Map<Integer, AdRecord> parseScanRecordAsMap(final byte[] scanRecord) {
// final Map<Integer, AdRecord> records = new HashMap<>();
//
// int index = 0;
// while (index < scanRecord.length) {
// final int length = scanRecord[index++];
// //Done once we run out of records
// if (length == 0) break;
//
// final int type = scanRecord[index] & 0xFF;
//
// //Done if our record isn't a valid type
// if (type == 0) break;
//
// final byte[] data = Arrays.copyOfRange(scanRecord, index + 1, index + length);
//
// records.put(type, new AdRecord(length, type, data));
//
// //Advance
// index += length;
// }
//
// return Collections.unmodifiableMap(records);
// }
//
// public static SparseArray<AdRecord> parseScanRecordAsSparseArray(final byte[] scanRecord) {
// final SparseArray<AdRecord> records = new SparseArray<>();
//
// int index = 0;
// while (index < scanRecord.length) {
// final int length = scanRecord[index++];
// //Done once we run out of records
// if (length == 0) break;
//
// final int type = scanRecord[index] & 0xFF;
//
// //Done if our record isn't a valid type
// if (type == 0) break;
//
// final byte[] data = Arrays.copyOfRange(scanRecord, index + 1, index + length);
//
// records.put(type, new AdRecord(length, type, data));
//
// //Advance
// index += length;
// }
//
// return records;
// }
// }
// Path: baseble/src/main/java/com/vise/baseble/model/adrecord/AdRecordStore.java
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.SparseArray;
import com.vise.baseble.utils.AdRecordUtil;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
package com.vise.baseble.model.adrecord;
/**
* @Description: 广播包解析仓库
* @author: <a href="http://www.xiaoyaoyou1212.com">DAWI</a>
* @date: 16/8/7 21:54.
*/
public class AdRecordStore implements Parcelable {
public static final Creator<AdRecordStore> CREATOR = new Creator<AdRecordStore>() {
public AdRecordStore createFromParcel(final Parcel in) {
return new AdRecordStore(in);
}
public AdRecordStore[] newArray(final int size) {
return new AdRecordStore[size];
}
};
private static final String RECORDS_ARRAY = "records_array";
private static final String LOCAL_NAME_COMPLETE = "local_name_complete";
private static final String LOCAL_NAME_SHORT = "local_name_short";
private final SparseArray<AdRecord> mAdRecords;
private final String mLocalNameComplete;
private final String mLocalNameShort;
public AdRecordStore(final Parcel in) {
final Bundle b = in.readBundle(getClass().getClassLoader());
mAdRecords = b.getSparseParcelableArray(RECORDS_ARRAY);
mLocalNameComplete = b.getString(LOCAL_NAME_COMPLETE);
mLocalNameShort = b.getString(LOCAL_NAME_SHORT);
}
/**
* Instantiates a new Bluetooth LE device Ad Record Store.
*
* @param adRecords the ad records
*/
public AdRecordStore(final SparseArray<AdRecord> adRecords) {
mAdRecords = adRecords; | mLocalNameComplete = AdRecordUtil.getRecordDataAsString(mAdRecords.get(AdRecord.BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME)); |
xiaoyaoyou1212/BLE | baseble/src/main/java/com/vise/baseble/callback/IRssiCallback.java | // Path: baseble/src/main/java/com/vise/baseble/exception/BleException.java
// public class BleException implements Serializable {
// private BleExceptionCode code;
// private String description;
//
// public BleException(BleExceptionCode code, String description) {
// this.code = code;
// this.description = description;
// }
//
// public BleExceptionCode getCode() {
// return code;
// }
//
// public BleException setCode(BleExceptionCode code) {
// this.code = code;
// return this;
// }
//
// public String getDescription() {
// return description;
// }
//
// public BleException setDescription(String description) {
// this.description = description;
// return this;
// }
//
// @Override
// public String toString() {
// return "BleException{" +
// "code=" + code +
// ", description='" + description + '\'' +
// '}';
// }
// }
| import com.vise.baseble.exception.BleException; | package com.vise.baseble.callback;
/**
* @Description: 获取信号值回调
* @author: <a href="http://xiaoyaoyou1212.360doc.com">DAWI</a>
* @date: 2017/10/19 15:19
*/
public interface IRssiCallback {
void onSuccess(int rssi);
| // Path: baseble/src/main/java/com/vise/baseble/exception/BleException.java
// public class BleException implements Serializable {
// private BleExceptionCode code;
// private String description;
//
// public BleException(BleExceptionCode code, String description) {
// this.code = code;
// this.description = description;
// }
//
// public BleExceptionCode getCode() {
// return code;
// }
//
// public BleException setCode(BleExceptionCode code) {
// this.code = code;
// return this;
// }
//
// public String getDescription() {
// return description;
// }
//
// public BleException setDescription(String description) {
// this.description = description;
// return this;
// }
//
// @Override
// public String toString() {
// return "BleException{" +
// "code=" + code +
// ", description='" + description + '\'' +
// '}';
// }
// }
// Path: baseble/src/main/java/com/vise/baseble/callback/IRssiCallback.java
import com.vise.baseble.exception.BleException;
package com.vise.baseble.callback;
/**
* @Description: 获取信号值回调
* @author: <a href="http://xiaoyaoyou1212.360doc.com">DAWI</a>
* @date: 2017/10/19 15:19
*/
public interface IRssiCallback {
void onSuccess(int rssi);
| void onFailure(BleException exception); |
xiaoyaoyou1212/BLE | baseble/src/main/java/com/vise/baseble/exception/ConnectException.java | // Path: baseble/src/main/java/com/vise/baseble/common/BleExceptionCode.java
// public enum BleExceptionCode {
// TIMEOUT, //超时
// CONNECT_ERR, //连接异常
// GATT_ERR, //GATT异常
// INITIATED_ERR, //初始化异常
// OTHER_ERR //其他异常
// }
| import android.bluetooth.BluetoothGatt;
import com.vise.baseble.common.BleExceptionCode; | package com.vise.baseble.exception;
/**
* @Description: 连接异常
* @author: <a href="http://www.xiaoyaoyou1212.com">DAWI</a>
* @date: 16/8/14 10:29.
*/
public class ConnectException extends BleException {
private BluetoothGatt bluetoothGatt;
private int gattStatus;
public ConnectException(BluetoothGatt bluetoothGatt, int gattStatus) { | // Path: baseble/src/main/java/com/vise/baseble/common/BleExceptionCode.java
// public enum BleExceptionCode {
// TIMEOUT, //超时
// CONNECT_ERR, //连接异常
// GATT_ERR, //GATT异常
// INITIATED_ERR, //初始化异常
// OTHER_ERR //其他异常
// }
// Path: baseble/src/main/java/com/vise/baseble/exception/ConnectException.java
import android.bluetooth.BluetoothGatt;
import com.vise.baseble.common.BleExceptionCode;
package com.vise.baseble.exception;
/**
* @Description: 连接异常
* @author: <a href="http://www.xiaoyaoyou1212.com">DAWI</a>
* @date: 16/8/14 10:29.
*/
public class ConnectException extends BleException {
private BluetoothGatt bluetoothGatt;
private int gattStatus;
public ConnectException(BluetoothGatt bluetoothGatt, int gattStatus) { | super(BleExceptionCode.CONNECT_ERR, "Connect Exception Occurred! "); |
xiaoyaoyou1212/BLE | baseble/src/main/java/com/vise/baseble/core/BluetoothGattChannel.java | // Path: baseble/src/main/java/com/vise/baseble/common/PropertyType.java
// public enum PropertyType {
// PROPERTY_READ(0x01),
// PROPERTY_WRITE(0x02),
// PROPERTY_NOTIFY(0x04),
// PROPERTY_INDICATE(0x08);
//
// private int propertyValue;
//
// PropertyType(int propertyValue) {
// this.propertyValue = propertyValue;
// }
//
// public int getPropertyValue() {
// return propertyValue;
// }
// }
| import android.bluetooth.BluetoothGatt;
import android.bluetooth.BluetoothGattCharacteristic;
import android.bluetooth.BluetoothGattDescriptor;
import android.bluetooth.BluetoothGattService;
import com.vise.baseble.common.PropertyType;
import java.util.UUID; | package com.vise.baseble.core;
/**
* @Description: BluetoothGatt 相关信息
* @author: <a href="http://xiaoyaoyou1212.360doc.com">DAWI</a>
* @date: 2017/10/17 16:25
*/
public class BluetoothGattChannel {
private BluetoothGatt bluetoothGatt;
private BluetoothGattService service;
private BluetoothGattCharacteristic characteristic;
private BluetoothGattDescriptor descriptor;
private String gattInfoKey; | // Path: baseble/src/main/java/com/vise/baseble/common/PropertyType.java
// public enum PropertyType {
// PROPERTY_READ(0x01),
// PROPERTY_WRITE(0x02),
// PROPERTY_NOTIFY(0x04),
// PROPERTY_INDICATE(0x08);
//
// private int propertyValue;
//
// PropertyType(int propertyValue) {
// this.propertyValue = propertyValue;
// }
//
// public int getPropertyValue() {
// return propertyValue;
// }
// }
// Path: baseble/src/main/java/com/vise/baseble/core/BluetoothGattChannel.java
import android.bluetooth.BluetoothGatt;
import android.bluetooth.BluetoothGattCharacteristic;
import android.bluetooth.BluetoothGattDescriptor;
import android.bluetooth.BluetoothGattService;
import com.vise.baseble.common.PropertyType;
import java.util.UUID;
package com.vise.baseble.core;
/**
* @Description: BluetoothGatt 相关信息
* @author: <a href="http://xiaoyaoyou1212.360doc.com">DAWI</a>
* @date: 2017/10/17 16:25
*/
public class BluetoothGattChannel {
private BluetoothGatt bluetoothGatt;
private BluetoothGattService service;
private BluetoothGattCharacteristic characteristic;
private BluetoothGattDescriptor descriptor;
private String gattInfoKey; | private PropertyType propertyType; |
TerryHowe/SIP-Voice-Quality-Report-Reaper | src/com/tt/reaper/Reaper.java | // Path: src/com/tt/reaper/filter/FilterExecute.java
// public class FilterExecute extends Thread {
// private static Logger logger = Logger.getLogger(FilterExecute.class);
// public static final FilterExecute instance = new FilterExecute();
// private String command;
// private boolean running = false;
//
// private FilterExecute() {
// }
//
// public synchronized void init() {
// command = new Configuration().getCommand();
// if (command == null) {
// logger.error("Filter command not configured");
// }
// if (running == false)
// start();
// running = true;
// }
//
// public void run() {
// try {
// logger.info("Running filter: " + command);
// Process p = Runtime.getRuntime().exec(command);
// p.waitFor();
// logger.warn("Filter exited with return value: " + p.exitValue());
// } catch (Exception e) {
// logger.error("Error running filter: ", e);
// }
// }
//
// }
//
// Path: src/com/tt/reaper/sip/CollectorStack.java
// public class CollectorStack {
// private static final String STACK_NAME = "CollectorStack";
// private static Logger logger = Logger.getLogger(CollectorStack.class);
// public static CollectorStack instance = new CollectorStack();
// private SipProvider collectorProvider;
// private static boolean initialized = false;
// public String lastSendData;
//
// private CollectorStack()
// {
// }
//
// public synchronized boolean init()
// {
// if (initialized == true)
// return true;
// initialized = true;
// logger.info("Starting the collector stack...");
// try {
// SipStack sipStack;
// Configuration configuration;
// configuration = new Configuration();
// configuration.setStackName(STACK_NAME);
// SipFactory.getInstance().setPathName("gov.nist");
// sipStack = SipFactory.getInstance().createSipStack(configuration);
// RequestMessage.initFactory(SipFactory.getInstance(), configuration);
// ListeningPoint reaperUdp = sipStack.createListeningPoint(configuration.getWriteInterface(), configuration.getWritePort(), "udp");
// collectorProvider = sipStack.createSipProvider(reaperUdp);
// collectorProvider.addSipListener(new CollectorListener());
// collectorProvider.setAutomaticDialogSupportEnabled(false);
// logger.info("Collector SIP stack initialized successfully");
// }
// catch (Exception e)
// {
// logger.error("Error initializing stack: ", e);
// return false;
// }
// return true;
// }
//
// public boolean sendResponse(ResponseMessage response) {
// try {
// ServerTransaction st = collectorProvider.getNewServerTransaction(response.getRequest());
// st.sendResponse(response.getResponse());
// }
// catch (Exception e) {
// logger.error("Error sending response: ", e);
// }
// return true;
// }
//
// public boolean sendMessage(String data) {
// lastSendData = data;
// try {
// PublishMessage publish = new PublishMessage(data);
// collectorProvider.sendRequest(publish.getRequest());
// }
// catch (Exception e)
// {
// logger.error("Error sending message: ", e);
// return false;
// }
// return true;
// }
//
// public CallIdHeader getNewCallId() {
// logger.info("Get new call id: " + collectorProvider);
// return collectorProvider.getNewCallId();
// }
// }
//
// Path: src/com/tt/reaper/sip/ReaperStack.java
// public class ReaperStack {
// private static final String STACK_NAME = "ReaperStack";
// private static Logger logger = Logger.getLogger(ReaperStack.class);
// public static ReaperStack instance = new ReaperStack();
// private SipProvider reaperProvider;
// private static boolean initialized = false;
//
// private ReaperStack()
// {
// }
//
// public synchronized boolean init()
// {
// if (initialized == true)
// return true;
// initialized = true;
// logger.info("Starting the reaper stack...");
// try {
// SipStack sipStack;
// Configuration configuration;
// configuration = new Configuration();
// configuration.setStackName(STACK_NAME);
// SipFactory.getInstance().setPathName("gov.nist");
// sipStack = SipFactory.getInstance().createSipStack(configuration);
// RequestMessage.initFactory(SipFactory.getInstance(), configuration);
// ListeningPoint reaperTcp = sipStack.createListeningPoint("127.0.0.1", configuration.getReadPort(), "tcp");
// reaperProvider = sipStack.createSipProvider(reaperTcp);
// reaperProvider.addSipListener(new ReaperListener());
// reaperProvider.setAutomaticDialogSupportEnabled(false);
// logger.info("Reaper SIP stack initialized successfully");
// }
// catch (Exception e)
// {
// logger.error("Error initializing stack: ", e);
// return false;
// }
// return true;
// }
// }
| import com.tt.reaper.call.CallManager;
import com.tt.reaper.filter.FilterExecute;
import com.tt.reaper.http.WebServer;
import com.tt.reaper.sip.CollectorStack;
import com.tt.reaper.sip.ReaperStack; | package com.tt.reaper;
public class Reaper {
private static boolean initialized = false;
public static Reaper instance = new Reaper();
private Reaper() {
}
public synchronized void init() {
if (initialized == true)
return;
initialized = true;
ReaperLogger.init();
CollectorManager.instance.init();
CallManager.instance.init(); | // Path: src/com/tt/reaper/filter/FilterExecute.java
// public class FilterExecute extends Thread {
// private static Logger logger = Logger.getLogger(FilterExecute.class);
// public static final FilterExecute instance = new FilterExecute();
// private String command;
// private boolean running = false;
//
// private FilterExecute() {
// }
//
// public synchronized void init() {
// command = new Configuration().getCommand();
// if (command == null) {
// logger.error("Filter command not configured");
// }
// if (running == false)
// start();
// running = true;
// }
//
// public void run() {
// try {
// logger.info("Running filter: " + command);
// Process p = Runtime.getRuntime().exec(command);
// p.waitFor();
// logger.warn("Filter exited with return value: " + p.exitValue());
// } catch (Exception e) {
// logger.error("Error running filter: ", e);
// }
// }
//
// }
//
// Path: src/com/tt/reaper/sip/CollectorStack.java
// public class CollectorStack {
// private static final String STACK_NAME = "CollectorStack";
// private static Logger logger = Logger.getLogger(CollectorStack.class);
// public static CollectorStack instance = new CollectorStack();
// private SipProvider collectorProvider;
// private static boolean initialized = false;
// public String lastSendData;
//
// private CollectorStack()
// {
// }
//
// public synchronized boolean init()
// {
// if (initialized == true)
// return true;
// initialized = true;
// logger.info("Starting the collector stack...");
// try {
// SipStack sipStack;
// Configuration configuration;
// configuration = new Configuration();
// configuration.setStackName(STACK_NAME);
// SipFactory.getInstance().setPathName("gov.nist");
// sipStack = SipFactory.getInstance().createSipStack(configuration);
// RequestMessage.initFactory(SipFactory.getInstance(), configuration);
// ListeningPoint reaperUdp = sipStack.createListeningPoint(configuration.getWriteInterface(), configuration.getWritePort(), "udp");
// collectorProvider = sipStack.createSipProvider(reaperUdp);
// collectorProvider.addSipListener(new CollectorListener());
// collectorProvider.setAutomaticDialogSupportEnabled(false);
// logger.info("Collector SIP stack initialized successfully");
// }
// catch (Exception e)
// {
// logger.error("Error initializing stack: ", e);
// return false;
// }
// return true;
// }
//
// public boolean sendResponse(ResponseMessage response) {
// try {
// ServerTransaction st = collectorProvider.getNewServerTransaction(response.getRequest());
// st.sendResponse(response.getResponse());
// }
// catch (Exception e) {
// logger.error("Error sending response: ", e);
// }
// return true;
// }
//
// public boolean sendMessage(String data) {
// lastSendData = data;
// try {
// PublishMessage publish = new PublishMessage(data);
// collectorProvider.sendRequest(publish.getRequest());
// }
// catch (Exception e)
// {
// logger.error("Error sending message: ", e);
// return false;
// }
// return true;
// }
//
// public CallIdHeader getNewCallId() {
// logger.info("Get new call id: " + collectorProvider);
// return collectorProvider.getNewCallId();
// }
// }
//
// Path: src/com/tt/reaper/sip/ReaperStack.java
// public class ReaperStack {
// private static final String STACK_NAME = "ReaperStack";
// private static Logger logger = Logger.getLogger(ReaperStack.class);
// public static ReaperStack instance = new ReaperStack();
// private SipProvider reaperProvider;
// private static boolean initialized = false;
//
// private ReaperStack()
// {
// }
//
// public synchronized boolean init()
// {
// if (initialized == true)
// return true;
// initialized = true;
// logger.info("Starting the reaper stack...");
// try {
// SipStack sipStack;
// Configuration configuration;
// configuration = new Configuration();
// configuration.setStackName(STACK_NAME);
// SipFactory.getInstance().setPathName("gov.nist");
// sipStack = SipFactory.getInstance().createSipStack(configuration);
// RequestMessage.initFactory(SipFactory.getInstance(), configuration);
// ListeningPoint reaperTcp = sipStack.createListeningPoint("127.0.0.1", configuration.getReadPort(), "tcp");
// reaperProvider = sipStack.createSipProvider(reaperTcp);
// reaperProvider.addSipListener(new ReaperListener());
// reaperProvider.setAutomaticDialogSupportEnabled(false);
// logger.info("Reaper SIP stack initialized successfully");
// }
// catch (Exception e)
// {
// logger.error("Error initializing stack: ", e);
// return false;
// }
// return true;
// }
// }
// Path: src/com/tt/reaper/Reaper.java
import com.tt.reaper.call.CallManager;
import com.tt.reaper.filter.FilterExecute;
import com.tt.reaper.http.WebServer;
import com.tt.reaper.sip.CollectorStack;
import com.tt.reaper.sip.ReaperStack;
package com.tt.reaper;
public class Reaper {
private static boolean initialized = false;
public static Reaper instance = new Reaper();
private Reaper() {
}
public synchronized void init() {
if (initialized == true)
return;
initialized = true;
ReaperLogger.init();
CollectorManager.instance.init();
CallManager.instance.init(); | ReaperStack.instance.init(); |
TerryHowe/SIP-Voice-Quality-Report-Reaper | src/com/tt/reaper/Reaper.java | // Path: src/com/tt/reaper/filter/FilterExecute.java
// public class FilterExecute extends Thread {
// private static Logger logger = Logger.getLogger(FilterExecute.class);
// public static final FilterExecute instance = new FilterExecute();
// private String command;
// private boolean running = false;
//
// private FilterExecute() {
// }
//
// public synchronized void init() {
// command = new Configuration().getCommand();
// if (command == null) {
// logger.error("Filter command not configured");
// }
// if (running == false)
// start();
// running = true;
// }
//
// public void run() {
// try {
// logger.info("Running filter: " + command);
// Process p = Runtime.getRuntime().exec(command);
// p.waitFor();
// logger.warn("Filter exited with return value: " + p.exitValue());
// } catch (Exception e) {
// logger.error("Error running filter: ", e);
// }
// }
//
// }
//
// Path: src/com/tt/reaper/sip/CollectorStack.java
// public class CollectorStack {
// private static final String STACK_NAME = "CollectorStack";
// private static Logger logger = Logger.getLogger(CollectorStack.class);
// public static CollectorStack instance = new CollectorStack();
// private SipProvider collectorProvider;
// private static boolean initialized = false;
// public String lastSendData;
//
// private CollectorStack()
// {
// }
//
// public synchronized boolean init()
// {
// if (initialized == true)
// return true;
// initialized = true;
// logger.info("Starting the collector stack...");
// try {
// SipStack sipStack;
// Configuration configuration;
// configuration = new Configuration();
// configuration.setStackName(STACK_NAME);
// SipFactory.getInstance().setPathName("gov.nist");
// sipStack = SipFactory.getInstance().createSipStack(configuration);
// RequestMessage.initFactory(SipFactory.getInstance(), configuration);
// ListeningPoint reaperUdp = sipStack.createListeningPoint(configuration.getWriteInterface(), configuration.getWritePort(), "udp");
// collectorProvider = sipStack.createSipProvider(reaperUdp);
// collectorProvider.addSipListener(new CollectorListener());
// collectorProvider.setAutomaticDialogSupportEnabled(false);
// logger.info("Collector SIP stack initialized successfully");
// }
// catch (Exception e)
// {
// logger.error("Error initializing stack: ", e);
// return false;
// }
// return true;
// }
//
// public boolean sendResponse(ResponseMessage response) {
// try {
// ServerTransaction st = collectorProvider.getNewServerTransaction(response.getRequest());
// st.sendResponse(response.getResponse());
// }
// catch (Exception e) {
// logger.error("Error sending response: ", e);
// }
// return true;
// }
//
// public boolean sendMessage(String data) {
// lastSendData = data;
// try {
// PublishMessage publish = new PublishMessage(data);
// collectorProvider.sendRequest(publish.getRequest());
// }
// catch (Exception e)
// {
// logger.error("Error sending message: ", e);
// return false;
// }
// return true;
// }
//
// public CallIdHeader getNewCallId() {
// logger.info("Get new call id: " + collectorProvider);
// return collectorProvider.getNewCallId();
// }
// }
//
// Path: src/com/tt/reaper/sip/ReaperStack.java
// public class ReaperStack {
// private static final String STACK_NAME = "ReaperStack";
// private static Logger logger = Logger.getLogger(ReaperStack.class);
// public static ReaperStack instance = new ReaperStack();
// private SipProvider reaperProvider;
// private static boolean initialized = false;
//
// private ReaperStack()
// {
// }
//
// public synchronized boolean init()
// {
// if (initialized == true)
// return true;
// initialized = true;
// logger.info("Starting the reaper stack...");
// try {
// SipStack sipStack;
// Configuration configuration;
// configuration = new Configuration();
// configuration.setStackName(STACK_NAME);
// SipFactory.getInstance().setPathName("gov.nist");
// sipStack = SipFactory.getInstance().createSipStack(configuration);
// RequestMessage.initFactory(SipFactory.getInstance(), configuration);
// ListeningPoint reaperTcp = sipStack.createListeningPoint("127.0.0.1", configuration.getReadPort(), "tcp");
// reaperProvider = sipStack.createSipProvider(reaperTcp);
// reaperProvider.addSipListener(new ReaperListener());
// reaperProvider.setAutomaticDialogSupportEnabled(false);
// logger.info("Reaper SIP stack initialized successfully");
// }
// catch (Exception e)
// {
// logger.error("Error initializing stack: ", e);
// return false;
// }
// return true;
// }
// }
| import com.tt.reaper.call.CallManager;
import com.tt.reaper.filter.FilterExecute;
import com.tt.reaper.http.WebServer;
import com.tt.reaper.sip.CollectorStack;
import com.tt.reaper.sip.ReaperStack; | package com.tt.reaper;
public class Reaper {
private static boolean initialized = false;
public static Reaper instance = new Reaper();
private Reaper() {
}
public synchronized void init() {
if (initialized == true)
return;
initialized = true;
ReaperLogger.init();
CollectorManager.instance.init();
CallManager.instance.init();
ReaperStack.instance.init(); | // Path: src/com/tt/reaper/filter/FilterExecute.java
// public class FilterExecute extends Thread {
// private static Logger logger = Logger.getLogger(FilterExecute.class);
// public static final FilterExecute instance = new FilterExecute();
// private String command;
// private boolean running = false;
//
// private FilterExecute() {
// }
//
// public synchronized void init() {
// command = new Configuration().getCommand();
// if (command == null) {
// logger.error("Filter command not configured");
// }
// if (running == false)
// start();
// running = true;
// }
//
// public void run() {
// try {
// logger.info("Running filter: " + command);
// Process p = Runtime.getRuntime().exec(command);
// p.waitFor();
// logger.warn("Filter exited with return value: " + p.exitValue());
// } catch (Exception e) {
// logger.error("Error running filter: ", e);
// }
// }
//
// }
//
// Path: src/com/tt/reaper/sip/CollectorStack.java
// public class CollectorStack {
// private static final String STACK_NAME = "CollectorStack";
// private static Logger logger = Logger.getLogger(CollectorStack.class);
// public static CollectorStack instance = new CollectorStack();
// private SipProvider collectorProvider;
// private static boolean initialized = false;
// public String lastSendData;
//
// private CollectorStack()
// {
// }
//
// public synchronized boolean init()
// {
// if (initialized == true)
// return true;
// initialized = true;
// logger.info("Starting the collector stack...");
// try {
// SipStack sipStack;
// Configuration configuration;
// configuration = new Configuration();
// configuration.setStackName(STACK_NAME);
// SipFactory.getInstance().setPathName("gov.nist");
// sipStack = SipFactory.getInstance().createSipStack(configuration);
// RequestMessage.initFactory(SipFactory.getInstance(), configuration);
// ListeningPoint reaperUdp = sipStack.createListeningPoint(configuration.getWriteInterface(), configuration.getWritePort(), "udp");
// collectorProvider = sipStack.createSipProvider(reaperUdp);
// collectorProvider.addSipListener(new CollectorListener());
// collectorProvider.setAutomaticDialogSupportEnabled(false);
// logger.info("Collector SIP stack initialized successfully");
// }
// catch (Exception e)
// {
// logger.error("Error initializing stack: ", e);
// return false;
// }
// return true;
// }
//
// public boolean sendResponse(ResponseMessage response) {
// try {
// ServerTransaction st = collectorProvider.getNewServerTransaction(response.getRequest());
// st.sendResponse(response.getResponse());
// }
// catch (Exception e) {
// logger.error("Error sending response: ", e);
// }
// return true;
// }
//
// public boolean sendMessage(String data) {
// lastSendData = data;
// try {
// PublishMessage publish = new PublishMessage(data);
// collectorProvider.sendRequest(publish.getRequest());
// }
// catch (Exception e)
// {
// logger.error("Error sending message: ", e);
// return false;
// }
// return true;
// }
//
// public CallIdHeader getNewCallId() {
// logger.info("Get new call id: " + collectorProvider);
// return collectorProvider.getNewCallId();
// }
// }
//
// Path: src/com/tt/reaper/sip/ReaperStack.java
// public class ReaperStack {
// private static final String STACK_NAME = "ReaperStack";
// private static Logger logger = Logger.getLogger(ReaperStack.class);
// public static ReaperStack instance = new ReaperStack();
// private SipProvider reaperProvider;
// private static boolean initialized = false;
//
// private ReaperStack()
// {
// }
//
// public synchronized boolean init()
// {
// if (initialized == true)
// return true;
// initialized = true;
// logger.info("Starting the reaper stack...");
// try {
// SipStack sipStack;
// Configuration configuration;
// configuration = new Configuration();
// configuration.setStackName(STACK_NAME);
// SipFactory.getInstance().setPathName("gov.nist");
// sipStack = SipFactory.getInstance().createSipStack(configuration);
// RequestMessage.initFactory(SipFactory.getInstance(), configuration);
// ListeningPoint reaperTcp = sipStack.createListeningPoint("127.0.0.1", configuration.getReadPort(), "tcp");
// reaperProvider = sipStack.createSipProvider(reaperTcp);
// reaperProvider.addSipListener(new ReaperListener());
// reaperProvider.setAutomaticDialogSupportEnabled(false);
// logger.info("Reaper SIP stack initialized successfully");
// }
// catch (Exception e)
// {
// logger.error("Error initializing stack: ", e);
// return false;
// }
// return true;
// }
// }
// Path: src/com/tt/reaper/Reaper.java
import com.tt.reaper.call.CallManager;
import com.tt.reaper.filter.FilterExecute;
import com.tt.reaper.http.WebServer;
import com.tt.reaper.sip.CollectorStack;
import com.tt.reaper.sip.ReaperStack;
package com.tt.reaper;
public class Reaper {
private static boolean initialized = false;
public static Reaper instance = new Reaper();
private Reaper() {
}
public synchronized void init() {
if (initialized == true)
return;
initialized = true;
ReaperLogger.init();
CollectorManager.instance.init();
CallManager.instance.init();
ReaperStack.instance.init(); | CollectorStack.instance.init(); |
TerryHowe/SIP-Voice-Quality-Report-Reaper | src/com/tt/reaper/Reaper.java | // Path: src/com/tt/reaper/filter/FilterExecute.java
// public class FilterExecute extends Thread {
// private static Logger logger = Logger.getLogger(FilterExecute.class);
// public static final FilterExecute instance = new FilterExecute();
// private String command;
// private boolean running = false;
//
// private FilterExecute() {
// }
//
// public synchronized void init() {
// command = new Configuration().getCommand();
// if (command == null) {
// logger.error("Filter command not configured");
// }
// if (running == false)
// start();
// running = true;
// }
//
// public void run() {
// try {
// logger.info("Running filter: " + command);
// Process p = Runtime.getRuntime().exec(command);
// p.waitFor();
// logger.warn("Filter exited with return value: " + p.exitValue());
// } catch (Exception e) {
// logger.error("Error running filter: ", e);
// }
// }
//
// }
//
// Path: src/com/tt/reaper/sip/CollectorStack.java
// public class CollectorStack {
// private static final String STACK_NAME = "CollectorStack";
// private static Logger logger = Logger.getLogger(CollectorStack.class);
// public static CollectorStack instance = new CollectorStack();
// private SipProvider collectorProvider;
// private static boolean initialized = false;
// public String lastSendData;
//
// private CollectorStack()
// {
// }
//
// public synchronized boolean init()
// {
// if (initialized == true)
// return true;
// initialized = true;
// logger.info("Starting the collector stack...");
// try {
// SipStack sipStack;
// Configuration configuration;
// configuration = new Configuration();
// configuration.setStackName(STACK_NAME);
// SipFactory.getInstance().setPathName("gov.nist");
// sipStack = SipFactory.getInstance().createSipStack(configuration);
// RequestMessage.initFactory(SipFactory.getInstance(), configuration);
// ListeningPoint reaperUdp = sipStack.createListeningPoint(configuration.getWriteInterface(), configuration.getWritePort(), "udp");
// collectorProvider = sipStack.createSipProvider(reaperUdp);
// collectorProvider.addSipListener(new CollectorListener());
// collectorProvider.setAutomaticDialogSupportEnabled(false);
// logger.info("Collector SIP stack initialized successfully");
// }
// catch (Exception e)
// {
// logger.error("Error initializing stack: ", e);
// return false;
// }
// return true;
// }
//
// public boolean sendResponse(ResponseMessage response) {
// try {
// ServerTransaction st = collectorProvider.getNewServerTransaction(response.getRequest());
// st.sendResponse(response.getResponse());
// }
// catch (Exception e) {
// logger.error("Error sending response: ", e);
// }
// return true;
// }
//
// public boolean sendMessage(String data) {
// lastSendData = data;
// try {
// PublishMessage publish = new PublishMessage(data);
// collectorProvider.sendRequest(publish.getRequest());
// }
// catch (Exception e)
// {
// logger.error("Error sending message: ", e);
// return false;
// }
// return true;
// }
//
// public CallIdHeader getNewCallId() {
// logger.info("Get new call id: " + collectorProvider);
// return collectorProvider.getNewCallId();
// }
// }
//
// Path: src/com/tt/reaper/sip/ReaperStack.java
// public class ReaperStack {
// private static final String STACK_NAME = "ReaperStack";
// private static Logger logger = Logger.getLogger(ReaperStack.class);
// public static ReaperStack instance = new ReaperStack();
// private SipProvider reaperProvider;
// private static boolean initialized = false;
//
// private ReaperStack()
// {
// }
//
// public synchronized boolean init()
// {
// if (initialized == true)
// return true;
// initialized = true;
// logger.info("Starting the reaper stack...");
// try {
// SipStack sipStack;
// Configuration configuration;
// configuration = new Configuration();
// configuration.setStackName(STACK_NAME);
// SipFactory.getInstance().setPathName("gov.nist");
// sipStack = SipFactory.getInstance().createSipStack(configuration);
// RequestMessage.initFactory(SipFactory.getInstance(), configuration);
// ListeningPoint reaperTcp = sipStack.createListeningPoint("127.0.0.1", configuration.getReadPort(), "tcp");
// reaperProvider = sipStack.createSipProvider(reaperTcp);
// reaperProvider.addSipListener(new ReaperListener());
// reaperProvider.setAutomaticDialogSupportEnabled(false);
// logger.info("Reaper SIP stack initialized successfully");
// }
// catch (Exception e)
// {
// logger.error("Error initializing stack: ", e);
// return false;
// }
// return true;
// }
// }
| import com.tt.reaper.call.CallManager;
import com.tt.reaper.filter.FilterExecute;
import com.tt.reaper.http.WebServer;
import com.tt.reaper.sip.CollectorStack;
import com.tt.reaper.sip.ReaperStack; | package com.tt.reaper;
public class Reaper {
private static boolean initialized = false;
public static Reaper instance = new Reaper();
private Reaper() {
}
public synchronized void init() {
if (initialized == true)
return;
initialized = true;
ReaperLogger.init();
CollectorManager.instance.init();
CallManager.instance.init();
ReaperStack.instance.init();
CollectorStack.instance.init(); | // Path: src/com/tt/reaper/filter/FilterExecute.java
// public class FilterExecute extends Thread {
// private static Logger logger = Logger.getLogger(FilterExecute.class);
// public static final FilterExecute instance = new FilterExecute();
// private String command;
// private boolean running = false;
//
// private FilterExecute() {
// }
//
// public synchronized void init() {
// command = new Configuration().getCommand();
// if (command == null) {
// logger.error("Filter command not configured");
// }
// if (running == false)
// start();
// running = true;
// }
//
// public void run() {
// try {
// logger.info("Running filter: " + command);
// Process p = Runtime.getRuntime().exec(command);
// p.waitFor();
// logger.warn("Filter exited with return value: " + p.exitValue());
// } catch (Exception e) {
// logger.error("Error running filter: ", e);
// }
// }
//
// }
//
// Path: src/com/tt/reaper/sip/CollectorStack.java
// public class CollectorStack {
// private static final String STACK_NAME = "CollectorStack";
// private static Logger logger = Logger.getLogger(CollectorStack.class);
// public static CollectorStack instance = new CollectorStack();
// private SipProvider collectorProvider;
// private static boolean initialized = false;
// public String lastSendData;
//
// private CollectorStack()
// {
// }
//
// public synchronized boolean init()
// {
// if (initialized == true)
// return true;
// initialized = true;
// logger.info("Starting the collector stack...");
// try {
// SipStack sipStack;
// Configuration configuration;
// configuration = new Configuration();
// configuration.setStackName(STACK_NAME);
// SipFactory.getInstance().setPathName("gov.nist");
// sipStack = SipFactory.getInstance().createSipStack(configuration);
// RequestMessage.initFactory(SipFactory.getInstance(), configuration);
// ListeningPoint reaperUdp = sipStack.createListeningPoint(configuration.getWriteInterface(), configuration.getWritePort(), "udp");
// collectorProvider = sipStack.createSipProvider(reaperUdp);
// collectorProvider.addSipListener(new CollectorListener());
// collectorProvider.setAutomaticDialogSupportEnabled(false);
// logger.info("Collector SIP stack initialized successfully");
// }
// catch (Exception e)
// {
// logger.error("Error initializing stack: ", e);
// return false;
// }
// return true;
// }
//
// public boolean sendResponse(ResponseMessage response) {
// try {
// ServerTransaction st = collectorProvider.getNewServerTransaction(response.getRequest());
// st.sendResponse(response.getResponse());
// }
// catch (Exception e) {
// logger.error("Error sending response: ", e);
// }
// return true;
// }
//
// public boolean sendMessage(String data) {
// lastSendData = data;
// try {
// PublishMessage publish = new PublishMessage(data);
// collectorProvider.sendRequest(publish.getRequest());
// }
// catch (Exception e)
// {
// logger.error("Error sending message: ", e);
// return false;
// }
// return true;
// }
//
// public CallIdHeader getNewCallId() {
// logger.info("Get new call id: " + collectorProvider);
// return collectorProvider.getNewCallId();
// }
// }
//
// Path: src/com/tt/reaper/sip/ReaperStack.java
// public class ReaperStack {
// private static final String STACK_NAME = "ReaperStack";
// private static Logger logger = Logger.getLogger(ReaperStack.class);
// public static ReaperStack instance = new ReaperStack();
// private SipProvider reaperProvider;
// private static boolean initialized = false;
//
// private ReaperStack()
// {
// }
//
// public synchronized boolean init()
// {
// if (initialized == true)
// return true;
// initialized = true;
// logger.info("Starting the reaper stack...");
// try {
// SipStack sipStack;
// Configuration configuration;
// configuration = new Configuration();
// configuration.setStackName(STACK_NAME);
// SipFactory.getInstance().setPathName("gov.nist");
// sipStack = SipFactory.getInstance().createSipStack(configuration);
// RequestMessage.initFactory(SipFactory.getInstance(), configuration);
// ListeningPoint reaperTcp = sipStack.createListeningPoint("127.0.0.1", configuration.getReadPort(), "tcp");
// reaperProvider = sipStack.createSipProvider(reaperTcp);
// reaperProvider.addSipListener(new ReaperListener());
// reaperProvider.setAutomaticDialogSupportEnabled(false);
// logger.info("Reaper SIP stack initialized successfully");
// }
// catch (Exception e)
// {
// logger.error("Error initializing stack: ", e);
// return false;
// }
// return true;
// }
// }
// Path: src/com/tt/reaper/Reaper.java
import com.tt.reaper.call.CallManager;
import com.tt.reaper.filter.FilterExecute;
import com.tt.reaper.http.WebServer;
import com.tt.reaper.sip.CollectorStack;
import com.tt.reaper.sip.ReaperStack;
package com.tt.reaper;
public class Reaper {
private static boolean initialized = false;
public static Reaper instance = new Reaper();
private Reaper() {
}
public synchronized void init() {
if (initialized == true)
return;
initialized = true;
ReaperLogger.init();
CollectorManager.instance.init();
CallManager.instance.init();
ReaperStack.instance.init();
CollectorStack.instance.init(); | FilterExecute.instance.init(); |
TerryHowe/SIP-Voice-Quality-Report-Reaper | test/com/tt/reaper/rtcp/TestRtcpPacket.java | // Path: src/com/tt/reaper/message/NotifyMessage.java
// public class NotifyMessage extends RequestMessage {
// public NotifyMessage(Request request) {
// super(Message.NOTIFY, request);
// }
//
// public NotifyMessage(String data)
// {
// super(SipMessage.NOTIFY, Request.NOTIFY, getNewCallId());
// init(data);
// }
//
// private boolean init(String data)
// {
// if (super.init() == false)
// return false;
// try {
// ContentTypeHeader contentTypeHeader;
// contentTypeHeader = headerFactory
// .createContentTypeHeader("application", "text/plain");
// request.setContent(data, contentTypeHeader);
// return true;
// }
// catch (Exception e)
// {
// logger.error("Error adding content: ", e);
// }
// return false;
// }
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.FileInputStream;
import java.util.Iterator;
import org.junit.Test;
import com.tt.reaper.message.NotifyMessage; | package com.tt.reaper.rtcp;
public class TestRtcpPacket {
public static final String XRFILE = "data/rtcpxr.data";
public static final String RECEIVER_FILE = "data/rtcp_receiver_report.data";
public static final String SENDER_FILE = "data/rtcp_sender_report.data";
public static final String SOURCE_MAC = "00:00:00:00:00:00";
public static final String SOURCE_IP = "10.0.100.1";
public static final int SOURCE_PORT = 9091;
public static final String DESTINATION_MAC = "01:01:01:01:01:01";
public static final String DESTINATION_IP = "100.1.1.1";
public static final int DESTINATION_PORT = 8081;
private static final int BUFFER_SIZE = 1024;
private static byte[] buffer = new byte[BUFFER_SIZE];
public static DataPacket create(String fileName)
{ | // Path: src/com/tt/reaper/message/NotifyMessage.java
// public class NotifyMessage extends RequestMessage {
// public NotifyMessage(Request request) {
// super(Message.NOTIFY, request);
// }
//
// public NotifyMessage(String data)
// {
// super(SipMessage.NOTIFY, Request.NOTIFY, getNewCallId());
// init(data);
// }
//
// private boolean init(String data)
// {
// if (super.init() == false)
// return false;
// try {
// ContentTypeHeader contentTypeHeader;
// contentTypeHeader = headerFactory
// .createContentTypeHeader("application", "text/plain");
// request.setContent(data, contentTypeHeader);
// return true;
// }
// catch (Exception e)
// {
// logger.error("Error adding content: ", e);
// }
// return false;
// }
// }
// Path: test/com/tt/reaper/rtcp/TestRtcpPacket.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.FileInputStream;
import java.util.Iterator;
import org.junit.Test;
import com.tt.reaper.message.NotifyMessage;
package com.tt.reaper.rtcp;
public class TestRtcpPacket {
public static final String XRFILE = "data/rtcpxr.data";
public static final String RECEIVER_FILE = "data/rtcp_receiver_report.data";
public static final String SENDER_FILE = "data/rtcp_sender_report.data";
public static final String SOURCE_MAC = "00:00:00:00:00:00";
public static final String SOURCE_IP = "10.0.100.1";
public static final int SOURCE_PORT = 9091;
public static final String DESTINATION_MAC = "01:01:01:01:01:01";
public static final String DESTINATION_IP = "100.1.1.1";
public static final int DESTINATION_PORT = 8081;
private static final int BUFFER_SIZE = 1024;
private static byte[] buffer = new byte[BUFFER_SIZE];
public static DataPacket create(String fileName)
{ | NotifyMessage message = createDatagram(fileName); |
TerryHowe/SIP-Voice-Quality-Report-Reaper | src/com/tt/reaper/call/CallContext.java | // Path: src/com/tt/reaper/rtcp/DataPacket.java
// public class DataPacket extends Message {
// private String sourceMacAddress;
// private String sourceIPAddress;
// private int sourcePort;
// private String destinationMacAddress;
// private String destinationIPAddress;
// private int destinationPort;
// private ArrayList<RtcpPacket> list = new ArrayList<RtcpPacket>();
//
// public DataPacket(byte[] content) {
// super(Message.DATA_PACKET);
// if (content == null)
// return;
// String header = new String(content);
// String[] fields = header.split(";");
// if (fields.length < 6) {
// logger.error("Failed to parse content");
// return;
// }
// sourceMacAddress = fields[0];
// sourceIPAddress = fields[1];
// sourcePort = Integer.parseInt(fields[2]);
// destinationMacAddress = fields[3];
// destinationIPAddress = fields[4];
// destinationPort = Integer.parseInt(fields[5]);
//
// String encodedData = fields[6];
// byte[] rtcpPacket = new byte[encodedData.length()/2];
// int index = 0;
// for (int j=0; j<rtcpPacket.length; j++)
// rtcpPacket[j] = (byte) Integer.parseInt("" + encodedData.charAt(index++) + encodedData.charAt(index++), 16);
//
// int offset = 0;
// while (offset < rtcpPacket.length) {
// RtcpPacket packet = null;
// switch (RtcpPacket.probePacketType(rtcpPacket, offset)) {
// case RtcpPacket.TYPE_SENDER_REPORT:
// packet = new RtcpSenderReport(rtcpPacket, offset);
// break;
// case RtcpPacket.TYPE_RECEIVER_REPORT:
// packet = new RtcpReceiverReport(rtcpPacket, offset);
// break;
// case RtcpPacket.TYPE_SOURCE_DESCRIPTION:
// packet = new RtcpSourceDescription(rtcpPacket, offset);
// break;
// case RtcpPacket.TYPE_GOODBYE:
// case RtcpPacket.TYPE_APPLICATION_DEFINED:
// packet = new RtcpPacket(rtcpPacket, offset);
// break;
// case RtcpPacket.TYPE_EXTENDED_REPORT:
// packet = new RtcpExtendedReport(rtcpPacket, offset);
// break;
// default:
// logger.error("Unexpected packet type: " + RtcpPacket.probePacketType(rtcpPacket, offset));
// ++offset;
// }
// if (packet == null)
// break;
// list.add(packet);
// offset += packet.getLength();
// }
// }
//
// public Iterator<RtcpPacket> getIterator() {
// return list.iterator();
// }
//
// public String getSource() {
// return sourceIPAddress + ":" + sourcePort;
// }
//
// public String getDestination() {
// return destinationIPAddress + ":" + destinationPort;
// }
//
// public String toString() {
// return "DataPacket(" + getSource() + "," + getDestination() + ")";
// }
//
// public String getSourceMac() {
// return sourceMacAddress;
// }
//
// public String getDestinationMac() {
// return destinationMacAddress;
// }
// }
//
// Path: src/com/tt/reaper/vq/LocalMetrics.java
// public class LocalMetrics extends Metrics {
// private static final String NAME = "LocalMetrics";
//
// LocalMetrics()
// {
// super(NAME);
// }
//
// public LocalMetrics(CallContext context, AudioData data) {
// super(NAME, context, data);
// }
// }
| import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import org.apache.log4j.Logger;
import com.tt.reaper.message.Message;
import com.tt.reaper.rtcp.DataPacket;
import com.tt.reaper.vq.LocalMetrics; | package com.tt.reaper.call;
public class CallContext {
protected static Logger logger = Logger.getLogger(CallContext.class);
public State state = StateInvited.instance;
public Date startTime;
public Date endTime;
public String from;
public String to;
public String callId;
public String fromMac;
public String toMac; | // Path: src/com/tt/reaper/rtcp/DataPacket.java
// public class DataPacket extends Message {
// private String sourceMacAddress;
// private String sourceIPAddress;
// private int sourcePort;
// private String destinationMacAddress;
// private String destinationIPAddress;
// private int destinationPort;
// private ArrayList<RtcpPacket> list = new ArrayList<RtcpPacket>();
//
// public DataPacket(byte[] content) {
// super(Message.DATA_PACKET);
// if (content == null)
// return;
// String header = new String(content);
// String[] fields = header.split(";");
// if (fields.length < 6) {
// logger.error("Failed to parse content");
// return;
// }
// sourceMacAddress = fields[0];
// sourceIPAddress = fields[1];
// sourcePort = Integer.parseInt(fields[2]);
// destinationMacAddress = fields[3];
// destinationIPAddress = fields[4];
// destinationPort = Integer.parseInt(fields[5]);
//
// String encodedData = fields[6];
// byte[] rtcpPacket = new byte[encodedData.length()/2];
// int index = 0;
// for (int j=0; j<rtcpPacket.length; j++)
// rtcpPacket[j] = (byte) Integer.parseInt("" + encodedData.charAt(index++) + encodedData.charAt(index++), 16);
//
// int offset = 0;
// while (offset < rtcpPacket.length) {
// RtcpPacket packet = null;
// switch (RtcpPacket.probePacketType(rtcpPacket, offset)) {
// case RtcpPacket.TYPE_SENDER_REPORT:
// packet = new RtcpSenderReport(rtcpPacket, offset);
// break;
// case RtcpPacket.TYPE_RECEIVER_REPORT:
// packet = new RtcpReceiverReport(rtcpPacket, offset);
// break;
// case RtcpPacket.TYPE_SOURCE_DESCRIPTION:
// packet = new RtcpSourceDescription(rtcpPacket, offset);
// break;
// case RtcpPacket.TYPE_GOODBYE:
// case RtcpPacket.TYPE_APPLICATION_DEFINED:
// packet = new RtcpPacket(rtcpPacket, offset);
// break;
// case RtcpPacket.TYPE_EXTENDED_REPORT:
// packet = new RtcpExtendedReport(rtcpPacket, offset);
// break;
// default:
// logger.error("Unexpected packet type: " + RtcpPacket.probePacketType(rtcpPacket, offset));
// ++offset;
// }
// if (packet == null)
// break;
// list.add(packet);
// offset += packet.getLength();
// }
// }
//
// public Iterator<RtcpPacket> getIterator() {
// return list.iterator();
// }
//
// public String getSource() {
// return sourceIPAddress + ":" + sourcePort;
// }
//
// public String getDestination() {
// return destinationIPAddress + ":" + destinationPort;
// }
//
// public String toString() {
// return "DataPacket(" + getSource() + "," + getDestination() + ")";
// }
//
// public String getSourceMac() {
// return sourceMacAddress;
// }
//
// public String getDestinationMac() {
// return destinationMacAddress;
// }
// }
//
// Path: src/com/tt/reaper/vq/LocalMetrics.java
// public class LocalMetrics extends Metrics {
// private static final String NAME = "LocalMetrics";
//
// LocalMetrics()
// {
// super(NAME);
// }
//
// public LocalMetrics(CallContext context, AudioData data) {
// super(NAME, context, data);
// }
// }
// Path: src/com/tt/reaper/call/CallContext.java
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import org.apache.log4j.Logger;
import com.tt.reaper.message.Message;
import com.tt.reaper.rtcp.DataPacket;
import com.tt.reaper.vq.LocalMetrics;
package com.tt.reaper.call;
public class CallContext {
protected static Logger logger = Logger.getLogger(CallContext.class);
public State state = StateInvited.instance;
public Date startTime;
public Date endTime;
public String from;
public String to;
public String callId;
public String fromMac;
public String toMac; | public LocalMetrics localMetrics; |
TerryHowe/SIP-Voice-Quality-Report-Reaper | src/com/tt/reaper/call/CallContext.java | // Path: src/com/tt/reaper/rtcp/DataPacket.java
// public class DataPacket extends Message {
// private String sourceMacAddress;
// private String sourceIPAddress;
// private int sourcePort;
// private String destinationMacAddress;
// private String destinationIPAddress;
// private int destinationPort;
// private ArrayList<RtcpPacket> list = new ArrayList<RtcpPacket>();
//
// public DataPacket(byte[] content) {
// super(Message.DATA_PACKET);
// if (content == null)
// return;
// String header = new String(content);
// String[] fields = header.split(";");
// if (fields.length < 6) {
// logger.error("Failed to parse content");
// return;
// }
// sourceMacAddress = fields[0];
// sourceIPAddress = fields[1];
// sourcePort = Integer.parseInt(fields[2]);
// destinationMacAddress = fields[3];
// destinationIPAddress = fields[4];
// destinationPort = Integer.parseInt(fields[5]);
//
// String encodedData = fields[6];
// byte[] rtcpPacket = new byte[encodedData.length()/2];
// int index = 0;
// for (int j=0; j<rtcpPacket.length; j++)
// rtcpPacket[j] = (byte) Integer.parseInt("" + encodedData.charAt(index++) + encodedData.charAt(index++), 16);
//
// int offset = 0;
// while (offset < rtcpPacket.length) {
// RtcpPacket packet = null;
// switch (RtcpPacket.probePacketType(rtcpPacket, offset)) {
// case RtcpPacket.TYPE_SENDER_REPORT:
// packet = new RtcpSenderReport(rtcpPacket, offset);
// break;
// case RtcpPacket.TYPE_RECEIVER_REPORT:
// packet = new RtcpReceiverReport(rtcpPacket, offset);
// break;
// case RtcpPacket.TYPE_SOURCE_DESCRIPTION:
// packet = new RtcpSourceDescription(rtcpPacket, offset);
// break;
// case RtcpPacket.TYPE_GOODBYE:
// case RtcpPacket.TYPE_APPLICATION_DEFINED:
// packet = new RtcpPacket(rtcpPacket, offset);
// break;
// case RtcpPacket.TYPE_EXTENDED_REPORT:
// packet = new RtcpExtendedReport(rtcpPacket, offset);
// break;
// default:
// logger.error("Unexpected packet type: " + RtcpPacket.probePacketType(rtcpPacket, offset));
// ++offset;
// }
// if (packet == null)
// break;
// list.add(packet);
// offset += packet.getLength();
// }
// }
//
// public Iterator<RtcpPacket> getIterator() {
// return list.iterator();
// }
//
// public String getSource() {
// return sourceIPAddress + ":" + sourcePort;
// }
//
// public String getDestination() {
// return destinationIPAddress + ":" + destinationPort;
// }
//
// public String toString() {
// return "DataPacket(" + getSource() + "," + getDestination() + ")";
// }
//
// public String getSourceMac() {
// return sourceMacAddress;
// }
//
// public String getDestinationMac() {
// return destinationMacAddress;
// }
// }
//
// Path: src/com/tt/reaper/vq/LocalMetrics.java
// public class LocalMetrics extends Metrics {
// private static final String NAME = "LocalMetrics";
//
// LocalMetrics()
// {
// super(NAME);
// }
//
// public LocalMetrics(CallContext context, AudioData data) {
// super(NAME, context, data);
// }
// }
| import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import org.apache.log4j.Logger;
import com.tt.reaper.message.Message;
import com.tt.reaper.rtcp.DataPacket;
import com.tt.reaper.vq.LocalMetrics; | }
public void setAudioFrom(ArrayList<AudioData> list) {
if (list == null)
return;
Iterator<AudioData> it;
it = list.iterator();
while (it.hasNext()) {
AudioData data = it.next();
data.from = true;
CallManager.instance.register(this, data.getIpRtpPort());
CallManager.instance.register(this, data.getIpRtcpPort());
audioFrom.add(data);
}
}
public void setAudioTo(ArrayList<AudioData> list) {
if (list == null)
return;
Iterator<AudioData> it;
it = list.iterator();
while (it.hasNext()) {
AudioData data = it.next();
data.from = false;
CallManager.instance.register(this, data.getIpRtpPort());
CallManager.instance.register(this, data.getIpRtcpPort());
audioTo.add(data);
}
}
| // Path: src/com/tt/reaper/rtcp/DataPacket.java
// public class DataPacket extends Message {
// private String sourceMacAddress;
// private String sourceIPAddress;
// private int sourcePort;
// private String destinationMacAddress;
// private String destinationIPAddress;
// private int destinationPort;
// private ArrayList<RtcpPacket> list = new ArrayList<RtcpPacket>();
//
// public DataPacket(byte[] content) {
// super(Message.DATA_PACKET);
// if (content == null)
// return;
// String header = new String(content);
// String[] fields = header.split(";");
// if (fields.length < 6) {
// logger.error("Failed to parse content");
// return;
// }
// sourceMacAddress = fields[0];
// sourceIPAddress = fields[1];
// sourcePort = Integer.parseInt(fields[2]);
// destinationMacAddress = fields[3];
// destinationIPAddress = fields[4];
// destinationPort = Integer.parseInt(fields[5]);
//
// String encodedData = fields[6];
// byte[] rtcpPacket = new byte[encodedData.length()/2];
// int index = 0;
// for (int j=0; j<rtcpPacket.length; j++)
// rtcpPacket[j] = (byte) Integer.parseInt("" + encodedData.charAt(index++) + encodedData.charAt(index++), 16);
//
// int offset = 0;
// while (offset < rtcpPacket.length) {
// RtcpPacket packet = null;
// switch (RtcpPacket.probePacketType(rtcpPacket, offset)) {
// case RtcpPacket.TYPE_SENDER_REPORT:
// packet = new RtcpSenderReport(rtcpPacket, offset);
// break;
// case RtcpPacket.TYPE_RECEIVER_REPORT:
// packet = new RtcpReceiverReport(rtcpPacket, offset);
// break;
// case RtcpPacket.TYPE_SOURCE_DESCRIPTION:
// packet = new RtcpSourceDescription(rtcpPacket, offset);
// break;
// case RtcpPacket.TYPE_GOODBYE:
// case RtcpPacket.TYPE_APPLICATION_DEFINED:
// packet = new RtcpPacket(rtcpPacket, offset);
// break;
// case RtcpPacket.TYPE_EXTENDED_REPORT:
// packet = new RtcpExtendedReport(rtcpPacket, offset);
// break;
// default:
// logger.error("Unexpected packet type: " + RtcpPacket.probePacketType(rtcpPacket, offset));
// ++offset;
// }
// if (packet == null)
// break;
// list.add(packet);
// offset += packet.getLength();
// }
// }
//
// public Iterator<RtcpPacket> getIterator() {
// return list.iterator();
// }
//
// public String getSource() {
// return sourceIPAddress + ":" + sourcePort;
// }
//
// public String getDestination() {
// return destinationIPAddress + ":" + destinationPort;
// }
//
// public String toString() {
// return "DataPacket(" + getSource() + "," + getDestination() + ")";
// }
//
// public String getSourceMac() {
// return sourceMacAddress;
// }
//
// public String getDestinationMac() {
// return destinationMacAddress;
// }
// }
//
// Path: src/com/tt/reaper/vq/LocalMetrics.java
// public class LocalMetrics extends Metrics {
// private static final String NAME = "LocalMetrics";
//
// LocalMetrics()
// {
// super(NAME);
// }
//
// public LocalMetrics(CallContext context, AudioData data) {
// super(NAME, context, data);
// }
// }
// Path: src/com/tt/reaper/call/CallContext.java
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import org.apache.log4j.Logger;
import com.tt.reaper.message.Message;
import com.tt.reaper.rtcp.DataPacket;
import com.tt.reaper.vq.LocalMetrics;
}
public void setAudioFrom(ArrayList<AudioData> list) {
if (list == null)
return;
Iterator<AudioData> it;
it = list.iterator();
while (it.hasNext()) {
AudioData data = it.next();
data.from = true;
CallManager.instance.register(this, data.getIpRtpPort());
CallManager.instance.register(this, data.getIpRtcpPort());
audioFrom.add(data);
}
}
public void setAudioTo(ArrayList<AudioData> list) {
if (list == null)
return;
Iterator<AudioData> it;
it = list.iterator();
while (it.hasNext()) {
AudioData data = it.next();
data.from = false;
CallManager.instance.register(this, data.getIpRtpPort());
CallManager.instance.register(this, data.getIpRtcpPort());
audioTo.add(data);
}
}
| LocalMetrics createMetrics(DataPacket packet) |
TerryHowe/SIP-Voice-Quality-Report-Reaper | test/com/tt/reaper/sip/MockCollector.java | // Path: src/com/tt/reaper/Configuration.java
// public class Configuration extends Properties {
// private static final long serialVersionUID = 1L;
// private static Logger logger = Logger.getLogger(Configuration.class);
// private static final String FILE_NAME = "config/reaper.properties";
// public static final String STACK_NAME = "javax.sip.STACK_NAME";
// public static final String STACK_TRACE_LEVEL = "gov.nist.javax.sip.TRACE_LEVEL";
// public static final String STACK_SERVER_LOG = "gov.nist.javax.sip.SERVER_LOG";
// public static final String STACK_DEBUG_LOG = "gov.nist.javax.sip.DEBUG_LOG";
// private static final String READ_INTERFACE = "readInterface";
// private static final String READ_PORT = "readPort";
// private static final String WRITE_INTERFACE = "writeInterface";
// private static final String FROM_PORT = "fromPort";
// private static final String FROM_USERNAME = "fromUsername";
// private static final String COLLECTOR_HOST = "collectorHost";
// private static final String COLLECTOR_PORT = "collectorPort";
// private static final String COLLECTOR_USERNAME = "collectorUsername";
// private static final String COMMAND_ARGUMENTS = "commandArguments";
// private static final String SOFTWARE_VERSION = "softwareVersion";
//
// public Configuration()
// {
// try {
// FileInputStream in = new FileInputStream(FILE_NAME);
// load(in);
// in.close();
// }
// catch (Exception e)
// {
// logger.error("Error reading properties file");
// }
// }
//
// public void setStackName(String value) {
// setProperty(STACK_NAME, value);
// }
//
// public String getStackTraceLevel() {
// return getProperty(Configuration.STACK_TRACE_LEVEL, "0");
// }
//
// public String getStackServerLog() {
// return getProperty(Configuration.STACK_SERVER_LOG, "/dev/null");
// }
//
// public String getStackDebugLog() {
// return getProperty(Configuration.STACK_DEBUG_LOG, "/dev/null");
// }
//
// public String getReadInterface() {
// return getProperty(Configuration.READ_INTERFACE, "eth0");
// }
//
//
// public int getReadPort() {
// try {
// return Integer.parseInt(getProperty(Configuration.READ_PORT, "5050"));
// }
// catch (Exception e)
// {
// logger.error("Error reading port configuration: ", e);
// }
// return 5050;
// }
//
// public String getWriteInterface() {
// return Nics.getIp(getProperty(Configuration.WRITE_INTERFACE, "lo"));
// }
//
// public int getWritePort() {
// try {
// return Integer.parseInt(getProperty(Configuration.FROM_PORT, "5060"));
// }
// catch (Exception e)
// {
// logger.error("Error reading port configuration: ", e);
// }
// return 5060;
// }
//
// public String getWriteUsername() {
// return getProperty(Configuration.FROM_USERNAME, "reaper");
// }
//
// public String getCollectorHost() {
// return getProperty(Configuration.COLLECTOR_HOST, "127.0.0.3");
// }
//
// public int getCollectorPort() {
// try {
// return Integer.parseInt(getProperty(Configuration.COLLECTOR_PORT, "5060"));
// }
// catch (Exception e)
// {
// logger.error("Error reading port configuration: ", e);
// }
// return 5060;
// }
//
// public String getCollectorUsername() {
// return getProperty(Configuration.COLLECTOR_USERNAME, "collector");
// }
//
// public String getCommand() {
// return "/opt/reaper/bin/filter.sh " + getProperty(Configuration.COMMAND_ARGUMENTS, " -n -e ") + " -i " + getReadInterface();
// }
//
// public String getSoftwareVersion() {
// return getProperty(Configuration.SOFTWARE_VERSION, "reaperv1.0");
// }
// }
| import java.io.FileInputStream;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import com.tt.reaper.Configuration; | package com.tt.reaper.sip;
public class MockCollector extends Thread {
public static final MockCollector instance = new MockCollector();
DatagramSocket socket;
byte[] buffer = new byte[2048]; | // Path: src/com/tt/reaper/Configuration.java
// public class Configuration extends Properties {
// private static final long serialVersionUID = 1L;
// private static Logger logger = Logger.getLogger(Configuration.class);
// private static final String FILE_NAME = "config/reaper.properties";
// public static final String STACK_NAME = "javax.sip.STACK_NAME";
// public static final String STACK_TRACE_LEVEL = "gov.nist.javax.sip.TRACE_LEVEL";
// public static final String STACK_SERVER_LOG = "gov.nist.javax.sip.SERVER_LOG";
// public static final String STACK_DEBUG_LOG = "gov.nist.javax.sip.DEBUG_LOG";
// private static final String READ_INTERFACE = "readInterface";
// private static final String READ_PORT = "readPort";
// private static final String WRITE_INTERFACE = "writeInterface";
// private static final String FROM_PORT = "fromPort";
// private static final String FROM_USERNAME = "fromUsername";
// private static final String COLLECTOR_HOST = "collectorHost";
// private static final String COLLECTOR_PORT = "collectorPort";
// private static final String COLLECTOR_USERNAME = "collectorUsername";
// private static final String COMMAND_ARGUMENTS = "commandArguments";
// private static final String SOFTWARE_VERSION = "softwareVersion";
//
// public Configuration()
// {
// try {
// FileInputStream in = new FileInputStream(FILE_NAME);
// load(in);
// in.close();
// }
// catch (Exception e)
// {
// logger.error("Error reading properties file");
// }
// }
//
// public void setStackName(String value) {
// setProperty(STACK_NAME, value);
// }
//
// public String getStackTraceLevel() {
// return getProperty(Configuration.STACK_TRACE_LEVEL, "0");
// }
//
// public String getStackServerLog() {
// return getProperty(Configuration.STACK_SERVER_LOG, "/dev/null");
// }
//
// public String getStackDebugLog() {
// return getProperty(Configuration.STACK_DEBUG_LOG, "/dev/null");
// }
//
// public String getReadInterface() {
// return getProperty(Configuration.READ_INTERFACE, "eth0");
// }
//
//
// public int getReadPort() {
// try {
// return Integer.parseInt(getProperty(Configuration.READ_PORT, "5050"));
// }
// catch (Exception e)
// {
// logger.error("Error reading port configuration: ", e);
// }
// return 5050;
// }
//
// public String getWriteInterface() {
// return Nics.getIp(getProperty(Configuration.WRITE_INTERFACE, "lo"));
// }
//
// public int getWritePort() {
// try {
// return Integer.parseInt(getProperty(Configuration.FROM_PORT, "5060"));
// }
// catch (Exception e)
// {
// logger.error("Error reading port configuration: ", e);
// }
// return 5060;
// }
//
// public String getWriteUsername() {
// return getProperty(Configuration.FROM_USERNAME, "reaper");
// }
//
// public String getCollectorHost() {
// return getProperty(Configuration.COLLECTOR_HOST, "127.0.0.3");
// }
//
// public int getCollectorPort() {
// try {
// return Integer.parseInt(getProperty(Configuration.COLLECTOR_PORT, "5060"));
// }
// catch (Exception e)
// {
// logger.error("Error reading port configuration: ", e);
// }
// return 5060;
// }
//
// public String getCollectorUsername() {
// return getProperty(Configuration.COLLECTOR_USERNAME, "collector");
// }
//
// public String getCommand() {
// return "/opt/reaper/bin/filter.sh " + getProperty(Configuration.COMMAND_ARGUMENTS, " -n -e ") + " -i " + getReadInterface();
// }
//
// public String getSoftwareVersion() {
// return getProperty(Configuration.SOFTWARE_VERSION, "reaperv1.0");
// }
// }
// Path: test/com/tt/reaper/sip/MockCollector.java
import java.io.FileInputStream;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import com.tt.reaper.Configuration;
package com.tt.reaper.sip;
public class MockCollector extends Thread {
public static final MockCollector instance = new MockCollector();
DatagramSocket socket;
byte[] buffer = new byte[2048]; | Configuration configuration = new Configuration(); |
TerryHowe/SIP-Voice-Quality-Report-Reaper | src/com/tt/reaper/call/StateTerminating.java | // Path: src/com/tt/reaper/sip/CollectorStack.java
// public class CollectorStack {
// private static final String STACK_NAME = "CollectorStack";
// private static Logger logger = Logger.getLogger(CollectorStack.class);
// public static CollectorStack instance = new CollectorStack();
// private SipProvider collectorProvider;
// private static boolean initialized = false;
// public String lastSendData;
//
// private CollectorStack()
// {
// }
//
// public synchronized boolean init()
// {
// if (initialized == true)
// return true;
// initialized = true;
// logger.info("Starting the collector stack...");
// try {
// SipStack sipStack;
// Configuration configuration;
// configuration = new Configuration();
// configuration.setStackName(STACK_NAME);
// SipFactory.getInstance().setPathName("gov.nist");
// sipStack = SipFactory.getInstance().createSipStack(configuration);
// RequestMessage.initFactory(SipFactory.getInstance(), configuration);
// ListeningPoint reaperUdp = sipStack.createListeningPoint(configuration.getWriteInterface(), configuration.getWritePort(), "udp");
// collectorProvider = sipStack.createSipProvider(reaperUdp);
// collectorProvider.addSipListener(new CollectorListener());
// collectorProvider.setAutomaticDialogSupportEnabled(false);
// logger.info("Collector SIP stack initialized successfully");
// }
// catch (Exception e)
// {
// logger.error("Error initializing stack: ", e);
// return false;
// }
// return true;
// }
//
// public boolean sendResponse(ResponseMessage response) {
// try {
// ServerTransaction st = collectorProvider.getNewServerTransaction(response.getRequest());
// st.sendResponse(response.getResponse());
// }
// catch (Exception e) {
// logger.error("Error sending response: ", e);
// }
// return true;
// }
//
// public boolean sendMessage(String data) {
// lastSendData = data;
// try {
// PublishMessage publish = new PublishMessage(data);
// collectorProvider.sendRequest(publish.getRequest());
// }
// catch (Exception e)
// {
// logger.error("Error sending message: ", e);
// return false;
// }
// return true;
// }
//
// public CallIdHeader getNewCallId() {
// logger.info("Get new call id: " + collectorProvider);
// return collectorProvider.getNewCallId();
// }
// }
//
// Path: src/com/tt/reaper/vq/LocalMetrics.java
// public class LocalMetrics extends Metrics {
// private static final String NAME = "LocalMetrics";
//
// LocalMetrics()
// {
// super(NAME);
// }
//
// public LocalMetrics(CallContext context, AudioData data) {
// super(NAME, context, data);
// }
// }
//
// Path: src/com/tt/reaper/vq/VQSessionReport.java
// public class VQSessionReport extends VQReportEvent {
// private static final String HEADER = "VQSessionReport : CallTerm\r\n";
//
// public VQSessionReport(LocalMetrics localMetrics) {
// super(HEADER, localMetrics);
// }
// }
| import java.util.Iterator;
import com.tt.reaper.message.Message;
import com.tt.reaper.message.RtpPacket;
import com.tt.reaper.sip.CollectorStack;
import com.tt.reaper.vq.LocalMetrics;
import com.tt.reaper.vq.VQSessionReport; | package com.tt.reaper.call;
public class StateTerminating extends State {
public static final StateTerminating instance = new StateTerminating();
private StateTerminating()
{
}
State process(CallContext context, Message message)
{
switch (message.getType())
{
case Message.SUCCESS:
case Message.FAILURE:
Iterator<AudioData> it;
it = context.audioFrom.iterator();
while (it.hasNext()) {
AudioData data = it.next();
data.close(); | // Path: src/com/tt/reaper/sip/CollectorStack.java
// public class CollectorStack {
// private static final String STACK_NAME = "CollectorStack";
// private static Logger logger = Logger.getLogger(CollectorStack.class);
// public static CollectorStack instance = new CollectorStack();
// private SipProvider collectorProvider;
// private static boolean initialized = false;
// public String lastSendData;
//
// private CollectorStack()
// {
// }
//
// public synchronized boolean init()
// {
// if (initialized == true)
// return true;
// initialized = true;
// logger.info("Starting the collector stack...");
// try {
// SipStack sipStack;
// Configuration configuration;
// configuration = new Configuration();
// configuration.setStackName(STACK_NAME);
// SipFactory.getInstance().setPathName("gov.nist");
// sipStack = SipFactory.getInstance().createSipStack(configuration);
// RequestMessage.initFactory(SipFactory.getInstance(), configuration);
// ListeningPoint reaperUdp = sipStack.createListeningPoint(configuration.getWriteInterface(), configuration.getWritePort(), "udp");
// collectorProvider = sipStack.createSipProvider(reaperUdp);
// collectorProvider.addSipListener(new CollectorListener());
// collectorProvider.setAutomaticDialogSupportEnabled(false);
// logger.info("Collector SIP stack initialized successfully");
// }
// catch (Exception e)
// {
// logger.error("Error initializing stack: ", e);
// return false;
// }
// return true;
// }
//
// public boolean sendResponse(ResponseMessage response) {
// try {
// ServerTransaction st = collectorProvider.getNewServerTransaction(response.getRequest());
// st.sendResponse(response.getResponse());
// }
// catch (Exception e) {
// logger.error("Error sending response: ", e);
// }
// return true;
// }
//
// public boolean sendMessage(String data) {
// lastSendData = data;
// try {
// PublishMessage publish = new PublishMessage(data);
// collectorProvider.sendRequest(publish.getRequest());
// }
// catch (Exception e)
// {
// logger.error("Error sending message: ", e);
// return false;
// }
// return true;
// }
//
// public CallIdHeader getNewCallId() {
// logger.info("Get new call id: " + collectorProvider);
// return collectorProvider.getNewCallId();
// }
// }
//
// Path: src/com/tt/reaper/vq/LocalMetrics.java
// public class LocalMetrics extends Metrics {
// private static final String NAME = "LocalMetrics";
//
// LocalMetrics()
// {
// super(NAME);
// }
//
// public LocalMetrics(CallContext context, AudioData data) {
// super(NAME, context, data);
// }
// }
//
// Path: src/com/tt/reaper/vq/VQSessionReport.java
// public class VQSessionReport extends VQReportEvent {
// private static final String HEADER = "VQSessionReport : CallTerm\r\n";
//
// public VQSessionReport(LocalMetrics localMetrics) {
// super(HEADER, localMetrics);
// }
// }
// Path: src/com/tt/reaper/call/StateTerminating.java
import java.util.Iterator;
import com.tt.reaper.message.Message;
import com.tt.reaper.message.RtpPacket;
import com.tt.reaper.sip.CollectorStack;
import com.tt.reaper.vq.LocalMetrics;
import com.tt.reaper.vq.VQSessionReport;
package com.tt.reaper.call;
public class StateTerminating extends State {
public static final StateTerminating instance = new StateTerminating();
private StateTerminating()
{
}
State process(CallContext context, Message message)
{
switch (message.getType())
{
case Message.SUCCESS:
case Message.FAILURE:
Iterator<AudioData> it;
it = context.audioFrom.iterator();
while (it.hasNext()) {
AudioData data = it.next();
data.close(); | LocalMetrics metrics = new LocalMetrics(context, data); |
TerryHowe/SIP-Voice-Quality-Report-Reaper | src/com/tt/reaper/call/StateTerminating.java | // Path: src/com/tt/reaper/sip/CollectorStack.java
// public class CollectorStack {
// private static final String STACK_NAME = "CollectorStack";
// private static Logger logger = Logger.getLogger(CollectorStack.class);
// public static CollectorStack instance = new CollectorStack();
// private SipProvider collectorProvider;
// private static boolean initialized = false;
// public String lastSendData;
//
// private CollectorStack()
// {
// }
//
// public synchronized boolean init()
// {
// if (initialized == true)
// return true;
// initialized = true;
// logger.info("Starting the collector stack...");
// try {
// SipStack sipStack;
// Configuration configuration;
// configuration = new Configuration();
// configuration.setStackName(STACK_NAME);
// SipFactory.getInstance().setPathName("gov.nist");
// sipStack = SipFactory.getInstance().createSipStack(configuration);
// RequestMessage.initFactory(SipFactory.getInstance(), configuration);
// ListeningPoint reaperUdp = sipStack.createListeningPoint(configuration.getWriteInterface(), configuration.getWritePort(), "udp");
// collectorProvider = sipStack.createSipProvider(reaperUdp);
// collectorProvider.addSipListener(new CollectorListener());
// collectorProvider.setAutomaticDialogSupportEnabled(false);
// logger.info("Collector SIP stack initialized successfully");
// }
// catch (Exception e)
// {
// logger.error("Error initializing stack: ", e);
// return false;
// }
// return true;
// }
//
// public boolean sendResponse(ResponseMessage response) {
// try {
// ServerTransaction st = collectorProvider.getNewServerTransaction(response.getRequest());
// st.sendResponse(response.getResponse());
// }
// catch (Exception e) {
// logger.error("Error sending response: ", e);
// }
// return true;
// }
//
// public boolean sendMessage(String data) {
// lastSendData = data;
// try {
// PublishMessage publish = new PublishMessage(data);
// collectorProvider.sendRequest(publish.getRequest());
// }
// catch (Exception e)
// {
// logger.error("Error sending message: ", e);
// return false;
// }
// return true;
// }
//
// public CallIdHeader getNewCallId() {
// logger.info("Get new call id: " + collectorProvider);
// return collectorProvider.getNewCallId();
// }
// }
//
// Path: src/com/tt/reaper/vq/LocalMetrics.java
// public class LocalMetrics extends Metrics {
// private static final String NAME = "LocalMetrics";
//
// LocalMetrics()
// {
// super(NAME);
// }
//
// public LocalMetrics(CallContext context, AudioData data) {
// super(NAME, context, data);
// }
// }
//
// Path: src/com/tt/reaper/vq/VQSessionReport.java
// public class VQSessionReport extends VQReportEvent {
// private static final String HEADER = "VQSessionReport : CallTerm\r\n";
//
// public VQSessionReport(LocalMetrics localMetrics) {
// super(HEADER, localMetrics);
// }
// }
| import java.util.Iterator;
import com.tt.reaper.message.Message;
import com.tt.reaper.message.RtpPacket;
import com.tt.reaper.sip.CollectorStack;
import com.tt.reaper.vq.LocalMetrics;
import com.tt.reaper.vq.VQSessionReport; | package com.tt.reaper.call;
public class StateTerminating extends State {
public static final StateTerminating instance = new StateTerminating();
private StateTerminating()
{
}
State process(CallContext context, Message message)
{
switch (message.getType())
{
case Message.SUCCESS:
case Message.FAILURE:
Iterator<AudioData> it;
it = context.audioFrom.iterator();
while (it.hasNext()) {
AudioData data = it.next();
data.close();
LocalMetrics metrics = new LocalMetrics(context, data);
metrics.setPacketLoss(data.getLossRate());
metrics.setDelay(data.getJitter()); | // Path: src/com/tt/reaper/sip/CollectorStack.java
// public class CollectorStack {
// private static final String STACK_NAME = "CollectorStack";
// private static Logger logger = Logger.getLogger(CollectorStack.class);
// public static CollectorStack instance = new CollectorStack();
// private SipProvider collectorProvider;
// private static boolean initialized = false;
// public String lastSendData;
//
// private CollectorStack()
// {
// }
//
// public synchronized boolean init()
// {
// if (initialized == true)
// return true;
// initialized = true;
// logger.info("Starting the collector stack...");
// try {
// SipStack sipStack;
// Configuration configuration;
// configuration = new Configuration();
// configuration.setStackName(STACK_NAME);
// SipFactory.getInstance().setPathName("gov.nist");
// sipStack = SipFactory.getInstance().createSipStack(configuration);
// RequestMessage.initFactory(SipFactory.getInstance(), configuration);
// ListeningPoint reaperUdp = sipStack.createListeningPoint(configuration.getWriteInterface(), configuration.getWritePort(), "udp");
// collectorProvider = sipStack.createSipProvider(reaperUdp);
// collectorProvider.addSipListener(new CollectorListener());
// collectorProvider.setAutomaticDialogSupportEnabled(false);
// logger.info("Collector SIP stack initialized successfully");
// }
// catch (Exception e)
// {
// logger.error("Error initializing stack: ", e);
// return false;
// }
// return true;
// }
//
// public boolean sendResponse(ResponseMessage response) {
// try {
// ServerTransaction st = collectorProvider.getNewServerTransaction(response.getRequest());
// st.sendResponse(response.getResponse());
// }
// catch (Exception e) {
// logger.error("Error sending response: ", e);
// }
// return true;
// }
//
// public boolean sendMessage(String data) {
// lastSendData = data;
// try {
// PublishMessage publish = new PublishMessage(data);
// collectorProvider.sendRequest(publish.getRequest());
// }
// catch (Exception e)
// {
// logger.error("Error sending message: ", e);
// return false;
// }
// return true;
// }
//
// public CallIdHeader getNewCallId() {
// logger.info("Get new call id: " + collectorProvider);
// return collectorProvider.getNewCallId();
// }
// }
//
// Path: src/com/tt/reaper/vq/LocalMetrics.java
// public class LocalMetrics extends Metrics {
// private static final String NAME = "LocalMetrics";
//
// LocalMetrics()
// {
// super(NAME);
// }
//
// public LocalMetrics(CallContext context, AudioData data) {
// super(NAME, context, data);
// }
// }
//
// Path: src/com/tt/reaper/vq/VQSessionReport.java
// public class VQSessionReport extends VQReportEvent {
// private static final String HEADER = "VQSessionReport : CallTerm\r\n";
//
// public VQSessionReport(LocalMetrics localMetrics) {
// super(HEADER, localMetrics);
// }
// }
// Path: src/com/tt/reaper/call/StateTerminating.java
import java.util.Iterator;
import com.tt.reaper.message.Message;
import com.tt.reaper.message.RtpPacket;
import com.tt.reaper.sip.CollectorStack;
import com.tt.reaper.vq.LocalMetrics;
import com.tt.reaper.vq.VQSessionReport;
package com.tt.reaper.call;
public class StateTerminating extends State {
public static final StateTerminating instance = new StateTerminating();
private StateTerminating()
{
}
State process(CallContext context, Message message)
{
switch (message.getType())
{
case Message.SUCCESS:
case Message.FAILURE:
Iterator<AudioData> it;
it = context.audioFrom.iterator();
while (it.hasNext()) {
AudioData data = it.next();
data.close();
LocalMetrics metrics = new LocalMetrics(context, data);
metrics.setPacketLoss(data.getLossRate());
metrics.setDelay(data.getJitter()); | VQSessionReport report = new VQSessionReport(metrics); |
TerryHowe/SIP-Voice-Quality-Report-Reaper | src/com/tt/reaper/call/StateTerminating.java | // Path: src/com/tt/reaper/sip/CollectorStack.java
// public class CollectorStack {
// private static final String STACK_NAME = "CollectorStack";
// private static Logger logger = Logger.getLogger(CollectorStack.class);
// public static CollectorStack instance = new CollectorStack();
// private SipProvider collectorProvider;
// private static boolean initialized = false;
// public String lastSendData;
//
// private CollectorStack()
// {
// }
//
// public synchronized boolean init()
// {
// if (initialized == true)
// return true;
// initialized = true;
// logger.info("Starting the collector stack...");
// try {
// SipStack sipStack;
// Configuration configuration;
// configuration = new Configuration();
// configuration.setStackName(STACK_NAME);
// SipFactory.getInstance().setPathName("gov.nist");
// sipStack = SipFactory.getInstance().createSipStack(configuration);
// RequestMessage.initFactory(SipFactory.getInstance(), configuration);
// ListeningPoint reaperUdp = sipStack.createListeningPoint(configuration.getWriteInterface(), configuration.getWritePort(), "udp");
// collectorProvider = sipStack.createSipProvider(reaperUdp);
// collectorProvider.addSipListener(new CollectorListener());
// collectorProvider.setAutomaticDialogSupportEnabled(false);
// logger.info("Collector SIP stack initialized successfully");
// }
// catch (Exception e)
// {
// logger.error("Error initializing stack: ", e);
// return false;
// }
// return true;
// }
//
// public boolean sendResponse(ResponseMessage response) {
// try {
// ServerTransaction st = collectorProvider.getNewServerTransaction(response.getRequest());
// st.sendResponse(response.getResponse());
// }
// catch (Exception e) {
// logger.error("Error sending response: ", e);
// }
// return true;
// }
//
// public boolean sendMessage(String data) {
// lastSendData = data;
// try {
// PublishMessage publish = new PublishMessage(data);
// collectorProvider.sendRequest(publish.getRequest());
// }
// catch (Exception e)
// {
// logger.error("Error sending message: ", e);
// return false;
// }
// return true;
// }
//
// public CallIdHeader getNewCallId() {
// logger.info("Get new call id: " + collectorProvider);
// return collectorProvider.getNewCallId();
// }
// }
//
// Path: src/com/tt/reaper/vq/LocalMetrics.java
// public class LocalMetrics extends Metrics {
// private static final String NAME = "LocalMetrics";
//
// LocalMetrics()
// {
// super(NAME);
// }
//
// public LocalMetrics(CallContext context, AudioData data) {
// super(NAME, context, data);
// }
// }
//
// Path: src/com/tt/reaper/vq/VQSessionReport.java
// public class VQSessionReport extends VQReportEvent {
// private static final String HEADER = "VQSessionReport : CallTerm\r\n";
//
// public VQSessionReport(LocalMetrics localMetrics) {
// super(HEADER, localMetrics);
// }
// }
| import java.util.Iterator;
import com.tt.reaper.message.Message;
import com.tt.reaper.message.RtpPacket;
import com.tt.reaper.sip.CollectorStack;
import com.tt.reaper.vq.LocalMetrics;
import com.tt.reaper.vq.VQSessionReport; | package com.tt.reaper.call;
public class StateTerminating extends State {
public static final StateTerminating instance = new StateTerminating();
private StateTerminating()
{
}
State process(CallContext context, Message message)
{
switch (message.getType())
{
case Message.SUCCESS:
case Message.FAILURE:
Iterator<AudioData> it;
it = context.audioFrom.iterator();
while (it.hasNext()) {
AudioData data = it.next();
data.close();
LocalMetrics metrics = new LocalMetrics(context, data);
metrics.setPacketLoss(data.getLossRate());
metrics.setDelay(data.getJitter());
VQSessionReport report = new VQSessionReport(metrics); | // Path: src/com/tt/reaper/sip/CollectorStack.java
// public class CollectorStack {
// private static final String STACK_NAME = "CollectorStack";
// private static Logger logger = Logger.getLogger(CollectorStack.class);
// public static CollectorStack instance = new CollectorStack();
// private SipProvider collectorProvider;
// private static boolean initialized = false;
// public String lastSendData;
//
// private CollectorStack()
// {
// }
//
// public synchronized boolean init()
// {
// if (initialized == true)
// return true;
// initialized = true;
// logger.info("Starting the collector stack...");
// try {
// SipStack sipStack;
// Configuration configuration;
// configuration = new Configuration();
// configuration.setStackName(STACK_NAME);
// SipFactory.getInstance().setPathName("gov.nist");
// sipStack = SipFactory.getInstance().createSipStack(configuration);
// RequestMessage.initFactory(SipFactory.getInstance(), configuration);
// ListeningPoint reaperUdp = sipStack.createListeningPoint(configuration.getWriteInterface(), configuration.getWritePort(), "udp");
// collectorProvider = sipStack.createSipProvider(reaperUdp);
// collectorProvider.addSipListener(new CollectorListener());
// collectorProvider.setAutomaticDialogSupportEnabled(false);
// logger.info("Collector SIP stack initialized successfully");
// }
// catch (Exception e)
// {
// logger.error("Error initializing stack: ", e);
// return false;
// }
// return true;
// }
//
// public boolean sendResponse(ResponseMessage response) {
// try {
// ServerTransaction st = collectorProvider.getNewServerTransaction(response.getRequest());
// st.sendResponse(response.getResponse());
// }
// catch (Exception e) {
// logger.error("Error sending response: ", e);
// }
// return true;
// }
//
// public boolean sendMessage(String data) {
// lastSendData = data;
// try {
// PublishMessage publish = new PublishMessage(data);
// collectorProvider.sendRequest(publish.getRequest());
// }
// catch (Exception e)
// {
// logger.error("Error sending message: ", e);
// return false;
// }
// return true;
// }
//
// public CallIdHeader getNewCallId() {
// logger.info("Get new call id: " + collectorProvider);
// return collectorProvider.getNewCallId();
// }
// }
//
// Path: src/com/tt/reaper/vq/LocalMetrics.java
// public class LocalMetrics extends Metrics {
// private static final String NAME = "LocalMetrics";
//
// LocalMetrics()
// {
// super(NAME);
// }
//
// public LocalMetrics(CallContext context, AudioData data) {
// super(NAME, context, data);
// }
// }
//
// Path: src/com/tt/reaper/vq/VQSessionReport.java
// public class VQSessionReport extends VQReportEvent {
// private static final String HEADER = "VQSessionReport : CallTerm\r\n";
//
// public VQSessionReport(LocalMetrics localMetrics) {
// super(HEADER, localMetrics);
// }
// }
// Path: src/com/tt/reaper/call/StateTerminating.java
import java.util.Iterator;
import com.tt.reaper.message.Message;
import com.tt.reaper.message.RtpPacket;
import com.tt.reaper.sip.CollectorStack;
import com.tt.reaper.vq.LocalMetrics;
import com.tt.reaper.vq.VQSessionReport;
package com.tt.reaper.call;
public class StateTerminating extends State {
public static final StateTerminating instance = new StateTerminating();
private StateTerminating()
{
}
State process(CallContext context, Message message)
{
switch (message.getType())
{
case Message.SUCCESS:
case Message.FAILURE:
Iterator<AudioData> it;
it = context.audioFrom.iterator();
while (it.hasNext()) {
AudioData data = it.next();
data.close();
LocalMetrics metrics = new LocalMetrics(context, data);
metrics.setPacketLoss(data.getLossRate());
metrics.setDelay(data.getJitter());
VQSessionReport report = new VQSessionReport(metrics); | CollectorStack.instance.sendMessage(report.toString()); |
TerryHowe/SIP-Voice-Quality-Report-Reaper | src/com/tt/reaper/filter/FilterExecute.java | // Path: src/com/tt/reaper/Configuration.java
// public class Configuration extends Properties {
// private static final long serialVersionUID = 1L;
// private static Logger logger = Logger.getLogger(Configuration.class);
// private static final String FILE_NAME = "config/reaper.properties";
// public static final String STACK_NAME = "javax.sip.STACK_NAME";
// public static final String STACK_TRACE_LEVEL = "gov.nist.javax.sip.TRACE_LEVEL";
// public static final String STACK_SERVER_LOG = "gov.nist.javax.sip.SERVER_LOG";
// public static final String STACK_DEBUG_LOG = "gov.nist.javax.sip.DEBUG_LOG";
// private static final String READ_INTERFACE = "readInterface";
// private static final String READ_PORT = "readPort";
// private static final String WRITE_INTERFACE = "writeInterface";
// private static final String FROM_PORT = "fromPort";
// private static final String FROM_USERNAME = "fromUsername";
// private static final String COLLECTOR_HOST = "collectorHost";
// private static final String COLLECTOR_PORT = "collectorPort";
// private static final String COLLECTOR_USERNAME = "collectorUsername";
// private static final String COMMAND_ARGUMENTS = "commandArguments";
// private static final String SOFTWARE_VERSION = "softwareVersion";
//
// public Configuration()
// {
// try {
// FileInputStream in = new FileInputStream(FILE_NAME);
// load(in);
// in.close();
// }
// catch (Exception e)
// {
// logger.error("Error reading properties file");
// }
// }
//
// public void setStackName(String value) {
// setProperty(STACK_NAME, value);
// }
//
// public String getStackTraceLevel() {
// return getProperty(Configuration.STACK_TRACE_LEVEL, "0");
// }
//
// public String getStackServerLog() {
// return getProperty(Configuration.STACK_SERVER_LOG, "/dev/null");
// }
//
// public String getStackDebugLog() {
// return getProperty(Configuration.STACK_DEBUG_LOG, "/dev/null");
// }
//
// public String getReadInterface() {
// return getProperty(Configuration.READ_INTERFACE, "eth0");
// }
//
//
// public int getReadPort() {
// try {
// return Integer.parseInt(getProperty(Configuration.READ_PORT, "5050"));
// }
// catch (Exception e)
// {
// logger.error("Error reading port configuration: ", e);
// }
// return 5050;
// }
//
// public String getWriteInterface() {
// return Nics.getIp(getProperty(Configuration.WRITE_INTERFACE, "lo"));
// }
//
// public int getWritePort() {
// try {
// return Integer.parseInt(getProperty(Configuration.FROM_PORT, "5060"));
// }
// catch (Exception e)
// {
// logger.error("Error reading port configuration: ", e);
// }
// return 5060;
// }
//
// public String getWriteUsername() {
// return getProperty(Configuration.FROM_USERNAME, "reaper");
// }
//
// public String getCollectorHost() {
// return getProperty(Configuration.COLLECTOR_HOST, "127.0.0.3");
// }
//
// public int getCollectorPort() {
// try {
// return Integer.parseInt(getProperty(Configuration.COLLECTOR_PORT, "5060"));
// }
// catch (Exception e)
// {
// logger.error("Error reading port configuration: ", e);
// }
// return 5060;
// }
//
// public String getCollectorUsername() {
// return getProperty(Configuration.COLLECTOR_USERNAME, "collector");
// }
//
// public String getCommand() {
// return "/opt/reaper/bin/filter.sh " + getProperty(Configuration.COMMAND_ARGUMENTS, " -n -e ") + " -i " + getReadInterface();
// }
//
// public String getSoftwareVersion() {
// return getProperty(Configuration.SOFTWARE_VERSION, "reaperv1.0");
// }
// }
| import org.apache.log4j.Logger;
import com.tt.reaper.Configuration; | package com.tt.reaper.filter;
public class FilterExecute extends Thread {
private static Logger logger = Logger.getLogger(FilterExecute.class);
public static final FilterExecute instance = new FilterExecute();
private String command;
private boolean running = false;
private FilterExecute() {
}
public synchronized void init() { | // Path: src/com/tt/reaper/Configuration.java
// public class Configuration extends Properties {
// private static final long serialVersionUID = 1L;
// private static Logger logger = Logger.getLogger(Configuration.class);
// private static final String FILE_NAME = "config/reaper.properties";
// public static final String STACK_NAME = "javax.sip.STACK_NAME";
// public static final String STACK_TRACE_LEVEL = "gov.nist.javax.sip.TRACE_LEVEL";
// public static final String STACK_SERVER_LOG = "gov.nist.javax.sip.SERVER_LOG";
// public static final String STACK_DEBUG_LOG = "gov.nist.javax.sip.DEBUG_LOG";
// private static final String READ_INTERFACE = "readInterface";
// private static final String READ_PORT = "readPort";
// private static final String WRITE_INTERFACE = "writeInterface";
// private static final String FROM_PORT = "fromPort";
// private static final String FROM_USERNAME = "fromUsername";
// private static final String COLLECTOR_HOST = "collectorHost";
// private static final String COLLECTOR_PORT = "collectorPort";
// private static final String COLLECTOR_USERNAME = "collectorUsername";
// private static final String COMMAND_ARGUMENTS = "commandArguments";
// private static final String SOFTWARE_VERSION = "softwareVersion";
//
// public Configuration()
// {
// try {
// FileInputStream in = new FileInputStream(FILE_NAME);
// load(in);
// in.close();
// }
// catch (Exception e)
// {
// logger.error("Error reading properties file");
// }
// }
//
// public void setStackName(String value) {
// setProperty(STACK_NAME, value);
// }
//
// public String getStackTraceLevel() {
// return getProperty(Configuration.STACK_TRACE_LEVEL, "0");
// }
//
// public String getStackServerLog() {
// return getProperty(Configuration.STACK_SERVER_LOG, "/dev/null");
// }
//
// public String getStackDebugLog() {
// return getProperty(Configuration.STACK_DEBUG_LOG, "/dev/null");
// }
//
// public String getReadInterface() {
// return getProperty(Configuration.READ_INTERFACE, "eth0");
// }
//
//
// public int getReadPort() {
// try {
// return Integer.parseInt(getProperty(Configuration.READ_PORT, "5050"));
// }
// catch (Exception e)
// {
// logger.error("Error reading port configuration: ", e);
// }
// return 5050;
// }
//
// public String getWriteInterface() {
// return Nics.getIp(getProperty(Configuration.WRITE_INTERFACE, "lo"));
// }
//
// public int getWritePort() {
// try {
// return Integer.parseInt(getProperty(Configuration.FROM_PORT, "5060"));
// }
// catch (Exception e)
// {
// logger.error("Error reading port configuration: ", e);
// }
// return 5060;
// }
//
// public String getWriteUsername() {
// return getProperty(Configuration.FROM_USERNAME, "reaper");
// }
//
// public String getCollectorHost() {
// return getProperty(Configuration.COLLECTOR_HOST, "127.0.0.3");
// }
//
// public int getCollectorPort() {
// try {
// return Integer.parseInt(getProperty(Configuration.COLLECTOR_PORT, "5060"));
// }
// catch (Exception e)
// {
// logger.error("Error reading port configuration: ", e);
// }
// return 5060;
// }
//
// public String getCollectorUsername() {
// return getProperty(Configuration.COLLECTOR_USERNAME, "collector");
// }
//
// public String getCommand() {
// return "/opt/reaper/bin/filter.sh " + getProperty(Configuration.COMMAND_ARGUMENTS, " -n -e ") + " -i " + getReadInterface();
// }
//
// public String getSoftwareVersion() {
// return getProperty(Configuration.SOFTWARE_VERSION, "reaperv1.0");
// }
// }
// Path: src/com/tt/reaper/filter/FilterExecute.java
import org.apache.log4j.Logger;
import com.tt.reaper.Configuration;
package com.tt.reaper.filter;
public class FilterExecute extends Thread {
private static Logger logger = Logger.getLogger(FilterExecute.class);
public static final FilterExecute instance = new FilterExecute();
private String command;
private boolean running = false;
private FilterExecute() {
}
public synchronized void init() { | command = new Configuration().getCommand(); |
TerryHowe/SIP-Voice-Quality-Report-Reaper | src/com/tt/reaper/http/WebHandler.java | // Path: src/com/tt/reaper/message/DataRequest.java
// public class DataRequest extends Message {
// public MessageQueue queue;
//
// public DataRequest(MessageQueue queue) {
// super(Message.DATA_REQUEST);
// this.queue = queue;
// }
// }
//
// Path: src/com/tt/reaper/message/DataResponse.java
// public class DataResponse extends Message {
// public String data;
//
// public DataResponse(String data) {
// super(Message.DATA_REQUEST);
// this.data = data;
// }
// }
//
// Path: src/com/tt/reaper/message/MessageQueue.java
// public class MessageQueue
// {
// private static Logger logger = Logger.getLogger(MessageQueue.class);
// protected List<Message> queue;
//
// public MessageQueue()
// {
// queue = Collections.synchronizedList(new LinkedList<Message>());
// }
//
// public Message getBlocking()
// {
// try
// {
// synchronized (queue)
// {
// while (queue.isEmpty())
// queue.wait();
// return (Message) queue.remove(0);
// }
// }
// catch (Exception e) {
// logger.error("Error with queue: ", e);
// }
// return null;
// }
//
// public Message get()
// {
// try
// {
// return (Message) queue.remove(0);
// }
// catch (Exception e) {}
// return null;
// }
//
// public void add(Message e)
// {
// synchronized (queue)
// {
// queue.add(e);
// queue.notify();
// }
// }
// }
| import java.io.IOException;
import java.io.OutputStream;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.tt.reaper.call.CallManager;
import com.tt.reaper.message.DataRequest;
import com.tt.reaper.message.DataResponse;
import com.tt.reaper.message.Message;
import com.tt.reaper.message.MessageQueue; | package com.tt.reaper.http;
public class WebHandler implements HttpHandler {
@Override
public void handle(HttpExchange xchange) throws IOException {
String body = "<title>Active Calls</title><h1>Active Calls</h1>";
body += "<pre>"; | // Path: src/com/tt/reaper/message/DataRequest.java
// public class DataRequest extends Message {
// public MessageQueue queue;
//
// public DataRequest(MessageQueue queue) {
// super(Message.DATA_REQUEST);
// this.queue = queue;
// }
// }
//
// Path: src/com/tt/reaper/message/DataResponse.java
// public class DataResponse extends Message {
// public String data;
//
// public DataResponse(String data) {
// super(Message.DATA_REQUEST);
// this.data = data;
// }
// }
//
// Path: src/com/tt/reaper/message/MessageQueue.java
// public class MessageQueue
// {
// private static Logger logger = Logger.getLogger(MessageQueue.class);
// protected List<Message> queue;
//
// public MessageQueue()
// {
// queue = Collections.synchronizedList(new LinkedList<Message>());
// }
//
// public Message getBlocking()
// {
// try
// {
// synchronized (queue)
// {
// while (queue.isEmpty())
// queue.wait();
// return (Message) queue.remove(0);
// }
// }
// catch (Exception e) {
// logger.error("Error with queue: ", e);
// }
// return null;
// }
//
// public Message get()
// {
// try
// {
// return (Message) queue.remove(0);
// }
// catch (Exception e) {}
// return null;
// }
//
// public void add(Message e)
// {
// synchronized (queue)
// {
// queue.add(e);
// queue.notify();
// }
// }
// }
// Path: src/com/tt/reaper/http/WebHandler.java
import java.io.IOException;
import java.io.OutputStream;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.tt.reaper.call.CallManager;
import com.tt.reaper.message.DataRequest;
import com.tt.reaper.message.DataResponse;
import com.tt.reaper.message.Message;
import com.tt.reaper.message.MessageQueue;
package com.tt.reaper.http;
public class WebHandler implements HttpHandler {
@Override
public void handle(HttpExchange xchange) throws IOException {
String body = "<title>Active Calls</title><h1>Active Calls</h1>";
body += "<pre>"; | MessageQueue queue = new MessageQueue(); |
TerryHowe/SIP-Voice-Quality-Report-Reaper | src/com/tt/reaper/http/WebHandler.java | // Path: src/com/tt/reaper/message/DataRequest.java
// public class DataRequest extends Message {
// public MessageQueue queue;
//
// public DataRequest(MessageQueue queue) {
// super(Message.DATA_REQUEST);
// this.queue = queue;
// }
// }
//
// Path: src/com/tt/reaper/message/DataResponse.java
// public class DataResponse extends Message {
// public String data;
//
// public DataResponse(String data) {
// super(Message.DATA_REQUEST);
// this.data = data;
// }
// }
//
// Path: src/com/tt/reaper/message/MessageQueue.java
// public class MessageQueue
// {
// private static Logger logger = Logger.getLogger(MessageQueue.class);
// protected List<Message> queue;
//
// public MessageQueue()
// {
// queue = Collections.synchronizedList(new LinkedList<Message>());
// }
//
// public Message getBlocking()
// {
// try
// {
// synchronized (queue)
// {
// while (queue.isEmpty())
// queue.wait();
// return (Message) queue.remove(0);
// }
// }
// catch (Exception e) {
// logger.error("Error with queue: ", e);
// }
// return null;
// }
//
// public Message get()
// {
// try
// {
// return (Message) queue.remove(0);
// }
// catch (Exception e) {}
// return null;
// }
//
// public void add(Message e)
// {
// synchronized (queue)
// {
// queue.add(e);
// queue.notify();
// }
// }
// }
| import java.io.IOException;
import java.io.OutputStream;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.tt.reaper.call.CallManager;
import com.tt.reaper.message.DataRequest;
import com.tt.reaper.message.DataResponse;
import com.tt.reaper.message.Message;
import com.tt.reaper.message.MessageQueue; | package com.tt.reaper.http;
public class WebHandler implements HttpHandler {
@Override
public void handle(HttpExchange xchange) throws IOException {
String body = "<title>Active Calls</title><h1>Active Calls</h1>";
body += "<pre>";
MessageQueue queue = new MessageQueue(); | // Path: src/com/tt/reaper/message/DataRequest.java
// public class DataRequest extends Message {
// public MessageQueue queue;
//
// public DataRequest(MessageQueue queue) {
// super(Message.DATA_REQUEST);
// this.queue = queue;
// }
// }
//
// Path: src/com/tt/reaper/message/DataResponse.java
// public class DataResponse extends Message {
// public String data;
//
// public DataResponse(String data) {
// super(Message.DATA_REQUEST);
// this.data = data;
// }
// }
//
// Path: src/com/tt/reaper/message/MessageQueue.java
// public class MessageQueue
// {
// private static Logger logger = Logger.getLogger(MessageQueue.class);
// protected List<Message> queue;
//
// public MessageQueue()
// {
// queue = Collections.synchronizedList(new LinkedList<Message>());
// }
//
// public Message getBlocking()
// {
// try
// {
// synchronized (queue)
// {
// while (queue.isEmpty())
// queue.wait();
// return (Message) queue.remove(0);
// }
// }
// catch (Exception e) {
// logger.error("Error with queue: ", e);
// }
// return null;
// }
//
// public Message get()
// {
// try
// {
// return (Message) queue.remove(0);
// }
// catch (Exception e) {}
// return null;
// }
//
// public void add(Message e)
// {
// synchronized (queue)
// {
// queue.add(e);
// queue.notify();
// }
// }
// }
// Path: src/com/tt/reaper/http/WebHandler.java
import java.io.IOException;
import java.io.OutputStream;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.tt.reaper.call.CallManager;
import com.tt.reaper.message.DataRequest;
import com.tt.reaper.message.DataResponse;
import com.tt.reaper.message.Message;
import com.tt.reaper.message.MessageQueue;
package com.tt.reaper.http;
public class WebHandler implements HttpHandler {
@Override
public void handle(HttpExchange xchange) throws IOException {
String body = "<title>Active Calls</title><h1>Active Calls</h1>";
body += "<pre>";
MessageQueue queue = new MessageQueue(); | CallManager.instance.send(new DataRequest(queue)); |
TerryHowe/SIP-Voice-Quality-Report-Reaper | src/com/tt/reaper/http/WebHandler.java | // Path: src/com/tt/reaper/message/DataRequest.java
// public class DataRequest extends Message {
// public MessageQueue queue;
//
// public DataRequest(MessageQueue queue) {
// super(Message.DATA_REQUEST);
// this.queue = queue;
// }
// }
//
// Path: src/com/tt/reaper/message/DataResponse.java
// public class DataResponse extends Message {
// public String data;
//
// public DataResponse(String data) {
// super(Message.DATA_REQUEST);
// this.data = data;
// }
// }
//
// Path: src/com/tt/reaper/message/MessageQueue.java
// public class MessageQueue
// {
// private static Logger logger = Logger.getLogger(MessageQueue.class);
// protected List<Message> queue;
//
// public MessageQueue()
// {
// queue = Collections.synchronizedList(new LinkedList<Message>());
// }
//
// public Message getBlocking()
// {
// try
// {
// synchronized (queue)
// {
// while (queue.isEmpty())
// queue.wait();
// return (Message) queue.remove(0);
// }
// }
// catch (Exception e) {
// logger.error("Error with queue: ", e);
// }
// return null;
// }
//
// public Message get()
// {
// try
// {
// return (Message) queue.remove(0);
// }
// catch (Exception e) {}
// return null;
// }
//
// public void add(Message e)
// {
// synchronized (queue)
// {
// queue.add(e);
// queue.notify();
// }
// }
// }
| import java.io.IOException;
import java.io.OutputStream;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.tt.reaper.call.CallManager;
import com.tt.reaper.message.DataRequest;
import com.tt.reaper.message.DataResponse;
import com.tt.reaper.message.Message;
import com.tt.reaper.message.MessageQueue; | package com.tt.reaper.http;
public class WebHandler implements HttpHandler {
@Override
public void handle(HttpExchange xchange) throws IOException {
String body = "<title>Active Calls</title><h1>Active Calls</h1>";
body += "<pre>";
MessageQueue queue = new MessageQueue();
CallManager.instance.send(new DataRequest(queue));
Message response = queue.getBlocking(); | // Path: src/com/tt/reaper/message/DataRequest.java
// public class DataRequest extends Message {
// public MessageQueue queue;
//
// public DataRequest(MessageQueue queue) {
// super(Message.DATA_REQUEST);
// this.queue = queue;
// }
// }
//
// Path: src/com/tt/reaper/message/DataResponse.java
// public class DataResponse extends Message {
// public String data;
//
// public DataResponse(String data) {
// super(Message.DATA_REQUEST);
// this.data = data;
// }
// }
//
// Path: src/com/tt/reaper/message/MessageQueue.java
// public class MessageQueue
// {
// private static Logger logger = Logger.getLogger(MessageQueue.class);
// protected List<Message> queue;
//
// public MessageQueue()
// {
// queue = Collections.synchronizedList(new LinkedList<Message>());
// }
//
// public Message getBlocking()
// {
// try
// {
// synchronized (queue)
// {
// while (queue.isEmpty())
// queue.wait();
// return (Message) queue.remove(0);
// }
// }
// catch (Exception e) {
// logger.error("Error with queue: ", e);
// }
// return null;
// }
//
// public Message get()
// {
// try
// {
// return (Message) queue.remove(0);
// }
// catch (Exception e) {}
// return null;
// }
//
// public void add(Message e)
// {
// synchronized (queue)
// {
// queue.add(e);
// queue.notify();
// }
// }
// }
// Path: src/com/tt/reaper/http/WebHandler.java
import java.io.IOException;
import java.io.OutputStream;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.tt.reaper.call.CallManager;
import com.tt.reaper.message.DataRequest;
import com.tt.reaper.message.DataResponse;
import com.tt.reaper.message.Message;
import com.tt.reaper.message.MessageQueue;
package com.tt.reaper.http;
public class WebHandler implements HttpHandler {
@Override
public void handle(HttpExchange xchange) throws IOException {
String body = "<title>Active Calls</title><h1>Active Calls</h1>";
body += "<pre>";
MessageQueue queue = new MessageQueue();
CallManager.instance.send(new DataRequest(queue));
Message response = queue.getBlocking(); | if (response instanceof DataResponse) |
TerryHowe/SIP-Voice-Quality-Report-Reaper | test/com/tt/reaper/call/TestRtpPacketFactory.java | // Path: test/com/tt/reaper/message/TestRtpPacket.java
// public class TestRtpPacket {
// public static final String SOURCE_MAC = "1:1:1:1:1:1";
// public static final String SOURCE_IP = "10.0.0.1";
// public static final String SOURCE_PORT = "9090";
// public static final String DESTINATION_MAC = "2:2:2:2:2:2";
// public static final String DESTINATION_IP = "10.0.0.2";
// public static final String DESTINATION_PORT = "8080";
//
// public static RtpPacket create(int sequenceNumber)
// {
// return new RtpPacket(create(sequenceNumber, 3));
// }
//
// public static String create(int sequenceNumber, int timeStamp) {
// return SOURCE_MAC + ";" + SOURCE_IP + ";" + SOURCE_PORT + ";" +
// DESTINATION_MAC + ";" + DESTINATION_IP + ";" + DESTINATION_PORT + ";" +
// sequenceNumber + ";" + timeStamp + ";" + (timeStamp + 1) + ";\n";
// }
//
// @Before
// public void setUp()
// {
// ReaperLogger.init();
// }
//
// @Test
// public void testPacket()
// {
// RtpPacket packet = new RtpPacket(create(1, 2));
// assertEquals(SOURCE_MAC, packet.getSourceMac());
// assertEquals(SOURCE_IP + ":" + SOURCE_PORT, packet.getSource());
// assertEquals(DESTINATION_MAC, packet.getDestinationMac());
// assertEquals(DESTINATION_IP + ":" + DESTINATION_PORT, packet.getDestination());
// assertEquals(1, packet.getSequenceNumber());
// assertEquals(2, packet.getTimeStamp());
// assertEquals(3, packet.getArrival());
// }
// }
| import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.tt.reaper.message.RtpPacket;
import com.tt.reaper.message.TestRtpPacket; | package com.tt.reaper.call;
public class TestRtpPacketFactory {
@Test
public void testFactory() {
RtpPacketFactory factory = new RtpPacketFactory();
factory.init(null);
assertEquals(null, factory.getNext());
}
@Test
public void testFactoryOne()
{
RtpPacketFactory factory = new RtpPacketFactory(); | // Path: test/com/tt/reaper/message/TestRtpPacket.java
// public class TestRtpPacket {
// public static final String SOURCE_MAC = "1:1:1:1:1:1";
// public static final String SOURCE_IP = "10.0.0.1";
// public static final String SOURCE_PORT = "9090";
// public static final String DESTINATION_MAC = "2:2:2:2:2:2";
// public static final String DESTINATION_IP = "10.0.0.2";
// public static final String DESTINATION_PORT = "8080";
//
// public static RtpPacket create(int sequenceNumber)
// {
// return new RtpPacket(create(sequenceNumber, 3));
// }
//
// public static String create(int sequenceNumber, int timeStamp) {
// return SOURCE_MAC + ";" + SOURCE_IP + ";" + SOURCE_PORT + ";" +
// DESTINATION_MAC + ";" + DESTINATION_IP + ";" + DESTINATION_PORT + ";" +
// sequenceNumber + ";" + timeStamp + ";" + (timeStamp + 1) + ";\n";
// }
//
// @Before
// public void setUp()
// {
// ReaperLogger.init();
// }
//
// @Test
// public void testPacket()
// {
// RtpPacket packet = new RtpPacket(create(1, 2));
// assertEquals(SOURCE_MAC, packet.getSourceMac());
// assertEquals(SOURCE_IP + ":" + SOURCE_PORT, packet.getSource());
// assertEquals(DESTINATION_MAC, packet.getDestinationMac());
// assertEquals(DESTINATION_IP + ":" + DESTINATION_PORT, packet.getDestination());
// assertEquals(1, packet.getSequenceNumber());
// assertEquals(2, packet.getTimeStamp());
// assertEquals(3, packet.getArrival());
// }
// }
// Path: test/com/tt/reaper/call/TestRtpPacketFactory.java
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.tt.reaper.message.RtpPacket;
import com.tt.reaper.message.TestRtpPacket;
package com.tt.reaper.call;
public class TestRtpPacketFactory {
@Test
public void testFactory() {
RtpPacketFactory factory = new RtpPacketFactory();
factory.init(null);
assertEquals(null, factory.getNext());
}
@Test
public void testFactoryOne()
{
RtpPacketFactory factory = new RtpPacketFactory(); | factory.init(TestRtpPacket.create(1, 2).getBytes()); |
TerryHowe/SIP-Voice-Quality-Report-Reaper | src/com/tt/reaper/call/StateInvited.java | // Path: src/com/tt/reaper/message/InviteMessage.java
// public class InviteMessage extends RequestMessage {
// public InviteMessage()
// {
// super(Message.INVITE, Request.INVITE, getNewCallId());
// status = init();
// }
//
// public InviteMessage(Request request) {
// super(Message.INVITE, request);
// }
// }
//
// Path: src/com/tt/reaper/message/SipMessage.java
// public abstract class SipMessage extends Message {
// protected static AddressFactory addressFactory;
// protected static HeaderFactory headerFactory;
// protected static MessageFactory messageFactory;
// protected static SdpFactory sdpFactory;
// private static int fromPort;
// private static String fromHost;
// private static String fromUsername;
// private static String toHost;
// private static String toPort;
// private static String toUsername;
// private static String softwareVersion;
//
// protected SipMessage(int type)
// {
// super(type);
// }
//
// public static boolean initFactory(SipFactory sipFactory, Configuration configuration)
// {
// try {
// headerFactory = sipFactory.createHeaderFactory();
// addressFactory = sipFactory.createAddressFactory();
// messageFactory = sipFactory.createMessageFactory();
// sdpFactory = SdpFactory.getInstance();
// fromPort = configuration.getWritePort();
// fromHost = configuration.getWriteInterface();
// fromUsername = configuration.getWriteUsername();
// toHost = configuration.getCollectorHost();
// toPort = "" + configuration.getCollectorPort();
// toUsername = configuration.getCollectorUsername();
// softwareVersion = configuration.getSoftwareVersion();
// return true;
// }
// catch (Exception e)
// {
// logger.error("Error initializing stack: ", e);
// }
// return false;
// }
//
// void setSdp(String sdpContent) {
// try {
// ContentTypeHeader contentTypeHeader;
// contentTypeHeader = headerFactory
// .createContentTypeHeader("application", "sdp");
// getMessage().setContent(sdpContent, contentTypeHeader);
// }
// catch (Exception e)
// {
// e.printStackTrace();
// }
// }
//
// protected static CallIdHeader getNewCallId() {
// return CollectorStack.instance.getNewCallId();
// }
//
// protected final int getFromPort() {
// return fromPort;
// }
//
// protected final String getFromHost() {
// return fromHost;
// }
//
// protected final String getFromUsername() {
// return fromUsername;
// }
//
// protected final String getToHost() {
// return toHost;
// }
//
// protected final String getToPort() {
// return toPort;
// }
//
// protected final String getToUsername() {
// return toUsername;
// }
//
// protected final String getSoftwareVersion() {
// return softwareVersion;
// }
//
// public abstract String getCallId();
// public abstract SIPMessage getMessage();
//
// @SuppressWarnings("unchecked")
// public final ArrayList<AudioData> getAudioData()
// {
// if (getMessage().getRawContent() == null)
// return null;
// ArrayList<AudioData> list = new ArrayList<AudioData>();
// String content = new String(getMessage().getRawContent());
// logger.debug("content=<" + content + ">");
// try {
// SessionDescription sdp = sdpFactory.createSessionDescription(content);
// String ipAddy = sdp.getConnection().getAddress();
// Vector<MediaDescriptionImpl> descriptors = (Vector<MediaDescriptionImpl>)sdp.getMediaDescriptions(true);
// Iterator<MediaDescriptionImpl> it = descriptors.iterator();
// while (it.hasNext()) {
// MediaDescriptionImpl mediaDescription = it.next();
// MediaField field = mediaDescription.getMediaField();
// if (field == null) {
// logger.warn("Missing media field");
// continue;
// }
// AudioData audio = new AudioData();
// audio.ipAddy = ipAddy;
// audio.rtpPort = field.getPort();
// Vector formats = field.getFormats();
// if (formats == null) {
// list.add(audio);
// continue;
// }
// if (formats.size() < 1) {
// list.add(audio);
// continue;
// }
// audio.payloadType = (String) field.getFormats().get(0);
//
// Vector attributes = mediaDescription.getAttributeFields();
// if (attributes == null) {
// list.add(audio);
// continue;
// }
// Iterator ait = attributes.iterator();
// while (ait.hasNext()) {
// Object objay = ait.next();
// if (! (objay instanceof AttributeField))
// continue;
// AttributeField afield = (AttributeField)objay;
// if (! "rtpmap".equals(afield.getName()))
// continue;
// String [] parsed = afield.getValue().split("[ /]");
// if (parsed.length < 3)
// continue;
// if (! parsed[0].equals(audio.payloadType))
// continue;
// audio.payloadDescription = parsed[1];
// audio.sampleRate = parsed[2];
// }
// list.add(audio);
// logger.info(getCallId() + " audio=" + audio.toString());
// }
// return list;
// } catch (Exception e) {
// e.printStackTrace();
// }
// return list;
// }
// }
| import com.tt.reaper.message.InviteMessage;
import com.tt.reaper.message.Message;
import com.tt.reaper.message.RtpPacket;
import com.tt.reaper.message.SipMessage; | package com.tt.reaper.call;
class StateInvited extends State {
public static final StateInvited instance = new StateInvited();
private StateInvited()
{
}
State process(CallContext context, Message message)
{
switch (message.getType())
{
case Message.INVITE: | // Path: src/com/tt/reaper/message/InviteMessage.java
// public class InviteMessage extends RequestMessage {
// public InviteMessage()
// {
// super(Message.INVITE, Request.INVITE, getNewCallId());
// status = init();
// }
//
// public InviteMessage(Request request) {
// super(Message.INVITE, request);
// }
// }
//
// Path: src/com/tt/reaper/message/SipMessage.java
// public abstract class SipMessage extends Message {
// protected static AddressFactory addressFactory;
// protected static HeaderFactory headerFactory;
// protected static MessageFactory messageFactory;
// protected static SdpFactory sdpFactory;
// private static int fromPort;
// private static String fromHost;
// private static String fromUsername;
// private static String toHost;
// private static String toPort;
// private static String toUsername;
// private static String softwareVersion;
//
// protected SipMessage(int type)
// {
// super(type);
// }
//
// public static boolean initFactory(SipFactory sipFactory, Configuration configuration)
// {
// try {
// headerFactory = sipFactory.createHeaderFactory();
// addressFactory = sipFactory.createAddressFactory();
// messageFactory = sipFactory.createMessageFactory();
// sdpFactory = SdpFactory.getInstance();
// fromPort = configuration.getWritePort();
// fromHost = configuration.getWriteInterface();
// fromUsername = configuration.getWriteUsername();
// toHost = configuration.getCollectorHost();
// toPort = "" + configuration.getCollectorPort();
// toUsername = configuration.getCollectorUsername();
// softwareVersion = configuration.getSoftwareVersion();
// return true;
// }
// catch (Exception e)
// {
// logger.error("Error initializing stack: ", e);
// }
// return false;
// }
//
// void setSdp(String sdpContent) {
// try {
// ContentTypeHeader contentTypeHeader;
// contentTypeHeader = headerFactory
// .createContentTypeHeader("application", "sdp");
// getMessage().setContent(sdpContent, contentTypeHeader);
// }
// catch (Exception e)
// {
// e.printStackTrace();
// }
// }
//
// protected static CallIdHeader getNewCallId() {
// return CollectorStack.instance.getNewCallId();
// }
//
// protected final int getFromPort() {
// return fromPort;
// }
//
// protected final String getFromHost() {
// return fromHost;
// }
//
// protected final String getFromUsername() {
// return fromUsername;
// }
//
// protected final String getToHost() {
// return toHost;
// }
//
// protected final String getToPort() {
// return toPort;
// }
//
// protected final String getToUsername() {
// return toUsername;
// }
//
// protected final String getSoftwareVersion() {
// return softwareVersion;
// }
//
// public abstract String getCallId();
// public abstract SIPMessage getMessage();
//
// @SuppressWarnings("unchecked")
// public final ArrayList<AudioData> getAudioData()
// {
// if (getMessage().getRawContent() == null)
// return null;
// ArrayList<AudioData> list = new ArrayList<AudioData>();
// String content = new String(getMessage().getRawContent());
// logger.debug("content=<" + content + ">");
// try {
// SessionDescription sdp = sdpFactory.createSessionDescription(content);
// String ipAddy = sdp.getConnection().getAddress();
// Vector<MediaDescriptionImpl> descriptors = (Vector<MediaDescriptionImpl>)sdp.getMediaDescriptions(true);
// Iterator<MediaDescriptionImpl> it = descriptors.iterator();
// while (it.hasNext()) {
// MediaDescriptionImpl mediaDescription = it.next();
// MediaField field = mediaDescription.getMediaField();
// if (field == null) {
// logger.warn("Missing media field");
// continue;
// }
// AudioData audio = new AudioData();
// audio.ipAddy = ipAddy;
// audio.rtpPort = field.getPort();
// Vector formats = field.getFormats();
// if (formats == null) {
// list.add(audio);
// continue;
// }
// if (formats.size() < 1) {
// list.add(audio);
// continue;
// }
// audio.payloadType = (String) field.getFormats().get(0);
//
// Vector attributes = mediaDescription.getAttributeFields();
// if (attributes == null) {
// list.add(audio);
// continue;
// }
// Iterator ait = attributes.iterator();
// while (ait.hasNext()) {
// Object objay = ait.next();
// if (! (objay instanceof AttributeField))
// continue;
// AttributeField afield = (AttributeField)objay;
// if (! "rtpmap".equals(afield.getName()))
// continue;
// String [] parsed = afield.getValue().split("[ /]");
// if (parsed.length < 3)
// continue;
// if (! parsed[0].equals(audio.payloadType))
// continue;
// audio.payloadDescription = parsed[1];
// audio.sampleRate = parsed[2];
// }
// list.add(audio);
// logger.info(getCallId() + " audio=" + audio.toString());
// }
// return list;
// } catch (Exception e) {
// e.printStackTrace();
// }
// return list;
// }
// }
// Path: src/com/tt/reaper/call/StateInvited.java
import com.tt.reaper.message.InviteMessage;
import com.tt.reaper.message.Message;
import com.tt.reaper.message.RtpPacket;
import com.tt.reaper.message.SipMessage;
package com.tt.reaper.call;
class StateInvited extends State {
public static final StateInvited instance = new StateInvited();
private StateInvited()
{
}
State process(CallContext context, Message message)
{
switch (message.getType())
{
case Message.INVITE: | InviteMessage invite = (InviteMessage)message; |
TerryHowe/SIP-Voice-Quality-Report-Reaper | test/com/tt/reaper/message/TestRtpPacket.java | // Path: src/com/tt/reaper/ReaperLogger.java
// public class ReaperLogger {
// private static boolean initialized = false;
// private static final String FILE_NAME = "config/log4j.properties";
//
// public static synchronized void init() {
// if (initialized == true)
// return;
// initialized = true;
// PropertyConfigurator.configure(FILE_NAME);
// }
// }
| import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
import com.tt.reaper.ReaperLogger; | package com.tt.reaper.message;
public class TestRtpPacket {
public static final String SOURCE_MAC = "1:1:1:1:1:1";
public static final String SOURCE_IP = "10.0.0.1";
public static final String SOURCE_PORT = "9090";
public static final String DESTINATION_MAC = "2:2:2:2:2:2";
public static final String DESTINATION_IP = "10.0.0.2";
public static final String DESTINATION_PORT = "8080";
public static RtpPacket create(int sequenceNumber)
{
return new RtpPacket(create(sequenceNumber, 3));
}
public static String create(int sequenceNumber, int timeStamp) {
return SOURCE_MAC + ";" + SOURCE_IP + ";" + SOURCE_PORT + ";" +
DESTINATION_MAC + ";" + DESTINATION_IP + ";" + DESTINATION_PORT + ";" +
sequenceNumber + ";" + timeStamp + ";" + (timeStamp + 1) + ";\n";
}
@Before
public void setUp()
{ | // Path: src/com/tt/reaper/ReaperLogger.java
// public class ReaperLogger {
// private static boolean initialized = false;
// private static final String FILE_NAME = "config/log4j.properties";
//
// public static synchronized void init() {
// if (initialized == true)
// return;
// initialized = true;
// PropertyConfigurator.configure(FILE_NAME);
// }
// }
// Path: test/com/tt/reaper/message/TestRtpPacket.java
import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
import com.tt.reaper.ReaperLogger;
package com.tt.reaper.message;
public class TestRtpPacket {
public static final String SOURCE_MAC = "1:1:1:1:1:1";
public static final String SOURCE_IP = "10.0.0.1";
public static final String SOURCE_PORT = "9090";
public static final String DESTINATION_MAC = "2:2:2:2:2:2";
public static final String DESTINATION_IP = "10.0.0.2";
public static final String DESTINATION_PORT = "8080";
public static RtpPacket create(int sequenceNumber)
{
return new RtpPacket(create(sequenceNumber, 3));
}
public static String create(int sequenceNumber, int timeStamp) {
return SOURCE_MAC + ";" + SOURCE_IP + ";" + SOURCE_PORT + ";" +
DESTINATION_MAC + ";" + DESTINATION_IP + ";" + DESTINATION_PORT + ";" +
sequenceNumber + ";" + timeStamp + ";" + (timeStamp + 1) + ";\n";
}
@Before
public void setUp()
{ | ReaperLogger.init(); |
RedMadRobot/Chronos | chronos/src/androidTest/java/com/redmadrobot/chronos/MemoryTest.java | // Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/gui/SampleHeavyActivity.java
// public final class SampleHeavyActivity extends MockActivity {
//
// private boolean isOutOfMemory = false;
//
// @Contract(pure = true)
// public boolean isOutOfMemory() {
// return isOutOfMemory;
// }
//
// public final int run() {
// return runOperation(new HeavyOperation());
// }
//
// @SuppressWarnings("UnusedDeclaration")
// public final void onOperationFinished(final HeavyOperationResult result) {
// isOutOfMemory = ((HeavyOperation) result.getOperation()).gotOutOfMemory();
// }
// }
//
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/util/TimingUtils.java
// public static void sleep() {
// try {
// Thread.sleep(TestSettings.RESPONSE_WAIT);
// } catch (InterruptedException e) {
// //ignore it
// }
// }
| import com.redmadrobot.chronos.mock.gui.SampleHeavyActivity;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.MediumTest;
import android.test.suitebuilder.annotation.SmallTest;
import java.util.LinkedList;
import java.util.List;
import static com.redmadrobot.chronos.util.TimingUtils.sleep; | package com.redmadrobot.chronos;
/**
* Test for proper memory management.
*
* @author maximefimov
*/
public class MemoryTest extends AndroidTestCase {
@SmallTest
public void testSingleResultFits() { | // Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/gui/SampleHeavyActivity.java
// public final class SampleHeavyActivity extends MockActivity {
//
// private boolean isOutOfMemory = false;
//
// @Contract(pure = true)
// public boolean isOutOfMemory() {
// return isOutOfMemory;
// }
//
// public final int run() {
// return runOperation(new HeavyOperation());
// }
//
// @SuppressWarnings("UnusedDeclaration")
// public final void onOperationFinished(final HeavyOperationResult result) {
// isOutOfMemory = ((HeavyOperation) result.getOperation()).gotOutOfMemory();
// }
// }
//
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/util/TimingUtils.java
// public static void sleep() {
// try {
// Thread.sleep(TestSettings.RESPONSE_WAIT);
// } catch (InterruptedException e) {
// //ignore it
// }
// }
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/MemoryTest.java
import com.redmadrobot.chronos.mock.gui.SampleHeavyActivity;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.MediumTest;
import android.test.suitebuilder.annotation.SmallTest;
import java.util.LinkedList;
import java.util.List;
import static com.redmadrobot.chronos.util.TimingUtils.sleep;
package com.redmadrobot.chronos;
/**
* Test for proper memory management.
*
* @author maximefimov
*/
public class MemoryTest extends AndroidTestCase {
@SmallTest
public void testSingleResultFits() { | final SampleHeavyActivity activity = new SampleHeavyActivity(); |
RedMadRobot/Chronos | chronos/src/androidTest/java/com/redmadrobot/chronos/MemoryTest.java | // Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/gui/SampleHeavyActivity.java
// public final class SampleHeavyActivity extends MockActivity {
//
// private boolean isOutOfMemory = false;
//
// @Contract(pure = true)
// public boolean isOutOfMemory() {
// return isOutOfMemory;
// }
//
// public final int run() {
// return runOperation(new HeavyOperation());
// }
//
// @SuppressWarnings("UnusedDeclaration")
// public final void onOperationFinished(final HeavyOperationResult result) {
// isOutOfMemory = ((HeavyOperation) result.getOperation()).gotOutOfMemory();
// }
// }
//
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/util/TimingUtils.java
// public static void sleep() {
// try {
// Thread.sleep(TestSettings.RESPONSE_WAIT);
// } catch (InterruptedException e) {
// //ignore it
// }
// }
| import com.redmadrobot.chronos.mock.gui.SampleHeavyActivity;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.MediumTest;
import android.test.suitebuilder.annotation.SmallTest;
import java.util.LinkedList;
import java.util.List;
import static com.redmadrobot.chronos.util.TimingUtils.sleep; | package com.redmadrobot.chronos;
/**
* Test for proper memory management.
*
* @author maximefimov
*/
public class MemoryTest extends AndroidTestCase {
@SmallTest
public void testSingleResultFits() {
final SampleHeavyActivity activity = new SampleHeavyActivity();
activity.start();
activity.run(); | // Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/gui/SampleHeavyActivity.java
// public final class SampleHeavyActivity extends MockActivity {
//
// private boolean isOutOfMemory = false;
//
// @Contract(pure = true)
// public boolean isOutOfMemory() {
// return isOutOfMemory;
// }
//
// public final int run() {
// return runOperation(new HeavyOperation());
// }
//
// @SuppressWarnings("UnusedDeclaration")
// public final void onOperationFinished(final HeavyOperationResult result) {
// isOutOfMemory = ((HeavyOperation) result.getOperation()).gotOutOfMemory();
// }
// }
//
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/util/TimingUtils.java
// public static void sleep() {
// try {
// Thread.sleep(TestSettings.RESPONSE_WAIT);
// } catch (InterruptedException e) {
// //ignore it
// }
// }
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/MemoryTest.java
import com.redmadrobot.chronos.mock.gui.SampleHeavyActivity;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.MediumTest;
import android.test.suitebuilder.annotation.SmallTest;
import java.util.LinkedList;
import java.util.List;
import static com.redmadrobot.chronos.util.TimingUtils.sleep;
package com.redmadrobot.chronos;
/**
* Test for proper memory management.
*
* @author maximefimov
*/
public class MemoryTest extends AndroidTestCase {
@SmallTest
public void testSingleResultFits() {
final SampleHeavyActivity activity = new SampleHeavyActivity();
activity.start();
activity.run(); | sleep(); |
RedMadRobot/Chronos | chronos/src/androidTest/java/com/redmadrobot/chronos/mock/gui/SampleHeavyActivity.java | // Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/HeavyOperation.java
// public final class HeavyOperation extends ChronosOperation<BigObject> {
//
// private boolean hasOutOfMemory = false;
//
// @Contract(pure = true)
// public final boolean gotOutOfMemory() {
// return hasOutOfMemory;
// }
//
// @Nullable
// @Override
// public BigObject run() {
// sleep(TestSettings.OPERATION_WAIT);
// BigObject result = null;
// try {
// result = new BigObject();
// } catch (OutOfMemoryError error) {
// hasOutOfMemory = true;
// }
// return result;
// }
//
// @NonNull
// @Override
// public Class<? extends ChronosOperationResult<BigObject>> getResultClass() {
// return HeavyOperationResult.class;
// }
// }
//
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/HeavyOperationResult.java
// public final class HeavyOperationResult extends ChronosOperationResult<BigObject> {
//
// }
| import com.redmadrobot.chronos.mock.operation.HeavyOperation;
import com.redmadrobot.chronos.mock.operation.HeavyOperationResult;
import org.jetbrains.annotations.Contract; | package com.redmadrobot.chronos.mock.gui;
/**
* Mock activity that does memory-consuming operations.
*
* @author maximefimov
*/
public final class SampleHeavyActivity extends MockActivity {
private boolean isOutOfMemory = false;
@Contract(pure = true)
public boolean isOutOfMemory() {
return isOutOfMemory;
}
public final int run() { | // Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/HeavyOperation.java
// public final class HeavyOperation extends ChronosOperation<BigObject> {
//
// private boolean hasOutOfMemory = false;
//
// @Contract(pure = true)
// public final boolean gotOutOfMemory() {
// return hasOutOfMemory;
// }
//
// @Nullable
// @Override
// public BigObject run() {
// sleep(TestSettings.OPERATION_WAIT);
// BigObject result = null;
// try {
// result = new BigObject();
// } catch (OutOfMemoryError error) {
// hasOutOfMemory = true;
// }
// return result;
// }
//
// @NonNull
// @Override
// public Class<? extends ChronosOperationResult<BigObject>> getResultClass() {
// return HeavyOperationResult.class;
// }
// }
//
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/HeavyOperationResult.java
// public final class HeavyOperationResult extends ChronosOperationResult<BigObject> {
//
// }
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/gui/SampleHeavyActivity.java
import com.redmadrobot.chronos.mock.operation.HeavyOperation;
import com.redmadrobot.chronos.mock.operation.HeavyOperationResult;
import org.jetbrains.annotations.Contract;
package com.redmadrobot.chronos.mock.gui;
/**
* Mock activity that does memory-consuming operations.
*
* @author maximefimov
*/
public final class SampleHeavyActivity extends MockActivity {
private boolean isOutOfMemory = false;
@Contract(pure = true)
public boolean isOutOfMemory() {
return isOutOfMemory;
}
public final int run() { | return runOperation(new HeavyOperation()); |
RedMadRobot/Chronos | chronos/src/androidTest/java/com/redmadrobot/chronos/mock/gui/SampleHeavyActivity.java | // Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/HeavyOperation.java
// public final class HeavyOperation extends ChronosOperation<BigObject> {
//
// private boolean hasOutOfMemory = false;
//
// @Contract(pure = true)
// public final boolean gotOutOfMemory() {
// return hasOutOfMemory;
// }
//
// @Nullable
// @Override
// public BigObject run() {
// sleep(TestSettings.OPERATION_WAIT);
// BigObject result = null;
// try {
// result = new BigObject();
// } catch (OutOfMemoryError error) {
// hasOutOfMemory = true;
// }
// return result;
// }
//
// @NonNull
// @Override
// public Class<? extends ChronosOperationResult<BigObject>> getResultClass() {
// return HeavyOperationResult.class;
// }
// }
//
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/HeavyOperationResult.java
// public final class HeavyOperationResult extends ChronosOperationResult<BigObject> {
//
// }
| import com.redmadrobot.chronos.mock.operation.HeavyOperation;
import com.redmadrobot.chronos.mock.operation.HeavyOperationResult;
import org.jetbrains.annotations.Contract; | package com.redmadrobot.chronos.mock.gui;
/**
* Mock activity that does memory-consuming operations.
*
* @author maximefimov
*/
public final class SampleHeavyActivity extends MockActivity {
private boolean isOutOfMemory = false;
@Contract(pure = true)
public boolean isOutOfMemory() {
return isOutOfMemory;
}
public final int run() {
return runOperation(new HeavyOperation());
}
@SuppressWarnings("UnusedDeclaration") | // Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/HeavyOperation.java
// public final class HeavyOperation extends ChronosOperation<BigObject> {
//
// private boolean hasOutOfMemory = false;
//
// @Contract(pure = true)
// public final boolean gotOutOfMemory() {
// return hasOutOfMemory;
// }
//
// @Nullable
// @Override
// public BigObject run() {
// sleep(TestSettings.OPERATION_WAIT);
// BigObject result = null;
// try {
// result = new BigObject();
// } catch (OutOfMemoryError error) {
// hasOutOfMemory = true;
// }
// return result;
// }
//
// @NonNull
// @Override
// public Class<? extends ChronosOperationResult<BigObject>> getResultClass() {
// return HeavyOperationResult.class;
// }
// }
//
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/HeavyOperationResult.java
// public final class HeavyOperationResult extends ChronosOperationResult<BigObject> {
//
// }
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/gui/SampleHeavyActivity.java
import com.redmadrobot.chronos.mock.operation.HeavyOperation;
import com.redmadrobot.chronos.mock.operation.HeavyOperationResult;
import org.jetbrains.annotations.Contract;
package com.redmadrobot.chronos.mock.gui;
/**
* Mock activity that does memory-consuming operations.
*
* @author maximefimov
*/
public final class SampleHeavyActivity extends MockActivity {
private boolean isOutOfMemory = false;
@Contract(pure = true)
public boolean isOutOfMemory() {
return isOutOfMemory;
}
public final int run() {
return runOperation(new HeavyOperation());
}
@SuppressWarnings("UnusedDeclaration") | public final void onOperationFinished(final HeavyOperationResult result) { |
RedMadRobot/Chronos | app/src/main/java/com/redmadrobot/chronos_sample/samples/SimpleRun.java | // Path: chronos/src/main/java/com/redmadrobot/chronos/gui/activity/ChronosActivity.java
// @SuppressWarnings("unused")
// public abstract class ChronosActivity extends Activity implements ChronosConnectorWrapper {
//
// /**
// * An entry point to access Chronos functions.
// */
// private final ChronosConnector mConnector = new ChronosConnector();
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// mConnector.onCreate(this, savedInstanceState);
// }
//
// @Override
// protected void onResume() {
// super.onResume();
// mConnector.onResume();
// }
//
// @Override
// protected void onSaveInstanceState(@NonNull final Bundle outState) {
// super.onSaveInstanceState(outState);
// mConnector.onSaveInstanceState(outState);
// }
//
// @Override
// protected void onPause() {
// mConnector.onPause();
// super.onPause();
// }
//
// @Override
// public final int runOperation(@NonNull final ChronosOperation operation,
// @NonNull final String tag) {
// return mConnector.runOperation(operation, tag, false);
// }
//
// @Override
// public final int runOperation(@NonNull final ChronosOperation operation) {
// return mConnector.runOperation(operation, false);
// }
//
// @Override
// public final int runOperationBroadcast(@NonNull final ChronosOperation operation,
// @NonNull final String tag) {
// return mConnector.runOperation(operation, tag, true);
// }
//
// @Override
// public final int runOperationBroadcast(@NonNull final ChronosOperation operation) {
// return mConnector.runOperation(operation, true);
// }
//
// @Override
// public final boolean cancelOperation(final int id) {
// return mConnector.cancelOperation(id, true);
// }
//
// @Override
// public final boolean cancelOperation(@NonNull final String tag) {
// return mConnector.cancelOperation(tag, true);
// }
//
// @Override
// @Contract(pure = true)
// public final boolean isOperationRunning(final int id) {
// return mConnector.isOperationRunning(id);
// }
//
// @Override
// @Contract(pure = true)
// public final boolean isOperationRunning(@NonNull final String tag) {
// return mConnector.isOperationRunning(tag);
// }
// }
//
// Path: app/src/main/java/com/redmadrobot/chronos_sample/operations/SimpleOperation.java
// public final class SimpleOperation extends ChronosOperation<String> {
//
// private final String mInput;
//
// public SimpleOperation(@NonNull final String input) {
// mInput = input;
// }
//
// @Nullable
// @Override
// //Chronos will run this method in a background thread, which means you can put
// //any time-consuming calls here, as it will not affect UI thread performance
// public String run() {
// final String result = "String length is " + mInput.length();
//
// try {
// Thread.sleep(3000);
// } catch (InterruptedException e) {
// // do nothing, thread is interrupted, which means a system wants to stop the run
// }
//
// return result;
// }
//
// @NonNull
// @Override
// // To be able to distinguish results from different operations in one Chronos client
// // (most commonly an activity, or a fragment)
// // you should create an 'OperationResult<>' subclass in each operation,
// // so that it will be used as a parameter
// // in a callback method 'onOperationFinished'
// public Class<? extends ChronosOperationResult<String>> getResultClass() {
// return Result.class;
// }
//
// public final static class Result extends ChronosOperationResult<String> {
//
// }
// }
| import com.redmadrobot.chronos.gui.activity.ChronosActivity;
import com.redmadrobot.chronos_sample.R;
import com.redmadrobot.chronos_sample.operations.SimpleOperation;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView; | package com.redmadrobot.chronos_sample.samples;
/**
* A sample of how to use Chronos in a most minimalistic way.
*
* @author maximefimov
*/
public final class SimpleRun extends ChronosActivity {
private TextView mTextOutput;
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_simple_run);
final EditText editInput = (EditText) findViewById(R.id.edit_input);
final View startView = findViewById(R.id.button_start);
mTextOutput = (TextView) findViewById(R.id.text_output);
startView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
// call the 'runOperation' method and it will begin executing of the operation
// in background thread, so it will not block your GUI. | // Path: chronos/src/main/java/com/redmadrobot/chronos/gui/activity/ChronosActivity.java
// @SuppressWarnings("unused")
// public abstract class ChronosActivity extends Activity implements ChronosConnectorWrapper {
//
// /**
// * An entry point to access Chronos functions.
// */
// private final ChronosConnector mConnector = new ChronosConnector();
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// mConnector.onCreate(this, savedInstanceState);
// }
//
// @Override
// protected void onResume() {
// super.onResume();
// mConnector.onResume();
// }
//
// @Override
// protected void onSaveInstanceState(@NonNull final Bundle outState) {
// super.onSaveInstanceState(outState);
// mConnector.onSaveInstanceState(outState);
// }
//
// @Override
// protected void onPause() {
// mConnector.onPause();
// super.onPause();
// }
//
// @Override
// public final int runOperation(@NonNull final ChronosOperation operation,
// @NonNull final String tag) {
// return mConnector.runOperation(operation, tag, false);
// }
//
// @Override
// public final int runOperation(@NonNull final ChronosOperation operation) {
// return mConnector.runOperation(operation, false);
// }
//
// @Override
// public final int runOperationBroadcast(@NonNull final ChronosOperation operation,
// @NonNull final String tag) {
// return mConnector.runOperation(operation, tag, true);
// }
//
// @Override
// public final int runOperationBroadcast(@NonNull final ChronosOperation operation) {
// return mConnector.runOperation(operation, true);
// }
//
// @Override
// public final boolean cancelOperation(final int id) {
// return mConnector.cancelOperation(id, true);
// }
//
// @Override
// public final boolean cancelOperation(@NonNull final String tag) {
// return mConnector.cancelOperation(tag, true);
// }
//
// @Override
// @Contract(pure = true)
// public final boolean isOperationRunning(final int id) {
// return mConnector.isOperationRunning(id);
// }
//
// @Override
// @Contract(pure = true)
// public final boolean isOperationRunning(@NonNull final String tag) {
// return mConnector.isOperationRunning(tag);
// }
// }
//
// Path: app/src/main/java/com/redmadrobot/chronos_sample/operations/SimpleOperation.java
// public final class SimpleOperation extends ChronosOperation<String> {
//
// private final String mInput;
//
// public SimpleOperation(@NonNull final String input) {
// mInput = input;
// }
//
// @Nullable
// @Override
// //Chronos will run this method in a background thread, which means you can put
// //any time-consuming calls here, as it will not affect UI thread performance
// public String run() {
// final String result = "String length is " + mInput.length();
//
// try {
// Thread.sleep(3000);
// } catch (InterruptedException e) {
// // do nothing, thread is interrupted, which means a system wants to stop the run
// }
//
// return result;
// }
//
// @NonNull
// @Override
// // To be able to distinguish results from different operations in one Chronos client
// // (most commonly an activity, or a fragment)
// // you should create an 'OperationResult<>' subclass in each operation,
// // so that it will be used as a parameter
// // in a callback method 'onOperationFinished'
// public Class<? extends ChronosOperationResult<String>> getResultClass() {
// return Result.class;
// }
//
// public final static class Result extends ChronosOperationResult<String> {
//
// }
// }
// Path: app/src/main/java/com/redmadrobot/chronos_sample/samples/SimpleRun.java
import com.redmadrobot.chronos.gui.activity.ChronosActivity;
import com.redmadrobot.chronos_sample.R;
import com.redmadrobot.chronos_sample.operations.SimpleOperation;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
package com.redmadrobot.chronos_sample.samples;
/**
* A sample of how to use Chronos in a most minimalistic way.
*
* @author maximefimov
*/
public final class SimpleRun extends ChronosActivity {
private TextView mTextOutput;
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_simple_run);
final EditText editInput = (EditText) findViewById(R.id.edit_input);
final View startView = findViewById(R.id.button_start);
mTextOutput = (TextView) findViewById(R.id.text_output);
startView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
// call the 'runOperation' method and it will begin executing of the operation
// in background thread, so it will not block your GUI. | runOperation(new SimpleOperation(editInput.getText().toString())); |
RedMadRobot/Chronos | chronos/src/androidTest/java/com/redmadrobot/chronos/mock/gui/SimpleMockFragment.java | // Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/SimpleErrorOperation.java
// public final class SimpleErrorOperation extends ChronosOperation<String> {
//
// private final static RuntimeException EXCEPTION = new RuntimeException("Test exception");
//
// @Contract("null -> false")
// public static boolean isExpectedException(@Nullable final Exception exception) {
// return exception != null && exception.equals(EXCEPTION);
// }
//
// @Nullable
// @Override
// public String run() {
// sleep(TestSettings.OPERATION_WAIT);
// throw EXCEPTION;
// }
//
// @NonNull
// @Override
// public Class<? extends ChronosOperationResult<String>> getResultClass() {
// return SimpleOperationResult.class;
// }
// }
//
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/SimpleOperation.java
// public final class SimpleOperation extends ChronosOperation<String> {
//
// private final String mInput;
//
// public SimpleOperation(@NonNull final String input) {
// mInput = input;
// }
//
// @Nullable
// @Override
// public String run() {
// final String result = transform(mInput);
// sleep(TestSettings.OPERATION_WAIT);
// return result;
// }
//
// public static boolean isTransform(@NonNull final String input, @Nullable final String output) {
// return output != null && transform(input).equals(output);
// }
//
// @NonNull
// private static String transform(@NonNull final String input) {
// return input.concat(input);
// }
//
// @NonNull
// @Override
// public Class<? extends ChronosOperationResult<String>> getResultClass() {
// return SimpleOperationResult.class;
// }
//
// }
//
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/SimpleOperationResult.java
// public final class SimpleOperationResult extends ChronosOperationResult<String> {
//
// }
| import com.redmadrobot.chronos.mock.operation.SimpleErrorOperation;
import com.redmadrobot.chronos.mock.operation.SimpleOperation;
import com.redmadrobot.chronos.mock.operation.SimpleOperationResult;
import org.jetbrains.annotations.Contract;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable; | package com.redmadrobot.chronos.mock.gui;
/**
* Fragment that can do a pre-defined operations and report its status.
*
* @author maximefimov
*/
public final class SimpleMockFragment extends MockFragment {
private final static String OPERATION_TAG = "fragment_operation_tag";
private String mResult;
private Exception mError;
private String mBroadcastResult;
private Exception mBroadcastError;
private int mResultObtained = 0;
private int mBroadcastResultObtained = 0;
@Nullable
public String getResult() {
return mResult;
}
@Nullable
public Exception getError() {
return mError;
}
@Nullable
public String getBroadcastResult() {
return mBroadcastResult;
}
@Nullable
public Exception getBroadcastError() {
return mBroadcastError;
}
public int getBroadcastResultObtained() {
return mBroadcastResultObtained;
}
public final int runSimple(@NonNull final String input) { | // Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/SimpleErrorOperation.java
// public final class SimpleErrorOperation extends ChronosOperation<String> {
//
// private final static RuntimeException EXCEPTION = new RuntimeException("Test exception");
//
// @Contract("null -> false")
// public static boolean isExpectedException(@Nullable final Exception exception) {
// return exception != null && exception.equals(EXCEPTION);
// }
//
// @Nullable
// @Override
// public String run() {
// sleep(TestSettings.OPERATION_WAIT);
// throw EXCEPTION;
// }
//
// @NonNull
// @Override
// public Class<? extends ChronosOperationResult<String>> getResultClass() {
// return SimpleOperationResult.class;
// }
// }
//
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/SimpleOperation.java
// public final class SimpleOperation extends ChronosOperation<String> {
//
// private final String mInput;
//
// public SimpleOperation(@NonNull final String input) {
// mInput = input;
// }
//
// @Nullable
// @Override
// public String run() {
// final String result = transform(mInput);
// sleep(TestSettings.OPERATION_WAIT);
// return result;
// }
//
// public static boolean isTransform(@NonNull final String input, @Nullable final String output) {
// return output != null && transform(input).equals(output);
// }
//
// @NonNull
// private static String transform(@NonNull final String input) {
// return input.concat(input);
// }
//
// @NonNull
// @Override
// public Class<? extends ChronosOperationResult<String>> getResultClass() {
// return SimpleOperationResult.class;
// }
//
// }
//
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/SimpleOperationResult.java
// public final class SimpleOperationResult extends ChronosOperationResult<String> {
//
// }
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/gui/SimpleMockFragment.java
import com.redmadrobot.chronos.mock.operation.SimpleErrorOperation;
import com.redmadrobot.chronos.mock.operation.SimpleOperation;
import com.redmadrobot.chronos.mock.operation.SimpleOperationResult;
import org.jetbrains.annotations.Contract;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
package com.redmadrobot.chronos.mock.gui;
/**
* Fragment that can do a pre-defined operations and report its status.
*
* @author maximefimov
*/
public final class SimpleMockFragment extends MockFragment {
private final static String OPERATION_TAG = "fragment_operation_tag";
private String mResult;
private Exception mError;
private String mBroadcastResult;
private Exception mBroadcastError;
private int mResultObtained = 0;
private int mBroadcastResultObtained = 0;
@Nullable
public String getResult() {
return mResult;
}
@Nullable
public Exception getError() {
return mError;
}
@Nullable
public String getBroadcastResult() {
return mBroadcastResult;
}
@Nullable
public Exception getBroadcastError() {
return mBroadcastError;
}
public int getBroadcastResultObtained() {
return mBroadcastResultObtained;
}
public final int runSimple(@NonNull final String input) { | return runOperation(new SimpleOperation(input)); |
RedMadRobot/Chronos | chronos/src/androidTest/java/com/redmadrobot/chronos/mock/gui/SimpleMockFragment.java | // Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/SimpleErrorOperation.java
// public final class SimpleErrorOperation extends ChronosOperation<String> {
//
// private final static RuntimeException EXCEPTION = new RuntimeException("Test exception");
//
// @Contract("null -> false")
// public static boolean isExpectedException(@Nullable final Exception exception) {
// return exception != null && exception.equals(EXCEPTION);
// }
//
// @Nullable
// @Override
// public String run() {
// sleep(TestSettings.OPERATION_WAIT);
// throw EXCEPTION;
// }
//
// @NonNull
// @Override
// public Class<? extends ChronosOperationResult<String>> getResultClass() {
// return SimpleOperationResult.class;
// }
// }
//
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/SimpleOperation.java
// public final class SimpleOperation extends ChronosOperation<String> {
//
// private final String mInput;
//
// public SimpleOperation(@NonNull final String input) {
// mInput = input;
// }
//
// @Nullable
// @Override
// public String run() {
// final String result = transform(mInput);
// sleep(TestSettings.OPERATION_WAIT);
// return result;
// }
//
// public static boolean isTransform(@NonNull final String input, @Nullable final String output) {
// return output != null && transform(input).equals(output);
// }
//
// @NonNull
// private static String transform(@NonNull final String input) {
// return input.concat(input);
// }
//
// @NonNull
// @Override
// public Class<? extends ChronosOperationResult<String>> getResultClass() {
// return SimpleOperationResult.class;
// }
//
// }
//
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/SimpleOperationResult.java
// public final class SimpleOperationResult extends ChronosOperationResult<String> {
//
// }
| import com.redmadrobot.chronos.mock.operation.SimpleErrorOperation;
import com.redmadrobot.chronos.mock.operation.SimpleOperation;
import com.redmadrobot.chronos.mock.operation.SimpleOperationResult;
import org.jetbrains.annotations.Contract;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable; | public String getBroadcastResult() {
return mBroadcastResult;
}
@Nullable
public Exception getBroadcastError() {
return mBroadcastError;
}
public int getBroadcastResultObtained() {
return mBroadcastResultObtained;
}
public final int runSimple(@NonNull final String input) {
return runOperation(new SimpleOperation(input));
}
public final int runBroadcast(@NonNull final String input) {
return runOperationBroadcast(new SimpleOperation(input));
}
public final int runSimpleTagged(@NonNull final String input) {
return runOperation(new SimpleOperation(input), OPERATION_TAG);
}
public final int runBroadcastTagged(@NonNull final String input) {
return runOperationBroadcast(new SimpleOperation(input), OPERATION_TAG);
}
public final int runErrorSimple() { | // Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/SimpleErrorOperation.java
// public final class SimpleErrorOperation extends ChronosOperation<String> {
//
// private final static RuntimeException EXCEPTION = new RuntimeException("Test exception");
//
// @Contract("null -> false")
// public static boolean isExpectedException(@Nullable final Exception exception) {
// return exception != null && exception.equals(EXCEPTION);
// }
//
// @Nullable
// @Override
// public String run() {
// sleep(TestSettings.OPERATION_WAIT);
// throw EXCEPTION;
// }
//
// @NonNull
// @Override
// public Class<? extends ChronosOperationResult<String>> getResultClass() {
// return SimpleOperationResult.class;
// }
// }
//
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/SimpleOperation.java
// public final class SimpleOperation extends ChronosOperation<String> {
//
// private final String mInput;
//
// public SimpleOperation(@NonNull final String input) {
// mInput = input;
// }
//
// @Nullable
// @Override
// public String run() {
// final String result = transform(mInput);
// sleep(TestSettings.OPERATION_WAIT);
// return result;
// }
//
// public static boolean isTransform(@NonNull final String input, @Nullable final String output) {
// return output != null && transform(input).equals(output);
// }
//
// @NonNull
// private static String transform(@NonNull final String input) {
// return input.concat(input);
// }
//
// @NonNull
// @Override
// public Class<? extends ChronosOperationResult<String>> getResultClass() {
// return SimpleOperationResult.class;
// }
//
// }
//
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/SimpleOperationResult.java
// public final class SimpleOperationResult extends ChronosOperationResult<String> {
//
// }
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/gui/SimpleMockFragment.java
import com.redmadrobot.chronos.mock.operation.SimpleErrorOperation;
import com.redmadrobot.chronos.mock.operation.SimpleOperation;
import com.redmadrobot.chronos.mock.operation.SimpleOperationResult;
import org.jetbrains.annotations.Contract;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
public String getBroadcastResult() {
return mBroadcastResult;
}
@Nullable
public Exception getBroadcastError() {
return mBroadcastError;
}
public int getBroadcastResultObtained() {
return mBroadcastResultObtained;
}
public final int runSimple(@NonNull final String input) {
return runOperation(new SimpleOperation(input));
}
public final int runBroadcast(@NonNull final String input) {
return runOperationBroadcast(new SimpleOperation(input));
}
public final int runSimpleTagged(@NonNull final String input) {
return runOperation(new SimpleOperation(input), OPERATION_TAG);
}
public final int runBroadcastTagged(@NonNull final String input) {
return runOperationBroadcast(new SimpleOperation(input), OPERATION_TAG);
}
public final int runErrorSimple() { | return runOperation(new SimpleErrorOperation()); |
RedMadRobot/Chronos | chronos/src/androidTest/java/com/redmadrobot/chronos/mock/gui/SimpleMockFragment.java | // Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/SimpleErrorOperation.java
// public final class SimpleErrorOperation extends ChronosOperation<String> {
//
// private final static RuntimeException EXCEPTION = new RuntimeException("Test exception");
//
// @Contract("null -> false")
// public static boolean isExpectedException(@Nullable final Exception exception) {
// return exception != null && exception.equals(EXCEPTION);
// }
//
// @Nullable
// @Override
// public String run() {
// sleep(TestSettings.OPERATION_WAIT);
// throw EXCEPTION;
// }
//
// @NonNull
// @Override
// public Class<? extends ChronosOperationResult<String>> getResultClass() {
// return SimpleOperationResult.class;
// }
// }
//
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/SimpleOperation.java
// public final class SimpleOperation extends ChronosOperation<String> {
//
// private final String mInput;
//
// public SimpleOperation(@NonNull final String input) {
// mInput = input;
// }
//
// @Nullable
// @Override
// public String run() {
// final String result = transform(mInput);
// sleep(TestSettings.OPERATION_WAIT);
// return result;
// }
//
// public static boolean isTransform(@NonNull final String input, @Nullable final String output) {
// return output != null && transform(input).equals(output);
// }
//
// @NonNull
// private static String transform(@NonNull final String input) {
// return input.concat(input);
// }
//
// @NonNull
// @Override
// public Class<? extends ChronosOperationResult<String>> getResultClass() {
// return SimpleOperationResult.class;
// }
//
// }
//
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/SimpleOperationResult.java
// public final class SimpleOperationResult extends ChronosOperationResult<String> {
//
// }
| import com.redmadrobot.chronos.mock.operation.SimpleErrorOperation;
import com.redmadrobot.chronos.mock.operation.SimpleOperation;
import com.redmadrobot.chronos.mock.operation.SimpleOperationResult;
import org.jetbrains.annotations.Contract;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable; | return runOperation(new SimpleErrorOperation());
}
public final int runErrorBroadcast() {
return runOperationBroadcast(new SimpleErrorOperation());
}
public final boolean cancel(final int id) {
return cancelOperation(id);
}
public final boolean cancelTagged() {
return cancelOperation(OPERATION_TAG);
}
public final int getResultObtained() {
return mResultObtained;
}
@Contract(pure = true)
public final boolean gotResult() {
return mResultObtained > 0;
}
@Contract(pure = true)
public final boolean gotBroadcastResult() {
return mBroadcastResultObtained > 0;
}
@SuppressWarnings("UnusedDeclaration") | // Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/SimpleErrorOperation.java
// public final class SimpleErrorOperation extends ChronosOperation<String> {
//
// private final static RuntimeException EXCEPTION = new RuntimeException("Test exception");
//
// @Contract("null -> false")
// public static boolean isExpectedException(@Nullable final Exception exception) {
// return exception != null && exception.equals(EXCEPTION);
// }
//
// @Nullable
// @Override
// public String run() {
// sleep(TestSettings.OPERATION_WAIT);
// throw EXCEPTION;
// }
//
// @NonNull
// @Override
// public Class<? extends ChronosOperationResult<String>> getResultClass() {
// return SimpleOperationResult.class;
// }
// }
//
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/SimpleOperation.java
// public final class SimpleOperation extends ChronosOperation<String> {
//
// private final String mInput;
//
// public SimpleOperation(@NonNull final String input) {
// mInput = input;
// }
//
// @Nullable
// @Override
// public String run() {
// final String result = transform(mInput);
// sleep(TestSettings.OPERATION_WAIT);
// return result;
// }
//
// public static boolean isTransform(@NonNull final String input, @Nullable final String output) {
// return output != null && transform(input).equals(output);
// }
//
// @NonNull
// private static String transform(@NonNull final String input) {
// return input.concat(input);
// }
//
// @NonNull
// @Override
// public Class<? extends ChronosOperationResult<String>> getResultClass() {
// return SimpleOperationResult.class;
// }
//
// }
//
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/SimpleOperationResult.java
// public final class SimpleOperationResult extends ChronosOperationResult<String> {
//
// }
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/gui/SimpleMockFragment.java
import com.redmadrobot.chronos.mock.operation.SimpleErrorOperation;
import com.redmadrobot.chronos.mock.operation.SimpleOperation;
import com.redmadrobot.chronos.mock.operation.SimpleOperationResult;
import org.jetbrains.annotations.Contract;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
return runOperation(new SimpleErrorOperation());
}
public final int runErrorBroadcast() {
return runOperationBroadcast(new SimpleErrorOperation());
}
public final boolean cancel(final int id) {
return cancelOperation(id);
}
public final boolean cancelTagged() {
return cancelOperation(OPERATION_TAG);
}
public final int getResultObtained() {
return mResultObtained;
}
@Contract(pure = true)
public final boolean gotResult() {
return mResultObtained > 0;
}
@Contract(pure = true)
public final boolean gotBroadcastResult() {
return mBroadcastResultObtained > 0;
}
@SuppressWarnings("UnusedDeclaration") | public final void onOperationFinished(final SimpleOperationResult result) { |
RedMadRobot/Chronos | chronos/src/androidTest/java/com/redmadrobot/chronos/ActivityRunTest.java | // Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/gui/SimpleMockActivity.java
// public final class SimpleMockActivity extends MockActivity {
//
// private final static String OPERATION_TAG = "activity_operation_tag";
//
// private String mResult;
//
// private Exception mError;
//
// private String mBroadcastResult;
//
// private Exception mBroadcastError;
//
// private int mResultObtained = 0;
//
// private int mBroadcastResultObtained = 0;
//
// @Nullable
// public String getResult() {
// return mResult;
// }
//
// @Nullable
// public Exception getError() {
// return mError;
// }
//
// @Nullable
// public String getBroadcastResult() {
// return mBroadcastResult;
// }
//
// @Nullable
// public Exception getBroadcastError() {
// return mBroadcastError;
// }
//
// public int getBroadcastResultObtained() {
// return mBroadcastResultObtained;
// }
//
// public final int runSimple(@NonNull final String input) {
// return runOperation(new SimpleOperation(input));
// }
//
// public final int runBroadcast(@NonNull final String input) {
// return runOperationBroadcast(new SimpleOperation(input));
// }
//
// public final int runSimpleTagged(@NonNull final String input) {
// return runOperation(new SimpleOperation(input), OPERATION_TAG);
// }
//
// public final int runBroadcastTagged(@NonNull final String input) {
// return runOperationBroadcast(new SimpleOperation(input), OPERATION_TAG);
// }
//
// public final int runErrorSimple() {
// return runOperation(new SimpleErrorOperation());
// }
//
// public final int runErrorBroadcast() {
// return runOperationBroadcast(new SimpleErrorOperation());
// }
//
// public final boolean cancel(final int id) {
// return cancelOperation(id);
// }
//
// public final boolean cancelTagged() {
// return cancelOperation(OPERATION_TAG);
// }
//
// public final boolean isRunning(final int id) {
// return isOperationRunning(id);
// }
//
// public final boolean isRunningTagged() {
// return isOperationRunning(OPERATION_TAG);
// }
//
// public final int getResultObtained() {
// return mResultObtained;
// }
//
// @Contract(pure = true)
// public final boolean gotResult() {
// return mResultObtained > 0;
// }
//
// @Contract(pure = true)
// public final boolean gotBroadcastResult() {
// return mBroadcastResultObtained > 0;
// }
//
// @SuppressWarnings("UnusedDeclaration")
// public final void onOperationFinished(final SimpleOperationResult result) {
// mResultObtained++;
// if (result.isSuccessful()) {
// mResult = result.getOutput();
// } else {
// mError = result.getException();
// }
// }
//
// @SuppressWarnings("UnusedDeclaration")
// public final void onBroadcastOperationFinished(final SimpleOperationResult result) {
// mBroadcastResultObtained++;
// if (result.isSuccessful()) {
// mBroadcastResult = result.getOutput();
// } else {
// mBroadcastError = result.getException();
// }
// }
// }
//
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/SimpleErrorOperation.java
// public final class SimpleErrorOperation extends ChronosOperation<String> {
//
// private final static RuntimeException EXCEPTION = new RuntimeException("Test exception");
//
// @Contract("null -> false")
// public static boolean isExpectedException(@Nullable final Exception exception) {
// return exception != null && exception.equals(EXCEPTION);
// }
//
// @Nullable
// @Override
// public String run() {
// sleep(TestSettings.OPERATION_WAIT);
// throw EXCEPTION;
// }
//
// @NonNull
// @Override
// public Class<? extends ChronosOperationResult<String>> getResultClass() {
// return SimpleOperationResult.class;
// }
// }
//
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/SimpleOperation.java
// public final class SimpleOperation extends ChronosOperation<String> {
//
// private final String mInput;
//
// public SimpleOperation(@NonNull final String input) {
// mInput = input;
// }
//
// @Nullable
// @Override
// public String run() {
// final String result = transform(mInput);
// sleep(TestSettings.OPERATION_WAIT);
// return result;
// }
//
// public static boolean isTransform(@NonNull final String input, @Nullable final String output) {
// return output != null && transform(input).equals(output);
// }
//
// @NonNull
// private static String transform(@NonNull final String input) {
// return input.concat(input);
// }
//
// @NonNull
// @Override
// public Class<? extends ChronosOperationResult<String>> getResultClass() {
// return SimpleOperationResult.class;
// }
//
// }
//
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/TestSettings.java
// public final static String INPUT = "test_input_string";
//
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/TestSettings.java
// public final static long SHORT_WAIT = 50L;
//
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/util/TimingUtils.java
// public static void sleep() {
// try {
// Thread.sleep(TestSettings.RESPONSE_WAIT);
// } catch (InterruptedException e) {
// //ignore it
// }
// }
| import com.redmadrobot.chronos.mock.gui.SimpleMockActivity;
import com.redmadrobot.chronos.mock.operation.SimpleErrorOperation;
import com.redmadrobot.chronos.mock.operation.SimpleOperation;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;
import static com.redmadrobot.chronos.TestSettings.INPUT;
import static com.redmadrobot.chronos.TestSettings.SHORT_WAIT;
import static com.redmadrobot.chronos.util.TimingUtils.sleep; | package com.redmadrobot.chronos;
/**
* Test for operation runs in Activity.
*
* @author maximefimov
*/
public class ActivityRunTest extends AndroidTestCase {
@SmallTest
public void testNormalRun() { | // Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/gui/SimpleMockActivity.java
// public final class SimpleMockActivity extends MockActivity {
//
// private final static String OPERATION_TAG = "activity_operation_tag";
//
// private String mResult;
//
// private Exception mError;
//
// private String mBroadcastResult;
//
// private Exception mBroadcastError;
//
// private int mResultObtained = 0;
//
// private int mBroadcastResultObtained = 0;
//
// @Nullable
// public String getResult() {
// return mResult;
// }
//
// @Nullable
// public Exception getError() {
// return mError;
// }
//
// @Nullable
// public String getBroadcastResult() {
// return mBroadcastResult;
// }
//
// @Nullable
// public Exception getBroadcastError() {
// return mBroadcastError;
// }
//
// public int getBroadcastResultObtained() {
// return mBroadcastResultObtained;
// }
//
// public final int runSimple(@NonNull final String input) {
// return runOperation(new SimpleOperation(input));
// }
//
// public final int runBroadcast(@NonNull final String input) {
// return runOperationBroadcast(new SimpleOperation(input));
// }
//
// public final int runSimpleTagged(@NonNull final String input) {
// return runOperation(new SimpleOperation(input), OPERATION_TAG);
// }
//
// public final int runBroadcastTagged(@NonNull final String input) {
// return runOperationBroadcast(new SimpleOperation(input), OPERATION_TAG);
// }
//
// public final int runErrorSimple() {
// return runOperation(new SimpleErrorOperation());
// }
//
// public final int runErrorBroadcast() {
// return runOperationBroadcast(new SimpleErrorOperation());
// }
//
// public final boolean cancel(final int id) {
// return cancelOperation(id);
// }
//
// public final boolean cancelTagged() {
// return cancelOperation(OPERATION_TAG);
// }
//
// public final boolean isRunning(final int id) {
// return isOperationRunning(id);
// }
//
// public final boolean isRunningTagged() {
// return isOperationRunning(OPERATION_TAG);
// }
//
// public final int getResultObtained() {
// return mResultObtained;
// }
//
// @Contract(pure = true)
// public final boolean gotResult() {
// return mResultObtained > 0;
// }
//
// @Contract(pure = true)
// public final boolean gotBroadcastResult() {
// return mBroadcastResultObtained > 0;
// }
//
// @SuppressWarnings("UnusedDeclaration")
// public final void onOperationFinished(final SimpleOperationResult result) {
// mResultObtained++;
// if (result.isSuccessful()) {
// mResult = result.getOutput();
// } else {
// mError = result.getException();
// }
// }
//
// @SuppressWarnings("UnusedDeclaration")
// public final void onBroadcastOperationFinished(final SimpleOperationResult result) {
// mBroadcastResultObtained++;
// if (result.isSuccessful()) {
// mBroadcastResult = result.getOutput();
// } else {
// mBroadcastError = result.getException();
// }
// }
// }
//
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/SimpleErrorOperation.java
// public final class SimpleErrorOperation extends ChronosOperation<String> {
//
// private final static RuntimeException EXCEPTION = new RuntimeException("Test exception");
//
// @Contract("null -> false")
// public static boolean isExpectedException(@Nullable final Exception exception) {
// return exception != null && exception.equals(EXCEPTION);
// }
//
// @Nullable
// @Override
// public String run() {
// sleep(TestSettings.OPERATION_WAIT);
// throw EXCEPTION;
// }
//
// @NonNull
// @Override
// public Class<? extends ChronosOperationResult<String>> getResultClass() {
// return SimpleOperationResult.class;
// }
// }
//
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/SimpleOperation.java
// public final class SimpleOperation extends ChronosOperation<String> {
//
// private final String mInput;
//
// public SimpleOperation(@NonNull final String input) {
// mInput = input;
// }
//
// @Nullable
// @Override
// public String run() {
// final String result = transform(mInput);
// sleep(TestSettings.OPERATION_WAIT);
// return result;
// }
//
// public static boolean isTransform(@NonNull final String input, @Nullable final String output) {
// return output != null && transform(input).equals(output);
// }
//
// @NonNull
// private static String transform(@NonNull final String input) {
// return input.concat(input);
// }
//
// @NonNull
// @Override
// public Class<? extends ChronosOperationResult<String>> getResultClass() {
// return SimpleOperationResult.class;
// }
//
// }
//
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/TestSettings.java
// public final static String INPUT = "test_input_string";
//
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/TestSettings.java
// public final static long SHORT_WAIT = 50L;
//
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/util/TimingUtils.java
// public static void sleep() {
// try {
// Thread.sleep(TestSettings.RESPONSE_WAIT);
// } catch (InterruptedException e) {
// //ignore it
// }
// }
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/ActivityRunTest.java
import com.redmadrobot.chronos.mock.gui.SimpleMockActivity;
import com.redmadrobot.chronos.mock.operation.SimpleErrorOperation;
import com.redmadrobot.chronos.mock.operation.SimpleOperation;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;
import static com.redmadrobot.chronos.TestSettings.INPUT;
import static com.redmadrobot.chronos.TestSettings.SHORT_WAIT;
import static com.redmadrobot.chronos.util.TimingUtils.sleep;
package com.redmadrobot.chronos;
/**
* Test for operation runs in Activity.
*
* @author maximefimov
*/
public class ActivityRunTest extends AndroidTestCase {
@SmallTest
public void testNormalRun() { | final SimpleMockActivity activity = new SimpleMockActivity(); |
RedMadRobot/Chronos | app/src/main/java/com/redmadrobot/chronos_sample/samples/DataLoadCancel.java | // Path: chronos/src/main/java/com/redmadrobot/chronos/gui/activity/ChronosActivity.java
// @SuppressWarnings("unused")
// public abstract class ChronosActivity extends Activity implements ChronosConnectorWrapper {
//
// /**
// * An entry point to access Chronos functions.
// */
// private final ChronosConnector mConnector = new ChronosConnector();
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// mConnector.onCreate(this, savedInstanceState);
// }
//
// @Override
// protected void onResume() {
// super.onResume();
// mConnector.onResume();
// }
//
// @Override
// protected void onSaveInstanceState(@NonNull final Bundle outState) {
// super.onSaveInstanceState(outState);
// mConnector.onSaveInstanceState(outState);
// }
//
// @Override
// protected void onPause() {
// mConnector.onPause();
// super.onPause();
// }
//
// @Override
// public final int runOperation(@NonNull final ChronosOperation operation,
// @NonNull final String tag) {
// return mConnector.runOperation(operation, tag, false);
// }
//
// @Override
// public final int runOperation(@NonNull final ChronosOperation operation) {
// return mConnector.runOperation(operation, false);
// }
//
// @Override
// public final int runOperationBroadcast(@NonNull final ChronosOperation operation,
// @NonNull final String tag) {
// return mConnector.runOperation(operation, tag, true);
// }
//
// @Override
// public final int runOperationBroadcast(@NonNull final ChronosOperation operation) {
// return mConnector.runOperation(operation, true);
// }
//
// @Override
// public final boolean cancelOperation(final int id) {
// return mConnector.cancelOperation(id, true);
// }
//
// @Override
// public final boolean cancelOperation(@NonNull final String tag) {
// return mConnector.cancelOperation(tag, true);
// }
//
// @Override
// @Contract(pure = true)
// public final boolean isOperationRunning(final int id) {
// return mConnector.isOperationRunning(id);
// }
//
// @Override
// @Contract(pure = true)
// public final boolean isOperationRunning(@NonNull final String tag) {
// return mConnector.isOperationRunning(tag);
// }
// }
//
// Path: app/src/main/java/com/redmadrobot/chronos_sample/operations/SimpleOperation.java
// public final class SimpleOperation extends ChronosOperation<String> {
//
// private final String mInput;
//
// public SimpleOperation(@NonNull final String input) {
// mInput = input;
// }
//
// @Nullable
// @Override
// //Chronos will run this method in a background thread, which means you can put
// //any time-consuming calls here, as it will not affect UI thread performance
// public String run() {
// final String result = "String length is " + mInput.length();
//
// try {
// Thread.sleep(3000);
// } catch (InterruptedException e) {
// // do nothing, thread is interrupted, which means a system wants to stop the run
// }
//
// return result;
// }
//
// @NonNull
// @Override
// // To be able to distinguish results from different operations in one Chronos client
// // (most commonly an activity, or a fragment)
// // you should create an 'OperationResult<>' subclass in each operation,
// // so that it will be used as a parameter
// // in a callback method 'onOperationFinished'
// public Class<? extends ChronosOperationResult<String>> getResultClass() {
// return Result.class;
// }
//
// public final static class Result extends ChronosOperationResult<String> {
//
// }
// }
| import com.redmadrobot.chronos.gui.activity.ChronosActivity;
import com.redmadrobot.chronos_sample.R;
import com.redmadrobot.chronos_sample.operations.SimpleOperation;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast; | protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_data_load_cancel);
mTextOutput = (TextView) findViewById(R.id.text_output);
if (savedInstanceState != null) {
mData = savedInstanceState.getString(KEY_DATA);
}
final View cancelView = findViewById(R.id.button_cancel);
cancelView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
// in any moment of time you can try to cancel a running operation
// though the run may not be cancelled, e.g. the run has been finished already, or never been issued at all
final boolean cancelResult = cancelOperation(TAG_DATA_LOADING);
if (cancelResult) {
mTextOutput.setText("Operation launch is cancelled");
} else {
showToast("Can't cancel operation launch");
}
}
});
}
@Override
protected void onResume() {
super.onResume();
if (mData == null) { | // Path: chronos/src/main/java/com/redmadrobot/chronos/gui/activity/ChronosActivity.java
// @SuppressWarnings("unused")
// public abstract class ChronosActivity extends Activity implements ChronosConnectorWrapper {
//
// /**
// * An entry point to access Chronos functions.
// */
// private final ChronosConnector mConnector = new ChronosConnector();
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// mConnector.onCreate(this, savedInstanceState);
// }
//
// @Override
// protected void onResume() {
// super.onResume();
// mConnector.onResume();
// }
//
// @Override
// protected void onSaveInstanceState(@NonNull final Bundle outState) {
// super.onSaveInstanceState(outState);
// mConnector.onSaveInstanceState(outState);
// }
//
// @Override
// protected void onPause() {
// mConnector.onPause();
// super.onPause();
// }
//
// @Override
// public final int runOperation(@NonNull final ChronosOperation operation,
// @NonNull final String tag) {
// return mConnector.runOperation(operation, tag, false);
// }
//
// @Override
// public final int runOperation(@NonNull final ChronosOperation operation) {
// return mConnector.runOperation(operation, false);
// }
//
// @Override
// public final int runOperationBroadcast(@NonNull final ChronosOperation operation,
// @NonNull final String tag) {
// return mConnector.runOperation(operation, tag, true);
// }
//
// @Override
// public final int runOperationBroadcast(@NonNull final ChronosOperation operation) {
// return mConnector.runOperation(operation, true);
// }
//
// @Override
// public final boolean cancelOperation(final int id) {
// return mConnector.cancelOperation(id, true);
// }
//
// @Override
// public final boolean cancelOperation(@NonNull final String tag) {
// return mConnector.cancelOperation(tag, true);
// }
//
// @Override
// @Contract(pure = true)
// public final boolean isOperationRunning(final int id) {
// return mConnector.isOperationRunning(id);
// }
//
// @Override
// @Contract(pure = true)
// public final boolean isOperationRunning(@NonNull final String tag) {
// return mConnector.isOperationRunning(tag);
// }
// }
//
// Path: app/src/main/java/com/redmadrobot/chronos_sample/operations/SimpleOperation.java
// public final class SimpleOperation extends ChronosOperation<String> {
//
// private final String mInput;
//
// public SimpleOperation(@NonNull final String input) {
// mInput = input;
// }
//
// @Nullable
// @Override
// //Chronos will run this method in a background thread, which means you can put
// //any time-consuming calls here, as it will not affect UI thread performance
// public String run() {
// final String result = "String length is " + mInput.length();
//
// try {
// Thread.sleep(3000);
// } catch (InterruptedException e) {
// // do nothing, thread is interrupted, which means a system wants to stop the run
// }
//
// return result;
// }
//
// @NonNull
// @Override
// // To be able to distinguish results from different operations in one Chronos client
// // (most commonly an activity, or a fragment)
// // you should create an 'OperationResult<>' subclass in each operation,
// // so that it will be used as a parameter
// // in a callback method 'onOperationFinished'
// public Class<? extends ChronosOperationResult<String>> getResultClass() {
// return Result.class;
// }
//
// public final static class Result extends ChronosOperationResult<String> {
//
// }
// }
// Path: app/src/main/java/com/redmadrobot/chronos_sample/samples/DataLoadCancel.java
import com.redmadrobot.chronos.gui.activity.ChronosActivity;
import com.redmadrobot.chronos_sample.R;
import com.redmadrobot.chronos_sample.operations.SimpleOperation;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_data_load_cancel);
mTextOutput = (TextView) findViewById(R.id.text_output);
if (savedInstanceState != null) {
mData = savedInstanceState.getString(KEY_DATA);
}
final View cancelView = findViewById(R.id.button_cancel);
cancelView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
// in any moment of time you can try to cancel a running operation
// though the run may not be cancelled, e.g. the run has been finished already, or never been issued at all
final boolean cancelResult = cancelOperation(TAG_DATA_LOADING);
if (cancelResult) {
mTextOutput.setText("Operation launch is cancelled");
} else {
showToast("Can't cancel operation launch");
}
}
});
}
@Override
protected void onResume() {
super.onResume();
if (mData == null) { | runOperation(new SimpleOperation(""), TAG_DATA_LOADING); |
RedMadRobot/Chronos | chronos/src/androidTest/java/com/redmadrobot/chronos/mock/gui/SimpleMockActivity.java | // Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/SimpleErrorOperation.java
// public final class SimpleErrorOperation extends ChronosOperation<String> {
//
// private final static RuntimeException EXCEPTION = new RuntimeException("Test exception");
//
// @Contract("null -> false")
// public static boolean isExpectedException(@Nullable final Exception exception) {
// return exception != null && exception.equals(EXCEPTION);
// }
//
// @Nullable
// @Override
// public String run() {
// sleep(TestSettings.OPERATION_WAIT);
// throw EXCEPTION;
// }
//
// @NonNull
// @Override
// public Class<? extends ChronosOperationResult<String>> getResultClass() {
// return SimpleOperationResult.class;
// }
// }
//
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/SimpleOperation.java
// public final class SimpleOperation extends ChronosOperation<String> {
//
// private final String mInput;
//
// public SimpleOperation(@NonNull final String input) {
// mInput = input;
// }
//
// @Nullable
// @Override
// public String run() {
// final String result = transform(mInput);
// sleep(TestSettings.OPERATION_WAIT);
// return result;
// }
//
// public static boolean isTransform(@NonNull final String input, @Nullable final String output) {
// return output != null && transform(input).equals(output);
// }
//
// @NonNull
// private static String transform(@NonNull final String input) {
// return input.concat(input);
// }
//
// @NonNull
// @Override
// public Class<? extends ChronosOperationResult<String>> getResultClass() {
// return SimpleOperationResult.class;
// }
//
// }
//
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/SimpleOperationResult.java
// public final class SimpleOperationResult extends ChronosOperationResult<String> {
//
// }
| import com.redmadrobot.chronos.mock.operation.SimpleErrorOperation;
import com.redmadrobot.chronos.mock.operation.SimpleOperation;
import com.redmadrobot.chronos.mock.operation.SimpleOperationResult;
import org.jetbrains.annotations.Contract;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable; | package com.redmadrobot.chronos.mock.gui;
/**
* Activity that can do a pre-defined operations and report its status.
*
* @author maximefimov
*/
public final class SimpleMockActivity extends MockActivity {
private final static String OPERATION_TAG = "activity_operation_tag";
private String mResult;
private Exception mError;
private String mBroadcastResult;
private Exception mBroadcastError;
private int mResultObtained = 0;
private int mBroadcastResultObtained = 0;
@Nullable
public String getResult() {
return mResult;
}
@Nullable
public Exception getError() {
return mError;
}
@Nullable
public String getBroadcastResult() {
return mBroadcastResult;
}
@Nullable
public Exception getBroadcastError() {
return mBroadcastError;
}
public int getBroadcastResultObtained() {
return mBroadcastResultObtained;
}
public final int runSimple(@NonNull final String input) { | // Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/SimpleErrorOperation.java
// public final class SimpleErrorOperation extends ChronosOperation<String> {
//
// private final static RuntimeException EXCEPTION = new RuntimeException("Test exception");
//
// @Contract("null -> false")
// public static boolean isExpectedException(@Nullable final Exception exception) {
// return exception != null && exception.equals(EXCEPTION);
// }
//
// @Nullable
// @Override
// public String run() {
// sleep(TestSettings.OPERATION_WAIT);
// throw EXCEPTION;
// }
//
// @NonNull
// @Override
// public Class<? extends ChronosOperationResult<String>> getResultClass() {
// return SimpleOperationResult.class;
// }
// }
//
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/SimpleOperation.java
// public final class SimpleOperation extends ChronosOperation<String> {
//
// private final String mInput;
//
// public SimpleOperation(@NonNull final String input) {
// mInput = input;
// }
//
// @Nullable
// @Override
// public String run() {
// final String result = transform(mInput);
// sleep(TestSettings.OPERATION_WAIT);
// return result;
// }
//
// public static boolean isTransform(@NonNull final String input, @Nullable final String output) {
// return output != null && transform(input).equals(output);
// }
//
// @NonNull
// private static String transform(@NonNull final String input) {
// return input.concat(input);
// }
//
// @NonNull
// @Override
// public Class<? extends ChronosOperationResult<String>> getResultClass() {
// return SimpleOperationResult.class;
// }
//
// }
//
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/SimpleOperationResult.java
// public final class SimpleOperationResult extends ChronosOperationResult<String> {
//
// }
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/gui/SimpleMockActivity.java
import com.redmadrobot.chronos.mock.operation.SimpleErrorOperation;
import com.redmadrobot.chronos.mock.operation.SimpleOperation;
import com.redmadrobot.chronos.mock.operation.SimpleOperationResult;
import org.jetbrains.annotations.Contract;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
package com.redmadrobot.chronos.mock.gui;
/**
* Activity that can do a pre-defined operations and report its status.
*
* @author maximefimov
*/
public final class SimpleMockActivity extends MockActivity {
private final static String OPERATION_TAG = "activity_operation_tag";
private String mResult;
private Exception mError;
private String mBroadcastResult;
private Exception mBroadcastError;
private int mResultObtained = 0;
private int mBroadcastResultObtained = 0;
@Nullable
public String getResult() {
return mResult;
}
@Nullable
public Exception getError() {
return mError;
}
@Nullable
public String getBroadcastResult() {
return mBroadcastResult;
}
@Nullable
public Exception getBroadcastError() {
return mBroadcastError;
}
public int getBroadcastResultObtained() {
return mBroadcastResultObtained;
}
public final int runSimple(@NonNull final String input) { | return runOperation(new SimpleOperation(input)); |
RedMadRobot/Chronos | chronos/src/androidTest/java/com/redmadrobot/chronos/mock/gui/SimpleMockActivity.java | // Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/SimpleErrorOperation.java
// public final class SimpleErrorOperation extends ChronosOperation<String> {
//
// private final static RuntimeException EXCEPTION = new RuntimeException("Test exception");
//
// @Contract("null -> false")
// public static boolean isExpectedException(@Nullable final Exception exception) {
// return exception != null && exception.equals(EXCEPTION);
// }
//
// @Nullable
// @Override
// public String run() {
// sleep(TestSettings.OPERATION_WAIT);
// throw EXCEPTION;
// }
//
// @NonNull
// @Override
// public Class<? extends ChronosOperationResult<String>> getResultClass() {
// return SimpleOperationResult.class;
// }
// }
//
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/SimpleOperation.java
// public final class SimpleOperation extends ChronosOperation<String> {
//
// private final String mInput;
//
// public SimpleOperation(@NonNull final String input) {
// mInput = input;
// }
//
// @Nullable
// @Override
// public String run() {
// final String result = transform(mInput);
// sleep(TestSettings.OPERATION_WAIT);
// return result;
// }
//
// public static boolean isTransform(@NonNull final String input, @Nullable final String output) {
// return output != null && transform(input).equals(output);
// }
//
// @NonNull
// private static String transform(@NonNull final String input) {
// return input.concat(input);
// }
//
// @NonNull
// @Override
// public Class<? extends ChronosOperationResult<String>> getResultClass() {
// return SimpleOperationResult.class;
// }
//
// }
//
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/SimpleOperationResult.java
// public final class SimpleOperationResult extends ChronosOperationResult<String> {
//
// }
| import com.redmadrobot.chronos.mock.operation.SimpleErrorOperation;
import com.redmadrobot.chronos.mock.operation.SimpleOperation;
import com.redmadrobot.chronos.mock.operation.SimpleOperationResult;
import org.jetbrains.annotations.Contract;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable; | public String getBroadcastResult() {
return mBroadcastResult;
}
@Nullable
public Exception getBroadcastError() {
return mBroadcastError;
}
public int getBroadcastResultObtained() {
return mBroadcastResultObtained;
}
public final int runSimple(@NonNull final String input) {
return runOperation(new SimpleOperation(input));
}
public final int runBroadcast(@NonNull final String input) {
return runOperationBroadcast(new SimpleOperation(input));
}
public final int runSimpleTagged(@NonNull final String input) {
return runOperation(new SimpleOperation(input), OPERATION_TAG);
}
public final int runBroadcastTagged(@NonNull final String input) {
return runOperationBroadcast(new SimpleOperation(input), OPERATION_TAG);
}
public final int runErrorSimple() { | // Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/SimpleErrorOperation.java
// public final class SimpleErrorOperation extends ChronosOperation<String> {
//
// private final static RuntimeException EXCEPTION = new RuntimeException("Test exception");
//
// @Contract("null -> false")
// public static boolean isExpectedException(@Nullable final Exception exception) {
// return exception != null && exception.equals(EXCEPTION);
// }
//
// @Nullable
// @Override
// public String run() {
// sleep(TestSettings.OPERATION_WAIT);
// throw EXCEPTION;
// }
//
// @NonNull
// @Override
// public Class<? extends ChronosOperationResult<String>> getResultClass() {
// return SimpleOperationResult.class;
// }
// }
//
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/SimpleOperation.java
// public final class SimpleOperation extends ChronosOperation<String> {
//
// private final String mInput;
//
// public SimpleOperation(@NonNull final String input) {
// mInput = input;
// }
//
// @Nullable
// @Override
// public String run() {
// final String result = transform(mInput);
// sleep(TestSettings.OPERATION_WAIT);
// return result;
// }
//
// public static boolean isTransform(@NonNull final String input, @Nullable final String output) {
// return output != null && transform(input).equals(output);
// }
//
// @NonNull
// private static String transform(@NonNull final String input) {
// return input.concat(input);
// }
//
// @NonNull
// @Override
// public Class<? extends ChronosOperationResult<String>> getResultClass() {
// return SimpleOperationResult.class;
// }
//
// }
//
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/SimpleOperationResult.java
// public final class SimpleOperationResult extends ChronosOperationResult<String> {
//
// }
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/gui/SimpleMockActivity.java
import com.redmadrobot.chronos.mock.operation.SimpleErrorOperation;
import com.redmadrobot.chronos.mock.operation.SimpleOperation;
import com.redmadrobot.chronos.mock.operation.SimpleOperationResult;
import org.jetbrains.annotations.Contract;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
public String getBroadcastResult() {
return mBroadcastResult;
}
@Nullable
public Exception getBroadcastError() {
return mBroadcastError;
}
public int getBroadcastResultObtained() {
return mBroadcastResultObtained;
}
public final int runSimple(@NonNull final String input) {
return runOperation(new SimpleOperation(input));
}
public final int runBroadcast(@NonNull final String input) {
return runOperationBroadcast(new SimpleOperation(input));
}
public final int runSimpleTagged(@NonNull final String input) {
return runOperation(new SimpleOperation(input), OPERATION_TAG);
}
public final int runBroadcastTagged(@NonNull final String input) {
return runOperationBroadcast(new SimpleOperation(input), OPERATION_TAG);
}
public final int runErrorSimple() { | return runOperation(new SimpleErrorOperation()); |
RedMadRobot/Chronos | chronos/src/androidTest/java/com/redmadrobot/chronos/mock/gui/SimpleMockActivity.java | // Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/SimpleErrorOperation.java
// public final class SimpleErrorOperation extends ChronosOperation<String> {
//
// private final static RuntimeException EXCEPTION = new RuntimeException("Test exception");
//
// @Contract("null -> false")
// public static boolean isExpectedException(@Nullable final Exception exception) {
// return exception != null && exception.equals(EXCEPTION);
// }
//
// @Nullable
// @Override
// public String run() {
// sleep(TestSettings.OPERATION_WAIT);
// throw EXCEPTION;
// }
//
// @NonNull
// @Override
// public Class<? extends ChronosOperationResult<String>> getResultClass() {
// return SimpleOperationResult.class;
// }
// }
//
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/SimpleOperation.java
// public final class SimpleOperation extends ChronosOperation<String> {
//
// private final String mInput;
//
// public SimpleOperation(@NonNull final String input) {
// mInput = input;
// }
//
// @Nullable
// @Override
// public String run() {
// final String result = transform(mInput);
// sleep(TestSettings.OPERATION_WAIT);
// return result;
// }
//
// public static boolean isTransform(@NonNull final String input, @Nullable final String output) {
// return output != null && transform(input).equals(output);
// }
//
// @NonNull
// private static String transform(@NonNull final String input) {
// return input.concat(input);
// }
//
// @NonNull
// @Override
// public Class<? extends ChronosOperationResult<String>> getResultClass() {
// return SimpleOperationResult.class;
// }
//
// }
//
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/SimpleOperationResult.java
// public final class SimpleOperationResult extends ChronosOperationResult<String> {
//
// }
| import com.redmadrobot.chronos.mock.operation.SimpleErrorOperation;
import com.redmadrobot.chronos.mock.operation.SimpleOperation;
import com.redmadrobot.chronos.mock.operation.SimpleOperationResult;
import org.jetbrains.annotations.Contract;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable; | return cancelOperation(id);
}
public final boolean cancelTagged() {
return cancelOperation(OPERATION_TAG);
}
public final boolean isRunning(final int id) {
return isOperationRunning(id);
}
public final boolean isRunningTagged() {
return isOperationRunning(OPERATION_TAG);
}
public final int getResultObtained() {
return mResultObtained;
}
@Contract(pure = true)
public final boolean gotResult() {
return mResultObtained > 0;
}
@Contract(pure = true)
public final boolean gotBroadcastResult() {
return mBroadcastResultObtained > 0;
}
@SuppressWarnings("UnusedDeclaration") | // Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/SimpleErrorOperation.java
// public final class SimpleErrorOperation extends ChronosOperation<String> {
//
// private final static RuntimeException EXCEPTION = new RuntimeException("Test exception");
//
// @Contract("null -> false")
// public static boolean isExpectedException(@Nullable final Exception exception) {
// return exception != null && exception.equals(EXCEPTION);
// }
//
// @Nullable
// @Override
// public String run() {
// sleep(TestSettings.OPERATION_WAIT);
// throw EXCEPTION;
// }
//
// @NonNull
// @Override
// public Class<? extends ChronosOperationResult<String>> getResultClass() {
// return SimpleOperationResult.class;
// }
// }
//
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/SimpleOperation.java
// public final class SimpleOperation extends ChronosOperation<String> {
//
// private final String mInput;
//
// public SimpleOperation(@NonNull final String input) {
// mInput = input;
// }
//
// @Nullable
// @Override
// public String run() {
// final String result = transform(mInput);
// sleep(TestSettings.OPERATION_WAIT);
// return result;
// }
//
// public static boolean isTransform(@NonNull final String input, @Nullable final String output) {
// return output != null && transform(input).equals(output);
// }
//
// @NonNull
// private static String transform(@NonNull final String input) {
// return input.concat(input);
// }
//
// @NonNull
// @Override
// public Class<? extends ChronosOperationResult<String>> getResultClass() {
// return SimpleOperationResult.class;
// }
//
// }
//
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/operation/SimpleOperationResult.java
// public final class SimpleOperationResult extends ChronosOperationResult<String> {
//
// }
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/mock/gui/SimpleMockActivity.java
import com.redmadrobot.chronos.mock.operation.SimpleErrorOperation;
import com.redmadrobot.chronos.mock.operation.SimpleOperation;
import com.redmadrobot.chronos.mock.operation.SimpleOperationResult;
import org.jetbrains.annotations.Contract;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
return cancelOperation(id);
}
public final boolean cancelTagged() {
return cancelOperation(OPERATION_TAG);
}
public final boolean isRunning(final int id) {
return isOperationRunning(id);
}
public final boolean isRunningTagged() {
return isOperationRunning(OPERATION_TAG);
}
public final int getResultObtained() {
return mResultObtained;
}
@Contract(pure = true)
public final boolean gotResult() {
return mResultObtained > 0;
}
@Contract(pure = true)
public final boolean gotBroadcastResult() {
return mBroadcastResultObtained > 0;
}
@SuppressWarnings("UnusedDeclaration") | public final void onOperationFinished(final SimpleOperationResult result) { |
RedMadRobot/Chronos | app/src/main/java/com/redmadrobot/chronos_sample/samples/DataLoad.java | // Path: chronos/src/main/java/com/redmadrobot/chronos/gui/activity/ChronosActivity.java
// @SuppressWarnings("unused")
// public abstract class ChronosActivity extends Activity implements ChronosConnectorWrapper {
//
// /**
// * An entry point to access Chronos functions.
// */
// private final ChronosConnector mConnector = new ChronosConnector();
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// mConnector.onCreate(this, savedInstanceState);
// }
//
// @Override
// protected void onResume() {
// super.onResume();
// mConnector.onResume();
// }
//
// @Override
// protected void onSaveInstanceState(@NonNull final Bundle outState) {
// super.onSaveInstanceState(outState);
// mConnector.onSaveInstanceState(outState);
// }
//
// @Override
// protected void onPause() {
// mConnector.onPause();
// super.onPause();
// }
//
// @Override
// public final int runOperation(@NonNull final ChronosOperation operation,
// @NonNull final String tag) {
// return mConnector.runOperation(operation, tag, false);
// }
//
// @Override
// public final int runOperation(@NonNull final ChronosOperation operation) {
// return mConnector.runOperation(operation, false);
// }
//
// @Override
// public final int runOperationBroadcast(@NonNull final ChronosOperation operation,
// @NonNull final String tag) {
// return mConnector.runOperation(operation, tag, true);
// }
//
// @Override
// public final int runOperationBroadcast(@NonNull final ChronosOperation operation) {
// return mConnector.runOperation(operation, true);
// }
//
// @Override
// public final boolean cancelOperation(final int id) {
// return mConnector.cancelOperation(id, true);
// }
//
// @Override
// public final boolean cancelOperation(@NonNull final String tag) {
// return mConnector.cancelOperation(tag, true);
// }
//
// @Override
// @Contract(pure = true)
// public final boolean isOperationRunning(final int id) {
// return mConnector.isOperationRunning(id);
// }
//
// @Override
// @Contract(pure = true)
// public final boolean isOperationRunning(@NonNull final String tag) {
// return mConnector.isOperationRunning(tag);
// }
// }
//
// Path: app/src/main/java/com/redmadrobot/chronos_sample/operations/SimpleOperation.java
// public final class SimpleOperation extends ChronosOperation<String> {
//
// private final String mInput;
//
// public SimpleOperation(@NonNull final String input) {
// mInput = input;
// }
//
// @Nullable
// @Override
// //Chronos will run this method in a background thread, which means you can put
// //any time-consuming calls here, as it will not affect UI thread performance
// public String run() {
// final String result = "String length is " + mInput.length();
//
// try {
// Thread.sleep(3000);
// } catch (InterruptedException e) {
// // do nothing, thread is interrupted, which means a system wants to stop the run
// }
//
// return result;
// }
//
// @NonNull
// @Override
// // To be able to distinguish results from different operations in one Chronos client
// // (most commonly an activity, or a fragment)
// // you should create an 'OperationResult<>' subclass in each operation,
// // so that it will be used as a parameter
// // in a callback method 'onOperationFinished'
// public Class<? extends ChronosOperationResult<String>> getResultClass() {
// return Result.class;
// }
//
// public final static class Result extends ChronosOperationResult<String> {
//
// }
// }
| import com.redmadrobot.chronos.gui.activity.ChronosActivity;
import com.redmadrobot.chronos_sample.R;
import com.redmadrobot.chronos_sample.operations.SimpleOperation;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.widget.TextView; | package com.redmadrobot.chronos_sample.samples;
/**
* A sample of how you can easily initiate your layout with data provided by some source, that takes
* some time to give a response, such as remote server, or a database.
*
* @author maximefimov
*/
public final class DataLoad extends ChronosActivity {
// a key by which the activity saves and restores already loaded data
private final static String KEY_DATA = "data";
// a tag which represents a group of operations that can't run simultaneously
private final static String TAG_DATA_LOADING = "data_loading";
private TextView mTextOutput;
// a data that has to be loaded
private String mData = null;
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_data_load);
mTextOutput = (TextView) findViewById(R.id.text_output);
if (savedInstanceState != null) {
//first of all, the activity tries to restored already loaded data
mData = savedInstanceState.getString(KEY_DATA);
}
}
@Override
protected void onResume() {
super.onResume();
//after this point all pending OperationResults are delivered, so that you may be sure,
// that all proper 'onOperationFinished' calls are done
if (mData == null) {// if it is still no data
// The activity launches a loading operations with a tag
// so that if it comes to this point once again and the data is not loaded yet,
// the next launch will be ignored.
// That means, no matter now often user rotates the device,
// only one operation with a given tag may be pending in a single moment of time. | // Path: chronos/src/main/java/com/redmadrobot/chronos/gui/activity/ChronosActivity.java
// @SuppressWarnings("unused")
// public abstract class ChronosActivity extends Activity implements ChronosConnectorWrapper {
//
// /**
// * An entry point to access Chronos functions.
// */
// private final ChronosConnector mConnector = new ChronosConnector();
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// mConnector.onCreate(this, savedInstanceState);
// }
//
// @Override
// protected void onResume() {
// super.onResume();
// mConnector.onResume();
// }
//
// @Override
// protected void onSaveInstanceState(@NonNull final Bundle outState) {
// super.onSaveInstanceState(outState);
// mConnector.onSaveInstanceState(outState);
// }
//
// @Override
// protected void onPause() {
// mConnector.onPause();
// super.onPause();
// }
//
// @Override
// public final int runOperation(@NonNull final ChronosOperation operation,
// @NonNull final String tag) {
// return mConnector.runOperation(operation, tag, false);
// }
//
// @Override
// public final int runOperation(@NonNull final ChronosOperation operation) {
// return mConnector.runOperation(operation, false);
// }
//
// @Override
// public final int runOperationBroadcast(@NonNull final ChronosOperation operation,
// @NonNull final String tag) {
// return mConnector.runOperation(operation, tag, true);
// }
//
// @Override
// public final int runOperationBroadcast(@NonNull final ChronosOperation operation) {
// return mConnector.runOperation(operation, true);
// }
//
// @Override
// public final boolean cancelOperation(final int id) {
// return mConnector.cancelOperation(id, true);
// }
//
// @Override
// public final boolean cancelOperation(@NonNull final String tag) {
// return mConnector.cancelOperation(tag, true);
// }
//
// @Override
// @Contract(pure = true)
// public final boolean isOperationRunning(final int id) {
// return mConnector.isOperationRunning(id);
// }
//
// @Override
// @Contract(pure = true)
// public final boolean isOperationRunning(@NonNull final String tag) {
// return mConnector.isOperationRunning(tag);
// }
// }
//
// Path: app/src/main/java/com/redmadrobot/chronos_sample/operations/SimpleOperation.java
// public final class SimpleOperation extends ChronosOperation<String> {
//
// private final String mInput;
//
// public SimpleOperation(@NonNull final String input) {
// mInput = input;
// }
//
// @Nullable
// @Override
// //Chronos will run this method in a background thread, which means you can put
// //any time-consuming calls here, as it will not affect UI thread performance
// public String run() {
// final String result = "String length is " + mInput.length();
//
// try {
// Thread.sleep(3000);
// } catch (InterruptedException e) {
// // do nothing, thread is interrupted, which means a system wants to stop the run
// }
//
// return result;
// }
//
// @NonNull
// @Override
// // To be able to distinguish results from different operations in one Chronos client
// // (most commonly an activity, or a fragment)
// // you should create an 'OperationResult<>' subclass in each operation,
// // so that it will be used as a parameter
// // in a callback method 'onOperationFinished'
// public Class<? extends ChronosOperationResult<String>> getResultClass() {
// return Result.class;
// }
//
// public final static class Result extends ChronosOperationResult<String> {
//
// }
// }
// Path: app/src/main/java/com/redmadrobot/chronos_sample/samples/DataLoad.java
import com.redmadrobot.chronos.gui.activity.ChronosActivity;
import com.redmadrobot.chronos_sample.R;
import com.redmadrobot.chronos_sample.operations.SimpleOperation;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.widget.TextView;
package com.redmadrobot.chronos_sample.samples;
/**
* A sample of how you can easily initiate your layout with data provided by some source, that takes
* some time to give a response, such as remote server, or a database.
*
* @author maximefimov
*/
public final class DataLoad extends ChronosActivity {
// a key by which the activity saves and restores already loaded data
private final static String KEY_DATA = "data";
// a tag which represents a group of operations that can't run simultaneously
private final static String TAG_DATA_LOADING = "data_loading";
private TextView mTextOutput;
// a data that has to be loaded
private String mData = null;
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_data_load);
mTextOutput = (TextView) findViewById(R.id.text_output);
if (savedInstanceState != null) {
//first of all, the activity tries to restored already loaded data
mData = savedInstanceState.getString(KEY_DATA);
}
}
@Override
protected void onResume() {
super.onResume();
//after this point all pending OperationResults are delivered, so that you may be sure,
// that all proper 'onOperationFinished' calls are done
if (mData == null) {// if it is still no data
// The activity launches a loading operations with a tag
// so that if it comes to this point once again and the data is not loaded yet,
// the next launch will be ignored.
// That means, no matter now often user rotates the device,
// only one operation with a given tag may be pending in a single moment of time. | runOperation(new SimpleOperation(""), TAG_DATA_LOADING); |
RedMadRobot/Chronos | chronos/src/androidTest/java/com/redmadrobot/chronos/util/TimingUtils.java | // Path: chronos/src/androidTest/java/com/redmadrobot/chronos/TestSettings.java
// public final class TestSettings {
//
// public final static long MICRO_WAIT = 10L;
//
// public final static long SHORT_WAIT = 50L;
//
// public final static long OPERATION_WAIT = 100L;
//
// public final static long RESPONSE_WAIT = 200L;
//
// public final static String INPUT = "test_input_string";
//
// private TestSettings() {
//
// }
// }
| import com.redmadrobot.chronos.TestSettings; | package com.redmadrobot.chronos.util;
/**
* Utilities to mock waiting for long running tasks.
*
* @author maximefimov
*/
public final class TimingUtils {
private TimingUtils() {
}
/**
* Current thread sleeps for a predefined amount of time. If it has been interrupted, the method
* would be finished and no exception is thrown.
*/
public static void sleep() {
try { | // Path: chronos/src/androidTest/java/com/redmadrobot/chronos/TestSettings.java
// public final class TestSettings {
//
// public final static long MICRO_WAIT = 10L;
//
// public final static long SHORT_WAIT = 50L;
//
// public final static long OPERATION_WAIT = 100L;
//
// public final static long RESPONSE_WAIT = 200L;
//
// public final static String INPUT = "test_input_string";
//
// private TestSettings() {
//
// }
// }
// Path: chronos/src/androidTest/java/com/redmadrobot/chronos/util/TimingUtils.java
import com.redmadrobot.chronos.TestSettings;
package com.redmadrobot.chronos.util;
/**
* Utilities to mock waiting for long running tasks.
*
* @author maximefimov
*/
public final class TimingUtils {
private TimingUtils() {
}
/**
* Current thread sleeps for a predefined amount of time. If it has been interrupted, the method
* would be finished and no exception is thrown.
*/
public static void sleep() {
try { | Thread.sleep(TestSettings.RESPONSE_WAIT); |
jembi/openhim-legacy | src/test/java/org/jembi/openhim/DefaultChannelComponentTest.java | // Path: src/main/java/org/jembi/openhim/DefaultChannelComponent.java
// public static class URLMapping {
// private String urlPattern;
// private String host;
// private String port;
// private String username;
// private String password;
// private String authType;
// private String allowUnsecured;
// private String path;
// private String pathTransform;
//
// @Override
// public boolean equals(Object obj) {
// if (!(obj instanceof URLMapping)) {
// return false;
// }
// URLMapping mapping = (URLMapping) obj;
// if (urlPattern.equals(mapping.getUrlPattern())
// && host.equals(mapping.getHost())
// && port.equals(mapping.getPort())) {
//
// return true;
// }
// return false;
// }
//
// public String getAuthType() {
// return authType;
// }
//
// public void setAuthType(String authType) {
// this.authType = authType;
// }
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getUrlPattern() {
// return urlPattern;
// }
//
// public void setUrlPattern(String urlPattern) {
// this.urlPattern = urlPattern;
// }
//
// public String getHost() {
// return host;
// }
//
// public void setHost(String host) {
// this.host = host;
// }
//
// public String getPort() {
// return port;
// }
//
// public void setPort(String port) {
// this.port = port;
// }
//
// public String getAllowUnsecured() {
// return allowUnsecured;
// }
//
// public void setAllowUnsecured(String allowUnsecured) {
// this.allowUnsecured = allowUnsecured;
// }
//
// public String getPath() {
// return path;
// }
//
// public void setPath(String path) {
// this.path = path;
// }
//
// public String getPathTransform() {
// return pathTransform;
// }
//
// public void setPathTransform(String pathTransform) {
// this.pathTransform = pathTransform;
// }
// }
//
// Path: src/main/java/org/jembi/openhim/RestfulHttpRequest.java
// public static enum Scheme { HTTP, HTTPS }
//
// Path: src/main/java/org/jembi/openhim/exception/DefaultChannelInvalidConfigException.java
// public class DefaultChannelInvalidConfigException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// public DefaultChannelInvalidConfigException() {}
//
// public DefaultChannelInvalidConfigException(String message) {
// super(message);
// }
//
// public DefaultChannelInvalidConfigException(Throwable cause) {
// super(cause);
// }
//
// public DefaultChannelInvalidConfigException(String message, Throwable cause) {
// super(message, cause);
// }
// }
| import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import java.io.IOException;
import org.jembi.openhim.DefaultChannelComponent.URLMapping;
import org.jembi.openhim.RestfulHttpRequest.Scheme;
import org.jembi.openhim.exception.DefaultChannelInvalidConfigException;
import org.junit.Test;
import org.mule.api.MuleMessage;
import org.mule.api.transport.PropertyScope;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException; | package org.jembi.openhim;
public class DefaultChannelComponentTest {
@Test
public void test_findURLMapping_match() throws JsonParseException, JsonMappingException, IOException {
DefaultChannelComponent dcc = new DefaultChannelComponent();
dcc.readMappings();
| // Path: src/main/java/org/jembi/openhim/DefaultChannelComponent.java
// public static class URLMapping {
// private String urlPattern;
// private String host;
// private String port;
// private String username;
// private String password;
// private String authType;
// private String allowUnsecured;
// private String path;
// private String pathTransform;
//
// @Override
// public boolean equals(Object obj) {
// if (!(obj instanceof URLMapping)) {
// return false;
// }
// URLMapping mapping = (URLMapping) obj;
// if (urlPattern.equals(mapping.getUrlPattern())
// && host.equals(mapping.getHost())
// && port.equals(mapping.getPort())) {
//
// return true;
// }
// return false;
// }
//
// public String getAuthType() {
// return authType;
// }
//
// public void setAuthType(String authType) {
// this.authType = authType;
// }
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getUrlPattern() {
// return urlPattern;
// }
//
// public void setUrlPattern(String urlPattern) {
// this.urlPattern = urlPattern;
// }
//
// public String getHost() {
// return host;
// }
//
// public void setHost(String host) {
// this.host = host;
// }
//
// public String getPort() {
// return port;
// }
//
// public void setPort(String port) {
// this.port = port;
// }
//
// public String getAllowUnsecured() {
// return allowUnsecured;
// }
//
// public void setAllowUnsecured(String allowUnsecured) {
// this.allowUnsecured = allowUnsecured;
// }
//
// public String getPath() {
// return path;
// }
//
// public void setPath(String path) {
// this.path = path;
// }
//
// public String getPathTransform() {
// return pathTransform;
// }
//
// public void setPathTransform(String pathTransform) {
// this.pathTransform = pathTransform;
// }
// }
//
// Path: src/main/java/org/jembi/openhim/RestfulHttpRequest.java
// public static enum Scheme { HTTP, HTTPS }
//
// Path: src/main/java/org/jembi/openhim/exception/DefaultChannelInvalidConfigException.java
// public class DefaultChannelInvalidConfigException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// public DefaultChannelInvalidConfigException() {}
//
// public DefaultChannelInvalidConfigException(String message) {
// super(message);
// }
//
// public DefaultChannelInvalidConfigException(Throwable cause) {
// super(cause);
// }
//
// public DefaultChannelInvalidConfigException(String message, Throwable cause) {
// super(message, cause);
// }
// }
// Path: src/test/java/org/jembi/openhim/DefaultChannelComponentTest.java
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import java.io.IOException;
import org.jembi.openhim.DefaultChannelComponent.URLMapping;
import org.jembi.openhim.RestfulHttpRequest.Scheme;
import org.jembi.openhim.exception.DefaultChannelInvalidConfigException;
import org.junit.Test;
import org.mule.api.MuleMessage;
import org.mule.api.transport.PropertyScope;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
package org.jembi.openhim;
public class DefaultChannelComponentTest {
@Test
public void test_findURLMapping_match() throws JsonParseException, JsonMappingException, IOException {
DefaultChannelComponent dcc = new DefaultChannelComponent();
dcc.readMappings();
| URLMapping mapping = dcc.findURLMapping(Scheme.HTTPS, "test/sample/123"); |
jembi/openhim-legacy | src/test/java/org/jembi/openhim/DefaultChannelComponentTest.java | // Path: src/main/java/org/jembi/openhim/DefaultChannelComponent.java
// public static class URLMapping {
// private String urlPattern;
// private String host;
// private String port;
// private String username;
// private String password;
// private String authType;
// private String allowUnsecured;
// private String path;
// private String pathTransform;
//
// @Override
// public boolean equals(Object obj) {
// if (!(obj instanceof URLMapping)) {
// return false;
// }
// URLMapping mapping = (URLMapping) obj;
// if (urlPattern.equals(mapping.getUrlPattern())
// && host.equals(mapping.getHost())
// && port.equals(mapping.getPort())) {
//
// return true;
// }
// return false;
// }
//
// public String getAuthType() {
// return authType;
// }
//
// public void setAuthType(String authType) {
// this.authType = authType;
// }
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getUrlPattern() {
// return urlPattern;
// }
//
// public void setUrlPattern(String urlPattern) {
// this.urlPattern = urlPattern;
// }
//
// public String getHost() {
// return host;
// }
//
// public void setHost(String host) {
// this.host = host;
// }
//
// public String getPort() {
// return port;
// }
//
// public void setPort(String port) {
// this.port = port;
// }
//
// public String getAllowUnsecured() {
// return allowUnsecured;
// }
//
// public void setAllowUnsecured(String allowUnsecured) {
// this.allowUnsecured = allowUnsecured;
// }
//
// public String getPath() {
// return path;
// }
//
// public void setPath(String path) {
// this.path = path;
// }
//
// public String getPathTransform() {
// return pathTransform;
// }
//
// public void setPathTransform(String pathTransform) {
// this.pathTransform = pathTransform;
// }
// }
//
// Path: src/main/java/org/jembi/openhim/RestfulHttpRequest.java
// public static enum Scheme { HTTP, HTTPS }
//
// Path: src/main/java/org/jembi/openhim/exception/DefaultChannelInvalidConfigException.java
// public class DefaultChannelInvalidConfigException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// public DefaultChannelInvalidConfigException() {}
//
// public DefaultChannelInvalidConfigException(String message) {
// super(message);
// }
//
// public DefaultChannelInvalidConfigException(Throwable cause) {
// super(cause);
// }
//
// public DefaultChannelInvalidConfigException(String message, Throwable cause) {
// super(message, cause);
// }
// }
| import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import java.io.IOException;
import org.jembi.openhim.DefaultChannelComponent.URLMapping;
import org.jembi.openhim.RestfulHttpRequest.Scheme;
import org.jembi.openhim.exception.DefaultChannelInvalidConfigException;
import org.junit.Test;
import org.mule.api.MuleMessage;
import org.mule.api.transport.PropertyScope;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException; | package org.jembi.openhim;
public class DefaultChannelComponentTest {
@Test
public void test_findURLMapping_match() throws JsonParseException, JsonMappingException, IOException {
DefaultChannelComponent dcc = new DefaultChannelComponent();
dcc.readMappings();
| // Path: src/main/java/org/jembi/openhim/DefaultChannelComponent.java
// public static class URLMapping {
// private String urlPattern;
// private String host;
// private String port;
// private String username;
// private String password;
// private String authType;
// private String allowUnsecured;
// private String path;
// private String pathTransform;
//
// @Override
// public boolean equals(Object obj) {
// if (!(obj instanceof URLMapping)) {
// return false;
// }
// URLMapping mapping = (URLMapping) obj;
// if (urlPattern.equals(mapping.getUrlPattern())
// && host.equals(mapping.getHost())
// && port.equals(mapping.getPort())) {
//
// return true;
// }
// return false;
// }
//
// public String getAuthType() {
// return authType;
// }
//
// public void setAuthType(String authType) {
// this.authType = authType;
// }
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getUrlPattern() {
// return urlPattern;
// }
//
// public void setUrlPattern(String urlPattern) {
// this.urlPattern = urlPattern;
// }
//
// public String getHost() {
// return host;
// }
//
// public void setHost(String host) {
// this.host = host;
// }
//
// public String getPort() {
// return port;
// }
//
// public void setPort(String port) {
// this.port = port;
// }
//
// public String getAllowUnsecured() {
// return allowUnsecured;
// }
//
// public void setAllowUnsecured(String allowUnsecured) {
// this.allowUnsecured = allowUnsecured;
// }
//
// public String getPath() {
// return path;
// }
//
// public void setPath(String path) {
// this.path = path;
// }
//
// public String getPathTransform() {
// return pathTransform;
// }
//
// public void setPathTransform(String pathTransform) {
// this.pathTransform = pathTransform;
// }
// }
//
// Path: src/main/java/org/jembi/openhim/RestfulHttpRequest.java
// public static enum Scheme { HTTP, HTTPS }
//
// Path: src/main/java/org/jembi/openhim/exception/DefaultChannelInvalidConfigException.java
// public class DefaultChannelInvalidConfigException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// public DefaultChannelInvalidConfigException() {}
//
// public DefaultChannelInvalidConfigException(String message) {
// super(message);
// }
//
// public DefaultChannelInvalidConfigException(Throwable cause) {
// super(cause);
// }
//
// public DefaultChannelInvalidConfigException(String message, Throwable cause) {
// super(message, cause);
// }
// }
// Path: src/test/java/org/jembi/openhim/DefaultChannelComponentTest.java
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import java.io.IOException;
import org.jembi.openhim.DefaultChannelComponent.URLMapping;
import org.jembi.openhim.RestfulHttpRequest.Scheme;
import org.jembi.openhim.exception.DefaultChannelInvalidConfigException;
import org.junit.Test;
import org.mule.api.MuleMessage;
import org.mule.api.transport.PropertyScope;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
package org.jembi.openhim;
public class DefaultChannelComponentTest {
@Test
public void test_findURLMapping_match() throws JsonParseException, JsonMappingException, IOException {
DefaultChannelComponent dcc = new DefaultChannelComponent();
dcc.readMappings();
| URLMapping mapping = dcc.findURLMapping(Scheme.HTTPS, "test/sample/123"); |
jembi/openhim-legacy | src/test/java/org/jembi/openhim/DefaultChannelComponentTest.java | // Path: src/main/java/org/jembi/openhim/DefaultChannelComponent.java
// public static class URLMapping {
// private String urlPattern;
// private String host;
// private String port;
// private String username;
// private String password;
// private String authType;
// private String allowUnsecured;
// private String path;
// private String pathTransform;
//
// @Override
// public boolean equals(Object obj) {
// if (!(obj instanceof URLMapping)) {
// return false;
// }
// URLMapping mapping = (URLMapping) obj;
// if (urlPattern.equals(mapping.getUrlPattern())
// && host.equals(mapping.getHost())
// && port.equals(mapping.getPort())) {
//
// return true;
// }
// return false;
// }
//
// public String getAuthType() {
// return authType;
// }
//
// public void setAuthType(String authType) {
// this.authType = authType;
// }
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getUrlPattern() {
// return urlPattern;
// }
//
// public void setUrlPattern(String urlPattern) {
// this.urlPattern = urlPattern;
// }
//
// public String getHost() {
// return host;
// }
//
// public void setHost(String host) {
// this.host = host;
// }
//
// public String getPort() {
// return port;
// }
//
// public void setPort(String port) {
// this.port = port;
// }
//
// public String getAllowUnsecured() {
// return allowUnsecured;
// }
//
// public void setAllowUnsecured(String allowUnsecured) {
// this.allowUnsecured = allowUnsecured;
// }
//
// public String getPath() {
// return path;
// }
//
// public void setPath(String path) {
// this.path = path;
// }
//
// public String getPathTransform() {
// return pathTransform;
// }
//
// public void setPathTransform(String pathTransform) {
// this.pathTransform = pathTransform;
// }
// }
//
// Path: src/main/java/org/jembi/openhim/RestfulHttpRequest.java
// public static enum Scheme { HTTP, HTTPS }
//
// Path: src/main/java/org/jembi/openhim/exception/DefaultChannelInvalidConfigException.java
// public class DefaultChannelInvalidConfigException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// public DefaultChannelInvalidConfigException() {}
//
// public DefaultChannelInvalidConfigException(String message) {
// super(message);
// }
//
// public DefaultChannelInvalidConfigException(Throwable cause) {
// super(cause);
// }
//
// public DefaultChannelInvalidConfigException(String message, Throwable cause) {
// super(message, cause);
// }
// }
| import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import java.io.IOException;
import org.jembi.openhim.DefaultChannelComponent.URLMapping;
import org.jembi.openhim.RestfulHttpRequest.Scheme;
import org.jembi.openhim.exception.DefaultChannelInvalidConfigException;
import org.junit.Test;
import org.mule.api.MuleMessage;
import org.mule.api.transport.PropertyScope;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException; | @Test
public void test_findUnsecureURLMapping_match() throws JsonParseException, JsonMappingException, IOException {
DefaultChannelComponent dcc = new DefaultChannelComponent();
dcc.readMappings();
URLMapping mapping = dcc.findURLMapping(Scheme.HTTP, "test/unsecure");
assertNotNull(mapping);
assertEquals("localhost", mapping.getHost());
assertEquals("8080", mapping.getPort());
URLMapping mapping2 = dcc.findURLMapping(Scheme.HTTP, "test/unsecure2");
assertNotNull(mapping2);
assertEquals("localhost", mapping2.getHost());
assertEquals("8080", mapping2.getPort());
}
@Test
public void test_shouldNotFindUnallowed() throws JsonParseException, JsonMappingException, IOException {
DefaultChannelComponent dcc = new DefaultChannelComponent();
dcc.readMappings();
URLMapping mapping = dcc.findURLMapping(Scheme.HTTP, "test/secure");
assertEquals(null, mapping);
//secure by default
URLMapping mapping2 = dcc.findURLMapping(Scheme.HTTP, "test/sample/123");
assertEquals(null, mapping2);
}
@Test | // Path: src/main/java/org/jembi/openhim/DefaultChannelComponent.java
// public static class URLMapping {
// private String urlPattern;
// private String host;
// private String port;
// private String username;
// private String password;
// private String authType;
// private String allowUnsecured;
// private String path;
// private String pathTransform;
//
// @Override
// public boolean equals(Object obj) {
// if (!(obj instanceof URLMapping)) {
// return false;
// }
// URLMapping mapping = (URLMapping) obj;
// if (urlPattern.equals(mapping.getUrlPattern())
// && host.equals(mapping.getHost())
// && port.equals(mapping.getPort())) {
//
// return true;
// }
// return false;
// }
//
// public String getAuthType() {
// return authType;
// }
//
// public void setAuthType(String authType) {
// this.authType = authType;
// }
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getUrlPattern() {
// return urlPattern;
// }
//
// public void setUrlPattern(String urlPattern) {
// this.urlPattern = urlPattern;
// }
//
// public String getHost() {
// return host;
// }
//
// public void setHost(String host) {
// this.host = host;
// }
//
// public String getPort() {
// return port;
// }
//
// public void setPort(String port) {
// this.port = port;
// }
//
// public String getAllowUnsecured() {
// return allowUnsecured;
// }
//
// public void setAllowUnsecured(String allowUnsecured) {
// this.allowUnsecured = allowUnsecured;
// }
//
// public String getPath() {
// return path;
// }
//
// public void setPath(String path) {
// this.path = path;
// }
//
// public String getPathTransform() {
// return pathTransform;
// }
//
// public void setPathTransform(String pathTransform) {
// this.pathTransform = pathTransform;
// }
// }
//
// Path: src/main/java/org/jembi/openhim/RestfulHttpRequest.java
// public static enum Scheme { HTTP, HTTPS }
//
// Path: src/main/java/org/jembi/openhim/exception/DefaultChannelInvalidConfigException.java
// public class DefaultChannelInvalidConfigException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// public DefaultChannelInvalidConfigException() {}
//
// public DefaultChannelInvalidConfigException(String message) {
// super(message);
// }
//
// public DefaultChannelInvalidConfigException(Throwable cause) {
// super(cause);
// }
//
// public DefaultChannelInvalidConfigException(String message, Throwable cause) {
// super(message, cause);
// }
// }
// Path: src/test/java/org/jembi/openhim/DefaultChannelComponentTest.java
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import java.io.IOException;
import org.jembi.openhim.DefaultChannelComponent.URLMapping;
import org.jembi.openhim.RestfulHttpRequest.Scheme;
import org.jembi.openhim.exception.DefaultChannelInvalidConfigException;
import org.junit.Test;
import org.mule.api.MuleMessage;
import org.mule.api.transport.PropertyScope;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
@Test
public void test_findUnsecureURLMapping_match() throws JsonParseException, JsonMappingException, IOException {
DefaultChannelComponent dcc = new DefaultChannelComponent();
dcc.readMappings();
URLMapping mapping = dcc.findURLMapping(Scheme.HTTP, "test/unsecure");
assertNotNull(mapping);
assertEquals("localhost", mapping.getHost());
assertEquals("8080", mapping.getPort());
URLMapping mapping2 = dcc.findURLMapping(Scheme.HTTP, "test/unsecure2");
assertNotNull(mapping2);
assertEquals("localhost", mapping2.getHost());
assertEquals("8080", mapping2.getPort());
}
@Test
public void test_shouldNotFindUnallowed() throws JsonParseException, JsonMappingException, IOException {
DefaultChannelComponent dcc = new DefaultChannelComponent();
dcc.readMappings();
URLMapping mapping = dcc.findURLMapping(Scheme.HTTP, "test/secure");
assertEquals(null, mapping);
//secure by default
URLMapping mapping2 = dcc.findURLMapping(Scheme.HTTP, "test/sample/123");
assertEquals(null, mapping2);
}
@Test | public void test_pathRedirection_pathConstant() throws DefaultChannelInvalidConfigException, JsonParseException, JsonMappingException, IOException { |
jembi/openhim-legacy | src/main/java/org/jembi/openhim/DefaultChannelComponent.java | // Path: src/main/java/org/jembi/openhim/RestfulHttpRequest.java
// public static enum Scheme { HTTP, HTTPS }
//
// Path: src/main/java/org/jembi/openhim/exception/DefaultChannelInvalidConfigException.java
// public class DefaultChannelInvalidConfigException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// public DefaultChannelInvalidConfigException() {}
//
// public DefaultChannelInvalidConfigException(String message) {
// super(message);
// }
//
// public DefaultChannelInvalidConfigException(Throwable cause) {
// super(cause);
// }
//
// public DefaultChannelInvalidConfigException(String message, Throwable cause) {
// super(message, cause);
// }
// }
| import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jembi.openhim.RestfulHttpRequest.Scheme;
import org.jembi.openhim.exception.DefaultChannelInvalidConfigException;
import org.jembi.openhim.exception.URLMappingNotFoundException;
import org.mule.api.MuleEventContext;
import org.mule.api.MuleMessage;
import org.mule.api.lifecycle.Callable;
import org.mule.api.transport.PropertyScope;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.codec.binary.Base64; | package org.jembi.openhim;
public class DefaultChannelComponent implements Callable {
protected static List<URLMapping> mappings = new ArrayList<URLMapping>();
private static final String MAPPING_FILE = "/defaultchannel-mapping.json";
private static final String HTTP_AUTH_TYPE_BASIC = "basic";
@Override
public Object onCall(MuleEventContext eventContext) throws Exception {
if (mappings.size() < 1) {
readMappings();
}
MuleMessage msg = eventContext.getMessage();
RestfulHttpRequest req = (RestfulHttpRequest) msg.getPayload();
String actualPath = req.getPath();
URLMapping mapping = findURLMapping(req.getScheme(), actualPath);
if (mapping == null) {
throw new URLMappingNotFoundException("A URL mapping was not found for the URL: " + req.getPath());
}
setMessagePropertiesFromMapping(req, msg, mapping);
return msg;
}
| // Path: src/main/java/org/jembi/openhim/RestfulHttpRequest.java
// public static enum Scheme { HTTP, HTTPS }
//
// Path: src/main/java/org/jembi/openhim/exception/DefaultChannelInvalidConfigException.java
// public class DefaultChannelInvalidConfigException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// public DefaultChannelInvalidConfigException() {}
//
// public DefaultChannelInvalidConfigException(String message) {
// super(message);
// }
//
// public DefaultChannelInvalidConfigException(Throwable cause) {
// super(cause);
// }
//
// public DefaultChannelInvalidConfigException(String message, Throwable cause) {
// super(message, cause);
// }
// }
// Path: src/main/java/org/jembi/openhim/DefaultChannelComponent.java
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jembi.openhim.RestfulHttpRequest.Scheme;
import org.jembi.openhim.exception.DefaultChannelInvalidConfigException;
import org.jembi.openhim.exception.URLMappingNotFoundException;
import org.mule.api.MuleEventContext;
import org.mule.api.MuleMessage;
import org.mule.api.lifecycle.Callable;
import org.mule.api.transport.PropertyScope;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.codec.binary.Base64;
package org.jembi.openhim;
public class DefaultChannelComponent implements Callable {
protected static List<URLMapping> mappings = new ArrayList<URLMapping>();
private static final String MAPPING_FILE = "/defaultchannel-mapping.json";
private static final String HTTP_AUTH_TYPE_BASIC = "basic";
@Override
public Object onCall(MuleEventContext eventContext) throws Exception {
if (mappings.size() < 1) {
readMappings();
}
MuleMessage msg = eventContext.getMessage();
RestfulHttpRequest req = (RestfulHttpRequest) msg.getPayload();
String actualPath = req.getPath();
URLMapping mapping = findURLMapping(req.getScheme(), actualPath);
if (mapping == null) {
throw new URLMappingNotFoundException("A URL mapping was not found for the URL: " + req.getPath());
}
setMessagePropertiesFromMapping(req, msg, mapping);
return msg;
}
| protected void setMessagePropertiesFromMapping(RestfulHttpRequest request, MuleMessage msg, URLMapping mapping) throws DefaultChannelInvalidConfigException { |
jembi/openhim-legacy | src/main/java/org/jembi/openhim/DefaultChannelComponent.java | // Path: src/main/java/org/jembi/openhim/RestfulHttpRequest.java
// public static enum Scheme { HTTP, HTTPS }
//
// Path: src/main/java/org/jembi/openhim/exception/DefaultChannelInvalidConfigException.java
// public class DefaultChannelInvalidConfigException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// public DefaultChannelInvalidConfigException() {}
//
// public DefaultChannelInvalidConfigException(String message) {
// super(message);
// }
//
// public DefaultChannelInvalidConfigException(Throwable cause) {
// super(cause);
// }
//
// public DefaultChannelInvalidConfigException(String message, Throwable cause) {
// super(message, cause);
// }
// }
| import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jembi.openhim.RestfulHttpRequest.Scheme;
import org.jembi.openhim.exception.DefaultChannelInvalidConfigException;
import org.jembi.openhim.exception.URLMappingNotFoundException;
import org.mule.api.MuleEventContext;
import org.mule.api.MuleMessage;
import org.mule.api.lifecycle.Callable;
import org.mule.api.transport.PropertyScope;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.codec.binary.Base64; | }
String path = null;
if (mapping.getPathTransform()!=null) {
path = transformPath(request.getPath(), mapping.getPathTransform());
} else {
path = mapping.getPath();
}
request.setPath(path);
}
private String transformPath(String path, String sPattern) throws DefaultChannelInvalidConfigException {
//replace all \/'s with a temporary ~ so that we don't split on those
String pattern = sPattern.replaceAll("\\\\/", "~");
String[] sub = pattern.split("/");
if (sub.length<2 || !sub[0].equals("s")) {
throw new DefaultChannelInvalidConfigException("Malformed pathTransform expression. Expected \"s/from/to\"");
}
String from = sub[1].replaceAll("~", "/");
String to = (sub.length>2) ? sub[2] : "";
to = to.replaceAll("~", "/");
return path.replaceAll(from, to);
}
| // Path: src/main/java/org/jembi/openhim/RestfulHttpRequest.java
// public static enum Scheme { HTTP, HTTPS }
//
// Path: src/main/java/org/jembi/openhim/exception/DefaultChannelInvalidConfigException.java
// public class DefaultChannelInvalidConfigException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// public DefaultChannelInvalidConfigException() {}
//
// public DefaultChannelInvalidConfigException(String message) {
// super(message);
// }
//
// public DefaultChannelInvalidConfigException(Throwable cause) {
// super(cause);
// }
//
// public DefaultChannelInvalidConfigException(String message, Throwable cause) {
// super(message, cause);
// }
// }
// Path: src/main/java/org/jembi/openhim/DefaultChannelComponent.java
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jembi.openhim.RestfulHttpRequest.Scheme;
import org.jembi.openhim.exception.DefaultChannelInvalidConfigException;
import org.jembi.openhim.exception.URLMappingNotFoundException;
import org.mule.api.MuleEventContext;
import org.mule.api.MuleMessage;
import org.mule.api.lifecycle.Callable;
import org.mule.api.transport.PropertyScope;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.codec.binary.Base64;
}
String path = null;
if (mapping.getPathTransform()!=null) {
path = transformPath(request.getPath(), mapping.getPathTransform());
} else {
path = mapping.getPath();
}
request.setPath(path);
}
private String transformPath(String path, String sPattern) throws DefaultChannelInvalidConfigException {
//replace all \/'s with a temporary ~ so that we don't split on those
String pattern = sPattern.replaceAll("\\\\/", "~");
String[] sub = pattern.split("/");
if (sub.length<2 || !sub[0].equals("s")) {
throw new DefaultChannelInvalidConfigException("Malformed pathTransform expression. Expected \"s/from/to\"");
}
String from = sub[1].replaceAll("~", "/");
String to = (sub.length>2) ? sub[2] : "";
to = to.replaceAll("~", "/");
return path.replaceAll(from, to);
}
| protected URLMapping findURLMapping(Scheme scheme, String actualPath) { |
jembi/openhim-legacy | src/test/java/org/jembi/openhim/transformers/HttpResponseToRestfulHttpResponseTransformerTest.java | // Path: src/main/java/org/jembi/openhim/RestfulHttpResponse.java
// public class RestfulHttpResponse implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private String uuid = UUID.randomUUID().toString();
//
// private RestfulHttpRequest originalRequest;
//
// private int httpStatus;
// private String body;
// private Map<String, Object> httpHeaders = new HashMap<String, Object>();
//
// public String getUuid() {
// return uuid;
// }
//
// public void setUuid(String uuid) {
// this.uuid = uuid;
// }
//
// public RestfulHttpRequest getOriginalRequest() {
// return originalRequest;
// }
//
// public void setOriginalRequest(RestfulHttpRequest originalRequest) {
// this.originalRequest = originalRequest;
// }
//
// public int getHttpStatus() {
// return httpStatus;
// }
//
// public void setHttpStatus(int httpStatus) {
// this.httpStatus = httpStatus;
// }
//
// public String getBody() {
// return body;
// }
//
// public void setBody(String body) {
// this.body = body;
// }
//
// @Override
// public String toString () {
// StringBuffer sb = new StringBuffer();
//
// sb.append("RestfulHttpResponse {\n");
// sb.append(" httpStatus: " + httpStatus + "\n");
// sb.append(" body: " + body + "\n");
//
// if (httpHeaders == null || httpHeaders.size() < 1) {
// sb.append(" httpHeaders: null\n");
// } else {
// sb.append(" httpHeaders: [\n");
// for (Object key : httpHeaders.keySet()) {
// Object value = httpHeaders.get(key);
// sb.append(" " + key + ": " + value + "\n");
// }
// sb.append(" ]");
// }
//
// sb.append("}");
//
// return sb.toString();
// }
//
// public Map<String, Object> getHttpHeaders() {
// return httpHeaders;
// }
//
// public void setHttpHeaders(Map<String, Object> httpHeaders) {
// this.httpHeaders = httpHeaders;
// }
//
// }
//
// Path: src/main/java/org/jembi/openhim/transformers/HttpResponseToRestfulHttpResponseTransformer.java
// public class HttpResponseToRestfulHttpResponseTransformer extends
// AbstractMessageTransformer {
//
// @Override
// public Object transformMessage(MuleMessage msg, String enc) throws TransformerException {
//
// RestfulHttpResponse restRes = new RestfulHttpResponse();
//
// try {
// int status = Integer.valueOf((String) msg.getProperty("http.status", PropertyScope.INBOUND));
// restRes.setHttpStatus(status);
// String body = msg.getPayloadAsString();
// restRes.setBody(body);
// String uuid = msg.getProperty("uuid", PropertyScope.SESSION);
// restRes.setUuid(uuid);
// restRes.setHttpHeaders((Map<String, Object>) msg.getProperty("http.headers", PropertyScope.INBOUND));
// } catch (Exception e) {
// throw new TransformerException(this, e);
// }
//
// return restRes;
// }
//
// }
| import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.HashMap;
import java.util.Map;
import org.jembi.openhim.RestfulHttpResponse;
import org.jembi.openhim.transformers.HttpResponseToRestfulHttpResponseTransformer;
import org.junit.Test;
import org.mule.api.MuleMessage;
import org.mule.api.transformer.TransformerException;
import org.mule.api.transport.PropertyScope; |
}
/**
* Test transformMessage method with null uuid
*/
@Test
public void testTransformMessageMuleMessageString_nullUUID() throws Exception {
excecuteTestCase("200", "Test Response", null, sampleHttpHeaders);
}
/**
* Test transformMessage method with null status code
*/
@Test
public void testTransformMessageMuleMessageString_nullStatusCode() throws Exception {
try {
excecuteTestCase(null, "Test Response", "d72ea800-beea-11e2-9e96-0800200c9a66", sampleHttpHeaders);
} catch (TransformerException e) {
// this is supposed to happen
}
}
private void excecuteTestCase(String httpStatus, String body, String uuid, Map<String, String> httpHeaders)
throws Exception, TransformerException {
setupMocks(httpStatus, body, uuid, httpHeaders); | // Path: src/main/java/org/jembi/openhim/RestfulHttpResponse.java
// public class RestfulHttpResponse implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private String uuid = UUID.randomUUID().toString();
//
// private RestfulHttpRequest originalRequest;
//
// private int httpStatus;
// private String body;
// private Map<String, Object> httpHeaders = new HashMap<String, Object>();
//
// public String getUuid() {
// return uuid;
// }
//
// public void setUuid(String uuid) {
// this.uuid = uuid;
// }
//
// public RestfulHttpRequest getOriginalRequest() {
// return originalRequest;
// }
//
// public void setOriginalRequest(RestfulHttpRequest originalRequest) {
// this.originalRequest = originalRequest;
// }
//
// public int getHttpStatus() {
// return httpStatus;
// }
//
// public void setHttpStatus(int httpStatus) {
// this.httpStatus = httpStatus;
// }
//
// public String getBody() {
// return body;
// }
//
// public void setBody(String body) {
// this.body = body;
// }
//
// @Override
// public String toString () {
// StringBuffer sb = new StringBuffer();
//
// sb.append("RestfulHttpResponse {\n");
// sb.append(" httpStatus: " + httpStatus + "\n");
// sb.append(" body: " + body + "\n");
//
// if (httpHeaders == null || httpHeaders.size() < 1) {
// sb.append(" httpHeaders: null\n");
// } else {
// sb.append(" httpHeaders: [\n");
// for (Object key : httpHeaders.keySet()) {
// Object value = httpHeaders.get(key);
// sb.append(" " + key + ": " + value + "\n");
// }
// sb.append(" ]");
// }
//
// sb.append("}");
//
// return sb.toString();
// }
//
// public Map<String, Object> getHttpHeaders() {
// return httpHeaders;
// }
//
// public void setHttpHeaders(Map<String, Object> httpHeaders) {
// this.httpHeaders = httpHeaders;
// }
//
// }
//
// Path: src/main/java/org/jembi/openhim/transformers/HttpResponseToRestfulHttpResponseTransformer.java
// public class HttpResponseToRestfulHttpResponseTransformer extends
// AbstractMessageTransformer {
//
// @Override
// public Object transformMessage(MuleMessage msg, String enc) throws TransformerException {
//
// RestfulHttpResponse restRes = new RestfulHttpResponse();
//
// try {
// int status = Integer.valueOf((String) msg.getProperty("http.status", PropertyScope.INBOUND));
// restRes.setHttpStatus(status);
// String body = msg.getPayloadAsString();
// restRes.setBody(body);
// String uuid = msg.getProperty("uuid", PropertyScope.SESSION);
// restRes.setUuid(uuid);
// restRes.setHttpHeaders((Map<String, Object>) msg.getProperty("http.headers", PropertyScope.INBOUND));
// } catch (Exception e) {
// throw new TransformerException(this, e);
// }
//
// return restRes;
// }
//
// }
// Path: src/test/java/org/jembi/openhim/transformers/HttpResponseToRestfulHttpResponseTransformerTest.java
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.HashMap;
import java.util.Map;
import org.jembi.openhim.RestfulHttpResponse;
import org.jembi.openhim.transformers.HttpResponseToRestfulHttpResponseTransformer;
import org.junit.Test;
import org.mule.api.MuleMessage;
import org.mule.api.transformer.TransformerException;
import org.mule.api.transport.PropertyScope;
}
/**
* Test transformMessage method with null uuid
*/
@Test
public void testTransformMessageMuleMessageString_nullUUID() throws Exception {
excecuteTestCase("200", "Test Response", null, sampleHttpHeaders);
}
/**
* Test transformMessage method with null status code
*/
@Test
public void testTransformMessageMuleMessageString_nullStatusCode() throws Exception {
try {
excecuteTestCase(null, "Test Response", "d72ea800-beea-11e2-9e96-0800200c9a66", sampleHttpHeaders);
} catch (TransformerException e) {
// this is supposed to happen
}
}
private void excecuteTestCase(String httpStatus, String body, String uuid, Map<String, String> httpHeaders)
throws Exception, TransformerException {
setupMocks(httpStatus, body, uuid, httpHeaders); | HttpResponseToRestfulHttpResponseTransformer trans = new HttpResponseToRestfulHttpResponseTransformer(); |
jembi/openhim-legacy | src/test/java/org/jembi/openhim/transformers/HttpResponseToRestfulHttpResponseTransformerTest.java | // Path: src/main/java/org/jembi/openhim/RestfulHttpResponse.java
// public class RestfulHttpResponse implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private String uuid = UUID.randomUUID().toString();
//
// private RestfulHttpRequest originalRequest;
//
// private int httpStatus;
// private String body;
// private Map<String, Object> httpHeaders = new HashMap<String, Object>();
//
// public String getUuid() {
// return uuid;
// }
//
// public void setUuid(String uuid) {
// this.uuid = uuid;
// }
//
// public RestfulHttpRequest getOriginalRequest() {
// return originalRequest;
// }
//
// public void setOriginalRequest(RestfulHttpRequest originalRequest) {
// this.originalRequest = originalRequest;
// }
//
// public int getHttpStatus() {
// return httpStatus;
// }
//
// public void setHttpStatus(int httpStatus) {
// this.httpStatus = httpStatus;
// }
//
// public String getBody() {
// return body;
// }
//
// public void setBody(String body) {
// this.body = body;
// }
//
// @Override
// public String toString () {
// StringBuffer sb = new StringBuffer();
//
// sb.append("RestfulHttpResponse {\n");
// sb.append(" httpStatus: " + httpStatus + "\n");
// sb.append(" body: " + body + "\n");
//
// if (httpHeaders == null || httpHeaders.size() < 1) {
// sb.append(" httpHeaders: null\n");
// } else {
// sb.append(" httpHeaders: [\n");
// for (Object key : httpHeaders.keySet()) {
// Object value = httpHeaders.get(key);
// sb.append(" " + key + ": " + value + "\n");
// }
// sb.append(" ]");
// }
//
// sb.append("}");
//
// return sb.toString();
// }
//
// public Map<String, Object> getHttpHeaders() {
// return httpHeaders;
// }
//
// public void setHttpHeaders(Map<String, Object> httpHeaders) {
// this.httpHeaders = httpHeaders;
// }
//
// }
//
// Path: src/main/java/org/jembi/openhim/transformers/HttpResponseToRestfulHttpResponseTransformer.java
// public class HttpResponseToRestfulHttpResponseTransformer extends
// AbstractMessageTransformer {
//
// @Override
// public Object transformMessage(MuleMessage msg, String enc) throws TransformerException {
//
// RestfulHttpResponse restRes = new RestfulHttpResponse();
//
// try {
// int status = Integer.valueOf((String) msg.getProperty("http.status", PropertyScope.INBOUND));
// restRes.setHttpStatus(status);
// String body = msg.getPayloadAsString();
// restRes.setBody(body);
// String uuid = msg.getProperty("uuid", PropertyScope.SESSION);
// restRes.setUuid(uuid);
// restRes.setHttpHeaders((Map<String, Object>) msg.getProperty("http.headers", PropertyScope.INBOUND));
// } catch (Exception e) {
// throw new TransformerException(this, e);
// }
//
// return restRes;
// }
//
// }
| import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.HashMap;
import java.util.Map;
import org.jembi.openhim.RestfulHttpResponse;
import org.jembi.openhim.transformers.HttpResponseToRestfulHttpResponseTransformer;
import org.junit.Test;
import org.mule.api.MuleMessage;
import org.mule.api.transformer.TransformerException;
import org.mule.api.transport.PropertyScope; | }
/**
* Test transformMessage method with null uuid
*/
@Test
public void testTransformMessageMuleMessageString_nullUUID() throws Exception {
excecuteTestCase("200", "Test Response", null, sampleHttpHeaders);
}
/**
* Test transformMessage method with null status code
*/
@Test
public void testTransformMessageMuleMessageString_nullStatusCode() throws Exception {
try {
excecuteTestCase(null, "Test Response", "d72ea800-beea-11e2-9e96-0800200c9a66", sampleHttpHeaders);
} catch (TransformerException e) {
// this is supposed to happen
}
}
private void excecuteTestCase(String httpStatus, String body, String uuid, Map<String, String> httpHeaders)
throws Exception, TransformerException {
setupMocks(httpStatus, body, uuid, httpHeaders);
HttpResponseToRestfulHttpResponseTransformer trans = new HttpResponseToRestfulHttpResponseTransformer(); | // Path: src/main/java/org/jembi/openhim/RestfulHttpResponse.java
// public class RestfulHttpResponse implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private String uuid = UUID.randomUUID().toString();
//
// private RestfulHttpRequest originalRequest;
//
// private int httpStatus;
// private String body;
// private Map<String, Object> httpHeaders = new HashMap<String, Object>();
//
// public String getUuid() {
// return uuid;
// }
//
// public void setUuid(String uuid) {
// this.uuid = uuid;
// }
//
// public RestfulHttpRequest getOriginalRequest() {
// return originalRequest;
// }
//
// public void setOriginalRequest(RestfulHttpRequest originalRequest) {
// this.originalRequest = originalRequest;
// }
//
// public int getHttpStatus() {
// return httpStatus;
// }
//
// public void setHttpStatus(int httpStatus) {
// this.httpStatus = httpStatus;
// }
//
// public String getBody() {
// return body;
// }
//
// public void setBody(String body) {
// this.body = body;
// }
//
// @Override
// public String toString () {
// StringBuffer sb = new StringBuffer();
//
// sb.append("RestfulHttpResponse {\n");
// sb.append(" httpStatus: " + httpStatus + "\n");
// sb.append(" body: " + body + "\n");
//
// if (httpHeaders == null || httpHeaders.size() < 1) {
// sb.append(" httpHeaders: null\n");
// } else {
// sb.append(" httpHeaders: [\n");
// for (Object key : httpHeaders.keySet()) {
// Object value = httpHeaders.get(key);
// sb.append(" " + key + ": " + value + "\n");
// }
// sb.append(" ]");
// }
//
// sb.append("}");
//
// return sb.toString();
// }
//
// public Map<String, Object> getHttpHeaders() {
// return httpHeaders;
// }
//
// public void setHttpHeaders(Map<String, Object> httpHeaders) {
// this.httpHeaders = httpHeaders;
// }
//
// }
//
// Path: src/main/java/org/jembi/openhim/transformers/HttpResponseToRestfulHttpResponseTransformer.java
// public class HttpResponseToRestfulHttpResponseTransformer extends
// AbstractMessageTransformer {
//
// @Override
// public Object transformMessage(MuleMessage msg, String enc) throws TransformerException {
//
// RestfulHttpResponse restRes = new RestfulHttpResponse();
//
// try {
// int status = Integer.valueOf((String) msg.getProperty("http.status", PropertyScope.INBOUND));
// restRes.setHttpStatus(status);
// String body = msg.getPayloadAsString();
// restRes.setBody(body);
// String uuid = msg.getProperty("uuid", PropertyScope.SESSION);
// restRes.setUuid(uuid);
// restRes.setHttpHeaders((Map<String, Object>) msg.getProperty("http.headers", PropertyScope.INBOUND));
// } catch (Exception e) {
// throw new TransformerException(this, e);
// }
//
// return restRes;
// }
//
// }
// Path: src/test/java/org/jembi/openhim/transformers/HttpResponseToRestfulHttpResponseTransformerTest.java
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.HashMap;
import java.util.Map;
import org.jembi.openhim.RestfulHttpResponse;
import org.jembi.openhim.transformers.HttpResponseToRestfulHttpResponseTransformer;
import org.junit.Test;
import org.mule.api.MuleMessage;
import org.mule.api.transformer.TransformerException;
import org.mule.api.transport.PropertyScope;
}
/**
* Test transformMessage method with null uuid
*/
@Test
public void testTransformMessageMuleMessageString_nullUUID() throws Exception {
excecuteTestCase("200", "Test Response", null, sampleHttpHeaders);
}
/**
* Test transformMessage method with null status code
*/
@Test
public void testTransformMessageMuleMessageString_nullStatusCode() throws Exception {
try {
excecuteTestCase(null, "Test Response", "d72ea800-beea-11e2-9e96-0800200c9a66", sampleHttpHeaders);
} catch (TransformerException e) {
// this is supposed to happen
}
}
private void excecuteTestCase(String httpStatus, String body, String uuid, Map<String, String> httpHeaders)
throws Exception, TransformerException {
setupMocks(httpStatus, body, uuid, httpHeaders);
HttpResponseToRestfulHttpResponseTransformer trans = new HttpResponseToRestfulHttpResponseTransformer(); | RestfulHttpResponse res = (RestfulHttpResponse) trans.transformMessage(msg, "UTF-8"); |
jembi/openhim-legacy | src/main/java/org/jembi/openhim/transformers/HttpResponseToRestfulHttpResponseTransformer.java | // Path: src/main/java/org/jembi/openhim/RestfulHttpResponse.java
// public class RestfulHttpResponse implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private String uuid = UUID.randomUUID().toString();
//
// private RestfulHttpRequest originalRequest;
//
// private int httpStatus;
// private String body;
// private Map<String, Object> httpHeaders = new HashMap<String, Object>();
//
// public String getUuid() {
// return uuid;
// }
//
// public void setUuid(String uuid) {
// this.uuid = uuid;
// }
//
// public RestfulHttpRequest getOriginalRequest() {
// return originalRequest;
// }
//
// public void setOriginalRequest(RestfulHttpRequest originalRequest) {
// this.originalRequest = originalRequest;
// }
//
// public int getHttpStatus() {
// return httpStatus;
// }
//
// public void setHttpStatus(int httpStatus) {
// this.httpStatus = httpStatus;
// }
//
// public String getBody() {
// return body;
// }
//
// public void setBody(String body) {
// this.body = body;
// }
//
// @Override
// public String toString () {
// StringBuffer sb = new StringBuffer();
//
// sb.append("RestfulHttpResponse {\n");
// sb.append(" httpStatus: " + httpStatus + "\n");
// sb.append(" body: " + body + "\n");
//
// if (httpHeaders == null || httpHeaders.size() < 1) {
// sb.append(" httpHeaders: null\n");
// } else {
// sb.append(" httpHeaders: [\n");
// for (Object key : httpHeaders.keySet()) {
// Object value = httpHeaders.get(key);
// sb.append(" " + key + ": " + value + "\n");
// }
// sb.append(" ]");
// }
//
// sb.append("}");
//
// return sb.toString();
// }
//
// public Map<String, Object> getHttpHeaders() {
// return httpHeaders;
// }
//
// public void setHttpHeaders(Map<String, Object> httpHeaders) {
// this.httpHeaders = httpHeaders;
// }
//
// }
| import java.util.Map;
import org.jembi.openhim.RestfulHttpResponse;
import org.mule.api.MuleMessage;
import org.mule.api.transformer.TransformerException;
import org.mule.api.transport.PropertyScope;
import org.mule.transformer.AbstractMessageTransformer; | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.jembi.openhim.transformers;
public class HttpResponseToRestfulHttpResponseTransformer extends
AbstractMessageTransformer {
@Override
public Object transformMessage(MuleMessage msg, String enc) throws TransformerException {
| // Path: src/main/java/org/jembi/openhim/RestfulHttpResponse.java
// public class RestfulHttpResponse implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private String uuid = UUID.randomUUID().toString();
//
// private RestfulHttpRequest originalRequest;
//
// private int httpStatus;
// private String body;
// private Map<String, Object> httpHeaders = new HashMap<String, Object>();
//
// public String getUuid() {
// return uuid;
// }
//
// public void setUuid(String uuid) {
// this.uuid = uuid;
// }
//
// public RestfulHttpRequest getOriginalRequest() {
// return originalRequest;
// }
//
// public void setOriginalRequest(RestfulHttpRequest originalRequest) {
// this.originalRequest = originalRequest;
// }
//
// public int getHttpStatus() {
// return httpStatus;
// }
//
// public void setHttpStatus(int httpStatus) {
// this.httpStatus = httpStatus;
// }
//
// public String getBody() {
// return body;
// }
//
// public void setBody(String body) {
// this.body = body;
// }
//
// @Override
// public String toString () {
// StringBuffer sb = new StringBuffer();
//
// sb.append("RestfulHttpResponse {\n");
// sb.append(" httpStatus: " + httpStatus + "\n");
// sb.append(" body: " + body + "\n");
//
// if (httpHeaders == null || httpHeaders.size() < 1) {
// sb.append(" httpHeaders: null\n");
// } else {
// sb.append(" httpHeaders: [\n");
// for (Object key : httpHeaders.keySet()) {
// Object value = httpHeaders.get(key);
// sb.append(" " + key + ": " + value + "\n");
// }
// sb.append(" ]");
// }
//
// sb.append("}");
//
// return sb.toString();
// }
//
// public Map<String, Object> getHttpHeaders() {
// return httpHeaders;
// }
//
// public void setHttpHeaders(Map<String, Object> httpHeaders) {
// this.httpHeaders = httpHeaders;
// }
//
// }
// Path: src/main/java/org/jembi/openhim/transformers/HttpResponseToRestfulHttpResponseTransformer.java
import java.util.Map;
import org.jembi.openhim.RestfulHttpResponse;
import org.mule.api.MuleMessage;
import org.mule.api.transformer.TransformerException;
import org.mule.api.transport.PropertyScope;
import org.mule.transformer.AbstractMessageTransformer;
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.jembi.openhim.transformers;
public class HttpResponseToRestfulHttpResponseTransformer extends
AbstractMessageTransformer {
@Override
public Object transformMessage(MuleMessage msg, String enc) throws TransformerException {
| RestfulHttpResponse restRes = new RestfulHttpResponse(); |
idega/is.idega.idegaweb.egov.citizen | src/java/is/idega/idegaweb/egov/citizen/business/AccountBusiness.java | // Path: src/java/is/idega/idegaweb/egov/citizen/data/AccountApplication.java
// public interface AccountApplication extends com.idega.block.process.data.Case
// {
// public void setEmail(java.lang.String p0);
// public java.lang.String getEmail();
// public void setApplicantName(java.lang.String p0);
// public java.lang.String getApplicantName();
// }
| import is.idega.idegaweb.egov.citizen.data.AccountApplication;
import is.idega.idegaweb.egov.message.business.CommuneMessageBusiness; | package is.idega.idegaweb.egov.citizen.business;
public interface AccountBusiness extends com.idega.business.IBOService {
public void acceptApplication(int p0, com.idega.user.data.User p1, boolean p2) throws java.rmi.RemoteException, javax.ejb.CreateException;
public void acceptApplication(int p0, com.idega.user.data.User p1, boolean p2, boolean p3, boolean p4, boolean p5) throws java.rmi.RemoteException, javax.ejb.CreateException;
| // Path: src/java/is/idega/idegaweb/egov/citizen/data/AccountApplication.java
// public interface AccountApplication extends com.idega.block.process.data.Case
// {
// public void setEmail(java.lang.String p0);
// public java.lang.String getEmail();
// public void setApplicantName(java.lang.String p0);
// public java.lang.String getApplicantName();
// }
// Path: src/java/is/idega/idegaweb/egov/citizen/business/AccountBusiness.java
import is.idega.idegaweb.egov.citizen.data.AccountApplication;
import is.idega.idegaweb.egov.message.business.CommuneMessageBusiness;
package is.idega.idegaweb.egov.citizen.business;
public interface AccountBusiness extends com.idega.business.IBOService {
public void acceptApplication(int p0, com.idega.user.data.User p1, boolean p2) throws java.rmi.RemoteException, javax.ejb.CreateException;
public void acceptApplication(int p0, com.idega.user.data.User p1, boolean p2, boolean p3, boolean p4, boolean p5) throws java.rmi.RemoteException, javax.ejb.CreateException;
| public java.lang.String getAcceptMessageSubject(AccountApplication theCase) throws java.rmi.RemoteException; |
idega/is.idega.idegaweb.egov.citizen | src/java/is/idega/idegaweb/egov/citizen/presentation/CitizenMessages.java | // Path: src/java/is/idega/idegaweb/egov/citizen/CitizenConstants.java
// public class CitizenConstants {
// public static final String IW_BUNDLE_IDENTIFIER = "is.idega.idegaweb.egov.citizen";
// public static final String NEEDED_SCRIPT_AND_STYLE_FILES = "needed_script_and_style_files";
// public static final String False = "false";
// // User edit parameters
// public static final String USER_EDIT_NAME_PARAMETER = "user-edit-name-parameter";
// public static final String USER_EDIT_BORN_PARAMETER = "user-edit-born-parameter";
// public static final String USER_EDIT_STREET_AND_NUMBER_PARAMETER = "user-edit-street-and-number-parameter";
// public static final String USER_EDIT_CITY_PARAMETER = "user-edit-city-parameter";
// public static final String USER_EDIT_POSTAL_CODE_PARAMETER = "user-edit-postal-code-parameter",
// USER_EDIT_POSTAL_BOX_PARAMETER = "user-edit-postal-box-parameter";
// public static final String USER_EDIT_COUNTRY_PARAMETER = "user-edit-country-parameter";
// public static final String USER_EDIT_MARITAL_STATUS_PARAMETER = "user-edit-marital-status-parameter";
// public static final String USER_EDIT_FAMILY_PARAMETER = "user-edit-family-parameter";
// public static final String USER_EDIT_RESUME_PARAMETER = "user-edit-resume-parameter";
// public static final String USER_EDIT_USER_ID_PARAMETER = "user-edit-id-parameter";
// public static final String USER_EDIT_PERSONAL_ID_PARAMETER = "user-edit-personal-id-parameter";
// public static final String USER_EDIT_USERNAME_PARAMETER = "user-edit-username-parameter";
// public static final String USER_EDIT_PASSWORD_PARAMETER = "user-edit-password-parameter";
// public static final String USER_EDIT_LANGUAGE_PARAMETER = "user-edit-language-parameter";
//
// }
| import is.idega.idegaweb.egov.citizen.CitizenConstants;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.context.FacesContext;
import com.idega.block.web2.business.JQuery;
import com.idega.block.web2.business.Web2Business;
import com.idega.facelets.ui.FaceletComponent;
import com.idega.idegaweb.IWBundle;
import com.idega.idegaweb.IWMainApplication;
import com.idega.idegaweb.IWResourceBundle;
import com.idega.presentation.IWBaseComponent;
import com.idega.presentation.IWContext;
import com.idega.presentation.Layer;
import com.idega.util.CoreConstants;
import com.idega.util.PresentationUtil;
import com.idega.webface.WFUtil; | package is.idega.idegaweb.egov.citizen.presentation;
public class CitizenMessages extends IWBaseComponent{
@Override
protected void initializeComponent(FacesContext context) {
super.initializeComponent(context);
IWContext iwc = IWContext.getIWContext(context); | // Path: src/java/is/idega/idegaweb/egov/citizen/CitizenConstants.java
// public class CitizenConstants {
// public static final String IW_BUNDLE_IDENTIFIER = "is.idega.idegaweb.egov.citizen";
// public static final String NEEDED_SCRIPT_AND_STYLE_FILES = "needed_script_and_style_files";
// public static final String False = "false";
// // User edit parameters
// public static final String USER_EDIT_NAME_PARAMETER = "user-edit-name-parameter";
// public static final String USER_EDIT_BORN_PARAMETER = "user-edit-born-parameter";
// public static final String USER_EDIT_STREET_AND_NUMBER_PARAMETER = "user-edit-street-and-number-parameter";
// public static final String USER_EDIT_CITY_PARAMETER = "user-edit-city-parameter";
// public static final String USER_EDIT_POSTAL_CODE_PARAMETER = "user-edit-postal-code-parameter",
// USER_EDIT_POSTAL_BOX_PARAMETER = "user-edit-postal-box-parameter";
// public static final String USER_EDIT_COUNTRY_PARAMETER = "user-edit-country-parameter";
// public static final String USER_EDIT_MARITAL_STATUS_PARAMETER = "user-edit-marital-status-parameter";
// public static final String USER_EDIT_FAMILY_PARAMETER = "user-edit-family-parameter";
// public static final String USER_EDIT_RESUME_PARAMETER = "user-edit-resume-parameter";
// public static final String USER_EDIT_USER_ID_PARAMETER = "user-edit-id-parameter";
// public static final String USER_EDIT_PERSONAL_ID_PARAMETER = "user-edit-personal-id-parameter";
// public static final String USER_EDIT_USERNAME_PARAMETER = "user-edit-username-parameter";
// public static final String USER_EDIT_PASSWORD_PARAMETER = "user-edit-password-parameter";
// public static final String USER_EDIT_LANGUAGE_PARAMETER = "user-edit-language-parameter";
//
// }
// Path: src/java/is/idega/idegaweb/egov/citizen/presentation/CitizenMessages.java
import is.idega.idegaweb.egov.citizen.CitizenConstants;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.context.FacesContext;
import com.idega.block.web2.business.JQuery;
import com.idega.block.web2.business.Web2Business;
import com.idega.facelets.ui.FaceletComponent;
import com.idega.idegaweb.IWBundle;
import com.idega.idegaweb.IWMainApplication;
import com.idega.idegaweb.IWResourceBundle;
import com.idega.presentation.IWBaseComponent;
import com.idega.presentation.IWContext;
import com.idega.presentation.Layer;
import com.idega.util.CoreConstants;
import com.idega.util.PresentationUtil;
import com.idega.webface.WFUtil;
package is.idega.idegaweb.egov.citizen.presentation;
public class CitizenMessages extends IWBaseComponent{
@Override
protected void initializeComponent(FacesContext context) {
super.initializeComponent(context);
IWContext iwc = IWContext.getIWContext(context); | IWBundle bundle = iwc.getIWMainApplication().getBundle(CitizenConstants.IW_BUNDLE_IDENTIFIER); |
idega/is.idega.idegaweb.egov.citizen | src/java/is/idega/idegaweb/egov/citizen/presentation/CitizenAccountApplication.java | // Path: src/java/is/idega/idegaweb/egov/citizen/business/WSCitizenAccountBusiness.java
// public interface WSCitizenAccountBusiness extends IBOService,
// CitizenAccountBusiness, CallbackHandler {
// /**
// * @see is.idega.idegaweb.egov.citizen.business.WSCitizenAccountBusinessBean#changePasswordAndSendLetterOrEmail
// */
// public void changePasswordAndSendLetterOrEmail(IWUserContext iwuc,
// LoginTable loginTable, User user, String newPassword,
// boolean sendLetter) throws CreateException, RemoteException;
//
// /**
// * @see is.idega.idegaweb.egov.citizen.business.WSCitizenAccountBusinessBean#handle
// */
// public void handle(Callback[] callbacks)
// throws UnsupportedCallbackException, RemoteException;
//
// /**
// * @see is.idega.idegaweb.egov.citizen.business.WSCitizenAccountBusinessBean#sendMessageToBank
// */
// public boolean sendMessageToBank() throws RemoteException;
//
// /**
// * @see is.idega.idegaweb.egov.citizen.business.WSCitizenAccountBusinessBean#sendLostPasswordMessage
// */
// public void sendLostPasswordMessage(User citizen, String login,
// String password) throws RemoteException, CreateException,
// RemoteException;
//
// /**
// * @see is.idega.idegaweb.egov.citizen.business.WSCitizenAccountBusinessBean#getAcceptMessageSubject
// */
// public String getAcceptMessageSubject(User owner) throws RemoteException;
// }
| import is.idega.idegaweb.egov.citizen.business.WSCitizenAccountBusiness;
import java.io.IOException;
import java.rmi.RemoteException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import com.idega.business.IBOLookup;
import com.idega.core.accesscontrol.business.UserHasLoginException;
import com.idega.core.accesscontrol.data.LoginTable;
import com.idega.core.accesscontrol.data.LoginTableHome;
import com.idega.core.builder.data.ICPage;
import com.idega.core.localisation.presentation.LocalePresentationUtil;
import com.idega.core.location.data.Address;
import com.idega.core.location.data.Commune;
import com.idega.data.IDOLookup;
import com.idega.idegaweb.IWApplicationContext;
import com.idega.idegaweb.IWResourceBundle;
import com.idega.presentation.ExceptionWrapper;
import com.idega.presentation.IWContext;
import com.idega.presentation.Layer;
import com.idega.presentation.Span;
import com.idega.presentation.text.Heading1;
import com.idega.presentation.text.Link;
import com.idega.presentation.text.Text;
import com.idega.presentation.ui.CheckBox;
import com.idega.presentation.ui.DropdownMenu;
import com.idega.presentation.ui.Form;
import com.idega.presentation.ui.HiddenInput;
import com.idega.presentation.ui.Label;
import com.idega.presentation.ui.TextInput;
import com.idega.user.business.UserBusiness;
import com.idega.user.data.User;
import com.idega.util.Age;
import com.idega.util.IWTimestamp;
import com.idega.util.text.SocialSecurityNumber; | } else if (!SocialSecurityNumber.isValidIcelandicSocialSecurityNumber(ssn)) {
errors.add(this.iwrb.getLocalizedString("not_a_valid_personal_id", "The personal ID you've entered is not valid."));
hasErrors = true;
}
if (!isValidAge(iwc, ssn)) {
Object[] arguments = { iwc.getApplicationSettings().getProperty(ATTRIBUTE_VALID_ACCOUNT_AGE, String.valueOf(18)) };
errors.add(MessageFormat.format(this.iwrb.getLocalizedString(NOT_VALID_ACCOUNT_AGE_KEY, NOT_VALID_ACCOUNT_AGE_DEFAULT), arguments));
hasErrors = true;
}
String email = iwc.getParameter(EMAIL_KEY);
if (email == null || email.length() == 0) {
errors.add(this.iwrb.getLocalizedString("email_can_not_be_empty", "You must provide a valid e-mail address"));
hasErrors = true;
}
boolean agreementAccepted = iwc.getParameter(APP_AGREEMENT_PARAM) != null && iwc.getParameter(APP_AGREEMENT_PARAM).length() > 0;
if (!agreementAccepted) {
errors.add(this.iwrb.getLocalizedString(APP_AGREEMENT_NOTAGREED_KEY, APP_AGREEMENT_NOTAGREED_DEFAULT));
hasErrors = true;
}
boolean sendSnailMail = iwc.getParameter(SNAIL_MAIL_KEY) != null && iwc.getParameter(SNAIL_MAIL_KEY).length() > 0;
String emailRepeat = iwc.getParameter(EMAIL_KEY_REPEAT);
String phoneHome = iwc.getParameter(PHONE_HOME_KEY);
String phoneWork = iwc.getParameter(PHONE_CELL_KEY);
String preferredLocale = iwc.getParameter(PARAMETER_PREFERRED_LOCALE);
| // Path: src/java/is/idega/idegaweb/egov/citizen/business/WSCitizenAccountBusiness.java
// public interface WSCitizenAccountBusiness extends IBOService,
// CitizenAccountBusiness, CallbackHandler {
// /**
// * @see is.idega.idegaweb.egov.citizen.business.WSCitizenAccountBusinessBean#changePasswordAndSendLetterOrEmail
// */
// public void changePasswordAndSendLetterOrEmail(IWUserContext iwuc,
// LoginTable loginTable, User user, String newPassword,
// boolean sendLetter) throws CreateException, RemoteException;
//
// /**
// * @see is.idega.idegaweb.egov.citizen.business.WSCitizenAccountBusinessBean#handle
// */
// public void handle(Callback[] callbacks)
// throws UnsupportedCallbackException, RemoteException;
//
// /**
// * @see is.idega.idegaweb.egov.citizen.business.WSCitizenAccountBusinessBean#sendMessageToBank
// */
// public boolean sendMessageToBank() throws RemoteException;
//
// /**
// * @see is.idega.idegaweb.egov.citizen.business.WSCitizenAccountBusinessBean#sendLostPasswordMessage
// */
// public void sendLostPasswordMessage(User citizen, String login,
// String password) throws RemoteException, CreateException,
// RemoteException;
//
// /**
// * @see is.idega.idegaweb.egov.citizen.business.WSCitizenAccountBusinessBean#getAcceptMessageSubject
// */
// public String getAcceptMessageSubject(User owner) throws RemoteException;
// }
// Path: src/java/is/idega/idegaweb/egov/citizen/presentation/CitizenAccountApplication.java
import is.idega.idegaweb.egov.citizen.business.WSCitizenAccountBusiness;
import java.io.IOException;
import java.rmi.RemoteException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import com.idega.business.IBOLookup;
import com.idega.core.accesscontrol.business.UserHasLoginException;
import com.idega.core.accesscontrol.data.LoginTable;
import com.idega.core.accesscontrol.data.LoginTableHome;
import com.idega.core.builder.data.ICPage;
import com.idega.core.localisation.presentation.LocalePresentationUtil;
import com.idega.core.location.data.Address;
import com.idega.core.location.data.Commune;
import com.idega.data.IDOLookup;
import com.idega.idegaweb.IWApplicationContext;
import com.idega.idegaweb.IWResourceBundle;
import com.idega.presentation.ExceptionWrapper;
import com.idega.presentation.IWContext;
import com.idega.presentation.Layer;
import com.idega.presentation.Span;
import com.idega.presentation.text.Heading1;
import com.idega.presentation.text.Link;
import com.idega.presentation.text.Text;
import com.idega.presentation.ui.CheckBox;
import com.idega.presentation.ui.DropdownMenu;
import com.idega.presentation.ui.Form;
import com.idega.presentation.ui.HiddenInput;
import com.idega.presentation.ui.Label;
import com.idega.presentation.ui.TextInput;
import com.idega.user.business.UserBusiness;
import com.idega.user.data.User;
import com.idega.util.Age;
import com.idega.util.IWTimestamp;
import com.idega.util.text.SocialSecurityNumber;
} else if (!SocialSecurityNumber.isValidIcelandicSocialSecurityNumber(ssn)) {
errors.add(this.iwrb.getLocalizedString("not_a_valid_personal_id", "The personal ID you've entered is not valid."));
hasErrors = true;
}
if (!isValidAge(iwc, ssn)) {
Object[] arguments = { iwc.getApplicationSettings().getProperty(ATTRIBUTE_VALID_ACCOUNT_AGE, String.valueOf(18)) };
errors.add(MessageFormat.format(this.iwrb.getLocalizedString(NOT_VALID_ACCOUNT_AGE_KEY, NOT_VALID_ACCOUNT_AGE_DEFAULT), arguments));
hasErrors = true;
}
String email = iwc.getParameter(EMAIL_KEY);
if (email == null || email.length() == 0) {
errors.add(this.iwrb.getLocalizedString("email_can_not_be_empty", "You must provide a valid e-mail address"));
hasErrors = true;
}
boolean agreementAccepted = iwc.getParameter(APP_AGREEMENT_PARAM) != null && iwc.getParameter(APP_AGREEMENT_PARAM).length() > 0;
if (!agreementAccepted) {
errors.add(this.iwrb.getLocalizedString(APP_AGREEMENT_NOTAGREED_KEY, APP_AGREEMENT_NOTAGREED_DEFAULT));
hasErrors = true;
}
boolean sendSnailMail = iwc.getParameter(SNAIL_MAIL_KEY) != null && iwc.getParameter(SNAIL_MAIL_KEY).length() > 0;
String emailRepeat = iwc.getParameter(EMAIL_KEY_REPEAT);
String phoneHome = iwc.getParameter(PHONE_HOME_KEY);
String phoneWork = iwc.getParameter(PHONE_CELL_KEY);
String preferredLocale = iwc.getParameter(PARAMETER_PREFERRED_LOCALE);
| WSCitizenAccountBusiness business = getBusiness(iwc); |
idega/is.idega.idegaweb.egov.citizen | src/java/is/idega/idegaweb/egov/citizen/business/CitizenAccountBusinessBean.java | // Path: src/java/is/idega/idegaweb/egov/citizen/data/AccountApplication.java
// public interface AccountApplication extends com.idega.block.process.data.Case
// {
// public void setEmail(java.lang.String p0);
// public java.lang.String getEmail();
// public void setApplicantName(java.lang.String p0);
// public java.lang.String getApplicantName();
// }
//
// Path: src/java/is/idega/idegaweb/egov/citizen/data/CitizenAccount.java
// public interface CitizenAccount extends IDOEntity, AccountApplication, Case {
//
// String getCaseCodeDescription();
//
// String getCaseCodeKey();
//
// String getApplicantName();
//
// String getSsn();
//
// String getEmail();
//
// String getPhoneHome();
//
// String getPhoneWork();
//
// String getCareOf();
//
// String getStreet();
//
// String getZipCode();
//
// String getCity();
//
// String getCivilStatus();
//
// boolean hasCohabitant();
//
// int getChildrenCount();
//
// String getApplicationReason();
//
// void setApplicantName(String name);
//
// void setSsn(String ssn);
//
// void setEmail(String email);
//
// void setPhoneHome(String phoneHome);
//
// void setPhoneWork(String phoneWork);
//
// void setCareOf(String careOf);
//
// void setStreet(String street);
//
// void setZipCode(String zipCode);
//
// void setCity(String city);
//
// void setCivilStatus(String civilStatus);
//
// void setHasCohabitant(boolean hasCohabitant);
//
// void setChildrenCount(int childrenCount);
//
// void setApplicationReason(String applicationReason);
// }
//
// Path: src/java/is/idega/idegaweb/egov/citizen/data/CitizenAccountHome.java
// public interface CitizenAccountHome extends IDOHome {
//
// public CitizenAccount create() throws javax.ejb.CreateException;
//
// public CitizenAccount findByPrimaryKey(Object pk) throws javax.ejb.FinderException;
//
// /**
// * @see se.idega.idegaweb.commune.account.citizen.data.CitizenAccountBMPBean#ejbFindAllCasesByStatus
// */
// public Collection findAllCasesByStatus(CaseStatus caseStatus) throws FinderException;
//
// /**
// * @see se.idega.idegaweb.commune.account.citizen.data.CitizenAccountBMPBean#ejbFindAllCasesByStatus
// */
// public Collection findAllCasesByStatus(String caseStatus) throws FinderException;
//
// /**
// * @see se.idega.idegaweb.commune.account.citizen.data.CitizenAccountBMPBean#ejbHomeGetTotalCount
// */
// public int getTotalCount() throws IDOException;
//
// /**
// * @see se.idega.idegaweb.commune.account.citizen.data.CitizenAccountBMPBean#ejbHomeGetCount
// */
// public int getCount(String personalID, String status) throws IDOException;
// }
| import is.idega.idegaweb.egov.citizen.data.AccountApplication;
import is.idega.idegaweb.egov.citizen.data.CitizenAccount;
import is.idega.idegaweb.egov.citizen.data.CitizenAccountHome;
import is.idega.idegaweb.egov.message.business.CommuneMessageBusiness;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.FinderException;
import javax.transaction.SystemException;
import javax.transaction.UserTransaction;
import com.idega.business.IBORuntimeException;
import com.idega.core.accesscontrol.business.UserHasLoginException;
import com.idega.core.accesscontrol.data.LoginInfo;
import com.idega.core.accesscontrol.data.LoginInfoHome;
import com.idega.core.accesscontrol.data.LoginTable;
import com.idega.data.IDOException;
import com.idega.data.IDOLookup;
import com.idega.data.IDOLookupException;
import com.idega.idegaweb.IWResourceBundle;
import com.idega.idegaweb.IWUserContext;
import com.idega.presentation.IWContext;
import com.idega.user.data.User;
import com.idega.user.data.UserHome;
import com.idega.util.CoreConstants;
import com.idega.util.CoreUtil;
import com.idega.util.Encrypter;
import com.idega.util.StringHandler;
import com.idega.util.StringUtil; | /*
* $Id$ Copyright (C) 2002 Idega hf. All Rights Reserved. This software is
* the proprietary information of Idega hf. Use is subject to license terms.
*/
package is.idega.idegaweb.egov.citizen.business;
/**
* Last modified: $Date$ by $Author$
*
* @author <a href="mail:[email protected]">Pall Helgason </a>
* @author <a href="http://www.staffannoteberg.com">Staffan N?teberg </a>
* @version $Revision$
*/
public class CitizenAccountBusinessBean extends AccountApplicationBusinessBean implements CitizenAccountBusiness, AccountBusiness {
/**
* Comment for <code>serialVersionUID</code>
*/
private static final long serialVersionUID = -8304259532337909367L;
private boolean acceptApplicationOnCreation = true;
| // Path: src/java/is/idega/idegaweb/egov/citizen/data/AccountApplication.java
// public interface AccountApplication extends com.idega.block.process.data.Case
// {
// public void setEmail(java.lang.String p0);
// public java.lang.String getEmail();
// public void setApplicantName(java.lang.String p0);
// public java.lang.String getApplicantName();
// }
//
// Path: src/java/is/idega/idegaweb/egov/citizen/data/CitizenAccount.java
// public interface CitizenAccount extends IDOEntity, AccountApplication, Case {
//
// String getCaseCodeDescription();
//
// String getCaseCodeKey();
//
// String getApplicantName();
//
// String getSsn();
//
// String getEmail();
//
// String getPhoneHome();
//
// String getPhoneWork();
//
// String getCareOf();
//
// String getStreet();
//
// String getZipCode();
//
// String getCity();
//
// String getCivilStatus();
//
// boolean hasCohabitant();
//
// int getChildrenCount();
//
// String getApplicationReason();
//
// void setApplicantName(String name);
//
// void setSsn(String ssn);
//
// void setEmail(String email);
//
// void setPhoneHome(String phoneHome);
//
// void setPhoneWork(String phoneWork);
//
// void setCareOf(String careOf);
//
// void setStreet(String street);
//
// void setZipCode(String zipCode);
//
// void setCity(String city);
//
// void setCivilStatus(String civilStatus);
//
// void setHasCohabitant(boolean hasCohabitant);
//
// void setChildrenCount(int childrenCount);
//
// void setApplicationReason(String applicationReason);
// }
//
// Path: src/java/is/idega/idegaweb/egov/citizen/data/CitizenAccountHome.java
// public interface CitizenAccountHome extends IDOHome {
//
// public CitizenAccount create() throws javax.ejb.CreateException;
//
// public CitizenAccount findByPrimaryKey(Object pk) throws javax.ejb.FinderException;
//
// /**
// * @see se.idega.idegaweb.commune.account.citizen.data.CitizenAccountBMPBean#ejbFindAllCasesByStatus
// */
// public Collection findAllCasesByStatus(CaseStatus caseStatus) throws FinderException;
//
// /**
// * @see se.idega.idegaweb.commune.account.citizen.data.CitizenAccountBMPBean#ejbFindAllCasesByStatus
// */
// public Collection findAllCasesByStatus(String caseStatus) throws FinderException;
//
// /**
// * @see se.idega.idegaweb.commune.account.citizen.data.CitizenAccountBMPBean#ejbHomeGetTotalCount
// */
// public int getTotalCount() throws IDOException;
//
// /**
// * @see se.idega.idegaweb.commune.account.citizen.data.CitizenAccountBMPBean#ejbHomeGetCount
// */
// public int getCount(String personalID, String status) throws IDOException;
// }
// Path: src/java/is/idega/idegaweb/egov/citizen/business/CitizenAccountBusinessBean.java
import is.idega.idegaweb.egov.citizen.data.AccountApplication;
import is.idega.idegaweb.egov.citizen.data.CitizenAccount;
import is.idega.idegaweb.egov.citizen.data.CitizenAccountHome;
import is.idega.idegaweb.egov.message.business.CommuneMessageBusiness;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.FinderException;
import javax.transaction.SystemException;
import javax.transaction.UserTransaction;
import com.idega.business.IBORuntimeException;
import com.idega.core.accesscontrol.business.UserHasLoginException;
import com.idega.core.accesscontrol.data.LoginInfo;
import com.idega.core.accesscontrol.data.LoginInfoHome;
import com.idega.core.accesscontrol.data.LoginTable;
import com.idega.data.IDOException;
import com.idega.data.IDOLookup;
import com.idega.data.IDOLookupException;
import com.idega.idegaweb.IWResourceBundle;
import com.idega.idegaweb.IWUserContext;
import com.idega.presentation.IWContext;
import com.idega.user.data.User;
import com.idega.user.data.UserHome;
import com.idega.util.CoreConstants;
import com.idega.util.CoreUtil;
import com.idega.util.Encrypter;
import com.idega.util.StringHandler;
import com.idega.util.StringUtil;
/*
* $Id$ Copyright (C) 2002 Idega hf. All Rights Reserved. This software is
* the proprietary information of Idega hf. Use is subject to license terms.
*/
package is.idega.idegaweb.egov.citizen.business;
/**
* Last modified: $Date$ by $Author$
*
* @author <a href="mail:[email protected]">Pall Helgason </a>
* @author <a href="http://www.staffannoteberg.com">Staffan N?teberg </a>
* @version $Revision$
*/
public class CitizenAccountBusinessBean extends AccountApplicationBusinessBean implements CitizenAccountBusiness, AccountBusiness {
/**
* Comment for <code>serialVersionUID</code>
*/
private static final long serialVersionUID = -8304259532337909367L;
private boolean acceptApplicationOnCreation = true;
| protected CitizenAccountHome getCitizenAccountHome() throws RemoteException { |
idega/is.idega.idegaweb.egov.citizen | src/java/is/idega/idegaweb/egov/citizen/business/CitizenAccountBusinessBean.java | // Path: src/java/is/idega/idegaweb/egov/citizen/data/AccountApplication.java
// public interface AccountApplication extends com.idega.block.process.data.Case
// {
// public void setEmail(java.lang.String p0);
// public java.lang.String getEmail();
// public void setApplicantName(java.lang.String p0);
// public java.lang.String getApplicantName();
// }
//
// Path: src/java/is/idega/idegaweb/egov/citizen/data/CitizenAccount.java
// public interface CitizenAccount extends IDOEntity, AccountApplication, Case {
//
// String getCaseCodeDescription();
//
// String getCaseCodeKey();
//
// String getApplicantName();
//
// String getSsn();
//
// String getEmail();
//
// String getPhoneHome();
//
// String getPhoneWork();
//
// String getCareOf();
//
// String getStreet();
//
// String getZipCode();
//
// String getCity();
//
// String getCivilStatus();
//
// boolean hasCohabitant();
//
// int getChildrenCount();
//
// String getApplicationReason();
//
// void setApplicantName(String name);
//
// void setSsn(String ssn);
//
// void setEmail(String email);
//
// void setPhoneHome(String phoneHome);
//
// void setPhoneWork(String phoneWork);
//
// void setCareOf(String careOf);
//
// void setStreet(String street);
//
// void setZipCode(String zipCode);
//
// void setCity(String city);
//
// void setCivilStatus(String civilStatus);
//
// void setHasCohabitant(boolean hasCohabitant);
//
// void setChildrenCount(int childrenCount);
//
// void setApplicationReason(String applicationReason);
// }
//
// Path: src/java/is/idega/idegaweb/egov/citizen/data/CitizenAccountHome.java
// public interface CitizenAccountHome extends IDOHome {
//
// public CitizenAccount create() throws javax.ejb.CreateException;
//
// public CitizenAccount findByPrimaryKey(Object pk) throws javax.ejb.FinderException;
//
// /**
// * @see se.idega.idegaweb.commune.account.citizen.data.CitizenAccountBMPBean#ejbFindAllCasesByStatus
// */
// public Collection findAllCasesByStatus(CaseStatus caseStatus) throws FinderException;
//
// /**
// * @see se.idega.idegaweb.commune.account.citizen.data.CitizenAccountBMPBean#ejbFindAllCasesByStatus
// */
// public Collection findAllCasesByStatus(String caseStatus) throws FinderException;
//
// /**
// * @see se.idega.idegaweb.commune.account.citizen.data.CitizenAccountBMPBean#ejbHomeGetTotalCount
// */
// public int getTotalCount() throws IDOException;
//
// /**
// * @see se.idega.idegaweb.commune.account.citizen.data.CitizenAccountBMPBean#ejbHomeGetCount
// */
// public int getCount(String personalID, String status) throws IDOException;
// }
| import is.idega.idegaweb.egov.citizen.data.AccountApplication;
import is.idega.idegaweb.egov.citizen.data.CitizenAccount;
import is.idega.idegaweb.egov.citizen.data.CitizenAccountHome;
import is.idega.idegaweb.egov.message.business.CommuneMessageBusiness;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.FinderException;
import javax.transaction.SystemException;
import javax.transaction.UserTransaction;
import com.idega.business.IBORuntimeException;
import com.idega.core.accesscontrol.business.UserHasLoginException;
import com.idega.core.accesscontrol.data.LoginInfo;
import com.idega.core.accesscontrol.data.LoginInfoHome;
import com.idega.core.accesscontrol.data.LoginTable;
import com.idega.data.IDOException;
import com.idega.data.IDOLookup;
import com.idega.data.IDOLookupException;
import com.idega.idegaweb.IWResourceBundle;
import com.idega.idegaweb.IWUserContext;
import com.idega.presentation.IWContext;
import com.idega.user.data.User;
import com.idega.user.data.UserHome;
import com.idega.util.CoreConstants;
import com.idega.util.CoreUtil;
import com.idega.util.Encrypter;
import com.idega.util.StringHandler;
import com.idega.util.StringUtil; | /*
* $Id$ Copyright (C) 2002 Idega hf. All Rights Reserved. This software is
* the proprietary information of Idega hf. Use is subject to license terms.
*/
package is.idega.idegaweb.egov.citizen.business;
/**
* Last modified: $Date$ by $Author$
*
* @author <a href="mail:[email protected]">Pall Helgason </a>
* @author <a href="http://www.staffannoteberg.com">Staffan N?teberg </a>
* @version $Revision$
*/
public class CitizenAccountBusinessBean extends AccountApplicationBusinessBean implements CitizenAccountBusiness, AccountBusiness {
/**
* Comment for <code>serialVersionUID</code>
*/
private static final long serialVersionUID = -8304259532337909367L;
private boolean acceptApplicationOnCreation = true;
protected CitizenAccountHome getCitizenAccountHome() throws RemoteException { | // Path: src/java/is/idega/idegaweb/egov/citizen/data/AccountApplication.java
// public interface AccountApplication extends com.idega.block.process.data.Case
// {
// public void setEmail(java.lang.String p0);
// public java.lang.String getEmail();
// public void setApplicantName(java.lang.String p0);
// public java.lang.String getApplicantName();
// }
//
// Path: src/java/is/idega/idegaweb/egov/citizen/data/CitizenAccount.java
// public interface CitizenAccount extends IDOEntity, AccountApplication, Case {
//
// String getCaseCodeDescription();
//
// String getCaseCodeKey();
//
// String getApplicantName();
//
// String getSsn();
//
// String getEmail();
//
// String getPhoneHome();
//
// String getPhoneWork();
//
// String getCareOf();
//
// String getStreet();
//
// String getZipCode();
//
// String getCity();
//
// String getCivilStatus();
//
// boolean hasCohabitant();
//
// int getChildrenCount();
//
// String getApplicationReason();
//
// void setApplicantName(String name);
//
// void setSsn(String ssn);
//
// void setEmail(String email);
//
// void setPhoneHome(String phoneHome);
//
// void setPhoneWork(String phoneWork);
//
// void setCareOf(String careOf);
//
// void setStreet(String street);
//
// void setZipCode(String zipCode);
//
// void setCity(String city);
//
// void setCivilStatus(String civilStatus);
//
// void setHasCohabitant(boolean hasCohabitant);
//
// void setChildrenCount(int childrenCount);
//
// void setApplicationReason(String applicationReason);
// }
//
// Path: src/java/is/idega/idegaweb/egov/citizen/data/CitizenAccountHome.java
// public interface CitizenAccountHome extends IDOHome {
//
// public CitizenAccount create() throws javax.ejb.CreateException;
//
// public CitizenAccount findByPrimaryKey(Object pk) throws javax.ejb.FinderException;
//
// /**
// * @see se.idega.idegaweb.commune.account.citizen.data.CitizenAccountBMPBean#ejbFindAllCasesByStatus
// */
// public Collection findAllCasesByStatus(CaseStatus caseStatus) throws FinderException;
//
// /**
// * @see se.idega.idegaweb.commune.account.citizen.data.CitizenAccountBMPBean#ejbFindAllCasesByStatus
// */
// public Collection findAllCasesByStatus(String caseStatus) throws FinderException;
//
// /**
// * @see se.idega.idegaweb.commune.account.citizen.data.CitizenAccountBMPBean#ejbHomeGetTotalCount
// */
// public int getTotalCount() throws IDOException;
//
// /**
// * @see se.idega.idegaweb.commune.account.citizen.data.CitizenAccountBMPBean#ejbHomeGetCount
// */
// public int getCount(String personalID, String status) throws IDOException;
// }
// Path: src/java/is/idega/idegaweb/egov/citizen/business/CitizenAccountBusinessBean.java
import is.idega.idegaweb.egov.citizen.data.AccountApplication;
import is.idega.idegaweb.egov.citizen.data.CitizenAccount;
import is.idega.idegaweb.egov.citizen.data.CitizenAccountHome;
import is.idega.idegaweb.egov.message.business.CommuneMessageBusiness;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.FinderException;
import javax.transaction.SystemException;
import javax.transaction.UserTransaction;
import com.idega.business.IBORuntimeException;
import com.idega.core.accesscontrol.business.UserHasLoginException;
import com.idega.core.accesscontrol.data.LoginInfo;
import com.idega.core.accesscontrol.data.LoginInfoHome;
import com.idega.core.accesscontrol.data.LoginTable;
import com.idega.data.IDOException;
import com.idega.data.IDOLookup;
import com.idega.data.IDOLookupException;
import com.idega.idegaweb.IWResourceBundle;
import com.idega.idegaweb.IWUserContext;
import com.idega.presentation.IWContext;
import com.idega.user.data.User;
import com.idega.user.data.UserHome;
import com.idega.util.CoreConstants;
import com.idega.util.CoreUtil;
import com.idega.util.Encrypter;
import com.idega.util.StringHandler;
import com.idega.util.StringUtil;
/*
* $Id$ Copyright (C) 2002 Idega hf. All Rights Reserved. This software is
* the proprietary information of Idega hf. Use is subject to license terms.
*/
package is.idega.idegaweb.egov.citizen.business;
/**
* Last modified: $Date$ by $Author$
*
* @author <a href="mail:[email protected]">Pall Helgason </a>
* @author <a href="http://www.staffannoteberg.com">Staffan N?teberg </a>
* @version $Revision$
*/
public class CitizenAccountBusinessBean extends AccountApplicationBusinessBean implements CitizenAccountBusiness, AccountBusiness {
/**
* Comment for <code>serialVersionUID</code>
*/
private static final long serialVersionUID = -8304259532337909367L;
private boolean acceptApplicationOnCreation = true;
protected CitizenAccountHome getCitizenAccountHome() throws RemoteException { | return (CitizenAccountHome) IDOLookup.getHome(CitizenAccount.class); |
idega/is.idega.idegaweb.egov.citizen | src/java/is/idega/idegaweb/egov/citizen/business/CitizenAccountBusinessBean.java | // Path: src/java/is/idega/idegaweb/egov/citizen/data/AccountApplication.java
// public interface AccountApplication extends com.idega.block.process.data.Case
// {
// public void setEmail(java.lang.String p0);
// public java.lang.String getEmail();
// public void setApplicantName(java.lang.String p0);
// public java.lang.String getApplicantName();
// }
//
// Path: src/java/is/idega/idegaweb/egov/citizen/data/CitizenAccount.java
// public interface CitizenAccount extends IDOEntity, AccountApplication, Case {
//
// String getCaseCodeDescription();
//
// String getCaseCodeKey();
//
// String getApplicantName();
//
// String getSsn();
//
// String getEmail();
//
// String getPhoneHome();
//
// String getPhoneWork();
//
// String getCareOf();
//
// String getStreet();
//
// String getZipCode();
//
// String getCity();
//
// String getCivilStatus();
//
// boolean hasCohabitant();
//
// int getChildrenCount();
//
// String getApplicationReason();
//
// void setApplicantName(String name);
//
// void setSsn(String ssn);
//
// void setEmail(String email);
//
// void setPhoneHome(String phoneHome);
//
// void setPhoneWork(String phoneWork);
//
// void setCareOf(String careOf);
//
// void setStreet(String street);
//
// void setZipCode(String zipCode);
//
// void setCity(String city);
//
// void setCivilStatus(String civilStatus);
//
// void setHasCohabitant(boolean hasCohabitant);
//
// void setChildrenCount(int childrenCount);
//
// void setApplicationReason(String applicationReason);
// }
//
// Path: src/java/is/idega/idegaweb/egov/citizen/data/CitizenAccountHome.java
// public interface CitizenAccountHome extends IDOHome {
//
// public CitizenAccount create() throws javax.ejb.CreateException;
//
// public CitizenAccount findByPrimaryKey(Object pk) throws javax.ejb.FinderException;
//
// /**
// * @see se.idega.idegaweb.commune.account.citizen.data.CitizenAccountBMPBean#ejbFindAllCasesByStatus
// */
// public Collection findAllCasesByStatus(CaseStatus caseStatus) throws FinderException;
//
// /**
// * @see se.idega.idegaweb.commune.account.citizen.data.CitizenAccountBMPBean#ejbFindAllCasesByStatus
// */
// public Collection findAllCasesByStatus(String caseStatus) throws FinderException;
//
// /**
// * @see se.idega.idegaweb.commune.account.citizen.data.CitizenAccountBMPBean#ejbHomeGetTotalCount
// */
// public int getTotalCount() throws IDOException;
//
// /**
// * @see se.idega.idegaweb.commune.account.citizen.data.CitizenAccountBMPBean#ejbHomeGetCount
// */
// public int getCount(String personalID, String status) throws IDOException;
// }
| import is.idega.idegaweb.egov.citizen.data.AccountApplication;
import is.idega.idegaweb.egov.citizen.data.CitizenAccount;
import is.idega.idegaweb.egov.citizen.data.CitizenAccountHome;
import is.idega.idegaweb.egov.message.business.CommuneMessageBusiness;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.FinderException;
import javax.transaction.SystemException;
import javax.transaction.UserTransaction;
import com.idega.business.IBORuntimeException;
import com.idega.core.accesscontrol.business.UserHasLoginException;
import com.idega.core.accesscontrol.data.LoginInfo;
import com.idega.core.accesscontrol.data.LoginInfoHome;
import com.idega.core.accesscontrol.data.LoginTable;
import com.idega.data.IDOException;
import com.idega.data.IDOLookup;
import com.idega.data.IDOLookupException;
import com.idega.idegaweb.IWResourceBundle;
import com.idega.idegaweb.IWUserContext;
import com.idega.presentation.IWContext;
import com.idega.user.data.User;
import com.idega.user.data.UserHome;
import com.idega.util.CoreConstants;
import com.idega.util.CoreUtil;
import com.idega.util.Encrypter;
import com.idega.util.StringHandler;
import com.idega.util.StringUtil; | try {
StringBuffer userSsn = new StringBuffer(ssn);
int i = ssn.indexOf('-');
if (i != -1) {
userSsn.deleteCharAt(i);
ssn = userSsn.toString();
}
user = ((UserHome) IDOLookup.getHome(User.class)).findByPersonalID(userSsn.toString());
}
catch (RemoteException e) {
return null;
}
catch (FinderException e) {
if (ssn.length() == 10) {
StringBuffer userSsn = new StringBuffer("20");
userSsn.append(ssn);
try {
user = ((UserHome) IDOLookup.getHome(User.class)).findByPersonalID(userSsn.toString());
}
catch (Exception ex) {
return null;
}
}
}
return user;
}
@Override | // Path: src/java/is/idega/idegaweb/egov/citizen/data/AccountApplication.java
// public interface AccountApplication extends com.idega.block.process.data.Case
// {
// public void setEmail(java.lang.String p0);
// public java.lang.String getEmail();
// public void setApplicantName(java.lang.String p0);
// public java.lang.String getApplicantName();
// }
//
// Path: src/java/is/idega/idegaweb/egov/citizen/data/CitizenAccount.java
// public interface CitizenAccount extends IDOEntity, AccountApplication, Case {
//
// String getCaseCodeDescription();
//
// String getCaseCodeKey();
//
// String getApplicantName();
//
// String getSsn();
//
// String getEmail();
//
// String getPhoneHome();
//
// String getPhoneWork();
//
// String getCareOf();
//
// String getStreet();
//
// String getZipCode();
//
// String getCity();
//
// String getCivilStatus();
//
// boolean hasCohabitant();
//
// int getChildrenCount();
//
// String getApplicationReason();
//
// void setApplicantName(String name);
//
// void setSsn(String ssn);
//
// void setEmail(String email);
//
// void setPhoneHome(String phoneHome);
//
// void setPhoneWork(String phoneWork);
//
// void setCareOf(String careOf);
//
// void setStreet(String street);
//
// void setZipCode(String zipCode);
//
// void setCity(String city);
//
// void setCivilStatus(String civilStatus);
//
// void setHasCohabitant(boolean hasCohabitant);
//
// void setChildrenCount(int childrenCount);
//
// void setApplicationReason(String applicationReason);
// }
//
// Path: src/java/is/idega/idegaweb/egov/citizen/data/CitizenAccountHome.java
// public interface CitizenAccountHome extends IDOHome {
//
// public CitizenAccount create() throws javax.ejb.CreateException;
//
// public CitizenAccount findByPrimaryKey(Object pk) throws javax.ejb.FinderException;
//
// /**
// * @see se.idega.idegaweb.commune.account.citizen.data.CitizenAccountBMPBean#ejbFindAllCasesByStatus
// */
// public Collection findAllCasesByStatus(CaseStatus caseStatus) throws FinderException;
//
// /**
// * @see se.idega.idegaweb.commune.account.citizen.data.CitizenAccountBMPBean#ejbFindAllCasesByStatus
// */
// public Collection findAllCasesByStatus(String caseStatus) throws FinderException;
//
// /**
// * @see se.idega.idegaweb.commune.account.citizen.data.CitizenAccountBMPBean#ejbHomeGetTotalCount
// */
// public int getTotalCount() throws IDOException;
//
// /**
// * @see se.idega.idegaweb.commune.account.citizen.data.CitizenAccountBMPBean#ejbHomeGetCount
// */
// public int getCount(String personalID, String status) throws IDOException;
// }
// Path: src/java/is/idega/idegaweb/egov/citizen/business/CitizenAccountBusinessBean.java
import is.idega.idegaweb.egov.citizen.data.AccountApplication;
import is.idega.idegaweb.egov.citizen.data.CitizenAccount;
import is.idega.idegaweb.egov.citizen.data.CitizenAccountHome;
import is.idega.idegaweb.egov.message.business.CommuneMessageBusiness;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.FinderException;
import javax.transaction.SystemException;
import javax.transaction.UserTransaction;
import com.idega.business.IBORuntimeException;
import com.idega.core.accesscontrol.business.UserHasLoginException;
import com.idega.core.accesscontrol.data.LoginInfo;
import com.idega.core.accesscontrol.data.LoginInfoHome;
import com.idega.core.accesscontrol.data.LoginTable;
import com.idega.data.IDOException;
import com.idega.data.IDOLookup;
import com.idega.data.IDOLookupException;
import com.idega.idegaweb.IWResourceBundle;
import com.idega.idegaweb.IWUserContext;
import com.idega.presentation.IWContext;
import com.idega.user.data.User;
import com.idega.user.data.UserHome;
import com.idega.util.CoreConstants;
import com.idega.util.CoreUtil;
import com.idega.util.Encrypter;
import com.idega.util.StringHandler;
import com.idega.util.StringUtil;
try {
StringBuffer userSsn = new StringBuffer(ssn);
int i = ssn.indexOf('-');
if (i != -1) {
userSsn.deleteCharAt(i);
ssn = userSsn.toString();
}
user = ((UserHome) IDOLookup.getHome(User.class)).findByPersonalID(userSsn.toString());
}
catch (RemoteException e) {
return null;
}
catch (FinderException e) {
if (ssn.length() == 10) {
StringBuffer userSsn = new StringBuffer("20");
userSsn.append(ssn);
try {
user = ((UserHome) IDOLookup.getHome(User.class)).findByPersonalID(userSsn.toString());
}
catch (Exception ex) {
return null;
}
}
}
return user;
}
@Override | protected AccountApplication getApplication(int applicationID) throws FinderException { |
idega/is.idega.idegaweb.egov.citizen | src/java/is/idega/idegaweb/egov/citizen/presentation/CitizenAccountStatistics.java | // Path: src/java/is/idega/idegaweb/egov/citizen/business/CitizenAccountBusiness.java
// public interface CitizenAccountBusiness extends IBOService, AccountBusiness {
//
// public Integer insertApplication(IWContext iwc, User user, String ssn, String email, String phoneHome, String phoneWork, boolean sendEmail, boolean createLoginAndSendLetter, boolean sendSnailMail) throws UserHasLoginException, RemoteException;
//
// /**
// * @see is.idega.idegaweb.egov.citizen.business.CitizenAccountBusinessBean#getUserIcelandic
// */
// public User getUserIcelandic(String ssn) throws RemoteException;
//
// /**
// * @see is.idega.idegaweb.egov.citizen.business.CitizenAccountBusinessBean#acceptApplication
// */
// public void acceptApplication(int applicationID, User performer, boolean createUserMessage, boolean createPasswordMessage, boolean sendEmail, boolean sendSnailMail) throws CreateException, RemoteException;
//
// /**
// * @see is.idega.idegaweb.egov.citizen.business.CitizenAccountBusinessBean#changePasswordAndSendLetterOrEmail
// */
// public void changePasswordAndSendLetterOrEmail(IWUserContext iwuc, LoginTable loginTable, User user, String newPassword, boolean sendLetter) throws CreateException, RemoteException;
//
// /**
// * @see is.idega.idegaweb.egov.citizen.business.CitizenAccountBusinessBean#getNumberOfApplications
// */
// public int getNumberOfApplications() throws RemoteException, RemoteException;
// }
| import is.idega.idegaweb.egov.citizen.business.CitizenAccountBusiness;
import java.rmi.RemoteException;
import com.idega.business.IBOLookup;
import com.idega.business.IBORuntimeException;
import com.idega.idegaweb.IWApplicationContext;
import com.idega.idegaweb.IWResourceBundle;
import com.idega.presentation.IWContext;
import com.idega.presentation.Layer;
import com.idega.presentation.text.Heading1;
import com.idega.presentation.text.Text;
import com.idega.presentation.ui.Label; | /*
* $Id$ Created on Mar 27, 2006
*
* Copyright (C) 2006 Idega Software hf. All Rights Reserved.
*
* This software is the proprietary information of Idega hf. Use is subject to license terms.
*/
package is.idega.idegaweb.egov.citizen.presentation;
public class CitizenAccountStatistics extends CitizenBlock {
public void present(IWContext iwc) {
try {
IWResourceBundle iwrb = getResourceBundle(iwc);
int citizenAccountCount = getCitizenAccountBusiness(iwc).getNumberOfApplications();
Layer section = new Layer(Layer.DIV);
section.setStyleClass("formSection");
section.setStyleClass("statisticsLayer");
add(section);
Heading1 heading = new Heading1(iwrb.getLocalizedString("citizen_account.statistics", "Citizen account statistics"));
section.add(heading);
Layer formItem = new Layer(Layer.DIV);
formItem.setStyleClass("formItem");
Label label = new Label();
label.add(new Text(iwrb.getLocalizedString("citizen_account.number_of_accounts", "Number of accounts")));
Layer span = new Layer(Layer.SPAN);
span.add(String.valueOf(citizenAccountCount));
formItem.add(label);
formItem.add(span);
section.add(formItem);
Layer clearLayer = new Layer(Layer.DIV);
clearLayer.setStyleClass("Clear");
section.add(clearLayer);
}
catch (RemoteException re) {
throw new IBORuntimeException(re);
}
}
| // Path: src/java/is/idega/idegaweb/egov/citizen/business/CitizenAccountBusiness.java
// public interface CitizenAccountBusiness extends IBOService, AccountBusiness {
//
// public Integer insertApplication(IWContext iwc, User user, String ssn, String email, String phoneHome, String phoneWork, boolean sendEmail, boolean createLoginAndSendLetter, boolean sendSnailMail) throws UserHasLoginException, RemoteException;
//
// /**
// * @see is.idega.idegaweb.egov.citizen.business.CitizenAccountBusinessBean#getUserIcelandic
// */
// public User getUserIcelandic(String ssn) throws RemoteException;
//
// /**
// * @see is.idega.idegaweb.egov.citizen.business.CitizenAccountBusinessBean#acceptApplication
// */
// public void acceptApplication(int applicationID, User performer, boolean createUserMessage, boolean createPasswordMessage, boolean sendEmail, boolean sendSnailMail) throws CreateException, RemoteException;
//
// /**
// * @see is.idega.idegaweb.egov.citizen.business.CitizenAccountBusinessBean#changePasswordAndSendLetterOrEmail
// */
// public void changePasswordAndSendLetterOrEmail(IWUserContext iwuc, LoginTable loginTable, User user, String newPassword, boolean sendLetter) throws CreateException, RemoteException;
//
// /**
// * @see is.idega.idegaweb.egov.citizen.business.CitizenAccountBusinessBean#getNumberOfApplications
// */
// public int getNumberOfApplications() throws RemoteException, RemoteException;
// }
// Path: src/java/is/idega/idegaweb/egov/citizen/presentation/CitizenAccountStatistics.java
import is.idega.idegaweb.egov.citizen.business.CitizenAccountBusiness;
import java.rmi.RemoteException;
import com.idega.business.IBOLookup;
import com.idega.business.IBORuntimeException;
import com.idega.idegaweb.IWApplicationContext;
import com.idega.idegaweb.IWResourceBundle;
import com.idega.presentation.IWContext;
import com.idega.presentation.Layer;
import com.idega.presentation.text.Heading1;
import com.idega.presentation.text.Text;
import com.idega.presentation.ui.Label;
/*
* $Id$ Created on Mar 27, 2006
*
* Copyright (C) 2006 Idega Software hf. All Rights Reserved.
*
* This software is the proprietary information of Idega hf. Use is subject to license terms.
*/
package is.idega.idegaweb.egov.citizen.presentation;
public class CitizenAccountStatistics extends CitizenBlock {
public void present(IWContext iwc) {
try {
IWResourceBundle iwrb = getResourceBundle(iwc);
int citizenAccountCount = getCitizenAccountBusiness(iwc).getNumberOfApplications();
Layer section = new Layer(Layer.DIV);
section.setStyleClass("formSection");
section.setStyleClass("statisticsLayer");
add(section);
Heading1 heading = new Heading1(iwrb.getLocalizedString("citizen_account.statistics", "Citizen account statistics"));
section.add(heading);
Layer formItem = new Layer(Layer.DIV);
formItem.setStyleClass("formItem");
Label label = new Label();
label.add(new Text(iwrb.getLocalizedString("citizen_account.number_of_accounts", "Number of accounts")));
Layer span = new Layer(Layer.SPAN);
span.add(String.valueOf(citizenAccountCount));
formItem.add(label);
formItem.add(span);
section.add(formItem);
Layer clearLayer = new Layer(Layer.DIV);
clearLayer.setStyleClass("Clear");
section.add(clearLayer);
}
catch (RemoteException re) {
throw new IBORuntimeException(re);
}
}
| protected CitizenAccountBusiness getCitizenAccountBusiness(IWApplicationContext iwac) throws RemoteException { |
idega/is.idega.idegaweb.egov.citizen | src/java/is/idega/idegaweb/egov/citizen/presentation/CitizenBlock.java | // Path: src/java/is/idega/idegaweb/egov/citizen/IWBundleStarter.java
// public class IWBundleStarter implements IWBundleStartable {
//
// public final static String IW_BUNDLE_IDENTIFIER = "is.idega.idegaweb.egov.citizen";
//
// @Override
// public void start(IWBundle starterBundle) {
// addDefaultRemoteServices(starterBundle);
// try{
// addDefaultContactPurposes();
// }catch(Exception e){
// Logger.getLogger(IWBundleStarter.class.getName()).log(Level.WARNING, "failed adding default contact purposes for ehub", e);
// }
// }
//
// @Override
// public void stop(IWBundle starterBundle) {
// }
//
// private void addDefaultContactPurposes() throws CreateException, IDOLookupException{
// ContactPurposeHome contactPurposeHome = (ContactPurposeHome) IDOLookup.getHome(ContactPurpose.class);
// Collection<ContactPurpose> contacts = contactPurposeHome.getContactPurposes(1);
// if(!ListUtil.isEmpty(contacts)){
// return;
// }
// ContactPurpose contactPurpose = contactPurposeHome.create();
// contactPurpose.setDisplayName("eHUB_messages");
// contactPurpose.store();
// contactPurpose = contactPurposeHome.create();
// contactPurpose.setDisplayName("eHUB_messages_SMS");
// contactPurpose.store();
// }
//
//
// private Collection<AdvancedProperty> getDefaultRemoteServices(){
// Collection <AdvancedProperty> defaultRemoteServices = new ArrayList<AdvancedProperty>();
// AdvancedProperty service = new AdvancedProperty("http://impratest.sidan.is","Innovation Center");
// defaultRemoteServices.add(service);
// service = new AdvancedProperty("http://biladev.sidan.is","Reykjavík City");
// defaultRemoteServices.add(service);
// service = new AdvancedProperty("http://felixtest.sidan.is","ÍSÍ");
// defaultRemoteServices.add(service);
// return defaultRemoteServices;
// }
//
// private void addDefaultRemoteServices(IWBundle starterBundle){
// CitizenRemoteServicesHome citizenRemoteServicesHome = null;
// try {
// citizenRemoteServicesHome = (CitizenRemoteServicesHome) IDOLookup.getHome(CitizenRemoteServices.class);
// } catch (IDOLookupException e) {
// Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "failed adding default remote services", e);
// return;
// }
// Collection<CitizenRemoteServices> services = citizenRemoteServicesHome.getRemoteServices(1);
// if(!ListUtil.isEmpty(services)){
// return;
// }
//
// Collection<AdvancedProperty> defaultServices = getDefaultRemoteServices();
// for(AdvancedProperty service : defaultServices){
// CitizenRemoteServices citizenRemoteServices = null;
// try {
// citizenRemoteServices = (CitizenRemoteServices) citizenRemoteServicesHome.createIDO();
// citizenRemoteServices.setAddress(service.getId());
// citizenRemoteServices.setServerName(service.getValue());
// citizenRemoteServices.store();
// } catch (Exception e) {
// Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "failed adding default remote service" + service, e);
// }
// }
// }
// }
| import is.idega.idegaweb.egov.citizen.IWBundleStarter;
import java.util.Collection;
import com.idega.presentation.Block;
import com.idega.presentation.IWContext;
import com.idega.presentation.Layer;
import com.idega.presentation.text.Heading1;
import com.idega.presentation.text.ListItem;
import com.idega.presentation.text.Lists;
import com.idega.presentation.text.Text;
import com.idega.util.ListUtil;
import com.idega.util.PresentationUtil; | /*
* $Id$
* Created on Jan 15, 2006
*
* Copyright (C) 2006 Idega Software hf. All Rights Reserved.
*
* This software is the proprietary information of Idega hf.
* Use is subject to license terms.
*/
package is.idega.idegaweb.egov.citizen.presentation;
public abstract class CitizenBlock extends Block {
@Override
public String getBundleIdentifier() { | // Path: src/java/is/idega/idegaweb/egov/citizen/IWBundleStarter.java
// public class IWBundleStarter implements IWBundleStartable {
//
// public final static String IW_BUNDLE_IDENTIFIER = "is.idega.idegaweb.egov.citizen";
//
// @Override
// public void start(IWBundle starterBundle) {
// addDefaultRemoteServices(starterBundle);
// try{
// addDefaultContactPurposes();
// }catch(Exception e){
// Logger.getLogger(IWBundleStarter.class.getName()).log(Level.WARNING, "failed adding default contact purposes for ehub", e);
// }
// }
//
// @Override
// public void stop(IWBundle starterBundle) {
// }
//
// private void addDefaultContactPurposes() throws CreateException, IDOLookupException{
// ContactPurposeHome contactPurposeHome = (ContactPurposeHome) IDOLookup.getHome(ContactPurpose.class);
// Collection<ContactPurpose> contacts = contactPurposeHome.getContactPurposes(1);
// if(!ListUtil.isEmpty(contacts)){
// return;
// }
// ContactPurpose contactPurpose = contactPurposeHome.create();
// contactPurpose.setDisplayName("eHUB_messages");
// contactPurpose.store();
// contactPurpose = contactPurposeHome.create();
// contactPurpose.setDisplayName("eHUB_messages_SMS");
// contactPurpose.store();
// }
//
//
// private Collection<AdvancedProperty> getDefaultRemoteServices(){
// Collection <AdvancedProperty> defaultRemoteServices = new ArrayList<AdvancedProperty>();
// AdvancedProperty service = new AdvancedProperty("http://impratest.sidan.is","Innovation Center");
// defaultRemoteServices.add(service);
// service = new AdvancedProperty("http://biladev.sidan.is","Reykjavík City");
// defaultRemoteServices.add(service);
// service = new AdvancedProperty("http://felixtest.sidan.is","ÍSÍ");
// defaultRemoteServices.add(service);
// return defaultRemoteServices;
// }
//
// private void addDefaultRemoteServices(IWBundle starterBundle){
// CitizenRemoteServicesHome citizenRemoteServicesHome = null;
// try {
// citizenRemoteServicesHome = (CitizenRemoteServicesHome) IDOLookup.getHome(CitizenRemoteServices.class);
// } catch (IDOLookupException e) {
// Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "failed adding default remote services", e);
// return;
// }
// Collection<CitizenRemoteServices> services = citizenRemoteServicesHome.getRemoteServices(1);
// if(!ListUtil.isEmpty(services)){
// return;
// }
//
// Collection<AdvancedProperty> defaultServices = getDefaultRemoteServices();
// for(AdvancedProperty service : defaultServices){
// CitizenRemoteServices citizenRemoteServices = null;
// try {
// citizenRemoteServices = (CitizenRemoteServices) citizenRemoteServicesHome.createIDO();
// citizenRemoteServices.setAddress(service.getId());
// citizenRemoteServices.setServerName(service.getValue());
// citizenRemoteServices.store();
// } catch (Exception e) {
// Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "failed adding default remote service" + service, e);
// }
// }
// }
// }
// Path: src/java/is/idega/idegaweb/egov/citizen/presentation/CitizenBlock.java
import is.idega.idegaweb.egov.citizen.IWBundleStarter;
import java.util.Collection;
import com.idega.presentation.Block;
import com.idega.presentation.IWContext;
import com.idega.presentation.Layer;
import com.idega.presentation.text.Heading1;
import com.idega.presentation.text.ListItem;
import com.idega.presentation.text.Lists;
import com.idega.presentation.text.Text;
import com.idega.util.ListUtil;
import com.idega.util.PresentationUtil;
/*
* $Id$
* Created on Jan 15, 2006
*
* Copyright (C) 2006 Idega Software hf. All Rights Reserved.
*
* This software is the proprietary information of Idega hf.
* Use is subject to license terms.
*/
package is.idega.idegaweb.egov.citizen.presentation;
public abstract class CitizenBlock extends Block {
@Override
public String getBundleIdentifier() { | return IWBundleStarter.IW_BUNDLE_IDENTIFIER; |
idega/is.idega.idegaweb.egov.citizen | src/java/is/idega/idegaweb/egov/citizen/business/AccountApplicationBusinessBean.java | // Path: src/java/is/idega/idegaweb/egov/citizen/IWBundleStarter.java
// public class IWBundleStarter implements IWBundleStartable {
//
// public final static String IW_BUNDLE_IDENTIFIER = "is.idega.idegaweb.egov.citizen";
//
// @Override
// public void start(IWBundle starterBundle) {
// addDefaultRemoteServices(starterBundle);
// try{
// addDefaultContactPurposes();
// }catch(Exception e){
// Logger.getLogger(IWBundleStarter.class.getName()).log(Level.WARNING, "failed adding default contact purposes for ehub", e);
// }
// }
//
// @Override
// public void stop(IWBundle starterBundle) {
// }
//
// private void addDefaultContactPurposes() throws CreateException, IDOLookupException{
// ContactPurposeHome contactPurposeHome = (ContactPurposeHome) IDOLookup.getHome(ContactPurpose.class);
// Collection<ContactPurpose> contacts = contactPurposeHome.getContactPurposes(1);
// if(!ListUtil.isEmpty(contacts)){
// return;
// }
// ContactPurpose contactPurpose = contactPurposeHome.create();
// contactPurpose.setDisplayName("eHUB_messages");
// contactPurpose.store();
// contactPurpose = contactPurposeHome.create();
// contactPurpose.setDisplayName("eHUB_messages_SMS");
// contactPurpose.store();
// }
//
//
// private Collection<AdvancedProperty> getDefaultRemoteServices(){
// Collection <AdvancedProperty> defaultRemoteServices = new ArrayList<AdvancedProperty>();
// AdvancedProperty service = new AdvancedProperty("http://impratest.sidan.is","Innovation Center");
// defaultRemoteServices.add(service);
// service = new AdvancedProperty("http://biladev.sidan.is","Reykjavík City");
// defaultRemoteServices.add(service);
// service = new AdvancedProperty("http://felixtest.sidan.is","ÍSÍ");
// defaultRemoteServices.add(service);
// return defaultRemoteServices;
// }
//
// private void addDefaultRemoteServices(IWBundle starterBundle){
// CitizenRemoteServicesHome citizenRemoteServicesHome = null;
// try {
// citizenRemoteServicesHome = (CitizenRemoteServicesHome) IDOLookup.getHome(CitizenRemoteServices.class);
// } catch (IDOLookupException e) {
// Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "failed adding default remote services", e);
// return;
// }
// Collection<CitizenRemoteServices> services = citizenRemoteServicesHome.getRemoteServices(1);
// if(!ListUtil.isEmpty(services)){
// return;
// }
//
// Collection<AdvancedProperty> defaultServices = getDefaultRemoteServices();
// for(AdvancedProperty service : defaultServices){
// CitizenRemoteServices citizenRemoteServices = null;
// try {
// citizenRemoteServices = (CitizenRemoteServices) citizenRemoteServicesHome.createIDO();
// citizenRemoteServices.setAddress(service.getId());
// citizenRemoteServices.setServerName(service.getValue());
// citizenRemoteServices.store();
// } catch (Exception e) {
// Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "failed adding default remote service" + service, e);
// }
// }
// }
// }
//
// Path: src/java/is/idega/idegaweb/egov/citizen/data/AccountApplication.java
// public interface AccountApplication extends com.idega.block.process.data.Case
// {
// public void setEmail(java.lang.String p0);
// public java.lang.String getEmail();
// public void setApplicantName(java.lang.String p0);
// public java.lang.String getApplicantName();
// }
| import is.idega.idegaweb.egov.accounting.business.CitizenBusiness;
import is.idega.idegaweb.egov.citizen.IWBundleStarter;
import is.idega.idegaweb.egov.citizen.data.AccountApplication;
import is.idega.idegaweb.egov.message.business.CommuneMessageBusiness;
import java.rmi.RemoteException;
import java.text.MessageFormat;
import javax.ejb.CreateException;
import javax.ejb.FinderException;
import javax.transaction.SystemException;
import javax.transaction.UserTransaction;
import com.idega.block.process.business.CaseBusinessBean;
import com.idega.core.accesscontrol.business.LoginCreateException;
import com.idega.core.accesscontrol.business.UserHasLoginException;
import com.idega.core.accesscontrol.data.LoginTable;
import com.idega.core.accesscontrol.data.PasswordNotKnown;
import com.idega.data.IDOCreateException;
import com.idega.idegaweb.IWResourceBundle;
import com.idega.user.data.Group;
import com.idega.user.data.User;
import com.idega.util.IWTimestamp; | /*
* $Id$
*
* Copyright (C) 2002 Idega hf. All Rights Reserved.
*
* This software is the proprietary information of Idega hf. Use is subject to license terms.
*
*/
package is.idega.idegaweb.egov.citizen.business;
/**
* @author <a href="mailto:[email protected]">Tryggvi Larusson</a>
* @version 1.0
*/
public abstract class AccountApplicationBusinessBean extends CaseBusinessBean implements AccountBusiness {
protected abstract Class getCaseEntityClass();
public CommuneMessageBusiness getMessageBusiness() throws RemoteException {
return (CommuneMessageBusiness) this.getServiceInstance(CommuneMessageBusiness.class);
}
| // Path: src/java/is/idega/idegaweb/egov/citizen/IWBundleStarter.java
// public class IWBundleStarter implements IWBundleStartable {
//
// public final static String IW_BUNDLE_IDENTIFIER = "is.idega.idegaweb.egov.citizen";
//
// @Override
// public void start(IWBundle starterBundle) {
// addDefaultRemoteServices(starterBundle);
// try{
// addDefaultContactPurposes();
// }catch(Exception e){
// Logger.getLogger(IWBundleStarter.class.getName()).log(Level.WARNING, "failed adding default contact purposes for ehub", e);
// }
// }
//
// @Override
// public void stop(IWBundle starterBundle) {
// }
//
// private void addDefaultContactPurposes() throws CreateException, IDOLookupException{
// ContactPurposeHome contactPurposeHome = (ContactPurposeHome) IDOLookup.getHome(ContactPurpose.class);
// Collection<ContactPurpose> contacts = contactPurposeHome.getContactPurposes(1);
// if(!ListUtil.isEmpty(contacts)){
// return;
// }
// ContactPurpose contactPurpose = contactPurposeHome.create();
// contactPurpose.setDisplayName("eHUB_messages");
// contactPurpose.store();
// contactPurpose = contactPurposeHome.create();
// contactPurpose.setDisplayName("eHUB_messages_SMS");
// contactPurpose.store();
// }
//
//
// private Collection<AdvancedProperty> getDefaultRemoteServices(){
// Collection <AdvancedProperty> defaultRemoteServices = new ArrayList<AdvancedProperty>();
// AdvancedProperty service = new AdvancedProperty("http://impratest.sidan.is","Innovation Center");
// defaultRemoteServices.add(service);
// service = new AdvancedProperty("http://biladev.sidan.is","Reykjavík City");
// defaultRemoteServices.add(service);
// service = new AdvancedProperty("http://felixtest.sidan.is","ÍSÍ");
// defaultRemoteServices.add(service);
// return defaultRemoteServices;
// }
//
// private void addDefaultRemoteServices(IWBundle starterBundle){
// CitizenRemoteServicesHome citizenRemoteServicesHome = null;
// try {
// citizenRemoteServicesHome = (CitizenRemoteServicesHome) IDOLookup.getHome(CitizenRemoteServices.class);
// } catch (IDOLookupException e) {
// Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "failed adding default remote services", e);
// return;
// }
// Collection<CitizenRemoteServices> services = citizenRemoteServicesHome.getRemoteServices(1);
// if(!ListUtil.isEmpty(services)){
// return;
// }
//
// Collection<AdvancedProperty> defaultServices = getDefaultRemoteServices();
// for(AdvancedProperty service : defaultServices){
// CitizenRemoteServices citizenRemoteServices = null;
// try {
// citizenRemoteServices = (CitizenRemoteServices) citizenRemoteServicesHome.createIDO();
// citizenRemoteServices.setAddress(service.getId());
// citizenRemoteServices.setServerName(service.getValue());
// citizenRemoteServices.store();
// } catch (Exception e) {
// Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "failed adding default remote service" + service, e);
// }
// }
// }
// }
//
// Path: src/java/is/idega/idegaweb/egov/citizen/data/AccountApplication.java
// public interface AccountApplication extends com.idega.block.process.data.Case
// {
// public void setEmail(java.lang.String p0);
// public java.lang.String getEmail();
// public void setApplicantName(java.lang.String p0);
// public java.lang.String getApplicantName();
// }
// Path: src/java/is/idega/idegaweb/egov/citizen/business/AccountApplicationBusinessBean.java
import is.idega.idegaweb.egov.accounting.business.CitizenBusiness;
import is.idega.idegaweb.egov.citizen.IWBundleStarter;
import is.idega.idegaweb.egov.citizen.data.AccountApplication;
import is.idega.idegaweb.egov.message.business.CommuneMessageBusiness;
import java.rmi.RemoteException;
import java.text.MessageFormat;
import javax.ejb.CreateException;
import javax.ejb.FinderException;
import javax.transaction.SystemException;
import javax.transaction.UserTransaction;
import com.idega.block.process.business.CaseBusinessBean;
import com.idega.core.accesscontrol.business.LoginCreateException;
import com.idega.core.accesscontrol.business.UserHasLoginException;
import com.idega.core.accesscontrol.data.LoginTable;
import com.idega.core.accesscontrol.data.PasswordNotKnown;
import com.idega.data.IDOCreateException;
import com.idega.idegaweb.IWResourceBundle;
import com.idega.user.data.Group;
import com.idega.user.data.User;
import com.idega.util.IWTimestamp;
/*
* $Id$
*
* Copyright (C) 2002 Idega hf. All Rights Reserved.
*
* This software is the proprietary information of Idega hf. Use is subject to license terms.
*
*/
package is.idega.idegaweb.egov.citizen.business;
/**
* @author <a href="mailto:[email protected]">Tryggvi Larusson</a>
* @version 1.0
*/
public abstract class AccountApplicationBusinessBean extends CaseBusinessBean implements AccountBusiness {
protected abstract Class getCaseEntityClass();
public CommuneMessageBusiness getMessageBusiness() throws RemoteException {
return (CommuneMessageBusiness) this.getServiceInstance(CommuneMessageBusiness.class);
}
| protected AccountApplication getApplication(int applicationID) throws FinderException { |
idega/is.idega.idegaweb.egov.citizen | src/java/is/idega/idegaweb/egov/citizen/business/AccountApplicationBusinessBean.java | // Path: src/java/is/idega/idegaweb/egov/citizen/IWBundleStarter.java
// public class IWBundleStarter implements IWBundleStartable {
//
// public final static String IW_BUNDLE_IDENTIFIER = "is.idega.idegaweb.egov.citizen";
//
// @Override
// public void start(IWBundle starterBundle) {
// addDefaultRemoteServices(starterBundle);
// try{
// addDefaultContactPurposes();
// }catch(Exception e){
// Logger.getLogger(IWBundleStarter.class.getName()).log(Level.WARNING, "failed adding default contact purposes for ehub", e);
// }
// }
//
// @Override
// public void stop(IWBundle starterBundle) {
// }
//
// private void addDefaultContactPurposes() throws CreateException, IDOLookupException{
// ContactPurposeHome contactPurposeHome = (ContactPurposeHome) IDOLookup.getHome(ContactPurpose.class);
// Collection<ContactPurpose> contacts = contactPurposeHome.getContactPurposes(1);
// if(!ListUtil.isEmpty(contacts)){
// return;
// }
// ContactPurpose contactPurpose = contactPurposeHome.create();
// contactPurpose.setDisplayName("eHUB_messages");
// contactPurpose.store();
// contactPurpose = contactPurposeHome.create();
// contactPurpose.setDisplayName("eHUB_messages_SMS");
// contactPurpose.store();
// }
//
//
// private Collection<AdvancedProperty> getDefaultRemoteServices(){
// Collection <AdvancedProperty> defaultRemoteServices = new ArrayList<AdvancedProperty>();
// AdvancedProperty service = new AdvancedProperty("http://impratest.sidan.is","Innovation Center");
// defaultRemoteServices.add(service);
// service = new AdvancedProperty("http://biladev.sidan.is","Reykjavík City");
// defaultRemoteServices.add(service);
// service = new AdvancedProperty("http://felixtest.sidan.is","ÍSÍ");
// defaultRemoteServices.add(service);
// return defaultRemoteServices;
// }
//
// private void addDefaultRemoteServices(IWBundle starterBundle){
// CitizenRemoteServicesHome citizenRemoteServicesHome = null;
// try {
// citizenRemoteServicesHome = (CitizenRemoteServicesHome) IDOLookup.getHome(CitizenRemoteServices.class);
// } catch (IDOLookupException e) {
// Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "failed adding default remote services", e);
// return;
// }
// Collection<CitizenRemoteServices> services = citizenRemoteServicesHome.getRemoteServices(1);
// if(!ListUtil.isEmpty(services)){
// return;
// }
//
// Collection<AdvancedProperty> defaultServices = getDefaultRemoteServices();
// for(AdvancedProperty service : defaultServices){
// CitizenRemoteServices citizenRemoteServices = null;
// try {
// citizenRemoteServices = (CitizenRemoteServices) citizenRemoteServicesHome.createIDO();
// citizenRemoteServices.setAddress(service.getId());
// citizenRemoteServices.setServerName(service.getValue());
// citizenRemoteServices.store();
// } catch (Exception e) {
// Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "failed adding default remote service" + service, e);
// }
// }
// }
// }
//
// Path: src/java/is/idega/idegaweb/egov/citizen/data/AccountApplication.java
// public interface AccountApplication extends com.idega.block.process.data.Case
// {
// public void setEmail(java.lang.String p0);
// public java.lang.String getEmail();
// public void setApplicantName(java.lang.String p0);
// public java.lang.String getApplicantName();
// }
| import is.idega.idegaweb.egov.accounting.business.CitizenBusiness;
import is.idega.idegaweb.egov.citizen.IWBundleStarter;
import is.idega.idegaweb.egov.citizen.data.AccountApplication;
import is.idega.idegaweb.egov.message.business.CommuneMessageBusiness;
import java.rmi.RemoteException;
import java.text.MessageFormat;
import javax.ejb.CreateException;
import javax.ejb.FinderException;
import javax.transaction.SystemException;
import javax.transaction.UserTransaction;
import com.idega.block.process.business.CaseBusinessBean;
import com.idega.core.accesscontrol.business.LoginCreateException;
import com.idega.core.accesscontrol.business.UserHasLoginException;
import com.idega.core.accesscontrol.data.LoginTable;
import com.idega.core.accesscontrol.data.PasswordNotKnown;
import com.idega.data.IDOCreateException;
import com.idega.idegaweb.IWResourceBundle;
import com.idega.user.data.Group;
import com.idega.user.data.User;
import com.idega.util.IWTimestamp; | lt = getUserBusiness().generateUserLogin(citizen);
login = lt.getUserLogin();
try {
String password = lt.getUnencryptedUserPassword();
String messageBody = this.getAcceptMessageBody(theCase, login, password);
String messageSubject = this.getAcceptMessageSubject(theCase);
if (createUserMessage) {
this.getMessageBusiness().createUserMessage(citizen, messageSubject, messageBody, sendLetter);
}
if (createPasswordMessage) {
this.getMessageBusiness().createPasswordMessage(citizen, login, password);
}
createUserMessage = sendEmail;
}
catch (PasswordNotKnown e) {
throw new IDOCreateException(e);
}
catch (RemoteException e) {
e.printStackTrace();
}
}
protected CitizenBusiness getUserBusiness() throws RemoteException {
return (CitizenBusiness) this.getServiceInstance(CitizenBusiness.class);
}
@Override
public String getBundleIdentifier() { | // Path: src/java/is/idega/idegaweb/egov/citizen/IWBundleStarter.java
// public class IWBundleStarter implements IWBundleStartable {
//
// public final static String IW_BUNDLE_IDENTIFIER = "is.idega.idegaweb.egov.citizen";
//
// @Override
// public void start(IWBundle starterBundle) {
// addDefaultRemoteServices(starterBundle);
// try{
// addDefaultContactPurposes();
// }catch(Exception e){
// Logger.getLogger(IWBundleStarter.class.getName()).log(Level.WARNING, "failed adding default contact purposes for ehub", e);
// }
// }
//
// @Override
// public void stop(IWBundle starterBundle) {
// }
//
// private void addDefaultContactPurposes() throws CreateException, IDOLookupException{
// ContactPurposeHome contactPurposeHome = (ContactPurposeHome) IDOLookup.getHome(ContactPurpose.class);
// Collection<ContactPurpose> contacts = contactPurposeHome.getContactPurposes(1);
// if(!ListUtil.isEmpty(contacts)){
// return;
// }
// ContactPurpose contactPurpose = contactPurposeHome.create();
// contactPurpose.setDisplayName("eHUB_messages");
// contactPurpose.store();
// contactPurpose = contactPurposeHome.create();
// contactPurpose.setDisplayName("eHUB_messages_SMS");
// contactPurpose.store();
// }
//
//
// private Collection<AdvancedProperty> getDefaultRemoteServices(){
// Collection <AdvancedProperty> defaultRemoteServices = new ArrayList<AdvancedProperty>();
// AdvancedProperty service = new AdvancedProperty("http://impratest.sidan.is","Innovation Center");
// defaultRemoteServices.add(service);
// service = new AdvancedProperty("http://biladev.sidan.is","Reykjavík City");
// defaultRemoteServices.add(service);
// service = new AdvancedProperty("http://felixtest.sidan.is","ÍSÍ");
// defaultRemoteServices.add(service);
// return defaultRemoteServices;
// }
//
// private void addDefaultRemoteServices(IWBundle starterBundle){
// CitizenRemoteServicesHome citizenRemoteServicesHome = null;
// try {
// citizenRemoteServicesHome = (CitizenRemoteServicesHome) IDOLookup.getHome(CitizenRemoteServices.class);
// } catch (IDOLookupException e) {
// Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "failed adding default remote services", e);
// return;
// }
// Collection<CitizenRemoteServices> services = citizenRemoteServicesHome.getRemoteServices(1);
// if(!ListUtil.isEmpty(services)){
// return;
// }
//
// Collection<AdvancedProperty> defaultServices = getDefaultRemoteServices();
// for(AdvancedProperty service : defaultServices){
// CitizenRemoteServices citizenRemoteServices = null;
// try {
// citizenRemoteServices = (CitizenRemoteServices) citizenRemoteServicesHome.createIDO();
// citizenRemoteServices.setAddress(service.getId());
// citizenRemoteServices.setServerName(service.getValue());
// citizenRemoteServices.store();
// } catch (Exception e) {
// Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "failed adding default remote service" + service, e);
// }
// }
// }
// }
//
// Path: src/java/is/idega/idegaweb/egov/citizen/data/AccountApplication.java
// public interface AccountApplication extends com.idega.block.process.data.Case
// {
// public void setEmail(java.lang.String p0);
// public java.lang.String getEmail();
// public void setApplicantName(java.lang.String p0);
// public java.lang.String getApplicantName();
// }
// Path: src/java/is/idega/idegaweb/egov/citizen/business/AccountApplicationBusinessBean.java
import is.idega.idegaweb.egov.accounting.business.CitizenBusiness;
import is.idega.idegaweb.egov.citizen.IWBundleStarter;
import is.idega.idegaweb.egov.citizen.data.AccountApplication;
import is.idega.idegaweb.egov.message.business.CommuneMessageBusiness;
import java.rmi.RemoteException;
import java.text.MessageFormat;
import javax.ejb.CreateException;
import javax.ejb.FinderException;
import javax.transaction.SystemException;
import javax.transaction.UserTransaction;
import com.idega.block.process.business.CaseBusinessBean;
import com.idega.core.accesscontrol.business.LoginCreateException;
import com.idega.core.accesscontrol.business.UserHasLoginException;
import com.idega.core.accesscontrol.data.LoginTable;
import com.idega.core.accesscontrol.data.PasswordNotKnown;
import com.idega.data.IDOCreateException;
import com.idega.idegaweb.IWResourceBundle;
import com.idega.user.data.Group;
import com.idega.user.data.User;
import com.idega.util.IWTimestamp;
lt = getUserBusiness().generateUserLogin(citizen);
login = lt.getUserLogin();
try {
String password = lt.getUnencryptedUserPassword();
String messageBody = this.getAcceptMessageBody(theCase, login, password);
String messageSubject = this.getAcceptMessageSubject(theCase);
if (createUserMessage) {
this.getMessageBusiness().createUserMessage(citizen, messageSubject, messageBody, sendLetter);
}
if (createPasswordMessage) {
this.getMessageBusiness().createPasswordMessage(citizen, login, password);
}
createUserMessage = sendEmail;
}
catch (PasswordNotKnown e) {
throw new IDOCreateException(e);
}
catch (RemoteException e) {
e.printStackTrace();
}
}
protected CitizenBusiness getUserBusiness() throws RemoteException {
return (CitizenBusiness) this.getServiceInstance(CitizenBusiness.class);
}
@Override
public String getBundleIdentifier() { | return IWBundleStarter.IW_BUNDLE_IDENTIFIER; |
idega/is.idega.idegaweb.egov.citizen | src/java/is/idega/idegaweb/egov/citizen/IWBundleStarter.java | // Path: src/java/is/idega/idegaweb/egov/citizen/data/CitizenRemoteServices.java
// public interface CitizenRemoteServices extends IDOEntity {
// public String getServerName();
// public void setServerName(String name);
// public String getAddress();
// public void setAddress(String address);
// public Collection<User> getUsers() throws IDORelationshipException;
// public void addUser(User user) throws IDORelationshipException;
// public void removeUser(User user)throws IDORelationshipException;
// }
//
// Path: src/java/is/idega/idegaweb/egov/citizen/data/CitizenRemoteServicesHome.java
// public interface CitizenRemoteServicesHome extends IDOHome {
// public Collection<CitizenRemoteServices> getRemoteServicesByNames(Collection <String> names);
// public Collection<CitizenRemoteServices> getRemoteServices(int maxAmount);
// public Collection<CitizenRemoteServices> getRemoteServicesByUserId(String userId) throws IDORelationshipException ;
// }
| import is.idega.idegaweb.egov.citizen.data.CitizenRemoteServices;
import is.idega.idegaweb.egov.citizen.data.CitizenRemoteServicesHome;
import java.util.ArrayList;
import java.util.Collection;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.CreateException;
import com.idega.builder.bean.AdvancedProperty;
import com.idega.core.contact.data.ContactPurpose;
import com.idega.core.contact.data.ContactPurposeHome;
import com.idega.data.IDOLookup;
import com.idega.data.IDOLookupException;
import com.idega.idegaweb.IWBundle;
import com.idega.idegaweb.IWBundleStartable;
import com.idega.util.ListUtil; | public void stop(IWBundle starterBundle) {
}
private void addDefaultContactPurposes() throws CreateException, IDOLookupException{
ContactPurposeHome contactPurposeHome = (ContactPurposeHome) IDOLookup.getHome(ContactPurpose.class);
Collection<ContactPurpose> contacts = contactPurposeHome.getContactPurposes(1);
if(!ListUtil.isEmpty(contacts)){
return;
}
ContactPurpose contactPurpose = contactPurposeHome.create();
contactPurpose.setDisplayName("eHUB_messages");
contactPurpose.store();
contactPurpose = contactPurposeHome.create();
contactPurpose.setDisplayName("eHUB_messages_SMS");
contactPurpose.store();
}
private Collection<AdvancedProperty> getDefaultRemoteServices(){
Collection <AdvancedProperty> defaultRemoteServices = new ArrayList<AdvancedProperty>();
AdvancedProperty service = new AdvancedProperty("http://impratest.sidan.is","Innovation Center");
defaultRemoteServices.add(service);
service = new AdvancedProperty("http://biladev.sidan.is","Reykjavík City");
defaultRemoteServices.add(service);
service = new AdvancedProperty("http://felixtest.sidan.is","ÍSÍ");
defaultRemoteServices.add(service);
return defaultRemoteServices;
}
private void addDefaultRemoteServices(IWBundle starterBundle){ | // Path: src/java/is/idega/idegaweb/egov/citizen/data/CitizenRemoteServices.java
// public interface CitizenRemoteServices extends IDOEntity {
// public String getServerName();
// public void setServerName(String name);
// public String getAddress();
// public void setAddress(String address);
// public Collection<User> getUsers() throws IDORelationshipException;
// public void addUser(User user) throws IDORelationshipException;
// public void removeUser(User user)throws IDORelationshipException;
// }
//
// Path: src/java/is/idega/idegaweb/egov/citizen/data/CitizenRemoteServicesHome.java
// public interface CitizenRemoteServicesHome extends IDOHome {
// public Collection<CitizenRemoteServices> getRemoteServicesByNames(Collection <String> names);
// public Collection<CitizenRemoteServices> getRemoteServices(int maxAmount);
// public Collection<CitizenRemoteServices> getRemoteServicesByUserId(String userId) throws IDORelationshipException ;
// }
// Path: src/java/is/idega/idegaweb/egov/citizen/IWBundleStarter.java
import is.idega.idegaweb.egov.citizen.data.CitizenRemoteServices;
import is.idega.idegaweb.egov.citizen.data.CitizenRemoteServicesHome;
import java.util.ArrayList;
import java.util.Collection;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.CreateException;
import com.idega.builder.bean.AdvancedProperty;
import com.idega.core.contact.data.ContactPurpose;
import com.idega.core.contact.data.ContactPurposeHome;
import com.idega.data.IDOLookup;
import com.idega.data.IDOLookupException;
import com.idega.idegaweb.IWBundle;
import com.idega.idegaweb.IWBundleStartable;
import com.idega.util.ListUtil;
public void stop(IWBundle starterBundle) {
}
private void addDefaultContactPurposes() throws CreateException, IDOLookupException{
ContactPurposeHome contactPurposeHome = (ContactPurposeHome) IDOLookup.getHome(ContactPurpose.class);
Collection<ContactPurpose> contacts = contactPurposeHome.getContactPurposes(1);
if(!ListUtil.isEmpty(contacts)){
return;
}
ContactPurpose contactPurpose = contactPurposeHome.create();
contactPurpose.setDisplayName("eHUB_messages");
contactPurpose.store();
contactPurpose = contactPurposeHome.create();
contactPurpose.setDisplayName("eHUB_messages_SMS");
contactPurpose.store();
}
private Collection<AdvancedProperty> getDefaultRemoteServices(){
Collection <AdvancedProperty> defaultRemoteServices = new ArrayList<AdvancedProperty>();
AdvancedProperty service = new AdvancedProperty("http://impratest.sidan.is","Innovation Center");
defaultRemoteServices.add(service);
service = new AdvancedProperty("http://biladev.sidan.is","Reykjavík City");
defaultRemoteServices.add(service);
service = new AdvancedProperty("http://felixtest.sidan.is","ÍSÍ");
defaultRemoteServices.add(service);
return defaultRemoteServices;
}
private void addDefaultRemoteServices(IWBundle starterBundle){ | CitizenRemoteServicesHome citizenRemoteServicesHome = null; |
idega/is.idega.idegaweb.egov.citizen | src/java/is/idega/idegaweb/egov/citizen/IWBundleStarter.java | // Path: src/java/is/idega/idegaweb/egov/citizen/data/CitizenRemoteServices.java
// public interface CitizenRemoteServices extends IDOEntity {
// public String getServerName();
// public void setServerName(String name);
// public String getAddress();
// public void setAddress(String address);
// public Collection<User> getUsers() throws IDORelationshipException;
// public void addUser(User user) throws IDORelationshipException;
// public void removeUser(User user)throws IDORelationshipException;
// }
//
// Path: src/java/is/idega/idegaweb/egov/citizen/data/CitizenRemoteServicesHome.java
// public interface CitizenRemoteServicesHome extends IDOHome {
// public Collection<CitizenRemoteServices> getRemoteServicesByNames(Collection <String> names);
// public Collection<CitizenRemoteServices> getRemoteServices(int maxAmount);
// public Collection<CitizenRemoteServices> getRemoteServicesByUserId(String userId) throws IDORelationshipException ;
// }
| import is.idega.idegaweb.egov.citizen.data.CitizenRemoteServices;
import is.idega.idegaweb.egov.citizen.data.CitizenRemoteServicesHome;
import java.util.ArrayList;
import java.util.Collection;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.CreateException;
import com.idega.builder.bean.AdvancedProperty;
import com.idega.core.contact.data.ContactPurpose;
import com.idega.core.contact.data.ContactPurposeHome;
import com.idega.data.IDOLookup;
import com.idega.data.IDOLookupException;
import com.idega.idegaweb.IWBundle;
import com.idega.idegaweb.IWBundleStartable;
import com.idega.util.ListUtil; |
private void addDefaultContactPurposes() throws CreateException, IDOLookupException{
ContactPurposeHome contactPurposeHome = (ContactPurposeHome) IDOLookup.getHome(ContactPurpose.class);
Collection<ContactPurpose> contacts = contactPurposeHome.getContactPurposes(1);
if(!ListUtil.isEmpty(contacts)){
return;
}
ContactPurpose contactPurpose = contactPurposeHome.create();
contactPurpose.setDisplayName("eHUB_messages");
contactPurpose.store();
contactPurpose = contactPurposeHome.create();
contactPurpose.setDisplayName("eHUB_messages_SMS");
contactPurpose.store();
}
private Collection<AdvancedProperty> getDefaultRemoteServices(){
Collection <AdvancedProperty> defaultRemoteServices = new ArrayList<AdvancedProperty>();
AdvancedProperty service = new AdvancedProperty("http://impratest.sidan.is","Innovation Center");
defaultRemoteServices.add(service);
service = new AdvancedProperty("http://biladev.sidan.is","Reykjavík City");
defaultRemoteServices.add(service);
service = new AdvancedProperty("http://felixtest.sidan.is","ÍSÍ");
defaultRemoteServices.add(service);
return defaultRemoteServices;
}
private void addDefaultRemoteServices(IWBundle starterBundle){
CitizenRemoteServicesHome citizenRemoteServicesHome = null;
try { | // Path: src/java/is/idega/idegaweb/egov/citizen/data/CitizenRemoteServices.java
// public interface CitizenRemoteServices extends IDOEntity {
// public String getServerName();
// public void setServerName(String name);
// public String getAddress();
// public void setAddress(String address);
// public Collection<User> getUsers() throws IDORelationshipException;
// public void addUser(User user) throws IDORelationshipException;
// public void removeUser(User user)throws IDORelationshipException;
// }
//
// Path: src/java/is/idega/idegaweb/egov/citizen/data/CitizenRemoteServicesHome.java
// public interface CitizenRemoteServicesHome extends IDOHome {
// public Collection<CitizenRemoteServices> getRemoteServicesByNames(Collection <String> names);
// public Collection<CitizenRemoteServices> getRemoteServices(int maxAmount);
// public Collection<CitizenRemoteServices> getRemoteServicesByUserId(String userId) throws IDORelationshipException ;
// }
// Path: src/java/is/idega/idegaweb/egov/citizen/IWBundleStarter.java
import is.idega.idegaweb.egov.citizen.data.CitizenRemoteServices;
import is.idega.idegaweb.egov.citizen.data.CitizenRemoteServicesHome;
import java.util.ArrayList;
import java.util.Collection;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.CreateException;
import com.idega.builder.bean.AdvancedProperty;
import com.idega.core.contact.data.ContactPurpose;
import com.idega.core.contact.data.ContactPurposeHome;
import com.idega.data.IDOLookup;
import com.idega.data.IDOLookupException;
import com.idega.idegaweb.IWBundle;
import com.idega.idegaweb.IWBundleStartable;
import com.idega.util.ListUtil;
private void addDefaultContactPurposes() throws CreateException, IDOLookupException{
ContactPurposeHome contactPurposeHome = (ContactPurposeHome) IDOLookup.getHome(ContactPurpose.class);
Collection<ContactPurpose> contacts = contactPurposeHome.getContactPurposes(1);
if(!ListUtil.isEmpty(contacts)){
return;
}
ContactPurpose contactPurpose = contactPurposeHome.create();
contactPurpose.setDisplayName("eHUB_messages");
contactPurpose.store();
contactPurpose = contactPurposeHome.create();
contactPurpose.setDisplayName("eHUB_messages_SMS");
contactPurpose.store();
}
private Collection<AdvancedProperty> getDefaultRemoteServices(){
Collection <AdvancedProperty> defaultRemoteServices = new ArrayList<AdvancedProperty>();
AdvancedProperty service = new AdvancedProperty("http://impratest.sidan.is","Innovation Center");
defaultRemoteServices.add(service);
service = new AdvancedProperty("http://biladev.sidan.is","Reykjavík City");
defaultRemoteServices.add(service);
service = new AdvancedProperty("http://felixtest.sidan.is","ÍSÍ");
defaultRemoteServices.add(service);
return defaultRemoteServices;
}
private void addDefaultRemoteServices(IWBundle starterBundle){
CitizenRemoteServicesHome citizenRemoteServicesHome = null;
try { | citizenRemoteServicesHome = (CitizenRemoteServicesHome) IDOLookup.getHome(CitizenRemoteServices.class); |
idega/is.idega.idegaweb.egov.citizen | src/java/is/idega/idegaweb/egov/citizen/presentation/SingleSingOn.java | // Path: src/java/is/idega/idegaweb/egov/citizen/data/CitizenRemoteServices.java
// public interface CitizenRemoteServices extends IDOEntity {
// public String getServerName();
// public void setServerName(String name);
// public String getAddress();
// public void setAddress(String address);
// public Collection<User> getUsers() throws IDORelationshipException;
// public void addUser(User user) throws IDORelationshipException;
// public void removeUser(User user)throws IDORelationshipException;
// }
//
// Path: src/java/is/idega/idegaweb/egov/citizen/data/CitizenRemoteServicesHome.java
// public interface CitizenRemoteServicesHome extends IDOHome {
// public Collection<CitizenRemoteServices> getRemoteServicesByNames(Collection <String> names);
// public Collection<CitizenRemoteServices> getRemoteServices(int maxAmount);
// public Collection<CitizenRemoteServices> getRemoteServicesByUserId(String userId) throws IDORelationshipException ;
// }
| import is.idega.idegaweb.egov.citizen.data.CitizenRemoteServices;
import is.idega.idegaweb.egov.citizen.data.CitizenRemoteServicesHome;
import java.util.Collection;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.idega.data.IDOLookup;
import com.idega.data.IDOLookupException;
import com.idega.idegaweb.IWBundle;
import com.idega.idegaweb.IWResourceBundle;
import com.idega.presentation.Block;
import com.idega.presentation.IWContext;
import com.idega.presentation.Layer;
import com.idega.presentation.ui.DropdownMenu;
import com.idega.presentation.ui.GenericButton;
import com.idega.presentation.ui.HiddenInput;
import com.idega.presentation.ui.Label;
import com.idega.presentation.ui.PasswordInput;
import com.idega.presentation.ui.TextInput;
import com.idega.util.CoreConstants;
import com.idega.util.StringUtil; | layer.add(input);
cellInfo.addText(iwrb.getLocalizedString("name", "Name"));
// Password
layer = new Layer();
main.add(layer);
layer.setStyleClass("formItem");
PasswordInput passwordInput = new PasswordInput(passwordName);
cellInfo = new Label(passwordInput);
layer.add(cellInfo);
layer.add(passwordInput);
cellInfo.addText(iwrb.getLocalizedString("password", "Password"));
// Remove
layer = new Layer();
main.add(layer);
layer.setStyleClass("formItem");
GenericButton add = new GenericButton("remove", iwrb.getLocalizedString("remove", "Remove"));
layer.add(add);
add.setOnClick("UserAccessSettingsHelper.removeSingleSingOn('#"+main.getId()+ CoreConstants.JS_STR_PARAM_SEPARATOR
+ loginId+CoreConstants.JS_STR_PARAM_END);
}
private Layer getDropdownMenuForServices(IWResourceBundle iwrb){
Layer layer = new Layer();
layer.setStyleClass("formItem");
DropdownMenu dropdown = new DropdownMenu();
dropdown.setName(dropdown.getId());
dropdown.setStyleClass(addressClass);
layer.add(dropdown); | // Path: src/java/is/idega/idegaweb/egov/citizen/data/CitizenRemoteServices.java
// public interface CitizenRemoteServices extends IDOEntity {
// public String getServerName();
// public void setServerName(String name);
// public String getAddress();
// public void setAddress(String address);
// public Collection<User> getUsers() throws IDORelationshipException;
// public void addUser(User user) throws IDORelationshipException;
// public void removeUser(User user)throws IDORelationshipException;
// }
//
// Path: src/java/is/idega/idegaweb/egov/citizen/data/CitizenRemoteServicesHome.java
// public interface CitizenRemoteServicesHome extends IDOHome {
// public Collection<CitizenRemoteServices> getRemoteServicesByNames(Collection <String> names);
// public Collection<CitizenRemoteServices> getRemoteServices(int maxAmount);
// public Collection<CitizenRemoteServices> getRemoteServicesByUserId(String userId) throws IDORelationshipException ;
// }
// Path: src/java/is/idega/idegaweb/egov/citizen/presentation/SingleSingOn.java
import is.idega.idegaweb.egov.citizen.data.CitizenRemoteServices;
import is.idega.idegaweb.egov.citizen.data.CitizenRemoteServicesHome;
import java.util.Collection;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.idega.data.IDOLookup;
import com.idega.data.IDOLookupException;
import com.idega.idegaweb.IWBundle;
import com.idega.idegaweb.IWResourceBundle;
import com.idega.presentation.Block;
import com.idega.presentation.IWContext;
import com.idega.presentation.Layer;
import com.idega.presentation.ui.DropdownMenu;
import com.idega.presentation.ui.GenericButton;
import com.idega.presentation.ui.HiddenInput;
import com.idega.presentation.ui.Label;
import com.idega.presentation.ui.PasswordInput;
import com.idega.presentation.ui.TextInput;
import com.idega.util.CoreConstants;
import com.idega.util.StringUtil;
layer.add(input);
cellInfo.addText(iwrb.getLocalizedString("name", "Name"));
// Password
layer = new Layer();
main.add(layer);
layer.setStyleClass("formItem");
PasswordInput passwordInput = new PasswordInput(passwordName);
cellInfo = new Label(passwordInput);
layer.add(cellInfo);
layer.add(passwordInput);
cellInfo.addText(iwrb.getLocalizedString("password", "Password"));
// Remove
layer = new Layer();
main.add(layer);
layer.setStyleClass("formItem");
GenericButton add = new GenericButton("remove", iwrb.getLocalizedString("remove", "Remove"));
layer.add(add);
add.setOnClick("UserAccessSettingsHelper.removeSingleSingOn('#"+main.getId()+ CoreConstants.JS_STR_PARAM_SEPARATOR
+ loginId+CoreConstants.JS_STR_PARAM_END);
}
private Layer getDropdownMenuForServices(IWResourceBundle iwrb){
Layer layer = new Layer();
layer.setStyleClass("formItem");
DropdownMenu dropdown = new DropdownMenu();
dropdown.setName(dropdown.getId());
dropdown.setStyleClass(addressClass);
layer.add(dropdown); | CitizenRemoteServicesHome citizenRemoteServicesHome = null; |
idega/is.idega.idegaweb.egov.citizen | src/java/is/idega/idegaweb/egov/citizen/presentation/SingleSingOn.java | // Path: src/java/is/idega/idegaweb/egov/citizen/data/CitizenRemoteServices.java
// public interface CitizenRemoteServices extends IDOEntity {
// public String getServerName();
// public void setServerName(String name);
// public String getAddress();
// public void setAddress(String address);
// public Collection<User> getUsers() throws IDORelationshipException;
// public void addUser(User user) throws IDORelationshipException;
// public void removeUser(User user)throws IDORelationshipException;
// }
//
// Path: src/java/is/idega/idegaweb/egov/citizen/data/CitizenRemoteServicesHome.java
// public interface CitizenRemoteServicesHome extends IDOHome {
// public Collection<CitizenRemoteServices> getRemoteServicesByNames(Collection <String> names);
// public Collection<CitizenRemoteServices> getRemoteServices(int maxAmount);
// public Collection<CitizenRemoteServices> getRemoteServicesByUserId(String userId) throws IDORelationshipException ;
// }
| import is.idega.idegaweb.egov.citizen.data.CitizenRemoteServices;
import is.idega.idegaweb.egov.citizen.data.CitizenRemoteServicesHome;
import java.util.Collection;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.idega.data.IDOLookup;
import com.idega.data.IDOLookupException;
import com.idega.idegaweb.IWBundle;
import com.idega.idegaweb.IWResourceBundle;
import com.idega.presentation.Block;
import com.idega.presentation.IWContext;
import com.idega.presentation.Layer;
import com.idega.presentation.ui.DropdownMenu;
import com.idega.presentation.ui.GenericButton;
import com.idega.presentation.ui.HiddenInput;
import com.idega.presentation.ui.Label;
import com.idega.presentation.ui.PasswordInput;
import com.idega.presentation.ui.TextInput;
import com.idega.util.CoreConstants;
import com.idega.util.StringUtil; |
// Password
layer = new Layer();
main.add(layer);
layer.setStyleClass("formItem");
PasswordInput passwordInput = new PasswordInput(passwordName);
cellInfo = new Label(passwordInput);
layer.add(cellInfo);
layer.add(passwordInput);
cellInfo.addText(iwrb.getLocalizedString("password", "Password"));
// Remove
layer = new Layer();
main.add(layer);
layer.setStyleClass("formItem");
GenericButton add = new GenericButton("remove", iwrb.getLocalizedString("remove", "Remove"));
layer.add(add);
add.setOnClick("UserAccessSettingsHelper.removeSingleSingOn('#"+main.getId()+ CoreConstants.JS_STR_PARAM_SEPARATOR
+ loginId+CoreConstants.JS_STR_PARAM_END);
}
private Layer getDropdownMenuForServices(IWResourceBundle iwrb){
Layer layer = new Layer();
layer.setStyleClass("formItem");
DropdownMenu dropdown = new DropdownMenu();
dropdown.setName(dropdown.getId());
dropdown.setStyleClass(addressClass);
layer.add(dropdown);
CitizenRemoteServicesHome citizenRemoteServicesHome = null;
try { | // Path: src/java/is/idega/idegaweb/egov/citizen/data/CitizenRemoteServices.java
// public interface CitizenRemoteServices extends IDOEntity {
// public String getServerName();
// public void setServerName(String name);
// public String getAddress();
// public void setAddress(String address);
// public Collection<User> getUsers() throws IDORelationshipException;
// public void addUser(User user) throws IDORelationshipException;
// public void removeUser(User user)throws IDORelationshipException;
// }
//
// Path: src/java/is/idega/idegaweb/egov/citizen/data/CitizenRemoteServicesHome.java
// public interface CitizenRemoteServicesHome extends IDOHome {
// public Collection<CitizenRemoteServices> getRemoteServicesByNames(Collection <String> names);
// public Collection<CitizenRemoteServices> getRemoteServices(int maxAmount);
// public Collection<CitizenRemoteServices> getRemoteServicesByUserId(String userId) throws IDORelationshipException ;
// }
// Path: src/java/is/idega/idegaweb/egov/citizen/presentation/SingleSingOn.java
import is.idega.idegaweb.egov.citizen.data.CitizenRemoteServices;
import is.idega.idegaweb.egov.citizen.data.CitizenRemoteServicesHome;
import java.util.Collection;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.idega.data.IDOLookup;
import com.idega.data.IDOLookupException;
import com.idega.idegaweb.IWBundle;
import com.idega.idegaweb.IWResourceBundle;
import com.idega.presentation.Block;
import com.idega.presentation.IWContext;
import com.idega.presentation.Layer;
import com.idega.presentation.ui.DropdownMenu;
import com.idega.presentation.ui.GenericButton;
import com.idega.presentation.ui.HiddenInput;
import com.idega.presentation.ui.Label;
import com.idega.presentation.ui.PasswordInput;
import com.idega.presentation.ui.TextInput;
import com.idega.util.CoreConstants;
import com.idega.util.StringUtil;
// Password
layer = new Layer();
main.add(layer);
layer.setStyleClass("formItem");
PasswordInput passwordInput = new PasswordInput(passwordName);
cellInfo = new Label(passwordInput);
layer.add(cellInfo);
layer.add(passwordInput);
cellInfo.addText(iwrb.getLocalizedString("password", "Password"));
// Remove
layer = new Layer();
main.add(layer);
layer.setStyleClass("formItem");
GenericButton add = new GenericButton("remove", iwrb.getLocalizedString("remove", "Remove"));
layer.add(add);
add.setOnClick("UserAccessSettingsHelper.removeSingleSingOn('#"+main.getId()+ CoreConstants.JS_STR_PARAM_SEPARATOR
+ loginId+CoreConstants.JS_STR_PARAM_END);
}
private Layer getDropdownMenuForServices(IWResourceBundle iwrb){
Layer layer = new Layer();
layer.setStyleClass("formItem");
DropdownMenu dropdown = new DropdownMenu();
dropdown.setName(dropdown.getId());
dropdown.setStyleClass(addressClass);
layer.add(dropdown);
CitizenRemoteServicesHome citizenRemoteServicesHome = null;
try { | citizenRemoteServicesHome = (CitizenRemoteServicesHome) IDOLookup.getHome(CitizenRemoteServices.class); |
twak/campskeleton | src/org/twak/camp/Feature.java | // Path: src/org/twak/camp/ui/Marker.java
// public class Marker extends Point2d
// {
// @Deprecated
// public Tag feature;
//
// public Bar bar;
//
// // what created this marker?
// public Object generator;
//
// @Deprecated
// public Map<String, Object> properties = new HashMap();
//
// @Deprecated
// public final static String TYPE = "type";
//
//
//
// public enum Type
// {
// AbsStart ("absolute from start"), AbsEnd ("absolute from end"), Rel ("relative");
// String name;
//
// Type(String name)
// {
// this.name = name;
// }
//
// @Override
// public String toString()
// {
// return name;
// }
// }
//
// @Deprecated
// public Marker(Tag feature) {
// this.feature = feature;
// properties.put(TYPE, Type.Rel);
// }
//
// public Marker() {
// }
// }
//
// Path: src/org/twak/camp/ui/Marker.java
// public enum Type
// {
// AbsStart ("absolute from start"), AbsEnd ("absolute from end"), Rel ("relative");
// String name;
//
// Type(String name)
// {
// this.name = name;
// }
//
// @Override
// public String toString()
// {
// return name;
// }
// }
| import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Comparator;
import javax.swing.ButtonGroup;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.JRadioButtonMenuItem;
import org.twak.camp.ui.Marker;
import org.twak.camp.ui.Marker.Type;
import org.twak.utils.ui.Rainbow; | package org.twak.camp;
/**
* "Tags" for output properties
*
* @author twak
*/
public class Feature
{
static Rainbow rainbow;
public Color color;
public String name;
String colorName;
public Feature (String name)
{
color = Rainbow.next( this.getClass() );
colorName = Rainbow.lastAsString( this.getClass() );
this.name = name;
}
public static Comparator<Feature> nameComparator = new Comparator<Feature> ()
{
public int compare( Feature o1, Feature o2 )
{
return String.CASE_INSENSITIVE_ORDER.compare(o1.name, o2.name);
}
};
@Override
public String toString()
{
return name +"("+colorName+")";
}
/**
* This menu is shown when someone clicks on the marker
* @return
*/ | // Path: src/org/twak/camp/ui/Marker.java
// public class Marker extends Point2d
// {
// @Deprecated
// public Tag feature;
//
// public Bar bar;
//
// // what created this marker?
// public Object generator;
//
// @Deprecated
// public Map<String, Object> properties = new HashMap();
//
// @Deprecated
// public final static String TYPE = "type";
//
//
//
// public enum Type
// {
// AbsStart ("absolute from start"), AbsEnd ("absolute from end"), Rel ("relative");
// String name;
//
// Type(String name)
// {
// this.name = name;
// }
//
// @Override
// public String toString()
// {
// return name;
// }
// }
//
// @Deprecated
// public Marker(Tag feature) {
// this.feature = feature;
// properties.put(TYPE, Type.Rel);
// }
//
// public Marker() {
// }
// }
//
// Path: src/org/twak/camp/ui/Marker.java
// public enum Type
// {
// AbsStart ("absolute from start"), AbsEnd ("absolute from end"), Rel ("relative");
// String name;
//
// Type(String name)
// {
// this.name = name;
// }
//
// @Override
// public String toString()
// {
// return name;
// }
// }
// Path: src/org/twak/camp/Feature.java
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Comparator;
import javax.swing.ButtonGroup;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.JRadioButtonMenuItem;
import org.twak.camp.ui.Marker;
import org.twak.camp.ui.Marker.Type;
import org.twak.utils.ui.Rainbow;
package org.twak.camp;
/**
* "Tags" for output properties
*
* @author twak
*/
public class Feature
{
static Rainbow rainbow;
public Color color;
public String name;
String colorName;
public Feature (String name)
{
color = Rainbow.next( this.getClass() );
colorName = Rainbow.lastAsString( this.getClass() );
this.name = name;
}
public static Comparator<Feature> nameComparator = new Comparator<Feature> ()
{
public int compare( Feature o1, Feature o2 )
{
return String.CASE_INSENSITIVE_ORDER.compare(o1.name, o2.name);
}
};
@Override
public String toString()
{
return name +"("+colorName+")";
}
/**
* This menu is shown when someone clicks on the marker
* @return
*/ | public JPopupMenu createMenu(final Marker m) |
twak/campskeleton | src/org/twak/camp/Feature.java | // Path: src/org/twak/camp/ui/Marker.java
// public class Marker extends Point2d
// {
// @Deprecated
// public Tag feature;
//
// public Bar bar;
//
// // what created this marker?
// public Object generator;
//
// @Deprecated
// public Map<String, Object> properties = new HashMap();
//
// @Deprecated
// public final static String TYPE = "type";
//
//
//
// public enum Type
// {
// AbsStart ("absolute from start"), AbsEnd ("absolute from end"), Rel ("relative");
// String name;
//
// Type(String name)
// {
// this.name = name;
// }
//
// @Override
// public String toString()
// {
// return name;
// }
// }
//
// @Deprecated
// public Marker(Tag feature) {
// this.feature = feature;
// properties.put(TYPE, Type.Rel);
// }
//
// public Marker() {
// }
// }
//
// Path: src/org/twak/camp/ui/Marker.java
// public enum Type
// {
// AbsStart ("absolute from start"), AbsEnd ("absolute from end"), Rel ("relative");
// String name;
//
// Type(String name)
// {
// this.name = name;
// }
//
// @Override
// public String toString()
// {
// return name;
// }
// }
| import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Comparator;
import javax.swing.ButtonGroup;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.JRadioButtonMenuItem;
import org.twak.camp.ui.Marker;
import org.twak.camp.ui.Marker.Type;
import org.twak.utils.ui.Rainbow; | colorName = Rainbow.lastAsString( this.getClass() );
this.name = name;
}
public static Comparator<Feature> nameComparator = new Comparator<Feature> ()
{
public int compare( Feature o1, Feature o2 )
{
return String.CASE_INSENSITIVE_ORDER.compare(o1.name, o2.name);
}
};
@Override
public String toString()
{
return name +"("+colorName+")";
}
/**
* This menu is shown when someone clicks on the marker
* @return
*/
public JPopupMenu createMenu(final Marker m)
{
JPopupMenu popup = new JPopupMenu();
JMenu menu = new JMenu( "type:" );
popup.add( menu );
ButtonGroup group = new ButtonGroup();
| // Path: src/org/twak/camp/ui/Marker.java
// public class Marker extends Point2d
// {
// @Deprecated
// public Tag feature;
//
// public Bar bar;
//
// // what created this marker?
// public Object generator;
//
// @Deprecated
// public Map<String, Object> properties = new HashMap();
//
// @Deprecated
// public final static String TYPE = "type";
//
//
//
// public enum Type
// {
// AbsStart ("absolute from start"), AbsEnd ("absolute from end"), Rel ("relative");
// String name;
//
// Type(String name)
// {
// this.name = name;
// }
//
// @Override
// public String toString()
// {
// return name;
// }
// }
//
// @Deprecated
// public Marker(Tag feature) {
// this.feature = feature;
// properties.put(TYPE, Type.Rel);
// }
//
// public Marker() {
// }
// }
//
// Path: src/org/twak/camp/ui/Marker.java
// public enum Type
// {
// AbsStart ("absolute from start"), AbsEnd ("absolute from end"), Rel ("relative");
// String name;
//
// Type(String name)
// {
// this.name = name;
// }
//
// @Override
// public String toString()
// {
// return name;
// }
// }
// Path: src/org/twak/camp/Feature.java
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Comparator;
import javax.swing.ButtonGroup;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.JRadioButtonMenuItem;
import org.twak.camp.ui.Marker;
import org.twak.camp.ui.Marker.Type;
import org.twak.utils.ui.Rainbow;
colorName = Rainbow.lastAsString( this.getClass() );
this.name = name;
}
public static Comparator<Feature> nameComparator = new Comparator<Feature> ()
{
public int compare( Feature o1, Feature o2 )
{
return String.CASE_INSENSITIVE_ORDER.compare(o1.name, o2.name);
}
};
@Override
public String toString()
{
return name +"("+colorName+")";
}
/**
* This menu is shown when someone clicks on the marker
* @return
*/
public JPopupMenu createMenu(final Marker m)
{
JPopupMenu popup = new JPopupMenu();
JMenu menu = new JMenu( "type:" );
popup.add( menu );
ButtonGroup group = new ButtonGroup();
| for (Type t : Marker.Type.values()) |
twak/campskeleton | src/org/twak/camp/ui/Anchor.java | // Path: src/org/twak/camp/Tag.java
// public class Tag
// {
// static Rainbow rainbow;
// public Color color;
// public String name;
// String colorName;
//
// public Tag()
// {
// this ("unnamed");
// }
//
// public Tag (String name)
// {
// color = Rainbow.next( Tag.class );
// colorName = Rainbow.lastAsString( Tag.class );
// this.name = name;
// }
//
// public static Comparator<Tag> nameComparator = new Comparator<Tag> ()
// {
// public int compare( Tag o1, Tag o2 )
// {
// return String.CASE_INSENSITIVE_ORDER.compare(o1.name, o2.name);
// }
// };
//
// @Override
// public String toString()
// {
// return name +"("+colorName+")";
// }
// }
| import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import javax.vecmath.Point2d;
import org.twak.camp.Tag; | package org.twak.camp.ui;
/**
* marks the locatino of a feature on a Bar
* @author twak
*/
public class Anchor extends Point2d
{ | // Path: src/org/twak/camp/Tag.java
// public class Tag
// {
// static Rainbow rainbow;
// public Color color;
// public String name;
// String colorName;
//
// public Tag()
// {
// this ("unnamed");
// }
//
// public Tag (String name)
// {
// color = Rainbow.next( Tag.class );
// colorName = Rainbow.lastAsString( Tag.class );
// this.name = name;
// }
//
// public static Comparator<Tag> nameComparator = new Comparator<Tag> ()
// {
// public int compare( Tag o1, Tag o2 )
// {
// return String.CASE_INSENSITIVE_ORDER.compare(o1.name, o2.name);
// }
// };
//
// @Override
// public String toString()
// {
// return name +"("+colorName+")";
// }
// }
// Path: src/org/twak/camp/ui/Anchor.java
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import javax.vecmath.Point2d;
import org.twak.camp.Tag;
package org.twak.camp.ui;
/**
* marks the locatino of a feature on a Bar
* @author twak
*/
public class Anchor extends Point2d
{ | public Tag feature; |
twak/campskeleton | src/org/twak/camp/CollisionQ.java | // Path: src/org/twak/camp/debug/DebugDevice.java
// public class DebugDevice
// {
// // global debug switch
// public static boolean debug; // change in reset(), below
// public static DebugDevice instance = new DebugDevice();
//
// public static void reset() {
// debug = false;
// instance.toDisplay.clear();
// instance.push();
// }
//
// static class Status
// {
// LoopL<Corner> corners;
// Output output;
// String name;
// public Status (String name, LoopL<Corner> corners, Output output)
// {
// this.name = name;
// this.corners = corners;
//
// // for (Corner c: corners.eIterator()) {
// // c.x += Math.random() * 1 - 0.5;
// // c.y += Math.random() * 1 - 0.5;
// // }
//
// this.output = output;
// }
//
// @Override
// public String toString() {
// return name;
// }
// }
//
// List<Status> toDisplay = new ArrayList();
// JFrame window = null;
// private JDebugDevice jDD;
//
// public static void dump ( String name, Skeleton skel )
// {
// if (!debug)
// return;
//
// instance.toDisplay.add(new Status ( skel.name+":"+name, Corner.dupeNewAll(skel.findLoopLive()), skel.output.dupeEdgesOnly() ));
// push();
// }
//
// public static void dump ( String name, LoopL<Corner> corners )
// {
// if (!debug)
// return;
//
// instance.toDisplay.add(new Status ( name, Corner.dupeNewAll(corners), null ));
// push();
// }
//
// public static void dumpPoints ( String name, LoopL<Point3d> points )
// {
// if (!debug)
// return;
//
// LoopL<Corner> loopl = new LoopL();
//
// Cache<Point3d, Corner> cCache = new Cache<Point3d, Corner>()
// {
// @Override
// public Corner create( Point3d i )
// {
// return new Corner( i.x, i.y, i.y );
// }
// };
//
// for ( Loop<Point3d> lc : points )
// {
// Loop<Corner> loop = new Loop();
// loopl.add( loop );
// for ( Loopable<Point3d> loopable : lc.loopableIterator() )
// {
// Corner me = cCache.get( loopable.get());
// Corner yu = cCache.get( loopable.get());
// loop.append( me );
// me.nextC = yu;
// yu.prevC = me;
// me.nextL = new Edge (me, yu);
// yu.prevL = me.nextL;
// }
// }
//
// instance.toDisplay.add(new Status ( name, loopl, null ));
// push();
// }
//
//
// public static void push()
// {
// if (!debug)
// return;
// instance.push_();
// }
//
// private void push_()
// {
// SwingUtilities.invokeLater(new Runnable() {
//
// public void run() {
// if (window == null) {
// window = new JFrame(this.getClass().getSimpleName());
// window.setSize(800, 800);
// window.setVisible(true);
// window.setContentPane(jDD = new JDebugDevice(DebugDevice.this));
//
// window.addWindowListener(new WindowAdapter() {
//
// @Override
// public void windowClosing(WindowEvent e) {
// DebugDevice.instance.window = null;
// }
// });
//
// }
// jDD.pingChanged();
// }
// });
// }
// }
| import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Set;
import javax.vecmath.Point3d;
import javax.vecmath.Tuple3d;
import org.twak.camp.debug.DebugDevice;
| public void holdRemoves()
{
removes.clear();
holdRemoves = true;
}
public void resumeRemoves()
{
holdRemoves = false;
for (Corner c : removes)
if (skel.liveCorners.contains( c )) // if hasn't been removed by horiz decomp
removeCorner( c );
removes.clear();
}
/**
* Given corner should be fully linked into the network. Needs to be removed as
* it connects two parallel faces. We remove toAdd.nextL
*
*
*/
private void removeCorner( Corner toAdd )
{
if ( holdRemoves )
{
removes.add( toAdd );
return;
}
| // Path: src/org/twak/camp/debug/DebugDevice.java
// public class DebugDevice
// {
// // global debug switch
// public static boolean debug; // change in reset(), below
// public static DebugDevice instance = new DebugDevice();
//
// public static void reset() {
// debug = false;
// instance.toDisplay.clear();
// instance.push();
// }
//
// static class Status
// {
// LoopL<Corner> corners;
// Output output;
// String name;
// public Status (String name, LoopL<Corner> corners, Output output)
// {
// this.name = name;
// this.corners = corners;
//
// // for (Corner c: corners.eIterator()) {
// // c.x += Math.random() * 1 - 0.5;
// // c.y += Math.random() * 1 - 0.5;
// // }
//
// this.output = output;
// }
//
// @Override
// public String toString() {
// return name;
// }
// }
//
// List<Status> toDisplay = new ArrayList();
// JFrame window = null;
// private JDebugDevice jDD;
//
// public static void dump ( String name, Skeleton skel )
// {
// if (!debug)
// return;
//
// instance.toDisplay.add(new Status ( skel.name+":"+name, Corner.dupeNewAll(skel.findLoopLive()), skel.output.dupeEdgesOnly() ));
// push();
// }
//
// public static void dump ( String name, LoopL<Corner> corners )
// {
// if (!debug)
// return;
//
// instance.toDisplay.add(new Status ( name, Corner.dupeNewAll(corners), null ));
// push();
// }
//
// public static void dumpPoints ( String name, LoopL<Point3d> points )
// {
// if (!debug)
// return;
//
// LoopL<Corner> loopl = new LoopL();
//
// Cache<Point3d, Corner> cCache = new Cache<Point3d, Corner>()
// {
// @Override
// public Corner create( Point3d i )
// {
// return new Corner( i.x, i.y, i.y );
// }
// };
//
// for ( Loop<Point3d> lc : points )
// {
// Loop<Corner> loop = new Loop();
// loopl.add( loop );
// for ( Loopable<Point3d> loopable : lc.loopableIterator() )
// {
// Corner me = cCache.get( loopable.get());
// Corner yu = cCache.get( loopable.get());
// loop.append( me );
// me.nextC = yu;
// yu.prevC = me;
// me.nextL = new Edge (me, yu);
// yu.prevL = me.nextL;
// }
// }
//
// instance.toDisplay.add(new Status ( name, loopl, null ));
// push();
// }
//
//
// public static void push()
// {
// if (!debug)
// return;
// instance.push_();
// }
//
// private void push_()
// {
// SwingUtilities.invokeLater(new Runnable() {
//
// public void run() {
// if (window == null) {
// window = new JFrame(this.getClass().getSimpleName());
// window.setSize(800, 800);
// window.setVisible(true);
// window.setContentPane(jDD = new JDebugDevice(DebugDevice.this));
//
// window.addWindowListener(new WindowAdapter() {
//
// @Override
// public void windowClosing(WindowEvent e) {
// DebugDevice.instance.window = null;
// }
// });
//
// }
// jDD.pingChanged();
// }
// });
// }
// }
// Path: src/org/twak/camp/CollisionQ.java
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Set;
import javax.vecmath.Point3d;
import javax.vecmath.Tuple3d;
import org.twak.camp.debug.DebugDevice;
public void holdRemoves()
{
removes.clear();
holdRemoves = true;
}
public void resumeRemoves()
{
holdRemoves = false;
for (Corner c : removes)
if (skel.liveCorners.contains( c )) // if hasn't been removed by horiz decomp
removeCorner( c );
removes.clear();
}
/**
* Given corner should be fully linked into the network. Needs to be removed as
* it connects two parallel faces. We remove toAdd.nextL
*
*
*/
private void removeCorner( Corner toAdd )
{
if ( holdRemoves )
{
removes.add( toAdd );
return;
}
| DebugDevice.dump("about to delete "+toAdd.toString(), skel);
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.