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 |
|---|---|---|---|---|---|---|
composable-systems/dropwizard-cassandra | src/test/java/systems/composable/dropwizard/cassandra/DropwizardCassandraIntegrationTest.java | // Path: src/test/java/systems/composable/dropwizard/cassandra/smoke/SmokeTestApp.java
// public class SmokeTestApp extends Application<SmokeTestConfiguration> {
//
// private static final Logger LOG = LoggerFactory.getLogger(SmokeTestApp.class);
//
// @Override
// public void initialize(Bootstrap<SmokeTestConfiguration> bootstrap) {
// // Prevents NoHostAvailable test errors
// try {
// Thread.sleep(1000);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// }
//
// @Override
// public void run(SmokeTestConfiguration configuration, Environment environment) throws Exception {
// LOG.debug("Running smoke test for {}", configuration.getCassandraConfig().getClusterName());
//
// final Cluster cluster = configuration.getCassandraConfig().build(environment);
// final String keyspace = configuration.getCassandraConfig().getKeyspace();
// final Session session = keyspace != null ? cluster.connect(keyspace) : cluster.connect();
//
// environment.jersey().register(new CassandraResource(session));
// }
// }
//
// Path: src/test/java/systems/composable/dropwizard/cassandra/smoke/SmokeTestConfiguration.java
// public class SmokeTestConfiguration extends Configuration {
//
// @Valid
// @NotNull
// private CassandraFactory cassandra;
//
// @JsonProperty("cassandra")
// public CassandraFactory getCassandraConfig() {
// return cassandra;
// }
//
// @JsonProperty("cassandra")
// public void setCassandraConfig(CassandraFactory cassndraConfig) {
// this.cassandra = cassndraConfig;
// }
// }
| import com.google.common.collect.Lists;
import com.google.common.io.Resources;
import io.dropwizard.testing.junit.DropwizardAppRule;
import org.junit.ClassRule;
import org.junit.Test;
import systems.composable.dropwizard.cassandra.smoke.SmokeTestApp;
import systems.composable.dropwizard.cassandra.smoke.SmokeTestConfiguration;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.UriBuilder;
import java.net.URI;
import static org.assertj.core.api.Assertions.assertThat; | /*
* Copyright 2016 Composable Systems Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package systems.composable.dropwizard.cassandra;
public class DropwizardCassandraIntegrationTest {
@ClassRule | // Path: src/test/java/systems/composable/dropwizard/cassandra/smoke/SmokeTestApp.java
// public class SmokeTestApp extends Application<SmokeTestConfiguration> {
//
// private static final Logger LOG = LoggerFactory.getLogger(SmokeTestApp.class);
//
// @Override
// public void initialize(Bootstrap<SmokeTestConfiguration> bootstrap) {
// // Prevents NoHostAvailable test errors
// try {
// Thread.sleep(1000);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// }
//
// @Override
// public void run(SmokeTestConfiguration configuration, Environment environment) throws Exception {
// LOG.debug("Running smoke test for {}", configuration.getCassandraConfig().getClusterName());
//
// final Cluster cluster = configuration.getCassandraConfig().build(environment);
// final String keyspace = configuration.getCassandraConfig().getKeyspace();
// final Session session = keyspace != null ? cluster.connect(keyspace) : cluster.connect();
//
// environment.jersey().register(new CassandraResource(session));
// }
// }
//
// Path: src/test/java/systems/composable/dropwizard/cassandra/smoke/SmokeTestConfiguration.java
// public class SmokeTestConfiguration extends Configuration {
//
// @Valid
// @NotNull
// private CassandraFactory cassandra;
//
// @JsonProperty("cassandra")
// public CassandraFactory getCassandraConfig() {
// return cassandra;
// }
//
// @JsonProperty("cassandra")
// public void setCassandraConfig(CassandraFactory cassndraConfig) {
// this.cassandra = cassndraConfig;
// }
// }
// Path: src/test/java/systems/composable/dropwizard/cassandra/DropwizardCassandraIntegrationTest.java
import com.google.common.collect.Lists;
import com.google.common.io.Resources;
import io.dropwizard.testing.junit.DropwizardAppRule;
import org.junit.ClassRule;
import org.junit.Test;
import systems.composable.dropwizard.cassandra.smoke.SmokeTestApp;
import systems.composable.dropwizard.cassandra.smoke.SmokeTestConfiguration;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.UriBuilder;
import java.net.URI;
import static org.assertj.core.api.Assertions.assertThat;
/*
* Copyright 2016 Composable Systems Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package systems.composable.dropwizard.cassandra;
public class DropwizardCassandraIntegrationTest {
@ClassRule | public static final DropwizardAppRule<SmokeTestConfiguration> APP = |
composable-systems/dropwizard-cassandra | src/test/java/systems/composable/dropwizard/cassandra/DropwizardCassandraIntegrationTest.java | // Path: src/test/java/systems/composable/dropwizard/cassandra/smoke/SmokeTestApp.java
// public class SmokeTestApp extends Application<SmokeTestConfiguration> {
//
// private static final Logger LOG = LoggerFactory.getLogger(SmokeTestApp.class);
//
// @Override
// public void initialize(Bootstrap<SmokeTestConfiguration> bootstrap) {
// // Prevents NoHostAvailable test errors
// try {
// Thread.sleep(1000);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// }
//
// @Override
// public void run(SmokeTestConfiguration configuration, Environment environment) throws Exception {
// LOG.debug("Running smoke test for {}", configuration.getCassandraConfig().getClusterName());
//
// final Cluster cluster = configuration.getCassandraConfig().build(environment);
// final String keyspace = configuration.getCassandraConfig().getKeyspace();
// final Session session = keyspace != null ? cluster.connect(keyspace) : cluster.connect();
//
// environment.jersey().register(new CassandraResource(session));
// }
// }
//
// Path: src/test/java/systems/composable/dropwizard/cassandra/smoke/SmokeTestConfiguration.java
// public class SmokeTestConfiguration extends Configuration {
//
// @Valid
// @NotNull
// private CassandraFactory cassandra;
//
// @JsonProperty("cassandra")
// public CassandraFactory getCassandraConfig() {
// return cassandra;
// }
//
// @JsonProperty("cassandra")
// public void setCassandraConfig(CassandraFactory cassndraConfig) {
// this.cassandra = cassndraConfig;
// }
// }
| import com.google.common.collect.Lists;
import com.google.common.io.Resources;
import io.dropwizard.testing.junit.DropwizardAppRule;
import org.junit.ClassRule;
import org.junit.Test;
import systems.composable.dropwizard.cassandra.smoke.SmokeTestApp;
import systems.composable.dropwizard.cassandra.smoke.SmokeTestConfiguration;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.UriBuilder;
import java.net.URI;
import static org.assertj.core.api.Assertions.assertThat; | /*
* Copyright 2016 Composable Systems Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package systems.composable.dropwizard.cassandra;
public class DropwizardCassandraIntegrationTest {
@ClassRule
public static final DropwizardAppRule<SmokeTestConfiguration> APP = | // Path: src/test/java/systems/composable/dropwizard/cassandra/smoke/SmokeTestApp.java
// public class SmokeTestApp extends Application<SmokeTestConfiguration> {
//
// private static final Logger LOG = LoggerFactory.getLogger(SmokeTestApp.class);
//
// @Override
// public void initialize(Bootstrap<SmokeTestConfiguration> bootstrap) {
// // Prevents NoHostAvailable test errors
// try {
// Thread.sleep(1000);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// }
//
// @Override
// public void run(SmokeTestConfiguration configuration, Environment environment) throws Exception {
// LOG.debug("Running smoke test for {}", configuration.getCassandraConfig().getClusterName());
//
// final Cluster cluster = configuration.getCassandraConfig().build(environment);
// final String keyspace = configuration.getCassandraConfig().getKeyspace();
// final Session session = keyspace != null ? cluster.connect(keyspace) : cluster.connect();
//
// environment.jersey().register(new CassandraResource(session));
// }
// }
//
// Path: src/test/java/systems/composable/dropwizard/cassandra/smoke/SmokeTestConfiguration.java
// public class SmokeTestConfiguration extends Configuration {
//
// @Valid
// @NotNull
// private CassandraFactory cassandra;
//
// @JsonProperty("cassandra")
// public CassandraFactory getCassandraConfig() {
// return cassandra;
// }
//
// @JsonProperty("cassandra")
// public void setCassandraConfig(CassandraFactory cassndraConfig) {
// this.cassandra = cassndraConfig;
// }
// }
// Path: src/test/java/systems/composable/dropwizard/cassandra/DropwizardCassandraIntegrationTest.java
import com.google.common.collect.Lists;
import com.google.common.io.Resources;
import io.dropwizard.testing.junit.DropwizardAppRule;
import org.junit.ClassRule;
import org.junit.Test;
import systems.composable.dropwizard.cassandra.smoke.SmokeTestApp;
import systems.composable.dropwizard.cassandra.smoke.SmokeTestConfiguration;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.UriBuilder;
import java.net.URI;
import static org.assertj.core.api.Assertions.assertThat;
/*
* Copyright 2016 Composable Systems Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package systems.composable.dropwizard.cassandra;
public class DropwizardCassandraIntegrationTest {
@ClassRule
public static final DropwizardAppRule<SmokeTestConfiguration> APP = | new DropwizardAppRule<>(SmokeTestApp.class, Resources.getResource("minimal.yml").getPath()); |
composable-systems/dropwizard-cassandra | src/test/java/systems/composable/dropwizard/cassandra/smoke/SmokeInjectedApp.java | // Path: src/test/java/systems/composable/dropwizard/cassandra/CassandraInjectedResource.java
// @Path("/")
// @Produces(MediaType.APPLICATION_JSON)
// public class CassandraInjectedResource {
//
// @Context Cluster cluster;
// @Context Session session;
//
// private List<String> query(Session session) {
// final ResultSet resultSet = session.execute("SELECT * FROM system_schema.columns");
// return resultSet.all().stream()
// .map(r -> r.getString(0))
// .collect(Collectors.toList());
// }
//
// @GET
// @Path("/querySessionField")
// public List<String> querySessionField() {
// return query(session);
// }
//
// @GET
// @Path("/querySessionParameter")
// public List<String> querySessionParameter(@Context Session session) {
// return query(session);
// }
//
// @GET
// @Path("/queryClusterField")
// public List<String> queryClusterField() {
// try (Session session = cluster.connect()) {
// return query(session);
// }
// }
// }
| import io.dropwizard.Application;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import systems.composable.dropwizard.cassandra.CassandraBundle;
import systems.composable.dropwizard.cassandra.CassandraFactory;
import systems.composable.dropwizard.cassandra.CassandraInjectedResource; | /*
* Copyright 2017 Composable Systems Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package systems.composable.dropwizard.cassandra.smoke;
public class SmokeInjectedApp extends Application<SmokeTestConfiguration> {
private static final Logger LOG = LoggerFactory.getLogger(SmokeInjectedApp.class);
@Override
public void initialize(Bootstrap<SmokeTestConfiguration> bootstrap) {
// Prevents NoHostAvailable test errors
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
bootstrap.addBundle(new CassandraBundle<SmokeTestConfiguration>() {
@Override
public CassandraFactory getCassandraFactory(SmokeTestConfiguration configuration) {
return configuration.getCassandraConfig();
}
});
}
@Override
public void run(SmokeTestConfiguration configuration, Environment environment) throws Exception {
LOG.debug("Running smoke test for {}", configuration.getCassandraConfig().getClusterName()); | // Path: src/test/java/systems/composable/dropwizard/cassandra/CassandraInjectedResource.java
// @Path("/")
// @Produces(MediaType.APPLICATION_JSON)
// public class CassandraInjectedResource {
//
// @Context Cluster cluster;
// @Context Session session;
//
// private List<String> query(Session session) {
// final ResultSet resultSet = session.execute("SELECT * FROM system_schema.columns");
// return resultSet.all().stream()
// .map(r -> r.getString(0))
// .collect(Collectors.toList());
// }
//
// @GET
// @Path("/querySessionField")
// public List<String> querySessionField() {
// return query(session);
// }
//
// @GET
// @Path("/querySessionParameter")
// public List<String> querySessionParameter(@Context Session session) {
// return query(session);
// }
//
// @GET
// @Path("/queryClusterField")
// public List<String> queryClusterField() {
// try (Session session = cluster.connect()) {
// return query(session);
// }
// }
// }
// Path: src/test/java/systems/composable/dropwizard/cassandra/smoke/SmokeInjectedApp.java
import io.dropwizard.Application;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import systems.composable.dropwizard.cassandra.CassandraBundle;
import systems.composable.dropwizard.cassandra.CassandraFactory;
import systems.composable.dropwizard.cassandra.CassandraInjectedResource;
/*
* Copyright 2017 Composable Systems Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package systems.composable.dropwizard.cassandra.smoke;
public class SmokeInjectedApp extends Application<SmokeTestConfiguration> {
private static final Logger LOG = LoggerFactory.getLogger(SmokeInjectedApp.class);
@Override
public void initialize(Bootstrap<SmokeTestConfiguration> bootstrap) {
// Prevents NoHostAvailable test errors
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
bootstrap.addBundle(new CassandraBundle<SmokeTestConfiguration>() {
@Override
public CassandraFactory getCassandraFactory(SmokeTestConfiguration configuration) {
return configuration.getCassandraConfig();
}
});
}
@Override
public void run(SmokeTestConfiguration configuration, Environment environment) throws Exception {
LOG.debug("Running smoke test for {}", configuration.getCassandraConfig().getClusterName()); | environment.jersey().register(new CassandraInjectedResource()); |
composable-systems/dropwizard-cassandra | src/test/java/systems/composable/dropwizard/cassandra/DropwizardInjectionIntegrationTest.java | // Path: src/test/java/systems/composable/dropwizard/cassandra/smoke/SmokeInjectedApp.java
// public class SmokeInjectedApp extends Application<SmokeTestConfiguration> {
//
// private static final Logger LOG = LoggerFactory.getLogger(SmokeInjectedApp.class);
//
// @Override
// public void initialize(Bootstrap<SmokeTestConfiguration> bootstrap) {
// // Prevents NoHostAvailable test errors
// try {
// Thread.sleep(1000);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// bootstrap.addBundle(new CassandraBundle<SmokeTestConfiguration>() {
// @Override
// public CassandraFactory getCassandraFactory(SmokeTestConfiguration configuration) {
// return configuration.getCassandraConfig();
// }
// });
// }
//
// @Override
// public void run(SmokeTestConfiguration configuration, Environment environment) throws Exception {
// LOG.debug("Running smoke test for {}", configuration.getCassandraConfig().getClusterName());
// environment.jersey().register(new CassandraInjectedResource());
// }
// }
//
// Path: src/test/java/systems/composable/dropwizard/cassandra/smoke/SmokeTestConfiguration.java
// public class SmokeTestConfiguration extends Configuration {
//
// @Valid
// @NotNull
// private CassandraFactory cassandra;
//
// @JsonProperty("cassandra")
// public CassandraFactory getCassandraConfig() {
// return cassandra;
// }
//
// @JsonProperty("cassandra")
// public void setCassandraConfig(CassandraFactory cassndraConfig) {
// this.cassandra = cassndraConfig;
// }
// }
| import com.google.common.collect.Lists;
import com.google.common.io.Resources;
import io.dropwizard.testing.junit.DropwizardAppRule;
import org.junit.ClassRule;
import org.junit.Test;
import systems.composable.dropwizard.cassandra.smoke.SmokeInjectedApp;
import systems.composable.dropwizard.cassandra.smoke.SmokeTestConfiguration;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.UriBuilder;
import static org.assertj.core.api.Assertions.assertThat; | /*
* Copyright 2017 Composable Systems Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package systems.composable.dropwizard.cassandra;
public class DropwizardInjectionIntegrationTest {
@ClassRule | // Path: src/test/java/systems/composable/dropwizard/cassandra/smoke/SmokeInjectedApp.java
// public class SmokeInjectedApp extends Application<SmokeTestConfiguration> {
//
// private static final Logger LOG = LoggerFactory.getLogger(SmokeInjectedApp.class);
//
// @Override
// public void initialize(Bootstrap<SmokeTestConfiguration> bootstrap) {
// // Prevents NoHostAvailable test errors
// try {
// Thread.sleep(1000);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// bootstrap.addBundle(new CassandraBundle<SmokeTestConfiguration>() {
// @Override
// public CassandraFactory getCassandraFactory(SmokeTestConfiguration configuration) {
// return configuration.getCassandraConfig();
// }
// });
// }
//
// @Override
// public void run(SmokeTestConfiguration configuration, Environment environment) throws Exception {
// LOG.debug("Running smoke test for {}", configuration.getCassandraConfig().getClusterName());
// environment.jersey().register(new CassandraInjectedResource());
// }
// }
//
// Path: src/test/java/systems/composable/dropwizard/cassandra/smoke/SmokeTestConfiguration.java
// public class SmokeTestConfiguration extends Configuration {
//
// @Valid
// @NotNull
// private CassandraFactory cassandra;
//
// @JsonProperty("cassandra")
// public CassandraFactory getCassandraConfig() {
// return cassandra;
// }
//
// @JsonProperty("cassandra")
// public void setCassandraConfig(CassandraFactory cassndraConfig) {
// this.cassandra = cassndraConfig;
// }
// }
// Path: src/test/java/systems/composable/dropwizard/cassandra/DropwizardInjectionIntegrationTest.java
import com.google.common.collect.Lists;
import com.google.common.io.Resources;
import io.dropwizard.testing.junit.DropwizardAppRule;
import org.junit.ClassRule;
import org.junit.Test;
import systems.composable.dropwizard.cassandra.smoke.SmokeInjectedApp;
import systems.composable.dropwizard.cassandra.smoke.SmokeTestConfiguration;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.UriBuilder;
import static org.assertj.core.api.Assertions.assertThat;
/*
* Copyright 2017 Composable Systems Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package systems.composable.dropwizard.cassandra;
public class DropwizardInjectionIntegrationTest {
@ClassRule | public static final DropwizardAppRule<SmokeTestConfiguration> APP = |
composable-systems/dropwizard-cassandra | src/test/java/systems/composable/dropwizard/cassandra/DropwizardInjectionIntegrationTest.java | // Path: src/test/java/systems/composable/dropwizard/cassandra/smoke/SmokeInjectedApp.java
// public class SmokeInjectedApp extends Application<SmokeTestConfiguration> {
//
// private static final Logger LOG = LoggerFactory.getLogger(SmokeInjectedApp.class);
//
// @Override
// public void initialize(Bootstrap<SmokeTestConfiguration> bootstrap) {
// // Prevents NoHostAvailable test errors
// try {
// Thread.sleep(1000);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// bootstrap.addBundle(new CassandraBundle<SmokeTestConfiguration>() {
// @Override
// public CassandraFactory getCassandraFactory(SmokeTestConfiguration configuration) {
// return configuration.getCassandraConfig();
// }
// });
// }
//
// @Override
// public void run(SmokeTestConfiguration configuration, Environment environment) throws Exception {
// LOG.debug("Running smoke test for {}", configuration.getCassandraConfig().getClusterName());
// environment.jersey().register(new CassandraInjectedResource());
// }
// }
//
// Path: src/test/java/systems/composable/dropwizard/cassandra/smoke/SmokeTestConfiguration.java
// public class SmokeTestConfiguration extends Configuration {
//
// @Valid
// @NotNull
// private CassandraFactory cassandra;
//
// @JsonProperty("cassandra")
// public CassandraFactory getCassandraConfig() {
// return cassandra;
// }
//
// @JsonProperty("cassandra")
// public void setCassandraConfig(CassandraFactory cassndraConfig) {
// this.cassandra = cassndraConfig;
// }
// }
| import com.google.common.collect.Lists;
import com.google.common.io.Resources;
import io.dropwizard.testing.junit.DropwizardAppRule;
import org.junit.ClassRule;
import org.junit.Test;
import systems.composable.dropwizard.cassandra.smoke.SmokeInjectedApp;
import systems.composable.dropwizard.cassandra.smoke.SmokeTestConfiguration;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.UriBuilder;
import static org.assertj.core.api.Assertions.assertThat; | /*
* Copyright 2017 Composable Systems Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package systems.composable.dropwizard.cassandra;
public class DropwizardInjectionIntegrationTest {
@ClassRule
public static final DropwizardAppRule<SmokeTestConfiguration> APP = | // Path: src/test/java/systems/composable/dropwizard/cassandra/smoke/SmokeInjectedApp.java
// public class SmokeInjectedApp extends Application<SmokeTestConfiguration> {
//
// private static final Logger LOG = LoggerFactory.getLogger(SmokeInjectedApp.class);
//
// @Override
// public void initialize(Bootstrap<SmokeTestConfiguration> bootstrap) {
// // Prevents NoHostAvailable test errors
// try {
// Thread.sleep(1000);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// bootstrap.addBundle(new CassandraBundle<SmokeTestConfiguration>() {
// @Override
// public CassandraFactory getCassandraFactory(SmokeTestConfiguration configuration) {
// return configuration.getCassandraConfig();
// }
// });
// }
//
// @Override
// public void run(SmokeTestConfiguration configuration, Environment environment) throws Exception {
// LOG.debug("Running smoke test for {}", configuration.getCassandraConfig().getClusterName());
// environment.jersey().register(new CassandraInjectedResource());
// }
// }
//
// Path: src/test/java/systems/composable/dropwizard/cassandra/smoke/SmokeTestConfiguration.java
// public class SmokeTestConfiguration extends Configuration {
//
// @Valid
// @NotNull
// private CassandraFactory cassandra;
//
// @JsonProperty("cassandra")
// public CassandraFactory getCassandraConfig() {
// return cassandra;
// }
//
// @JsonProperty("cassandra")
// public void setCassandraConfig(CassandraFactory cassndraConfig) {
// this.cassandra = cassndraConfig;
// }
// }
// Path: src/test/java/systems/composable/dropwizard/cassandra/DropwizardInjectionIntegrationTest.java
import com.google.common.collect.Lists;
import com.google.common.io.Resources;
import io.dropwizard.testing.junit.DropwizardAppRule;
import org.junit.ClassRule;
import org.junit.Test;
import systems.composable.dropwizard.cassandra.smoke.SmokeInjectedApp;
import systems.composable.dropwizard.cassandra.smoke.SmokeTestConfiguration;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.UriBuilder;
import static org.assertj.core.api.Assertions.assertThat;
/*
* Copyright 2017 Composable Systems Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package systems.composable.dropwizard.cassandra;
public class DropwizardInjectionIntegrationTest {
@ClassRule
public static final DropwizardAppRule<SmokeTestConfiguration> APP = | new DropwizardAppRule<>(SmokeInjectedApp.class, Resources.getResource("minimal.yml").getPath()); |
kkucherenkov/FxCameraApp | src/com/af/experiments/FxCameraApp/shaders/GlPreviewShader.java | // Path: src/com/af/experiments/FxCameraApp/Utils/OpenGlUtils.java
// public static final int GL_TEXTURE_EXTERNAL_OES = 0x8D65;
| import static android.opengl.GLES20.*;
import static com.af.experiments.FxCameraApp.Utils.OpenGlUtils.GL_TEXTURE_EXTERNAL_OES; | package com.af.experiments.FxCameraApp.shaders;
public class GlPreviewShader extends GlShader{
private static final String VERTEX_SHADER =
"uniform mat4 uMVPMatrix;\n" +
"uniform mat4 uSTMatrix;\n" +
"uniform float uCRatio;\n" +
"attribute vec4 aPosition;\n" +
"attribute vec4 aTextureCoord;\n" +
"varying highp vec2 vTextureCoord;\n" +
"void main() {\n" +
"vec4 scaledPos = aPosition;\n" +
"scaledPos.x = scaledPos.x * uCRatio;\n" +
"gl_Position = uMVPMatrix * scaledPos;\n" +
"vTextureCoord = (uSTMatrix * aTextureCoord).xy;\n" +
"}\n";
private final int mTexTarget;
public GlPreviewShader(final int texTarget) {
super(VERTEX_SHADER, createFragmentShaderSourceOESIfNeed(texTarget));
mTexTarget = texTarget;
}
private static String createFragmentShaderSourceOESIfNeed(final int texTarget) { | // Path: src/com/af/experiments/FxCameraApp/Utils/OpenGlUtils.java
// public static final int GL_TEXTURE_EXTERNAL_OES = 0x8D65;
// Path: src/com/af/experiments/FxCameraApp/shaders/GlPreviewShader.java
import static android.opengl.GLES20.*;
import static com.af.experiments.FxCameraApp.Utils.OpenGlUtils.GL_TEXTURE_EXTERNAL_OES;
package com.af.experiments.FxCameraApp.shaders;
public class GlPreviewShader extends GlShader{
private static final String VERTEX_SHADER =
"uniform mat4 uMVPMatrix;\n" +
"uniform mat4 uSTMatrix;\n" +
"uniform float uCRatio;\n" +
"attribute vec4 aPosition;\n" +
"attribute vec4 aTextureCoord;\n" +
"varying highp vec2 vTextureCoord;\n" +
"void main() {\n" +
"vec4 scaledPos = aPosition;\n" +
"scaledPos.x = scaledPos.x * uCRatio;\n" +
"gl_Position = uMVPMatrix * scaledPos;\n" +
"vTextureCoord = (uSTMatrix * aTextureCoord).xy;\n" +
"}\n";
private final int mTexTarget;
public GlPreviewShader(final int texTarget) {
super(VERTEX_SHADER, createFragmentShaderSourceOESIfNeed(texTarget));
mTexTarget = texTarget;
}
private static String createFragmentShaderSourceOESIfNeed(final int texTarget) { | if (texTarget == GL_TEXTURE_EXTERNAL_OES) { |
kkucherenkov/FxCameraApp | src/com/af/experiments/FxCameraApp/ogles/GlPreviewTextureFactory.java | // Path: src/com/af/experiments/FxCameraApp/View/PreviewTexture.java
// public interface PreviewTexture {
//
// public interface OnFrameAvailableListener {
// void onFrameAvailable(PreviewTexture previewTexture);
// }
//
// void setOnFrameAvailableListener(final OnFrameAvailableListener l);
//
// int getTextureTarget();
//
// void setup(CameraHelper camera) throws IOException;
//
// void updateTexImage();
//
// void getTransformMatrix(float[] mtx);
//
// }
| import com.af.experiments.FxCameraApp.View.PreviewTexture; | package com.af.experiments.FxCameraApp.ogles;
public class GlPreviewTextureFactory {
private static final int HONYCOMB = 11;
| // Path: src/com/af/experiments/FxCameraApp/View/PreviewTexture.java
// public interface PreviewTexture {
//
// public interface OnFrameAvailableListener {
// void onFrameAvailable(PreviewTexture previewTexture);
// }
//
// void setOnFrameAvailableListener(final OnFrameAvailableListener l);
//
// int getTextureTarget();
//
// void setup(CameraHelper camera) throws IOException;
//
// void updateTexImage();
//
// void getTransformMatrix(float[] mtx);
//
// }
// Path: src/com/af/experiments/FxCameraApp/ogles/GlPreviewTextureFactory.java
import com.af.experiments.FxCameraApp.View.PreviewTexture;
package com.af.experiments.FxCameraApp.ogles;
public class GlPreviewTextureFactory {
private static final int HONYCOMB = 11;
| public static PreviewTexture newPreviewTexture(final int texName) { |
kkucherenkov/FxCameraApp | src/com/af/experiments/FxCameraApp/shaders/GlPerlinNoiseShader.java | // Path: src/com/af/experiments/FxCameraApp/renderer/GLES20FramebufferObject.java
// public class GLES20FramebufferObject {
//
// private int mWidth;
// private int mHeight;
// private int mFramebufferName;
// private int mRenderbufferName;
// private int mTexName;
//
// public int getWidth() {
// return mWidth;
// }
// public int getHeight() {
// return mHeight;
// }
// public int getTexName() {
// return mTexName;
// }
//
// public void setup(final int width, final int height) {
// final int[] args = new int[1];
// glGetIntegerv(GL_MAX_TEXTURE_SIZE, args, 0);
// if (width > args[0] || height > args[0]) {
// throw new IllegalArgumentException("GL_MAX_TEXTURE_SIZE " + args[0]);
// }
//
// glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, args, 0);
// if (width > args[0] || height > args[0]) {
// throw new IllegalArgumentException("GL_MAX_RENDERBUFFER_SIZE " + args[0]);
// }
//
// glGetIntegerv(GL_FRAMEBUFFER_BINDING, args, 0);
// final int saveFramebuffer = args[0];
// glGetIntegerv(GL_RENDERBUFFER_BINDING, args, 0);
// final int saveRenderbuffer = args[0];
// glGetIntegerv(GL_TEXTURE_BINDING_2D, args, 0);
// final int saveTexName = args[0];
//
// release();
//
// try {
// mWidth = width;
// mHeight = height;
//
// glGenFramebuffers(args.length, args, 0);
// mFramebufferName = args[0];
// glBindFramebuffer(GL_FRAMEBUFFER, mFramebufferName);
//
// glGenRenderbuffers(args.length, args, 0);
// mRenderbufferName = args[0];
// glBindRenderbuffer(GL_RENDERBUFFER, mRenderbufferName);
// glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height);
// glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, mRenderbufferName);
//
// glGenTextures(args.length, args, 0);
// mTexName = args[0];
// glBindTexture(GL_TEXTURE_2D, mTexName);
//
// OpenGlUtils.setupSampler(GL_TEXTURE_2D, GL_LINEAR, GL_NEAREST);
//
// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, null);
// glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mTexName, 0);
//
// final int status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
// if (status != GL_FRAMEBUFFER_COMPLETE) {
// throw new RuntimeException("Failed to initialize framebuffer object " + status);
// }
// } catch (final RuntimeException e) {
// release();
// throw e;
// }
//
// glBindFramebuffer(GL_FRAMEBUFFER, saveFramebuffer);
// glBindRenderbuffer(GL_RENDERBUFFER, saveRenderbuffer);
// glBindTexture(GL_TEXTURE_2D, saveTexName);
// }
//
// public void release() {
// final int[] args = new int[1];
// args[0] = mTexName;
// glDeleteTextures(args.length, args, 0);
// mTexName = 0;
// args[0] = mRenderbufferName;
// glDeleteRenderbuffers(args.length, args, 0);
// mRenderbufferName = 0;
// args[0] = mFramebufferName;
// glDeleteFramebuffers(args.length, args, 0);
// mFramebufferName = 0;
// }
//
// public void enable() {
// glBindFramebuffer(GL_FRAMEBUFFER, mFramebufferName);
// }
//
// public Bitmap getBitmap() {
// return getBitmap(0, false);
// }
//
// public Bitmap getBitmap(final int orientation) {
// return getBitmap(orientation, false);
// }
//
// public Bitmap getBitmap(final int orientation, final boolean mirror) {
// final int[] pixels = new int[mWidth * mHeight];
// final IntBuffer buffer = IntBuffer.wrap(pixels);
// buffer.position(0);
//
// enable();
// glReadPixels(0, 0, mWidth, mHeight, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
// glBindFramebuffer(GL_FRAMEBUFFER, 0);
//
// return OpenGlUtils.createBitmap(pixels, mWidth, mHeight, Bitmap.Config.ARGB_8888, orientation, mirror);
// }
//
// }
| import com.af.experiments.FxCameraApp.renderer.GLES20FramebufferObject;
import static android.opengl.GLES20.*;
| "float n00 = dot(g00, vec2(fx.x, fy.x));" +
"float n10 = dot(g10, vec2(fx.y, fy.y));" +
"float n01 = dot(g01, vec2(fx.z, fy.z));" +
"float n11 = dot(g11, vec2(fx.w, fy.w));" +
"vec2 fade_xy = fade(Pf.xy);" +
"vec2 n_x = mix(vec2(n00, n01), vec2(n10, n11), fade_xy.x);" +
"float n_xy = mix(n_x.x, n_x.y, fade_xy.y);" +
"return 2.3 * n_xy;" +
"}" +
"void main() {" +
"float n1 = (cnoise(vTextureCoord * scale) + 1.0) / 2.0;" +
"vec4 colorDiff = colorFinish - colorStart;" +
"vec4 color = colorStart + colorDiff * n1;" +
"gl_FragColor = color;" +
"}";
private float mScale = 8.0f;
private float[] mColorStart = new float[]{ 0.0f, 0.0f, 0.0f, 1.0f };
private float[] mColorFinish = new float[]{ 1.0f, 1.0f, 1.0f, 1.0f };
public GlPerlinNoiseShader() {
super(DEFAULT_VERTEX_SHADER, FRAGMENT_SHADER);
}
@Override
| // Path: src/com/af/experiments/FxCameraApp/renderer/GLES20FramebufferObject.java
// public class GLES20FramebufferObject {
//
// private int mWidth;
// private int mHeight;
// private int mFramebufferName;
// private int mRenderbufferName;
// private int mTexName;
//
// public int getWidth() {
// return mWidth;
// }
// public int getHeight() {
// return mHeight;
// }
// public int getTexName() {
// return mTexName;
// }
//
// public void setup(final int width, final int height) {
// final int[] args = new int[1];
// glGetIntegerv(GL_MAX_TEXTURE_SIZE, args, 0);
// if (width > args[0] || height > args[0]) {
// throw new IllegalArgumentException("GL_MAX_TEXTURE_SIZE " + args[0]);
// }
//
// glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, args, 0);
// if (width > args[0] || height > args[0]) {
// throw new IllegalArgumentException("GL_MAX_RENDERBUFFER_SIZE " + args[0]);
// }
//
// glGetIntegerv(GL_FRAMEBUFFER_BINDING, args, 0);
// final int saveFramebuffer = args[0];
// glGetIntegerv(GL_RENDERBUFFER_BINDING, args, 0);
// final int saveRenderbuffer = args[0];
// glGetIntegerv(GL_TEXTURE_BINDING_2D, args, 0);
// final int saveTexName = args[0];
//
// release();
//
// try {
// mWidth = width;
// mHeight = height;
//
// glGenFramebuffers(args.length, args, 0);
// mFramebufferName = args[0];
// glBindFramebuffer(GL_FRAMEBUFFER, mFramebufferName);
//
// glGenRenderbuffers(args.length, args, 0);
// mRenderbufferName = args[0];
// glBindRenderbuffer(GL_RENDERBUFFER, mRenderbufferName);
// glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height);
// glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, mRenderbufferName);
//
// glGenTextures(args.length, args, 0);
// mTexName = args[0];
// glBindTexture(GL_TEXTURE_2D, mTexName);
//
// OpenGlUtils.setupSampler(GL_TEXTURE_2D, GL_LINEAR, GL_NEAREST);
//
// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, null);
// glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mTexName, 0);
//
// final int status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
// if (status != GL_FRAMEBUFFER_COMPLETE) {
// throw new RuntimeException("Failed to initialize framebuffer object " + status);
// }
// } catch (final RuntimeException e) {
// release();
// throw e;
// }
//
// glBindFramebuffer(GL_FRAMEBUFFER, saveFramebuffer);
// glBindRenderbuffer(GL_RENDERBUFFER, saveRenderbuffer);
// glBindTexture(GL_TEXTURE_2D, saveTexName);
// }
//
// public void release() {
// final int[] args = new int[1];
// args[0] = mTexName;
// glDeleteTextures(args.length, args, 0);
// mTexName = 0;
// args[0] = mRenderbufferName;
// glDeleteRenderbuffers(args.length, args, 0);
// mRenderbufferName = 0;
// args[0] = mFramebufferName;
// glDeleteFramebuffers(args.length, args, 0);
// mFramebufferName = 0;
// }
//
// public void enable() {
// glBindFramebuffer(GL_FRAMEBUFFER, mFramebufferName);
// }
//
// public Bitmap getBitmap() {
// return getBitmap(0, false);
// }
//
// public Bitmap getBitmap(final int orientation) {
// return getBitmap(orientation, false);
// }
//
// public Bitmap getBitmap(final int orientation, final boolean mirror) {
// final int[] pixels = new int[mWidth * mHeight];
// final IntBuffer buffer = IntBuffer.wrap(pixels);
// buffer.position(0);
//
// enable();
// glReadPixels(0, 0, mWidth, mHeight, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
// glBindFramebuffer(GL_FRAMEBUFFER, 0);
//
// return OpenGlUtils.createBitmap(pixels, mWidth, mHeight, Bitmap.Config.ARGB_8888, orientation, mirror);
// }
//
// }
// Path: src/com/af/experiments/FxCameraApp/shaders/GlPerlinNoiseShader.java
import com.af.experiments.FxCameraApp.renderer.GLES20FramebufferObject;
import static android.opengl.GLES20.*;
"float n00 = dot(g00, vec2(fx.x, fy.x));" +
"float n10 = dot(g10, vec2(fx.y, fy.y));" +
"float n01 = dot(g01, vec2(fx.z, fy.z));" +
"float n11 = dot(g11, vec2(fx.w, fy.w));" +
"vec2 fade_xy = fade(Pf.xy);" +
"vec2 n_x = mix(vec2(n00, n01), vec2(n10, n11), fade_xy.x);" +
"float n_xy = mix(n_x.x, n_x.y, fade_xy.y);" +
"return 2.3 * n_xy;" +
"}" +
"void main() {" +
"float n1 = (cnoise(vTextureCoord * scale) + 1.0) / 2.0;" +
"vec4 colorDiff = colorFinish - colorStart;" +
"vec4 color = colorStart + colorDiff * n1;" +
"gl_FragColor = color;" +
"}";
private float mScale = 8.0f;
private float[] mColorStart = new float[]{ 0.0f, 0.0f, 0.0f, 1.0f };
private float[] mColorFinish = new float[]{ 1.0f, 1.0f, 1.0f, 1.0f };
public GlPerlinNoiseShader() {
super(DEFAULT_VERTEX_SHADER, FRAGMENT_SHADER);
}
@Override
| public void draw(final int texName, final GLES20FramebufferObject fbo) {
|
kkucherenkov/FxCameraApp | src/com/af/experiments/FxCameraApp/shaders/GlShaderGroup.java | // Path: src/com/af/experiments/FxCameraApp/renderer/GLES20FramebufferObject.java
// public class GLES20FramebufferObject {
//
// private int mWidth;
// private int mHeight;
// private int mFramebufferName;
// private int mRenderbufferName;
// private int mTexName;
//
// public int getWidth() {
// return mWidth;
// }
// public int getHeight() {
// return mHeight;
// }
// public int getTexName() {
// return mTexName;
// }
//
// public void setup(final int width, final int height) {
// final int[] args = new int[1];
// glGetIntegerv(GL_MAX_TEXTURE_SIZE, args, 0);
// if (width > args[0] || height > args[0]) {
// throw new IllegalArgumentException("GL_MAX_TEXTURE_SIZE " + args[0]);
// }
//
// glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, args, 0);
// if (width > args[0] || height > args[0]) {
// throw new IllegalArgumentException("GL_MAX_RENDERBUFFER_SIZE " + args[0]);
// }
//
// glGetIntegerv(GL_FRAMEBUFFER_BINDING, args, 0);
// final int saveFramebuffer = args[0];
// glGetIntegerv(GL_RENDERBUFFER_BINDING, args, 0);
// final int saveRenderbuffer = args[0];
// glGetIntegerv(GL_TEXTURE_BINDING_2D, args, 0);
// final int saveTexName = args[0];
//
// release();
//
// try {
// mWidth = width;
// mHeight = height;
//
// glGenFramebuffers(args.length, args, 0);
// mFramebufferName = args[0];
// glBindFramebuffer(GL_FRAMEBUFFER, mFramebufferName);
//
// glGenRenderbuffers(args.length, args, 0);
// mRenderbufferName = args[0];
// glBindRenderbuffer(GL_RENDERBUFFER, mRenderbufferName);
// glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height);
// glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, mRenderbufferName);
//
// glGenTextures(args.length, args, 0);
// mTexName = args[0];
// glBindTexture(GL_TEXTURE_2D, mTexName);
//
// OpenGlUtils.setupSampler(GL_TEXTURE_2D, GL_LINEAR, GL_NEAREST);
//
// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, null);
// glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mTexName, 0);
//
// final int status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
// if (status != GL_FRAMEBUFFER_COMPLETE) {
// throw new RuntimeException("Failed to initialize framebuffer object " + status);
// }
// } catch (final RuntimeException e) {
// release();
// throw e;
// }
//
// glBindFramebuffer(GL_FRAMEBUFFER, saveFramebuffer);
// glBindRenderbuffer(GL_RENDERBUFFER, saveRenderbuffer);
// glBindTexture(GL_TEXTURE_2D, saveTexName);
// }
//
// public void release() {
// final int[] args = new int[1];
// args[0] = mTexName;
// glDeleteTextures(args.length, args, 0);
// mTexName = 0;
// args[0] = mRenderbufferName;
// glDeleteRenderbuffers(args.length, args, 0);
// mRenderbufferName = 0;
// args[0] = mFramebufferName;
// glDeleteFramebuffers(args.length, args, 0);
// mFramebufferName = 0;
// }
//
// public void enable() {
// glBindFramebuffer(GL_FRAMEBUFFER, mFramebufferName);
// }
//
// public Bitmap getBitmap() {
// return getBitmap(0, false);
// }
//
// public Bitmap getBitmap(final int orientation) {
// return getBitmap(orientation, false);
// }
//
// public Bitmap getBitmap(final int orientation, final boolean mirror) {
// final int[] pixels = new int[mWidth * mHeight];
// final IntBuffer buffer = IntBuffer.wrap(pixels);
// buffer.position(0);
//
// enable();
// glReadPixels(0, 0, mWidth, mHeight, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
// glBindFramebuffer(GL_FRAMEBUFFER, 0);
//
// return OpenGlUtils.createBitmap(pixels, mWidth, mHeight, Bitmap.Config.ARGB_8888, orientation, mirror);
// }
//
// }
| import android.util.Pair;
import com.af.experiments.FxCameraApp.renderer.GLES20FramebufferObject;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import static android.opengl.GLES20.glBindFramebuffer;
import static android.opengl.GLES20.glClear;
import static android.opengl.GLES20.GL_COLOR_BUFFER_BIT;
import static android.opengl.GLES20.GL_FRAMEBUFFER; | package com.af.experiments.FxCameraApp.shaders;
public class GlShaderGroup extends GlShader {
private final Collection<GlShader> mShaders;
| // Path: src/com/af/experiments/FxCameraApp/renderer/GLES20FramebufferObject.java
// public class GLES20FramebufferObject {
//
// private int mWidth;
// private int mHeight;
// private int mFramebufferName;
// private int mRenderbufferName;
// private int mTexName;
//
// public int getWidth() {
// return mWidth;
// }
// public int getHeight() {
// return mHeight;
// }
// public int getTexName() {
// return mTexName;
// }
//
// public void setup(final int width, final int height) {
// final int[] args = new int[1];
// glGetIntegerv(GL_MAX_TEXTURE_SIZE, args, 0);
// if (width > args[0] || height > args[0]) {
// throw new IllegalArgumentException("GL_MAX_TEXTURE_SIZE " + args[0]);
// }
//
// glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, args, 0);
// if (width > args[0] || height > args[0]) {
// throw new IllegalArgumentException("GL_MAX_RENDERBUFFER_SIZE " + args[0]);
// }
//
// glGetIntegerv(GL_FRAMEBUFFER_BINDING, args, 0);
// final int saveFramebuffer = args[0];
// glGetIntegerv(GL_RENDERBUFFER_BINDING, args, 0);
// final int saveRenderbuffer = args[0];
// glGetIntegerv(GL_TEXTURE_BINDING_2D, args, 0);
// final int saveTexName = args[0];
//
// release();
//
// try {
// mWidth = width;
// mHeight = height;
//
// glGenFramebuffers(args.length, args, 0);
// mFramebufferName = args[0];
// glBindFramebuffer(GL_FRAMEBUFFER, mFramebufferName);
//
// glGenRenderbuffers(args.length, args, 0);
// mRenderbufferName = args[0];
// glBindRenderbuffer(GL_RENDERBUFFER, mRenderbufferName);
// glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height);
// glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, mRenderbufferName);
//
// glGenTextures(args.length, args, 0);
// mTexName = args[0];
// glBindTexture(GL_TEXTURE_2D, mTexName);
//
// OpenGlUtils.setupSampler(GL_TEXTURE_2D, GL_LINEAR, GL_NEAREST);
//
// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, null);
// glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mTexName, 0);
//
// final int status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
// if (status != GL_FRAMEBUFFER_COMPLETE) {
// throw new RuntimeException("Failed to initialize framebuffer object " + status);
// }
// } catch (final RuntimeException e) {
// release();
// throw e;
// }
//
// glBindFramebuffer(GL_FRAMEBUFFER, saveFramebuffer);
// glBindRenderbuffer(GL_RENDERBUFFER, saveRenderbuffer);
// glBindTexture(GL_TEXTURE_2D, saveTexName);
// }
//
// public void release() {
// final int[] args = new int[1];
// args[0] = mTexName;
// glDeleteTextures(args.length, args, 0);
// mTexName = 0;
// args[0] = mRenderbufferName;
// glDeleteRenderbuffers(args.length, args, 0);
// mRenderbufferName = 0;
// args[0] = mFramebufferName;
// glDeleteFramebuffers(args.length, args, 0);
// mFramebufferName = 0;
// }
//
// public void enable() {
// glBindFramebuffer(GL_FRAMEBUFFER, mFramebufferName);
// }
//
// public Bitmap getBitmap() {
// return getBitmap(0, false);
// }
//
// public Bitmap getBitmap(final int orientation) {
// return getBitmap(orientation, false);
// }
//
// public Bitmap getBitmap(final int orientation, final boolean mirror) {
// final int[] pixels = new int[mWidth * mHeight];
// final IntBuffer buffer = IntBuffer.wrap(pixels);
// buffer.position(0);
//
// enable();
// glReadPixels(0, 0, mWidth, mHeight, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
// glBindFramebuffer(GL_FRAMEBUFFER, 0);
//
// return OpenGlUtils.createBitmap(pixels, mWidth, mHeight, Bitmap.Config.ARGB_8888, orientation, mirror);
// }
//
// }
// Path: src/com/af/experiments/FxCameraApp/shaders/GlShaderGroup.java
import android.util.Pair;
import com.af.experiments.FxCameraApp.renderer.GLES20FramebufferObject;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import static android.opengl.GLES20.glBindFramebuffer;
import static android.opengl.GLES20.glClear;
import static android.opengl.GLES20.GL_COLOR_BUFFER_BIT;
import static android.opengl.GLES20.GL_FRAMEBUFFER;
package com.af.experiments.FxCameraApp.shaders;
public class GlShaderGroup extends GlShader {
private final Collection<GlShader> mShaders;
| private final ArrayList<Pair<GlShader, GLES20FramebufferObject>> mList = new ArrayList<Pair<GlShader, GLES20FramebufferObject>>(); |
kkucherenkov/FxCameraApp | src/com/af/experiments/FxCameraApp/shaders/GlTwoInputShader.java | // Path: src/com/af/experiments/FxCameraApp/ogles/Texture.java
// public interface Texture {
// int getTexName();
// int getWidth();
// int getHeight();
// void setup();
// void release();
// }
//
// Path: src/com/af/experiments/FxCameraApp/renderer/GLES20FramebufferObject.java
// public class GLES20FramebufferObject {
//
// private int mWidth;
// private int mHeight;
// private int mFramebufferName;
// private int mRenderbufferName;
// private int mTexName;
//
// public int getWidth() {
// return mWidth;
// }
// public int getHeight() {
// return mHeight;
// }
// public int getTexName() {
// return mTexName;
// }
//
// public void setup(final int width, final int height) {
// final int[] args = new int[1];
// glGetIntegerv(GL_MAX_TEXTURE_SIZE, args, 0);
// if (width > args[0] || height > args[0]) {
// throw new IllegalArgumentException("GL_MAX_TEXTURE_SIZE " + args[0]);
// }
//
// glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, args, 0);
// if (width > args[0] || height > args[0]) {
// throw new IllegalArgumentException("GL_MAX_RENDERBUFFER_SIZE " + args[0]);
// }
//
// glGetIntegerv(GL_FRAMEBUFFER_BINDING, args, 0);
// final int saveFramebuffer = args[0];
// glGetIntegerv(GL_RENDERBUFFER_BINDING, args, 0);
// final int saveRenderbuffer = args[0];
// glGetIntegerv(GL_TEXTURE_BINDING_2D, args, 0);
// final int saveTexName = args[0];
//
// release();
//
// try {
// mWidth = width;
// mHeight = height;
//
// glGenFramebuffers(args.length, args, 0);
// mFramebufferName = args[0];
// glBindFramebuffer(GL_FRAMEBUFFER, mFramebufferName);
//
// glGenRenderbuffers(args.length, args, 0);
// mRenderbufferName = args[0];
// glBindRenderbuffer(GL_RENDERBUFFER, mRenderbufferName);
// glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height);
// glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, mRenderbufferName);
//
// glGenTextures(args.length, args, 0);
// mTexName = args[0];
// glBindTexture(GL_TEXTURE_2D, mTexName);
//
// OpenGlUtils.setupSampler(GL_TEXTURE_2D, GL_LINEAR, GL_NEAREST);
//
// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, null);
// glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mTexName, 0);
//
// final int status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
// if (status != GL_FRAMEBUFFER_COMPLETE) {
// throw new RuntimeException("Failed to initialize framebuffer object " + status);
// }
// } catch (final RuntimeException e) {
// release();
// throw e;
// }
//
// glBindFramebuffer(GL_FRAMEBUFFER, saveFramebuffer);
// glBindRenderbuffer(GL_RENDERBUFFER, saveRenderbuffer);
// glBindTexture(GL_TEXTURE_2D, saveTexName);
// }
//
// public void release() {
// final int[] args = new int[1];
// args[0] = mTexName;
// glDeleteTextures(args.length, args, 0);
// mTexName = 0;
// args[0] = mRenderbufferName;
// glDeleteRenderbuffers(args.length, args, 0);
// mRenderbufferName = 0;
// args[0] = mFramebufferName;
// glDeleteFramebuffers(args.length, args, 0);
// mFramebufferName = 0;
// }
//
// public void enable() {
// glBindFramebuffer(GL_FRAMEBUFFER, mFramebufferName);
// }
//
// public Bitmap getBitmap() {
// return getBitmap(0, false);
// }
//
// public Bitmap getBitmap(final int orientation) {
// return getBitmap(orientation, false);
// }
//
// public Bitmap getBitmap(final int orientation, final boolean mirror) {
// final int[] pixels = new int[mWidth * mHeight];
// final IntBuffer buffer = IntBuffer.wrap(pixels);
// buffer.position(0);
//
// enable();
// glReadPixels(0, 0, mWidth, mHeight, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
// glBindFramebuffer(GL_FRAMEBUFFER, 0);
//
// return OpenGlUtils.createBitmap(pixels, mWidth, mHeight, Bitmap.Config.ARGB_8888, orientation, mirror);
// }
//
// }
| import com.af.experiments.FxCameraApp.ogles.Texture;
import com.af.experiments.FxCameraApp.renderer.GLES20FramebufferObject;
import static android.opengl.GLES20.*;
| package com.af.experiments.FxCameraApp.shaders;
public abstract class GlTwoInputShader extends GlShader {
public static final String UNIFORM_SAMPLER2 = "sTexture2";
| // Path: src/com/af/experiments/FxCameraApp/ogles/Texture.java
// public interface Texture {
// int getTexName();
// int getWidth();
// int getHeight();
// void setup();
// void release();
// }
//
// Path: src/com/af/experiments/FxCameraApp/renderer/GLES20FramebufferObject.java
// public class GLES20FramebufferObject {
//
// private int mWidth;
// private int mHeight;
// private int mFramebufferName;
// private int mRenderbufferName;
// private int mTexName;
//
// public int getWidth() {
// return mWidth;
// }
// public int getHeight() {
// return mHeight;
// }
// public int getTexName() {
// return mTexName;
// }
//
// public void setup(final int width, final int height) {
// final int[] args = new int[1];
// glGetIntegerv(GL_MAX_TEXTURE_SIZE, args, 0);
// if (width > args[0] || height > args[0]) {
// throw new IllegalArgumentException("GL_MAX_TEXTURE_SIZE " + args[0]);
// }
//
// glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, args, 0);
// if (width > args[0] || height > args[0]) {
// throw new IllegalArgumentException("GL_MAX_RENDERBUFFER_SIZE " + args[0]);
// }
//
// glGetIntegerv(GL_FRAMEBUFFER_BINDING, args, 0);
// final int saveFramebuffer = args[0];
// glGetIntegerv(GL_RENDERBUFFER_BINDING, args, 0);
// final int saveRenderbuffer = args[0];
// glGetIntegerv(GL_TEXTURE_BINDING_2D, args, 0);
// final int saveTexName = args[0];
//
// release();
//
// try {
// mWidth = width;
// mHeight = height;
//
// glGenFramebuffers(args.length, args, 0);
// mFramebufferName = args[0];
// glBindFramebuffer(GL_FRAMEBUFFER, mFramebufferName);
//
// glGenRenderbuffers(args.length, args, 0);
// mRenderbufferName = args[0];
// glBindRenderbuffer(GL_RENDERBUFFER, mRenderbufferName);
// glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height);
// glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, mRenderbufferName);
//
// glGenTextures(args.length, args, 0);
// mTexName = args[0];
// glBindTexture(GL_TEXTURE_2D, mTexName);
//
// OpenGlUtils.setupSampler(GL_TEXTURE_2D, GL_LINEAR, GL_NEAREST);
//
// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, null);
// glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mTexName, 0);
//
// final int status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
// if (status != GL_FRAMEBUFFER_COMPLETE) {
// throw new RuntimeException("Failed to initialize framebuffer object " + status);
// }
// } catch (final RuntimeException e) {
// release();
// throw e;
// }
//
// glBindFramebuffer(GL_FRAMEBUFFER, saveFramebuffer);
// glBindRenderbuffer(GL_RENDERBUFFER, saveRenderbuffer);
// glBindTexture(GL_TEXTURE_2D, saveTexName);
// }
//
// public void release() {
// final int[] args = new int[1];
// args[0] = mTexName;
// glDeleteTextures(args.length, args, 0);
// mTexName = 0;
// args[0] = mRenderbufferName;
// glDeleteRenderbuffers(args.length, args, 0);
// mRenderbufferName = 0;
// args[0] = mFramebufferName;
// glDeleteFramebuffers(args.length, args, 0);
// mFramebufferName = 0;
// }
//
// public void enable() {
// glBindFramebuffer(GL_FRAMEBUFFER, mFramebufferName);
// }
//
// public Bitmap getBitmap() {
// return getBitmap(0, false);
// }
//
// public Bitmap getBitmap(final int orientation) {
// return getBitmap(orientation, false);
// }
//
// public Bitmap getBitmap(final int orientation, final boolean mirror) {
// final int[] pixels = new int[mWidth * mHeight];
// final IntBuffer buffer = IntBuffer.wrap(pixels);
// buffer.position(0);
//
// enable();
// glReadPixels(0, 0, mWidth, mHeight, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
// glBindFramebuffer(GL_FRAMEBUFFER, 0);
//
// return OpenGlUtils.createBitmap(pixels, mWidth, mHeight, Bitmap.Config.ARGB_8888, orientation, mirror);
// }
//
// }
// Path: src/com/af/experiments/FxCameraApp/shaders/GlTwoInputShader.java
import com.af.experiments.FxCameraApp.ogles.Texture;
import com.af.experiments.FxCameraApp.renderer.GLES20FramebufferObject;
import static android.opengl.GLES20.*;
package com.af.experiments.FxCameraApp.shaders;
public abstract class GlTwoInputShader extends GlShader {
public static final String UNIFORM_SAMPLER2 = "sTexture2";
| private final Texture mTexture;
|
kkucherenkov/FxCameraApp | src/com/af/experiments/FxCameraApp/shaders/GlTwoInputShader.java | // Path: src/com/af/experiments/FxCameraApp/ogles/Texture.java
// public interface Texture {
// int getTexName();
// int getWidth();
// int getHeight();
// void setup();
// void release();
// }
//
// Path: src/com/af/experiments/FxCameraApp/renderer/GLES20FramebufferObject.java
// public class GLES20FramebufferObject {
//
// private int mWidth;
// private int mHeight;
// private int mFramebufferName;
// private int mRenderbufferName;
// private int mTexName;
//
// public int getWidth() {
// return mWidth;
// }
// public int getHeight() {
// return mHeight;
// }
// public int getTexName() {
// return mTexName;
// }
//
// public void setup(final int width, final int height) {
// final int[] args = new int[1];
// glGetIntegerv(GL_MAX_TEXTURE_SIZE, args, 0);
// if (width > args[0] || height > args[0]) {
// throw new IllegalArgumentException("GL_MAX_TEXTURE_SIZE " + args[0]);
// }
//
// glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, args, 0);
// if (width > args[0] || height > args[0]) {
// throw new IllegalArgumentException("GL_MAX_RENDERBUFFER_SIZE " + args[0]);
// }
//
// glGetIntegerv(GL_FRAMEBUFFER_BINDING, args, 0);
// final int saveFramebuffer = args[0];
// glGetIntegerv(GL_RENDERBUFFER_BINDING, args, 0);
// final int saveRenderbuffer = args[0];
// glGetIntegerv(GL_TEXTURE_BINDING_2D, args, 0);
// final int saveTexName = args[0];
//
// release();
//
// try {
// mWidth = width;
// mHeight = height;
//
// glGenFramebuffers(args.length, args, 0);
// mFramebufferName = args[0];
// glBindFramebuffer(GL_FRAMEBUFFER, mFramebufferName);
//
// glGenRenderbuffers(args.length, args, 0);
// mRenderbufferName = args[0];
// glBindRenderbuffer(GL_RENDERBUFFER, mRenderbufferName);
// glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height);
// glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, mRenderbufferName);
//
// glGenTextures(args.length, args, 0);
// mTexName = args[0];
// glBindTexture(GL_TEXTURE_2D, mTexName);
//
// OpenGlUtils.setupSampler(GL_TEXTURE_2D, GL_LINEAR, GL_NEAREST);
//
// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, null);
// glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mTexName, 0);
//
// final int status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
// if (status != GL_FRAMEBUFFER_COMPLETE) {
// throw new RuntimeException("Failed to initialize framebuffer object " + status);
// }
// } catch (final RuntimeException e) {
// release();
// throw e;
// }
//
// glBindFramebuffer(GL_FRAMEBUFFER, saveFramebuffer);
// glBindRenderbuffer(GL_RENDERBUFFER, saveRenderbuffer);
// glBindTexture(GL_TEXTURE_2D, saveTexName);
// }
//
// public void release() {
// final int[] args = new int[1];
// args[0] = mTexName;
// glDeleteTextures(args.length, args, 0);
// mTexName = 0;
// args[0] = mRenderbufferName;
// glDeleteRenderbuffers(args.length, args, 0);
// mRenderbufferName = 0;
// args[0] = mFramebufferName;
// glDeleteFramebuffers(args.length, args, 0);
// mFramebufferName = 0;
// }
//
// public void enable() {
// glBindFramebuffer(GL_FRAMEBUFFER, mFramebufferName);
// }
//
// public Bitmap getBitmap() {
// return getBitmap(0, false);
// }
//
// public Bitmap getBitmap(final int orientation) {
// return getBitmap(orientation, false);
// }
//
// public Bitmap getBitmap(final int orientation, final boolean mirror) {
// final int[] pixels = new int[mWidth * mHeight];
// final IntBuffer buffer = IntBuffer.wrap(pixels);
// buffer.position(0);
//
// enable();
// glReadPixels(0, 0, mWidth, mHeight, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
// glBindFramebuffer(GL_FRAMEBUFFER, 0);
//
// return OpenGlUtils.createBitmap(pixels, mWidth, mHeight, Bitmap.Config.ARGB_8888, orientation, mirror);
// }
//
// }
| import com.af.experiments.FxCameraApp.ogles.Texture;
import com.af.experiments.FxCameraApp.renderer.GLES20FramebufferObject;
import static android.opengl.GLES20.*;
| package com.af.experiments.FxCameraApp.shaders;
public abstract class GlTwoInputShader extends GlShader {
public static final String UNIFORM_SAMPLER2 = "sTexture2";
private final Texture mTexture;
protected GlTwoInputShader(final String vertexShaderSource, final String fragmentShaderSource, final Texture texture) {
super(vertexShaderSource, fragmentShaderSource);
mTexture = texture;
}
@Override
public void setup() {
release();
super.setup();
mTexture.setup();
}
@Override
public void release() {
mTexture.release();
super.release();
}
@Override
| // Path: src/com/af/experiments/FxCameraApp/ogles/Texture.java
// public interface Texture {
// int getTexName();
// int getWidth();
// int getHeight();
// void setup();
// void release();
// }
//
// Path: src/com/af/experiments/FxCameraApp/renderer/GLES20FramebufferObject.java
// public class GLES20FramebufferObject {
//
// private int mWidth;
// private int mHeight;
// private int mFramebufferName;
// private int mRenderbufferName;
// private int mTexName;
//
// public int getWidth() {
// return mWidth;
// }
// public int getHeight() {
// return mHeight;
// }
// public int getTexName() {
// return mTexName;
// }
//
// public void setup(final int width, final int height) {
// final int[] args = new int[1];
// glGetIntegerv(GL_MAX_TEXTURE_SIZE, args, 0);
// if (width > args[0] || height > args[0]) {
// throw new IllegalArgumentException("GL_MAX_TEXTURE_SIZE " + args[0]);
// }
//
// glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, args, 0);
// if (width > args[0] || height > args[0]) {
// throw new IllegalArgumentException("GL_MAX_RENDERBUFFER_SIZE " + args[0]);
// }
//
// glGetIntegerv(GL_FRAMEBUFFER_BINDING, args, 0);
// final int saveFramebuffer = args[0];
// glGetIntegerv(GL_RENDERBUFFER_BINDING, args, 0);
// final int saveRenderbuffer = args[0];
// glGetIntegerv(GL_TEXTURE_BINDING_2D, args, 0);
// final int saveTexName = args[0];
//
// release();
//
// try {
// mWidth = width;
// mHeight = height;
//
// glGenFramebuffers(args.length, args, 0);
// mFramebufferName = args[0];
// glBindFramebuffer(GL_FRAMEBUFFER, mFramebufferName);
//
// glGenRenderbuffers(args.length, args, 0);
// mRenderbufferName = args[0];
// glBindRenderbuffer(GL_RENDERBUFFER, mRenderbufferName);
// glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height);
// glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, mRenderbufferName);
//
// glGenTextures(args.length, args, 0);
// mTexName = args[0];
// glBindTexture(GL_TEXTURE_2D, mTexName);
//
// OpenGlUtils.setupSampler(GL_TEXTURE_2D, GL_LINEAR, GL_NEAREST);
//
// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, null);
// glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mTexName, 0);
//
// final int status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
// if (status != GL_FRAMEBUFFER_COMPLETE) {
// throw new RuntimeException("Failed to initialize framebuffer object " + status);
// }
// } catch (final RuntimeException e) {
// release();
// throw e;
// }
//
// glBindFramebuffer(GL_FRAMEBUFFER, saveFramebuffer);
// glBindRenderbuffer(GL_RENDERBUFFER, saveRenderbuffer);
// glBindTexture(GL_TEXTURE_2D, saveTexName);
// }
//
// public void release() {
// final int[] args = new int[1];
// args[0] = mTexName;
// glDeleteTextures(args.length, args, 0);
// mTexName = 0;
// args[0] = mRenderbufferName;
// glDeleteRenderbuffers(args.length, args, 0);
// mRenderbufferName = 0;
// args[0] = mFramebufferName;
// glDeleteFramebuffers(args.length, args, 0);
// mFramebufferName = 0;
// }
//
// public void enable() {
// glBindFramebuffer(GL_FRAMEBUFFER, mFramebufferName);
// }
//
// public Bitmap getBitmap() {
// return getBitmap(0, false);
// }
//
// public Bitmap getBitmap(final int orientation) {
// return getBitmap(orientation, false);
// }
//
// public Bitmap getBitmap(final int orientation, final boolean mirror) {
// final int[] pixels = new int[mWidth * mHeight];
// final IntBuffer buffer = IntBuffer.wrap(pixels);
// buffer.position(0);
//
// enable();
// glReadPixels(0, 0, mWidth, mHeight, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
// glBindFramebuffer(GL_FRAMEBUFFER, 0);
//
// return OpenGlUtils.createBitmap(pixels, mWidth, mHeight, Bitmap.Config.ARGB_8888, orientation, mirror);
// }
//
// }
// Path: src/com/af/experiments/FxCameraApp/shaders/GlTwoInputShader.java
import com.af.experiments.FxCameraApp.ogles.Texture;
import com.af.experiments.FxCameraApp.renderer.GLES20FramebufferObject;
import static android.opengl.GLES20.*;
package com.af.experiments.FxCameraApp.shaders;
public abstract class GlTwoInputShader extends GlShader {
public static final String UNIFORM_SAMPLER2 = "sTexture2";
private final Texture mTexture;
protected GlTwoInputShader(final String vertexShaderSource, final String fragmentShaderSource, final Texture texture) {
super(vertexShaderSource, fragmentShaderSource);
mTexture = texture;
}
@Override
public void setup() {
release();
super.setup();
mTexture.setup();
}
@Override
public void release() {
mTexture.release();
super.release();
}
@Override
| public void draw(final int texName, final GLES20FramebufferObject fbo) {
|
kkucherenkov/FxCameraApp | src/com/af/experiments/FxCameraApp/ogles/GlTextureView.java | // Path: src/com/af/experiments/FxCameraApp/Utils/LogWriter.java
// public final class LogWriter extends Writer {
//
// private final StringBuilder mBuilder = new StringBuilder();
// private final String mTag;
//
// public LogWriter(final String tag) {
// mTag = tag;
// }
//
// @Override
// public void close() {
// flushBuilder();
// }
//
// @Override
// public void flush() {
// flushBuilder();
// }
//
// @Override
// public void write(final char[] buf, final int offset, final int count) {
// for(int i = 0; i < count; i++) {
// final char c = buf[offset + i];
// if (c == '\n') {
// flushBuilder();
// } else {
// mBuilder.append(c);
// }
// }
// }
//
// private void flushBuilder() {
// if (mBuilder.length() > 0) {
// Log.v(mTag, mBuilder.toString());
// mBuilder.delete(0, mBuilder.length());
// }
// }
//
// }
| import android.app.ActivityManager;
import android.content.Context;
import android.graphics.SurfaceTexture;
import android.opengl.GLDebugHelper;
import android.opengl.GLSurfaceView;
import android.os.Build;
import android.util.AttributeSet;
import android.util.Log;
import android.view.TextureView;
import com.af.experiments.FxCameraApp.Utils.LogWriter;
import javax.microedition.khronos.egl.*;
import javax.microedition.khronos.opengles.GL;
import javax.microedition.khronos.opengles.GL10;
import java.io.Writer;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import static android.opengl.GLSurfaceView.DEBUG_CHECK_GL_ERROR;
import static android.opengl.GLSurfaceView.DEBUG_LOG_GL_CALLS;
import static android.opengl.GLSurfaceView.RENDERMODE_CONTINUOUSLY;
import static android.opengl.GLSurfaceView.RENDERMODE_WHEN_DIRTY;
import static javax.microedition.khronos.egl.EGL10.*;
import static javax.microedition.khronos.egl.EGL11.EGL_CONTEXT_LOST; | * Could not make the context current, probably because the underlying
* SurfaceView surface has been destroyed.
*/
logEglErrorAsWarning("EGLHelper", "eglMakeCurrent", mEgl.eglGetError());
return false;
}
return true;
}
/**
* Create a GL object for the current EGL context.
* @return
*/
GL createGL() {
GL gl = mEglContext.getGL();
final GlTextureView view = mGLSurfaceViewWeakRef.get();
if (view != null) {
if (view.mGLWrapper != null) {
gl = view.mGLWrapper.wrap(gl);
}
if ((view.mDebugFlags & (DEBUG_CHECK_GL_ERROR | DEBUG_LOG_GL_CALLS)) != 0) {
int configFlags = 0;
Writer log = null;
if ((view.mDebugFlags & DEBUG_CHECK_GL_ERROR) != 0) {
configFlags |= GLDebugHelper.CONFIG_CHECK_GL_ERROR;
}
if ((view.mDebugFlags & DEBUG_LOG_GL_CALLS) != 0) { | // Path: src/com/af/experiments/FxCameraApp/Utils/LogWriter.java
// public final class LogWriter extends Writer {
//
// private final StringBuilder mBuilder = new StringBuilder();
// private final String mTag;
//
// public LogWriter(final String tag) {
// mTag = tag;
// }
//
// @Override
// public void close() {
// flushBuilder();
// }
//
// @Override
// public void flush() {
// flushBuilder();
// }
//
// @Override
// public void write(final char[] buf, final int offset, final int count) {
// for(int i = 0; i < count; i++) {
// final char c = buf[offset + i];
// if (c == '\n') {
// flushBuilder();
// } else {
// mBuilder.append(c);
// }
// }
// }
//
// private void flushBuilder() {
// if (mBuilder.length() > 0) {
// Log.v(mTag, mBuilder.toString());
// mBuilder.delete(0, mBuilder.length());
// }
// }
//
// }
// Path: src/com/af/experiments/FxCameraApp/ogles/GlTextureView.java
import android.app.ActivityManager;
import android.content.Context;
import android.graphics.SurfaceTexture;
import android.opengl.GLDebugHelper;
import android.opengl.GLSurfaceView;
import android.os.Build;
import android.util.AttributeSet;
import android.util.Log;
import android.view.TextureView;
import com.af.experiments.FxCameraApp.Utils.LogWriter;
import javax.microedition.khronos.egl.*;
import javax.microedition.khronos.opengles.GL;
import javax.microedition.khronos.opengles.GL10;
import java.io.Writer;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import static android.opengl.GLSurfaceView.DEBUG_CHECK_GL_ERROR;
import static android.opengl.GLSurfaceView.DEBUG_LOG_GL_CALLS;
import static android.opengl.GLSurfaceView.RENDERMODE_CONTINUOUSLY;
import static android.opengl.GLSurfaceView.RENDERMODE_WHEN_DIRTY;
import static javax.microedition.khronos.egl.EGL10.*;
import static javax.microedition.khronos.egl.EGL11.EGL_CONTEXT_LOST;
* Could not make the context current, probably because the underlying
* SurfaceView surface has been destroyed.
*/
logEglErrorAsWarning("EGLHelper", "eglMakeCurrent", mEgl.eglGetError());
return false;
}
return true;
}
/**
* Create a GL object for the current EGL context.
* @return
*/
GL createGL() {
GL gl = mEglContext.getGL();
final GlTextureView view = mGLSurfaceViewWeakRef.get();
if (view != null) {
if (view.mGLWrapper != null) {
gl = view.mGLWrapper.wrap(gl);
}
if ((view.mDebugFlags & (DEBUG_CHECK_GL_ERROR | DEBUG_LOG_GL_CALLS)) != 0) {
int configFlags = 0;
Writer log = null;
if ((view.mDebugFlags & DEBUG_CHECK_GL_ERROR) != 0) {
configFlags |= GLDebugHelper.CONFIG_CHECK_GL_ERROR;
}
if ((view.mDebugFlags & DEBUG_LOG_GL_CALLS) != 0) { | log = new LogWriter(GlTextureView.TAG); |
hubinix/kamike.divide | kamikeDivide/src/com/kamike/divide/KamiStatement.java | // Path: kamikeDivide/src/com/kamike/db/generic/GenericColumn.java
// public class GenericColumn {
//
// private String name;
// private int length;
// private boolean nullable;
// private GenericType type;
// private Field field;
// private Object value;
// private String strValue;
// private int intValue;
// private double doubleValue;
// private Timestamp timestampValue;
// private long longValue;
// private boolean booleanValue;
//
// public GenericColumn() {
// this.length = 255;
// this.nullable=true;
// }
//
//
// /**
// * @return the name
// */
// public String getName() {
// return name;
// }
//
// /**
// * @param name the name to set
// */
// public void setName(String name) {
// this.name = name;
// }
//
// /**
// * @return the type
// */
// public GenericType getType() {
// return type;
// }
//
// /**
// * @param type the type to set
// */
// public void setType(GenericType type) {
// this.type = type;
// }
//
// /**
// * @return the field
// */
// public Field getField() {
// return field;
// }
//
// /**
// * @param field the field to set
// */
// public void setField(Field field) {
// this.field = field;
// }
//
// /**
// * @return the value
// */
// public Object getValue() {
// return value;
// }
//
// /**
// * @param value the value to set
// */
// public void setValue(Object value) {
// this.value = value;
// }
//
// /**
// * @return the strValue
// */
// public String getStrValue() {
// return strValue;
// }
//
// /**
// * @param strValue the strValue to set
// */
// public void setStrValue(String strValue) {
// this.strValue = strValue;
// }
//
// /**
// * @return the intValue
// */
// public int getIntValue() {
// return intValue;
// }
//
// /**
// * @param intValue the intValue to set
// */
// public void setIntValue(int intValue) {
// this.intValue = intValue;
// }
//
// /**
// * @return the doubleValue
// */
// public double getDoubleValue() {
// return doubleValue;
// }
//
// /**
// * @param doubleValue the doubleValue to set
// */
// public void setDoubleValue(double doubleValue) {
// this.doubleValue = doubleValue;
// }
//
// /**
// * @return the timestampValue
// */
// public Timestamp getTimestampValue() {
// return timestampValue;
// }
//
// /**
// * @param timestampValue the timestampValue to set
// */
// public void setTimestampValue(Timestamp timestampValue) {
// this.timestampValue = timestampValue;
// }
//
// /**
// * @return the longValue
// */
// public long getLongValue() {
// return longValue;
// }
//
// /**
// * @param longValue the longValue to set
// */
// public void setLongValue(long longValue) {
// this.longValue = longValue;
// }
//
// /**
// * @return the booleanValue
// */
// public boolean getBooleanValue() {
// return booleanValue;
// }
//
// /**
// * @param booleanValue the booleanValue to set
// */
// public void setBooleanValue(boolean booleanValue) {
// this.booleanValue = booleanValue;
// }
//
// /**
// * @return the length
// */
// public int getLength() {
// return length;
// }
//
// /**
// * @param length the length to set
// */
// public void setLength(int length) {
// this.length = length;
// }
//
// /**
// * @return the nullable
// */
// public boolean isNullable() {
// return nullable;
// }
//
// /**
// * @param nullable the nullable to set
// */
// public void setNullable(boolean nullable) {
// this.nullable = nullable;
// }
//
// public String column() {
//
// StringBuffer buffer = new StringBuffer();
// buffer.append(" `");
// buffer.append(this.getName());
// buffer.append("` ");
// switch (this.getType()) {
// case Int:
// buffer.append(" INT ");
// break;
// case Long:
// buffer.append(" BIGINT ");
// break;
// case Double:
// buffer.append(" DOUBLE ");
// break;
// case Boolean:
// buffer.append(" INT ");
// break;
// case Timestamp:
// buffer.append(" TIMESTAMP ");
// buffer.append(" NULL ");
// break;
// case String:
// if (this.getLength() < 256) {
// buffer.append("VARCHAR");
// buffer.append("(");
// buffer.append(this.getLength());
// buffer.append(") ");
//
// } else if (this.getLength() < 65535) {
// buffer.append(" TEXT ");
// } else if (this.getLength() < 16777215) {
// buffer.append(" MEDIUMTEXT ");
// } else {
// buffer.append(" LONGTEXT ");
// }
// break;
// }
//
// if (this.isNullable()) {
// buffer.append(" NOT NULL ");
// } else {
// buffer.append(" DEFAULT NULL");
// }
//
// buffer.append(", ");
// return buffer.toString();
// }
// }
| import java.util.ArrayList;
import com.kamike.db.generic.GenericColumn; | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.kamike.divide;
/**
*
* @author THiNk
*/
public class KamiStatement implements Cloneable, AutoCloseable {
private String sql;
private int resultSetOption1;
private int resultSetOption2; | // Path: kamikeDivide/src/com/kamike/db/generic/GenericColumn.java
// public class GenericColumn {
//
// private String name;
// private int length;
// private boolean nullable;
// private GenericType type;
// private Field field;
// private Object value;
// private String strValue;
// private int intValue;
// private double doubleValue;
// private Timestamp timestampValue;
// private long longValue;
// private boolean booleanValue;
//
// public GenericColumn() {
// this.length = 255;
// this.nullable=true;
// }
//
//
// /**
// * @return the name
// */
// public String getName() {
// return name;
// }
//
// /**
// * @param name the name to set
// */
// public void setName(String name) {
// this.name = name;
// }
//
// /**
// * @return the type
// */
// public GenericType getType() {
// return type;
// }
//
// /**
// * @param type the type to set
// */
// public void setType(GenericType type) {
// this.type = type;
// }
//
// /**
// * @return the field
// */
// public Field getField() {
// return field;
// }
//
// /**
// * @param field the field to set
// */
// public void setField(Field field) {
// this.field = field;
// }
//
// /**
// * @return the value
// */
// public Object getValue() {
// return value;
// }
//
// /**
// * @param value the value to set
// */
// public void setValue(Object value) {
// this.value = value;
// }
//
// /**
// * @return the strValue
// */
// public String getStrValue() {
// return strValue;
// }
//
// /**
// * @param strValue the strValue to set
// */
// public void setStrValue(String strValue) {
// this.strValue = strValue;
// }
//
// /**
// * @return the intValue
// */
// public int getIntValue() {
// return intValue;
// }
//
// /**
// * @param intValue the intValue to set
// */
// public void setIntValue(int intValue) {
// this.intValue = intValue;
// }
//
// /**
// * @return the doubleValue
// */
// public double getDoubleValue() {
// return doubleValue;
// }
//
// /**
// * @param doubleValue the doubleValue to set
// */
// public void setDoubleValue(double doubleValue) {
// this.doubleValue = doubleValue;
// }
//
// /**
// * @return the timestampValue
// */
// public Timestamp getTimestampValue() {
// return timestampValue;
// }
//
// /**
// * @param timestampValue the timestampValue to set
// */
// public void setTimestampValue(Timestamp timestampValue) {
// this.timestampValue = timestampValue;
// }
//
// /**
// * @return the longValue
// */
// public long getLongValue() {
// return longValue;
// }
//
// /**
// * @param longValue the longValue to set
// */
// public void setLongValue(long longValue) {
// this.longValue = longValue;
// }
//
// /**
// * @return the booleanValue
// */
// public boolean getBooleanValue() {
// return booleanValue;
// }
//
// /**
// * @param booleanValue the booleanValue to set
// */
// public void setBooleanValue(boolean booleanValue) {
// this.booleanValue = booleanValue;
// }
//
// /**
// * @return the length
// */
// public int getLength() {
// return length;
// }
//
// /**
// * @param length the length to set
// */
// public void setLength(int length) {
// this.length = length;
// }
//
// /**
// * @return the nullable
// */
// public boolean isNullable() {
// return nullable;
// }
//
// /**
// * @param nullable the nullable to set
// */
// public void setNullable(boolean nullable) {
// this.nullable = nullable;
// }
//
// public String column() {
//
// StringBuffer buffer = new StringBuffer();
// buffer.append(" `");
// buffer.append(this.getName());
// buffer.append("` ");
// switch (this.getType()) {
// case Int:
// buffer.append(" INT ");
// break;
// case Long:
// buffer.append(" BIGINT ");
// break;
// case Double:
// buffer.append(" DOUBLE ");
// break;
// case Boolean:
// buffer.append(" INT ");
// break;
// case Timestamp:
// buffer.append(" TIMESTAMP ");
// buffer.append(" NULL ");
// break;
// case String:
// if (this.getLength() < 256) {
// buffer.append("VARCHAR");
// buffer.append("(");
// buffer.append(this.getLength());
// buffer.append(") ");
//
// } else if (this.getLength() < 65535) {
// buffer.append(" TEXT ");
// } else if (this.getLength() < 16777215) {
// buffer.append(" MEDIUMTEXT ");
// } else {
// buffer.append(" LONGTEXT ");
// }
// break;
// }
//
// if (this.isNullable()) {
// buffer.append(" NOT NULL ");
// } else {
// buffer.append(" DEFAULT NULL");
// }
//
// buffer.append(", ");
// return buffer.toString();
// }
// }
// Path: kamikeDivide/src/com/kamike/divide/KamiStatement.java
import java.util.ArrayList;
import com.kamike.db.generic.GenericColumn;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.kamike.divide;
/**
*
* @author THiNk
*/
public class KamiStatement implements Cloneable, AutoCloseable {
private String sql;
private int resultSetOption1;
private int resultSetOption2; | private ArrayList<GenericColumn> columns; |
hubinix/kamike.divide | kamikeDivide/src/com/kamike/db/generic/BaseReader.java | // Path: kamikeDivide/src/com/kamike/db/GenericReader.java
// public abstract class GenericReader<T> {
//
// public abstract long count();
//
//
//
// protected GenericReader() {
//
//
// }
//
// public abstract ArrayList<T> find();
//
// public abstract ArrayList<T> find(T t);
//
// public abstract T get(T t);
//
// }
//
// Path: kamikeDivide/src/com/kamike/db/DbInst.java
// public class DbInst {
//
// private static volatile DbInst dbinst = new DbInst();
// private Database database;
//
// public void destroy() {
// if (database != null) {
// database.destroy();
// }
//
// }
//
// private DbInst() {
//
// }
//
// public static DbInst getInstance() {
//
// return dbinst;
// }
//
// /**
// * @return the DATABASE_URL
// */
// public Database getDatabase(boolean newDatabase) {
// if (newDatabase) {
//
// String ip = SystemConfig.DB_IP;
// String port = SystemConfig.DB_PORT;
// String name = SystemConfig.DB_NAME;
// String user = SystemConfig.DB_USER;
// String password = SystemConfig.DB_PASSWORD;
//
// database = new MySQLDatabase(ip, port, name, user, password);
// }
// return database;
// }
//
// public Database getDatabase() {
// if (database == null) {
//
// String ip = SystemConfig.DB_IP;
// String port = SystemConfig.DB_PORT;
// String name = SystemConfig.DB_NAME;
// String user = SystemConfig.DB_USER;
// String password = SystemConfig.DB_PASSWORD;
//
// database = new MySQLDatabase(ip, port, name, user, password);
// }
// return database;
// }
//
// }
| import com.kamike.db.GenericReader;
import com.kamike.db.DbInst;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger; | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.kamike.db.generic;
/**
*
*
* @author brin hubinix@gmail.com
*/
public abstract class BaseReader<T> extends GenericReader<T> {
protected BaseReader() {
}
public abstract GenericSelect<T> createSelect();
public abstract GenericSelect<T> createSelect(T t);
@Override
public long count() {
GenericSelect<T> select = createSelect();
ResultSet rs = null;
PreparedStatement ps = null;
Connection conn = null;
long ret = 0;
try { | // Path: kamikeDivide/src/com/kamike/db/GenericReader.java
// public abstract class GenericReader<T> {
//
// public abstract long count();
//
//
//
// protected GenericReader() {
//
//
// }
//
// public abstract ArrayList<T> find();
//
// public abstract ArrayList<T> find(T t);
//
// public abstract T get(T t);
//
// }
//
// Path: kamikeDivide/src/com/kamike/db/DbInst.java
// public class DbInst {
//
// private static volatile DbInst dbinst = new DbInst();
// private Database database;
//
// public void destroy() {
// if (database != null) {
// database.destroy();
// }
//
// }
//
// private DbInst() {
//
// }
//
// public static DbInst getInstance() {
//
// return dbinst;
// }
//
// /**
// * @return the DATABASE_URL
// */
// public Database getDatabase(boolean newDatabase) {
// if (newDatabase) {
//
// String ip = SystemConfig.DB_IP;
// String port = SystemConfig.DB_PORT;
// String name = SystemConfig.DB_NAME;
// String user = SystemConfig.DB_USER;
// String password = SystemConfig.DB_PASSWORD;
//
// database = new MySQLDatabase(ip, port, name, user, password);
// }
// return database;
// }
//
// public Database getDatabase() {
// if (database == null) {
//
// String ip = SystemConfig.DB_IP;
// String port = SystemConfig.DB_PORT;
// String name = SystemConfig.DB_NAME;
// String user = SystemConfig.DB_USER;
// String password = SystemConfig.DB_PASSWORD;
//
// database = new MySQLDatabase(ip, port, name, user, password);
// }
// return database;
// }
//
// }
// Path: kamikeDivide/src/com/kamike/db/generic/BaseReader.java
import com.kamike.db.GenericReader;
import com.kamike.db.DbInst;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.kamike.db.generic;
/**
*
*
* @author brin hubinix@gmail.com
*/
public abstract class BaseReader<T> extends GenericReader<T> {
protected BaseReader() {
}
public abstract GenericSelect<T> createSelect();
public abstract GenericSelect<T> createSelect(T t);
@Override
public long count() {
GenericSelect<T> select = createSelect();
ResultSet rs = null;
PreparedStatement ps = null;
Connection conn = null;
long ret = 0;
try { | conn = DbInst.getInstance().getDatabase().getSingleConnection(); |
hubinix/kamike.divide | kamikeDivide/src/com/kamike/db/DbInst.java | // Path: kamikeDivide/src/com/kamike/config/SystemConfig.java
// public class SystemConfig {
// private static volatile SystemConfig ec = new SystemConfig();
//
// private final ConcurrentHashMap<String, String> systemConstants = new ConcurrentHashMap<String, String>();
//
// public static String WATCH_PATH="E:/share/kami";
// public static String DOMAIN="high.xinhuavideo.com";
// public static String FASP_PATH="E:/high/fasp/bin/";
// public static String SYSDBNAME="kamike";
// public static String THIS_DB_ID="kamike";
//
// public static String DB_USER = "root";
// public static String DB_PASSWORD = "wlnwzkybd";
// public static String DB_IP = "127.0.0.1";
// public static String DB_PORT = "3306";
// public static String DB_NAME = "kamike";
//
// private SystemConfig() {
//
// }
// private Configuration baseConfig;
//
// public static SystemConfig getInstance() {
// return ec;
// }
//
// /**
// * @param baseConfig the baseConfig to set
// */
// public void setBaseConfig(Configuration baseConfig) {
// this.baseConfig = baseConfig;
// }
//
// /**
// * @return the systemConstants
// */
// public ConcurrentHashMap<String, String> getSystemConstants() {
// return systemConstants;
// }
//
// /**
// * @param name
// * @return the systemConstants
// */
// public String getSystemConstant(String name) {
// return SystemConfig.getInstance().getSystemConstants().get(name);
// }
//
//
//
// /**
// * @return the baseConfig
// */
// public Configuration getBaseConfig() {
// return baseConfig;
// }
// }
| import com.kamike.config.SystemConfig; | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.kamike.db;
/**
*
* @author brin
*/
public class DbInst {
private static volatile DbInst dbinst = new DbInst();
private Database database;
public void destroy() {
if (database != null) {
database.destroy();
}
}
private DbInst() {
}
public static DbInst getInstance() {
return dbinst;
}
/**
* @return the DATABASE_URL
*/
public Database getDatabase(boolean newDatabase) {
if (newDatabase) {
| // Path: kamikeDivide/src/com/kamike/config/SystemConfig.java
// public class SystemConfig {
// private static volatile SystemConfig ec = new SystemConfig();
//
// private final ConcurrentHashMap<String, String> systemConstants = new ConcurrentHashMap<String, String>();
//
// public static String WATCH_PATH="E:/share/kami";
// public static String DOMAIN="high.xinhuavideo.com";
// public static String FASP_PATH="E:/high/fasp/bin/";
// public static String SYSDBNAME="kamike";
// public static String THIS_DB_ID="kamike";
//
// public static String DB_USER = "root";
// public static String DB_PASSWORD = "wlnwzkybd";
// public static String DB_IP = "127.0.0.1";
// public static String DB_PORT = "3306";
// public static String DB_NAME = "kamike";
//
// private SystemConfig() {
//
// }
// private Configuration baseConfig;
//
// public static SystemConfig getInstance() {
// return ec;
// }
//
// /**
// * @param baseConfig the baseConfig to set
// */
// public void setBaseConfig(Configuration baseConfig) {
// this.baseConfig = baseConfig;
// }
//
// /**
// * @return the systemConstants
// */
// public ConcurrentHashMap<String, String> getSystemConstants() {
// return systemConstants;
// }
//
// /**
// * @param name
// * @return the systemConstants
// */
// public String getSystemConstant(String name) {
// return SystemConfig.getInstance().getSystemConstants().get(name);
// }
//
//
//
// /**
// * @return the baseConfig
// */
// public Configuration getBaseConfig() {
// return baseConfig;
// }
// }
// Path: kamikeDivide/src/com/kamike/db/DbInst.java
import com.kamike.config.SystemConfig;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.kamike.db;
/**
*
* @author brin
*/
public class DbInst {
private static volatile DbInst dbinst = new DbInst();
private Database database;
public void destroy() {
if (database != null) {
database.destroy();
}
}
private DbInst() {
}
public static DbInst getInstance() {
return dbinst;
}
/**
* @return the DATABASE_URL
*/
public Database getDatabase(boolean newDatabase) {
if (newDatabase) {
| String ip = SystemConfig.DB_IP; |
hubinix/kamike.divide | kamikeDivide/src/com/kamike/db/PostgresqlDatabase.java | // Path: kamikeDivide/src/com/kamike/config/SystemConstants.java
// public class SystemConstants {
// public static final String CONTEXT_PATH="context.path";
// public static final String INITIAL_CONFIG_FILE="/conf.txt";
// public static final String INITIAL_REALPATH="initial.realpath";
// public static final String WATCH_PATH="watch.path";
// public static final String DOMAIN="domain";
//
// public static String POSTGRESQL = "postgresql";
//
// public static String JDBC = "jdbc";
// public static String POSTGRESQL_DRIVER = "org.postgresql.Driver";
// public static String MYSQL = "mysql";
// public static String SQLSERVER = "sqlserver";
//
// public static String MYSQL_DRIVER = "com.mysql.jdbc.Driver";
//
// public static String SQLSERVER_DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
//
//
//
//
//
// }
| import com.kamike.config.SystemConstants; | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.kamike.db;
/**
*
* @author brin
*/
public class PostgresqlDatabase extends C3p0Database {
public PostgresqlDatabase(String ip, String port, String name, String user, String password) { | // Path: kamikeDivide/src/com/kamike/config/SystemConstants.java
// public class SystemConstants {
// public static final String CONTEXT_PATH="context.path";
// public static final String INITIAL_CONFIG_FILE="/conf.txt";
// public static final String INITIAL_REALPATH="initial.realpath";
// public static final String WATCH_PATH="watch.path";
// public static final String DOMAIN="domain";
//
// public static String POSTGRESQL = "postgresql";
//
// public static String JDBC = "jdbc";
// public static String POSTGRESQL_DRIVER = "org.postgresql.Driver";
// public static String MYSQL = "mysql";
// public static String SQLSERVER = "sqlserver";
//
// public static String MYSQL_DRIVER = "com.mysql.jdbc.Driver";
//
// public static String SQLSERVER_DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
//
//
//
//
//
// }
// Path: kamikeDivide/src/com/kamike/db/PostgresqlDatabase.java
import com.kamike.config.SystemConstants;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.kamike.db;
/**
*
* @author brin
*/
public class PostgresqlDatabase extends C3p0Database {
public PostgresqlDatabase(String ip, String port, String name, String user, String password) { | super(SystemConstants.POSTGRESQL, ip, "", port, name, user, password); |
jsaund/RxUploader | rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/SampleApplication.java | // Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/config/Config.java
// public class Config {
// public static final String HOST = "https://api.500px.com/";
//
// public static final HttpLoggingInterceptor.Level HTTP_LOG_LEVEL =
// HttpLoggingInterceptor.Level.HEADERS;
//
//
// public static final String REQUEST_TOKEN_URL = HOST + "v1/oauth/request_token";
// public static final String ACCESS_TOKEN_URL = HOST + "v1/oauth/access_token";
// public static final String AUTH_CALLBACK_URL = "";
//
// public static final String CONSUMER_KEY = "<INSERT YOUR 500PX CONSUMER KEY>";
// public static final String CONSUMER_SECRET = "<INSERT YOUR 500PX CONSUMER SECRET>";
//
// public static final String X_AUTH_MODE = "client_auth";
// public static final String X_AUTH_USERNAME = "<INSERT YOUR 500PX USERNAME>";
// public static final String X_AUTH_PASSWORD = "<INSERT YOUR 500PX PASSWORD>";
//
// public static final String USERNAME = X_AUTH_USERNAME;
// }
//
// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/service/XOAuthProvider.java
// public class XOAuthProvider extends AbstractOAuthProvider {
//
// private transient OkHttpClient okHttpClient;
//
// public XOAuthProvider(String requestTokenEndpointUrl, String accessTokenEndpointUrl,
// String authorizationWebsiteUrl) {
// super(requestTokenEndpointUrl, accessTokenEndpointUrl, authorizationWebsiteUrl);
// this.okHttpClient = new OkHttpClient();
// }
//
// public XOAuthProvider(String requestTokenEndpointUrl, String accessTokenEndpointUrl,
// String authorizationWebsiteUrl, OkHttpClient okHttpClient) {
// super(requestTokenEndpointUrl, accessTokenEndpointUrl, authorizationWebsiteUrl);
// this.okHttpClient = okHttpClient;
// }
//
// public void setOkHttpClient(OkHttpClient okHttpClient) {
// this.okHttpClient = okHttpClient;
// }
//
// @Override
// protected HttpRequest createRequest(String endpointUrl) throws Exception {
// final Request.Builder builder =
// new Request.Builder()
// .url(endpointUrl)
// .post(Util.EMPTY_REQUEST);
// if (endpointUrl.contains(Config.ACCESS_TOKEN_URL)) {
// final MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
// final String body =
// String.format("x_auth_mode=%s&x_auth_password=%s&x_auth_username=%s",
// Config.X_AUTH_MODE, Config.X_AUTH_PASSWORD, Config.X_AUTH_USERNAME);
// builder.post(RequestBody.create(mediaType, body));
// }
// return new OkHttpRequestAdapter(builder.build());
// }
//
// @Override
// protected HttpResponse sendRequest(HttpRequest request) throws Exception {
// Response response = okHttpClient.newCall((Request) request.unwrap()).execute();
// return new OkHttpResponseAdapter(response);
// }
// }
| import android.app.Application;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.jagsaund.rxuploader.sample.config.Config;
import com.jagsaund.rxuploader.sample.service.XOAuthProvider;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import rx.Completable;
import rx.Observable;
import se.akerfeldt.okhttp.signpost.OkHttpOAuthConsumer;
import timber.log.Timber; | package com.jagsaund.rxuploader.sample;
public class SampleApplication extends Application {
private static String token;
private static String secret;
@NonNull
public static Completable authorize() {
final OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
final HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor(); | // Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/config/Config.java
// public class Config {
// public static final String HOST = "https://api.500px.com/";
//
// public static final HttpLoggingInterceptor.Level HTTP_LOG_LEVEL =
// HttpLoggingInterceptor.Level.HEADERS;
//
//
// public static final String REQUEST_TOKEN_URL = HOST + "v1/oauth/request_token";
// public static final String ACCESS_TOKEN_URL = HOST + "v1/oauth/access_token";
// public static final String AUTH_CALLBACK_URL = "";
//
// public static final String CONSUMER_KEY = "<INSERT YOUR 500PX CONSUMER KEY>";
// public static final String CONSUMER_SECRET = "<INSERT YOUR 500PX CONSUMER SECRET>";
//
// public static final String X_AUTH_MODE = "client_auth";
// public static final String X_AUTH_USERNAME = "<INSERT YOUR 500PX USERNAME>";
// public static final String X_AUTH_PASSWORD = "<INSERT YOUR 500PX PASSWORD>";
//
// public static final String USERNAME = X_AUTH_USERNAME;
// }
//
// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/service/XOAuthProvider.java
// public class XOAuthProvider extends AbstractOAuthProvider {
//
// private transient OkHttpClient okHttpClient;
//
// public XOAuthProvider(String requestTokenEndpointUrl, String accessTokenEndpointUrl,
// String authorizationWebsiteUrl) {
// super(requestTokenEndpointUrl, accessTokenEndpointUrl, authorizationWebsiteUrl);
// this.okHttpClient = new OkHttpClient();
// }
//
// public XOAuthProvider(String requestTokenEndpointUrl, String accessTokenEndpointUrl,
// String authorizationWebsiteUrl, OkHttpClient okHttpClient) {
// super(requestTokenEndpointUrl, accessTokenEndpointUrl, authorizationWebsiteUrl);
// this.okHttpClient = okHttpClient;
// }
//
// public void setOkHttpClient(OkHttpClient okHttpClient) {
// this.okHttpClient = okHttpClient;
// }
//
// @Override
// protected HttpRequest createRequest(String endpointUrl) throws Exception {
// final Request.Builder builder =
// new Request.Builder()
// .url(endpointUrl)
// .post(Util.EMPTY_REQUEST);
// if (endpointUrl.contains(Config.ACCESS_TOKEN_URL)) {
// final MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
// final String body =
// String.format("x_auth_mode=%s&x_auth_password=%s&x_auth_username=%s",
// Config.X_AUTH_MODE, Config.X_AUTH_PASSWORD, Config.X_AUTH_USERNAME);
// builder.post(RequestBody.create(mediaType, body));
// }
// return new OkHttpRequestAdapter(builder.build());
// }
//
// @Override
// protected HttpResponse sendRequest(HttpRequest request) throws Exception {
// Response response = okHttpClient.newCall((Request) request.unwrap()).execute();
// return new OkHttpResponseAdapter(response);
// }
// }
// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/SampleApplication.java
import android.app.Application;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.jagsaund.rxuploader.sample.config.Config;
import com.jagsaund.rxuploader.sample.service.XOAuthProvider;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import rx.Completable;
import rx.Observable;
import se.akerfeldt.okhttp.signpost.OkHttpOAuthConsumer;
import timber.log.Timber;
package com.jagsaund.rxuploader.sample;
public class SampleApplication extends Application {
private static String token;
private static String secret;
@NonNull
public static Completable authorize() {
final OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
final HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor(); | loggingInterceptor.setLevel(Config.HTTP_LOG_LEVEL); |
jsaund/RxUploader | rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/SampleApplication.java | // Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/config/Config.java
// public class Config {
// public static final String HOST = "https://api.500px.com/";
//
// public static final HttpLoggingInterceptor.Level HTTP_LOG_LEVEL =
// HttpLoggingInterceptor.Level.HEADERS;
//
//
// public static final String REQUEST_TOKEN_URL = HOST + "v1/oauth/request_token";
// public static final String ACCESS_TOKEN_URL = HOST + "v1/oauth/access_token";
// public static final String AUTH_CALLBACK_URL = "";
//
// public static final String CONSUMER_KEY = "<INSERT YOUR 500PX CONSUMER KEY>";
// public static final String CONSUMER_SECRET = "<INSERT YOUR 500PX CONSUMER SECRET>";
//
// public static final String X_AUTH_MODE = "client_auth";
// public static final String X_AUTH_USERNAME = "<INSERT YOUR 500PX USERNAME>";
// public static final String X_AUTH_PASSWORD = "<INSERT YOUR 500PX PASSWORD>";
//
// public static final String USERNAME = X_AUTH_USERNAME;
// }
//
// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/service/XOAuthProvider.java
// public class XOAuthProvider extends AbstractOAuthProvider {
//
// private transient OkHttpClient okHttpClient;
//
// public XOAuthProvider(String requestTokenEndpointUrl, String accessTokenEndpointUrl,
// String authorizationWebsiteUrl) {
// super(requestTokenEndpointUrl, accessTokenEndpointUrl, authorizationWebsiteUrl);
// this.okHttpClient = new OkHttpClient();
// }
//
// public XOAuthProvider(String requestTokenEndpointUrl, String accessTokenEndpointUrl,
// String authorizationWebsiteUrl, OkHttpClient okHttpClient) {
// super(requestTokenEndpointUrl, accessTokenEndpointUrl, authorizationWebsiteUrl);
// this.okHttpClient = okHttpClient;
// }
//
// public void setOkHttpClient(OkHttpClient okHttpClient) {
// this.okHttpClient = okHttpClient;
// }
//
// @Override
// protected HttpRequest createRequest(String endpointUrl) throws Exception {
// final Request.Builder builder =
// new Request.Builder()
// .url(endpointUrl)
// .post(Util.EMPTY_REQUEST);
// if (endpointUrl.contains(Config.ACCESS_TOKEN_URL)) {
// final MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
// final String body =
// String.format("x_auth_mode=%s&x_auth_password=%s&x_auth_username=%s",
// Config.X_AUTH_MODE, Config.X_AUTH_PASSWORD, Config.X_AUTH_USERNAME);
// builder.post(RequestBody.create(mediaType, body));
// }
// return new OkHttpRequestAdapter(builder.build());
// }
//
// @Override
// protected HttpResponse sendRequest(HttpRequest request) throws Exception {
// Response response = okHttpClient.newCall((Request) request.unwrap()).execute();
// return new OkHttpResponseAdapter(response);
// }
// }
| import android.app.Application;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.jagsaund.rxuploader.sample.config.Config;
import com.jagsaund.rxuploader.sample.service.XOAuthProvider;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import rx.Completable;
import rx.Observable;
import se.akerfeldt.okhttp.signpost.OkHttpOAuthConsumer;
import timber.log.Timber; | package com.jagsaund.rxuploader.sample;
public class SampleApplication extends Application {
private static String token;
private static String secret;
@NonNull
public static Completable authorize() {
final OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
final HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
loggingInterceptor.setLevel(Config.HTTP_LOG_LEVEL);
httpClient.addInterceptor(loggingInterceptor);
final OkHttpOAuthConsumer consumer =
new OkHttpOAuthConsumer(Config.CONSUMER_KEY, Config.CONSUMER_SECRET);
| // Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/config/Config.java
// public class Config {
// public static final String HOST = "https://api.500px.com/";
//
// public static final HttpLoggingInterceptor.Level HTTP_LOG_LEVEL =
// HttpLoggingInterceptor.Level.HEADERS;
//
//
// public static final String REQUEST_TOKEN_URL = HOST + "v1/oauth/request_token";
// public static final String ACCESS_TOKEN_URL = HOST + "v1/oauth/access_token";
// public static final String AUTH_CALLBACK_URL = "";
//
// public static final String CONSUMER_KEY = "<INSERT YOUR 500PX CONSUMER KEY>";
// public static final String CONSUMER_SECRET = "<INSERT YOUR 500PX CONSUMER SECRET>";
//
// public static final String X_AUTH_MODE = "client_auth";
// public static final String X_AUTH_USERNAME = "<INSERT YOUR 500PX USERNAME>";
// public static final String X_AUTH_PASSWORD = "<INSERT YOUR 500PX PASSWORD>";
//
// public static final String USERNAME = X_AUTH_USERNAME;
// }
//
// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/service/XOAuthProvider.java
// public class XOAuthProvider extends AbstractOAuthProvider {
//
// private transient OkHttpClient okHttpClient;
//
// public XOAuthProvider(String requestTokenEndpointUrl, String accessTokenEndpointUrl,
// String authorizationWebsiteUrl) {
// super(requestTokenEndpointUrl, accessTokenEndpointUrl, authorizationWebsiteUrl);
// this.okHttpClient = new OkHttpClient();
// }
//
// public XOAuthProvider(String requestTokenEndpointUrl, String accessTokenEndpointUrl,
// String authorizationWebsiteUrl, OkHttpClient okHttpClient) {
// super(requestTokenEndpointUrl, accessTokenEndpointUrl, authorizationWebsiteUrl);
// this.okHttpClient = okHttpClient;
// }
//
// public void setOkHttpClient(OkHttpClient okHttpClient) {
// this.okHttpClient = okHttpClient;
// }
//
// @Override
// protected HttpRequest createRequest(String endpointUrl) throws Exception {
// final Request.Builder builder =
// new Request.Builder()
// .url(endpointUrl)
// .post(Util.EMPTY_REQUEST);
// if (endpointUrl.contains(Config.ACCESS_TOKEN_URL)) {
// final MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
// final String body =
// String.format("x_auth_mode=%s&x_auth_password=%s&x_auth_username=%s",
// Config.X_AUTH_MODE, Config.X_AUTH_PASSWORD, Config.X_AUTH_USERNAME);
// builder.post(RequestBody.create(mediaType, body));
// }
// return new OkHttpRequestAdapter(builder.build());
// }
//
// @Override
// protected HttpResponse sendRequest(HttpRequest request) throws Exception {
// Response response = okHttpClient.newCall((Request) request.unwrap()).execute();
// return new OkHttpResponseAdapter(response);
// }
// }
// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/SampleApplication.java
import android.app.Application;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.jagsaund.rxuploader.sample.config.Config;
import com.jagsaund.rxuploader.sample.service.XOAuthProvider;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import rx.Completable;
import rx.Observable;
import se.akerfeldt.okhttp.signpost.OkHttpOAuthConsumer;
import timber.log.Timber;
package com.jagsaund.rxuploader.sample;
public class SampleApplication extends Application {
private static String token;
private static String secret;
@NonNull
public static Completable authorize() {
final OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
final HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
loggingInterceptor.setLevel(Config.HTTP_LOG_LEVEL);
httpClient.addInterceptor(loggingInterceptor);
final OkHttpOAuthConsumer consumer =
new OkHttpOAuthConsumer(Config.CONSUMER_KEY, Config.CONSUMER_SECRET);
| final XOAuthProvider provider = |
jsaund/RxUploader | rxuploader/src/main/java/com/jagsaund/rxuploader/store/UploadDataStore.java | // Path: rxuploader/src/main/java/com/jagsaund/rxuploader/job/Job.java
// @AutoValue
// public abstract class Job {
// public static final String INVALID_JOB_ID = "invalid_job_id";
// public static final Map<String, Object> INVALID_METADATA = Collections.emptyMap();
// public static final Job INVALID_JOB = Job.builder()
// .setId(INVALID_JOB_ID)
// .setStatus(Status.createInvalid(INVALID_JOB_ID))
// .setFilepath("")
// .setMetadata(INVALID_METADATA)
// .setMimeType("")
// .build();
//
// public static boolean isInvalid(@NonNull Job job) {
// return INVALID_JOB == job || INVALID_JOB_ID.equals(job.id());
// }
//
// @NonNull
// public static TypeAdapter<Job> typeAdapter(Gson gson) {
// return new AutoValue_Job.GsonTypeAdapter(gson);
// }
//
// @NonNull
// public static Builder builder() {
// return new AutoValue_Job.Builder();
// }
//
// @NonNull
// public abstract String id();
//
// @NonNull
// public abstract Status status();
//
// @NonNull
// public Job withStatus(@NonNull Status status) {
// return toBuilder().setStatus(status).build();
// }
//
// @NonNull
// abstract Builder toBuilder();
//
// @NonNull
// public abstract String filepath();
//
// @NonNull
// public abstract Map<String, Object> metadata();
//
// @NonNull
// public abstract String mimeType();
//
// @AutoValue.Builder
// public abstract static class Builder {
// public abstract Builder setId(String jobId);
//
// public abstract Builder setStatus(Status status);
//
// public abstract Builder setFilepath(String filepath);
//
// public abstract Builder setMetadata(Map<String, Object> metadata);
//
// public abstract Builder setMimeType(String mimeType);
//
// public abstract Job build();
// }
// }
//
// Path: rxuploader/src/main/java/com/jagsaund/rxuploader/job/Status.java
// public class Status {
// @NonNull private final StatusType status;
// @NonNull private final String id;
//
// @Nullable private final ErrorType error;
//
// @Expose(serialize = false,
// deserialize = false) private final int progress;
//
// @Expose(serialize = false,
// deserialize = false) @Nullable private final Object response;
//
// private Status(@NonNull String id, @NonNull StatusType status, int progress,
// @Nullable ErrorType error, @Nullable Object response) {
// this.id = id;
// this.status = status;
// this.progress = progress;
// this.error = error;
// this.response = response;
// }
//
// @NonNull
// public static Status createQueued(@NonNull String id) {
// return new Status(id, StatusType.QUEUED, 0, null, null);
// }
//
// @NonNull
// public static Status createSending(@NonNull String id, int progress) {
// return new Status(id, StatusType.SENDING, progress, null, null);
// }
//
// @NonNull
// public static Status createCompleted(@NonNull String id, @Nullable Object response) {
// return new Status(id, StatusType.COMPLETED, 0, null, response);
// }
//
// @NonNull
// public static Status createFailed(@NonNull String id, @NonNull ErrorType error) {
// return new Status(id, StatusType.FAILED, 0, error, null);
// }
//
// @NonNull
// public static Status createInvalid(@NonNull String id) {
// return new Status(id, StatusType.INVALID, 0, null, null);
// }
//
// @NonNull
// public String id() {
// return id;
// }
//
// @NonNull
// public StatusType statusType() {
// return status;
// }
//
// public int progress() {
// return progress;
// }
//
// @NonNull
// public Status withProgress(int progress) {
// return createSending(id, progress);
// }
//
// @Nullable
// public ErrorType error() {
// return error;
// }
//
// @Nullable
// public Object response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Status jobStatus = (Status) o;
//
// if (progress != jobStatus.progress) return false;
// if (status != jobStatus.status) return false;
// if (error != jobStatus.error) return false;
// if (!id.equals(jobStatus.id)) return false;
// return response != null ? response.equals(jobStatus.response) : jobStatus.response == null;
// }
//
// @Override
// public int hashCode() {
// int result = status.hashCode();
// result = 31 * result + (error != null ? error.hashCode() : 0);
// result = 31 * result + id.hashCode();
// result = 31 * result + progress;
// result = 31 * result + (response != null ? response.hashCode() : 0);
// return result;
// }
//
// @Override
// public String toString() {
// return "JobStatus{"
// + "status="
// + status
// + ", id="
// + id
// + ", progress="
// + progress
// + ", error="
// + error
// + ", response="
// + response
// + '}';
// }
// }
| import android.support.annotation.NonNull;
import com.jagsaund.rxuploader.job.Job;
import com.jagsaund.rxuploader.job.Status;
import rx.Observable; | package com.jagsaund.rxuploader.store;
/**
* A local store for persisting and retrieving {@link Job} items.
*/
public interface UploadDataStore {
/**
* Retrieves a single {@link Job} for the provided {@code jobId}.
*
* @param jobId id of the job to retrieve from the store
* @return {@link Job} associated with the {@code jobId} or {@link Job#INVALID_JOB} if not found
*/
@NonNull | // Path: rxuploader/src/main/java/com/jagsaund/rxuploader/job/Job.java
// @AutoValue
// public abstract class Job {
// public static final String INVALID_JOB_ID = "invalid_job_id";
// public static final Map<String, Object> INVALID_METADATA = Collections.emptyMap();
// public static final Job INVALID_JOB = Job.builder()
// .setId(INVALID_JOB_ID)
// .setStatus(Status.createInvalid(INVALID_JOB_ID))
// .setFilepath("")
// .setMetadata(INVALID_METADATA)
// .setMimeType("")
// .build();
//
// public static boolean isInvalid(@NonNull Job job) {
// return INVALID_JOB == job || INVALID_JOB_ID.equals(job.id());
// }
//
// @NonNull
// public static TypeAdapter<Job> typeAdapter(Gson gson) {
// return new AutoValue_Job.GsonTypeAdapter(gson);
// }
//
// @NonNull
// public static Builder builder() {
// return new AutoValue_Job.Builder();
// }
//
// @NonNull
// public abstract String id();
//
// @NonNull
// public abstract Status status();
//
// @NonNull
// public Job withStatus(@NonNull Status status) {
// return toBuilder().setStatus(status).build();
// }
//
// @NonNull
// abstract Builder toBuilder();
//
// @NonNull
// public abstract String filepath();
//
// @NonNull
// public abstract Map<String, Object> metadata();
//
// @NonNull
// public abstract String mimeType();
//
// @AutoValue.Builder
// public abstract static class Builder {
// public abstract Builder setId(String jobId);
//
// public abstract Builder setStatus(Status status);
//
// public abstract Builder setFilepath(String filepath);
//
// public abstract Builder setMetadata(Map<String, Object> metadata);
//
// public abstract Builder setMimeType(String mimeType);
//
// public abstract Job build();
// }
// }
//
// Path: rxuploader/src/main/java/com/jagsaund/rxuploader/job/Status.java
// public class Status {
// @NonNull private final StatusType status;
// @NonNull private final String id;
//
// @Nullable private final ErrorType error;
//
// @Expose(serialize = false,
// deserialize = false) private final int progress;
//
// @Expose(serialize = false,
// deserialize = false) @Nullable private final Object response;
//
// private Status(@NonNull String id, @NonNull StatusType status, int progress,
// @Nullable ErrorType error, @Nullable Object response) {
// this.id = id;
// this.status = status;
// this.progress = progress;
// this.error = error;
// this.response = response;
// }
//
// @NonNull
// public static Status createQueued(@NonNull String id) {
// return new Status(id, StatusType.QUEUED, 0, null, null);
// }
//
// @NonNull
// public static Status createSending(@NonNull String id, int progress) {
// return new Status(id, StatusType.SENDING, progress, null, null);
// }
//
// @NonNull
// public static Status createCompleted(@NonNull String id, @Nullable Object response) {
// return new Status(id, StatusType.COMPLETED, 0, null, response);
// }
//
// @NonNull
// public static Status createFailed(@NonNull String id, @NonNull ErrorType error) {
// return new Status(id, StatusType.FAILED, 0, error, null);
// }
//
// @NonNull
// public static Status createInvalid(@NonNull String id) {
// return new Status(id, StatusType.INVALID, 0, null, null);
// }
//
// @NonNull
// public String id() {
// return id;
// }
//
// @NonNull
// public StatusType statusType() {
// return status;
// }
//
// public int progress() {
// return progress;
// }
//
// @NonNull
// public Status withProgress(int progress) {
// return createSending(id, progress);
// }
//
// @Nullable
// public ErrorType error() {
// return error;
// }
//
// @Nullable
// public Object response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Status jobStatus = (Status) o;
//
// if (progress != jobStatus.progress) return false;
// if (status != jobStatus.status) return false;
// if (error != jobStatus.error) return false;
// if (!id.equals(jobStatus.id)) return false;
// return response != null ? response.equals(jobStatus.response) : jobStatus.response == null;
// }
//
// @Override
// public int hashCode() {
// int result = status.hashCode();
// result = 31 * result + (error != null ? error.hashCode() : 0);
// result = 31 * result + id.hashCode();
// result = 31 * result + progress;
// result = 31 * result + (response != null ? response.hashCode() : 0);
// return result;
// }
//
// @Override
// public String toString() {
// return "JobStatus{"
// + "status="
// + status
// + ", id="
// + id
// + ", progress="
// + progress
// + ", error="
// + error
// + ", response="
// + response
// + '}';
// }
// }
// Path: rxuploader/src/main/java/com/jagsaund/rxuploader/store/UploadDataStore.java
import android.support.annotation.NonNull;
import com.jagsaund.rxuploader.job.Job;
import com.jagsaund.rxuploader.job.Status;
import rx.Observable;
package com.jagsaund.rxuploader.store;
/**
* A local store for persisting and retrieving {@link Job} items.
*/
public interface UploadDataStore {
/**
* Retrieves a single {@link Job} for the provided {@code jobId}.
*
* @param jobId id of the job to retrieve from the store
* @return {@link Job} associated with the {@code jobId} or {@link Job#INVALID_JOB} if not found
*/
@NonNull | Observable<Job> get(@NonNull String jobId); |
jsaund/RxUploader | rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/model/data/UploadDataModel.java | // Path: rxuploader/src/main/java/com/jagsaund/rxuploader/job/Status.java
// public class Status {
// @NonNull private final StatusType status;
// @NonNull private final String id;
//
// @Nullable private final ErrorType error;
//
// @Expose(serialize = false,
// deserialize = false) private final int progress;
//
// @Expose(serialize = false,
// deserialize = false) @Nullable private final Object response;
//
// private Status(@NonNull String id, @NonNull StatusType status, int progress,
// @Nullable ErrorType error, @Nullable Object response) {
// this.id = id;
// this.status = status;
// this.progress = progress;
// this.error = error;
// this.response = response;
// }
//
// @NonNull
// public static Status createQueued(@NonNull String id) {
// return new Status(id, StatusType.QUEUED, 0, null, null);
// }
//
// @NonNull
// public static Status createSending(@NonNull String id, int progress) {
// return new Status(id, StatusType.SENDING, progress, null, null);
// }
//
// @NonNull
// public static Status createCompleted(@NonNull String id, @Nullable Object response) {
// return new Status(id, StatusType.COMPLETED, 0, null, response);
// }
//
// @NonNull
// public static Status createFailed(@NonNull String id, @NonNull ErrorType error) {
// return new Status(id, StatusType.FAILED, 0, error, null);
// }
//
// @NonNull
// public static Status createInvalid(@NonNull String id) {
// return new Status(id, StatusType.INVALID, 0, null, null);
// }
//
// @NonNull
// public String id() {
// return id;
// }
//
// @NonNull
// public StatusType statusType() {
// return status;
// }
//
// public int progress() {
// return progress;
// }
//
// @NonNull
// public Status withProgress(int progress) {
// return createSending(id, progress);
// }
//
// @Nullable
// public ErrorType error() {
// return error;
// }
//
// @Nullable
// public Object response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Status jobStatus = (Status) o;
//
// if (progress != jobStatus.progress) return false;
// if (status != jobStatus.status) return false;
// if (error != jobStatus.error) return false;
// if (!id.equals(jobStatus.id)) return false;
// return response != null ? response.equals(jobStatus.response) : jobStatus.response == null;
// }
//
// @Override
// public int hashCode() {
// int result = status.hashCode();
// result = 31 * result + (error != null ? error.hashCode() : 0);
// result = 31 * result + id.hashCode();
// result = 31 * result + progress;
// result = 31 * result + (response != null ? response.hashCode() : 0);
// return result;
// }
//
// @Override
// public String toString() {
// return "JobStatus{"
// + "status="
// + status
// + ", id="
// + id
// + ", progress="
// + progress
// + ", error="
// + error
// + ", response="
// + response
// + '}';
// }
// }
| import android.support.annotation.NonNull;
import com.jagsaund.rxuploader.job.Status; | package com.jagsaund.rxuploader.sample.model.data;
public class UploadDataModel implements DataModel {
@NonNull
public static DataModel create(@NonNull String name, @NonNull String description, | // Path: rxuploader/src/main/java/com/jagsaund/rxuploader/job/Status.java
// public class Status {
// @NonNull private final StatusType status;
// @NonNull private final String id;
//
// @Nullable private final ErrorType error;
//
// @Expose(serialize = false,
// deserialize = false) private final int progress;
//
// @Expose(serialize = false,
// deserialize = false) @Nullable private final Object response;
//
// private Status(@NonNull String id, @NonNull StatusType status, int progress,
// @Nullable ErrorType error, @Nullable Object response) {
// this.id = id;
// this.status = status;
// this.progress = progress;
// this.error = error;
// this.response = response;
// }
//
// @NonNull
// public static Status createQueued(@NonNull String id) {
// return new Status(id, StatusType.QUEUED, 0, null, null);
// }
//
// @NonNull
// public static Status createSending(@NonNull String id, int progress) {
// return new Status(id, StatusType.SENDING, progress, null, null);
// }
//
// @NonNull
// public static Status createCompleted(@NonNull String id, @Nullable Object response) {
// return new Status(id, StatusType.COMPLETED, 0, null, response);
// }
//
// @NonNull
// public static Status createFailed(@NonNull String id, @NonNull ErrorType error) {
// return new Status(id, StatusType.FAILED, 0, error, null);
// }
//
// @NonNull
// public static Status createInvalid(@NonNull String id) {
// return new Status(id, StatusType.INVALID, 0, null, null);
// }
//
// @NonNull
// public String id() {
// return id;
// }
//
// @NonNull
// public StatusType statusType() {
// return status;
// }
//
// public int progress() {
// return progress;
// }
//
// @NonNull
// public Status withProgress(int progress) {
// return createSending(id, progress);
// }
//
// @Nullable
// public ErrorType error() {
// return error;
// }
//
// @Nullable
// public Object response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Status jobStatus = (Status) o;
//
// if (progress != jobStatus.progress) return false;
// if (status != jobStatus.status) return false;
// if (error != jobStatus.error) return false;
// if (!id.equals(jobStatus.id)) return false;
// return response != null ? response.equals(jobStatus.response) : jobStatus.response == null;
// }
//
// @Override
// public int hashCode() {
// int result = status.hashCode();
// result = 31 * result + (error != null ? error.hashCode() : 0);
// result = 31 * result + id.hashCode();
// result = 31 * result + progress;
// result = 31 * result + (response != null ? response.hashCode() : 0);
// return result;
// }
//
// @Override
// public String toString() {
// return "JobStatus{"
// + "status="
// + status
// + ", id="
// + id
// + ", progress="
// + progress
// + ", error="
// + error
// + ", response="
// + response
// + '}';
// }
// }
// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/model/data/UploadDataModel.java
import android.support.annotation.NonNull;
import com.jagsaund.rxuploader.job.Status;
package com.jagsaund.rxuploader.sample.model.data;
public class UploadDataModel implements DataModel {
@NonNull
public static DataModel create(@NonNull String name, @NonNull String description, | @NonNull Status status) { |
jsaund/RxUploader | rxuploader/src/main/java/com/jagsaund/rxuploader/UploadErrorAdapter.java | // Path: rxuploader/src/main/java/com/jagsaund/rxuploader/job/ErrorType.java
// public enum ErrorType {
// NETWORK("network"),
// FILE_NOT_FOUND("file_not_found"),
// SERVICE("service"),
// TERMINATED("terminated"),
// UNKNOWN("unknown");
//
// @NonNull private final String type;
//
// ErrorType(@NonNull String type) {
// this.type = type;
// }
//
// @NonNull
// @Override
// public String toString() {
// return "ErrorType: " + type;
// }
// }
| import android.support.annotation.NonNull;
import com.jagsaund.rxuploader.job.ErrorType; | package com.jagsaund.rxuploader;
/**
* Defines how the {@link Uploader} should handle errors. This includes mapping {@link Throwable} to
* {@link ErrorType} and determining which errors can be retried.
*/
public interface UploadErrorAdapter {
/**
* Maps {@link Throwable} to an {@link ErrorType}.
*
* @param error The error to map from
* @return an {@link ErrorType} representing the received {@code error}
*/
@NonNull | // Path: rxuploader/src/main/java/com/jagsaund/rxuploader/job/ErrorType.java
// public enum ErrorType {
// NETWORK("network"),
// FILE_NOT_FOUND("file_not_found"),
// SERVICE("service"),
// TERMINATED("terminated"),
// UNKNOWN("unknown");
//
// @NonNull private final String type;
//
// ErrorType(@NonNull String type) {
// this.type = type;
// }
//
// @NonNull
// @Override
// public String toString() {
// return "ErrorType: " + type;
// }
// }
// Path: rxuploader/src/main/java/com/jagsaund/rxuploader/UploadErrorAdapter.java
import android.support.annotation.NonNull;
import com.jagsaund.rxuploader.job.ErrorType;
package com.jagsaund.rxuploader;
/**
* Defines how the {@link Uploader} should handle errors. This includes mapping {@link Throwable} to
* {@link ErrorType} and determining which errors can be retried.
*/
public interface UploadErrorAdapter {
/**
* Maps {@link Throwable} to an {@link ErrorType}.
*
* @param error The error to map from
* @return an {@link ErrorType} representing the received {@code error}
*/
@NonNull | ErrorType fromThrowable(@NonNull Throwable error); |
jsaund/RxUploader | rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/model/data/DataModel.java | // Path: rxuploader/src/main/java/com/jagsaund/rxuploader/job/Status.java
// public class Status {
// @NonNull private final StatusType status;
// @NonNull private final String id;
//
// @Nullable private final ErrorType error;
//
// @Expose(serialize = false,
// deserialize = false) private final int progress;
//
// @Expose(serialize = false,
// deserialize = false) @Nullable private final Object response;
//
// private Status(@NonNull String id, @NonNull StatusType status, int progress,
// @Nullable ErrorType error, @Nullable Object response) {
// this.id = id;
// this.status = status;
// this.progress = progress;
// this.error = error;
// this.response = response;
// }
//
// @NonNull
// public static Status createQueued(@NonNull String id) {
// return new Status(id, StatusType.QUEUED, 0, null, null);
// }
//
// @NonNull
// public static Status createSending(@NonNull String id, int progress) {
// return new Status(id, StatusType.SENDING, progress, null, null);
// }
//
// @NonNull
// public static Status createCompleted(@NonNull String id, @Nullable Object response) {
// return new Status(id, StatusType.COMPLETED, 0, null, response);
// }
//
// @NonNull
// public static Status createFailed(@NonNull String id, @NonNull ErrorType error) {
// return new Status(id, StatusType.FAILED, 0, error, null);
// }
//
// @NonNull
// public static Status createInvalid(@NonNull String id) {
// return new Status(id, StatusType.INVALID, 0, null, null);
// }
//
// @NonNull
// public String id() {
// return id;
// }
//
// @NonNull
// public StatusType statusType() {
// return status;
// }
//
// public int progress() {
// return progress;
// }
//
// @NonNull
// public Status withProgress(int progress) {
// return createSending(id, progress);
// }
//
// @Nullable
// public ErrorType error() {
// return error;
// }
//
// @Nullable
// public Object response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Status jobStatus = (Status) o;
//
// if (progress != jobStatus.progress) return false;
// if (status != jobStatus.status) return false;
// if (error != jobStatus.error) return false;
// if (!id.equals(jobStatus.id)) return false;
// return response != null ? response.equals(jobStatus.response) : jobStatus.response == null;
// }
//
// @Override
// public int hashCode() {
// int result = status.hashCode();
// result = 31 * result + (error != null ? error.hashCode() : 0);
// result = 31 * result + id.hashCode();
// result = 31 * result + progress;
// result = 31 * result + (response != null ? response.hashCode() : 0);
// return result;
// }
//
// @Override
// public String toString() {
// return "JobStatus{"
// + "status="
// + status
// + ", id="
// + id
// + ", progress="
// + progress
// + ", error="
// + error
// + ", response="
// + response
// + '}';
// }
// }
| import android.support.annotation.NonNull;
import com.jagsaund.rxuploader.job.Status; | package com.jagsaund.rxuploader.sample.model.data;
public interface DataModel {
@DataModelType
int type();
@NonNull
String id();
@NonNull | // Path: rxuploader/src/main/java/com/jagsaund/rxuploader/job/Status.java
// public class Status {
// @NonNull private final StatusType status;
// @NonNull private final String id;
//
// @Nullable private final ErrorType error;
//
// @Expose(serialize = false,
// deserialize = false) private final int progress;
//
// @Expose(serialize = false,
// deserialize = false) @Nullable private final Object response;
//
// private Status(@NonNull String id, @NonNull StatusType status, int progress,
// @Nullable ErrorType error, @Nullable Object response) {
// this.id = id;
// this.status = status;
// this.progress = progress;
// this.error = error;
// this.response = response;
// }
//
// @NonNull
// public static Status createQueued(@NonNull String id) {
// return new Status(id, StatusType.QUEUED, 0, null, null);
// }
//
// @NonNull
// public static Status createSending(@NonNull String id, int progress) {
// return new Status(id, StatusType.SENDING, progress, null, null);
// }
//
// @NonNull
// public static Status createCompleted(@NonNull String id, @Nullable Object response) {
// return new Status(id, StatusType.COMPLETED, 0, null, response);
// }
//
// @NonNull
// public static Status createFailed(@NonNull String id, @NonNull ErrorType error) {
// return new Status(id, StatusType.FAILED, 0, error, null);
// }
//
// @NonNull
// public static Status createInvalid(@NonNull String id) {
// return new Status(id, StatusType.INVALID, 0, null, null);
// }
//
// @NonNull
// public String id() {
// return id;
// }
//
// @NonNull
// public StatusType statusType() {
// return status;
// }
//
// public int progress() {
// return progress;
// }
//
// @NonNull
// public Status withProgress(int progress) {
// return createSending(id, progress);
// }
//
// @Nullable
// public ErrorType error() {
// return error;
// }
//
// @Nullable
// public Object response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Status jobStatus = (Status) o;
//
// if (progress != jobStatus.progress) return false;
// if (status != jobStatus.status) return false;
// if (error != jobStatus.error) return false;
// if (!id.equals(jobStatus.id)) return false;
// return response != null ? response.equals(jobStatus.response) : jobStatus.response == null;
// }
//
// @Override
// public int hashCode() {
// int result = status.hashCode();
// result = 31 * result + (error != null ? error.hashCode() : 0);
// result = 31 * result + id.hashCode();
// result = 31 * result + progress;
// result = 31 * result + (response != null ? response.hashCode() : 0);
// return result;
// }
//
// @Override
// public String toString() {
// return "JobStatus{"
// + "status="
// + status
// + ", id="
// + id
// + ", progress="
// + progress
// + ", error="
// + error
// + ", response="
// + response
// + '}';
// }
// }
// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/model/data/DataModel.java
import android.support.annotation.NonNull;
import com.jagsaund.rxuploader.job.Status;
package com.jagsaund.rxuploader.sample.model.data;
public interface DataModel {
@DataModelType
int type();
@NonNull
String id();
@NonNull | Status getStatus(); |
jsaund/RxUploader | rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/service/ApiService.java | // Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/model/wire/PhotosJSONModel.java
// @AutoValue
// public abstract class PhotosJSONModel {
// @NonNull
// public static TypeAdapter<PhotosJSONModel> typeAdapter(Gson gson) {
// return new AutoValue_PhotosJSONModel.GsonTypeAdapter(gson);
// }
//
// @SerializedName("photos")
// public abstract List<PhotoJSONModel> photos();
// }
//
// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/model/wire/UploadPhotoJSONModel.java
// @AutoValue
// public abstract class UploadPhotoJSONModel {
// @NonNull
// public static TypeAdapter<UploadPhotoJSONModel> typeAdapter(Gson gson) {
// return new AutoValue_UploadPhotoJSONModel.GsonTypeAdapter(gson);
// }
//
// @SerializedName("photo")
// public abstract PhotoJSONModel photo();
// }
| import android.support.annotation.NonNull;
import com.jagsaund.rxuploader.sample.model.wire.PhotosJSONModel;
import com.jagsaund.rxuploader.sample.model.wire.UploadPhotoJSONModel;
import okhttp3.MultipartBody;
import retrofit2.http.GET;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.Part;
import retrofit2.http.Query;
import rx.Observable; | package com.jagsaund.rxuploader.sample.service;
public interface ApiService {
@NonNull
@GET("v1/photos?feature=user") | // Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/model/wire/PhotosJSONModel.java
// @AutoValue
// public abstract class PhotosJSONModel {
// @NonNull
// public static TypeAdapter<PhotosJSONModel> typeAdapter(Gson gson) {
// return new AutoValue_PhotosJSONModel.GsonTypeAdapter(gson);
// }
//
// @SerializedName("photos")
// public abstract List<PhotoJSONModel> photos();
// }
//
// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/model/wire/UploadPhotoJSONModel.java
// @AutoValue
// public abstract class UploadPhotoJSONModel {
// @NonNull
// public static TypeAdapter<UploadPhotoJSONModel> typeAdapter(Gson gson) {
// return new AutoValue_UploadPhotoJSONModel.GsonTypeAdapter(gson);
// }
//
// @SerializedName("photo")
// public abstract PhotoJSONModel photo();
// }
// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/service/ApiService.java
import android.support.annotation.NonNull;
import com.jagsaund.rxuploader.sample.model.wire.PhotosJSONModel;
import com.jagsaund.rxuploader.sample.model.wire.UploadPhotoJSONModel;
import okhttp3.MultipartBody;
import retrofit2.http.GET;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.Part;
import retrofit2.http.Query;
import rx.Observable;
package com.jagsaund.rxuploader.sample.service;
public interface ApiService {
@NonNull
@GET("v1/photos?feature=user") | Observable<PhotosJSONModel> getPhotos(@Query("username") @NonNull String username); |
jsaund/RxUploader | rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/service/ApiService.java | // Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/model/wire/PhotosJSONModel.java
// @AutoValue
// public abstract class PhotosJSONModel {
// @NonNull
// public static TypeAdapter<PhotosJSONModel> typeAdapter(Gson gson) {
// return new AutoValue_PhotosJSONModel.GsonTypeAdapter(gson);
// }
//
// @SerializedName("photos")
// public abstract List<PhotoJSONModel> photos();
// }
//
// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/model/wire/UploadPhotoJSONModel.java
// @AutoValue
// public abstract class UploadPhotoJSONModel {
// @NonNull
// public static TypeAdapter<UploadPhotoJSONModel> typeAdapter(Gson gson) {
// return new AutoValue_UploadPhotoJSONModel.GsonTypeAdapter(gson);
// }
//
// @SerializedName("photo")
// public abstract PhotoJSONModel photo();
// }
| import android.support.annotation.NonNull;
import com.jagsaund.rxuploader.sample.model.wire.PhotosJSONModel;
import com.jagsaund.rxuploader.sample.model.wire.UploadPhotoJSONModel;
import okhttp3.MultipartBody;
import retrofit2.http.GET;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.Part;
import retrofit2.http.Query;
import rx.Observable; | package com.jagsaund.rxuploader.sample.service;
public interface ApiService {
@NonNull
@GET("v1/photos?feature=user")
Observable<PhotosJSONModel> getPhotos(@Query("username") @NonNull String username);
@NonNull
@Multipart
@POST("v1/photos/upload") | // Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/model/wire/PhotosJSONModel.java
// @AutoValue
// public abstract class PhotosJSONModel {
// @NonNull
// public static TypeAdapter<PhotosJSONModel> typeAdapter(Gson gson) {
// return new AutoValue_PhotosJSONModel.GsonTypeAdapter(gson);
// }
//
// @SerializedName("photos")
// public abstract List<PhotoJSONModel> photos();
// }
//
// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/model/wire/UploadPhotoJSONModel.java
// @AutoValue
// public abstract class UploadPhotoJSONModel {
// @NonNull
// public static TypeAdapter<UploadPhotoJSONModel> typeAdapter(Gson gson) {
// return new AutoValue_UploadPhotoJSONModel.GsonTypeAdapter(gson);
// }
//
// @SerializedName("photo")
// public abstract PhotoJSONModel photo();
// }
// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/service/ApiService.java
import android.support.annotation.NonNull;
import com.jagsaund.rxuploader.sample.model.wire.PhotosJSONModel;
import com.jagsaund.rxuploader.sample.model.wire.UploadPhotoJSONModel;
import okhttp3.MultipartBody;
import retrofit2.http.GET;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.Part;
import retrofit2.http.Query;
import rx.Observable;
package com.jagsaund.rxuploader.sample.service;
public interface ApiService {
@NonNull
@GET("v1/photos?feature=user")
Observable<PhotosJSONModel> getPhotos(@Query("username") @NonNull String username);
@NonNull
@Multipart
@POST("v1/photos/upload") | Observable<UploadPhotoJSONModel> uploadPhoto(@Query("name") @NonNull String name, |
jsaund/RxUploader | rxuploader/src/test/java/com/jagsaund/rxuploader/rx/RxRequestBodyTest.java | // Path: rxuploader/src/main/java/com/jagsaund/rxuploader/job/Status.java
// public class Status {
// @NonNull private final StatusType status;
// @NonNull private final String id;
//
// @Nullable private final ErrorType error;
//
// @Expose(serialize = false,
// deserialize = false) private final int progress;
//
// @Expose(serialize = false,
// deserialize = false) @Nullable private final Object response;
//
// private Status(@NonNull String id, @NonNull StatusType status, int progress,
// @Nullable ErrorType error, @Nullable Object response) {
// this.id = id;
// this.status = status;
// this.progress = progress;
// this.error = error;
// this.response = response;
// }
//
// @NonNull
// public static Status createQueued(@NonNull String id) {
// return new Status(id, StatusType.QUEUED, 0, null, null);
// }
//
// @NonNull
// public static Status createSending(@NonNull String id, int progress) {
// return new Status(id, StatusType.SENDING, progress, null, null);
// }
//
// @NonNull
// public static Status createCompleted(@NonNull String id, @Nullable Object response) {
// return new Status(id, StatusType.COMPLETED, 0, null, response);
// }
//
// @NonNull
// public static Status createFailed(@NonNull String id, @NonNull ErrorType error) {
// return new Status(id, StatusType.FAILED, 0, error, null);
// }
//
// @NonNull
// public static Status createInvalid(@NonNull String id) {
// return new Status(id, StatusType.INVALID, 0, null, null);
// }
//
// @NonNull
// public String id() {
// return id;
// }
//
// @NonNull
// public StatusType statusType() {
// return status;
// }
//
// public int progress() {
// return progress;
// }
//
// @NonNull
// public Status withProgress(int progress) {
// return createSending(id, progress);
// }
//
// @Nullable
// public ErrorType error() {
// return error;
// }
//
// @Nullable
// public Object response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Status jobStatus = (Status) o;
//
// if (progress != jobStatus.progress) return false;
// if (status != jobStatus.status) return false;
// if (error != jobStatus.error) return false;
// if (!id.equals(jobStatus.id)) return false;
// return response != null ? response.equals(jobStatus.response) : jobStatus.response == null;
// }
//
// @Override
// public int hashCode() {
// int result = status.hashCode();
// result = 31 * result + (error != null ? error.hashCode() : 0);
// result = 31 * result + id.hashCode();
// result = 31 * result + progress;
// result = 31 * result + (response != null ? response.hashCode() : 0);
// return result;
// }
//
// @Override
// public String toString() {
// return "JobStatus{"
// + "status="
// + status
// + ", id="
// + id
// + ", progress="
// + progress
// + ", error="
// + error
// + ", response="
// + response
// + '}';
// }
// }
| import com.jagsaund.rxuploader.job.Status;
import java.io.IOException;
import java.io.InputStream;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import okio.BufferedSink;
import okio.Source;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;
import rx.Emitter;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyLong;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; | package com.jagsaund.rxuploader.rx;
@RunWith(MockitoJUnitRunner.class)
public class RxRequestBodyTest {
@Test
public void testWrite() throws Exception {
final String jobId = "test-job-id";
final long length = RxRequestBody.BUFFER_SIZE * 3;
final BufferedSink sink = mock(BufferedSink.class);
final InputStream inputStream = mock(InputStream.class); | // Path: rxuploader/src/main/java/com/jagsaund/rxuploader/job/Status.java
// public class Status {
// @NonNull private final StatusType status;
// @NonNull private final String id;
//
// @Nullable private final ErrorType error;
//
// @Expose(serialize = false,
// deserialize = false) private final int progress;
//
// @Expose(serialize = false,
// deserialize = false) @Nullable private final Object response;
//
// private Status(@NonNull String id, @NonNull StatusType status, int progress,
// @Nullable ErrorType error, @Nullable Object response) {
// this.id = id;
// this.status = status;
// this.progress = progress;
// this.error = error;
// this.response = response;
// }
//
// @NonNull
// public static Status createQueued(@NonNull String id) {
// return new Status(id, StatusType.QUEUED, 0, null, null);
// }
//
// @NonNull
// public static Status createSending(@NonNull String id, int progress) {
// return new Status(id, StatusType.SENDING, progress, null, null);
// }
//
// @NonNull
// public static Status createCompleted(@NonNull String id, @Nullable Object response) {
// return new Status(id, StatusType.COMPLETED, 0, null, response);
// }
//
// @NonNull
// public static Status createFailed(@NonNull String id, @NonNull ErrorType error) {
// return new Status(id, StatusType.FAILED, 0, error, null);
// }
//
// @NonNull
// public static Status createInvalid(@NonNull String id) {
// return new Status(id, StatusType.INVALID, 0, null, null);
// }
//
// @NonNull
// public String id() {
// return id;
// }
//
// @NonNull
// public StatusType statusType() {
// return status;
// }
//
// public int progress() {
// return progress;
// }
//
// @NonNull
// public Status withProgress(int progress) {
// return createSending(id, progress);
// }
//
// @Nullable
// public ErrorType error() {
// return error;
// }
//
// @Nullable
// public Object response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Status jobStatus = (Status) o;
//
// if (progress != jobStatus.progress) return false;
// if (status != jobStatus.status) return false;
// if (error != jobStatus.error) return false;
// if (!id.equals(jobStatus.id)) return false;
// return response != null ? response.equals(jobStatus.response) : jobStatus.response == null;
// }
//
// @Override
// public int hashCode() {
// int result = status.hashCode();
// result = 31 * result + (error != null ? error.hashCode() : 0);
// result = 31 * result + id.hashCode();
// result = 31 * result + progress;
// result = 31 * result + (response != null ? response.hashCode() : 0);
// return result;
// }
//
// @Override
// public String toString() {
// return "JobStatus{"
// + "status="
// + status
// + ", id="
// + id
// + ", progress="
// + progress
// + ", error="
// + error
// + ", response="
// + response
// + '}';
// }
// }
// Path: rxuploader/src/test/java/com/jagsaund/rxuploader/rx/RxRequestBodyTest.java
import com.jagsaund.rxuploader.job.Status;
import java.io.IOException;
import java.io.InputStream;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import okio.BufferedSink;
import okio.Source;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;
import rx.Emitter;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyLong;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
package com.jagsaund.rxuploader.rx;
@RunWith(MockitoJUnitRunner.class)
public class RxRequestBodyTest {
@Test
public void testWrite() throws Exception {
final String jobId = "test-job-id";
final long length = RxRequestBody.BUFFER_SIZE * 3;
final BufferedSink sink = mock(BufferedSink.class);
final InputStream inputStream = mock(InputStream.class); | final Emitter<Status> emitter = mock(Emitter.class); |
jsaund/RxUploader | rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/model/data/PhotoDataModel.java | // Path: rxuploader/src/main/java/com/jagsaund/rxuploader/job/Status.java
// public class Status {
// @NonNull private final StatusType status;
// @NonNull private final String id;
//
// @Nullable private final ErrorType error;
//
// @Expose(serialize = false,
// deserialize = false) private final int progress;
//
// @Expose(serialize = false,
// deserialize = false) @Nullable private final Object response;
//
// private Status(@NonNull String id, @NonNull StatusType status, int progress,
// @Nullable ErrorType error, @Nullable Object response) {
// this.id = id;
// this.status = status;
// this.progress = progress;
// this.error = error;
// this.response = response;
// }
//
// @NonNull
// public static Status createQueued(@NonNull String id) {
// return new Status(id, StatusType.QUEUED, 0, null, null);
// }
//
// @NonNull
// public static Status createSending(@NonNull String id, int progress) {
// return new Status(id, StatusType.SENDING, progress, null, null);
// }
//
// @NonNull
// public static Status createCompleted(@NonNull String id, @Nullable Object response) {
// return new Status(id, StatusType.COMPLETED, 0, null, response);
// }
//
// @NonNull
// public static Status createFailed(@NonNull String id, @NonNull ErrorType error) {
// return new Status(id, StatusType.FAILED, 0, error, null);
// }
//
// @NonNull
// public static Status createInvalid(@NonNull String id) {
// return new Status(id, StatusType.INVALID, 0, null, null);
// }
//
// @NonNull
// public String id() {
// return id;
// }
//
// @NonNull
// public StatusType statusType() {
// return status;
// }
//
// public int progress() {
// return progress;
// }
//
// @NonNull
// public Status withProgress(int progress) {
// return createSending(id, progress);
// }
//
// @Nullable
// public ErrorType error() {
// return error;
// }
//
// @Nullable
// public Object response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Status jobStatus = (Status) o;
//
// if (progress != jobStatus.progress) return false;
// if (status != jobStatus.status) return false;
// if (error != jobStatus.error) return false;
// if (!id.equals(jobStatus.id)) return false;
// return response != null ? response.equals(jobStatus.response) : jobStatus.response == null;
// }
//
// @Override
// public int hashCode() {
// int result = status.hashCode();
// result = 31 * result + (error != null ? error.hashCode() : 0);
// result = 31 * result + id.hashCode();
// result = 31 * result + progress;
// result = 31 * result + (response != null ? response.hashCode() : 0);
// return result;
// }
//
// @Override
// public String toString() {
// return "JobStatus{"
// + "status="
// + status
// + ", id="
// + id
// + ", progress="
// + progress
// + ", error="
// + error
// + ", response="
// + response
// + '}';
// }
// }
//
// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/model/wire/PhotoJSONModel.java
// @AutoValue
// public abstract class PhotoJSONModel {
// @NonNull
// public static TypeAdapter<PhotoJSONModel> typeAdapter(Gson gson) {
// return new AutoValue_PhotoJSONModel.GsonTypeAdapter(gson);
// }
//
// @SerializedName("id")
// public abstract int id();
//
// @SerializedName("user_id")
// public abstract Integer userId();
//
// @SerializedName("name")
// public abstract String name();
//
// @Nullable
// @SerializedName("description")
// public abstract String description();
//
// @SerializedName("width")
// public abstract int width();
//
// @SerializedName("height")
// public abstract int height();
//
// @SerializedName("image_url")
// public abstract String imageUrl();
//
// @SerializedName("images")
// public abstract List<ImageJSONModel> images();
//
// @SerializedName("user")
// public abstract UserJSONModel user();
// }
//
// Path: rxuploader/src/main/java/com/jagsaund/rxuploader/utils/StringUtils.java
// public class StringUtils {
// private StringUtils() {
// }
//
// public static boolean isNullOrEmpty(@Nullable CharSequence s) {
// return s == null || s.length() == 0;
// }
//
// @NonNull
// public static String getOrDefault(@Nullable String s, @NonNull String t) {
// return s != null ? s : t;
// }
//
// @NonNull
// public static String getOrEmpty(@Nullable String s) {
// return getOrDefault(s, "");
// }
// }
| import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.jagsaund.rxuploader.job.Status;
import com.jagsaund.rxuploader.sample.model.wire.PhotoJSONModel;
import com.jagsaund.rxuploader.utils.StringUtils; | package com.jagsaund.rxuploader.sample.model.data;
public class PhotoDataModel implements DataModel {
@NonNull | // Path: rxuploader/src/main/java/com/jagsaund/rxuploader/job/Status.java
// public class Status {
// @NonNull private final StatusType status;
// @NonNull private final String id;
//
// @Nullable private final ErrorType error;
//
// @Expose(serialize = false,
// deserialize = false) private final int progress;
//
// @Expose(serialize = false,
// deserialize = false) @Nullable private final Object response;
//
// private Status(@NonNull String id, @NonNull StatusType status, int progress,
// @Nullable ErrorType error, @Nullable Object response) {
// this.id = id;
// this.status = status;
// this.progress = progress;
// this.error = error;
// this.response = response;
// }
//
// @NonNull
// public static Status createQueued(@NonNull String id) {
// return new Status(id, StatusType.QUEUED, 0, null, null);
// }
//
// @NonNull
// public static Status createSending(@NonNull String id, int progress) {
// return new Status(id, StatusType.SENDING, progress, null, null);
// }
//
// @NonNull
// public static Status createCompleted(@NonNull String id, @Nullable Object response) {
// return new Status(id, StatusType.COMPLETED, 0, null, response);
// }
//
// @NonNull
// public static Status createFailed(@NonNull String id, @NonNull ErrorType error) {
// return new Status(id, StatusType.FAILED, 0, error, null);
// }
//
// @NonNull
// public static Status createInvalid(@NonNull String id) {
// return new Status(id, StatusType.INVALID, 0, null, null);
// }
//
// @NonNull
// public String id() {
// return id;
// }
//
// @NonNull
// public StatusType statusType() {
// return status;
// }
//
// public int progress() {
// return progress;
// }
//
// @NonNull
// public Status withProgress(int progress) {
// return createSending(id, progress);
// }
//
// @Nullable
// public ErrorType error() {
// return error;
// }
//
// @Nullable
// public Object response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Status jobStatus = (Status) o;
//
// if (progress != jobStatus.progress) return false;
// if (status != jobStatus.status) return false;
// if (error != jobStatus.error) return false;
// if (!id.equals(jobStatus.id)) return false;
// return response != null ? response.equals(jobStatus.response) : jobStatus.response == null;
// }
//
// @Override
// public int hashCode() {
// int result = status.hashCode();
// result = 31 * result + (error != null ? error.hashCode() : 0);
// result = 31 * result + id.hashCode();
// result = 31 * result + progress;
// result = 31 * result + (response != null ? response.hashCode() : 0);
// return result;
// }
//
// @Override
// public String toString() {
// return "JobStatus{"
// + "status="
// + status
// + ", id="
// + id
// + ", progress="
// + progress
// + ", error="
// + error
// + ", response="
// + response
// + '}';
// }
// }
//
// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/model/wire/PhotoJSONModel.java
// @AutoValue
// public abstract class PhotoJSONModel {
// @NonNull
// public static TypeAdapter<PhotoJSONModel> typeAdapter(Gson gson) {
// return new AutoValue_PhotoJSONModel.GsonTypeAdapter(gson);
// }
//
// @SerializedName("id")
// public abstract int id();
//
// @SerializedName("user_id")
// public abstract Integer userId();
//
// @SerializedName("name")
// public abstract String name();
//
// @Nullable
// @SerializedName("description")
// public abstract String description();
//
// @SerializedName("width")
// public abstract int width();
//
// @SerializedName("height")
// public abstract int height();
//
// @SerializedName("image_url")
// public abstract String imageUrl();
//
// @SerializedName("images")
// public abstract List<ImageJSONModel> images();
//
// @SerializedName("user")
// public abstract UserJSONModel user();
// }
//
// Path: rxuploader/src/main/java/com/jagsaund/rxuploader/utils/StringUtils.java
// public class StringUtils {
// private StringUtils() {
// }
//
// public static boolean isNullOrEmpty(@Nullable CharSequence s) {
// return s == null || s.length() == 0;
// }
//
// @NonNull
// public static String getOrDefault(@Nullable String s, @NonNull String t) {
// return s != null ? s : t;
// }
//
// @NonNull
// public static String getOrEmpty(@Nullable String s) {
// return getOrDefault(s, "");
// }
// }
// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/model/data/PhotoDataModel.java
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.jagsaund.rxuploader.job.Status;
import com.jagsaund.rxuploader.sample.model.wire.PhotoJSONModel;
import com.jagsaund.rxuploader.utils.StringUtils;
package com.jagsaund.rxuploader.sample.model.data;
public class PhotoDataModel implements DataModel {
@NonNull | public static DataModel create(@NonNull PhotoJSONModel model) { |
jsaund/RxUploader | rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/model/data/PhotoDataModel.java | // Path: rxuploader/src/main/java/com/jagsaund/rxuploader/job/Status.java
// public class Status {
// @NonNull private final StatusType status;
// @NonNull private final String id;
//
// @Nullable private final ErrorType error;
//
// @Expose(serialize = false,
// deserialize = false) private final int progress;
//
// @Expose(serialize = false,
// deserialize = false) @Nullable private final Object response;
//
// private Status(@NonNull String id, @NonNull StatusType status, int progress,
// @Nullable ErrorType error, @Nullable Object response) {
// this.id = id;
// this.status = status;
// this.progress = progress;
// this.error = error;
// this.response = response;
// }
//
// @NonNull
// public static Status createQueued(@NonNull String id) {
// return new Status(id, StatusType.QUEUED, 0, null, null);
// }
//
// @NonNull
// public static Status createSending(@NonNull String id, int progress) {
// return new Status(id, StatusType.SENDING, progress, null, null);
// }
//
// @NonNull
// public static Status createCompleted(@NonNull String id, @Nullable Object response) {
// return new Status(id, StatusType.COMPLETED, 0, null, response);
// }
//
// @NonNull
// public static Status createFailed(@NonNull String id, @NonNull ErrorType error) {
// return new Status(id, StatusType.FAILED, 0, error, null);
// }
//
// @NonNull
// public static Status createInvalid(@NonNull String id) {
// return new Status(id, StatusType.INVALID, 0, null, null);
// }
//
// @NonNull
// public String id() {
// return id;
// }
//
// @NonNull
// public StatusType statusType() {
// return status;
// }
//
// public int progress() {
// return progress;
// }
//
// @NonNull
// public Status withProgress(int progress) {
// return createSending(id, progress);
// }
//
// @Nullable
// public ErrorType error() {
// return error;
// }
//
// @Nullable
// public Object response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Status jobStatus = (Status) o;
//
// if (progress != jobStatus.progress) return false;
// if (status != jobStatus.status) return false;
// if (error != jobStatus.error) return false;
// if (!id.equals(jobStatus.id)) return false;
// return response != null ? response.equals(jobStatus.response) : jobStatus.response == null;
// }
//
// @Override
// public int hashCode() {
// int result = status.hashCode();
// result = 31 * result + (error != null ? error.hashCode() : 0);
// result = 31 * result + id.hashCode();
// result = 31 * result + progress;
// result = 31 * result + (response != null ? response.hashCode() : 0);
// return result;
// }
//
// @Override
// public String toString() {
// return "JobStatus{"
// + "status="
// + status
// + ", id="
// + id
// + ", progress="
// + progress
// + ", error="
// + error
// + ", response="
// + response
// + '}';
// }
// }
//
// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/model/wire/PhotoJSONModel.java
// @AutoValue
// public abstract class PhotoJSONModel {
// @NonNull
// public static TypeAdapter<PhotoJSONModel> typeAdapter(Gson gson) {
// return new AutoValue_PhotoJSONModel.GsonTypeAdapter(gson);
// }
//
// @SerializedName("id")
// public abstract int id();
//
// @SerializedName("user_id")
// public abstract Integer userId();
//
// @SerializedName("name")
// public abstract String name();
//
// @Nullable
// @SerializedName("description")
// public abstract String description();
//
// @SerializedName("width")
// public abstract int width();
//
// @SerializedName("height")
// public abstract int height();
//
// @SerializedName("image_url")
// public abstract String imageUrl();
//
// @SerializedName("images")
// public abstract List<ImageJSONModel> images();
//
// @SerializedName("user")
// public abstract UserJSONModel user();
// }
//
// Path: rxuploader/src/main/java/com/jagsaund/rxuploader/utils/StringUtils.java
// public class StringUtils {
// private StringUtils() {
// }
//
// public static boolean isNullOrEmpty(@Nullable CharSequence s) {
// return s == null || s.length() == 0;
// }
//
// @NonNull
// public static String getOrDefault(@Nullable String s, @NonNull String t) {
// return s != null ? s : t;
// }
//
// @NonNull
// public static String getOrEmpty(@Nullable String s) {
// return getOrDefault(s, "");
// }
// }
| import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.jagsaund.rxuploader.job.Status;
import com.jagsaund.rxuploader.sample.model.wire.PhotoJSONModel;
import com.jagsaund.rxuploader.utils.StringUtils; | package com.jagsaund.rxuploader.sample.model.data;
public class PhotoDataModel implements DataModel {
@NonNull
public static DataModel create(@NonNull PhotoJSONModel model) {
return new PhotoDataModel(String.valueOf(model.id()), model.name(),
model.description(), model.imageUrl());
}
@NonNull private final String id;
@NonNull private final String name;
@NonNull private final String description;
@NonNull private final String url; | // Path: rxuploader/src/main/java/com/jagsaund/rxuploader/job/Status.java
// public class Status {
// @NonNull private final StatusType status;
// @NonNull private final String id;
//
// @Nullable private final ErrorType error;
//
// @Expose(serialize = false,
// deserialize = false) private final int progress;
//
// @Expose(serialize = false,
// deserialize = false) @Nullable private final Object response;
//
// private Status(@NonNull String id, @NonNull StatusType status, int progress,
// @Nullable ErrorType error, @Nullable Object response) {
// this.id = id;
// this.status = status;
// this.progress = progress;
// this.error = error;
// this.response = response;
// }
//
// @NonNull
// public static Status createQueued(@NonNull String id) {
// return new Status(id, StatusType.QUEUED, 0, null, null);
// }
//
// @NonNull
// public static Status createSending(@NonNull String id, int progress) {
// return new Status(id, StatusType.SENDING, progress, null, null);
// }
//
// @NonNull
// public static Status createCompleted(@NonNull String id, @Nullable Object response) {
// return new Status(id, StatusType.COMPLETED, 0, null, response);
// }
//
// @NonNull
// public static Status createFailed(@NonNull String id, @NonNull ErrorType error) {
// return new Status(id, StatusType.FAILED, 0, error, null);
// }
//
// @NonNull
// public static Status createInvalid(@NonNull String id) {
// return new Status(id, StatusType.INVALID, 0, null, null);
// }
//
// @NonNull
// public String id() {
// return id;
// }
//
// @NonNull
// public StatusType statusType() {
// return status;
// }
//
// public int progress() {
// return progress;
// }
//
// @NonNull
// public Status withProgress(int progress) {
// return createSending(id, progress);
// }
//
// @Nullable
// public ErrorType error() {
// return error;
// }
//
// @Nullable
// public Object response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Status jobStatus = (Status) o;
//
// if (progress != jobStatus.progress) return false;
// if (status != jobStatus.status) return false;
// if (error != jobStatus.error) return false;
// if (!id.equals(jobStatus.id)) return false;
// return response != null ? response.equals(jobStatus.response) : jobStatus.response == null;
// }
//
// @Override
// public int hashCode() {
// int result = status.hashCode();
// result = 31 * result + (error != null ? error.hashCode() : 0);
// result = 31 * result + id.hashCode();
// result = 31 * result + progress;
// result = 31 * result + (response != null ? response.hashCode() : 0);
// return result;
// }
//
// @Override
// public String toString() {
// return "JobStatus{"
// + "status="
// + status
// + ", id="
// + id
// + ", progress="
// + progress
// + ", error="
// + error
// + ", response="
// + response
// + '}';
// }
// }
//
// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/model/wire/PhotoJSONModel.java
// @AutoValue
// public abstract class PhotoJSONModel {
// @NonNull
// public static TypeAdapter<PhotoJSONModel> typeAdapter(Gson gson) {
// return new AutoValue_PhotoJSONModel.GsonTypeAdapter(gson);
// }
//
// @SerializedName("id")
// public abstract int id();
//
// @SerializedName("user_id")
// public abstract Integer userId();
//
// @SerializedName("name")
// public abstract String name();
//
// @Nullable
// @SerializedName("description")
// public abstract String description();
//
// @SerializedName("width")
// public abstract int width();
//
// @SerializedName("height")
// public abstract int height();
//
// @SerializedName("image_url")
// public abstract String imageUrl();
//
// @SerializedName("images")
// public abstract List<ImageJSONModel> images();
//
// @SerializedName("user")
// public abstract UserJSONModel user();
// }
//
// Path: rxuploader/src/main/java/com/jagsaund/rxuploader/utils/StringUtils.java
// public class StringUtils {
// private StringUtils() {
// }
//
// public static boolean isNullOrEmpty(@Nullable CharSequence s) {
// return s == null || s.length() == 0;
// }
//
// @NonNull
// public static String getOrDefault(@Nullable String s, @NonNull String t) {
// return s != null ? s : t;
// }
//
// @NonNull
// public static String getOrEmpty(@Nullable String s) {
// return getOrDefault(s, "");
// }
// }
// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/model/data/PhotoDataModel.java
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.jagsaund.rxuploader.job.Status;
import com.jagsaund.rxuploader.sample.model.wire.PhotoJSONModel;
import com.jagsaund.rxuploader.utils.StringUtils;
package com.jagsaund.rxuploader.sample.model.data;
public class PhotoDataModel implements DataModel {
@NonNull
public static DataModel create(@NonNull PhotoJSONModel model) {
return new PhotoDataModel(String.valueOf(model.id()), model.name(),
model.description(), model.imageUrl());
}
@NonNull private final String id;
@NonNull private final String name;
@NonNull private final String description;
@NonNull private final String url; | @NonNull private final Status status; |
jsaund/RxUploader | rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/model/data/PhotoDataModel.java | // Path: rxuploader/src/main/java/com/jagsaund/rxuploader/job/Status.java
// public class Status {
// @NonNull private final StatusType status;
// @NonNull private final String id;
//
// @Nullable private final ErrorType error;
//
// @Expose(serialize = false,
// deserialize = false) private final int progress;
//
// @Expose(serialize = false,
// deserialize = false) @Nullable private final Object response;
//
// private Status(@NonNull String id, @NonNull StatusType status, int progress,
// @Nullable ErrorType error, @Nullable Object response) {
// this.id = id;
// this.status = status;
// this.progress = progress;
// this.error = error;
// this.response = response;
// }
//
// @NonNull
// public static Status createQueued(@NonNull String id) {
// return new Status(id, StatusType.QUEUED, 0, null, null);
// }
//
// @NonNull
// public static Status createSending(@NonNull String id, int progress) {
// return new Status(id, StatusType.SENDING, progress, null, null);
// }
//
// @NonNull
// public static Status createCompleted(@NonNull String id, @Nullable Object response) {
// return new Status(id, StatusType.COMPLETED, 0, null, response);
// }
//
// @NonNull
// public static Status createFailed(@NonNull String id, @NonNull ErrorType error) {
// return new Status(id, StatusType.FAILED, 0, error, null);
// }
//
// @NonNull
// public static Status createInvalid(@NonNull String id) {
// return new Status(id, StatusType.INVALID, 0, null, null);
// }
//
// @NonNull
// public String id() {
// return id;
// }
//
// @NonNull
// public StatusType statusType() {
// return status;
// }
//
// public int progress() {
// return progress;
// }
//
// @NonNull
// public Status withProgress(int progress) {
// return createSending(id, progress);
// }
//
// @Nullable
// public ErrorType error() {
// return error;
// }
//
// @Nullable
// public Object response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Status jobStatus = (Status) o;
//
// if (progress != jobStatus.progress) return false;
// if (status != jobStatus.status) return false;
// if (error != jobStatus.error) return false;
// if (!id.equals(jobStatus.id)) return false;
// return response != null ? response.equals(jobStatus.response) : jobStatus.response == null;
// }
//
// @Override
// public int hashCode() {
// int result = status.hashCode();
// result = 31 * result + (error != null ? error.hashCode() : 0);
// result = 31 * result + id.hashCode();
// result = 31 * result + progress;
// result = 31 * result + (response != null ? response.hashCode() : 0);
// return result;
// }
//
// @Override
// public String toString() {
// return "JobStatus{"
// + "status="
// + status
// + ", id="
// + id
// + ", progress="
// + progress
// + ", error="
// + error
// + ", response="
// + response
// + '}';
// }
// }
//
// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/model/wire/PhotoJSONModel.java
// @AutoValue
// public abstract class PhotoJSONModel {
// @NonNull
// public static TypeAdapter<PhotoJSONModel> typeAdapter(Gson gson) {
// return new AutoValue_PhotoJSONModel.GsonTypeAdapter(gson);
// }
//
// @SerializedName("id")
// public abstract int id();
//
// @SerializedName("user_id")
// public abstract Integer userId();
//
// @SerializedName("name")
// public abstract String name();
//
// @Nullable
// @SerializedName("description")
// public abstract String description();
//
// @SerializedName("width")
// public abstract int width();
//
// @SerializedName("height")
// public abstract int height();
//
// @SerializedName("image_url")
// public abstract String imageUrl();
//
// @SerializedName("images")
// public abstract List<ImageJSONModel> images();
//
// @SerializedName("user")
// public abstract UserJSONModel user();
// }
//
// Path: rxuploader/src/main/java/com/jagsaund/rxuploader/utils/StringUtils.java
// public class StringUtils {
// private StringUtils() {
// }
//
// public static boolean isNullOrEmpty(@Nullable CharSequence s) {
// return s == null || s.length() == 0;
// }
//
// @NonNull
// public static String getOrDefault(@Nullable String s, @NonNull String t) {
// return s != null ? s : t;
// }
//
// @NonNull
// public static String getOrEmpty(@Nullable String s) {
// return getOrDefault(s, "");
// }
// }
| import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.jagsaund.rxuploader.job.Status;
import com.jagsaund.rxuploader.sample.model.wire.PhotoJSONModel;
import com.jagsaund.rxuploader.utils.StringUtils; | package com.jagsaund.rxuploader.sample.model.data;
public class PhotoDataModel implements DataModel {
@NonNull
public static DataModel create(@NonNull PhotoJSONModel model) {
return new PhotoDataModel(String.valueOf(model.id()), model.name(),
model.description(), model.imageUrl());
}
@NonNull private final String id;
@NonNull private final String name;
@NonNull private final String description;
@NonNull private final String url;
@NonNull private final Status status;
private PhotoDataModel(@NonNull String id, @NonNull String name, @Nullable String description,
@NonNull String url) {
this.id = id;
this.name = name; | // Path: rxuploader/src/main/java/com/jagsaund/rxuploader/job/Status.java
// public class Status {
// @NonNull private final StatusType status;
// @NonNull private final String id;
//
// @Nullable private final ErrorType error;
//
// @Expose(serialize = false,
// deserialize = false) private final int progress;
//
// @Expose(serialize = false,
// deserialize = false) @Nullable private final Object response;
//
// private Status(@NonNull String id, @NonNull StatusType status, int progress,
// @Nullable ErrorType error, @Nullable Object response) {
// this.id = id;
// this.status = status;
// this.progress = progress;
// this.error = error;
// this.response = response;
// }
//
// @NonNull
// public static Status createQueued(@NonNull String id) {
// return new Status(id, StatusType.QUEUED, 0, null, null);
// }
//
// @NonNull
// public static Status createSending(@NonNull String id, int progress) {
// return new Status(id, StatusType.SENDING, progress, null, null);
// }
//
// @NonNull
// public static Status createCompleted(@NonNull String id, @Nullable Object response) {
// return new Status(id, StatusType.COMPLETED, 0, null, response);
// }
//
// @NonNull
// public static Status createFailed(@NonNull String id, @NonNull ErrorType error) {
// return new Status(id, StatusType.FAILED, 0, error, null);
// }
//
// @NonNull
// public static Status createInvalid(@NonNull String id) {
// return new Status(id, StatusType.INVALID, 0, null, null);
// }
//
// @NonNull
// public String id() {
// return id;
// }
//
// @NonNull
// public StatusType statusType() {
// return status;
// }
//
// public int progress() {
// return progress;
// }
//
// @NonNull
// public Status withProgress(int progress) {
// return createSending(id, progress);
// }
//
// @Nullable
// public ErrorType error() {
// return error;
// }
//
// @Nullable
// public Object response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Status jobStatus = (Status) o;
//
// if (progress != jobStatus.progress) return false;
// if (status != jobStatus.status) return false;
// if (error != jobStatus.error) return false;
// if (!id.equals(jobStatus.id)) return false;
// return response != null ? response.equals(jobStatus.response) : jobStatus.response == null;
// }
//
// @Override
// public int hashCode() {
// int result = status.hashCode();
// result = 31 * result + (error != null ? error.hashCode() : 0);
// result = 31 * result + id.hashCode();
// result = 31 * result + progress;
// result = 31 * result + (response != null ? response.hashCode() : 0);
// return result;
// }
//
// @Override
// public String toString() {
// return "JobStatus{"
// + "status="
// + status
// + ", id="
// + id
// + ", progress="
// + progress
// + ", error="
// + error
// + ", response="
// + response
// + '}';
// }
// }
//
// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/model/wire/PhotoJSONModel.java
// @AutoValue
// public abstract class PhotoJSONModel {
// @NonNull
// public static TypeAdapter<PhotoJSONModel> typeAdapter(Gson gson) {
// return new AutoValue_PhotoJSONModel.GsonTypeAdapter(gson);
// }
//
// @SerializedName("id")
// public abstract int id();
//
// @SerializedName("user_id")
// public abstract Integer userId();
//
// @SerializedName("name")
// public abstract String name();
//
// @Nullable
// @SerializedName("description")
// public abstract String description();
//
// @SerializedName("width")
// public abstract int width();
//
// @SerializedName("height")
// public abstract int height();
//
// @SerializedName("image_url")
// public abstract String imageUrl();
//
// @SerializedName("images")
// public abstract List<ImageJSONModel> images();
//
// @SerializedName("user")
// public abstract UserJSONModel user();
// }
//
// Path: rxuploader/src/main/java/com/jagsaund/rxuploader/utils/StringUtils.java
// public class StringUtils {
// private StringUtils() {
// }
//
// public static boolean isNullOrEmpty(@Nullable CharSequence s) {
// return s == null || s.length() == 0;
// }
//
// @NonNull
// public static String getOrDefault(@Nullable String s, @NonNull String t) {
// return s != null ? s : t;
// }
//
// @NonNull
// public static String getOrEmpty(@Nullable String s) {
// return getOrDefault(s, "");
// }
// }
// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/model/data/PhotoDataModel.java
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.jagsaund.rxuploader.job.Status;
import com.jagsaund.rxuploader.sample.model.wire.PhotoJSONModel;
import com.jagsaund.rxuploader.utils.StringUtils;
package com.jagsaund.rxuploader.sample.model.data;
public class PhotoDataModel implements DataModel {
@NonNull
public static DataModel create(@NonNull PhotoJSONModel model) {
return new PhotoDataModel(String.valueOf(model.id()), model.name(),
model.description(), model.imageUrl());
}
@NonNull private final String id;
@NonNull private final String name;
@NonNull private final String description;
@NonNull private final String url;
@NonNull private final Status status;
private PhotoDataModel(@NonNull String id, @NonNull String name, @Nullable String description,
@NonNull String url) {
this.id = id;
this.name = name; | this.description = StringUtils.getOrEmpty(description); |
jsaund/RxUploader | rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/PhotoUploadErrorAdapter.java | // Path: rxuploader/src/main/java/com/jagsaund/rxuploader/UploadErrorAdapter.java
// public interface UploadErrorAdapter {
// /**
// * Maps {@link Throwable} to an {@link ErrorType}.
// *
// * @param error The error to map from
// * @return an {@link ErrorType} representing the received {@code error}
// */
// @NonNull
// ErrorType fromThrowable(@NonNull Throwable error);
//
// /**
// * Determines if a particular {@code error} can be retried.
// *
// * @param error check if the error can be retried
// * @return {@link Boolean#TRUE} if the job can be retried and {@link Boolean#FALSE} otherwise
// */
// boolean canRetry(@NonNull Throwable error);
// }
//
// Path: rxuploader/src/main/java/com/jagsaund/rxuploader/job/ErrorType.java
// public enum ErrorType {
// NETWORK("network"),
// FILE_NOT_FOUND("file_not_found"),
// SERVICE("service"),
// TERMINATED("terminated"),
// UNKNOWN("unknown");
//
// @NonNull private final String type;
//
// ErrorType(@NonNull String type) {
// this.type = type;
// }
//
// @NonNull
// @Override
// public String toString() {
// return "ErrorType: " + type;
// }
// }
| import android.support.annotation.NonNull;
import com.jagsaund.rxuploader.UploadErrorAdapter;
import com.jagsaund.rxuploader.job.ErrorType;
import java.io.FileNotFoundException;
import java.io.IOException;
import retrofit2.HttpException; | package com.jagsaund.rxuploader.sample;
class PhotoUploadErrorAdapter implements UploadErrorAdapter {
@NonNull
@Override | // Path: rxuploader/src/main/java/com/jagsaund/rxuploader/UploadErrorAdapter.java
// public interface UploadErrorAdapter {
// /**
// * Maps {@link Throwable} to an {@link ErrorType}.
// *
// * @param error The error to map from
// * @return an {@link ErrorType} representing the received {@code error}
// */
// @NonNull
// ErrorType fromThrowable(@NonNull Throwable error);
//
// /**
// * Determines if a particular {@code error} can be retried.
// *
// * @param error check if the error can be retried
// * @return {@link Boolean#TRUE} if the job can be retried and {@link Boolean#FALSE} otherwise
// */
// boolean canRetry(@NonNull Throwable error);
// }
//
// Path: rxuploader/src/main/java/com/jagsaund/rxuploader/job/ErrorType.java
// public enum ErrorType {
// NETWORK("network"),
// FILE_NOT_FOUND("file_not_found"),
// SERVICE("service"),
// TERMINATED("terminated"),
// UNKNOWN("unknown");
//
// @NonNull private final String type;
//
// ErrorType(@NonNull String type) {
// this.type = type;
// }
//
// @NonNull
// @Override
// public String toString() {
// return "ErrorType: " + type;
// }
// }
// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/PhotoUploadErrorAdapter.java
import android.support.annotation.NonNull;
import com.jagsaund.rxuploader.UploadErrorAdapter;
import com.jagsaund.rxuploader.job.ErrorType;
import java.io.FileNotFoundException;
import java.io.IOException;
import retrofit2.HttpException;
package com.jagsaund.rxuploader.sample;
class PhotoUploadErrorAdapter implements UploadErrorAdapter {
@NonNull
@Override | public ErrorType fromThrowable(@NonNull Throwable error) { |
jsaund/RxUploader | rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/service/XOAuthProvider.java | // Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/config/Config.java
// public class Config {
// public static final String HOST = "https://api.500px.com/";
//
// public static final HttpLoggingInterceptor.Level HTTP_LOG_LEVEL =
// HttpLoggingInterceptor.Level.HEADERS;
//
//
// public static final String REQUEST_TOKEN_URL = HOST + "v1/oauth/request_token";
// public static final String ACCESS_TOKEN_URL = HOST + "v1/oauth/access_token";
// public static final String AUTH_CALLBACK_URL = "";
//
// public static final String CONSUMER_KEY = "<INSERT YOUR 500PX CONSUMER KEY>";
// public static final String CONSUMER_SECRET = "<INSERT YOUR 500PX CONSUMER SECRET>";
//
// public static final String X_AUTH_MODE = "client_auth";
// public static final String X_AUTH_USERNAME = "<INSERT YOUR 500PX USERNAME>";
// public static final String X_AUTH_PASSWORD = "<INSERT YOUR 500PX PASSWORD>";
//
// public static final String USERNAME = X_AUTH_USERNAME;
// }
| import com.jagsaund.rxuploader.sample.config.Config;
import oauth.signpost.AbstractOAuthProvider;
import oauth.signpost.http.HttpRequest;
import oauth.signpost.http.HttpResponse;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.internal.Util;
import se.akerfeldt.okhttp.signpost.OkHttpRequestAdapter;
import se.akerfeldt.okhttp.signpost.OkHttpResponseAdapter; | package com.jagsaund.rxuploader.sample.service;
public class XOAuthProvider extends AbstractOAuthProvider {
private transient OkHttpClient okHttpClient;
public XOAuthProvider(String requestTokenEndpointUrl, String accessTokenEndpointUrl,
String authorizationWebsiteUrl) {
super(requestTokenEndpointUrl, accessTokenEndpointUrl, authorizationWebsiteUrl);
this.okHttpClient = new OkHttpClient();
}
public XOAuthProvider(String requestTokenEndpointUrl, String accessTokenEndpointUrl,
String authorizationWebsiteUrl, OkHttpClient okHttpClient) {
super(requestTokenEndpointUrl, accessTokenEndpointUrl, authorizationWebsiteUrl);
this.okHttpClient = okHttpClient;
}
public void setOkHttpClient(OkHttpClient okHttpClient) {
this.okHttpClient = okHttpClient;
}
@Override
protected HttpRequest createRequest(String endpointUrl) throws Exception {
final Request.Builder builder =
new Request.Builder()
.url(endpointUrl)
.post(Util.EMPTY_REQUEST); | // Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/config/Config.java
// public class Config {
// public static final String HOST = "https://api.500px.com/";
//
// public static final HttpLoggingInterceptor.Level HTTP_LOG_LEVEL =
// HttpLoggingInterceptor.Level.HEADERS;
//
//
// public static final String REQUEST_TOKEN_URL = HOST + "v1/oauth/request_token";
// public static final String ACCESS_TOKEN_URL = HOST + "v1/oauth/access_token";
// public static final String AUTH_CALLBACK_URL = "";
//
// public static final String CONSUMER_KEY = "<INSERT YOUR 500PX CONSUMER KEY>";
// public static final String CONSUMER_SECRET = "<INSERT YOUR 500PX CONSUMER SECRET>";
//
// public static final String X_AUTH_MODE = "client_auth";
// public static final String X_AUTH_USERNAME = "<INSERT YOUR 500PX USERNAME>";
// public static final String X_AUTH_PASSWORD = "<INSERT YOUR 500PX PASSWORD>";
//
// public static final String USERNAME = X_AUTH_USERNAME;
// }
// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/service/XOAuthProvider.java
import com.jagsaund.rxuploader.sample.config.Config;
import oauth.signpost.AbstractOAuthProvider;
import oauth.signpost.http.HttpRequest;
import oauth.signpost.http.HttpResponse;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.internal.Util;
import se.akerfeldt.okhttp.signpost.OkHttpRequestAdapter;
import se.akerfeldt.okhttp.signpost.OkHttpResponseAdapter;
package com.jagsaund.rxuploader.sample.service;
public class XOAuthProvider extends AbstractOAuthProvider {
private transient OkHttpClient okHttpClient;
public XOAuthProvider(String requestTokenEndpointUrl, String accessTokenEndpointUrl,
String authorizationWebsiteUrl) {
super(requestTokenEndpointUrl, accessTokenEndpointUrl, authorizationWebsiteUrl);
this.okHttpClient = new OkHttpClient();
}
public XOAuthProvider(String requestTokenEndpointUrl, String accessTokenEndpointUrl,
String authorizationWebsiteUrl, OkHttpClient okHttpClient) {
super(requestTokenEndpointUrl, accessTokenEndpointUrl, authorizationWebsiteUrl);
this.okHttpClient = okHttpClient;
}
public void setOkHttpClient(OkHttpClient okHttpClient) {
this.okHttpClient = okHttpClient;
}
@Override
protected HttpRequest createRequest(String endpointUrl) throws Exception {
final Request.Builder builder =
new Request.Builder()
.url(endpointUrl)
.post(Util.EMPTY_REQUEST); | if (endpointUrl.contains(Config.ACCESS_TOKEN_URL)) { |
jsaund/RxUploader | rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/service/Service.java | // Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/config/Config.java
// public class Config {
// public static final String HOST = "https://api.500px.com/";
//
// public static final HttpLoggingInterceptor.Level HTTP_LOG_LEVEL =
// HttpLoggingInterceptor.Level.HEADERS;
//
//
// public static final String REQUEST_TOKEN_URL = HOST + "v1/oauth/request_token";
// public static final String ACCESS_TOKEN_URL = HOST + "v1/oauth/access_token";
// public static final String AUTH_CALLBACK_URL = "";
//
// public static final String CONSUMER_KEY = "<INSERT YOUR 500PX CONSUMER KEY>";
// public static final String CONSUMER_SECRET = "<INSERT YOUR 500PX CONSUMER SECRET>";
//
// public static final String X_AUTH_MODE = "client_auth";
// public static final String X_AUTH_USERNAME = "<INSERT YOUR 500PX USERNAME>";
// public static final String X_AUTH_PASSWORD = "<INSERT YOUR 500PX PASSWORD>";
//
// public static final String USERNAME = X_AUTH_USERNAME;
// }
//
// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/model/wire/JSONModelTypeAdapterFactory.java
// @GsonTypeAdapterFactory
// public abstract class JSONModelTypeAdapterFactory implements TypeAdapterFactory {
// @NonNull
// public static TypeAdapterFactory create() {
// return new AutoValueGson_JSONModelTypeAdapterFactory();
// }
// }
| import android.support.annotation.NonNull;
import com.google.gson.GsonBuilder;
import com.jagsaund.rxuploader.sample.config.Config;
import com.jagsaund.rxuploader.sample.model.wire.JSONModelTypeAdapterFactory;
import java.util.HashMap;
import java.util.Map;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
import se.akerfeldt.okhttp.signpost.OkHttpOAuthConsumer;
import se.akerfeldt.okhttp.signpost.SigningInterceptor; | package com.jagsaund.rxuploader.sample.service;
public final class Service {
private static final Map<Class<?>, Object> serviceMap = new HashMap<>();
private Service() {
}
@NonNull
public static ApiService apiService(@NonNull String token, @NonNull String secret) {
ApiService s = (ApiService) serviceMap.get(ApiService.class);
if (s == null) {
s = createService(ApiService.class, token, secret);
serviceMap.put(ApiService.class, s);
}
return s;
}
@NonNull
private static <S> S createService(@NonNull Class<S> s, @NonNull String token,
@NonNull String secret) {
final GsonConverterFactory serializer = GsonConverterFactory.create( | // Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/config/Config.java
// public class Config {
// public static final String HOST = "https://api.500px.com/";
//
// public static final HttpLoggingInterceptor.Level HTTP_LOG_LEVEL =
// HttpLoggingInterceptor.Level.HEADERS;
//
//
// public static final String REQUEST_TOKEN_URL = HOST + "v1/oauth/request_token";
// public static final String ACCESS_TOKEN_URL = HOST + "v1/oauth/access_token";
// public static final String AUTH_CALLBACK_URL = "";
//
// public static final String CONSUMER_KEY = "<INSERT YOUR 500PX CONSUMER KEY>";
// public static final String CONSUMER_SECRET = "<INSERT YOUR 500PX CONSUMER SECRET>";
//
// public static final String X_AUTH_MODE = "client_auth";
// public static final String X_AUTH_USERNAME = "<INSERT YOUR 500PX USERNAME>";
// public static final String X_AUTH_PASSWORD = "<INSERT YOUR 500PX PASSWORD>";
//
// public static final String USERNAME = X_AUTH_USERNAME;
// }
//
// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/model/wire/JSONModelTypeAdapterFactory.java
// @GsonTypeAdapterFactory
// public abstract class JSONModelTypeAdapterFactory implements TypeAdapterFactory {
// @NonNull
// public static TypeAdapterFactory create() {
// return new AutoValueGson_JSONModelTypeAdapterFactory();
// }
// }
// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/service/Service.java
import android.support.annotation.NonNull;
import com.google.gson.GsonBuilder;
import com.jagsaund.rxuploader.sample.config.Config;
import com.jagsaund.rxuploader.sample.model.wire.JSONModelTypeAdapterFactory;
import java.util.HashMap;
import java.util.Map;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
import se.akerfeldt.okhttp.signpost.OkHttpOAuthConsumer;
import se.akerfeldt.okhttp.signpost.SigningInterceptor;
package com.jagsaund.rxuploader.sample.service;
public final class Service {
private static final Map<Class<?>, Object> serviceMap = new HashMap<>();
private Service() {
}
@NonNull
public static ApiService apiService(@NonNull String token, @NonNull String secret) {
ApiService s = (ApiService) serviceMap.get(ApiService.class);
if (s == null) {
s = createService(ApiService.class, token, secret);
serviceMap.put(ApiService.class, s);
}
return s;
}
@NonNull
private static <S> S createService(@NonNull Class<S> s, @NonNull String token,
@NonNull String secret) {
final GsonConverterFactory serializer = GsonConverterFactory.create( | new GsonBuilder().registerTypeAdapterFactory(JSONModelTypeAdapterFactory.create()) |
jsaund/RxUploader | rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/service/Service.java | // Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/config/Config.java
// public class Config {
// public static final String HOST = "https://api.500px.com/";
//
// public static final HttpLoggingInterceptor.Level HTTP_LOG_LEVEL =
// HttpLoggingInterceptor.Level.HEADERS;
//
//
// public static final String REQUEST_TOKEN_URL = HOST + "v1/oauth/request_token";
// public static final String ACCESS_TOKEN_URL = HOST + "v1/oauth/access_token";
// public static final String AUTH_CALLBACK_URL = "";
//
// public static final String CONSUMER_KEY = "<INSERT YOUR 500PX CONSUMER KEY>";
// public static final String CONSUMER_SECRET = "<INSERT YOUR 500PX CONSUMER SECRET>";
//
// public static final String X_AUTH_MODE = "client_auth";
// public static final String X_AUTH_USERNAME = "<INSERT YOUR 500PX USERNAME>";
// public static final String X_AUTH_PASSWORD = "<INSERT YOUR 500PX PASSWORD>";
//
// public static final String USERNAME = X_AUTH_USERNAME;
// }
//
// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/model/wire/JSONModelTypeAdapterFactory.java
// @GsonTypeAdapterFactory
// public abstract class JSONModelTypeAdapterFactory implements TypeAdapterFactory {
// @NonNull
// public static TypeAdapterFactory create() {
// return new AutoValueGson_JSONModelTypeAdapterFactory();
// }
// }
| import android.support.annotation.NonNull;
import com.google.gson.GsonBuilder;
import com.jagsaund.rxuploader.sample.config.Config;
import com.jagsaund.rxuploader.sample.model.wire.JSONModelTypeAdapterFactory;
import java.util.HashMap;
import java.util.Map;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
import se.akerfeldt.okhttp.signpost.OkHttpOAuthConsumer;
import se.akerfeldt.okhttp.signpost.SigningInterceptor; | package com.jagsaund.rxuploader.sample.service;
public final class Service {
private static final Map<Class<?>, Object> serviceMap = new HashMap<>();
private Service() {
}
@NonNull
public static ApiService apiService(@NonNull String token, @NonNull String secret) {
ApiService s = (ApiService) serviceMap.get(ApiService.class);
if (s == null) {
s = createService(ApiService.class, token, secret);
serviceMap.put(ApiService.class, s);
}
return s;
}
@NonNull
private static <S> S createService(@NonNull Class<S> s, @NonNull String token,
@NonNull String secret) {
final GsonConverterFactory serializer = GsonConverterFactory.create(
new GsonBuilder().registerTypeAdapterFactory(JSONModelTypeAdapterFactory.create())
.create());
final OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
OkHttpOAuthConsumer consumer = new OkHttpOAuthConsumer( | // Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/config/Config.java
// public class Config {
// public static final String HOST = "https://api.500px.com/";
//
// public static final HttpLoggingInterceptor.Level HTTP_LOG_LEVEL =
// HttpLoggingInterceptor.Level.HEADERS;
//
//
// public static final String REQUEST_TOKEN_URL = HOST + "v1/oauth/request_token";
// public static final String ACCESS_TOKEN_URL = HOST + "v1/oauth/access_token";
// public static final String AUTH_CALLBACK_URL = "";
//
// public static final String CONSUMER_KEY = "<INSERT YOUR 500PX CONSUMER KEY>";
// public static final String CONSUMER_SECRET = "<INSERT YOUR 500PX CONSUMER SECRET>";
//
// public static final String X_AUTH_MODE = "client_auth";
// public static final String X_AUTH_USERNAME = "<INSERT YOUR 500PX USERNAME>";
// public static final String X_AUTH_PASSWORD = "<INSERT YOUR 500PX PASSWORD>";
//
// public static final String USERNAME = X_AUTH_USERNAME;
// }
//
// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/model/wire/JSONModelTypeAdapterFactory.java
// @GsonTypeAdapterFactory
// public abstract class JSONModelTypeAdapterFactory implements TypeAdapterFactory {
// @NonNull
// public static TypeAdapterFactory create() {
// return new AutoValueGson_JSONModelTypeAdapterFactory();
// }
// }
// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/service/Service.java
import android.support.annotation.NonNull;
import com.google.gson.GsonBuilder;
import com.jagsaund.rxuploader.sample.config.Config;
import com.jagsaund.rxuploader.sample.model.wire.JSONModelTypeAdapterFactory;
import java.util.HashMap;
import java.util.Map;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
import se.akerfeldt.okhttp.signpost.OkHttpOAuthConsumer;
import se.akerfeldt.okhttp.signpost.SigningInterceptor;
package com.jagsaund.rxuploader.sample.service;
public final class Service {
private static final Map<Class<?>, Object> serviceMap = new HashMap<>();
private Service() {
}
@NonNull
public static ApiService apiService(@NonNull String token, @NonNull String secret) {
ApiService s = (ApiService) serviceMap.get(ApiService.class);
if (s == null) {
s = createService(ApiService.class, token, secret);
serviceMap.put(ApiService.class, s);
}
return s;
}
@NonNull
private static <S> S createService(@NonNull Class<S> s, @NonNull String token,
@NonNull String secret) {
final GsonConverterFactory serializer = GsonConverterFactory.create(
new GsonBuilder().registerTypeAdapterFactory(JSONModelTypeAdapterFactory.create())
.create());
final OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
OkHttpOAuthConsumer consumer = new OkHttpOAuthConsumer( | Config.CONSUMER_KEY, Config.CONSUMER_SECRET); |
jsaund/RxUploader | rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/service/PhotoUploadService.java | // Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/model/wire/PhotoJSONModel.java
// @AutoValue
// public abstract class PhotoJSONModel {
// @NonNull
// public static TypeAdapter<PhotoJSONModel> typeAdapter(Gson gson) {
// return new AutoValue_PhotoJSONModel.GsonTypeAdapter(gson);
// }
//
// @SerializedName("id")
// public abstract int id();
//
// @SerializedName("user_id")
// public abstract Integer userId();
//
// @SerializedName("name")
// public abstract String name();
//
// @Nullable
// @SerializedName("description")
// public abstract String description();
//
// @SerializedName("width")
// public abstract int width();
//
// @SerializedName("height")
// public abstract int height();
//
// @SerializedName("image_url")
// public abstract String imageUrl();
//
// @SerializedName("images")
// public abstract List<ImageJSONModel> images();
//
// @SerializedName("user")
// public abstract UserJSONModel user();
// }
//
// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/model/wire/UploadPhotoJSONModel.java
// @AutoValue
// public abstract class UploadPhotoJSONModel {
// @NonNull
// public static TypeAdapter<UploadPhotoJSONModel> typeAdapter(Gson gson) {
// return new AutoValue_UploadPhotoJSONModel.GsonTypeAdapter(gson);
// }
//
// @SerializedName("photo")
// public abstract PhotoJSONModel photo();
// }
//
// Path: rxuploader/src/main/java/com/jagsaund/rxuploader/store/UploadService.java
// public interface UploadService<T> {
// /**
// * Uploads multipart content to a remote endpoint.
// *
// * @param metadata Optional information to be associated with the upload operation
// * @param data A file to upload
// * @return The response received from the upload operation
// */
// Single<T> upload(@NonNull Map<String, Object> metadata, @NonNull MultipartBody.Part data);
// }
| import android.support.annotation.NonNull;
import android.support.annotation.VisibleForTesting;
import com.jagsaund.rxuploader.sample.model.wire.PhotoJSONModel;
import com.jagsaund.rxuploader.sample.model.wire.UploadPhotoJSONModel;
import com.jagsaund.rxuploader.store.UploadService;
import java.util.Map;
import okhttp3.MultipartBody;
import rx.Single; | package com.jagsaund.rxuploader.sample.service;
public class PhotoUploadService implements UploadService<PhotoJSONModel> {
@NonNull private final ApiService apiService;
@VisibleForTesting
PhotoUploadService(@NonNull ApiService apiService) {
this.apiService = apiService;
}
@NonNull
public static UploadService create(@NonNull ApiService apiService) {
return new PhotoUploadService(apiService);
}
@Override
public Single<PhotoJSONModel> upload(@NonNull Map<String, Object> metadata,
@NonNull MultipartBody.Part data) {
final String name = (String) metadata.get("name");
final String description = (String) metadata.get("description");
final Double privacy = (Double) metadata.get("privacy");
return apiService
.uploadPhoto(name, description, privacy != null ? privacy.intValue() : 0, data) | // Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/model/wire/PhotoJSONModel.java
// @AutoValue
// public abstract class PhotoJSONModel {
// @NonNull
// public static TypeAdapter<PhotoJSONModel> typeAdapter(Gson gson) {
// return new AutoValue_PhotoJSONModel.GsonTypeAdapter(gson);
// }
//
// @SerializedName("id")
// public abstract int id();
//
// @SerializedName("user_id")
// public abstract Integer userId();
//
// @SerializedName("name")
// public abstract String name();
//
// @Nullable
// @SerializedName("description")
// public abstract String description();
//
// @SerializedName("width")
// public abstract int width();
//
// @SerializedName("height")
// public abstract int height();
//
// @SerializedName("image_url")
// public abstract String imageUrl();
//
// @SerializedName("images")
// public abstract List<ImageJSONModel> images();
//
// @SerializedName("user")
// public abstract UserJSONModel user();
// }
//
// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/model/wire/UploadPhotoJSONModel.java
// @AutoValue
// public abstract class UploadPhotoJSONModel {
// @NonNull
// public static TypeAdapter<UploadPhotoJSONModel> typeAdapter(Gson gson) {
// return new AutoValue_UploadPhotoJSONModel.GsonTypeAdapter(gson);
// }
//
// @SerializedName("photo")
// public abstract PhotoJSONModel photo();
// }
//
// Path: rxuploader/src/main/java/com/jagsaund/rxuploader/store/UploadService.java
// public interface UploadService<T> {
// /**
// * Uploads multipart content to a remote endpoint.
// *
// * @param metadata Optional information to be associated with the upload operation
// * @param data A file to upload
// * @return The response received from the upload operation
// */
// Single<T> upload(@NonNull Map<String, Object> metadata, @NonNull MultipartBody.Part data);
// }
// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/service/PhotoUploadService.java
import android.support.annotation.NonNull;
import android.support.annotation.VisibleForTesting;
import com.jagsaund.rxuploader.sample.model.wire.PhotoJSONModel;
import com.jagsaund.rxuploader.sample.model.wire.UploadPhotoJSONModel;
import com.jagsaund.rxuploader.store.UploadService;
import java.util.Map;
import okhttp3.MultipartBody;
import rx.Single;
package com.jagsaund.rxuploader.sample.service;
public class PhotoUploadService implements UploadService<PhotoJSONModel> {
@NonNull private final ApiService apiService;
@VisibleForTesting
PhotoUploadService(@NonNull ApiService apiService) {
this.apiService = apiService;
}
@NonNull
public static UploadService create(@NonNull ApiService apiService) {
return new PhotoUploadService(apiService);
}
@Override
public Single<PhotoJSONModel> upload(@NonNull Map<String, Object> metadata,
@NonNull MultipartBody.Part data) {
final String name = (String) metadata.get("name");
final String description = (String) metadata.get("description");
final Double privacy = (Double) metadata.get("privacy");
return apiService
.uploadPhoto(name, description, privacy != null ? privacy.intValue() : 0, data) | .map(UploadPhotoJSONModel::photo) |
jsaund/RxUploader | rxuploader/src/main/java/com/jagsaund/rxuploader/rx/RxRequestBody.java | // Path: rxuploader/src/main/java/com/jagsaund/rxuploader/job/Status.java
// public class Status {
// @NonNull private final StatusType status;
// @NonNull private final String id;
//
// @Nullable private final ErrorType error;
//
// @Expose(serialize = false,
// deserialize = false) private final int progress;
//
// @Expose(serialize = false,
// deserialize = false) @Nullable private final Object response;
//
// private Status(@NonNull String id, @NonNull StatusType status, int progress,
// @Nullable ErrorType error, @Nullable Object response) {
// this.id = id;
// this.status = status;
// this.progress = progress;
// this.error = error;
// this.response = response;
// }
//
// @NonNull
// public static Status createQueued(@NonNull String id) {
// return new Status(id, StatusType.QUEUED, 0, null, null);
// }
//
// @NonNull
// public static Status createSending(@NonNull String id, int progress) {
// return new Status(id, StatusType.SENDING, progress, null, null);
// }
//
// @NonNull
// public static Status createCompleted(@NonNull String id, @Nullable Object response) {
// return new Status(id, StatusType.COMPLETED, 0, null, response);
// }
//
// @NonNull
// public static Status createFailed(@NonNull String id, @NonNull ErrorType error) {
// return new Status(id, StatusType.FAILED, 0, error, null);
// }
//
// @NonNull
// public static Status createInvalid(@NonNull String id) {
// return new Status(id, StatusType.INVALID, 0, null, null);
// }
//
// @NonNull
// public String id() {
// return id;
// }
//
// @NonNull
// public StatusType statusType() {
// return status;
// }
//
// public int progress() {
// return progress;
// }
//
// @NonNull
// public Status withProgress(int progress) {
// return createSending(id, progress);
// }
//
// @Nullable
// public ErrorType error() {
// return error;
// }
//
// @Nullable
// public Object response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Status jobStatus = (Status) o;
//
// if (progress != jobStatus.progress) return false;
// if (status != jobStatus.status) return false;
// if (error != jobStatus.error) return false;
// if (!id.equals(jobStatus.id)) return false;
// return response != null ? response.equals(jobStatus.response) : jobStatus.response == null;
// }
//
// @Override
// public int hashCode() {
// int result = status.hashCode();
// result = 31 * result + (error != null ? error.hashCode() : 0);
// result = 31 * result + id.hashCode();
// result = 31 * result + progress;
// result = 31 * result + (response != null ? response.hashCode() : 0);
// return result;
// }
//
// @Override
// public String toString() {
// return "JobStatus{"
// + "status="
// + status
// + ", id="
// + id
// + ", progress="
// + progress
// + ", error="
// + error
// + ", response="
// + response
// + '}';
// }
// }
| import android.support.annotation.NonNull;
import android.support.annotation.VisibleForTesting;
import com.jagsaund.rxuploader.job.Status;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import okio.BufferedSink;
import okio.Okio;
import okio.Source;
import rx.Emitter; | package com.jagsaund.rxuploader.rx;
/**
* Transforms a {@linkplain RequestBody} into one that is reactive and will emit progress updates
* to the provide {@code Emitter}. Progress updates are emitted as {@linkplain Status} items.
*/
public class RxRequestBody extends RequestBody {
public static final long BUFFER_SIZE = 8 * 1024;
@NonNull private final String jobId;
@NonNull private final MediaType mediaType;
@NonNull private final InputStream inputStream; | // Path: rxuploader/src/main/java/com/jagsaund/rxuploader/job/Status.java
// public class Status {
// @NonNull private final StatusType status;
// @NonNull private final String id;
//
// @Nullable private final ErrorType error;
//
// @Expose(serialize = false,
// deserialize = false) private final int progress;
//
// @Expose(serialize = false,
// deserialize = false) @Nullable private final Object response;
//
// private Status(@NonNull String id, @NonNull StatusType status, int progress,
// @Nullable ErrorType error, @Nullable Object response) {
// this.id = id;
// this.status = status;
// this.progress = progress;
// this.error = error;
// this.response = response;
// }
//
// @NonNull
// public static Status createQueued(@NonNull String id) {
// return new Status(id, StatusType.QUEUED, 0, null, null);
// }
//
// @NonNull
// public static Status createSending(@NonNull String id, int progress) {
// return new Status(id, StatusType.SENDING, progress, null, null);
// }
//
// @NonNull
// public static Status createCompleted(@NonNull String id, @Nullable Object response) {
// return new Status(id, StatusType.COMPLETED, 0, null, response);
// }
//
// @NonNull
// public static Status createFailed(@NonNull String id, @NonNull ErrorType error) {
// return new Status(id, StatusType.FAILED, 0, error, null);
// }
//
// @NonNull
// public static Status createInvalid(@NonNull String id) {
// return new Status(id, StatusType.INVALID, 0, null, null);
// }
//
// @NonNull
// public String id() {
// return id;
// }
//
// @NonNull
// public StatusType statusType() {
// return status;
// }
//
// public int progress() {
// return progress;
// }
//
// @NonNull
// public Status withProgress(int progress) {
// return createSending(id, progress);
// }
//
// @Nullable
// public ErrorType error() {
// return error;
// }
//
// @Nullable
// public Object response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Status jobStatus = (Status) o;
//
// if (progress != jobStatus.progress) return false;
// if (status != jobStatus.status) return false;
// if (error != jobStatus.error) return false;
// if (!id.equals(jobStatus.id)) return false;
// return response != null ? response.equals(jobStatus.response) : jobStatus.response == null;
// }
//
// @Override
// public int hashCode() {
// int result = status.hashCode();
// result = 31 * result + (error != null ? error.hashCode() : 0);
// result = 31 * result + id.hashCode();
// result = 31 * result + progress;
// result = 31 * result + (response != null ? response.hashCode() : 0);
// return result;
// }
//
// @Override
// public String toString() {
// return "JobStatus{"
// + "status="
// + status
// + ", id="
// + id
// + ", progress="
// + progress
// + ", error="
// + error
// + ", response="
// + response
// + '}';
// }
// }
// Path: rxuploader/src/main/java/com/jagsaund/rxuploader/rx/RxRequestBody.java
import android.support.annotation.NonNull;
import android.support.annotation.VisibleForTesting;
import com.jagsaund.rxuploader.job.Status;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import okio.BufferedSink;
import okio.Okio;
import okio.Source;
import rx.Emitter;
package com.jagsaund.rxuploader.rx;
/**
* Transforms a {@linkplain RequestBody} into one that is reactive and will emit progress updates
* to the provide {@code Emitter}. Progress updates are emitted as {@linkplain Status} items.
*/
public class RxRequestBody extends RequestBody {
public static final long BUFFER_SIZE = 8 * 1024;
@NonNull private final String jobId;
@NonNull private final MediaType mediaType;
@NonNull private final InputStream inputStream; | @NonNull private final Emitter<Status> progressEmitter; |
jsaund/RxUploader | rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/UploadRecyclerAdapter.java | // Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/model/UploadPhotoList.java
// public class UploadPhotoList extends SortedList<DataModel> {
// public UploadPhotoList(@NonNull final RecyclerView.Adapter adapter) {
// super(DataModel.class, new SortedList.Callback<DataModel>() {
//
// @Override
// public void onInserted(int position, int count) {
// adapter.notifyItemRangeInserted(position, count);
// }
//
// @Override
// public void onRemoved(int position, int count) {
// adapter.notifyItemRangeRemoved(position, count);
// }
//
// @Override
// public void onMoved(int fromPosition, int toPosition) {
// adapter.notifyItemMoved(fromPosition, toPosition);
// }
//
// @Override
// public int compare(@NonNull DataModel o1, @NonNull DataModel o2) {
// // upload jobs are ordered first
// if (o1.type() != o2.type()) {
// if (o1.type() == DataModelType.UPLOAD) {
// return -1;
// } else {
// return 1;
// }
// }
// return o1.id().compareTo(o2.id());
// }
//
// @Override
// public void onChanged(int position, int count) {
// adapter.notifyItemRangeChanged(position, count);
// }
//
// @Override
// public boolean areContentsTheSame(@NonNull DataModel oldItem,
// @NonNull DataModel newItem) {
// return oldItem.hashCode() == newItem.hashCode();
// }
//
// @Override
// public boolean areItemsTheSame(@NonNull DataModel item1, @NonNull DataModel item2) {
// return item1.type() == item2.type() && item1.id().equals(item2.id());
// }
// });
// }
// }
//
// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/model/data/DataModel.java
// public interface DataModel {
// @DataModelType
// int type();
//
// @NonNull
// String id();
//
// @NonNull
// Status getStatus();
// }
| import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestManager;
import com.jagsaund.rxuploader.sample.model.UploadPhotoList;
import com.jagsaund.rxuploader.sample.model.data.DataModel;
import java.util.List; | package com.jagsaund.rxuploader.sample;
public class UploadRecyclerAdapter extends RecyclerView.Adapter<UploadViewHolder> {
@NonNull private final UploadPhotoList photoList;
@NonNull private final RequestManager glide;
public UploadRecyclerAdapter(@NonNull Context context) {
photoList = new UploadPhotoList(this);
glide = Glide.with(context);
}
@NonNull
@Override
public UploadViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return UploadViewHolder.create(parent, glide);
}
@Override
public void onBindViewHolder(@NonNull UploadViewHolder holder, int position) { | // Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/model/UploadPhotoList.java
// public class UploadPhotoList extends SortedList<DataModel> {
// public UploadPhotoList(@NonNull final RecyclerView.Adapter adapter) {
// super(DataModel.class, new SortedList.Callback<DataModel>() {
//
// @Override
// public void onInserted(int position, int count) {
// adapter.notifyItemRangeInserted(position, count);
// }
//
// @Override
// public void onRemoved(int position, int count) {
// adapter.notifyItemRangeRemoved(position, count);
// }
//
// @Override
// public void onMoved(int fromPosition, int toPosition) {
// adapter.notifyItemMoved(fromPosition, toPosition);
// }
//
// @Override
// public int compare(@NonNull DataModel o1, @NonNull DataModel o2) {
// // upload jobs are ordered first
// if (o1.type() != o2.type()) {
// if (o1.type() == DataModelType.UPLOAD) {
// return -1;
// } else {
// return 1;
// }
// }
// return o1.id().compareTo(o2.id());
// }
//
// @Override
// public void onChanged(int position, int count) {
// adapter.notifyItemRangeChanged(position, count);
// }
//
// @Override
// public boolean areContentsTheSame(@NonNull DataModel oldItem,
// @NonNull DataModel newItem) {
// return oldItem.hashCode() == newItem.hashCode();
// }
//
// @Override
// public boolean areItemsTheSame(@NonNull DataModel item1, @NonNull DataModel item2) {
// return item1.type() == item2.type() && item1.id().equals(item2.id());
// }
// });
// }
// }
//
// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/model/data/DataModel.java
// public interface DataModel {
// @DataModelType
// int type();
//
// @NonNull
// String id();
//
// @NonNull
// Status getStatus();
// }
// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/UploadRecyclerAdapter.java
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestManager;
import com.jagsaund.rxuploader.sample.model.UploadPhotoList;
import com.jagsaund.rxuploader.sample.model.data.DataModel;
import java.util.List;
package com.jagsaund.rxuploader.sample;
public class UploadRecyclerAdapter extends RecyclerView.Adapter<UploadViewHolder> {
@NonNull private final UploadPhotoList photoList;
@NonNull private final RequestManager glide;
public UploadRecyclerAdapter(@NonNull Context context) {
photoList = new UploadPhotoList(this);
glide = Glide.with(context);
}
@NonNull
@Override
public UploadViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return UploadViewHolder.create(parent, glide);
}
@Override
public void onBindViewHolder(@NonNull UploadViewHolder holder, int position) { | final DataModel m = getItemAt(position); |
jsaund/RxUploader | rxuploader/src/main/java/com/jagsaund/rxuploader/UploadInteractor.java | // Path: rxuploader/src/main/java/com/jagsaund/rxuploader/job/Job.java
// @AutoValue
// public abstract class Job {
// public static final String INVALID_JOB_ID = "invalid_job_id";
// public static final Map<String, Object> INVALID_METADATA = Collections.emptyMap();
// public static final Job INVALID_JOB = Job.builder()
// .setId(INVALID_JOB_ID)
// .setStatus(Status.createInvalid(INVALID_JOB_ID))
// .setFilepath("")
// .setMetadata(INVALID_METADATA)
// .setMimeType("")
// .build();
//
// public static boolean isInvalid(@NonNull Job job) {
// return INVALID_JOB == job || INVALID_JOB_ID.equals(job.id());
// }
//
// @NonNull
// public static TypeAdapter<Job> typeAdapter(Gson gson) {
// return new AutoValue_Job.GsonTypeAdapter(gson);
// }
//
// @NonNull
// public static Builder builder() {
// return new AutoValue_Job.Builder();
// }
//
// @NonNull
// public abstract String id();
//
// @NonNull
// public abstract Status status();
//
// @NonNull
// public Job withStatus(@NonNull Status status) {
// return toBuilder().setStatus(status).build();
// }
//
// @NonNull
// abstract Builder toBuilder();
//
// @NonNull
// public abstract String filepath();
//
// @NonNull
// public abstract Map<String, Object> metadata();
//
// @NonNull
// public abstract String mimeType();
//
// @AutoValue.Builder
// public abstract static class Builder {
// public abstract Builder setId(String jobId);
//
// public abstract Builder setStatus(Status status);
//
// public abstract Builder setFilepath(String filepath);
//
// public abstract Builder setMetadata(Map<String, Object> metadata);
//
// public abstract Builder setMimeType(String mimeType);
//
// public abstract Job build();
// }
// }
//
// Path: rxuploader/src/main/java/com/jagsaund/rxuploader/job/Status.java
// public class Status {
// @NonNull private final StatusType status;
// @NonNull private final String id;
//
// @Nullable private final ErrorType error;
//
// @Expose(serialize = false,
// deserialize = false) private final int progress;
//
// @Expose(serialize = false,
// deserialize = false) @Nullable private final Object response;
//
// private Status(@NonNull String id, @NonNull StatusType status, int progress,
// @Nullable ErrorType error, @Nullable Object response) {
// this.id = id;
// this.status = status;
// this.progress = progress;
// this.error = error;
// this.response = response;
// }
//
// @NonNull
// public static Status createQueued(@NonNull String id) {
// return new Status(id, StatusType.QUEUED, 0, null, null);
// }
//
// @NonNull
// public static Status createSending(@NonNull String id, int progress) {
// return new Status(id, StatusType.SENDING, progress, null, null);
// }
//
// @NonNull
// public static Status createCompleted(@NonNull String id, @Nullable Object response) {
// return new Status(id, StatusType.COMPLETED, 0, null, response);
// }
//
// @NonNull
// public static Status createFailed(@NonNull String id, @NonNull ErrorType error) {
// return new Status(id, StatusType.FAILED, 0, error, null);
// }
//
// @NonNull
// public static Status createInvalid(@NonNull String id) {
// return new Status(id, StatusType.INVALID, 0, null, null);
// }
//
// @NonNull
// public String id() {
// return id;
// }
//
// @NonNull
// public StatusType statusType() {
// return status;
// }
//
// public int progress() {
// return progress;
// }
//
// @NonNull
// public Status withProgress(int progress) {
// return createSending(id, progress);
// }
//
// @Nullable
// public ErrorType error() {
// return error;
// }
//
// @Nullable
// public Object response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Status jobStatus = (Status) o;
//
// if (progress != jobStatus.progress) return false;
// if (status != jobStatus.status) return false;
// if (error != jobStatus.error) return false;
// if (!id.equals(jobStatus.id)) return false;
// return response != null ? response.equals(jobStatus.response) : jobStatus.response == null;
// }
//
// @Override
// public int hashCode() {
// int result = status.hashCode();
// result = 31 * result + (error != null ? error.hashCode() : 0);
// result = 31 * result + id.hashCode();
// result = 31 * result + progress;
// result = 31 * result + (response != null ? response.hashCode() : 0);
// return result;
// }
//
// @Override
// public String toString() {
// return "JobStatus{"
// + "status="
// + status
// + ", id="
// + id
// + ", progress="
// + progress
// + ", error="
// + error
// + ", response="
// + response
// + '}';
// }
// }
| import android.support.annotation.NonNull;
import com.jagsaund.rxuploader.job.Job;
import com.jagsaund.rxuploader.job.Status;
import rx.Observable; | package com.jagsaund.rxuploader;
public interface UploadInteractor {
@NonNull | // Path: rxuploader/src/main/java/com/jagsaund/rxuploader/job/Job.java
// @AutoValue
// public abstract class Job {
// public static final String INVALID_JOB_ID = "invalid_job_id";
// public static final Map<String, Object> INVALID_METADATA = Collections.emptyMap();
// public static final Job INVALID_JOB = Job.builder()
// .setId(INVALID_JOB_ID)
// .setStatus(Status.createInvalid(INVALID_JOB_ID))
// .setFilepath("")
// .setMetadata(INVALID_METADATA)
// .setMimeType("")
// .build();
//
// public static boolean isInvalid(@NonNull Job job) {
// return INVALID_JOB == job || INVALID_JOB_ID.equals(job.id());
// }
//
// @NonNull
// public static TypeAdapter<Job> typeAdapter(Gson gson) {
// return new AutoValue_Job.GsonTypeAdapter(gson);
// }
//
// @NonNull
// public static Builder builder() {
// return new AutoValue_Job.Builder();
// }
//
// @NonNull
// public abstract String id();
//
// @NonNull
// public abstract Status status();
//
// @NonNull
// public Job withStatus(@NonNull Status status) {
// return toBuilder().setStatus(status).build();
// }
//
// @NonNull
// abstract Builder toBuilder();
//
// @NonNull
// public abstract String filepath();
//
// @NonNull
// public abstract Map<String, Object> metadata();
//
// @NonNull
// public abstract String mimeType();
//
// @AutoValue.Builder
// public abstract static class Builder {
// public abstract Builder setId(String jobId);
//
// public abstract Builder setStatus(Status status);
//
// public abstract Builder setFilepath(String filepath);
//
// public abstract Builder setMetadata(Map<String, Object> metadata);
//
// public abstract Builder setMimeType(String mimeType);
//
// public abstract Job build();
// }
// }
//
// Path: rxuploader/src/main/java/com/jagsaund/rxuploader/job/Status.java
// public class Status {
// @NonNull private final StatusType status;
// @NonNull private final String id;
//
// @Nullable private final ErrorType error;
//
// @Expose(serialize = false,
// deserialize = false) private final int progress;
//
// @Expose(serialize = false,
// deserialize = false) @Nullable private final Object response;
//
// private Status(@NonNull String id, @NonNull StatusType status, int progress,
// @Nullable ErrorType error, @Nullable Object response) {
// this.id = id;
// this.status = status;
// this.progress = progress;
// this.error = error;
// this.response = response;
// }
//
// @NonNull
// public static Status createQueued(@NonNull String id) {
// return new Status(id, StatusType.QUEUED, 0, null, null);
// }
//
// @NonNull
// public static Status createSending(@NonNull String id, int progress) {
// return new Status(id, StatusType.SENDING, progress, null, null);
// }
//
// @NonNull
// public static Status createCompleted(@NonNull String id, @Nullable Object response) {
// return new Status(id, StatusType.COMPLETED, 0, null, response);
// }
//
// @NonNull
// public static Status createFailed(@NonNull String id, @NonNull ErrorType error) {
// return new Status(id, StatusType.FAILED, 0, error, null);
// }
//
// @NonNull
// public static Status createInvalid(@NonNull String id) {
// return new Status(id, StatusType.INVALID, 0, null, null);
// }
//
// @NonNull
// public String id() {
// return id;
// }
//
// @NonNull
// public StatusType statusType() {
// return status;
// }
//
// public int progress() {
// return progress;
// }
//
// @NonNull
// public Status withProgress(int progress) {
// return createSending(id, progress);
// }
//
// @Nullable
// public ErrorType error() {
// return error;
// }
//
// @Nullable
// public Object response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Status jobStatus = (Status) o;
//
// if (progress != jobStatus.progress) return false;
// if (status != jobStatus.status) return false;
// if (error != jobStatus.error) return false;
// if (!id.equals(jobStatus.id)) return false;
// return response != null ? response.equals(jobStatus.response) : jobStatus.response == null;
// }
//
// @Override
// public int hashCode() {
// int result = status.hashCode();
// result = 31 * result + (error != null ? error.hashCode() : 0);
// result = 31 * result + id.hashCode();
// result = 31 * result + progress;
// result = 31 * result + (response != null ? response.hashCode() : 0);
// return result;
// }
//
// @Override
// public String toString() {
// return "JobStatus{"
// + "status="
// + status
// + ", id="
// + id
// + ", progress="
// + progress
// + ", error="
// + error
// + ", response="
// + response
// + '}';
// }
// }
// Path: rxuploader/src/main/java/com/jagsaund/rxuploader/UploadInteractor.java
import android.support.annotation.NonNull;
import com.jagsaund.rxuploader.job.Job;
import com.jagsaund.rxuploader.job.Status;
import rx.Observable;
package com.jagsaund.rxuploader;
public interface UploadInteractor {
@NonNull | Observable<Job> get(@NonNull String id); |
jsaund/RxUploader | rxuploader/src/main/java/com/jagsaund/rxuploader/UploadInteractor.java | // Path: rxuploader/src/main/java/com/jagsaund/rxuploader/job/Job.java
// @AutoValue
// public abstract class Job {
// public static final String INVALID_JOB_ID = "invalid_job_id";
// public static final Map<String, Object> INVALID_METADATA = Collections.emptyMap();
// public static final Job INVALID_JOB = Job.builder()
// .setId(INVALID_JOB_ID)
// .setStatus(Status.createInvalid(INVALID_JOB_ID))
// .setFilepath("")
// .setMetadata(INVALID_METADATA)
// .setMimeType("")
// .build();
//
// public static boolean isInvalid(@NonNull Job job) {
// return INVALID_JOB == job || INVALID_JOB_ID.equals(job.id());
// }
//
// @NonNull
// public static TypeAdapter<Job> typeAdapter(Gson gson) {
// return new AutoValue_Job.GsonTypeAdapter(gson);
// }
//
// @NonNull
// public static Builder builder() {
// return new AutoValue_Job.Builder();
// }
//
// @NonNull
// public abstract String id();
//
// @NonNull
// public abstract Status status();
//
// @NonNull
// public Job withStatus(@NonNull Status status) {
// return toBuilder().setStatus(status).build();
// }
//
// @NonNull
// abstract Builder toBuilder();
//
// @NonNull
// public abstract String filepath();
//
// @NonNull
// public abstract Map<String, Object> metadata();
//
// @NonNull
// public abstract String mimeType();
//
// @AutoValue.Builder
// public abstract static class Builder {
// public abstract Builder setId(String jobId);
//
// public abstract Builder setStatus(Status status);
//
// public abstract Builder setFilepath(String filepath);
//
// public abstract Builder setMetadata(Map<String, Object> metadata);
//
// public abstract Builder setMimeType(String mimeType);
//
// public abstract Job build();
// }
// }
//
// Path: rxuploader/src/main/java/com/jagsaund/rxuploader/job/Status.java
// public class Status {
// @NonNull private final StatusType status;
// @NonNull private final String id;
//
// @Nullable private final ErrorType error;
//
// @Expose(serialize = false,
// deserialize = false) private final int progress;
//
// @Expose(serialize = false,
// deserialize = false) @Nullable private final Object response;
//
// private Status(@NonNull String id, @NonNull StatusType status, int progress,
// @Nullable ErrorType error, @Nullable Object response) {
// this.id = id;
// this.status = status;
// this.progress = progress;
// this.error = error;
// this.response = response;
// }
//
// @NonNull
// public static Status createQueued(@NonNull String id) {
// return new Status(id, StatusType.QUEUED, 0, null, null);
// }
//
// @NonNull
// public static Status createSending(@NonNull String id, int progress) {
// return new Status(id, StatusType.SENDING, progress, null, null);
// }
//
// @NonNull
// public static Status createCompleted(@NonNull String id, @Nullable Object response) {
// return new Status(id, StatusType.COMPLETED, 0, null, response);
// }
//
// @NonNull
// public static Status createFailed(@NonNull String id, @NonNull ErrorType error) {
// return new Status(id, StatusType.FAILED, 0, error, null);
// }
//
// @NonNull
// public static Status createInvalid(@NonNull String id) {
// return new Status(id, StatusType.INVALID, 0, null, null);
// }
//
// @NonNull
// public String id() {
// return id;
// }
//
// @NonNull
// public StatusType statusType() {
// return status;
// }
//
// public int progress() {
// return progress;
// }
//
// @NonNull
// public Status withProgress(int progress) {
// return createSending(id, progress);
// }
//
// @Nullable
// public ErrorType error() {
// return error;
// }
//
// @Nullable
// public Object response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Status jobStatus = (Status) o;
//
// if (progress != jobStatus.progress) return false;
// if (status != jobStatus.status) return false;
// if (error != jobStatus.error) return false;
// if (!id.equals(jobStatus.id)) return false;
// return response != null ? response.equals(jobStatus.response) : jobStatus.response == null;
// }
//
// @Override
// public int hashCode() {
// int result = status.hashCode();
// result = 31 * result + (error != null ? error.hashCode() : 0);
// result = 31 * result + id.hashCode();
// result = 31 * result + progress;
// result = 31 * result + (response != null ? response.hashCode() : 0);
// return result;
// }
//
// @Override
// public String toString() {
// return "JobStatus{"
// + "status="
// + status
// + ", id="
// + id
// + ", progress="
// + progress
// + ", error="
// + error
// + ", response="
// + response
// + '}';
// }
// }
| import android.support.annotation.NonNull;
import com.jagsaund.rxuploader.job.Job;
import com.jagsaund.rxuploader.job.Status;
import rx.Observable; | package com.jagsaund.rxuploader;
public interface UploadInteractor {
@NonNull
Observable<Job> get(@NonNull String id);
@NonNull
Observable<Job> getAll();
@NonNull
Observable<Job> save(@NonNull Job job);
@NonNull | // Path: rxuploader/src/main/java/com/jagsaund/rxuploader/job/Job.java
// @AutoValue
// public abstract class Job {
// public static final String INVALID_JOB_ID = "invalid_job_id";
// public static final Map<String, Object> INVALID_METADATA = Collections.emptyMap();
// public static final Job INVALID_JOB = Job.builder()
// .setId(INVALID_JOB_ID)
// .setStatus(Status.createInvalid(INVALID_JOB_ID))
// .setFilepath("")
// .setMetadata(INVALID_METADATA)
// .setMimeType("")
// .build();
//
// public static boolean isInvalid(@NonNull Job job) {
// return INVALID_JOB == job || INVALID_JOB_ID.equals(job.id());
// }
//
// @NonNull
// public static TypeAdapter<Job> typeAdapter(Gson gson) {
// return new AutoValue_Job.GsonTypeAdapter(gson);
// }
//
// @NonNull
// public static Builder builder() {
// return new AutoValue_Job.Builder();
// }
//
// @NonNull
// public abstract String id();
//
// @NonNull
// public abstract Status status();
//
// @NonNull
// public Job withStatus(@NonNull Status status) {
// return toBuilder().setStatus(status).build();
// }
//
// @NonNull
// abstract Builder toBuilder();
//
// @NonNull
// public abstract String filepath();
//
// @NonNull
// public abstract Map<String, Object> metadata();
//
// @NonNull
// public abstract String mimeType();
//
// @AutoValue.Builder
// public abstract static class Builder {
// public abstract Builder setId(String jobId);
//
// public abstract Builder setStatus(Status status);
//
// public abstract Builder setFilepath(String filepath);
//
// public abstract Builder setMetadata(Map<String, Object> metadata);
//
// public abstract Builder setMimeType(String mimeType);
//
// public abstract Job build();
// }
// }
//
// Path: rxuploader/src/main/java/com/jagsaund/rxuploader/job/Status.java
// public class Status {
// @NonNull private final StatusType status;
// @NonNull private final String id;
//
// @Nullable private final ErrorType error;
//
// @Expose(serialize = false,
// deserialize = false) private final int progress;
//
// @Expose(serialize = false,
// deserialize = false) @Nullable private final Object response;
//
// private Status(@NonNull String id, @NonNull StatusType status, int progress,
// @Nullable ErrorType error, @Nullable Object response) {
// this.id = id;
// this.status = status;
// this.progress = progress;
// this.error = error;
// this.response = response;
// }
//
// @NonNull
// public static Status createQueued(@NonNull String id) {
// return new Status(id, StatusType.QUEUED, 0, null, null);
// }
//
// @NonNull
// public static Status createSending(@NonNull String id, int progress) {
// return new Status(id, StatusType.SENDING, progress, null, null);
// }
//
// @NonNull
// public static Status createCompleted(@NonNull String id, @Nullable Object response) {
// return new Status(id, StatusType.COMPLETED, 0, null, response);
// }
//
// @NonNull
// public static Status createFailed(@NonNull String id, @NonNull ErrorType error) {
// return new Status(id, StatusType.FAILED, 0, error, null);
// }
//
// @NonNull
// public static Status createInvalid(@NonNull String id) {
// return new Status(id, StatusType.INVALID, 0, null, null);
// }
//
// @NonNull
// public String id() {
// return id;
// }
//
// @NonNull
// public StatusType statusType() {
// return status;
// }
//
// public int progress() {
// return progress;
// }
//
// @NonNull
// public Status withProgress(int progress) {
// return createSending(id, progress);
// }
//
// @Nullable
// public ErrorType error() {
// return error;
// }
//
// @Nullable
// public Object response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Status jobStatus = (Status) o;
//
// if (progress != jobStatus.progress) return false;
// if (status != jobStatus.status) return false;
// if (error != jobStatus.error) return false;
// if (!id.equals(jobStatus.id)) return false;
// return response != null ? response.equals(jobStatus.response) : jobStatus.response == null;
// }
//
// @Override
// public int hashCode() {
// int result = status.hashCode();
// result = 31 * result + (error != null ? error.hashCode() : 0);
// result = 31 * result + id.hashCode();
// result = 31 * result + progress;
// result = 31 * result + (response != null ? response.hashCode() : 0);
// return result;
// }
//
// @Override
// public String toString() {
// return "JobStatus{"
// + "status="
// + status
// + ", id="
// + id
// + ", progress="
// + progress
// + ", error="
// + error
// + ", response="
// + response
// + '}';
// }
// }
// Path: rxuploader/src/main/java/com/jagsaund/rxuploader/UploadInteractor.java
import android.support.annotation.NonNull;
import com.jagsaund.rxuploader.job.Job;
import com.jagsaund.rxuploader.job.Status;
import rx.Observable;
package com.jagsaund.rxuploader;
public interface UploadInteractor {
@NonNull
Observable<Job> get(@NonNull String id);
@NonNull
Observable<Job> getAll();
@NonNull
Observable<Job> save(@NonNull Job job);
@NonNull | Observable<Job> update(@NonNull Status status); |
brettcannon/oplop | Java/src/com/pyen/oplop/android/Oplop.java | // Path: Java/src/com/pyen/oplop/password/PasswordGenerator.java
// public class PasswordGenerator {
// private String m_label;
// private String m_password;
// private String m_rawHash;
//
// public static final int LENGTH = 8;
//
// public PasswordGenerator(String label, String password) {
// m_label = label;
// m_password = password;
// }
//
// public String generate() {
// MD5 md5 = new MD5();
//
// md5.Update(m_password);
// md5.Update(m_label);
//
// m_rawHash = new String(Base64Coder.urlSafeEncode(md5.Final()));
//
// String hash = requireDigit(m_rawHash);
//
// return hash.substring(0,LENGTH);
// }
//
// public String requireDigit(String password) {
// boolean foundDigits = false;
// StringBuffer digits = new StringBuffer();
// for (int i=0; i<password.length(); i++) {
// if (Character.isDigit(password.charAt(i))) {
// if (i<LENGTH) {
// // in this case, we already have a number, so
// // nothing for us to do.
// return password;
// }
// else {
// digits.append(password.charAt(i));
// foundDigits = true;
// }
// }
// else {
// if (foundDigits) {
// return digits.toString() + password;
// }
// }
// }
// return '1' + password;
// }
//
// /**
// * Only here for testing purposes. Not valid unless generate has been
// * called.
// */
// String getRawHash() {
// return m_rawHash;
// }
//
// public static void main(String a[]) {
// PasswordGenerator pg = new PasswordGenerator(a[0], a[1]);
// System.out.println(pg.generate());
// }
// }
| import java.util.ArrayList;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.database.Cursor;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.EditText;
import com.pyen.oplop.password.PasswordGenerator; | clearFields();
}
});
generateButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
generatePassword();
displayPassword();
}
});
}
/**
* Clear all the UI fields in the main view.
*/
private void clearFields(){
mLabelText.setText("");
mMasterPasswordText.setText("");
}
/**
* Generate the password base on the label and master password.
*/
private void generatePassword(){
String label = mLabelText.getText().toString();
String password = mMasterPasswordText.getText().toString(); | // Path: Java/src/com/pyen/oplop/password/PasswordGenerator.java
// public class PasswordGenerator {
// private String m_label;
// private String m_password;
// private String m_rawHash;
//
// public static final int LENGTH = 8;
//
// public PasswordGenerator(String label, String password) {
// m_label = label;
// m_password = password;
// }
//
// public String generate() {
// MD5 md5 = new MD5();
//
// md5.Update(m_password);
// md5.Update(m_label);
//
// m_rawHash = new String(Base64Coder.urlSafeEncode(md5.Final()));
//
// String hash = requireDigit(m_rawHash);
//
// return hash.substring(0,LENGTH);
// }
//
// public String requireDigit(String password) {
// boolean foundDigits = false;
// StringBuffer digits = new StringBuffer();
// for (int i=0; i<password.length(); i++) {
// if (Character.isDigit(password.charAt(i))) {
// if (i<LENGTH) {
// // in this case, we already have a number, so
// // nothing for us to do.
// return password;
// }
// else {
// digits.append(password.charAt(i));
// foundDigits = true;
// }
// }
// else {
// if (foundDigits) {
// return digits.toString() + password;
// }
// }
// }
// return '1' + password;
// }
//
// /**
// * Only here for testing purposes. Not valid unless generate has been
// * called.
// */
// String getRawHash() {
// return m_rawHash;
// }
//
// public static void main(String a[]) {
// PasswordGenerator pg = new PasswordGenerator(a[0], a[1]);
// System.out.println(pg.generate());
// }
// }
// Path: Java/src/com/pyen/oplop/android/Oplop.java
import java.util.ArrayList;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.database.Cursor;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.EditText;
import com.pyen.oplop.password.PasswordGenerator;
clearFields();
}
});
generateButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
generatePassword();
displayPassword();
}
});
}
/**
* Clear all the UI fields in the main view.
*/
private void clearFields(){
mLabelText.setText("");
mMasterPasswordText.setText("");
}
/**
* Generate the password base on the label and master password.
*/
private void generatePassword(){
String label = mLabelText.getText().toString();
String password = mMasterPasswordText.getText().toString(); | PasswordGenerator generator = new PasswordGenerator(label,password); |
brettcannon/oplop | Java/src/com/pyen/oplop/j2me/MainForm.java | // Path: Java/src/com/pyen/oplop/password/PasswordGenerator.java
// public class PasswordGenerator {
// private String m_label;
// private String m_password;
// private String m_rawHash;
//
// public static final int LENGTH = 8;
//
// public PasswordGenerator(String label, String password) {
// m_label = label;
// m_password = password;
// }
//
// public String generate() {
// MD5 md5 = new MD5();
//
// md5.Update(m_password);
// md5.Update(m_label);
//
// m_rawHash = new String(Base64Coder.urlSafeEncode(md5.Final()));
//
// String hash = requireDigit(m_rawHash);
//
// return hash.substring(0,LENGTH);
// }
//
// public String requireDigit(String password) {
// boolean foundDigits = false;
// StringBuffer digits = new StringBuffer();
// for (int i=0; i<password.length(); i++) {
// if (Character.isDigit(password.charAt(i))) {
// if (i<LENGTH) {
// // in this case, we already have a number, so
// // nothing for us to do.
// return password;
// }
// else {
// digits.append(password.charAt(i));
// foundDigits = true;
// }
// }
// else {
// if (foundDigits) {
// return digits.toString() + password;
// }
// }
// }
// return '1' + password;
// }
//
// /**
// * Only here for testing purposes. Not valid unless generate has been
// * called.
// */
// String getRawHash() {
// return m_rawHash;
// }
//
// public static void main(String a[]) {
// PasswordGenerator pg = new PasswordGenerator(a[0], a[1]);
// System.out.println(pg.generate());
// }
// }
| import java.util.Vector;
import java.util.Enumeration;
import javax.microedition.lcdui.TextField;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.ChoiceGroup;
import com.pyen.oplop.password.PasswordGenerator; |
m_label = new TextField("Nickname", "", 255, TextField.ANY);
append(m_label);
m_storedLabels =
new ChoiceGroup("", ChoiceGroup.POPUP);
populateStoredLabels();
append(m_storedLabels);
m_password = new TextField("Password", "", 255, TextField.PASSWORD);
append(m_password);
addCommand(new Command("Ok", Command.OK, 1));
addCommand(new Command("Back", Command.BACK, 1));
}
public OplopForm getNextForm() {
String chosenLabel = "";
if (m_label.size() > 0) {
chosenLabel = m_label.getString();
}
else {
for (int i=0; i<m_storedLabels.size(); i++) {
if (m_storedLabels.isSelected(i)) {
chosenLabel = m_storedLabels.getString(i);
break;
}
}
}
m_cache.add(chosenLabel); | // Path: Java/src/com/pyen/oplop/password/PasswordGenerator.java
// public class PasswordGenerator {
// private String m_label;
// private String m_password;
// private String m_rawHash;
//
// public static final int LENGTH = 8;
//
// public PasswordGenerator(String label, String password) {
// m_label = label;
// m_password = password;
// }
//
// public String generate() {
// MD5 md5 = new MD5();
//
// md5.Update(m_password);
// md5.Update(m_label);
//
// m_rawHash = new String(Base64Coder.urlSafeEncode(md5.Final()));
//
// String hash = requireDigit(m_rawHash);
//
// return hash.substring(0,LENGTH);
// }
//
// public String requireDigit(String password) {
// boolean foundDigits = false;
// StringBuffer digits = new StringBuffer();
// for (int i=0; i<password.length(); i++) {
// if (Character.isDigit(password.charAt(i))) {
// if (i<LENGTH) {
// // in this case, we already have a number, so
// // nothing for us to do.
// return password;
// }
// else {
// digits.append(password.charAt(i));
// foundDigits = true;
// }
// }
// else {
// if (foundDigits) {
// return digits.toString() + password;
// }
// }
// }
// return '1' + password;
// }
//
// /**
// * Only here for testing purposes. Not valid unless generate has been
// * called.
// */
// String getRawHash() {
// return m_rawHash;
// }
//
// public static void main(String a[]) {
// PasswordGenerator pg = new PasswordGenerator(a[0], a[1]);
// System.out.println(pg.generate());
// }
// }
// Path: Java/src/com/pyen/oplop/j2me/MainForm.java
import java.util.Vector;
import java.util.Enumeration;
import javax.microedition.lcdui.TextField;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.ChoiceGroup;
import com.pyen.oplop.password.PasswordGenerator;
m_label = new TextField("Nickname", "", 255, TextField.ANY);
append(m_label);
m_storedLabels =
new ChoiceGroup("", ChoiceGroup.POPUP);
populateStoredLabels();
append(m_storedLabels);
m_password = new TextField("Password", "", 255, TextField.PASSWORD);
append(m_password);
addCommand(new Command("Ok", Command.OK, 1));
addCommand(new Command("Back", Command.BACK, 1));
}
public OplopForm getNextForm() {
String chosenLabel = "";
if (m_label.size() > 0) {
chosenLabel = m_label.getString();
}
else {
for (int i=0; i<m_storedLabels.size(); i++) {
if (m_storedLabels.isSelected(i)) {
chosenLabel = m_storedLabels.getString(i);
break;
}
}
}
m_cache.add(chosenLabel); | return new ResultForm(new PasswordGenerator( |
jottley/spring-social-salesforce | src/main/java/org/springframework/social/salesforce/api/impl/json/SalesforceProfileMixin.java | // Path: src/main/java/org/springframework/social/salesforce/api/Photo.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class Photo {
//
// private String smallPhotoUrl;
//
// private String largePhotoUrl;
//
//
// public Photo() {
//
// }
//
//
// public String getSmallPhotoUrl() {
// return smallPhotoUrl;
// }
//
// public void setSmallPhotoUrl(String smallPhotoUrl) {
// this.smallPhotoUrl = smallPhotoUrl;
// }
//
// public String getLargePhotoUrl() {
// return largePhotoUrl;
// }
//
// public void setLargePhotoUrl(String largePhotoUrl) {
// this.largePhotoUrl = largePhotoUrl;
// }
//
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/SalesforceProfile.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class SalesforceProfile implements Serializable {
// protected String id;
//
// protected String email;
//
// protected String firstName;
//
// protected String lastName;
//
// protected Photo photo;
//
// protected String name;
//
//
// /*public SalesforceProfile(String id, String firstName, String lastName, String email) {
// this.id = id;
// this.firstName = firstName;
// this.lastName = lastName;
// this.email = email;
// }*/
//
//
// public String getId() {
// return id;
// }
//
// public String getEmail() {
// return email;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public Photo getPhoto() {
// return this.photo;
// }
//
// public String getName() {
// return this.name;
// }
//
// public String getUsername() {
// return this.id;
// }
// }
| import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.springframework.social.salesforce.api.Photo;
import org.springframework.social.salesforce.api.SalesforceProfile; | /**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.impl.json;
/**
* {@link SalesforceProfile}
*
* @author Umut Utkan
* @author Alexandra Leahu
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class SalesforceProfileMixin {
@JsonCreator
SalesforceProfileMixin(
@JsonProperty("id") String id,
@JsonProperty("firstName") String firstName,
@JsonProperty("lastName") String lastName,
@JsonProperty("email") String email,
@JsonProperty("name") String name) {
}
@JsonProperty("photo") | // Path: src/main/java/org/springframework/social/salesforce/api/Photo.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class Photo {
//
// private String smallPhotoUrl;
//
// private String largePhotoUrl;
//
//
// public Photo() {
//
// }
//
//
// public String getSmallPhotoUrl() {
// return smallPhotoUrl;
// }
//
// public void setSmallPhotoUrl(String smallPhotoUrl) {
// this.smallPhotoUrl = smallPhotoUrl;
// }
//
// public String getLargePhotoUrl() {
// return largePhotoUrl;
// }
//
// public void setLargePhotoUrl(String largePhotoUrl) {
// this.largePhotoUrl = largePhotoUrl;
// }
//
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/SalesforceProfile.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class SalesforceProfile implements Serializable {
// protected String id;
//
// protected String email;
//
// protected String firstName;
//
// protected String lastName;
//
// protected Photo photo;
//
// protected String name;
//
//
// /*public SalesforceProfile(String id, String firstName, String lastName, String email) {
// this.id = id;
// this.firstName = firstName;
// this.lastName = lastName;
// this.email = email;
// }*/
//
//
// public String getId() {
// return id;
// }
//
// public String getEmail() {
// return email;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public Photo getPhoto() {
// return this.photo;
// }
//
// public String getName() {
// return this.name;
// }
//
// public String getUsername() {
// return this.id;
// }
// }
// Path: src/main/java/org/springframework/social/salesforce/api/impl/json/SalesforceProfileMixin.java
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.springframework.social.salesforce.api.Photo;
import org.springframework.social.salesforce.api.SalesforceProfile;
/**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.impl.json;
/**
* {@link SalesforceProfile}
*
* @author Umut Utkan
* @author Alexandra Leahu
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class SalesforceProfileMixin {
@JsonCreator
SalesforceProfileMixin(
@JsonProperty("id") String id,
@JsonProperty("firstName") String firstName,
@JsonProperty("lastName") String lastName,
@JsonProperty("email") String email,
@JsonProperty("name") String name) {
}
@JsonProperty("photo") | Photo photo; |
jottley/spring-social-salesforce | src/test/java/org/springframework/social/salesforce/api/client/BaseSalesforceFactoryTest.java | // Path: src/main/java/org/springframework/social/salesforce/api/Salesforce.java
// public interface Salesforce extends ApiBinding {
//
// public ApiOperations apiOperations();
//
// public ApiOperations apiOperations(String instanceUrl);
//
// public ChatterOperations chatterOperations();
//
// public ChatterOperations chatterOperations(String instanceUrl);
//
// public QueryOperations queryOperations();
//
// public QueryOperations queryOperations(String instanceUrl);
//
// public RecentOperations recentOperations();
//
// public RecentOperations recentOperations(String instanceUrl);
//
// public SearchOperations searchOperations();
//
// public SearchOperations searchOperations(String instanceUrl);
//
// public SObjectOperations sObjectsOperations();
//
// public SObjectOperations sObjectsOperations(String instanceUrl);
//
// public UserOperations userOperations();
//
// public UserOperations userOperations(String gatewayUrl);
//
// public LimitsOperations limitsOperations();
//
// public LimitsOperations limitsOperations(String instanceUrl);
//
// public <T> List<T> readList(JsonNode jsonNode, Class<T> type);
//
// public <T> T readObject(JsonNode jsonNode, Class<T> type);
//
// public String getBaseUrl();
//
// public String getInstanceUrl();
//
// public void setInstanceUrl(String instanceUrl);
//
// public String getUserInfoUrl();
//
// public String getAuthGatewayUrl();
//
// public void setAuthGatewayBaseUrl(String gatewayUrl);
//
// public ConnectOperations connectOperations();
//
// public ConnectOperations connectOperations(String instanceUrl);
//
// public CustomApiOperations customApiOperations();
//
// public CustomApiOperations customApiOperations(String instanceUrl);
// }
//
// Path: src/main/java/org/springframework/social/salesforce/client/BaseSalesforceFactory.java
// public class BaseSalesforceFactory implements SalesforceFactory {
//
// private final static String DEFAULT_AUTH_URL = SalesforceServiceProvider.PRODUCTION_GATEWAY_URL + SalesforceServiceProvider.TOKEN_PATH;
//
//
// private String clientId;
//
// private String clientSecret;
//
// private String authorizeUrl = DEFAULT_AUTH_URL;
//
// private RestTemplate restTemplate;
//
//
// public BaseSalesforceFactory(String clientId, String clientSecret) {
// this(clientId, clientSecret, createRestTemplate());
// }
//
// public BaseSalesforceFactory(String clientId, String clientSecret, RestTemplate restTemplate) {
// this.clientId = clientId;
// this.clientSecret = clientSecret;
// this.restTemplate = restTemplate;
// }
//
//
// public void setAuthorizeUrl(String authorizeUrl) {
// this.authorizeUrl = authorizeUrl;
// }
//
// public String getAuthorizeUrl() {
// return (this.authorizeUrl == null) ? DEFAULT_AUTH_URL : this.authorizeUrl;
// }
//
// @Override
// @SuppressWarnings("unchecked")
// public Salesforce create(String username, String password, String securityToken) {
// MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
// map.add("grant_type", "password");
// map.add("client_id", this.clientId);
// map.add("client_secret", this.clientSecret);
// map.add("username", username);
// map.add("password", password + (securityToken == null ? "" : securityToken));
//
// Map<String, String> token = restTemplate.postForObject(this.authorizeUrl, map, Map.class);
// SalesforceTemplate template = new SalesforceTemplate(token.get("access_token"));
// String instanceUrl = token.get("instance_url");
// if (instanceUrl != null) {
// template.setInstanceUrl(instanceUrl);
// }
// return template;
// }
//
// private static RestTemplate createRestTemplate() {
// RestTemplate restTemplate = new RestTemplate();
// restTemplate.setRequestFactory(ClientHttpRequestFactorySelector.getRequestFactory());
// restTemplate.setErrorHandler(new ErrorHandler());
// return restTemplate;
// }
//
// }
| import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus;
import org.junit.Test;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.social.salesforce.api.Salesforce;
import org.springframework.social.salesforce.client.BaseSalesforceFactory;
import org.springframework.test.web.client.MockRestServiceServer;
import org.springframework.web.client.RestTemplate;
import static org.junit.Assert.assertNotNull;
import static org.springframework.http.HttpMethod.POST;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.content;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.method; | /**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.client;
/**
* @author Umut Utkan
* @author Jared Ottley
*/
public class BaseSalesforceFactoryTest {
@Test
public void testClientLogin() {
RestTemplate restTemplate = new RestTemplate();
MockRestServiceServer mockServer = MockRestServiceServer.createServer(restTemplate);
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setContentType(MediaType.APPLICATION_JSON);
mockServer.expect(requestTo("https://login.salesforce.com/services/oauth2/token"))
.andExpect(method(POST))
.andExpect(content().string("grant_type=password&client_id=client-id&client_secret=client-secret&username=my-username&password=my-passwordsecurity-token"))
.andRespond(withStatus(HttpStatus.OK).body(loadResource("client-token.json")).headers(responseHeaders));
| // Path: src/main/java/org/springframework/social/salesforce/api/Salesforce.java
// public interface Salesforce extends ApiBinding {
//
// public ApiOperations apiOperations();
//
// public ApiOperations apiOperations(String instanceUrl);
//
// public ChatterOperations chatterOperations();
//
// public ChatterOperations chatterOperations(String instanceUrl);
//
// public QueryOperations queryOperations();
//
// public QueryOperations queryOperations(String instanceUrl);
//
// public RecentOperations recentOperations();
//
// public RecentOperations recentOperations(String instanceUrl);
//
// public SearchOperations searchOperations();
//
// public SearchOperations searchOperations(String instanceUrl);
//
// public SObjectOperations sObjectsOperations();
//
// public SObjectOperations sObjectsOperations(String instanceUrl);
//
// public UserOperations userOperations();
//
// public UserOperations userOperations(String gatewayUrl);
//
// public LimitsOperations limitsOperations();
//
// public LimitsOperations limitsOperations(String instanceUrl);
//
// public <T> List<T> readList(JsonNode jsonNode, Class<T> type);
//
// public <T> T readObject(JsonNode jsonNode, Class<T> type);
//
// public String getBaseUrl();
//
// public String getInstanceUrl();
//
// public void setInstanceUrl(String instanceUrl);
//
// public String getUserInfoUrl();
//
// public String getAuthGatewayUrl();
//
// public void setAuthGatewayBaseUrl(String gatewayUrl);
//
// public ConnectOperations connectOperations();
//
// public ConnectOperations connectOperations(String instanceUrl);
//
// public CustomApiOperations customApiOperations();
//
// public CustomApiOperations customApiOperations(String instanceUrl);
// }
//
// Path: src/main/java/org/springframework/social/salesforce/client/BaseSalesforceFactory.java
// public class BaseSalesforceFactory implements SalesforceFactory {
//
// private final static String DEFAULT_AUTH_URL = SalesforceServiceProvider.PRODUCTION_GATEWAY_URL + SalesforceServiceProvider.TOKEN_PATH;
//
//
// private String clientId;
//
// private String clientSecret;
//
// private String authorizeUrl = DEFAULT_AUTH_URL;
//
// private RestTemplate restTemplate;
//
//
// public BaseSalesforceFactory(String clientId, String clientSecret) {
// this(clientId, clientSecret, createRestTemplate());
// }
//
// public BaseSalesforceFactory(String clientId, String clientSecret, RestTemplate restTemplate) {
// this.clientId = clientId;
// this.clientSecret = clientSecret;
// this.restTemplate = restTemplate;
// }
//
//
// public void setAuthorizeUrl(String authorizeUrl) {
// this.authorizeUrl = authorizeUrl;
// }
//
// public String getAuthorizeUrl() {
// return (this.authorizeUrl == null) ? DEFAULT_AUTH_URL : this.authorizeUrl;
// }
//
// @Override
// @SuppressWarnings("unchecked")
// public Salesforce create(String username, String password, String securityToken) {
// MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
// map.add("grant_type", "password");
// map.add("client_id", this.clientId);
// map.add("client_secret", this.clientSecret);
// map.add("username", username);
// map.add("password", password + (securityToken == null ? "" : securityToken));
//
// Map<String, String> token = restTemplate.postForObject(this.authorizeUrl, map, Map.class);
// SalesforceTemplate template = new SalesforceTemplate(token.get("access_token"));
// String instanceUrl = token.get("instance_url");
// if (instanceUrl != null) {
// template.setInstanceUrl(instanceUrl);
// }
// return template;
// }
//
// private static RestTemplate createRestTemplate() {
// RestTemplate restTemplate = new RestTemplate();
// restTemplate.setRequestFactory(ClientHttpRequestFactorySelector.getRequestFactory());
// restTemplate.setErrorHandler(new ErrorHandler());
// return restTemplate;
// }
//
// }
// Path: src/test/java/org/springframework/social/salesforce/api/client/BaseSalesforceFactoryTest.java
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus;
import org.junit.Test;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.social.salesforce.api.Salesforce;
import org.springframework.social.salesforce.client.BaseSalesforceFactory;
import org.springframework.test.web.client.MockRestServiceServer;
import org.springframework.web.client.RestTemplate;
import static org.junit.Assert.assertNotNull;
import static org.springframework.http.HttpMethod.POST;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.content;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
/**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.client;
/**
* @author Umut Utkan
* @author Jared Ottley
*/
public class BaseSalesforceFactoryTest {
@Test
public void testClientLogin() {
RestTemplate restTemplate = new RestTemplate();
MockRestServiceServer mockServer = MockRestServiceServer.createServer(restTemplate);
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setContentType(MediaType.APPLICATION_JSON);
mockServer.expect(requestTo("https://login.salesforce.com/services/oauth2/token"))
.andExpect(method(POST))
.andExpect(content().string("grant_type=password&client_id=client-id&client_secret=client-secret&username=my-username&password=my-passwordsecurity-token"))
.andRespond(withStatus(HttpStatus.OK).body(loadResource("client-token.json")).headers(responseHeaders));
| Salesforce template = new BaseSalesforceFactory("client-id", "client-secret", restTemplate) |
jottley/spring-social-salesforce | src/test/java/org/springframework/social/salesforce/api/client/BaseSalesforceFactoryTest.java | // Path: src/main/java/org/springframework/social/salesforce/api/Salesforce.java
// public interface Salesforce extends ApiBinding {
//
// public ApiOperations apiOperations();
//
// public ApiOperations apiOperations(String instanceUrl);
//
// public ChatterOperations chatterOperations();
//
// public ChatterOperations chatterOperations(String instanceUrl);
//
// public QueryOperations queryOperations();
//
// public QueryOperations queryOperations(String instanceUrl);
//
// public RecentOperations recentOperations();
//
// public RecentOperations recentOperations(String instanceUrl);
//
// public SearchOperations searchOperations();
//
// public SearchOperations searchOperations(String instanceUrl);
//
// public SObjectOperations sObjectsOperations();
//
// public SObjectOperations sObjectsOperations(String instanceUrl);
//
// public UserOperations userOperations();
//
// public UserOperations userOperations(String gatewayUrl);
//
// public LimitsOperations limitsOperations();
//
// public LimitsOperations limitsOperations(String instanceUrl);
//
// public <T> List<T> readList(JsonNode jsonNode, Class<T> type);
//
// public <T> T readObject(JsonNode jsonNode, Class<T> type);
//
// public String getBaseUrl();
//
// public String getInstanceUrl();
//
// public void setInstanceUrl(String instanceUrl);
//
// public String getUserInfoUrl();
//
// public String getAuthGatewayUrl();
//
// public void setAuthGatewayBaseUrl(String gatewayUrl);
//
// public ConnectOperations connectOperations();
//
// public ConnectOperations connectOperations(String instanceUrl);
//
// public CustomApiOperations customApiOperations();
//
// public CustomApiOperations customApiOperations(String instanceUrl);
// }
//
// Path: src/main/java/org/springframework/social/salesforce/client/BaseSalesforceFactory.java
// public class BaseSalesforceFactory implements SalesforceFactory {
//
// private final static String DEFAULT_AUTH_URL = SalesforceServiceProvider.PRODUCTION_GATEWAY_URL + SalesforceServiceProvider.TOKEN_PATH;
//
//
// private String clientId;
//
// private String clientSecret;
//
// private String authorizeUrl = DEFAULT_AUTH_URL;
//
// private RestTemplate restTemplate;
//
//
// public BaseSalesforceFactory(String clientId, String clientSecret) {
// this(clientId, clientSecret, createRestTemplate());
// }
//
// public BaseSalesforceFactory(String clientId, String clientSecret, RestTemplate restTemplate) {
// this.clientId = clientId;
// this.clientSecret = clientSecret;
// this.restTemplate = restTemplate;
// }
//
//
// public void setAuthorizeUrl(String authorizeUrl) {
// this.authorizeUrl = authorizeUrl;
// }
//
// public String getAuthorizeUrl() {
// return (this.authorizeUrl == null) ? DEFAULT_AUTH_URL : this.authorizeUrl;
// }
//
// @Override
// @SuppressWarnings("unchecked")
// public Salesforce create(String username, String password, String securityToken) {
// MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
// map.add("grant_type", "password");
// map.add("client_id", this.clientId);
// map.add("client_secret", this.clientSecret);
// map.add("username", username);
// map.add("password", password + (securityToken == null ? "" : securityToken));
//
// Map<String, String> token = restTemplate.postForObject(this.authorizeUrl, map, Map.class);
// SalesforceTemplate template = new SalesforceTemplate(token.get("access_token"));
// String instanceUrl = token.get("instance_url");
// if (instanceUrl != null) {
// template.setInstanceUrl(instanceUrl);
// }
// return template;
// }
//
// private static RestTemplate createRestTemplate() {
// RestTemplate restTemplate = new RestTemplate();
// restTemplate.setRequestFactory(ClientHttpRequestFactorySelector.getRequestFactory());
// restTemplate.setErrorHandler(new ErrorHandler());
// return restTemplate;
// }
//
// }
| import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus;
import org.junit.Test;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.social.salesforce.api.Salesforce;
import org.springframework.social.salesforce.client.BaseSalesforceFactory;
import org.springframework.test.web.client.MockRestServiceServer;
import org.springframework.web.client.RestTemplate;
import static org.junit.Assert.assertNotNull;
import static org.springframework.http.HttpMethod.POST;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.content;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.method; | /**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.client;
/**
* @author Umut Utkan
* @author Jared Ottley
*/
public class BaseSalesforceFactoryTest {
@Test
public void testClientLogin() {
RestTemplate restTemplate = new RestTemplate();
MockRestServiceServer mockServer = MockRestServiceServer.createServer(restTemplate);
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setContentType(MediaType.APPLICATION_JSON);
mockServer.expect(requestTo("https://login.salesforce.com/services/oauth2/token"))
.andExpect(method(POST))
.andExpect(content().string("grant_type=password&client_id=client-id&client_secret=client-secret&username=my-username&password=my-passwordsecurity-token"))
.andRespond(withStatus(HttpStatus.OK).body(loadResource("client-token.json")).headers(responseHeaders));
| // Path: src/main/java/org/springframework/social/salesforce/api/Salesforce.java
// public interface Salesforce extends ApiBinding {
//
// public ApiOperations apiOperations();
//
// public ApiOperations apiOperations(String instanceUrl);
//
// public ChatterOperations chatterOperations();
//
// public ChatterOperations chatterOperations(String instanceUrl);
//
// public QueryOperations queryOperations();
//
// public QueryOperations queryOperations(String instanceUrl);
//
// public RecentOperations recentOperations();
//
// public RecentOperations recentOperations(String instanceUrl);
//
// public SearchOperations searchOperations();
//
// public SearchOperations searchOperations(String instanceUrl);
//
// public SObjectOperations sObjectsOperations();
//
// public SObjectOperations sObjectsOperations(String instanceUrl);
//
// public UserOperations userOperations();
//
// public UserOperations userOperations(String gatewayUrl);
//
// public LimitsOperations limitsOperations();
//
// public LimitsOperations limitsOperations(String instanceUrl);
//
// public <T> List<T> readList(JsonNode jsonNode, Class<T> type);
//
// public <T> T readObject(JsonNode jsonNode, Class<T> type);
//
// public String getBaseUrl();
//
// public String getInstanceUrl();
//
// public void setInstanceUrl(String instanceUrl);
//
// public String getUserInfoUrl();
//
// public String getAuthGatewayUrl();
//
// public void setAuthGatewayBaseUrl(String gatewayUrl);
//
// public ConnectOperations connectOperations();
//
// public ConnectOperations connectOperations(String instanceUrl);
//
// public CustomApiOperations customApiOperations();
//
// public CustomApiOperations customApiOperations(String instanceUrl);
// }
//
// Path: src/main/java/org/springframework/social/salesforce/client/BaseSalesforceFactory.java
// public class BaseSalesforceFactory implements SalesforceFactory {
//
// private final static String DEFAULT_AUTH_URL = SalesforceServiceProvider.PRODUCTION_GATEWAY_URL + SalesforceServiceProvider.TOKEN_PATH;
//
//
// private String clientId;
//
// private String clientSecret;
//
// private String authorizeUrl = DEFAULT_AUTH_URL;
//
// private RestTemplate restTemplate;
//
//
// public BaseSalesforceFactory(String clientId, String clientSecret) {
// this(clientId, clientSecret, createRestTemplate());
// }
//
// public BaseSalesforceFactory(String clientId, String clientSecret, RestTemplate restTemplate) {
// this.clientId = clientId;
// this.clientSecret = clientSecret;
// this.restTemplate = restTemplate;
// }
//
//
// public void setAuthorizeUrl(String authorizeUrl) {
// this.authorizeUrl = authorizeUrl;
// }
//
// public String getAuthorizeUrl() {
// return (this.authorizeUrl == null) ? DEFAULT_AUTH_URL : this.authorizeUrl;
// }
//
// @Override
// @SuppressWarnings("unchecked")
// public Salesforce create(String username, String password, String securityToken) {
// MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
// map.add("grant_type", "password");
// map.add("client_id", this.clientId);
// map.add("client_secret", this.clientSecret);
// map.add("username", username);
// map.add("password", password + (securityToken == null ? "" : securityToken));
//
// Map<String, String> token = restTemplate.postForObject(this.authorizeUrl, map, Map.class);
// SalesforceTemplate template = new SalesforceTemplate(token.get("access_token"));
// String instanceUrl = token.get("instance_url");
// if (instanceUrl != null) {
// template.setInstanceUrl(instanceUrl);
// }
// return template;
// }
//
// private static RestTemplate createRestTemplate() {
// RestTemplate restTemplate = new RestTemplate();
// restTemplate.setRequestFactory(ClientHttpRequestFactorySelector.getRequestFactory());
// restTemplate.setErrorHandler(new ErrorHandler());
// return restTemplate;
// }
//
// }
// Path: src/test/java/org/springframework/social/salesforce/api/client/BaseSalesforceFactoryTest.java
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus;
import org.junit.Test;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.social.salesforce.api.Salesforce;
import org.springframework.social.salesforce.client.BaseSalesforceFactory;
import org.springframework.test.web.client.MockRestServiceServer;
import org.springframework.web.client.RestTemplate;
import static org.junit.Assert.assertNotNull;
import static org.springframework.http.HttpMethod.POST;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.content;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
/**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.client;
/**
* @author Umut Utkan
* @author Jared Ottley
*/
public class BaseSalesforceFactoryTest {
@Test
public void testClientLogin() {
RestTemplate restTemplate = new RestTemplate();
MockRestServiceServer mockServer = MockRestServiceServer.createServer(restTemplate);
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setContentType(MediaType.APPLICATION_JSON);
mockServer.expect(requestTo("https://login.salesforce.com/services/oauth2/token"))
.andExpect(method(POST))
.andExpect(content().string("grant_type=password&client_id=client-id&client_secret=client-secret&username=my-username&password=my-passwordsecurity-token"))
.andRespond(withStatus(HttpStatus.OK).body(loadResource("client-token.json")).headers(responseHeaders));
| Salesforce template = new BaseSalesforceFactory("client-id", "client-secret", restTemplate) |
jottley/spring-social-salesforce | src/main/java/org/springframework/social/salesforce/api/impl/RecentTemplate.java | // Path: src/main/java/org/springframework/social/salesforce/api/RecentOperations.java
// public interface RecentOperations {
//
// List<ResultItem> recent();
//
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/ResultItem.java
// public class ResultItem implements Serializable {
//
// private String type;
//
// private String url;
//
// private Map attributes;
//
//
// public ResultItem(String type, String url) {
// this.type = type;
// this.url = url;
// this.attributes = new HashMap();
// }
//
//
// public String getType() {
// return this.type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public String getUrl() {
// return this.url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public Map getAttributes() {
// return attributes;
// }
//
// public void setAttributes(Map attributes) {
// this.attributes = attributes;
// }
//
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/Salesforce.java
// public interface Salesforce extends ApiBinding {
//
// public ApiOperations apiOperations();
//
// public ApiOperations apiOperations(String instanceUrl);
//
// public ChatterOperations chatterOperations();
//
// public ChatterOperations chatterOperations(String instanceUrl);
//
// public QueryOperations queryOperations();
//
// public QueryOperations queryOperations(String instanceUrl);
//
// public RecentOperations recentOperations();
//
// public RecentOperations recentOperations(String instanceUrl);
//
// public SearchOperations searchOperations();
//
// public SearchOperations searchOperations(String instanceUrl);
//
// public SObjectOperations sObjectsOperations();
//
// public SObjectOperations sObjectsOperations(String instanceUrl);
//
// public UserOperations userOperations();
//
// public UserOperations userOperations(String gatewayUrl);
//
// public LimitsOperations limitsOperations();
//
// public LimitsOperations limitsOperations(String instanceUrl);
//
// public <T> List<T> readList(JsonNode jsonNode, Class<T> type);
//
// public <T> T readObject(JsonNode jsonNode, Class<T> type);
//
// public String getBaseUrl();
//
// public String getInstanceUrl();
//
// public void setInstanceUrl(String instanceUrl);
//
// public String getUserInfoUrl();
//
// public String getAuthGatewayUrl();
//
// public void setAuthGatewayBaseUrl(String gatewayUrl);
//
// public ConnectOperations connectOperations();
//
// public ConnectOperations connectOperations(String instanceUrl);
//
// public CustomApiOperations customApiOperations();
//
// public CustomApiOperations customApiOperations(String instanceUrl);
// }
| import com.fasterxml.jackson.databind.JsonNode;
import org.springframework.social.salesforce.api.RecentOperations;
import org.springframework.social.salesforce.api.ResultItem;
import org.springframework.social.salesforce.api.Salesforce;
import org.springframework.web.client.RestTemplate;
import java.util.List; | /**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.impl;
/**
* Default implementation of RecentOperations.
*
* @author Umut Utkan
* @author Jared Ottley
*/
public class RecentTemplate extends AbstractSalesForceOperations<Salesforce> implements RecentOperations {
private RestTemplate restTemplate;
public RecentTemplate(Salesforce api, RestTemplate restTemplate) {
super(api);
this.restTemplate = restTemplate;
}
@Override | // Path: src/main/java/org/springframework/social/salesforce/api/RecentOperations.java
// public interface RecentOperations {
//
// List<ResultItem> recent();
//
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/ResultItem.java
// public class ResultItem implements Serializable {
//
// private String type;
//
// private String url;
//
// private Map attributes;
//
//
// public ResultItem(String type, String url) {
// this.type = type;
// this.url = url;
// this.attributes = new HashMap();
// }
//
//
// public String getType() {
// return this.type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public String getUrl() {
// return this.url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public Map getAttributes() {
// return attributes;
// }
//
// public void setAttributes(Map attributes) {
// this.attributes = attributes;
// }
//
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/Salesforce.java
// public interface Salesforce extends ApiBinding {
//
// public ApiOperations apiOperations();
//
// public ApiOperations apiOperations(String instanceUrl);
//
// public ChatterOperations chatterOperations();
//
// public ChatterOperations chatterOperations(String instanceUrl);
//
// public QueryOperations queryOperations();
//
// public QueryOperations queryOperations(String instanceUrl);
//
// public RecentOperations recentOperations();
//
// public RecentOperations recentOperations(String instanceUrl);
//
// public SearchOperations searchOperations();
//
// public SearchOperations searchOperations(String instanceUrl);
//
// public SObjectOperations sObjectsOperations();
//
// public SObjectOperations sObjectsOperations(String instanceUrl);
//
// public UserOperations userOperations();
//
// public UserOperations userOperations(String gatewayUrl);
//
// public LimitsOperations limitsOperations();
//
// public LimitsOperations limitsOperations(String instanceUrl);
//
// public <T> List<T> readList(JsonNode jsonNode, Class<T> type);
//
// public <T> T readObject(JsonNode jsonNode, Class<T> type);
//
// public String getBaseUrl();
//
// public String getInstanceUrl();
//
// public void setInstanceUrl(String instanceUrl);
//
// public String getUserInfoUrl();
//
// public String getAuthGatewayUrl();
//
// public void setAuthGatewayBaseUrl(String gatewayUrl);
//
// public ConnectOperations connectOperations();
//
// public ConnectOperations connectOperations(String instanceUrl);
//
// public CustomApiOperations customApiOperations();
//
// public CustomApiOperations customApiOperations(String instanceUrl);
// }
// Path: src/main/java/org/springframework/social/salesforce/api/impl/RecentTemplate.java
import com.fasterxml.jackson.databind.JsonNode;
import org.springframework.social.salesforce.api.RecentOperations;
import org.springframework.social.salesforce.api.ResultItem;
import org.springframework.social.salesforce.api.Salesforce;
import org.springframework.web.client.RestTemplate;
import java.util.List;
/**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.impl;
/**
* Default implementation of RecentOperations.
*
* @author Umut Utkan
* @author Jared Ottley
*/
public class RecentTemplate extends AbstractSalesForceOperations<Salesforce> implements RecentOperations {
private RestTemplate restTemplate;
public RecentTemplate(Salesforce api, RestTemplate restTemplate) {
super(api);
this.restTemplate = restTemplate;
}
@Override | public List<ResultItem> recent() { |
jottley/spring-social-salesforce | src/main/java/org/springframework/social/salesforce/api/impl/QueryTemplate.java | // Path: src/main/java/org/springframework/social/salesforce/api/QueryOperations.java
// public interface QueryOperations {
//
// /**
// * Execute SOQL query and return the first page of results
// *
// * @param query The SOQL query to execute
// * @return QueryResult
// */
// QueryResult query(String query);
//
// /**
// * Execute SOQL query and return the first page of results
// *
// * @param query The SOQL query to execute
// * @param includeDeletedItems if result should include deleted items
// * documentation https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_queryall.htm
// * @return QueryResult
// */
// QueryResult query(String query, boolean includeDeletedItems);
//
// /*
// * Retrieve next page of results based on argument from url (usually from query result "nextRecordsUrl")
// */
// QueryResult nextPage(String urlOrToken);
//
// /**
// * Execute SOQL query and return all results.
// *
// * @param query The SOQL query to execute
// * @return QueryResult
// */
// QueryResult queryAll(String query);
//
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/QueryResult.java
// public class QueryResult {
//
// private int totalSize;
//
// private boolean done;
//
// private String nextRecordsUrl;
//
// private List<ResultItem> records;
//
//
// public QueryResult(int totalSize, boolean done) {
// this.totalSize = totalSize;
// this.done = done;
// }
//
//
// public int getTotalSize() {
// return totalSize;
// }
//
// public boolean isDone() {
// return done;
// }
//
// public List<ResultItem> getRecords() {
// return records;
// }
//
// public void setRecords(List<ResultItem> records) {
// this.records = records;
// }
//
// public String getNextRecordsUrl() {
// return nextRecordsUrl;
// }
//
// public void setNextRecordsUrl(String nextRecordsUrl) {
// this.nextRecordsUrl = nextRecordsUrl;
// }
//
// public String getNextRecordsToken() {
// if (this.nextRecordsUrl != null) {
// return this.nextRecordsUrl.substring(this.nextRecordsUrl.lastIndexOf('/') + 1, this.nextRecordsUrl.length());
// }
// return null;
// }
//
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/Salesforce.java
// public interface Salesforce extends ApiBinding {
//
// public ApiOperations apiOperations();
//
// public ApiOperations apiOperations(String instanceUrl);
//
// public ChatterOperations chatterOperations();
//
// public ChatterOperations chatterOperations(String instanceUrl);
//
// public QueryOperations queryOperations();
//
// public QueryOperations queryOperations(String instanceUrl);
//
// public RecentOperations recentOperations();
//
// public RecentOperations recentOperations(String instanceUrl);
//
// public SearchOperations searchOperations();
//
// public SearchOperations searchOperations(String instanceUrl);
//
// public SObjectOperations sObjectsOperations();
//
// public SObjectOperations sObjectsOperations(String instanceUrl);
//
// public UserOperations userOperations();
//
// public UserOperations userOperations(String gatewayUrl);
//
// public LimitsOperations limitsOperations();
//
// public LimitsOperations limitsOperations(String instanceUrl);
//
// public <T> List<T> readList(JsonNode jsonNode, Class<T> type);
//
// public <T> T readObject(JsonNode jsonNode, Class<T> type);
//
// public String getBaseUrl();
//
// public String getInstanceUrl();
//
// public void setInstanceUrl(String instanceUrl);
//
// public String getUserInfoUrl();
//
// public String getAuthGatewayUrl();
//
// public void setAuthGatewayBaseUrl(String gatewayUrl);
//
// public ConnectOperations connectOperations();
//
// public ConnectOperations connectOperations(String instanceUrl);
//
// public CustomApiOperations customApiOperations();
//
// public CustomApiOperations customApiOperations(String instanceUrl);
// }
| import java.net.URI;
import org.apache.commons.lang3.StringUtils;
import org.springframework.social.salesforce.api.QueryOperations;
import org.springframework.social.salesforce.api.QueryResult;
import org.springframework.social.salesforce.api.Salesforce;
import org.springframework.social.support.URIBuilder;
import org.springframework.web.client.RestTemplate; | /**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.impl;
/**
* Default implementation of QueryOperations.
*
* @author Umut Utkan
* @author Jared Ottley
*/
public class QueryTemplate extends AbstractSalesForceOperations<Salesforce> implements QueryOperations {
private RestTemplate restTemplate;
public QueryTemplate(Salesforce api, RestTemplate restTemplate) {
super(api);
this.restTemplate = restTemplate;
}
@Override | // Path: src/main/java/org/springframework/social/salesforce/api/QueryOperations.java
// public interface QueryOperations {
//
// /**
// * Execute SOQL query and return the first page of results
// *
// * @param query The SOQL query to execute
// * @return QueryResult
// */
// QueryResult query(String query);
//
// /**
// * Execute SOQL query and return the first page of results
// *
// * @param query The SOQL query to execute
// * @param includeDeletedItems if result should include deleted items
// * documentation https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_queryall.htm
// * @return QueryResult
// */
// QueryResult query(String query, boolean includeDeletedItems);
//
// /*
// * Retrieve next page of results based on argument from url (usually from query result "nextRecordsUrl")
// */
// QueryResult nextPage(String urlOrToken);
//
// /**
// * Execute SOQL query and return all results.
// *
// * @param query The SOQL query to execute
// * @return QueryResult
// */
// QueryResult queryAll(String query);
//
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/QueryResult.java
// public class QueryResult {
//
// private int totalSize;
//
// private boolean done;
//
// private String nextRecordsUrl;
//
// private List<ResultItem> records;
//
//
// public QueryResult(int totalSize, boolean done) {
// this.totalSize = totalSize;
// this.done = done;
// }
//
//
// public int getTotalSize() {
// return totalSize;
// }
//
// public boolean isDone() {
// return done;
// }
//
// public List<ResultItem> getRecords() {
// return records;
// }
//
// public void setRecords(List<ResultItem> records) {
// this.records = records;
// }
//
// public String getNextRecordsUrl() {
// return nextRecordsUrl;
// }
//
// public void setNextRecordsUrl(String nextRecordsUrl) {
// this.nextRecordsUrl = nextRecordsUrl;
// }
//
// public String getNextRecordsToken() {
// if (this.nextRecordsUrl != null) {
// return this.nextRecordsUrl.substring(this.nextRecordsUrl.lastIndexOf('/') + 1, this.nextRecordsUrl.length());
// }
// return null;
// }
//
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/Salesforce.java
// public interface Salesforce extends ApiBinding {
//
// public ApiOperations apiOperations();
//
// public ApiOperations apiOperations(String instanceUrl);
//
// public ChatterOperations chatterOperations();
//
// public ChatterOperations chatterOperations(String instanceUrl);
//
// public QueryOperations queryOperations();
//
// public QueryOperations queryOperations(String instanceUrl);
//
// public RecentOperations recentOperations();
//
// public RecentOperations recentOperations(String instanceUrl);
//
// public SearchOperations searchOperations();
//
// public SearchOperations searchOperations(String instanceUrl);
//
// public SObjectOperations sObjectsOperations();
//
// public SObjectOperations sObjectsOperations(String instanceUrl);
//
// public UserOperations userOperations();
//
// public UserOperations userOperations(String gatewayUrl);
//
// public LimitsOperations limitsOperations();
//
// public LimitsOperations limitsOperations(String instanceUrl);
//
// public <T> List<T> readList(JsonNode jsonNode, Class<T> type);
//
// public <T> T readObject(JsonNode jsonNode, Class<T> type);
//
// public String getBaseUrl();
//
// public String getInstanceUrl();
//
// public void setInstanceUrl(String instanceUrl);
//
// public String getUserInfoUrl();
//
// public String getAuthGatewayUrl();
//
// public void setAuthGatewayBaseUrl(String gatewayUrl);
//
// public ConnectOperations connectOperations();
//
// public ConnectOperations connectOperations(String instanceUrl);
//
// public CustomApiOperations customApiOperations();
//
// public CustomApiOperations customApiOperations(String instanceUrl);
// }
// Path: src/main/java/org/springframework/social/salesforce/api/impl/QueryTemplate.java
import java.net.URI;
import org.apache.commons.lang3.StringUtils;
import org.springframework.social.salesforce.api.QueryOperations;
import org.springframework.social.salesforce.api.QueryResult;
import org.springframework.social.salesforce.api.Salesforce;
import org.springframework.social.support.URIBuilder;
import org.springframework.web.client.RestTemplate;
/**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.impl;
/**
* Default implementation of QueryOperations.
*
* @author Umut Utkan
* @author Jared Ottley
*/
public class QueryTemplate extends AbstractSalesForceOperations<Salesforce> implements QueryOperations {
private RestTemplate restTemplate;
public QueryTemplate(Salesforce api, RestTemplate restTemplate) {
super(api);
this.restTemplate = restTemplate;
}
@Override | public QueryResult query(String query) { |
jottley/spring-social-salesforce | src/main/java/org/springframework/social/salesforce/client/SimpleCachingSalesforceFactory.java | // Path: src/main/java/org/springframework/social/salesforce/api/Salesforce.java
// public interface Salesforce extends ApiBinding {
//
// public ApiOperations apiOperations();
//
// public ApiOperations apiOperations(String instanceUrl);
//
// public ChatterOperations chatterOperations();
//
// public ChatterOperations chatterOperations(String instanceUrl);
//
// public QueryOperations queryOperations();
//
// public QueryOperations queryOperations(String instanceUrl);
//
// public RecentOperations recentOperations();
//
// public RecentOperations recentOperations(String instanceUrl);
//
// public SearchOperations searchOperations();
//
// public SearchOperations searchOperations(String instanceUrl);
//
// public SObjectOperations sObjectsOperations();
//
// public SObjectOperations sObjectsOperations(String instanceUrl);
//
// public UserOperations userOperations();
//
// public UserOperations userOperations(String gatewayUrl);
//
// public LimitsOperations limitsOperations();
//
// public LimitsOperations limitsOperations(String instanceUrl);
//
// public <T> List<T> readList(JsonNode jsonNode, Class<T> type);
//
// public <T> T readObject(JsonNode jsonNode, Class<T> type);
//
// public String getBaseUrl();
//
// public String getInstanceUrl();
//
// public void setInstanceUrl(String instanceUrl);
//
// public String getUserInfoUrl();
//
// public String getAuthGatewayUrl();
//
// public void setAuthGatewayBaseUrl(String gatewayUrl);
//
// public ConnectOperations connectOperations();
//
// public ConnectOperations connectOperations(String instanceUrl);
//
// public CustomApiOperations customApiOperations();
//
// public CustomApiOperations customApiOperations(String instanceUrl);
// }
| import org.springframework.social.salesforce.api.Salesforce;
import java.util.HashMap;
import java.util.Map; | /**
* Copyright (C) 2016 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.client;
/**
* Simple caching wrapper for SalesforceFactory.
*
* @author Umut Utkan
*/
public class SimpleCachingSalesforceFactory implements SalesforceFactory {
private SalesforceFactory delegate;
| // Path: src/main/java/org/springframework/social/salesforce/api/Salesforce.java
// public interface Salesforce extends ApiBinding {
//
// public ApiOperations apiOperations();
//
// public ApiOperations apiOperations(String instanceUrl);
//
// public ChatterOperations chatterOperations();
//
// public ChatterOperations chatterOperations(String instanceUrl);
//
// public QueryOperations queryOperations();
//
// public QueryOperations queryOperations(String instanceUrl);
//
// public RecentOperations recentOperations();
//
// public RecentOperations recentOperations(String instanceUrl);
//
// public SearchOperations searchOperations();
//
// public SearchOperations searchOperations(String instanceUrl);
//
// public SObjectOperations sObjectsOperations();
//
// public SObjectOperations sObjectsOperations(String instanceUrl);
//
// public UserOperations userOperations();
//
// public UserOperations userOperations(String gatewayUrl);
//
// public LimitsOperations limitsOperations();
//
// public LimitsOperations limitsOperations(String instanceUrl);
//
// public <T> List<T> readList(JsonNode jsonNode, Class<T> type);
//
// public <T> T readObject(JsonNode jsonNode, Class<T> type);
//
// public String getBaseUrl();
//
// public String getInstanceUrl();
//
// public void setInstanceUrl(String instanceUrl);
//
// public String getUserInfoUrl();
//
// public String getAuthGatewayUrl();
//
// public void setAuthGatewayBaseUrl(String gatewayUrl);
//
// public ConnectOperations connectOperations();
//
// public ConnectOperations connectOperations(String instanceUrl);
//
// public CustomApiOperations customApiOperations();
//
// public CustomApiOperations customApiOperations(String instanceUrl);
// }
// Path: src/main/java/org/springframework/social/salesforce/client/SimpleCachingSalesforceFactory.java
import org.springframework.social.salesforce.api.Salesforce;
import java.util.HashMap;
import java.util.Map;
/**
* Copyright (C) 2016 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.client;
/**
* Simple caching wrapper for SalesforceFactory.
*
* @author Umut Utkan
*/
public class SimpleCachingSalesforceFactory implements SalesforceFactory {
private SalesforceFactory delegate;
| private final Map<String, Salesforce> cache = new HashMap<String, Salesforce>(); |
jottley/spring-social-salesforce | src/test/java/org/springframework/social/salesforce/api/impl/QueryTemplateTest.java | // Path: src/main/java/org/springframework/social/salesforce/api/QueryResult.java
// public class QueryResult {
//
// private int totalSize;
//
// private boolean done;
//
// private String nextRecordsUrl;
//
// private List<ResultItem> records;
//
//
// public QueryResult(int totalSize, boolean done) {
// this.totalSize = totalSize;
// this.done = done;
// }
//
//
// public int getTotalSize() {
// return totalSize;
// }
//
// public boolean isDone() {
// return done;
// }
//
// public List<ResultItem> getRecords() {
// return records;
// }
//
// public void setRecords(List<ResultItem> records) {
// this.records = records;
// }
//
// public String getNextRecordsUrl() {
// return nextRecordsUrl;
// }
//
// public void setNextRecordsUrl(String nextRecordsUrl) {
// this.nextRecordsUrl = nextRecordsUrl;
// }
//
// public String getNextRecordsToken() {
// if (this.nextRecordsUrl != null) {
// return this.nextRecordsUrl.substring(this.nextRecordsUrl.lastIndexOf('/') + 1, this.nextRecordsUrl.length());
// }
// return null;
// }
//
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/ResultItem.java
// public class ResultItem implements Serializable {
//
// private String type;
//
// private String url;
//
// private Map attributes;
//
//
// public ResultItem(String type, String url) {
// this.type = type;
// this.url = url;
// this.attributes = new HashMap();
// }
//
//
// public String getType() {
// return this.type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public String getUrl() {
// return this.url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public Map getAttributes() {
// return attributes;
// }
//
// public void setAttributes(Map attributes) {
// this.attributes = attributes;
// }
//
// }
| import org.junit.Test;
import org.springframework.http.HttpStatus;
import org.springframework.social.salesforce.api.QueryResult;
import org.springframework.social.salesforce.api.ResultItem;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.springframework.http.HttpMethod.GET;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus; | /**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.impl;
/**
* @author Umut Utkan
* @author Jared Ottley
*/
public class QueryTemplateTest extends AbstractSalesforceTest {
@Test
public void simpleQuery() {
mockServer.expect(requestTo("https://na7.salesforce.com/services/data/" + salesforce.apiOperations().getVersion() + "/query?q=SELECT+Id%2C+Name%2C+BillingCity+FROM+Account"))
.andExpect(method(GET))
.andRespond(withStatus(HttpStatus.OK).body(loadResource("query-simple.json")).headers(responseHeaders)); | // Path: src/main/java/org/springframework/social/salesforce/api/QueryResult.java
// public class QueryResult {
//
// private int totalSize;
//
// private boolean done;
//
// private String nextRecordsUrl;
//
// private List<ResultItem> records;
//
//
// public QueryResult(int totalSize, boolean done) {
// this.totalSize = totalSize;
// this.done = done;
// }
//
//
// public int getTotalSize() {
// return totalSize;
// }
//
// public boolean isDone() {
// return done;
// }
//
// public List<ResultItem> getRecords() {
// return records;
// }
//
// public void setRecords(List<ResultItem> records) {
// this.records = records;
// }
//
// public String getNextRecordsUrl() {
// return nextRecordsUrl;
// }
//
// public void setNextRecordsUrl(String nextRecordsUrl) {
// this.nextRecordsUrl = nextRecordsUrl;
// }
//
// public String getNextRecordsToken() {
// if (this.nextRecordsUrl != null) {
// return this.nextRecordsUrl.substring(this.nextRecordsUrl.lastIndexOf('/') + 1, this.nextRecordsUrl.length());
// }
// return null;
// }
//
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/ResultItem.java
// public class ResultItem implements Serializable {
//
// private String type;
//
// private String url;
//
// private Map attributes;
//
//
// public ResultItem(String type, String url) {
// this.type = type;
// this.url = url;
// this.attributes = new HashMap();
// }
//
//
// public String getType() {
// return this.type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public String getUrl() {
// return this.url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public Map getAttributes() {
// return attributes;
// }
//
// public void setAttributes(Map attributes) {
// this.attributes = attributes;
// }
//
// }
// Path: src/test/java/org/springframework/social/salesforce/api/impl/QueryTemplateTest.java
import org.junit.Test;
import org.springframework.http.HttpStatus;
import org.springframework.social.salesforce.api.QueryResult;
import org.springframework.social.salesforce.api.ResultItem;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.springframework.http.HttpMethod.GET;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus;
/**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.impl;
/**
* @author Umut Utkan
* @author Jared Ottley
*/
public class QueryTemplateTest extends AbstractSalesforceTest {
@Test
public void simpleQuery() {
mockServer.expect(requestTo("https://na7.salesforce.com/services/data/" + salesforce.apiOperations().getVersion() + "/query?q=SELECT+Id%2C+Name%2C+BillingCity+FROM+Account"))
.andExpect(method(GET))
.andRespond(withStatus(HttpStatus.OK).body(loadResource("query-simple.json")).headers(responseHeaders)); | QueryResult result = salesforce.queryOperations().query("SELECT Id, Name, BillingCity FROM Account"); |
jottley/spring-social-salesforce | src/test/java/org/springframework/social/salesforce/api/impl/QueryTemplateTest.java | // Path: src/main/java/org/springframework/social/salesforce/api/QueryResult.java
// public class QueryResult {
//
// private int totalSize;
//
// private boolean done;
//
// private String nextRecordsUrl;
//
// private List<ResultItem> records;
//
//
// public QueryResult(int totalSize, boolean done) {
// this.totalSize = totalSize;
// this.done = done;
// }
//
//
// public int getTotalSize() {
// return totalSize;
// }
//
// public boolean isDone() {
// return done;
// }
//
// public List<ResultItem> getRecords() {
// return records;
// }
//
// public void setRecords(List<ResultItem> records) {
// this.records = records;
// }
//
// public String getNextRecordsUrl() {
// return nextRecordsUrl;
// }
//
// public void setNextRecordsUrl(String nextRecordsUrl) {
// this.nextRecordsUrl = nextRecordsUrl;
// }
//
// public String getNextRecordsToken() {
// if (this.nextRecordsUrl != null) {
// return this.nextRecordsUrl.substring(this.nextRecordsUrl.lastIndexOf('/') + 1, this.nextRecordsUrl.length());
// }
// return null;
// }
//
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/ResultItem.java
// public class ResultItem implements Serializable {
//
// private String type;
//
// private String url;
//
// private Map attributes;
//
//
// public ResultItem(String type, String url) {
// this.type = type;
// this.url = url;
// this.attributes = new HashMap();
// }
//
//
// public String getType() {
// return this.type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public String getUrl() {
// return this.url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public Map getAttributes() {
// return attributes;
// }
//
// public void setAttributes(Map attributes) {
// this.attributes = attributes;
// }
//
// }
| import org.junit.Test;
import org.springframework.http.HttpStatus;
import org.springframework.social.salesforce.api.QueryResult;
import org.springframework.social.salesforce.api.ResultItem;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.springframework.http.HttpMethod.GET;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus; | /**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.impl;
/**
* @author Umut Utkan
* @author Jared Ottley
*/
public class QueryTemplateTest extends AbstractSalesforceTest {
@Test
public void simpleQuery() {
mockServer.expect(requestTo("https://na7.salesforce.com/services/data/" + salesforce.apiOperations().getVersion() + "/query?q=SELECT+Id%2C+Name%2C+BillingCity+FROM+Account"))
.andExpect(method(GET))
.andRespond(withStatus(HttpStatus.OK).body(loadResource("query-simple.json")).headers(responseHeaders));
QueryResult result = salesforce.queryOperations().query("SELECT Id, Name, BillingCity FROM Account");
assertEquals(12, result.getRecords().size());
assertEquals("/services/data/v37.0/query/01gD0000002HU6KIAW-2000", result.getNextRecordsUrl());
assertEquals("01gD0000002HU6KIAW-2000", result.getNextRecordsToken()); | // Path: src/main/java/org/springframework/social/salesforce/api/QueryResult.java
// public class QueryResult {
//
// private int totalSize;
//
// private boolean done;
//
// private String nextRecordsUrl;
//
// private List<ResultItem> records;
//
//
// public QueryResult(int totalSize, boolean done) {
// this.totalSize = totalSize;
// this.done = done;
// }
//
//
// public int getTotalSize() {
// return totalSize;
// }
//
// public boolean isDone() {
// return done;
// }
//
// public List<ResultItem> getRecords() {
// return records;
// }
//
// public void setRecords(List<ResultItem> records) {
// this.records = records;
// }
//
// public String getNextRecordsUrl() {
// return nextRecordsUrl;
// }
//
// public void setNextRecordsUrl(String nextRecordsUrl) {
// this.nextRecordsUrl = nextRecordsUrl;
// }
//
// public String getNextRecordsToken() {
// if (this.nextRecordsUrl != null) {
// return this.nextRecordsUrl.substring(this.nextRecordsUrl.lastIndexOf('/') + 1, this.nextRecordsUrl.length());
// }
// return null;
// }
//
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/ResultItem.java
// public class ResultItem implements Serializable {
//
// private String type;
//
// private String url;
//
// private Map attributes;
//
//
// public ResultItem(String type, String url) {
// this.type = type;
// this.url = url;
// this.attributes = new HashMap();
// }
//
//
// public String getType() {
// return this.type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public String getUrl() {
// return this.url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public Map getAttributes() {
// return attributes;
// }
//
// public void setAttributes(Map attributes) {
// this.attributes = attributes;
// }
//
// }
// Path: src/test/java/org/springframework/social/salesforce/api/impl/QueryTemplateTest.java
import org.junit.Test;
import org.springframework.http.HttpStatus;
import org.springframework.social.salesforce.api.QueryResult;
import org.springframework.social.salesforce.api.ResultItem;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.springframework.http.HttpMethod.GET;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus;
/**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.impl;
/**
* @author Umut Utkan
* @author Jared Ottley
*/
public class QueryTemplateTest extends AbstractSalesforceTest {
@Test
public void simpleQuery() {
mockServer.expect(requestTo("https://na7.salesforce.com/services/data/" + salesforce.apiOperations().getVersion() + "/query?q=SELECT+Id%2C+Name%2C+BillingCity+FROM+Account"))
.andExpect(method(GET))
.andRespond(withStatus(HttpStatus.OK).body(loadResource("query-simple.json")).headers(responseHeaders));
QueryResult result = salesforce.queryOperations().query("SELECT Id, Name, BillingCity FROM Account");
assertEquals(12, result.getRecords().size());
assertEquals("/services/data/v37.0/query/01gD0000002HU6KIAW-2000", result.getNextRecordsUrl());
assertEquals("01gD0000002HU6KIAW-2000", result.getNextRecordsToken()); | for (ResultItem item : result.getRecords()) { |
jottley/spring-social-salesforce | src/main/java/org/springframework/social/salesforce/api/impl/json/ResultItemDeserializer.java | // Path: src/main/java/org/springframework/social/salesforce/api/QueryResult.java
// public class QueryResult {
//
// private int totalSize;
//
// private boolean done;
//
// private String nextRecordsUrl;
//
// private List<ResultItem> records;
//
//
// public QueryResult(int totalSize, boolean done) {
// this.totalSize = totalSize;
// this.done = done;
// }
//
//
// public int getTotalSize() {
// return totalSize;
// }
//
// public boolean isDone() {
// return done;
// }
//
// public List<ResultItem> getRecords() {
// return records;
// }
//
// public void setRecords(List<ResultItem> records) {
// this.records = records;
// }
//
// public String getNextRecordsUrl() {
// return nextRecordsUrl;
// }
//
// public void setNextRecordsUrl(String nextRecordsUrl) {
// this.nextRecordsUrl = nextRecordsUrl;
// }
//
// public String getNextRecordsToken() {
// if (this.nextRecordsUrl != null) {
// return this.nextRecordsUrl.substring(this.nextRecordsUrl.lastIndexOf('/') + 1, this.nextRecordsUrl.length());
// }
// return null;
// }
//
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/ResultItem.java
// public class ResultItem implements Serializable {
//
// private String type;
//
// private String url;
//
// private Map attributes;
//
//
// public ResultItem(String type, String url) {
// this.type = type;
// this.url = url;
// this.attributes = new HashMap();
// }
//
//
// public String getType() {
// return this.type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public String getUrl() {
// return this.url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public Map getAttributes() {
// return attributes;
// }
//
// public void setAttributes(Map attributes) {
// this.attributes = attributes;
// }
//
// }
| import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.joor.Reflect;
import org.springframework.social.salesforce.api.QueryResult;
import org.springframework.social.salesforce.api.ResultItem;
import java.io.IOException;
import java.util.Map; | /**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.impl.json;
/**
* Deserializer for {@link ResultItem}
*
* @author Umut Utkan
*/
public class ResultItemDeserializer extends JsonDeserializer<ResultItem>
{
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public ResultItem deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException
{
ObjectMapper mapper = new ObjectMapper();
Reflect.on(mapper).set("_deserializationConfig", ctxt.getConfig());
jp.setCodec(mapper);
JsonNode jsonNode = jp.readValueAsTree();
Map<String, Object> map = mapper.convertValue(jsonNode, Map.class);
ResultItem item = new ResultItem((String) ((Map) map.get("attributes")).get("type"),
(String) ((Map) map.get("attributes")).get("url"));
map.remove("attributes");
//item.setAttributes(map);
for(Map.Entry<String, Object> entry : map.entrySet()) {
if(entry.getValue() instanceof Map) {
Map<String, Object> inner = (Map) entry.getValue();
if(inner.get("records") != null) { | // Path: src/main/java/org/springframework/social/salesforce/api/QueryResult.java
// public class QueryResult {
//
// private int totalSize;
//
// private boolean done;
//
// private String nextRecordsUrl;
//
// private List<ResultItem> records;
//
//
// public QueryResult(int totalSize, boolean done) {
// this.totalSize = totalSize;
// this.done = done;
// }
//
//
// public int getTotalSize() {
// return totalSize;
// }
//
// public boolean isDone() {
// return done;
// }
//
// public List<ResultItem> getRecords() {
// return records;
// }
//
// public void setRecords(List<ResultItem> records) {
// this.records = records;
// }
//
// public String getNextRecordsUrl() {
// return nextRecordsUrl;
// }
//
// public void setNextRecordsUrl(String nextRecordsUrl) {
// this.nextRecordsUrl = nextRecordsUrl;
// }
//
// public String getNextRecordsToken() {
// if (this.nextRecordsUrl != null) {
// return this.nextRecordsUrl.substring(this.nextRecordsUrl.lastIndexOf('/') + 1, this.nextRecordsUrl.length());
// }
// return null;
// }
//
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/ResultItem.java
// public class ResultItem implements Serializable {
//
// private String type;
//
// private String url;
//
// private Map attributes;
//
//
// public ResultItem(String type, String url) {
// this.type = type;
// this.url = url;
// this.attributes = new HashMap();
// }
//
//
// public String getType() {
// return this.type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public String getUrl() {
// return this.url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public Map getAttributes() {
// return attributes;
// }
//
// public void setAttributes(Map attributes) {
// this.attributes = attributes;
// }
//
// }
// Path: src/main/java/org/springframework/social/salesforce/api/impl/json/ResultItemDeserializer.java
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.joor.Reflect;
import org.springframework.social.salesforce.api.QueryResult;
import org.springframework.social.salesforce.api.ResultItem;
import java.io.IOException;
import java.util.Map;
/**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.impl.json;
/**
* Deserializer for {@link ResultItem}
*
* @author Umut Utkan
*/
public class ResultItemDeserializer extends JsonDeserializer<ResultItem>
{
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public ResultItem deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException
{
ObjectMapper mapper = new ObjectMapper();
Reflect.on(mapper).set("_deserializationConfig", ctxt.getConfig());
jp.setCodec(mapper);
JsonNode jsonNode = jp.readValueAsTree();
Map<String, Object> map = mapper.convertValue(jsonNode, Map.class);
ResultItem item = new ResultItem((String) ((Map) map.get("attributes")).get("type"),
(String) ((Map) map.get("attributes")).get("url"));
map.remove("attributes");
//item.setAttributes(map);
for(Map.Entry<String, Object> entry : map.entrySet()) {
if(entry.getValue() instanceof Map) {
Map<String, Object> inner = (Map) entry.getValue();
if(inner.get("records") != null) { | item.getAttributes().put(entry.getKey(), mapper.convertValue(jsonNode.get(entry.getKey()), QueryResult.class)); |
jottley/spring-social-salesforce | src/test/java/org/springframework/social/salesforce/api/impl/MetaApiTemplateTest.java | // Path: src/main/java/org/springframework/social/salesforce/api/ApiVersion.java
// public class ApiVersion implements Serializable {
//
// private String label;
//
// private String version;
//
// private String url;
//
//
// public ApiVersion(String version, String label, String url) {
// this.version = version;
// this.label = label;
// this.url = url;
// }
//
//
// public String getLabel() {
// return label;
// }
//
// public String getVersion() {
// return version;
// }
//
// public String getUrl() {
// return url;
// }
//
// @Override
// public String toString() {
// return "ApiVersion{" +
// "label='" + label + '\'' +
// ", version='" + version + '\'' +
// ", url='" + url + '\'' +
// '}';
// }
//
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/InvalidSalesforceApiVersionException.java
// public class InvalidSalesforceApiVersionException
// extends Throwable
// {
// public InvalidSalesforceApiVersionException()
// {
// //NOOP
// }
//
// public InvalidSalesforceApiVersionException(String version)
// {
// super(version + " is not a valid Salesforce Api version.");
// }
// }
| import org.junit.Test;
import org.springframework.http.HttpStatus;
import org.springframework.social.salesforce.api.ApiVersion;
import org.springframework.social.salesforce.api.InvalidSalesforceApiVersionException;
import java.util.List;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.springframework.http.HttpMethod.GET;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus; | /**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.impl;
/**
* @author Umut Utkan
* @author Jared Ottley
*/
public class MetaApiTemplateTest extends AbstractSalesforceTest
{
@Test
public void getApiVersions()
{
mockServer.expect(requestTo("https://na7.salesforce.com/services/data"))
.andExpect(method(GET))
.andRespond(withStatus(HttpStatus.OK).body(loadResource("versions.json")).headers(responseHeaders)); | // Path: src/main/java/org/springframework/social/salesforce/api/ApiVersion.java
// public class ApiVersion implements Serializable {
//
// private String label;
//
// private String version;
//
// private String url;
//
//
// public ApiVersion(String version, String label, String url) {
// this.version = version;
// this.label = label;
// this.url = url;
// }
//
//
// public String getLabel() {
// return label;
// }
//
// public String getVersion() {
// return version;
// }
//
// public String getUrl() {
// return url;
// }
//
// @Override
// public String toString() {
// return "ApiVersion{" +
// "label='" + label + '\'' +
// ", version='" + version + '\'' +
// ", url='" + url + '\'' +
// '}';
// }
//
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/InvalidSalesforceApiVersionException.java
// public class InvalidSalesforceApiVersionException
// extends Throwable
// {
// public InvalidSalesforceApiVersionException()
// {
// //NOOP
// }
//
// public InvalidSalesforceApiVersionException(String version)
// {
// super(version + " is not a valid Salesforce Api version.");
// }
// }
// Path: src/test/java/org/springframework/social/salesforce/api/impl/MetaApiTemplateTest.java
import org.junit.Test;
import org.springframework.http.HttpStatus;
import org.springframework.social.salesforce.api.ApiVersion;
import org.springframework.social.salesforce.api.InvalidSalesforceApiVersionException;
import java.util.List;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.springframework.http.HttpMethod.GET;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus;
/**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.impl;
/**
* @author Umut Utkan
* @author Jared Ottley
*/
public class MetaApiTemplateTest extends AbstractSalesforceTest
{
@Test
public void getApiVersions()
{
mockServer.expect(requestTo("https://na7.salesforce.com/services/data"))
.andExpect(method(GET))
.andRespond(withStatus(HttpStatus.OK).body(loadResource("versions.json")).headers(responseHeaders)); | List<ApiVersion> versions = salesforce.apiOperations().getVersions(); |
jottley/spring-social-salesforce | src/test/java/org/springframework/social/salesforce/api/impl/MetaApiTemplateTest.java | // Path: src/main/java/org/springframework/social/salesforce/api/ApiVersion.java
// public class ApiVersion implements Serializable {
//
// private String label;
//
// private String version;
//
// private String url;
//
//
// public ApiVersion(String version, String label, String url) {
// this.version = version;
// this.label = label;
// this.url = url;
// }
//
//
// public String getLabel() {
// return label;
// }
//
// public String getVersion() {
// return version;
// }
//
// public String getUrl() {
// return url;
// }
//
// @Override
// public String toString() {
// return "ApiVersion{" +
// "label='" + label + '\'' +
// ", version='" + version + '\'' +
// ", url='" + url + '\'' +
// '}';
// }
//
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/InvalidSalesforceApiVersionException.java
// public class InvalidSalesforceApiVersionException
// extends Throwable
// {
// public InvalidSalesforceApiVersionException()
// {
// //NOOP
// }
//
// public InvalidSalesforceApiVersionException(String version)
// {
// super(version + " is not a valid Salesforce Api version.");
// }
// }
| import org.junit.Test;
import org.springframework.http.HttpStatus;
import org.springframework.social.salesforce.api.ApiVersion;
import org.springframework.social.salesforce.api.InvalidSalesforceApiVersionException;
import java.util.List;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.springframework.http.HttpMethod.GET;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus; | }
@Test
public void getServices2()
{
mockServer.expect(requestTo("https://na7.salesforce.com/services/data/v37.0"))
.andExpect(method(GET))
.andRespond(withStatus(HttpStatus.OK).body(loadResource("services2.json")).headers(responseHeaders));
Map<String, String> services = salesforce.apiOperations().getServices();
assertEquals(6, services.size());
assertEquals("/services/data/v37.0/sobjects", services.get("sobjects"));
assertEquals("/services/data/v37.0/chatter", services.get("chatter"));
}
@Test
public void getVersion()
{
String version = salesforce.apiOperations().getVersion();
assertEquals("v37.0", version);
}
@Test
public void setVersion()
{
try
{
salesforce.apiOperations().setVersion("v38.0");
String version = salesforce.apiOperations().getVersion();
assertEquals("v38.0", version);
} | // Path: src/main/java/org/springframework/social/salesforce/api/ApiVersion.java
// public class ApiVersion implements Serializable {
//
// private String label;
//
// private String version;
//
// private String url;
//
//
// public ApiVersion(String version, String label, String url) {
// this.version = version;
// this.label = label;
// this.url = url;
// }
//
//
// public String getLabel() {
// return label;
// }
//
// public String getVersion() {
// return version;
// }
//
// public String getUrl() {
// return url;
// }
//
// @Override
// public String toString() {
// return "ApiVersion{" +
// "label='" + label + '\'' +
// ", version='" + version + '\'' +
// ", url='" + url + '\'' +
// '}';
// }
//
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/InvalidSalesforceApiVersionException.java
// public class InvalidSalesforceApiVersionException
// extends Throwable
// {
// public InvalidSalesforceApiVersionException()
// {
// //NOOP
// }
//
// public InvalidSalesforceApiVersionException(String version)
// {
// super(version + " is not a valid Salesforce Api version.");
// }
// }
// Path: src/test/java/org/springframework/social/salesforce/api/impl/MetaApiTemplateTest.java
import org.junit.Test;
import org.springframework.http.HttpStatus;
import org.springframework.social.salesforce.api.ApiVersion;
import org.springframework.social.salesforce.api.InvalidSalesforceApiVersionException;
import java.util.List;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.springframework.http.HttpMethod.GET;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus;
}
@Test
public void getServices2()
{
mockServer.expect(requestTo("https://na7.salesforce.com/services/data/v37.0"))
.andExpect(method(GET))
.andRespond(withStatus(HttpStatus.OK).body(loadResource("services2.json")).headers(responseHeaders));
Map<String, String> services = salesforce.apiOperations().getServices();
assertEquals(6, services.size());
assertEquals("/services/data/v37.0/sobjects", services.get("sobjects"));
assertEquals("/services/data/v37.0/chatter", services.get("chatter"));
}
@Test
public void getVersion()
{
String version = salesforce.apiOperations().getVersion();
assertEquals("v37.0", version);
}
@Test
public void setVersion()
{
try
{
salesforce.apiOperations().setVersion("v38.0");
String version = salesforce.apiOperations().getVersion();
assertEquals("v38.0", version);
} | catch (InvalidSalesforceApiVersionException e) |
jottley/spring-social-salesforce | src/test/java/org/springframework/social/salesforce/api/impl/SearchTemplateTest.java | // Path: src/main/java/org/springframework/social/salesforce/api/ResultItem.java
// public class ResultItem implements Serializable {
//
// private String type;
//
// private String url;
//
// private Map attributes;
//
//
// public ResultItem(String type, String url) {
// this.type = type;
// this.url = url;
// this.attributes = new HashMap();
// }
//
//
// public String getType() {
// return this.type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public String getUrl() {
// return this.url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public Map getAttributes() {
// return attributes;
// }
//
// public void setAttributes(Map attributes) {
// this.attributes = attributes;
// }
//
// }
| import org.junit.Test;
import org.springframework.http.HttpStatus;
import org.springframework.social.salesforce.api.ResultItem;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.springframework.http.HttpMethod.GET;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus; | /**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.impl;
/**
* @author Umut Utkan
* @author Jared Ottley
*/
public class SearchTemplateTest extends AbstractSalesforceTest {
@Test
public void search() {
mockServer.expect(requestTo("https://na7.salesforce.com/services/data/" + salesforce.apiOperations().getVersion() + "/search?q=FIND+%7Bxxx*%7D+IN+ALL+FIELDS+RETURNING+Contact%2C+Account"))
.andExpect(method(GET))
.andRespond(withStatus(HttpStatus.OK).body(loadResource("search.json")).headers(responseHeaders)); | // Path: src/main/java/org/springframework/social/salesforce/api/ResultItem.java
// public class ResultItem implements Serializable {
//
// private String type;
//
// private String url;
//
// private Map attributes;
//
//
// public ResultItem(String type, String url) {
// this.type = type;
// this.url = url;
// this.attributes = new HashMap();
// }
//
//
// public String getType() {
// return this.type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public String getUrl() {
// return this.url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public Map getAttributes() {
// return attributes;
// }
//
// public void setAttributes(Map attributes) {
// this.attributes = attributes;
// }
//
// }
// Path: src/test/java/org/springframework/social/salesforce/api/impl/SearchTemplateTest.java
import org.junit.Test;
import org.springframework.http.HttpStatus;
import org.springframework.social.salesforce.api.ResultItem;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.springframework.http.HttpMethod.GET;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus;
/**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.impl;
/**
* @author Umut Utkan
* @author Jared Ottley
*/
public class SearchTemplateTest extends AbstractSalesforceTest {
@Test
public void search() {
mockServer.expect(requestTo("https://na7.salesforce.com/services/data/" + salesforce.apiOperations().getVersion() + "/search?q=FIND+%7Bxxx*%7D+IN+ALL+FIELDS+RETURNING+Contact%2C+Account"))
.andExpect(method(GET))
.andRespond(withStatus(HttpStatus.OK).body(loadResource("search.json")).headers(responseHeaders)); | List<ResultItem> results = salesforce.searchOperations().search("FIND {xxx*} IN ALL FIELDS RETURNING Contact, Account"); |
jottley/spring-social-salesforce | src/main/java/org/springframework/social/salesforce/config/xml/SalesforceConfigBeanDefinitionParser.java | // Path: src/main/java/org/springframework/social/salesforce/config/support/SalesforceApiHelper.java
// public class SalesforceApiHelper implements ApiHelper<Salesforce>
// {
// private final UsersConnectionRepository usersConnectionRepository;
//
// private final UserIdSource userIdSource;
//
// private SalesforceApiHelper(UsersConnectionRepository usersConnectionRepository, UserIdSource userIdSource) {
// this.usersConnectionRepository = usersConnectionRepository;
// this.userIdSource = userIdSource;
// }
//
//
// @Override
// public Salesforce getApi()
// {
// Connection<Salesforce> connection = usersConnectionRepository.createConnectionRepository(userIdSource.getUserId()).findPrimaryConnection(Salesforce.class);
// if (logger.isDebugEnabled() && connection == null) {
// logger.debug("No current connection; Returning default TwitterTemplate instance.");
// }
// return connection != null ? connection.getApi() : null;
// }
//
// private final static Log logger = LogFactory.getLog(SalesforceApiHelper.class);
//
// }
//
// Path: src/main/java/org/springframework/social/salesforce/connect/SalesforceConnectionFactory.java
// public class SalesforceConnectionFactory extends OAuth2ConnectionFactory<Salesforce> {
//
// public SalesforceConnectionFactory(String clientId, String clientSecret) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret),
// new SalesforceAdapter());
// }
//
// public SalesforceConnectionFactory(String clientId, String clientSecret, boolean sandbox) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret, sandbox),
// sandbox ? new SalesforceAdapter(sandbox) : new SalesforceAdapter());
// }
//
// public SalesforceConnectionFactory(String clientId, String clientSecret, String instanceUrl) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret),
// new SalesforceAdapter(instanceUrl));
// }
//
// public SalesforceConnectionFactory(String clientId, String clientSecret, String instanceUrl, boolean sandbox) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret, sandbox),
// sandbox ? new SalesforceAdapter(instanceUrl, sandbox) : new SalesforceAdapter(instanceUrl));
// }
//
// @Deprecated
// public SalesforceConnectionFactory(String clientId, String clientSecret, String authorizeUrl, String tokenUrl) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret,
// authorizeUrl, tokenUrl), new SalesforceAdapter());
// }
//
// @Deprecated
// public SalesforceConnectionFactory(String clientId, String clientSecret, String authorizeUrl, String tokenUrl, String instanceUrl) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret,
// authorizeUrl, tokenUrl), new SalesforceAdapter(instanceUrl));
// }
//
// @Deprecated
// public SalesforceConnectionFactory(String clientId, String clientSecret, String authorizeUrl, String tokenUrl, String instanceUrl, String gatewayUrl) {
// super("salesforce", new SalesforceServiceProvider(clientId, clientSecret,
// authorizeUrl, tokenUrl), new SalesforceAdapter(instanceUrl, gatewayUrl));
// }
//
// }
//
// Path: src/main/java/org/springframework/social/salesforce/security/SalesforceAuthenticationService.java
// public class SalesforceAuthenticationService extends OAuth2AuthenticationService<Salesforce>
// {
// public SalesforceAuthenticationService(String consumerKey, String consumerSecret)
// {
// super(new SalesforceConnectionFactory(consumerKey, consumerSecret));
// }
//
// public SalesforceAuthenticationService(String consumerKey, String consumerSecret, boolean sandbox)
// {
// super(new SalesforceConnectionFactory(consumerKey, consumerSecret, sandbox));
// }
// }
| import org.springframework.social.config.xml.AbstractProviderConfigBeanDefinitionParser;
import org.springframework.social.salesforce.config.support.SalesforceApiHelper;
import org.springframework.social.salesforce.connect.SalesforceConnectionFactory;
import org.springframework.social.salesforce.security.SalesforceAuthenticationService;
import org.springframework.social.security.provider.SocialAuthenticationService; | /**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.config.xml;
/**
*
* @author Jared Ottley
*
*/
public class SalesforceConfigBeanDefinitionParser extends AbstractProviderConfigBeanDefinitionParser
{
public SalesforceConfigBeanDefinitionParser() { | // Path: src/main/java/org/springframework/social/salesforce/config/support/SalesforceApiHelper.java
// public class SalesforceApiHelper implements ApiHelper<Salesforce>
// {
// private final UsersConnectionRepository usersConnectionRepository;
//
// private final UserIdSource userIdSource;
//
// private SalesforceApiHelper(UsersConnectionRepository usersConnectionRepository, UserIdSource userIdSource) {
// this.usersConnectionRepository = usersConnectionRepository;
// this.userIdSource = userIdSource;
// }
//
//
// @Override
// public Salesforce getApi()
// {
// Connection<Salesforce> connection = usersConnectionRepository.createConnectionRepository(userIdSource.getUserId()).findPrimaryConnection(Salesforce.class);
// if (logger.isDebugEnabled() && connection == null) {
// logger.debug("No current connection; Returning default TwitterTemplate instance.");
// }
// return connection != null ? connection.getApi() : null;
// }
//
// private final static Log logger = LogFactory.getLog(SalesforceApiHelper.class);
//
// }
//
// Path: src/main/java/org/springframework/social/salesforce/connect/SalesforceConnectionFactory.java
// public class SalesforceConnectionFactory extends OAuth2ConnectionFactory<Salesforce> {
//
// public SalesforceConnectionFactory(String clientId, String clientSecret) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret),
// new SalesforceAdapter());
// }
//
// public SalesforceConnectionFactory(String clientId, String clientSecret, boolean sandbox) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret, sandbox),
// sandbox ? new SalesforceAdapter(sandbox) : new SalesforceAdapter());
// }
//
// public SalesforceConnectionFactory(String clientId, String clientSecret, String instanceUrl) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret),
// new SalesforceAdapter(instanceUrl));
// }
//
// public SalesforceConnectionFactory(String clientId, String clientSecret, String instanceUrl, boolean sandbox) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret, sandbox),
// sandbox ? new SalesforceAdapter(instanceUrl, sandbox) : new SalesforceAdapter(instanceUrl));
// }
//
// @Deprecated
// public SalesforceConnectionFactory(String clientId, String clientSecret, String authorizeUrl, String tokenUrl) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret,
// authorizeUrl, tokenUrl), new SalesforceAdapter());
// }
//
// @Deprecated
// public SalesforceConnectionFactory(String clientId, String clientSecret, String authorizeUrl, String tokenUrl, String instanceUrl) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret,
// authorizeUrl, tokenUrl), new SalesforceAdapter(instanceUrl));
// }
//
// @Deprecated
// public SalesforceConnectionFactory(String clientId, String clientSecret, String authorizeUrl, String tokenUrl, String instanceUrl, String gatewayUrl) {
// super("salesforce", new SalesforceServiceProvider(clientId, clientSecret,
// authorizeUrl, tokenUrl), new SalesforceAdapter(instanceUrl, gatewayUrl));
// }
//
// }
//
// Path: src/main/java/org/springframework/social/salesforce/security/SalesforceAuthenticationService.java
// public class SalesforceAuthenticationService extends OAuth2AuthenticationService<Salesforce>
// {
// public SalesforceAuthenticationService(String consumerKey, String consumerSecret)
// {
// super(new SalesforceConnectionFactory(consumerKey, consumerSecret));
// }
//
// public SalesforceAuthenticationService(String consumerKey, String consumerSecret, boolean sandbox)
// {
// super(new SalesforceConnectionFactory(consumerKey, consumerSecret, sandbox));
// }
// }
// Path: src/main/java/org/springframework/social/salesforce/config/xml/SalesforceConfigBeanDefinitionParser.java
import org.springframework.social.config.xml.AbstractProviderConfigBeanDefinitionParser;
import org.springframework.social.salesforce.config.support.SalesforceApiHelper;
import org.springframework.social.salesforce.connect.SalesforceConnectionFactory;
import org.springframework.social.salesforce.security.SalesforceAuthenticationService;
import org.springframework.social.security.provider.SocialAuthenticationService;
/**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.config.xml;
/**
*
* @author Jared Ottley
*
*/
public class SalesforceConfigBeanDefinitionParser extends AbstractProviderConfigBeanDefinitionParser
{
public SalesforceConfigBeanDefinitionParser() { | super(SalesforceConnectionFactory.class, SalesforceApiHelper.class); |
jottley/spring-social-salesforce | src/main/java/org/springframework/social/salesforce/config/xml/SalesforceConfigBeanDefinitionParser.java | // Path: src/main/java/org/springframework/social/salesforce/config/support/SalesforceApiHelper.java
// public class SalesforceApiHelper implements ApiHelper<Salesforce>
// {
// private final UsersConnectionRepository usersConnectionRepository;
//
// private final UserIdSource userIdSource;
//
// private SalesforceApiHelper(UsersConnectionRepository usersConnectionRepository, UserIdSource userIdSource) {
// this.usersConnectionRepository = usersConnectionRepository;
// this.userIdSource = userIdSource;
// }
//
//
// @Override
// public Salesforce getApi()
// {
// Connection<Salesforce> connection = usersConnectionRepository.createConnectionRepository(userIdSource.getUserId()).findPrimaryConnection(Salesforce.class);
// if (logger.isDebugEnabled() && connection == null) {
// logger.debug("No current connection; Returning default TwitterTemplate instance.");
// }
// return connection != null ? connection.getApi() : null;
// }
//
// private final static Log logger = LogFactory.getLog(SalesforceApiHelper.class);
//
// }
//
// Path: src/main/java/org/springframework/social/salesforce/connect/SalesforceConnectionFactory.java
// public class SalesforceConnectionFactory extends OAuth2ConnectionFactory<Salesforce> {
//
// public SalesforceConnectionFactory(String clientId, String clientSecret) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret),
// new SalesforceAdapter());
// }
//
// public SalesforceConnectionFactory(String clientId, String clientSecret, boolean sandbox) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret, sandbox),
// sandbox ? new SalesforceAdapter(sandbox) : new SalesforceAdapter());
// }
//
// public SalesforceConnectionFactory(String clientId, String clientSecret, String instanceUrl) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret),
// new SalesforceAdapter(instanceUrl));
// }
//
// public SalesforceConnectionFactory(String clientId, String clientSecret, String instanceUrl, boolean sandbox) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret, sandbox),
// sandbox ? new SalesforceAdapter(instanceUrl, sandbox) : new SalesforceAdapter(instanceUrl));
// }
//
// @Deprecated
// public SalesforceConnectionFactory(String clientId, String clientSecret, String authorizeUrl, String tokenUrl) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret,
// authorizeUrl, tokenUrl), new SalesforceAdapter());
// }
//
// @Deprecated
// public SalesforceConnectionFactory(String clientId, String clientSecret, String authorizeUrl, String tokenUrl, String instanceUrl) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret,
// authorizeUrl, tokenUrl), new SalesforceAdapter(instanceUrl));
// }
//
// @Deprecated
// public SalesforceConnectionFactory(String clientId, String clientSecret, String authorizeUrl, String tokenUrl, String instanceUrl, String gatewayUrl) {
// super("salesforce", new SalesforceServiceProvider(clientId, clientSecret,
// authorizeUrl, tokenUrl), new SalesforceAdapter(instanceUrl, gatewayUrl));
// }
//
// }
//
// Path: src/main/java/org/springframework/social/salesforce/security/SalesforceAuthenticationService.java
// public class SalesforceAuthenticationService extends OAuth2AuthenticationService<Salesforce>
// {
// public SalesforceAuthenticationService(String consumerKey, String consumerSecret)
// {
// super(new SalesforceConnectionFactory(consumerKey, consumerSecret));
// }
//
// public SalesforceAuthenticationService(String consumerKey, String consumerSecret, boolean sandbox)
// {
// super(new SalesforceConnectionFactory(consumerKey, consumerSecret, sandbox));
// }
// }
| import org.springframework.social.config.xml.AbstractProviderConfigBeanDefinitionParser;
import org.springframework.social.salesforce.config.support.SalesforceApiHelper;
import org.springframework.social.salesforce.connect.SalesforceConnectionFactory;
import org.springframework.social.salesforce.security.SalesforceAuthenticationService;
import org.springframework.social.security.provider.SocialAuthenticationService; | /**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.config.xml;
/**
*
* @author Jared Ottley
*
*/
public class SalesforceConfigBeanDefinitionParser extends AbstractProviderConfigBeanDefinitionParser
{
public SalesforceConfigBeanDefinitionParser() { | // Path: src/main/java/org/springframework/social/salesforce/config/support/SalesforceApiHelper.java
// public class SalesforceApiHelper implements ApiHelper<Salesforce>
// {
// private final UsersConnectionRepository usersConnectionRepository;
//
// private final UserIdSource userIdSource;
//
// private SalesforceApiHelper(UsersConnectionRepository usersConnectionRepository, UserIdSource userIdSource) {
// this.usersConnectionRepository = usersConnectionRepository;
// this.userIdSource = userIdSource;
// }
//
//
// @Override
// public Salesforce getApi()
// {
// Connection<Salesforce> connection = usersConnectionRepository.createConnectionRepository(userIdSource.getUserId()).findPrimaryConnection(Salesforce.class);
// if (logger.isDebugEnabled() && connection == null) {
// logger.debug("No current connection; Returning default TwitterTemplate instance.");
// }
// return connection != null ? connection.getApi() : null;
// }
//
// private final static Log logger = LogFactory.getLog(SalesforceApiHelper.class);
//
// }
//
// Path: src/main/java/org/springframework/social/salesforce/connect/SalesforceConnectionFactory.java
// public class SalesforceConnectionFactory extends OAuth2ConnectionFactory<Salesforce> {
//
// public SalesforceConnectionFactory(String clientId, String clientSecret) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret),
// new SalesforceAdapter());
// }
//
// public SalesforceConnectionFactory(String clientId, String clientSecret, boolean sandbox) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret, sandbox),
// sandbox ? new SalesforceAdapter(sandbox) : new SalesforceAdapter());
// }
//
// public SalesforceConnectionFactory(String clientId, String clientSecret, String instanceUrl) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret),
// new SalesforceAdapter(instanceUrl));
// }
//
// public SalesforceConnectionFactory(String clientId, String clientSecret, String instanceUrl, boolean sandbox) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret, sandbox),
// sandbox ? new SalesforceAdapter(instanceUrl, sandbox) : new SalesforceAdapter(instanceUrl));
// }
//
// @Deprecated
// public SalesforceConnectionFactory(String clientId, String clientSecret, String authorizeUrl, String tokenUrl) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret,
// authorizeUrl, tokenUrl), new SalesforceAdapter());
// }
//
// @Deprecated
// public SalesforceConnectionFactory(String clientId, String clientSecret, String authorizeUrl, String tokenUrl, String instanceUrl) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret,
// authorizeUrl, tokenUrl), new SalesforceAdapter(instanceUrl));
// }
//
// @Deprecated
// public SalesforceConnectionFactory(String clientId, String clientSecret, String authorizeUrl, String tokenUrl, String instanceUrl, String gatewayUrl) {
// super("salesforce", new SalesforceServiceProvider(clientId, clientSecret,
// authorizeUrl, tokenUrl), new SalesforceAdapter(instanceUrl, gatewayUrl));
// }
//
// }
//
// Path: src/main/java/org/springframework/social/salesforce/security/SalesforceAuthenticationService.java
// public class SalesforceAuthenticationService extends OAuth2AuthenticationService<Salesforce>
// {
// public SalesforceAuthenticationService(String consumerKey, String consumerSecret)
// {
// super(new SalesforceConnectionFactory(consumerKey, consumerSecret));
// }
//
// public SalesforceAuthenticationService(String consumerKey, String consumerSecret, boolean sandbox)
// {
// super(new SalesforceConnectionFactory(consumerKey, consumerSecret, sandbox));
// }
// }
// Path: src/main/java/org/springframework/social/salesforce/config/xml/SalesforceConfigBeanDefinitionParser.java
import org.springframework.social.config.xml.AbstractProviderConfigBeanDefinitionParser;
import org.springframework.social.salesforce.config.support.SalesforceApiHelper;
import org.springframework.social.salesforce.connect.SalesforceConnectionFactory;
import org.springframework.social.salesforce.security.SalesforceAuthenticationService;
import org.springframework.social.security.provider.SocialAuthenticationService;
/**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.config.xml;
/**
*
* @author Jared Ottley
*
*/
public class SalesforceConfigBeanDefinitionParser extends AbstractProviderConfigBeanDefinitionParser
{
public SalesforceConfigBeanDefinitionParser() { | super(SalesforceConnectionFactory.class, SalesforceApiHelper.class); |
jottley/spring-social-salesforce | src/main/java/org/springframework/social/salesforce/config/xml/SalesforceConfigBeanDefinitionParser.java | // Path: src/main/java/org/springframework/social/salesforce/config/support/SalesforceApiHelper.java
// public class SalesforceApiHelper implements ApiHelper<Salesforce>
// {
// private final UsersConnectionRepository usersConnectionRepository;
//
// private final UserIdSource userIdSource;
//
// private SalesforceApiHelper(UsersConnectionRepository usersConnectionRepository, UserIdSource userIdSource) {
// this.usersConnectionRepository = usersConnectionRepository;
// this.userIdSource = userIdSource;
// }
//
//
// @Override
// public Salesforce getApi()
// {
// Connection<Salesforce> connection = usersConnectionRepository.createConnectionRepository(userIdSource.getUserId()).findPrimaryConnection(Salesforce.class);
// if (logger.isDebugEnabled() && connection == null) {
// logger.debug("No current connection; Returning default TwitterTemplate instance.");
// }
// return connection != null ? connection.getApi() : null;
// }
//
// private final static Log logger = LogFactory.getLog(SalesforceApiHelper.class);
//
// }
//
// Path: src/main/java/org/springframework/social/salesforce/connect/SalesforceConnectionFactory.java
// public class SalesforceConnectionFactory extends OAuth2ConnectionFactory<Salesforce> {
//
// public SalesforceConnectionFactory(String clientId, String clientSecret) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret),
// new SalesforceAdapter());
// }
//
// public SalesforceConnectionFactory(String clientId, String clientSecret, boolean sandbox) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret, sandbox),
// sandbox ? new SalesforceAdapter(sandbox) : new SalesforceAdapter());
// }
//
// public SalesforceConnectionFactory(String clientId, String clientSecret, String instanceUrl) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret),
// new SalesforceAdapter(instanceUrl));
// }
//
// public SalesforceConnectionFactory(String clientId, String clientSecret, String instanceUrl, boolean sandbox) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret, sandbox),
// sandbox ? new SalesforceAdapter(instanceUrl, sandbox) : new SalesforceAdapter(instanceUrl));
// }
//
// @Deprecated
// public SalesforceConnectionFactory(String clientId, String clientSecret, String authorizeUrl, String tokenUrl) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret,
// authorizeUrl, tokenUrl), new SalesforceAdapter());
// }
//
// @Deprecated
// public SalesforceConnectionFactory(String clientId, String clientSecret, String authorizeUrl, String tokenUrl, String instanceUrl) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret,
// authorizeUrl, tokenUrl), new SalesforceAdapter(instanceUrl));
// }
//
// @Deprecated
// public SalesforceConnectionFactory(String clientId, String clientSecret, String authorizeUrl, String tokenUrl, String instanceUrl, String gatewayUrl) {
// super("salesforce", new SalesforceServiceProvider(clientId, clientSecret,
// authorizeUrl, tokenUrl), new SalesforceAdapter(instanceUrl, gatewayUrl));
// }
//
// }
//
// Path: src/main/java/org/springframework/social/salesforce/security/SalesforceAuthenticationService.java
// public class SalesforceAuthenticationService extends OAuth2AuthenticationService<Salesforce>
// {
// public SalesforceAuthenticationService(String consumerKey, String consumerSecret)
// {
// super(new SalesforceConnectionFactory(consumerKey, consumerSecret));
// }
//
// public SalesforceAuthenticationService(String consumerKey, String consumerSecret, boolean sandbox)
// {
// super(new SalesforceConnectionFactory(consumerKey, consumerSecret, sandbox));
// }
// }
| import org.springframework.social.config.xml.AbstractProviderConfigBeanDefinitionParser;
import org.springframework.social.salesforce.config.support.SalesforceApiHelper;
import org.springframework.social.salesforce.connect.SalesforceConnectionFactory;
import org.springframework.social.salesforce.security.SalesforceAuthenticationService;
import org.springframework.social.security.provider.SocialAuthenticationService; | /**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.config.xml;
/**
*
* @author Jared Ottley
*
*/
public class SalesforceConfigBeanDefinitionParser extends AbstractProviderConfigBeanDefinitionParser
{
public SalesforceConfigBeanDefinitionParser() {
super(SalesforceConnectionFactory.class, SalesforceApiHelper.class);
}
@Override
protected Class<? extends SocialAuthenticationService<?>> getAuthenticationServiceClass() { | // Path: src/main/java/org/springframework/social/salesforce/config/support/SalesforceApiHelper.java
// public class SalesforceApiHelper implements ApiHelper<Salesforce>
// {
// private final UsersConnectionRepository usersConnectionRepository;
//
// private final UserIdSource userIdSource;
//
// private SalesforceApiHelper(UsersConnectionRepository usersConnectionRepository, UserIdSource userIdSource) {
// this.usersConnectionRepository = usersConnectionRepository;
// this.userIdSource = userIdSource;
// }
//
//
// @Override
// public Salesforce getApi()
// {
// Connection<Salesforce> connection = usersConnectionRepository.createConnectionRepository(userIdSource.getUserId()).findPrimaryConnection(Salesforce.class);
// if (logger.isDebugEnabled() && connection == null) {
// logger.debug("No current connection; Returning default TwitterTemplate instance.");
// }
// return connection != null ? connection.getApi() : null;
// }
//
// private final static Log logger = LogFactory.getLog(SalesforceApiHelper.class);
//
// }
//
// Path: src/main/java/org/springframework/social/salesforce/connect/SalesforceConnectionFactory.java
// public class SalesforceConnectionFactory extends OAuth2ConnectionFactory<Salesforce> {
//
// public SalesforceConnectionFactory(String clientId, String clientSecret) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret),
// new SalesforceAdapter());
// }
//
// public SalesforceConnectionFactory(String clientId, String clientSecret, boolean sandbox) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret, sandbox),
// sandbox ? new SalesforceAdapter(sandbox) : new SalesforceAdapter());
// }
//
// public SalesforceConnectionFactory(String clientId, String clientSecret, String instanceUrl) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret),
// new SalesforceAdapter(instanceUrl));
// }
//
// public SalesforceConnectionFactory(String clientId, String clientSecret, String instanceUrl, boolean sandbox) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret, sandbox),
// sandbox ? new SalesforceAdapter(instanceUrl, sandbox) : new SalesforceAdapter(instanceUrl));
// }
//
// @Deprecated
// public SalesforceConnectionFactory(String clientId, String clientSecret, String authorizeUrl, String tokenUrl) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret,
// authorizeUrl, tokenUrl), new SalesforceAdapter());
// }
//
// @Deprecated
// public SalesforceConnectionFactory(String clientId, String clientSecret, String authorizeUrl, String tokenUrl, String instanceUrl) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret,
// authorizeUrl, tokenUrl), new SalesforceAdapter(instanceUrl));
// }
//
// @Deprecated
// public SalesforceConnectionFactory(String clientId, String clientSecret, String authorizeUrl, String tokenUrl, String instanceUrl, String gatewayUrl) {
// super("salesforce", new SalesforceServiceProvider(clientId, clientSecret,
// authorizeUrl, tokenUrl), new SalesforceAdapter(instanceUrl, gatewayUrl));
// }
//
// }
//
// Path: src/main/java/org/springframework/social/salesforce/security/SalesforceAuthenticationService.java
// public class SalesforceAuthenticationService extends OAuth2AuthenticationService<Salesforce>
// {
// public SalesforceAuthenticationService(String consumerKey, String consumerSecret)
// {
// super(new SalesforceConnectionFactory(consumerKey, consumerSecret));
// }
//
// public SalesforceAuthenticationService(String consumerKey, String consumerSecret, boolean sandbox)
// {
// super(new SalesforceConnectionFactory(consumerKey, consumerSecret, sandbox));
// }
// }
// Path: src/main/java/org/springframework/social/salesforce/config/xml/SalesforceConfigBeanDefinitionParser.java
import org.springframework.social.config.xml.AbstractProviderConfigBeanDefinitionParser;
import org.springframework.social.salesforce.config.support.SalesforceApiHelper;
import org.springframework.social.salesforce.connect.SalesforceConnectionFactory;
import org.springframework.social.salesforce.security.SalesforceAuthenticationService;
import org.springframework.social.security.provider.SocialAuthenticationService;
/**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.config.xml;
/**
*
* @author Jared Ottley
*
*/
public class SalesforceConfigBeanDefinitionParser extends AbstractProviderConfigBeanDefinitionParser
{
public SalesforceConfigBeanDefinitionParser() {
super(SalesforceConnectionFactory.class, SalesforceApiHelper.class);
}
@Override
protected Class<? extends SocialAuthenticationService<?>> getAuthenticationServiceClass() { | return SalesforceAuthenticationService.class; |
jottley/spring-social-salesforce | src/test/java/org/springframework/social/salesforce/api/impl/UserOperationsTemplateTest.java | // Path: src/main/java/org/springframework/social/salesforce/api/SalesforceUserDetails.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class SalesforceUserDetails extends SalesforceProfile {
// private String organizationId;
//
// private String nickname;
//
// private String preferredUsername;
//
// public SalesforceUserDetails(String id, String firstName, String lastName,
// String email, String name, String organizationId, String nickname,
// String preferredUsername) {
// super();
// this.id = id;
// this.firstName = firstName;
// this.lastName = lastName;
// this.email = email;
// this.name = name;
// this.organizationId = organizationId;
// this.nickname = nickname;
// this.preferredUsername = preferredUsername;
// }
//
// public String getOrganizationId() {
// return organizationId;
// }
//
// public String getNickname() {
// return nickname;
// }
//
// public String getPreferredUsername() {
// return preferredUsername;
// }
// }
| import static org.junit.Assert.assertEquals;
import static org.springframework.http.HttpMethod.GET;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus;
import org.junit.Test;
import org.springframework.http.HttpStatus;
import org.springframework.social.salesforce.api.SalesforceUserDetails; | /**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.impl;
/**
* @author Alexandra Leahu
* @author Jared Ottley
*/
public class UserOperationsTemplateTest extends AbstractSalesforceTest {
@Test
public void getUserDetails() {
mockServer.expect(requestTo("https://login.salesforce.com/services/oauth2/userinfo"))
.andExpect(method(GET))
.andRespond(withStatus(HttpStatus.OK).body(loadResource("userDetails.json")).headers(responseHeaders)); | // Path: src/main/java/org/springframework/social/salesforce/api/SalesforceUserDetails.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class SalesforceUserDetails extends SalesforceProfile {
// private String organizationId;
//
// private String nickname;
//
// private String preferredUsername;
//
// public SalesforceUserDetails(String id, String firstName, String lastName,
// String email, String name, String organizationId, String nickname,
// String preferredUsername) {
// super();
// this.id = id;
// this.firstName = firstName;
// this.lastName = lastName;
// this.email = email;
// this.name = name;
// this.organizationId = organizationId;
// this.nickname = nickname;
// this.preferredUsername = preferredUsername;
// }
//
// public String getOrganizationId() {
// return organizationId;
// }
//
// public String getNickname() {
// return nickname;
// }
//
// public String getPreferredUsername() {
// return preferredUsername;
// }
// }
// Path: src/test/java/org/springframework/social/salesforce/api/impl/UserOperationsTemplateTest.java
import static org.junit.Assert.assertEquals;
import static org.springframework.http.HttpMethod.GET;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus;
import org.junit.Test;
import org.springframework.http.HttpStatus;
import org.springframework.social.salesforce.api.SalesforceUserDetails;
/**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.impl;
/**
* @author Alexandra Leahu
* @author Jared Ottley
*/
public class UserOperationsTemplateTest extends AbstractSalesforceTest {
@Test
public void getUserDetails() {
mockServer.expect(requestTo("https://login.salesforce.com/services/oauth2/userinfo"))
.andExpect(method(GET))
.andRespond(withStatus(HttpStatus.OK).body(loadResource("userDetails.json")).headers(responseHeaders)); | SalesforceUserDetails userDetails = salesforce.userOperations().getSalesforceUserDetails(); |
jottley/spring-social-salesforce | src/main/java/org/springframework/social/salesforce/api/impl/ApiTemplate.java | // Path: src/main/java/org/springframework/social/salesforce/api/ApiOperations.java
// public interface ApiOperations {
//
// static final String DEFAULT_API_VERSION = "v37.0";
//
// List<ApiVersion> getVersions();
//
// Map<String, String> getServices(String version);
//
// Map<String, String> getServices();
//
// void setVersion(String version)
// throws InvalidSalesforceApiVersionException;
//
// String getVersion();
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/ApiVersion.java
// public class ApiVersion implements Serializable {
//
// private String label;
//
// private String version;
//
// private String url;
//
//
// public ApiVersion(String version, String label, String url) {
// this.version = version;
// this.label = label;
// this.url = url;
// }
//
//
// public String getLabel() {
// return label;
// }
//
// public String getVersion() {
// return version;
// }
//
// public String getUrl() {
// return url;
// }
//
// @Override
// public String toString() {
// return "ApiVersion{" +
// "label='" + label + '\'' +
// ", version='" + version + '\'' +
// ", url='" + url + '\'' +
// '}';
// }
//
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/InvalidSalesforceApiVersionException.java
// public class InvalidSalesforceApiVersionException
// extends Throwable
// {
// public InvalidSalesforceApiVersionException()
// {
// //NOOP
// }
//
// public InvalidSalesforceApiVersionException(String version)
// {
// super(version + " is not a valid Salesforce Api version.");
// }
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/Salesforce.java
// public interface Salesforce extends ApiBinding {
//
// public ApiOperations apiOperations();
//
// public ApiOperations apiOperations(String instanceUrl);
//
// public ChatterOperations chatterOperations();
//
// public ChatterOperations chatterOperations(String instanceUrl);
//
// public QueryOperations queryOperations();
//
// public QueryOperations queryOperations(String instanceUrl);
//
// public RecentOperations recentOperations();
//
// public RecentOperations recentOperations(String instanceUrl);
//
// public SearchOperations searchOperations();
//
// public SearchOperations searchOperations(String instanceUrl);
//
// public SObjectOperations sObjectsOperations();
//
// public SObjectOperations sObjectsOperations(String instanceUrl);
//
// public UserOperations userOperations();
//
// public UserOperations userOperations(String gatewayUrl);
//
// public LimitsOperations limitsOperations();
//
// public LimitsOperations limitsOperations(String instanceUrl);
//
// public <T> List<T> readList(JsonNode jsonNode, Class<T> type);
//
// public <T> T readObject(JsonNode jsonNode, Class<T> type);
//
// public String getBaseUrl();
//
// public String getInstanceUrl();
//
// public void setInstanceUrl(String instanceUrl);
//
// public String getUserInfoUrl();
//
// public String getAuthGatewayUrl();
//
// public void setAuthGatewayBaseUrl(String gatewayUrl);
//
// public ConnectOperations connectOperations();
//
// public ConnectOperations connectOperations(String instanceUrl);
//
// public CustomApiOperations customApiOperations();
//
// public CustomApiOperations customApiOperations(String instanceUrl);
// }
| import com.fasterxml.jackson.databind.JsonNode;
import org.apache.commons.lang3.StringUtils;
import org.springframework.social.salesforce.api.ApiOperations;
import org.springframework.social.salesforce.api.ApiVersion;
import org.springframework.social.salesforce.api.InvalidSalesforceApiVersionException;
import org.springframework.social.salesforce.api.Salesforce;
import org.springframework.social.support.URIBuilder;
import org.springframework.web.client.RestTemplate;
import java.net.URI;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern; | /**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.impl;
/**
* Default implementation of ApiOperations.
*
* @author Umut Utkan
* @author Jared Ottley
*/
public class ApiTemplate extends AbstractSalesForceOperations<Salesforce> implements ApiOperations {
private RestTemplate restTemplate;
private String version;
String versionRegEx = "v[0-9][0-9]\\.[0-9]";
public ApiTemplate(Salesforce api, RestTemplate restTemplate) {
super(api);
this.restTemplate = restTemplate;
}
| // Path: src/main/java/org/springframework/social/salesforce/api/ApiOperations.java
// public interface ApiOperations {
//
// static final String DEFAULT_API_VERSION = "v37.0";
//
// List<ApiVersion> getVersions();
//
// Map<String, String> getServices(String version);
//
// Map<String, String> getServices();
//
// void setVersion(String version)
// throws InvalidSalesforceApiVersionException;
//
// String getVersion();
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/ApiVersion.java
// public class ApiVersion implements Serializable {
//
// private String label;
//
// private String version;
//
// private String url;
//
//
// public ApiVersion(String version, String label, String url) {
// this.version = version;
// this.label = label;
// this.url = url;
// }
//
//
// public String getLabel() {
// return label;
// }
//
// public String getVersion() {
// return version;
// }
//
// public String getUrl() {
// return url;
// }
//
// @Override
// public String toString() {
// return "ApiVersion{" +
// "label='" + label + '\'' +
// ", version='" + version + '\'' +
// ", url='" + url + '\'' +
// '}';
// }
//
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/InvalidSalesforceApiVersionException.java
// public class InvalidSalesforceApiVersionException
// extends Throwable
// {
// public InvalidSalesforceApiVersionException()
// {
// //NOOP
// }
//
// public InvalidSalesforceApiVersionException(String version)
// {
// super(version + " is not a valid Salesforce Api version.");
// }
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/Salesforce.java
// public interface Salesforce extends ApiBinding {
//
// public ApiOperations apiOperations();
//
// public ApiOperations apiOperations(String instanceUrl);
//
// public ChatterOperations chatterOperations();
//
// public ChatterOperations chatterOperations(String instanceUrl);
//
// public QueryOperations queryOperations();
//
// public QueryOperations queryOperations(String instanceUrl);
//
// public RecentOperations recentOperations();
//
// public RecentOperations recentOperations(String instanceUrl);
//
// public SearchOperations searchOperations();
//
// public SearchOperations searchOperations(String instanceUrl);
//
// public SObjectOperations sObjectsOperations();
//
// public SObjectOperations sObjectsOperations(String instanceUrl);
//
// public UserOperations userOperations();
//
// public UserOperations userOperations(String gatewayUrl);
//
// public LimitsOperations limitsOperations();
//
// public LimitsOperations limitsOperations(String instanceUrl);
//
// public <T> List<T> readList(JsonNode jsonNode, Class<T> type);
//
// public <T> T readObject(JsonNode jsonNode, Class<T> type);
//
// public String getBaseUrl();
//
// public String getInstanceUrl();
//
// public void setInstanceUrl(String instanceUrl);
//
// public String getUserInfoUrl();
//
// public String getAuthGatewayUrl();
//
// public void setAuthGatewayBaseUrl(String gatewayUrl);
//
// public ConnectOperations connectOperations();
//
// public ConnectOperations connectOperations(String instanceUrl);
//
// public CustomApiOperations customApiOperations();
//
// public CustomApiOperations customApiOperations(String instanceUrl);
// }
// Path: src/main/java/org/springframework/social/salesforce/api/impl/ApiTemplate.java
import com.fasterxml.jackson.databind.JsonNode;
import org.apache.commons.lang3.StringUtils;
import org.springframework.social.salesforce.api.ApiOperations;
import org.springframework.social.salesforce.api.ApiVersion;
import org.springframework.social.salesforce.api.InvalidSalesforceApiVersionException;
import org.springframework.social.salesforce.api.Salesforce;
import org.springframework.social.support.URIBuilder;
import org.springframework.web.client.RestTemplate;
import java.net.URI;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.impl;
/**
* Default implementation of ApiOperations.
*
* @author Umut Utkan
* @author Jared Ottley
*/
public class ApiTemplate extends AbstractSalesForceOperations<Salesforce> implements ApiOperations {
private RestTemplate restTemplate;
private String version;
String versionRegEx = "v[0-9][0-9]\\.[0-9]";
public ApiTemplate(Salesforce api, RestTemplate restTemplate) {
super(api);
this.restTemplate = restTemplate;
}
| public List<ApiVersion> getVersions() { |
jottley/spring-social-salesforce | src/main/java/org/springframework/social/salesforce/api/impl/ApiTemplate.java | // Path: src/main/java/org/springframework/social/salesforce/api/ApiOperations.java
// public interface ApiOperations {
//
// static final String DEFAULT_API_VERSION = "v37.0";
//
// List<ApiVersion> getVersions();
//
// Map<String, String> getServices(String version);
//
// Map<String, String> getServices();
//
// void setVersion(String version)
// throws InvalidSalesforceApiVersionException;
//
// String getVersion();
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/ApiVersion.java
// public class ApiVersion implements Serializable {
//
// private String label;
//
// private String version;
//
// private String url;
//
//
// public ApiVersion(String version, String label, String url) {
// this.version = version;
// this.label = label;
// this.url = url;
// }
//
//
// public String getLabel() {
// return label;
// }
//
// public String getVersion() {
// return version;
// }
//
// public String getUrl() {
// return url;
// }
//
// @Override
// public String toString() {
// return "ApiVersion{" +
// "label='" + label + '\'' +
// ", version='" + version + '\'' +
// ", url='" + url + '\'' +
// '}';
// }
//
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/InvalidSalesforceApiVersionException.java
// public class InvalidSalesforceApiVersionException
// extends Throwable
// {
// public InvalidSalesforceApiVersionException()
// {
// //NOOP
// }
//
// public InvalidSalesforceApiVersionException(String version)
// {
// super(version + " is not a valid Salesforce Api version.");
// }
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/Salesforce.java
// public interface Salesforce extends ApiBinding {
//
// public ApiOperations apiOperations();
//
// public ApiOperations apiOperations(String instanceUrl);
//
// public ChatterOperations chatterOperations();
//
// public ChatterOperations chatterOperations(String instanceUrl);
//
// public QueryOperations queryOperations();
//
// public QueryOperations queryOperations(String instanceUrl);
//
// public RecentOperations recentOperations();
//
// public RecentOperations recentOperations(String instanceUrl);
//
// public SearchOperations searchOperations();
//
// public SearchOperations searchOperations(String instanceUrl);
//
// public SObjectOperations sObjectsOperations();
//
// public SObjectOperations sObjectsOperations(String instanceUrl);
//
// public UserOperations userOperations();
//
// public UserOperations userOperations(String gatewayUrl);
//
// public LimitsOperations limitsOperations();
//
// public LimitsOperations limitsOperations(String instanceUrl);
//
// public <T> List<T> readList(JsonNode jsonNode, Class<T> type);
//
// public <T> T readObject(JsonNode jsonNode, Class<T> type);
//
// public String getBaseUrl();
//
// public String getInstanceUrl();
//
// public void setInstanceUrl(String instanceUrl);
//
// public String getUserInfoUrl();
//
// public String getAuthGatewayUrl();
//
// public void setAuthGatewayBaseUrl(String gatewayUrl);
//
// public ConnectOperations connectOperations();
//
// public ConnectOperations connectOperations(String instanceUrl);
//
// public CustomApiOperations customApiOperations();
//
// public CustomApiOperations customApiOperations(String instanceUrl);
// }
| import com.fasterxml.jackson.databind.JsonNode;
import org.apache.commons.lang3.StringUtils;
import org.springframework.social.salesforce.api.ApiOperations;
import org.springframework.social.salesforce.api.ApiVersion;
import org.springframework.social.salesforce.api.InvalidSalesforceApiVersionException;
import org.springframework.social.salesforce.api.Salesforce;
import org.springframework.social.support.URIBuilder;
import org.springframework.web.client.RestTemplate;
import java.net.URI;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern; | /**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.impl;
/**
* Default implementation of ApiOperations.
*
* @author Umut Utkan
* @author Jared Ottley
*/
public class ApiTemplate extends AbstractSalesForceOperations<Salesforce> implements ApiOperations {
private RestTemplate restTemplate;
private String version;
String versionRegEx = "v[0-9][0-9]\\.[0-9]";
public ApiTemplate(Salesforce api, RestTemplate restTemplate) {
super(api);
this.restTemplate = restTemplate;
}
public List<ApiVersion> getVersions() {
URI uri = URIBuilder.fromUri(api.getBaseUrl()).build();
JsonNode dataNode = restTemplate.getForObject(uri, JsonNode.class);
return api.readList(dataNode, ApiVersion.class);
}
@SuppressWarnings("unchecked")
public Map<String, String> getServices(String version) {
requireAuthorization();
return restTemplate.getForObject(api.getBaseUrl() + "/{version}", Map.class, version);
}
@SuppressWarnings("unchecked")
public Map<String, String> getServices() {
requireAuthorization();
return this.getServices(getVersion());
}
public void setVersion(String version) | // Path: src/main/java/org/springframework/social/salesforce/api/ApiOperations.java
// public interface ApiOperations {
//
// static final String DEFAULT_API_VERSION = "v37.0";
//
// List<ApiVersion> getVersions();
//
// Map<String, String> getServices(String version);
//
// Map<String, String> getServices();
//
// void setVersion(String version)
// throws InvalidSalesforceApiVersionException;
//
// String getVersion();
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/ApiVersion.java
// public class ApiVersion implements Serializable {
//
// private String label;
//
// private String version;
//
// private String url;
//
//
// public ApiVersion(String version, String label, String url) {
// this.version = version;
// this.label = label;
// this.url = url;
// }
//
//
// public String getLabel() {
// return label;
// }
//
// public String getVersion() {
// return version;
// }
//
// public String getUrl() {
// return url;
// }
//
// @Override
// public String toString() {
// return "ApiVersion{" +
// "label='" + label + '\'' +
// ", version='" + version + '\'' +
// ", url='" + url + '\'' +
// '}';
// }
//
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/InvalidSalesforceApiVersionException.java
// public class InvalidSalesforceApiVersionException
// extends Throwable
// {
// public InvalidSalesforceApiVersionException()
// {
// //NOOP
// }
//
// public InvalidSalesforceApiVersionException(String version)
// {
// super(version + " is not a valid Salesforce Api version.");
// }
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/Salesforce.java
// public interface Salesforce extends ApiBinding {
//
// public ApiOperations apiOperations();
//
// public ApiOperations apiOperations(String instanceUrl);
//
// public ChatterOperations chatterOperations();
//
// public ChatterOperations chatterOperations(String instanceUrl);
//
// public QueryOperations queryOperations();
//
// public QueryOperations queryOperations(String instanceUrl);
//
// public RecentOperations recentOperations();
//
// public RecentOperations recentOperations(String instanceUrl);
//
// public SearchOperations searchOperations();
//
// public SearchOperations searchOperations(String instanceUrl);
//
// public SObjectOperations sObjectsOperations();
//
// public SObjectOperations sObjectsOperations(String instanceUrl);
//
// public UserOperations userOperations();
//
// public UserOperations userOperations(String gatewayUrl);
//
// public LimitsOperations limitsOperations();
//
// public LimitsOperations limitsOperations(String instanceUrl);
//
// public <T> List<T> readList(JsonNode jsonNode, Class<T> type);
//
// public <T> T readObject(JsonNode jsonNode, Class<T> type);
//
// public String getBaseUrl();
//
// public String getInstanceUrl();
//
// public void setInstanceUrl(String instanceUrl);
//
// public String getUserInfoUrl();
//
// public String getAuthGatewayUrl();
//
// public void setAuthGatewayBaseUrl(String gatewayUrl);
//
// public ConnectOperations connectOperations();
//
// public ConnectOperations connectOperations(String instanceUrl);
//
// public CustomApiOperations customApiOperations();
//
// public CustomApiOperations customApiOperations(String instanceUrl);
// }
// Path: src/main/java/org/springframework/social/salesforce/api/impl/ApiTemplate.java
import com.fasterxml.jackson.databind.JsonNode;
import org.apache.commons.lang3.StringUtils;
import org.springframework.social.salesforce.api.ApiOperations;
import org.springframework.social.salesforce.api.ApiVersion;
import org.springframework.social.salesforce.api.InvalidSalesforceApiVersionException;
import org.springframework.social.salesforce.api.Salesforce;
import org.springframework.social.support.URIBuilder;
import org.springframework.web.client.RestTemplate;
import java.net.URI;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.impl;
/**
* Default implementation of ApiOperations.
*
* @author Umut Utkan
* @author Jared Ottley
*/
public class ApiTemplate extends AbstractSalesForceOperations<Salesforce> implements ApiOperations {
private RestTemplate restTemplate;
private String version;
String versionRegEx = "v[0-9][0-9]\\.[0-9]";
public ApiTemplate(Salesforce api, RestTemplate restTemplate) {
super(api);
this.restTemplate = restTemplate;
}
public List<ApiVersion> getVersions() {
URI uri = URIBuilder.fromUri(api.getBaseUrl()).build();
JsonNode dataNode = restTemplate.getForObject(uri, JsonNode.class);
return api.readList(dataNode, ApiVersion.class);
}
@SuppressWarnings("unchecked")
public Map<String, String> getServices(String version) {
requireAuthorization();
return restTemplate.getForObject(api.getBaseUrl() + "/{version}", Map.class, version);
}
@SuppressWarnings("unchecked")
public Map<String, String> getServices() {
requireAuthorization();
return this.getServices(getVersion());
}
public void setVersion(String version) | throws InvalidSalesforceApiVersionException |
jottley/spring-social-salesforce | src/main/java/org/springframework/social/salesforce/client/ErrorHandler.java | // Path: src/main/java/org/springframework/social/salesforce/connect/SalesforceServiceProvider.java
// public class SalesforceServiceProvider extends AbstractOAuth2ServiceProvider<Salesforce> {
//
// //Provider ID
// public final static String ID = "salesforce";
//
// public final static String PRODUCTION_GATEWAY_URL = "https://login.salesforce.com";
// public final static String SANDBOX_GATEWAY_URL = "https://test.salesforce.com";
//
// public final static String TOKEN_PATH = "/services/oauth2/token";
// public final static String AUTHORIZE_PATH = "/services/oauth2/authorize";
//
// public SalesforceServiceProvider(String clientId, String clientSecret) {
// this(clientId, clientSecret,
// PRODUCTION_GATEWAY_URL + AUTHORIZE_PATH,
// PRODUCTION_GATEWAY_URL + TOKEN_PATH);
// }
//
// public SalesforceServiceProvider(String clientId, String clientSecret, boolean sandbox)
// {
// super(new SalesforceOAuth2Template(clientId, clientSecret, (sandbox ? SANDBOX_GATEWAY_URL : PRODUCTION_GATEWAY_URL) + AUTHORIZE_PATH, (sandbox ? SANDBOX_GATEWAY_URL : PRODUCTION_GATEWAY_URL) + TOKEN_PATH));
// }
//
// public SalesforceServiceProvider(String clientId, String clientSecret, String authorizeUrl, String tokenUrl) {
// super(new SalesforceOAuth2Template(clientId, clientSecret, authorizeUrl, tokenUrl));
// }
//
//
// public Salesforce getApi(String accessToken) {
// SalesforceTemplate template = new SalesforceTemplate(accessToken);
//
// // gets the returned instance url and sets to Salesforce template as base url.
// String instanceUrl = ((SalesforceOAuth2Template) getOAuthOperations()).getInstanceUrl();
// if (instanceUrl != null) {
// template.setInstanceUrl(instanceUrl);
// }
//
// return template;
// }
//
// }
| import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.http.HttpStatus;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.social.InvalidAuthorizationException;
import org.springframework.social.OperationNotPermittedException;
import org.springframework.social.RateLimitExceededException;
import org.springframework.social.salesforce.connect.SalesforceServiceProvider;
import org.springframework.web.client.DefaultResponseErrorHandler;
import java.io.IOException;
import java.util.Map; | /**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.client;
/**
* Custom error handler for handling Salesforce API specific error responses.
*
* @author Umut Utkan
* @author Jared Ottley
*/
public class ErrorHandler extends DefaultResponseErrorHandler {
@Override
public void handleError(ClientHttpResponse response) throws IOException {
if (response.getStatusCode().equals(HttpStatus.BAD_REQUEST)) {
Map<String, String> error = extractErrorDetailsFromResponse(response);
if ("unsupported_response_type".equals(error.get("error"))) { | // Path: src/main/java/org/springframework/social/salesforce/connect/SalesforceServiceProvider.java
// public class SalesforceServiceProvider extends AbstractOAuth2ServiceProvider<Salesforce> {
//
// //Provider ID
// public final static String ID = "salesforce";
//
// public final static String PRODUCTION_GATEWAY_URL = "https://login.salesforce.com";
// public final static String SANDBOX_GATEWAY_URL = "https://test.salesforce.com";
//
// public final static String TOKEN_PATH = "/services/oauth2/token";
// public final static String AUTHORIZE_PATH = "/services/oauth2/authorize";
//
// public SalesforceServiceProvider(String clientId, String clientSecret) {
// this(clientId, clientSecret,
// PRODUCTION_GATEWAY_URL + AUTHORIZE_PATH,
// PRODUCTION_GATEWAY_URL + TOKEN_PATH);
// }
//
// public SalesforceServiceProvider(String clientId, String clientSecret, boolean sandbox)
// {
// super(new SalesforceOAuth2Template(clientId, clientSecret, (sandbox ? SANDBOX_GATEWAY_URL : PRODUCTION_GATEWAY_URL) + AUTHORIZE_PATH, (sandbox ? SANDBOX_GATEWAY_URL : PRODUCTION_GATEWAY_URL) + TOKEN_PATH));
// }
//
// public SalesforceServiceProvider(String clientId, String clientSecret, String authorizeUrl, String tokenUrl) {
// super(new SalesforceOAuth2Template(clientId, clientSecret, authorizeUrl, tokenUrl));
// }
//
//
// public Salesforce getApi(String accessToken) {
// SalesforceTemplate template = new SalesforceTemplate(accessToken);
//
// // gets the returned instance url and sets to Salesforce template as base url.
// String instanceUrl = ((SalesforceOAuth2Template) getOAuthOperations()).getInstanceUrl();
// if (instanceUrl != null) {
// template.setInstanceUrl(instanceUrl);
// }
//
// return template;
// }
//
// }
// Path: src/main/java/org/springframework/social/salesforce/client/ErrorHandler.java
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.http.HttpStatus;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.social.InvalidAuthorizationException;
import org.springframework.social.OperationNotPermittedException;
import org.springframework.social.RateLimitExceededException;
import org.springframework.social.salesforce.connect.SalesforceServiceProvider;
import org.springframework.web.client.DefaultResponseErrorHandler;
import java.io.IOException;
import java.util.Map;
/**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.client;
/**
* Custom error handler for handling Salesforce API specific error responses.
*
* @author Umut Utkan
* @author Jared Ottley
*/
public class ErrorHandler extends DefaultResponseErrorHandler {
@Override
public void handleError(ClientHttpResponse response) throws IOException {
if (response.getStatusCode().equals(HttpStatus.BAD_REQUEST)) {
Map<String, String> error = extractErrorDetailsFromResponse(response);
if ("unsupported_response_type".equals(error.get("error"))) { | throw new OperationNotPermittedException(SalesforceServiceProvider.ID, error.get("error_description")); |
jottley/spring-social-salesforce | src/main/java/org/springframework/social/salesforce/api/LimitResult.java | // Path: src/main/java/org/springframework/social/salesforce/api/AbstractLimits.java
// @JsonInclude(JsonInclude.Include.NON_NULL)
// /**
// * The core limits properties. Any additional limits for connected apps can call
// * be found in the additional properties
// *
// * @author Jared Ottley
// */
// public class AbstractLimits implements Serializable {
//
// private static final long serialVersionUID = 6213553807904726408L;
//
// @JsonProperty("Max")
// private int max;
//
// @JsonProperty("Remaining")
// private int remaining;
//
// @JsonIgnore
// private Map<String, Object> additionalProperties = new HashMap<String, Object>();
//
// /**
// * NOOP
// */
// public AbstractLimits() {
//
// }
//
// /**
// *
// * @param remaining
// * @param max
// */
// public AbstractLimits(int max, int remaining) {
// this.max = max;
// this.remaining = remaining;
// }
//
// @JsonProperty("Max")
// public int getMax() {
// return max;
// }
//
// @JsonProperty("Remaining")
// public int getRemaining() {
// return remaining;
// }
//
// @JsonAnyGetter
// public Map<String, Object> getAdditionalProperties() {
// return this.additionalProperties;
// }
//
// @JsonAnySetter
// public void setAdditionalProperty(String name, Object value) {
// this.additionalProperties.put(name, value);
// }
//
// }
| import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import org.springframework.social.salesforce.api.AbstractLimits; | /**
* Copyright (C) 2019 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
/**
* @author Jared Ottley
*/ | // Path: src/main/java/org/springframework/social/salesforce/api/AbstractLimits.java
// @JsonInclude(JsonInclude.Include.NON_NULL)
// /**
// * The core limits properties. Any additional limits for connected apps can call
// * be found in the additional properties
// *
// * @author Jared Ottley
// */
// public class AbstractLimits implements Serializable {
//
// private static final long serialVersionUID = 6213553807904726408L;
//
// @JsonProperty("Max")
// private int max;
//
// @JsonProperty("Remaining")
// private int remaining;
//
// @JsonIgnore
// private Map<String, Object> additionalProperties = new HashMap<String, Object>();
//
// /**
// * NOOP
// */
// public AbstractLimits() {
//
// }
//
// /**
// *
// * @param remaining
// * @param max
// */
// public AbstractLimits(int max, int remaining) {
// this.max = max;
// this.remaining = remaining;
// }
//
// @JsonProperty("Max")
// public int getMax() {
// return max;
// }
//
// @JsonProperty("Remaining")
// public int getRemaining() {
// return remaining;
// }
//
// @JsonAnyGetter
// public Map<String, Object> getAdditionalProperties() {
// return this.additionalProperties;
// }
//
// @JsonAnySetter
// public void setAdditionalProperty(String name, Object value) {
// this.additionalProperties.put(name, value);
// }
//
// }
// Path: src/main/java/org/springframework/social/salesforce/api/LimitResult.java
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import org.springframework.social.salesforce.api.AbstractLimits;
/**
* Copyright (C) 2019 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
/**
* @author Jared Ottley
*/ | public class LimitResult extends AbstractLimits { |
jottley/spring-social-salesforce | src/main/java/org/springframework/social/salesforce/api/impl/json/QueryResultMixin.java | // Path: src/main/java/org/springframework/social/salesforce/api/QueryResult.java
// public class QueryResult {
//
// private int totalSize;
//
// private boolean done;
//
// private String nextRecordsUrl;
//
// private List<ResultItem> records;
//
//
// public QueryResult(int totalSize, boolean done) {
// this.totalSize = totalSize;
// this.done = done;
// }
//
//
// public int getTotalSize() {
// return totalSize;
// }
//
// public boolean isDone() {
// return done;
// }
//
// public List<ResultItem> getRecords() {
// return records;
// }
//
// public void setRecords(List<ResultItem> records) {
// this.records = records;
// }
//
// public String getNextRecordsUrl() {
// return nextRecordsUrl;
// }
//
// public void setNextRecordsUrl(String nextRecordsUrl) {
// this.nextRecordsUrl = nextRecordsUrl;
// }
//
// public String getNextRecordsToken() {
// if (this.nextRecordsUrl != null) {
// return this.nextRecordsUrl.substring(this.nextRecordsUrl.lastIndexOf('/') + 1, this.nextRecordsUrl.length());
// }
// return null;
// }
//
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/ResultItem.java
// public class ResultItem implements Serializable {
//
// private String type;
//
// private String url;
//
// private Map attributes;
//
//
// public ResultItem(String type, String url) {
// this.type = type;
// this.url = url;
// this.attributes = new HashMap();
// }
//
//
// public String getType() {
// return this.type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public String getUrl() {
// return this.url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public Map getAttributes() {
// return attributes;
// }
//
// public void setAttributes(Map attributes) {
// this.attributes = attributes;
// }
//
// }
| import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.springframework.social.salesforce.api.QueryResult;
import org.springframework.social.salesforce.api.ResultItem;
import java.util.List; | /**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.impl.json;
/**
* {@link QueryResult}
*
* @author Umut Utkan
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class QueryResultMixin {
@JsonCreator
QueryResultMixin(
@JsonProperty("totalSize") int totalSize,
@JsonProperty("done") boolean done) {
}
@JsonProperty("nextRecordsUrl")
String nextRecordsUrl;
@JsonProperty("records") | // Path: src/main/java/org/springframework/social/salesforce/api/QueryResult.java
// public class QueryResult {
//
// private int totalSize;
//
// private boolean done;
//
// private String nextRecordsUrl;
//
// private List<ResultItem> records;
//
//
// public QueryResult(int totalSize, boolean done) {
// this.totalSize = totalSize;
// this.done = done;
// }
//
//
// public int getTotalSize() {
// return totalSize;
// }
//
// public boolean isDone() {
// return done;
// }
//
// public List<ResultItem> getRecords() {
// return records;
// }
//
// public void setRecords(List<ResultItem> records) {
// this.records = records;
// }
//
// public String getNextRecordsUrl() {
// return nextRecordsUrl;
// }
//
// public void setNextRecordsUrl(String nextRecordsUrl) {
// this.nextRecordsUrl = nextRecordsUrl;
// }
//
// public String getNextRecordsToken() {
// if (this.nextRecordsUrl != null) {
// return this.nextRecordsUrl.substring(this.nextRecordsUrl.lastIndexOf('/') + 1, this.nextRecordsUrl.length());
// }
// return null;
// }
//
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/ResultItem.java
// public class ResultItem implements Serializable {
//
// private String type;
//
// private String url;
//
// private Map attributes;
//
//
// public ResultItem(String type, String url) {
// this.type = type;
// this.url = url;
// this.attributes = new HashMap();
// }
//
//
// public String getType() {
// return this.type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public String getUrl() {
// return this.url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public Map getAttributes() {
// return attributes;
// }
//
// public void setAttributes(Map attributes) {
// this.attributes = attributes;
// }
//
// }
// Path: src/main/java/org/springframework/social/salesforce/api/impl/json/QueryResultMixin.java
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.springframework.social.salesforce.api.QueryResult;
import org.springframework.social.salesforce.api.ResultItem;
import java.util.List;
/**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.impl.json;
/**
* {@link QueryResult}
*
* @author Umut Utkan
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class QueryResultMixin {
@JsonCreator
QueryResultMixin(
@JsonProperty("totalSize") int totalSize,
@JsonProperty("done") boolean done) {
}
@JsonProperty("nextRecordsUrl")
String nextRecordsUrl;
@JsonProperty("records") | List<ResultItem> records; |
jottley/spring-social-salesforce | src/main/java/org/springframework/social/salesforce/api/impl/SearchTemplate.java | // Path: src/main/java/org/springframework/social/salesforce/api/ResultItem.java
// public class ResultItem implements Serializable {
//
// private String type;
//
// private String url;
//
// private Map attributes;
//
//
// public ResultItem(String type, String url) {
// this.type = type;
// this.url = url;
// this.attributes = new HashMap();
// }
//
//
// public String getType() {
// return this.type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public String getUrl() {
// return this.url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public Map getAttributes() {
// return attributes;
// }
//
// public void setAttributes(Map attributes) {
// this.attributes = attributes;
// }
//
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/Salesforce.java
// public interface Salesforce extends ApiBinding {
//
// public ApiOperations apiOperations();
//
// public ApiOperations apiOperations(String instanceUrl);
//
// public ChatterOperations chatterOperations();
//
// public ChatterOperations chatterOperations(String instanceUrl);
//
// public QueryOperations queryOperations();
//
// public QueryOperations queryOperations(String instanceUrl);
//
// public RecentOperations recentOperations();
//
// public RecentOperations recentOperations(String instanceUrl);
//
// public SearchOperations searchOperations();
//
// public SearchOperations searchOperations(String instanceUrl);
//
// public SObjectOperations sObjectsOperations();
//
// public SObjectOperations sObjectsOperations(String instanceUrl);
//
// public UserOperations userOperations();
//
// public UserOperations userOperations(String gatewayUrl);
//
// public LimitsOperations limitsOperations();
//
// public LimitsOperations limitsOperations(String instanceUrl);
//
// public <T> List<T> readList(JsonNode jsonNode, Class<T> type);
//
// public <T> T readObject(JsonNode jsonNode, Class<T> type);
//
// public String getBaseUrl();
//
// public String getInstanceUrl();
//
// public void setInstanceUrl(String instanceUrl);
//
// public String getUserInfoUrl();
//
// public String getAuthGatewayUrl();
//
// public void setAuthGatewayBaseUrl(String gatewayUrl);
//
// public ConnectOperations connectOperations();
//
// public ConnectOperations connectOperations(String instanceUrl);
//
// public CustomApiOperations customApiOperations();
//
// public CustomApiOperations customApiOperations(String instanceUrl);
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/SearchOperations.java
// public interface SearchOperations {
//
// /**
// * Execute SOSL Query and retrieve results
// *
// * @param soslQuery The SOSL Query to execute
// * @return List of ResultItem
// */
// List<ResultItem> search(String soslQuery);
//
//
// }
| import com.fasterxml.jackson.databind.JsonNode;
import org.springframework.social.salesforce.api.ResultItem;
import org.springframework.social.salesforce.api.Salesforce;
import org.springframework.social.salesforce.api.SearchOperations;
import org.springframework.social.support.URIBuilder;
import org.springframework.web.client.RestTemplate;
import java.net.URI;
import java.util.List; | /**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.impl;
/**
* Default implementation of SearchOperations.
*
* @author Umut Utkan
* @author Jared Ottley
*/
public class SearchTemplate extends AbstractSalesForceOperations<Salesforce> implements SearchOperations {
private RestTemplate restTemplate;
public SearchTemplate(Salesforce api, RestTemplate restTemplate) {
super(api);
this.restTemplate = restTemplate;
}
/**
* @see org.springframework.social.salesforce.api.SearchOperations#search(java.lang.String)
*/
@Override | // Path: src/main/java/org/springframework/social/salesforce/api/ResultItem.java
// public class ResultItem implements Serializable {
//
// private String type;
//
// private String url;
//
// private Map attributes;
//
//
// public ResultItem(String type, String url) {
// this.type = type;
// this.url = url;
// this.attributes = new HashMap();
// }
//
//
// public String getType() {
// return this.type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public String getUrl() {
// return this.url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public Map getAttributes() {
// return attributes;
// }
//
// public void setAttributes(Map attributes) {
// this.attributes = attributes;
// }
//
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/Salesforce.java
// public interface Salesforce extends ApiBinding {
//
// public ApiOperations apiOperations();
//
// public ApiOperations apiOperations(String instanceUrl);
//
// public ChatterOperations chatterOperations();
//
// public ChatterOperations chatterOperations(String instanceUrl);
//
// public QueryOperations queryOperations();
//
// public QueryOperations queryOperations(String instanceUrl);
//
// public RecentOperations recentOperations();
//
// public RecentOperations recentOperations(String instanceUrl);
//
// public SearchOperations searchOperations();
//
// public SearchOperations searchOperations(String instanceUrl);
//
// public SObjectOperations sObjectsOperations();
//
// public SObjectOperations sObjectsOperations(String instanceUrl);
//
// public UserOperations userOperations();
//
// public UserOperations userOperations(String gatewayUrl);
//
// public LimitsOperations limitsOperations();
//
// public LimitsOperations limitsOperations(String instanceUrl);
//
// public <T> List<T> readList(JsonNode jsonNode, Class<T> type);
//
// public <T> T readObject(JsonNode jsonNode, Class<T> type);
//
// public String getBaseUrl();
//
// public String getInstanceUrl();
//
// public void setInstanceUrl(String instanceUrl);
//
// public String getUserInfoUrl();
//
// public String getAuthGatewayUrl();
//
// public void setAuthGatewayBaseUrl(String gatewayUrl);
//
// public ConnectOperations connectOperations();
//
// public ConnectOperations connectOperations(String instanceUrl);
//
// public CustomApiOperations customApiOperations();
//
// public CustomApiOperations customApiOperations(String instanceUrl);
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/SearchOperations.java
// public interface SearchOperations {
//
// /**
// * Execute SOSL Query and retrieve results
// *
// * @param soslQuery The SOSL Query to execute
// * @return List of ResultItem
// */
// List<ResultItem> search(String soslQuery);
//
//
// }
// Path: src/main/java/org/springframework/social/salesforce/api/impl/SearchTemplate.java
import com.fasterxml.jackson.databind.JsonNode;
import org.springframework.social.salesforce.api.ResultItem;
import org.springframework.social.salesforce.api.Salesforce;
import org.springframework.social.salesforce.api.SearchOperations;
import org.springframework.social.support.URIBuilder;
import org.springframework.web.client.RestTemplate;
import java.net.URI;
import java.util.List;
/**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.impl;
/**
* Default implementation of SearchOperations.
*
* @author Umut Utkan
* @author Jared Ottley
*/
public class SearchTemplate extends AbstractSalesForceOperations<Salesforce> implements SearchOperations {
private RestTemplate restTemplate;
public SearchTemplate(Salesforce api, RestTemplate restTemplate) {
super(api);
this.restTemplate = restTemplate;
}
/**
* @see org.springframework.social.salesforce.api.SearchOperations#search(java.lang.String)
*/
@Override | public List<ResultItem> search(String soslQuery) { |
jottley/spring-social-salesforce | src/main/java/org/springframework/social/salesforce/connect/SalesforceAdapter.java | // Path: src/main/java/org/springframework/social/salesforce/api/Salesforce.java
// public interface Salesforce extends ApiBinding {
//
// public ApiOperations apiOperations();
//
// public ApiOperations apiOperations(String instanceUrl);
//
// public ChatterOperations chatterOperations();
//
// public ChatterOperations chatterOperations(String instanceUrl);
//
// public QueryOperations queryOperations();
//
// public QueryOperations queryOperations(String instanceUrl);
//
// public RecentOperations recentOperations();
//
// public RecentOperations recentOperations(String instanceUrl);
//
// public SearchOperations searchOperations();
//
// public SearchOperations searchOperations(String instanceUrl);
//
// public SObjectOperations sObjectsOperations();
//
// public SObjectOperations sObjectsOperations(String instanceUrl);
//
// public UserOperations userOperations();
//
// public UserOperations userOperations(String gatewayUrl);
//
// public LimitsOperations limitsOperations();
//
// public LimitsOperations limitsOperations(String instanceUrl);
//
// public <T> List<T> readList(JsonNode jsonNode, Class<T> type);
//
// public <T> T readObject(JsonNode jsonNode, Class<T> type);
//
// public String getBaseUrl();
//
// public String getInstanceUrl();
//
// public void setInstanceUrl(String instanceUrl);
//
// public String getUserInfoUrl();
//
// public String getAuthGatewayUrl();
//
// public void setAuthGatewayBaseUrl(String gatewayUrl);
//
// public ConnectOperations connectOperations();
//
// public ConnectOperations connectOperations(String instanceUrl);
//
// public CustomApiOperations customApiOperations();
//
// public CustomApiOperations customApiOperations(String instanceUrl);
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/SalesforceProfile.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class SalesforceProfile implements Serializable {
// protected String id;
//
// protected String email;
//
// protected String firstName;
//
// protected String lastName;
//
// protected Photo photo;
//
// protected String name;
//
//
// /*public SalesforceProfile(String id, String firstName, String lastName, String email) {
// this.id = id;
// this.firstName = firstName;
// this.lastName = lastName;
// this.email = email;
// }*/
//
//
// public String getId() {
// return id;
// }
//
// public String getEmail() {
// return email;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public Photo getPhoto() {
// return this.photo;
// }
//
// public String getName() {
// return this.name;
// }
//
// public String getUsername() {
// return this.id;
// }
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/SalesforceUserDetails.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class SalesforceUserDetails extends SalesforceProfile {
// private String organizationId;
//
// private String nickname;
//
// private String preferredUsername;
//
// public SalesforceUserDetails(String id, String firstName, String lastName,
// String email, String name, String organizationId, String nickname,
// String preferredUsername) {
// super();
// this.id = id;
// this.firstName = firstName;
// this.lastName = lastName;
// this.email = email;
// this.name = name;
// this.organizationId = organizationId;
// this.nickname = nickname;
// this.preferredUsername = preferredUsername;
// }
//
// public String getOrganizationId() {
// return organizationId;
// }
//
// public String getNickname() {
// return nickname;
// }
//
// public String getPreferredUsername() {
// return preferredUsername;
// }
// }
| import org.springframework.social.ApiException;
import org.springframework.social.connect.ApiAdapter;
import org.springframework.social.connect.ConnectionValues;
import org.springframework.social.connect.UserProfile;
import org.springframework.social.connect.UserProfileBuilder;
import org.springframework.social.salesforce.api.Salesforce;
import org.springframework.social.salesforce.api.SalesforceProfile;
import org.springframework.social.salesforce.api.SalesforceUserDetails;
import org.springframework.util.StringUtils; |
public SalesforceAdapter(boolean sandbox)
{
if (sandbox)
{
this.gatewayUrl = SalesforceServiceProvider.SANDBOX_GATEWAY_URL;
}
}
public boolean test(Salesforce salesForce)
{
try
{
if (StringUtils.isEmpty(instanceUrl))
{
salesForce.chatterOperations().getUserProfile();
}
else
{
salesForce.chatterOperations(instanceUrl).getUserProfile();
}
return true;
}
catch (ApiException e)
{
return false;
}
}
public void setConnectionValues(Salesforce salesforce, ConnectionValues values) { | // Path: src/main/java/org/springframework/social/salesforce/api/Salesforce.java
// public interface Salesforce extends ApiBinding {
//
// public ApiOperations apiOperations();
//
// public ApiOperations apiOperations(String instanceUrl);
//
// public ChatterOperations chatterOperations();
//
// public ChatterOperations chatterOperations(String instanceUrl);
//
// public QueryOperations queryOperations();
//
// public QueryOperations queryOperations(String instanceUrl);
//
// public RecentOperations recentOperations();
//
// public RecentOperations recentOperations(String instanceUrl);
//
// public SearchOperations searchOperations();
//
// public SearchOperations searchOperations(String instanceUrl);
//
// public SObjectOperations sObjectsOperations();
//
// public SObjectOperations sObjectsOperations(String instanceUrl);
//
// public UserOperations userOperations();
//
// public UserOperations userOperations(String gatewayUrl);
//
// public LimitsOperations limitsOperations();
//
// public LimitsOperations limitsOperations(String instanceUrl);
//
// public <T> List<T> readList(JsonNode jsonNode, Class<T> type);
//
// public <T> T readObject(JsonNode jsonNode, Class<T> type);
//
// public String getBaseUrl();
//
// public String getInstanceUrl();
//
// public void setInstanceUrl(String instanceUrl);
//
// public String getUserInfoUrl();
//
// public String getAuthGatewayUrl();
//
// public void setAuthGatewayBaseUrl(String gatewayUrl);
//
// public ConnectOperations connectOperations();
//
// public ConnectOperations connectOperations(String instanceUrl);
//
// public CustomApiOperations customApiOperations();
//
// public CustomApiOperations customApiOperations(String instanceUrl);
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/SalesforceProfile.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class SalesforceProfile implements Serializable {
// protected String id;
//
// protected String email;
//
// protected String firstName;
//
// protected String lastName;
//
// protected Photo photo;
//
// protected String name;
//
//
// /*public SalesforceProfile(String id, String firstName, String lastName, String email) {
// this.id = id;
// this.firstName = firstName;
// this.lastName = lastName;
// this.email = email;
// }*/
//
//
// public String getId() {
// return id;
// }
//
// public String getEmail() {
// return email;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public Photo getPhoto() {
// return this.photo;
// }
//
// public String getName() {
// return this.name;
// }
//
// public String getUsername() {
// return this.id;
// }
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/SalesforceUserDetails.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class SalesforceUserDetails extends SalesforceProfile {
// private String organizationId;
//
// private String nickname;
//
// private String preferredUsername;
//
// public SalesforceUserDetails(String id, String firstName, String lastName,
// String email, String name, String organizationId, String nickname,
// String preferredUsername) {
// super();
// this.id = id;
// this.firstName = firstName;
// this.lastName = lastName;
// this.email = email;
// this.name = name;
// this.organizationId = organizationId;
// this.nickname = nickname;
// this.preferredUsername = preferredUsername;
// }
//
// public String getOrganizationId() {
// return organizationId;
// }
//
// public String getNickname() {
// return nickname;
// }
//
// public String getPreferredUsername() {
// return preferredUsername;
// }
// }
// Path: src/main/java/org/springframework/social/salesforce/connect/SalesforceAdapter.java
import org.springframework.social.ApiException;
import org.springframework.social.connect.ApiAdapter;
import org.springframework.social.connect.ConnectionValues;
import org.springframework.social.connect.UserProfile;
import org.springframework.social.connect.UserProfileBuilder;
import org.springframework.social.salesforce.api.Salesforce;
import org.springframework.social.salesforce.api.SalesforceProfile;
import org.springframework.social.salesforce.api.SalesforceUserDetails;
import org.springframework.util.StringUtils;
public SalesforceAdapter(boolean sandbox)
{
if (sandbox)
{
this.gatewayUrl = SalesforceServiceProvider.SANDBOX_GATEWAY_URL;
}
}
public boolean test(Salesforce salesForce)
{
try
{
if (StringUtils.isEmpty(instanceUrl))
{
salesForce.chatterOperations().getUserProfile();
}
else
{
salesForce.chatterOperations(instanceUrl).getUserProfile();
}
return true;
}
catch (ApiException e)
{
return false;
}
}
public void setConnectionValues(Salesforce salesforce, ConnectionValues values) { | SalesforceUserDetails userDetails; |
jottley/spring-social-salesforce | src/main/java/org/springframework/social/salesforce/connect/SalesforceAdapter.java | // Path: src/main/java/org/springframework/social/salesforce/api/Salesforce.java
// public interface Salesforce extends ApiBinding {
//
// public ApiOperations apiOperations();
//
// public ApiOperations apiOperations(String instanceUrl);
//
// public ChatterOperations chatterOperations();
//
// public ChatterOperations chatterOperations(String instanceUrl);
//
// public QueryOperations queryOperations();
//
// public QueryOperations queryOperations(String instanceUrl);
//
// public RecentOperations recentOperations();
//
// public RecentOperations recentOperations(String instanceUrl);
//
// public SearchOperations searchOperations();
//
// public SearchOperations searchOperations(String instanceUrl);
//
// public SObjectOperations sObjectsOperations();
//
// public SObjectOperations sObjectsOperations(String instanceUrl);
//
// public UserOperations userOperations();
//
// public UserOperations userOperations(String gatewayUrl);
//
// public LimitsOperations limitsOperations();
//
// public LimitsOperations limitsOperations(String instanceUrl);
//
// public <T> List<T> readList(JsonNode jsonNode, Class<T> type);
//
// public <T> T readObject(JsonNode jsonNode, Class<T> type);
//
// public String getBaseUrl();
//
// public String getInstanceUrl();
//
// public void setInstanceUrl(String instanceUrl);
//
// public String getUserInfoUrl();
//
// public String getAuthGatewayUrl();
//
// public void setAuthGatewayBaseUrl(String gatewayUrl);
//
// public ConnectOperations connectOperations();
//
// public ConnectOperations connectOperations(String instanceUrl);
//
// public CustomApiOperations customApiOperations();
//
// public CustomApiOperations customApiOperations(String instanceUrl);
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/SalesforceProfile.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class SalesforceProfile implements Serializable {
// protected String id;
//
// protected String email;
//
// protected String firstName;
//
// protected String lastName;
//
// protected Photo photo;
//
// protected String name;
//
//
// /*public SalesforceProfile(String id, String firstName, String lastName, String email) {
// this.id = id;
// this.firstName = firstName;
// this.lastName = lastName;
// this.email = email;
// }*/
//
//
// public String getId() {
// return id;
// }
//
// public String getEmail() {
// return email;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public Photo getPhoto() {
// return this.photo;
// }
//
// public String getName() {
// return this.name;
// }
//
// public String getUsername() {
// return this.id;
// }
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/SalesforceUserDetails.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class SalesforceUserDetails extends SalesforceProfile {
// private String organizationId;
//
// private String nickname;
//
// private String preferredUsername;
//
// public SalesforceUserDetails(String id, String firstName, String lastName,
// String email, String name, String organizationId, String nickname,
// String preferredUsername) {
// super();
// this.id = id;
// this.firstName = firstName;
// this.lastName = lastName;
// this.email = email;
// this.name = name;
// this.organizationId = organizationId;
// this.nickname = nickname;
// this.preferredUsername = preferredUsername;
// }
//
// public String getOrganizationId() {
// return organizationId;
// }
//
// public String getNickname() {
// return nickname;
// }
//
// public String getPreferredUsername() {
// return preferredUsername;
// }
// }
| import org.springframework.social.ApiException;
import org.springframework.social.connect.ApiAdapter;
import org.springframework.social.connect.ConnectionValues;
import org.springframework.social.connect.UserProfile;
import org.springframework.social.connect.UserProfileBuilder;
import org.springframework.social.salesforce.api.Salesforce;
import org.springframework.social.salesforce.api.SalesforceProfile;
import org.springframework.social.salesforce.api.SalesforceUserDetails;
import org.springframework.util.StringUtils; | {
salesForce.chatterOperations().getUserProfile();
}
else
{
salesForce.chatterOperations(instanceUrl).getUserProfile();
}
return true;
}
catch (ApiException e)
{
return false;
}
}
public void setConnectionValues(Salesforce salesforce, ConnectionValues values) {
SalesforceUserDetails userDetails;
if (StringUtils.isEmpty(gatewayUrl))
{
userDetails = salesforce.userOperations().getSalesforceUserDetails();
}
else
{
userDetails = salesforce.userOperations(gatewayUrl).getSalesforceUserDetails();
}
values.setProviderUserId(userDetails.getId());
values.setDisplayName(userDetails.getName());
}
public UserProfile fetchUserProfile(Salesforce salesforce) { | // Path: src/main/java/org/springframework/social/salesforce/api/Salesforce.java
// public interface Salesforce extends ApiBinding {
//
// public ApiOperations apiOperations();
//
// public ApiOperations apiOperations(String instanceUrl);
//
// public ChatterOperations chatterOperations();
//
// public ChatterOperations chatterOperations(String instanceUrl);
//
// public QueryOperations queryOperations();
//
// public QueryOperations queryOperations(String instanceUrl);
//
// public RecentOperations recentOperations();
//
// public RecentOperations recentOperations(String instanceUrl);
//
// public SearchOperations searchOperations();
//
// public SearchOperations searchOperations(String instanceUrl);
//
// public SObjectOperations sObjectsOperations();
//
// public SObjectOperations sObjectsOperations(String instanceUrl);
//
// public UserOperations userOperations();
//
// public UserOperations userOperations(String gatewayUrl);
//
// public LimitsOperations limitsOperations();
//
// public LimitsOperations limitsOperations(String instanceUrl);
//
// public <T> List<T> readList(JsonNode jsonNode, Class<T> type);
//
// public <T> T readObject(JsonNode jsonNode, Class<T> type);
//
// public String getBaseUrl();
//
// public String getInstanceUrl();
//
// public void setInstanceUrl(String instanceUrl);
//
// public String getUserInfoUrl();
//
// public String getAuthGatewayUrl();
//
// public void setAuthGatewayBaseUrl(String gatewayUrl);
//
// public ConnectOperations connectOperations();
//
// public ConnectOperations connectOperations(String instanceUrl);
//
// public CustomApiOperations customApiOperations();
//
// public CustomApiOperations customApiOperations(String instanceUrl);
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/SalesforceProfile.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class SalesforceProfile implements Serializable {
// protected String id;
//
// protected String email;
//
// protected String firstName;
//
// protected String lastName;
//
// protected Photo photo;
//
// protected String name;
//
//
// /*public SalesforceProfile(String id, String firstName, String lastName, String email) {
// this.id = id;
// this.firstName = firstName;
// this.lastName = lastName;
// this.email = email;
// }*/
//
//
// public String getId() {
// return id;
// }
//
// public String getEmail() {
// return email;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public Photo getPhoto() {
// return this.photo;
// }
//
// public String getName() {
// return this.name;
// }
//
// public String getUsername() {
// return this.id;
// }
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/SalesforceUserDetails.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class SalesforceUserDetails extends SalesforceProfile {
// private String organizationId;
//
// private String nickname;
//
// private String preferredUsername;
//
// public SalesforceUserDetails(String id, String firstName, String lastName,
// String email, String name, String organizationId, String nickname,
// String preferredUsername) {
// super();
// this.id = id;
// this.firstName = firstName;
// this.lastName = lastName;
// this.email = email;
// this.name = name;
// this.organizationId = organizationId;
// this.nickname = nickname;
// this.preferredUsername = preferredUsername;
// }
//
// public String getOrganizationId() {
// return organizationId;
// }
//
// public String getNickname() {
// return nickname;
// }
//
// public String getPreferredUsername() {
// return preferredUsername;
// }
// }
// Path: src/main/java/org/springframework/social/salesforce/connect/SalesforceAdapter.java
import org.springframework.social.ApiException;
import org.springframework.social.connect.ApiAdapter;
import org.springframework.social.connect.ConnectionValues;
import org.springframework.social.connect.UserProfile;
import org.springframework.social.connect.UserProfileBuilder;
import org.springframework.social.salesforce.api.Salesforce;
import org.springframework.social.salesforce.api.SalesforceProfile;
import org.springframework.social.salesforce.api.SalesforceUserDetails;
import org.springframework.util.StringUtils;
{
salesForce.chatterOperations().getUserProfile();
}
else
{
salesForce.chatterOperations(instanceUrl).getUserProfile();
}
return true;
}
catch (ApiException e)
{
return false;
}
}
public void setConnectionValues(Salesforce salesforce, ConnectionValues values) {
SalesforceUserDetails userDetails;
if (StringUtils.isEmpty(gatewayUrl))
{
userDetails = salesforce.userOperations().getSalesforceUserDetails();
}
else
{
userDetails = salesforce.userOperations(gatewayUrl).getSalesforceUserDetails();
}
values.setProviderUserId(userDetails.getId());
values.setDisplayName(userDetails.getName());
}
public UserProfile fetchUserProfile(Salesforce salesforce) { | SalesforceProfile profile; |
jottley/spring-social-salesforce | src/main/java/org/springframework/social/salesforce/api/InvalidIDException.java | // Path: src/main/java/org/springframework/social/salesforce/connect/SalesforceServiceProvider.java
// public class SalesforceServiceProvider extends AbstractOAuth2ServiceProvider<Salesforce> {
//
// //Provider ID
// public final static String ID = "salesforce";
//
// public final static String PRODUCTION_GATEWAY_URL = "https://login.salesforce.com";
// public final static String SANDBOX_GATEWAY_URL = "https://test.salesforce.com";
//
// public final static String TOKEN_PATH = "/services/oauth2/token";
// public final static String AUTHORIZE_PATH = "/services/oauth2/authorize";
//
// public SalesforceServiceProvider(String clientId, String clientSecret) {
// this(clientId, clientSecret,
// PRODUCTION_GATEWAY_URL + AUTHORIZE_PATH,
// PRODUCTION_GATEWAY_URL + TOKEN_PATH);
// }
//
// public SalesforceServiceProvider(String clientId, String clientSecret, boolean sandbox)
// {
// super(new SalesforceOAuth2Template(clientId, clientSecret, (sandbox ? SANDBOX_GATEWAY_URL : PRODUCTION_GATEWAY_URL) + AUTHORIZE_PATH, (sandbox ? SANDBOX_GATEWAY_URL : PRODUCTION_GATEWAY_URL) + TOKEN_PATH));
// }
//
// public SalesforceServiceProvider(String clientId, String clientSecret, String authorizeUrl, String tokenUrl) {
// super(new SalesforceOAuth2Template(clientId, clientSecret, authorizeUrl, tokenUrl));
// }
//
//
// public Salesforce getApi(String accessToken) {
// SalesforceTemplate template = new SalesforceTemplate(accessToken);
//
// // gets the returned instance url and sets to Salesforce template as base url.
// String instanceUrl = ((SalesforceOAuth2Template) getOAuthOperations()).getInstanceUrl();
// if (instanceUrl != null) {
// template.setInstanceUrl(instanceUrl);
// }
//
// return template;
// }
//
// }
| import org.springframework.social.ApiException;
import org.springframework.social.salesforce.connect.SalesforceServiceProvider; | /**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api;
/**
* @author Umut Utkan
* @author Jared Ottley
*/
public class InvalidIDException extends ApiException {
public InvalidIDException(String message) { | // Path: src/main/java/org/springframework/social/salesforce/connect/SalesforceServiceProvider.java
// public class SalesforceServiceProvider extends AbstractOAuth2ServiceProvider<Salesforce> {
//
// //Provider ID
// public final static String ID = "salesforce";
//
// public final static String PRODUCTION_GATEWAY_URL = "https://login.salesforce.com";
// public final static String SANDBOX_GATEWAY_URL = "https://test.salesforce.com";
//
// public final static String TOKEN_PATH = "/services/oauth2/token";
// public final static String AUTHORIZE_PATH = "/services/oauth2/authorize";
//
// public SalesforceServiceProvider(String clientId, String clientSecret) {
// this(clientId, clientSecret,
// PRODUCTION_GATEWAY_URL + AUTHORIZE_PATH,
// PRODUCTION_GATEWAY_URL + TOKEN_PATH);
// }
//
// public SalesforceServiceProvider(String clientId, String clientSecret, boolean sandbox)
// {
// super(new SalesforceOAuth2Template(clientId, clientSecret, (sandbox ? SANDBOX_GATEWAY_URL : PRODUCTION_GATEWAY_URL) + AUTHORIZE_PATH, (sandbox ? SANDBOX_GATEWAY_URL : PRODUCTION_GATEWAY_URL) + TOKEN_PATH));
// }
//
// public SalesforceServiceProvider(String clientId, String clientSecret, String authorizeUrl, String tokenUrl) {
// super(new SalesforceOAuth2Template(clientId, clientSecret, authorizeUrl, tokenUrl));
// }
//
//
// public Salesforce getApi(String accessToken) {
// SalesforceTemplate template = new SalesforceTemplate(accessToken);
//
// // gets the returned instance url and sets to Salesforce template as base url.
// String instanceUrl = ((SalesforceOAuth2Template) getOAuthOperations()).getInstanceUrl();
// if (instanceUrl != null) {
// template.setInstanceUrl(instanceUrl);
// }
//
// return template;
// }
//
// }
// Path: src/main/java/org/springframework/social/salesforce/api/InvalidIDException.java
import org.springframework.social.ApiException;
import org.springframework.social.salesforce.connect.SalesforceServiceProvider;
/**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api;
/**
* @author Umut Utkan
* @author Jared Ottley
*/
public class InvalidIDException extends ApiException {
public InvalidIDException(String message) { | super(SalesforceServiceProvider.ID, message); |
jottley/spring-social-salesforce | src/main/java/org/springframework/social/salesforce/security/SalesforceAuthenticationService.java | // Path: src/main/java/org/springframework/social/salesforce/api/Salesforce.java
// public interface Salesforce extends ApiBinding {
//
// public ApiOperations apiOperations();
//
// public ApiOperations apiOperations(String instanceUrl);
//
// public ChatterOperations chatterOperations();
//
// public ChatterOperations chatterOperations(String instanceUrl);
//
// public QueryOperations queryOperations();
//
// public QueryOperations queryOperations(String instanceUrl);
//
// public RecentOperations recentOperations();
//
// public RecentOperations recentOperations(String instanceUrl);
//
// public SearchOperations searchOperations();
//
// public SearchOperations searchOperations(String instanceUrl);
//
// public SObjectOperations sObjectsOperations();
//
// public SObjectOperations sObjectsOperations(String instanceUrl);
//
// public UserOperations userOperations();
//
// public UserOperations userOperations(String gatewayUrl);
//
// public LimitsOperations limitsOperations();
//
// public LimitsOperations limitsOperations(String instanceUrl);
//
// public <T> List<T> readList(JsonNode jsonNode, Class<T> type);
//
// public <T> T readObject(JsonNode jsonNode, Class<T> type);
//
// public String getBaseUrl();
//
// public String getInstanceUrl();
//
// public void setInstanceUrl(String instanceUrl);
//
// public String getUserInfoUrl();
//
// public String getAuthGatewayUrl();
//
// public void setAuthGatewayBaseUrl(String gatewayUrl);
//
// public ConnectOperations connectOperations();
//
// public ConnectOperations connectOperations(String instanceUrl);
//
// public CustomApiOperations customApiOperations();
//
// public CustomApiOperations customApiOperations(String instanceUrl);
// }
//
// Path: src/main/java/org/springframework/social/salesforce/connect/SalesforceConnectionFactory.java
// public class SalesforceConnectionFactory extends OAuth2ConnectionFactory<Salesforce> {
//
// public SalesforceConnectionFactory(String clientId, String clientSecret) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret),
// new SalesforceAdapter());
// }
//
// public SalesforceConnectionFactory(String clientId, String clientSecret, boolean sandbox) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret, sandbox),
// sandbox ? new SalesforceAdapter(sandbox) : new SalesforceAdapter());
// }
//
// public SalesforceConnectionFactory(String clientId, String clientSecret, String instanceUrl) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret),
// new SalesforceAdapter(instanceUrl));
// }
//
// public SalesforceConnectionFactory(String clientId, String clientSecret, String instanceUrl, boolean sandbox) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret, sandbox),
// sandbox ? new SalesforceAdapter(instanceUrl, sandbox) : new SalesforceAdapter(instanceUrl));
// }
//
// @Deprecated
// public SalesforceConnectionFactory(String clientId, String clientSecret, String authorizeUrl, String tokenUrl) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret,
// authorizeUrl, tokenUrl), new SalesforceAdapter());
// }
//
// @Deprecated
// public SalesforceConnectionFactory(String clientId, String clientSecret, String authorizeUrl, String tokenUrl, String instanceUrl) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret,
// authorizeUrl, tokenUrl), new SalesforceAdapter(instanceUrl));
// }
//
// @Deprecated
// public SalesforceConnectionFactory(String clientId, String clientSecret, String authorizeUrl, String tokenUrl, String instanceUrl, String gatewayUrl) {
// super("salesforce", new SalesforceServiceProvider(clientId, clientSecret,
// authorizeUrl, tokenUrl), new SalesforceAdapter(instanceUrl, gatewayUrl));
// }
//
// }
| import org.springframework.social.salesforce.api.Salesforce;
import org.springframework.social.salesforce.connect.SalesforceConnectionFactory;
import org.springframework.social.security.provider.OAuth2AuthenticationService; | /**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.security;
/**
*
* @author Jared Ottley
*
*/
public class SalesforceAuthenticationService extends OAuth2AuthenticationService<Salesforce>
{
public SalesforceAuthenticationService(String consumerKey, String consumerSecret)
{ | // Path: src/main/java/org/springframework/social/salesforce/api/Salesforce.java
// public interface Salesforce extends ApiBinding {
//
// public ApiOperations apiOperations();
//
// public ApiOperations apiOperations(String instanceUrl);
//
// public ChatterOperations chatterOperations();
//
// public ChatterOperations chatterOperations(String instanceUrl);
//
// public QueryOperations queryOperations();
//
// public QueryOperations queryOperations(String instanceUrl);
//
// public RecentOperations recentOperations();
//
// public RecentOperations recentOperations(String instanceUrl);
//
// public SearchOperations searchOperations();
//
// public SearchOperations searchOperations(String instanceUrl);
//
// public SObjectOperations sObjectsOperations();
//
// public SObjectOperations sObjectsOperations(String instanceUrl);
//
// public UserOperations userOperations();
//
// public UserOperations userOperations(String gatewayUrl);
//
// public LimitsOperations limitsOperations();
//
// public LimitsOperations limitsOperations(String instanceUrl);
//
// public <T> List<T> readList(JsonNode jsonNode, Class<T> type);
//
// public <T> T readObject(JsonNode jsonNode, Class<T> type);
//
// public String getBaseUrl();
//
// public String getInstanceUrl();
//
// public void setInstanceUrl(String instanceUrl);
//
// public String getUserInfoUrl();
//
// public String getAuthGatewayUrl();
//
// public void setAuthGatewayBaseUrl(String gatewayUrl);
//
// public ConnectOperations connectOperations();
//
// public ConnectOperations connectOperations(String instanceUrl);
//
// public CustomApiOperations customApiOperations();
//
// public CustomApiOperations customApiOperations(String instanceUrl);
// }
//
// Path: src/main/java/org/springframework/social/salesforce/connect/SalesforceConnectionFactory.java
// public class SalesforceConnectionFactory extends OAuth2ConnectionFactory<Salesforce> {
//
// public SalesforceConnectionFactory(String clientId, String clientSecret) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret),
// new SalesforceAdapter());
// }
//
// public SalesforceConnectionFactory(String clientId, String clientSecret, boolean sandbox) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret, sandbox),
// sandbox ? new SalesforceAdapter(sandbox) : new SalesforceAdapter());
// }
//
// public SalesforceConnectionFactory(String clientId, String clientSecret, String instanceUrl) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret),
// new SalesforceAdapter(instanceUrl));
// }
//
// public SalesforceConnectionFactory(String clientId, String clientSecret, String instanceUrl, boolean sandbox) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret, sandbox),
// sandbox ? new SalesforceAdapter(instanceUrl, sandbox) : new SalesforceAdapter(instanceUrl));
// }
//
// @Deprecated
// public SalesforceConnectionFactory(String clientId, String clientSecret, String authorizeUrl, String tokenUrl) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret,
// authorizeUrl, tokenUrl), new SalesforceAdapter());
// }
//
// @Deprecated
// public SalesforceConnectionFactory(String clientId, String clientSecret, String authorizeUrl, String tokenUrl, String instanceUrl) {
// super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret,
// authorizeUrl, tokenUrl), new SalesforceAdapter(instanceUrl));
// }
//
// @Deprecated
// public SalesforceConnectionFactory(String clientId, String clientSecret, String authorizeUrl, String tokenUrl, String instanceUrl, String gatewayUrl) {
// super("salesforce", new SalesforceServiceProvider(clientId, clientSecret,
// authorizeUrl, tokenUrl), new SalesforceAdapter(instanceUrl, gatewayUrl));
// }
//
// }
// Path: src/main/java/org/springframework/social/salesforce/security/SalesforceAuthenticationService.java
import org.springframework.social.salesforce.api.Salesforce;
import org.springframework.social.salesforce.connect.SalesforceConnectionFactory;
import org.springframework.social.security.provider.OAuth2AuthenticationService;
/**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.security;
/**
*
* @author Jared Ottley
*
*/
public class SalesforceAuthenticationService extends OAuth2AuthenticationService<Salesforce>
{
public SalesforceAuthenticationService(String consumerKey, String consumerSecret)
{ | super(new SalesforceConnectionFactory(consumerKey, consumerSecret)); |
jottley/spring-social-salesforce | src/main/java/org/springframework/social/salesforce/api/impl/UserOperationsTemplate.java | // Path: src/main/java/org/springframework/social/salesforce/api/Salesforce.java
// public interface Salesforce extends ApiBinding {
//
// public ApiOperations apiOperations();
//
// public ApiOperations apiOperations(String instanceUrl);
//
// public ChatterOperations chatterOperations();
//
// public ChatterOperations chatterOperations(String instanceUrl);
//
// public QueryOperations queryOperations();
//
// public QueryOperations queryOperations(String instanceUrl);
//
// public RecentOperations recentOperations();
//
// public RecentOperations recentOperations(String instanceUrl);
//
// public SearchOperations searchOperations();
//
// public SearchOperations searchOperations(String instanceUrl);
//
// public SObjectOperations sObjectsOperations();
//
// public SObjectOperations sObjectsOperations(String instanceUrl);
//
// public UserOperations userOperations();
//
// public UserOperations userOperations(String gatewayUrl);
//
// public LimitsOperations limitsOperations();
//
// public LimitsOperations limitsOperations(String instanceUrl);
//
// public <T> List<T> readList(JsonNode jsonNode, Class<T> type);
//
// public <T> T readObject(JsonNode jsonNode, Class<T> type);
//
// public String getBaseUrl();
//
// public String getInstanceUrl();
//
// public void setInstanceUrl(String instanceUrl);
//
// public String getUserInfoUrl();
//
// public String getAuthGatewayUrl();
//
// public void setAuthGatewayBaseUrl(String gatewayUrl);
//
// public ConnectOperations connectOperations();
//
// public ConnectOperations connectOperations(String instanceUrl);
//
// public CustomApiOperations customApiOperations();
//
// public CustomApiOperations customApiOperations(String instanceUrl);
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/SalesforceUserDetails.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class SalesforceUserDetails extends SalesforceProfile {
// private String organizationId;
//
// private String nickname;
//
// private String preferredUsername;
//
// public SalesforceUserDetails(String id, String firstName, String lastName,
// String email, String name, String organizationId, String nickname,
// String preferredUsername) {
// super();
// this.id = id;
// this.firstName = firstName;
// this.lastName = lastName;
// this.email = email;
// this.name = name;
// this.organizationId = organizationId;
// this.nickname = nickname;
// this.preferredUsername = preferredUsername;
// }
//
// public String getOrganizationId() {
// return organizationId;
// }
//
// public String getNickname() {
// return nickname;
// }
//
// public String getPreferredUsername() {
// return preferredUsername;
// }
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/UserOperations.java
// public interface UserOperations {
//
// /**
// * Retrieves the details for the current logged in user.
// * @return user details
// */
// SalesforceUserDetails getSalesforceUserDetails();
//
// }
| import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.social.salesforce.api.Salesforce;
import org.springframework.social.salesforce.api.SalesforceUserDetails;
import org.springframework.social.salesforce.api.UserOperations;
import org.springframework.web.client.RestTemplate; | /**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.impl;
/**
* Default implementation of UserOperations.
*
* @author Alexandra Leahu
* @author Jared Ottley
*/
public class UserOperationsTemplate extends AbstractSalesForceOperations<Salesforce> implements UserOperations {
private RestTemplate restTemplate;
public UserOperationsTemplate(Salesforce api, RestTemplate restTemplate) {
super(api);
this.restTemplate = restTemplate;
}
@Override | // Path: src/main/java/org/springframework/social/salesforce/api/Salesforce.java
// public interface Salesforce extends ApiBinding {
//
// public ApiOperations apiOperations();
//
// public ApiOperations apiOperations(String instanceUrl);
//
// public ChatterOperations chatterOperations();
//
// public ChatterOperations chatterOperations(String instanceUrl);
//
// public QueryOperations queryOperations();
//
// public QueryOperations queryOperations(String instanceUrl);
//
// public RecentOperations recentOperations();
//
// public RecentOperations recentOperations(String instanceUrl);
//
// public SearchOperations searchOperations();
//
// public SearchOperations searchOperations(String instanceUrl);
//
// public SObjectOperations sObjectsOperations();
//
// public SObjectOperations sObjectsOperations(String instanceUrl);
//
// public UserOperations userOperations();
//
// public UserOperations userOperations(String gatewayUrl);
//
// public LimitsOperations limitsOperations();
//
// public LimitsOperations limitsOperations(String instanceUrl);
//
// public <T> List<T> readList(JsonNode jsonNode, Class<T> type);
//
// public <T> T readObject(JsonNode jsonNode, Class<T> type);
//
// public String getBaseUrl();
//
// public String getInstanceUrl();
//
// public void setInstanceUrl(String instanceUrl);
//
// public String getUserInfoUrl();
//
// public String getAuthGatewayUrl();
//
// public void setAuthGatewayBaseUrl(String gatewayUrl);
//
// public ConnectOperations connectOperations();
//
// public ConnectOperations connectOperations(String instanceUrl);
//
// public CustomApiOperations customApiOperations();
//
// public CustomApiOperations customApiOperations(String instanceUrl);
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/SalesforceUserDetails.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class SalesforceUserDetails extends SalesforceProfile {
// private String organizationId;
//
// private String nickname;
//
// private String preferredUsername;
//
// public SalesforceUserDetails(String id, String firstName, String lastName,
// String email, String name, String organizationId, String nickname,
// String preferredUsername) {
// super();
// this.id = id;
// this.firstName = firstName;
// this.lastName = lastName;
// this.email = email;
// this.name = name;
// this.organizationId = organizationId;
// this.nickname = nickname;
// this.preferredUsername = preferredUsername;
// }
//
// public String getOrganizationId() {
// return organizationId;
// }
//
// public String getNickname() {
// return nickname;
// }
//
// public String getPreferredUsername() {
// return preferredUsername;
// }
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/UserOperations.java
// public interface UserOperations {
//
// /**
// * Retrieves the details for the current logged in user.
// * @return user details
// */
// SalesforceUserDetails getSalesforceUserDetails();
//
// }
// Path: src/main/java/org/springframework/social/salesforce/api/impl/UserOperationsTemplate.java
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.social.salesforce.api.Salesforce;
import org.springframework.social.salesforce.api.SalesforceUserDetails;
import org.springframework.social.salesforce.api.UserOperations;
import org.springframework.web.client.RestTemplate;
/**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.impl;
/**
* Default implementation of UserOperations.
*
* @author Alexandra Leahu
* @author Jared Ottley
*/
public class UserOperationsTemplate extends AbstractSalesForceOperations<Salesforce> implements UserOperations {
private RestTemplate restTemplate;
public UserOperationsTemplate(Salesforce api, RestTemplate restTemplate) {
super(api);
this.restTemplate = restTemplate;
}
@Override | public SalesforceUserDetails getSalesforceUserDetails() { |
jottley/spring-social-salesforce | src/test/java/org/springframework/social/salesforce/api/impl/ChatterTemplateTest.java | // Path: src/main/java/org/springframework/social/salesforce/api/SalesforceProfile.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class SalesforceProfile implements Serializable {
// protected String id;
//
// protected String email;
//
// protected String firstName;
//
// protected String lastName;
//
// protected Photo photo;
//
// protected String name;
//
//
// /*public SalesforceProfile(String id, String firstName, String lastName, String email) {
// this.id = id;
// this.firstName = firstName;
// this.lastName = lastName;
// this.email = email;
// }*/
//
//
// public String getId() {
// return id;
// }
//
// public String getEmail() {
// return email;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public Photo getPhoto() {
// return this.photo;
// }
//
// public String getName() {
// return this.name;
// }
//
// public String getUsername() {
// return this.id;
// }
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/Status.java
// public class Status {
//
// private String text;
//
// private List<Map<String, String>> segments;
//
//
// public Status(String text) {
// this.text = text;
// }
//
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
//
// public List<Map<String, String>> getSegments() {
// return segments;
// }
//
// public void setSegments(List<Map<String, String>> segments) {
// this.segments = segments;
// }
//
// @Override
// public String toString() {
// return "Status{" +
// "text='" + text + '\'' +
// ", segments=" + segments +
// '}';
// }
//
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.springframework.http.HttpMethod.GET;
import static org.springframework.http.HttpMethod.POST;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.content;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus;
import org.junit.Test;
import org.springframework.http.HttpStatus;
import org.springframework.social.salesforce.api.SalesforceProfile;
import org.springframework.social.salesforce.api.Status; | /**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.impl;
/**
* @author Umut Utkan
* @author Jared Ottley
* @author Alexandru Leahu
*/
public class ChatterTemplateTest extends AbstractSalesforceTest {
@Test
public void getProfile() {
mockServer.expect(requestTo("https://na7.salesforce.com/services/data/" + salesforce.apiOperations().getVersion() + "/chatter/users/me"))
.andExpect(method(GET))
.andRespond(withStatus(HttpStatus.OK).body(loadResource("profile.json")).headers(responseHeaders)); | // Path: src/main/java/org/springframework/social/salesforce/api/SalesforceProfile.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class SalesforceProfile implements Serializable {
// protected String id;
//
// protected String email;
//
// protected String firstName;
//
// protected String lastName;
//
// protected Photo photo;
//
// protected String name;
//
//
// /*public SalesforceProfile(String id, String firstName, String lastName, String email) {
// this.id = id;
// this.firstName = firstName;
// this.lastName = lastName;
// this.email = email;
// }*/
//
//
// public String getId() {
// return id;
// }
//
// public String getEmail() {
// return email;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public Photo getPhoto() {
// return this.photo;
// }
//
// public String getName() {
// return this.name;
// }
//
// public String getUsername() {
// return this.id;
// }
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/Status.java
// public class Status {
//
// private String text;
//
// private List<Map<String, String>> segments;
//
//
// public Status(String text) {
// this.text = text;
// }
//
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
//
// public List<Map<String, String>> getSegments() {
// return segments;
// }
//
// public void setSegments(List<Map<String, String>> segments) {
// this.segments = segments;
// }
//
// @Override
// public String toString() {
// return "Status{" +
// "text='" + text + '\'' +
// ", segments=" + segments +
// '}';
// }
//
// }
// Path: src/test/java/org/springframework/social/salesforce/api/impl/ChatterTemplateTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.springframework.http.HttpMethod.GET;
import static org.springframework.http.HttpMethod.POST;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.content;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus;
import org.junit.Test;
import org.springframework.http.HttpStatus;
import org.springframework.social.salesforce.api.SalesforceProfile;
import org.springframework.social.salesforce.api.Status;
/**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.impl;
/**
* @author Umut Utkan
* @author Jared Ottley
* @author Alexandru Leahu
*/
public class ChatterTemplateTest extends AbstractSalesforceTest {
@Test
public void getProfile() {
mockServer.expect(requestTo("https://na7.salesforce.com/services/data/" + salesforce.apiOperations().getVersion() + "/chatter/users/me"))
.andExpect(method(GET))
.andRespond(withStatus(HttpStatus.OK).body(loadResource("profile.json")).headers(responseHeaders)); | SalesforceProfile profile = salesforce.chatterOperations().getUserProfile(); |
jottley/spring-social-salesforce | src/test/java/org/springframework/social/salesforce/api/impl/ChatterTemplateTest.java | // Path: src/main/java/org/springframework/social/salesforce/api/SalesforceProfile.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class SalesforceProfile implements Serializable {
// protected String id;
//
// protected String email;
//
// protected String firstName;
//
// protected String lastName;
//
// protected Photo photo;
//
// protected String name;
//
//
// /*public SalesforceProfile(String id, String firstName, String lastName, String email) {
// this.id = id;
// this.firstName = firstName;
// this.lastName = lastName;
// this.email = email;
// }*/
//
//
// public String getId() {
// return id;
// }
//
// public String getEmail() {
// return email;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public Photo getPhoto() {
// return this.photo;
// }
//
// public String getName() {
// return this.name;
// }
//
// public String getUsername() {
// return this.id;
// }
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/Status.java
// public class Status {
//
// private String text;
//
// private List<Map<String, String>> segments;
//
//
// public Status(String text) {
// this.text = text;
// }
//
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
//
// public List<Map<String, String>> getSegments() {
// return segments;
// }
//
// public void setSegments(List<Map<String, String>> segments) {
// this.segments = segments;
// }
//
// @Override
// public String toString() {
// return "Status{" +
// "text='" + text + '\'' +
// ", segments=" + segments +
// '}';
// }
//
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.springframework.http.HttpMethod.GET;
import static org.springframework.http.HttpMethod.POST;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.content;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus;
import org.junit.Test;
import org.springframework.http.HttpStatus;
import org.springframework.social.salesforce.api.SalesforceProfile;
import org.springframework.social.salesforce.api.Status; | /**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.impl;
/**
* @author Umut Utkan
* @author Jared Ottley
* @author Alexandru Leahu
*/
public class ChatterTemplateTest extends AbstractSalesforceTest {
@Test
public void getProfile() {
mockServer.expect(requestTo("https://na7.salesforce.com/services/data/" + salesforce.apiOperations().getVersion() + "/chatter/users/me"))
.andExpect(method(GET))
.andRespond(withStatus(HttpStatus.OK).body(loadResource("profile.json")).headers(responseHeaders));
SalesforceProfile profile = salesforce.chatterOperations().getUserProfile();
assertEquals("Umut Utkan", profile.getName());
assertEquals("umut.utkan@foo.com", profile.getEmail());
assertEquals("005A0000001cRuvIAE", profile.getId());
assertEquals("005A0000001cRuvIAE", profile.getUsername());
assertEquals("Umut Utkan", profile.getName());
assertEquals("https://c.na7.content.force.com/profilephoto/005/F", profile.getPhoto().getLargePhotoUrl());
assertEquals("https://c.na7.content.force.com/profilephoto/005/T", profile.getPhoto().getSmallPhotoUrl());
}
@Test
public void getStatus() {
mockServer.expect(requestTo("https://na7.salesforce.com/services/data/" + salesforce.apiOperations().getVersion() + "/chatter/users/me/status"))
.andExpect(method(GET))
.andRespond(withStatus(HttpStatus.OK).body(loadResource("chatter-status.json")).headers(responseHeaders));
| // Path: src/main/java/org/springframework/social/salesforce/api/SalesforceProfile.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class SalesforceProfile implements Serializable {
// protected String id;
//
// protected String email;
//
// protected String firstName;
//
// protected String lastName;
//
// protected Photo photo;
//
// protected String name;
//
//
// /*public SalesforceProfile(String id, String firstName, String lastName, String email) {
// this.id = id;
// this.firstName = firstName;
// this.lastName = lastName;
// this.email = email;
// }*/
//
//
// public String getId() {
// return id;
// }
//
// public String getEmail() {
// return email;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public Photo getPhoto() {
// return this.photo;
// }
//
// public String getName() {
// return this.name;
// }
//
// public String getUsername() {
// return this.id;
// }
// }
//
// Path: src/main/java/org/springframework/social/salesforce/api/Status.java
// public class Status {
//
// private String text;
//
// private List<Map<String, String>> segments;
//
//
// public Status(String text) {
// this.text = text;
// }
//
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
//
// public List<Map<String, String>> getSegments() {
// return segments;
// }
//
// public void setSegments(List<Map<String, String>> segments) {
// this.segments = segments;
// }
//
// @Override
// public String toString() {
// return "Status{" +
// "text='" + text + '\'' +
// ", segments=" + segments +
// '}';
// }
//
// }
// Path: src/test/java/org/springframework/social/salesforce/api/impl/ChatterTemplateTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.springframework.http.HttpMethod.GET;
import static org.springframework.http.HttpMethod.POST;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.content;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus;
import org.junit.Test;
import org.springframework.http.HttpStatus;
import org.springframework.social.salesforce.api.SalesforceProfile;
import org.springframework.social.salesforce.api.Status;
/**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.impl;
/**
* @author Umut Utkan
* @author Jared Ottley
* @author Alexandru Leahu
*/
public class ChatterTemplateTest extends AbstractSalesforceTest {
@Test
public void getProfile() {
mockServer.expect(requestTo("https://na7.salesforce.com/services/data/" + salesforce.apiOperations().getVersion() + "/chatter/users/me"))
.andExpect(method(GET))
.andRespond(withStatus(HttpStatus.OK).body(loadResource("profile.json")).headers(responseHeaders));
SalesforceProfile profile = salesforce.chatterOperations().getUserProfile();
assertEquals("Umut Utkan", profile.getName());
assertEquals("umut.utkan@foo.com", profile.getEmail());
assertEquals("005A0000001cRuvIAE", profile.getId());
assertEquals("005A0000001cRuvIAE", profile.getUsername());
assertEquals("Umut Utkan", profile.getName());
assertEquals("https://c.na7.content.force.com/profilephoto/005/F", profile.getPhoto().getLargePhotoUrl());
assertEquals("https://c.na7.content.force.com/profilephoto/005/T", profile.getPhoto().getSmallPhotoUrl());
}
@Test
public void getStatus() {
mockServer.expect(requestTo("https://na7.salesforce.com/services/data/" + salesforce.apiOperations().getVersion() + "/chatter/users/me/status"))
.andExpect(method(GET))
.andRespond(withStatus(HttpStatus.OK).body(loadResource("chatter-status.json")).headers(responseHeaders));
| Status status = salesforce.chatterOperations().getStatus(); |
jottley/spring-social-salesforce | src/main/java/org/springframework/social/salesforce/api/impl/AbstractSalesForceOperations.java | // Path: src/main/java/org/springframework/social/salesforce/api/Salesforce.java
// public interface Salesforce extends ApiBinding {
//
// public ApiOperations apiOperations();
//
// public ApiOperations apiOperations(String instanceUrl);
//
// public ChatterOperations chatterOperations();
//
// public ChatterOperations chatterOperations(String instanceUrl);
//
// public QueryOperations queryOperations();
//
// public QueryOperations queryOperations(String instanceUrl);
//
// public RecentOperations recentOperations();
//
// public RecentOperations recentOperations(String instanceUrl);
//
// public SearchOperations searchOperations();
//
// public SearchOperations searchOperations(String instanceUrl);
//
// public SObjectOperations sObjectsOperations();
//
// public SObjectOperations sObjectsOperations(String instanceUrl);
//
// public UserOperations userOperations();
//
// public UserOperations userOperations(String gatewayUrl);
//
// public LimitsOperations limitsOperations();
//
// public LimitsOperations limitsOperations(String instanceUrl);
//
// public <T> List<T> readList(JsonNode jsonNode, Class<T> type);
//
// public <T> T readObject(JsonNode jsonNode, Class<T> type);
//
// public String getBaseUrl();
//
// public String getInstanceUrl();
//
// public void setInstanceUrl(String instanceUrl);
//
// public String getUserInfoUrl();
//
// public String getAuthGatewayUrl();
//
// public void setAuthGatewayBaseUrl(String gatewayUrl);
//
// public ConnectOperations connectOperations();
//
// public ConnectOperations connectOperations(String instanceUrl);
//
// public CustomApiOperations customApiOperations();
//
// public CustomApiOperations customApiOperations(String instanceUrl);
// }
//
// Path: src/main/java/org/springframework/social/salesforce/connect/SalesforceServiceProvider.java
// public class SalesforceServiceProvider extends AbstractOAuth2ServiceProvider<Salesforce> {
//
// //Provider ID
// public final static String ID = "salesforce";
//
// public final static String PRODUCTION_GATEWAY_URL = "https://login.salesforce.com";
// public final static String SANDBOX_GATEWAY_URL = "https://test.salesforce.com";
//
// public final static String TOKEN_PATH = "/services/oauth2/token";
// public final static String AUTHORIZE_PATH = "/services/oauth2/authorize";
//
// public SalesforceServiceProvider(String clientId, String clientSecret) {
// this(clientId, clientSecret,
// PRODUCTION_GATEWAY_URL + AUTHORIZE_PATH,
// PRODUCTION_GATEWAY_URL + TOKEN_PATH);
// }
//
// public SalesforceServiceProvider(String clientId, String clientSecret, boolean sandbox)
// {
// super(new SalesforceOAuth2Template(clientId, clientSecret, (sandbox ? SANDBOX_GATEWAY_URL : PRODUCTION_GATEWAY_URL) + AUTHORIZE_PATH, (sandbox ? SANDBOX_GATEWAY_URL : PRODUCTION_GATEWAY_URL) + TOKEN_PATH));
// }
//
// public SalesforceServiceProvider(String clientId, String clientSecret, String authorizeUrl, String tokenUrl) {
// super(new SalesforceOAuth2Template(clientId, clientSecret, authorizeUrl, tokenUrl));
// }
//
//
// public Salesforce getApi(String accessToken) {
// SalesforceTemplate template = new SalesforceTemplate(accessToken);
//
// // gets the returned instance url and sets to Salesforce template as base url.
// String instanceUrl = ((SalesforceOAuth2Template) getOAuthOperations()).getInstanceUrl();
// if (instanceUrl != null) {
// template.setInstanceUrl(instanceUrl);
// }
//
// return template;
// }
//
// }
| import org.springframework.social.ApiBinding;
import org.springframework.social.MissingAuthorizationException;
import org.springframework.social.salesforce.api.Salesforce;
import org.springframework.social.salesforce.connect.SalesforceServiceProvider; | /**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.impl;
/**
* @author Umut Utkan
* @author Jared Ottley
*/
public class AbstractSalesForceOperations<T extends ApiBinding> {
protected T api;
public AbstractSalesForceOperations(T api) {
this.api = api;
}
protected void requireAuthorization() {
if (!api.isAuthorized()) { | // Path: src/main/java/org/springframework/social/salesforce/api/Salesforce.java
// public interface Salesforce extends ApiBinding {
//
// public ApiOperations apiOperations();
//
// public ApiOperations apiOperations(String instanceUrl);
//
// public ChatterOperations chatterOperations();
//
// public ChatterOperations chatterOperations(String instanceUrl);
//
// public QueryOperations queryOperations();
//
// public QueryOperations queryOperations(String instanceUrl);
//
// public RecentOperations recentOperations();
//
// public RecentOperations recentOperations(String instanceUrl);
//
// public SearchOperations searchOperations();
//
// public SearchOperations searchOperations(String instanceUrl);
//
// public SObjectOperations sObjectsOperations();
//
// public SObjectOperations sObjectsOperations(String instanceUrl);
//
// public UserOperations userOperations();
//
// public UserOperations userOperations(String gatewayUrl);
//
// public LimitsOperations limitsOperations();
//
// public LimitsOperations limitsOperations(String instanceUrl);
//
// public <T> List<T> readList(JsonNode jsonNode, Class<T> type);
//
// public <T> T readObject(JsonNode jsonNode, Class<T> type);
//
// public String getBaseUrl();
//
// public String getInstanceUrl();
//
// public void setInstanceUrl(String instanceUrl);
//
// public String getUserInfoUrl();
//
// public String getAuthGatewayUrl();
//
// public void setAuthGatewayBaseUrl(String gatewayUrl);
//
// public ConnectOperations connectOperations();
//
// public ConnectOperations connectOperations(String instanceUrl);
//
// public CustomApiOperations customApiOperations();
//
// public CustomApiOperations customApiOperations(String instanceUrl);
// }
//
// Path: src/main/java/org/springframework/social/salesforce/connect/SalesforceServiceProvider.java
// public class SalesforceServiceProvider extends AbstractOAuth2ServiceProvider<Salesforce> {
//
// //Provider ID
// public final static String ID = "salesforce";
//
// public final static String PRODUCTION_GATEWAY_URL = "https://login.salesforce.com";
// public final static String SANDBOX_GATEWAY_URL = "https://test.salesforce.com";
//
// public final static String TOKEN_PATH = "/services/oauth2/token";
// public final static String AUTHORIZE_PATH = "/services/oauth2/authorize";
//
// public SalesforceServiceProvider(String clientId, String clientSecret) {
// this(clientId, clientSecret,
// PRODUCTION_GATEWAY_URL + AUTHORIZE_PATH,
// PRODUCTION_GATEWAY_URL + TOKEN_PATH);
// }
//
// public SalesforceServiceProvider(String clientId, String clientSecret, boolean sandbox)
// {
// super(new SalesforceOAuth2Template(clientId, clientSecret, (sandbox ? SANDBOX_GATEWAY_URL : PRODUCTION_GATEWAY_URL) + AUTHORIZE_PATH, (sandbox ? SANDBOX_GATEWAY_URL : PRODUCTION_GATEWAY_URL) + TOKEN_PATH));
// }
//
// public SalesforceServiceProvider(String clientId, String clientSecret, String authorizeUrl, String tokenUrl) {
// super(new SalesforceOAuth2Template(clientId, clientSecret, authorizeUrl, tokenUrl));
// }
//
//
// public Salesforce getApi(String accessToken) {
// SalesforceTemplate template = new SalesforceTemplate(accessToken);
//
// // gets the returned instance url and sets to Salesforce template as base url.
// String instanceUrl = ((SalesforceOAuth2Template) getOAuthOperations()).getInstanceUrl();
// if (instanceUrl != null) {
// template.setInstanceUrl(instanceUrl);
// }
//
// return template;
// }
//
// }
// Path: src/main/java/org/springframework/social/salesforce/api/impl/AbstractSalesForceOperations.java
import org.springframework.social.ApiBinding;
import org.springframework.social.MissingAuthorizationException;
import org.springframework.social.salesforce.api.Salesforce;
import org.springframework.social.salesforce.connect.SalesforceServiceProvider;
/**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.impl;
/**
* @author Umut Utkan
* @author Jared Ottley
*/
public class AbstractSalesForceOperations<T extends ApiBinding> {
protected T api;
public AbstractSalesForceOperations(T api) {
this.api = api;
}
protected void requireAuthorization() {
if (!api.isAuthorized()) { | throw new MissingAuthorizationException(SalesforceServiceProvider.ID); |
jottley/spring-social-salesforce | src/main/java/org/springframework/social/salesforce/api/impl/AbstractSalesForceOperations.java | // Path: src/main/java/org/springframework/social/salesforce/api/Salesforce.java
// public interface Salesforce extends ApiBinding {
//
// public ApiOperations apiOperations();
//
// public ApiOperations apiOperations(String instanceUrl);
//
// public ChatterOperations chatterOperations();
//
// public ChatterOperations chatterOperations(String instanceUrl);
//
// public QueryOperations queryOperations();
//
// public QueryOperations queryOperations(String instanceUrl);
//
// public RecentOperations recentOperations();
//
// public RecentOperations recentOperations(String instanceUrl);
//
// public SearchOperations searchOperations();
//
// public SearchOperations searchOperations(String instanceUrl);
//
// public SObjectOperations sObjectsOperations();
//
// public SObjectOperations sObjectsOperations(String instanceUrl);
//
// public UserOperations userOperations();
//
// public UserOperations userOperations(String gatewayUrl);
//
// public LimitsOperations limitsOperations();
//
// public LimitsOperations limitsOperations(String instanceUrl);
//
// public <T> List<T> readList(JsonNode jsonNode, Class<T> type);
//
// public <T> T readObject(JsonNode jsonNode, Class<T> type);
//
// public String getBaseUrl();
//
// public String getInstanceUrl();
//
// public void setInstanceUrl(String instanceUrl);
//
// public String getUserInfoUrl();
//
// public String getAuthGatewayUrl();
//
// public void setAuthGatewayBaseUrl(String gatewayUrl);
//
// public ConnectOperations connectOperations();
//
// public ConnectOperations connectOperations(String instanceUrl);
//
// public CustomApiOperations customApiOperations();
//
// public CustomApiOperations customApiOperations(String instanceUrl);
// }
//
// Path: src/main/java/org/springframework/social/salesforce/connect/SalesforceServiceProvider.java
// public class SalesforceServiceProvider extends AbstractOAuth2ServiceProvider<Salesforce> {
//
// //Provider ID
// public final static String ID = "salesforce";
//
// public final static String PRODUCTION_GATEWAY_URL = "https://login.salesforce.com";
// public final static String SANDBOX_GATEWAY_URL = "https://test.salesforce.com";
//
// public final static String TOKEN_PATH = "/services/oauth2/token";
// public final static String AUTHORIZE_PATH = "/services/oauth2/authorize";
//
// public SalesforceServiceProvider(String clientId, String clientSecret) {
// this(clientId, clientSecret,
// PRODUCTION_GATEWAY_URL + AUTHORIZE_PATH,
// PRODUCTION_GATEWAY_URL + TOKEN_PATH);
// }
//
// public SalesforceServiceProvider(String clientId, String clientSecret, boolean sandbox)
// {
// super(new SalesforceOAuth2Template(clientId, clientSecret, (sandbox ? SANDBOX_GATEWAY_URL : PRODUCTION_GATEWAY_URL) + AUTHORIZE_PATH, (sandbox ? SANDBOX_GATEWAY_URL : PRODUCTION_GATEWAY_URL) + TOKEN_PATH));
// }
//
// public SalesforceServiceProvider(String clientId, String clientSecret, String authorizeUrl, String tokenUrl) {
// super(new SalesforceOAuth2Template(clientId, clientSecret, authorizeUrl, tokenUrl));
// }
//
//
// public Salesforce getApi(String accessToken) {
// SalesforceTemplate template = new SalesforceTemplate(accessToken);
//
// // gets the returned instance url and sets to Salesforce template as base url.
// String instanceUrl = ((SalesforceOAuth2Template) getOAuthOperations()).getInstanceUrl();
// if (instanceUrl != null) {
// template.setInstanceUrl(instanceUrl);
// }
//
// return template;
// }
//
// }
| import org.springframework.social.ApiBinding;
import org.springframework.social.MissingAuthorizationException;
import org.springframework.social.salesforce.api.Salesforce;
import org.springframework.social.salesforce.connect.SalesforceServiceProvider; | /**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.impl;
/**
* @author Umut Utkan
* @author Jared Ottley
*/
public class AbstractSalesForceOperations<T extends ApiBinding> {
protected T api;
public AbstractSalesForceOperations(T api) {
this.api = api;
}
protected void requireAuthorization() {
if (!api.isAuthorized()) {
throw new MissingAuthorizationException(SalesforceServiceProvider.ID);
}
}
protected static String BASE_URL = "https://na7.salesforce.com/services/data";
public String getVersion()
{ | // Path: src/main/java/org/springframework/social/salesforce/api/Salesforce.java
// public interface Salesforce extends ApiBinding {
//
// public ApiOperations apiOperations();
//
// public ApiOperations apiOperations(String instanceUrl);
//
// public ChatterOperations chatterOperations();
//
// public ChatterOperations chatterOperations(String instanceUrl);
//
// public QueryOperations queryOperations();
//
// public QueryOperations queryOperations(String instanceUrl);
//
// public RecentOperations recentOperations();
//
// public RecentOperations recentOperations(String instanceUrl);
//
// public SearchOperations searchOperations();
//
// public SearchOperations searchOperations(String instanceUrl);
//
// public SObjectOperations sObjectsOperations();
//
// public SObjectOperations sObjectsOperations(String instanceUrl);
//
// public UserOperations userOperations();
//
// public UserOperations userOperations(String gatewayUrl);
//
// public LimitsOperations limitsOperations();
//
// public LimitsOperations limitsOperations(String instanceUrl);
//
// public <T> List<T> readList(JsonNode jsonNode, Class<T> type);
//
// public <T> T readObject(JsonNode jsonNode, Class<T> type);
//
// public String getBaseUrl();
//
// public String getInstanceUrl();
//
// public void setInstanceUrl(String instanceUrl);
//
// public String getUserInfoUrl();
//
// public String getAuthGatewayUrl();
//
// public void setAuthGatewayBaseUrl(String gatewayUrl);
//
// public ConnectOperations connectOperations();
//
// public ConnectOperations connectOperations(String instanceUrl);
//
// public CustomApiOperations customApiOperations();
//
// public CustomApiOperations customApiOperations(String instanceUrl);
// }
//
// Path: src/main/java/org/springframework/social/salesforce/connect/SalesforceServiceProvider.java
// public class SalesforceServiceProvider extends AbstractOAuth2ServiceProvider<Salesforce> {
//
// //Provider ID
// public final static String ID = "salesforce";
//
// public final static String PRODUCTION_GATEWAY_URL = "https://login.salesforce.com";
// public final static String SANDBOX_GATEWAY_URL = "https://test.salesforce.com";
//
// public final static String TOKEN_PATH = "/services/oauth2/token";
// public final static String AUTHORIZE_PATH = "/services/oauth2/authorize";
//
// public SalesforceServiceProvider(String clientId, String clientSecret) {
// this(clientId, clientSecret,
// PRODUCTION_GATEWAY_URL + AUTHORIZE_PATH,
// PRODUCTION_GATEWAY_URL + TOKEN_PATH);
// }
//
// public SalesforceServiceProvider(String clientId, String clientSecret, boolean sandbox)
// {
// super(new SalesforceOAuth2Template(clientId, clientSecret, (sandbox ? SANDBOX_GATEWAY_URL : PRODUCTION_GATEWAY_URL) + AUTHORIZE_PATH, (sandbox ? SANDBOX_GATEWAY_URL : PRODUCTION_GATEWAY_URL) + TOKEN_PATH));
// }
//
// public SalesforceServiceProvider(String clientId, String clientSecret, String authorizeUrl, String tokenUrl) {
// super(new SalesforceOAuth2Template(clientId, clientSecret, authorizeUrl, tokenUrl));
// }
//
//
// public Salesforce getApi(String accessToken) {
// SalesforceTemplate template = new SalesforceTemplate(accessToken);
//
// // gets the returned instance url and sets to Salesforce template as base url.
// String instanceUrl = ((SalesforceOAuth2Template) getOAuthOperations()).getInstanceUrl();
// if (instanceUrl != null) {
// template.setInstanceUrl(instanceUrl);
// }
//
// return template;
// }
//
// }
// Path: src/main/java/org/springframework/social/salesforce/api/impl/AbstractSalesForceOperations.java
import org.springframework.social.ApiBinding;
import org.springframework.social.MissingAuthorizationException;
import org.springframework.social.salesforce.api.Salesforce;
import org.springframework.social.salesforce.connect.SalesforceServiceProvider;
/**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.impl;
/**
* @author Umut Utkan
* @author Jared Ottley
*/
public class AbstractSalesForceOperations<T extends ApiBinding> {
protected T api;
public AbstractSalesForceOperations(T api) {
this.api = api;
}
protected void requireAuthorization() {
if (!api.isAuthorized()) {
throw new MissingAuthorizationException(SalesforceServiceProvider.ID);
}
}
protected static String BASE_URL = "https://na7.salesforce.com/services/data";
public String getVersion()
{ | return ((Salesforce)api).apiOperations().getVersion(); |
jottley/spring-social-salesforce | src/main/java/org/springframework/social/salesforce/api/impl/SalesforceErrorHandler.java | // Path: src/main/java/org/springframework/social/salesforce/api/SalesforceRequestException.java
// public class SalesforceRequestException extends ApiException {
//
// private static final long serialVersionUID = 7047374539651371668L;
//
// private final List<String> fields;
// private final String code;
//
// public SalesforceRequestException(String message) {
// super(SalesforceServiceProvider.ID, message);
// this.code = null;
// this.fields = null;
// }
//
// public SalesforceRequestException(String providerId, String message) {
// super(providerId, message);
// this.code = null;
// this.fields = null;
// }
//
// @SuppressWarnings("unchecked")
// public SalesforceRequestException(Map<String, Object> errorDetails) {
// super(SalesforceServiceProvider.ID, (String)errorDetails.get("message"));
//
// this.code = StringUtils.defaultString((String)errorDetails.get("errorCode"), "UNKNOWN");
// this.fields = (List<String>) errorDetails.get("fields");
// }
//
// @SuppressWarnings("unchecked")
// public SalesforceRequestException(String providerId, Map<String, Object> errorDetails) {
// super(providerId, (String)errorDetails.get("message"));
//
// this.code = StringUtils.defaultString((String)errorDetails.get("errorCode"), "UNKNOWN");
// this.fields = (List<String>) errorDetails.get("fields");
// }
//
// public List<String> getFields() {
// return fields;
// }
//
// public String getCode() {
// return code;
// }
//
// }
//
// Path: src/main/java/org/springframework/social/salesforce/connect/SalesforceServiceProvider.java
// public class SalesforceServiceProvider extends AbstractOAuth2ServiceProvider<Salesforce> {
//
// //Provider ID
// public final static String ID = "salesforce";
//
// public final static String PRODUCTION_GATEWAY_URL = "https://login.salesforce.com";
// public final static String SANDBOX_GATEWAY_URL = "https://test.salesforce.com";
//
// public final static String TOKEN_PATH = "/services/oauth2/token";
// public final static String AUTHORIZE_PATH = "/services/oauth2/authorize";
//
// public SalesforceServiceProvider(String clientId, String clientSecret) {
// this(clientId, clientSecret,
// PRODUCTION_GATEWAY_URL + AUTHORIZE_PATH,
// PRODUCTION_GATEWAY_URL + TOKEN_PATH);
// }
//
// public SalesforceServiceProvider(String clientId, String clientSecret, boolean sandbox)
// {
// super(new SalesforceOAuth2Template(clientId, clientSecret, (sandbox ? SANDBOX_GATEWAY_URL : PRODUCTION_GATEWAY_URL) + AUTHORIZE_PATH, (sandbox ? SANDBOX_GATEWAY_URL : PRODUCTION_GATEWAY_URL) + TOKEN_PATH));
// }
//
// public SalesforceServiceProvider(String clientId, String clientSecret, String authorizeUrl, String tokenUrl) {
// super(new SalesforceOAuth2Template(clientId, clientSecret, authorizeUrl, tokenUrl));
// }
//
//
// public Salesforce getApi(String accessToken) {
// SalesforceTemplate template = new SalesforceTemplate(accessToken);
//
// // gets the returned instance url and sets to Salesforce template as base url.
// String instanceUrl = ((SalesforceOAuth2Template) getOAuthOperations()).getInstanceUrl();
// if (instanceUrl != null) {
// template.setInstanceUrl(instanceUrl);
// }
//
// return template;
// }
//
// }
| import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.type.CollectionType;
import com.fasterxml.jackson.databind.type.TypeFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.social.InsufficientPermissionException;
import org.springframework.social.InternalServerErrorException;
import org.springframework.social.InvalidAuthorizationException;
import org.springframework.social.RateLimitExceededException;
import org.springframework.social.ResourceNotFoundException;
import org.springframework.social.UncategorizedApiException;
import org.springframework.social.salesforce.api.SalesforceRequestException;
import org.springframework.social.salesforce.connect.SalesforceServiceProvider;
import org.springframework.web.client.DefaultResponseErrorHandler;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map; | /**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.impl;
/**
* @author Umut Utkan
* @author Jared Ottley
*/
public class SalesforceErrorHandler extends DefaultResponseErrorHandler {
Logger logger = LoggerFactory.getLogger(SalesforceErrorHandler.class);
private static final String ERROR_CODE = "errorCode";
private static final String BAD_OAUTH_TOKEN = "Bad_OAuth_Token";
private static final String MESSAGE = "message";
private static final String SESSION_EXPIRED_INVALID = "Invalid access token";
@Override
public void handleError(ClientHttpResponse response) throws IOException {
Map<String, Object> errorDetails = extractErrorDetailsFromResponse(response);
if (errorDetails == null) {
handleUncategorizedError(response, errorDetails);
}
handleSalesforceError(response.getStatusCode(), errorDetails);
// if not otherwise handled, do default handling and wrap with UncategorizedApiException
handleUncategorizedError(response, errorDetails);
}
private void handleSalesforceError(HttpStatus statusCode, Map<String, Object> errorDetails) {
if (statusCode.equals(HttpStatus.NOT_FOUND)) { | // Path: src/main/java/org/springframework/social/salesforce/api/SalesforceRequestException.java
// public class SalesforceRequestException extends ApiException {
//
// private static final long serialVersionUID = 7047374539651371668L;
//
// private final List<String> fields;
// private final String code;
//
// public SalesforceRequestException(String message) {
// super(SalesforceServiceProvider.ID, message);
// this.code = null;
// this.fields = null;
// }
//
// public SalesforceRequestException(String providerId, String message) {
// super(providerId, message);
// this.code = null;
// this.fields = null;
// }
//
// @SuppressWarnings("unchecked")
// public SalesforceRequestException(Map<String, Object> errorDetails) {
// super(SalesforceServiceProvider.ID, (String)errorDetails.get("message"));
//
// this.code = StringUtils.defaultString((String)errorDetails.get("errorCode"), "UNKNOWN");
// this.fields = (List<String>) errorDetails.get("fields");
// }
//
// @SuppressWarnings("unchecked")
// public SalesforceRequestException(String providerId, Map<String, Object> errorDetails) {
// super(providerId, (String)errorDetails.get("message"));
//
// this.code = StringUtils.defaultString((String)errorDetails.get("errorCode"), "UNKNOWN");
// this.fields = (List<String>) errorDetails.get("fields");
// }
//
// public List<String> getFields() {
// return fields;
// }
//
// public String getCode() {
// return code;
// }
//
// }
//
// Path: src/main/java/org/springframework/social/salesforce/connect/SalesforceServiceProvider.java
// public class SalesforceServiceProvider extends AbstractOAuth2ServiceProvider<Salesforce> {
//
// //Provider ID
// public final static String ID = "salesforce";
//
// public final static String PRODUCTION_GATEWAY_URL = "https://login.salesforce.com";
// public final static String SANDBOX_GATEWAY_URL = "https://test.salesforce.com";
//
// public final static String TOKEN_PATH = "/services/oauth2/token";
// public final static String AUTHORIZE_PATH = "/services/oauth2/authorize";
//
// public SalesforceServiceProvider(String clientId, String clientSecret) {
// this(clientId, clientSecret,
// PRODUCTION_GATEWAY_URL + AUTHORIZE_PATH,
// PRODUCTION_GATEWAY_URL + TOKEN_PATH);
// }
//
// public SalesforceServiceProvider(String clientId, String clientSecret, boolean sandbox)
// {
// super(new SalesforceOAuth2Template(clientId, clientSecret, (sandbox ? SANDBOX_GATEWAY_URL : PRODUCTION_GATEWAY_URL) + AUTHORIZE_PATH, (sandbox ? SANDBOX_GATEWAY_URL : PRODUCTION_GATEWAY_URL) + TOKEN_PATH));
// }
//
// public SalesforceServiceProvider(String clientId, String clientSecret, String authorizeUrl, String tokenUrl) {
// super(new SalesforceOAuth2Template(clientId, clientSecret, authorizeUrl, tokenUrl));
// }
//
//
// public Salesforce getApi(String accessToken) {
// SalesforceTemplate template = new SalesforceTemplate(accessToken);
//
// // gets the returned instance url and sets to Salesforce template as base url.
// String instanceUrl = ((SalesforceOAuth2Template) getOAuthOperations()).getInstanceUrl();
// if (instanceUrl != null) {
// template.setInstanceUrl(instanceUrl);
// }
//
// return template;
// }
//
// }
// Path: src/main/java/org/springframework/social/salesforce/api/impl/SalesforceErrorHandler.java
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.type.CollectionType;
import com.fasterxml.jackson.databind.type.TypeFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.social.InsufficientPermissionException;
import org.springframework.social.InternalServerErrorException;
import org.springframework.social.InvalidAuthorizationException;
import org.springframework.social.RateLimitExceededException;
import org.springframework.social.ResourceNotFoundException;
import org.springframework.social.UncategorizedApiException;
import org.springframework.social.salesforce.api.SalesforceRequestException;
import org.springframework.social.salesforce.connect.SalesforceServiceProvider;
import org.springframework.web.client.DefaultResponseErrorHandler;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.impl;
/**
* @author Umut Utkan
* @author Jared Ottley
*/
public class SalesforceErrorHandler extends DefaultResponseErrorHandler {
Logger logger = LoggerFactory.getLogger(SalesforceErrorHandler.class);
private static final String ERROR_CODE = "errorCode";
private static final String BAD_OAUTH_TOKEN = "Bad_OAuth_Token";
private static final String MESSAGE = "message";
private static final String SESSION_EXPIRED_INVALID = "Invalid access token";
@Override
public void handleError(ClientHttpResponse response) throws IOException {
Map<String, Object> errorDetails = extractErrorDetailsFromResponse(response);
if (errorDetails == null) {
handleUncategorizedError(response, errorDetails);
}
handleSalesforceError(response.getStatusCode(), errorDetails);
// if not otherwise handled, do default handling and wrap with UncategorizedApiException
handleUncategorizedError(response, errorDetails);
}
private void handleSalesforceError(HttpStatus statusCode, Map<String, Object> errorDetails) {
if (statusCode.equals(HttpStatus.NOT_FOUND)) { | throw new ResourceNotFoundException(SalesforceServiceProvider.ID, extractErrorMessage(errorDetails)); |
jottley/spring-social-salesforce | src/test/java/org/springframework/social/salesforce/api/impl/RecentTemplateTest.java | // Path: src/main/java/org/springframework/social/salesforce/api/ResultItem.java
// public class ResultItem implements Serializable {
//
// private String type;
//
// private String url;
//
// private Map attributes;
//
//
// public ResultItem(String type, String url) {
// this.type = type;
// this.url = url;
// this.attributes = new HashMap();
// }
//
//
// public String getType() {
// return this.type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public String getUrl() {
// return this.url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public Map getAttributes() {
// return attributes;
// }
//
// public void setAttributes(Map attributes) {
// this.attributes = attributes;
// }
//
// }
| import org.junit.Test;
import org.springframework.http.HttpStatus;
import org.springframework.social.salesforce.api.ResultItem;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.springframework.http.HttpMethod.GET;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus; | /**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.impl;
/**
* @author Umut Utkan
* @author Jared Ottley
*/
public class RecentTemplateTest extends AbstractSalesforceTest {
@Test
public void search() {
mockServer.expect(requestTo("https://na7.salesforce.com/services/data/" + salesforce.apiOperations().getVersion() + "/recent"))
.andExpect(method(GET))
.andRespond(withStatus(HttpStatus.OK).body(loadResource("recent.json")).headers(responseHeaders)); | // Path: src/main/java/org/springframework/social/salesforce/api/ResultItem.java
// public class ResultItem implements Serializable {
//
// private String type;
//
// private String url;
//
// private Map attributes;
//
//
// public ResultItem(String type, String url) {
// this.type = type;
// this.url = url;
// this.attributes = new HashMap();
// }
//
//
// public String getType() {
// return this.type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public String getUrl() {
// return this.url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public Map getAttributes() {
// return attributes;
// }
//
// public void setAttributes(Map attributes) {
// this.attributes = attributes;
// }
//
// }
// Path: src/test/java/org/springframework/social/salesforce/api/impl/RecentTemplateTest.java
import org.junit.Test;
import org.springframework.http.HttpStatus;
import org.springframework.social.salesforce.api.ResultItem;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.springframework.http.HttpMethod.GET;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus;
/**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api.impl;
/**
* @author Umut Utkan
* @author Jared Ottley
*/
public class RecentTemplateTest extends AbstractSalesforceTest {
@Test
public void search() {
mockServer.expect(requestTo("https://na7.salesforce.com/services/data/" + salesforce.apiOperations().getVersion() + "/recent"))
.andExpect(method(GET))
.andRespond(withStatus(HttpStatus.OK).body(loadResource("recent.json")).headers(responseHeaders)); | List<ResultItem> items = salesforce.recentOperations().recent(); |
jottley/spring-social-salesforce | src/main/java/org/springframework/social/salesforce/api/SalesforceRequestException.java | // Path: src/main/java/org/springframework/social/salesforce/connect/SalesforceServiceProvider.java
// public class SalesforceServiceProvider extends AbstractOAuth2ServiceProvider<Salesforce> {
//
// //Provider ID
// public final static String ID = "salesforce";
//
// public final static String PRODUCTION_GATEWAY_URL = "https://login.salesforce.com";
// public final static String SANDBOX_GATEWAY_URL = "https://test.salesforce.com";
//
// public final static String TOKEN_PATH = "/services/oauth2/token";
// public final static String AUTHORIZE_PATH = "/services/oauth2/authorize";
//
// public SalesforceServiceProvider(String clientId, String clientSecret) {
// this(clientId, clientSecret,
// PRODUCTION_GATEWAY_URL + AUTHORIZE_PATH,
// PRODUCTION_GATEWAY_URL + TOKEN_PATH);
// }
//
// public SalesforceServiceProvider(String clientId, String clientSecret, boolean sandbox)
// {
// super(new SalesforceOAuth2Template(clientId, clientSecret, (sandbox ? SANDBOX_GATEWAY_URL : PRODUCTION_GATEWAY_URL) + AUTHORIZE_PATH, (sandbox ? SANDBOX_GATEWAY_URL : PRODUCTION_GATEWAY_URL) + TOKEN_PATH));
// }
//
// public SalesforceServiceProvider(String clientId, String clientSecret, String authorizeUrl, String tokenUrl) {
// super(new SalesforceOAuth2Template(clientId, clientSecret, authorizeUrl, tokenUrl));
// }
//
//
// public Salesforce getApi(String accessToken) {
// SalesforceTemplate template = new SalesforceTemplate(accessToken);
//
// // gets the returned instance url and sets to Salesforce template as base url.
// String instanceUrl = ((SalesforceOAuth2Template) getOAuthOperations()).getInstanceUrl();
// if (instanceUrl != null) {
// template.setInstanceUrl(instanceUrl);
// }
//
// return template;
// }
//
// }
| import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.springframework.social.ApiException;
import org.springframework.social.salesforce.connect.SalesforceServiceProvider; | /**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api;
/**
* Encapsulates the error response sent by Salesforce.
* <br>
*
* @see <a
* href="http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_concepts_core_data_objects.htm">
* Salesforce API Core Datatypes</a>
*
* @author Umut Utkan
* @author Jared Ottley
*/
public class SalesforceRequestException extends ApiException {
private static final long serialVersionUID = 7047374539651371668L;
private final List<String> fields;
private final String code;
public SalesforceRequestException(String message) { | // Path: src/main/java/org/springframework/social/salesforce/connect/SalesforceServiceProvider.java
// public class SalesforceServiceProvider extends AbstractOAuth2ServiceProvider<Salesforce> {
//
// //Provider ID
// public final static String ID = "salesforce";
//
// public final static String PRODUCTION_GATEWAY_URL = "https://login.salesforce.com";
// public final static String SANDBOX_GATEWAY_URL = "https://test.salesforce.com";
//
// public final static String TOKEN_PATH = "/services/oauth2/token";
// public final static String AUTHORIZE_PATH = "/services/oauth2/authorize";
//
// public SalesforceServiceProvider(String clientId, String clientSecret) {
// this(clientId, clientSecret,
// PRODUCTION_GATEWAY_URL + AUTHORIZE_PATH,
// PRODUCTION_GATEWAY_URL + TOKEN_PATH);
// }
//
// public SalesforceServiceProvider(String clientId, String clientSecret, boolean sandbox)
// {
// super(new SalesforceOAuth2Template(clientId, clientSecret, (sandbox ? SANDBOX_GATEWAY_URL : PRODUCTION_GATEWAY_URL) + AUTHORIZE_PATH, (sandbox ? SANDBOX_GATEWAY_URL : PRODUCTION_GATEWAY_URL) + TOKEN_PATH));
// }
//
// public SalesforceServiceProvider(String clientId, String clientSecret, String authorizeUrl, String tokenUrl) {
// super(new SalesforceOAuth2Template(clientId, clientSecret, authorizeUrl, tokenUrl));
// }
//
//
// public Salesforce getApi(String accessToken) {
// SalesforceTemplate template = new SalesforceTemplate(accessToken);
//
// // gets the returned instance url and sets to Salesforce template as base url.
// String instanceUrl = ((SalesforceOAuth2Template) getOAuthOperations()).getInstanceUrl();
// if (instanceUrl != null) {
// template.setInstanceUrl(instanceUrl);
// }
//
// return template;
// }
//
// }
// Path: src/main/java/org/springframework/social/salesforce/api/SalesforceRequestException.java
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.springframework.social.ApiException;
import org.springframework.social.salesforce.connect.SalesforceServiceProvider;
/**
* Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.salesforce.api;
/**
* Encapsulates the error response sent by Salesforce.
* <br>
*
* @see <a
* href="http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_concepts_core_data_objects.htm">
* Salesforce API Core Datatypes</a>
*
* @author Umut Utkan
* @author Jared Ottley
*/
public class SalesforceRequestException extends ApiException {
private static final long serialVersionUID = 7047374539651371668L;
private final List<String> fields;
private final String code;
public SalesforceRequestException(String message) { | super(SalesforceServiceProvider.ID, message); |
yongjhih/AutoJson | auto-json-sample/src/main/java/model3/Person.java | // Path: auto-json-sample/src/main/java/model2/Address.java
// @AutoJson
// public abstract class Address implements Parcelable {
// @Nullable
// @AutoJson.Field
// public abstract double[] coordinates();
//
// @Nullable
// @AutoJson.Field(name = "is_hidden")
// public abstract String cityName();
//
// public static Address create(double[] coordinates, String cityName) {
// return builder().coordinates(coordinates).cityName(cityName).build();
// }
//
// public static Builder builder() {
// return new AutoJson_Address.Builder();
// }
//
// @AutoJson.Builder
// public interface Builder {
// public Builder coordinates(double[] x);
// public Builder cityName(String x);
// public Address build();
// }
//
// @AutoJson.Validate
// public void validate() {
// if (cityName().length() < 2) {
// throw new IllegalStateException("Not a city name");
// }
// }
// }
| import auto.json.AutoJson;
import android.os.Parcelable;
import android.graphics.Bitmap;
import android.support.annotation.Nullable;
import java.util.List;
import java.util.Map;
import model1.HeightBucket;
import model2.Address; | package model3;
@AutoJson
public abstract class Person implements Parcelable { | // Path: auto-json-sample/src/main/java/model2/Address.java
// @AutoJson
// public abstract class Address implements Parcelable {
// @Nullable
// @AutoJson.Field
// public abstract double[] coordinates();
//
// @Nullable
// @AutoJson.Field(name = "is_hidden")
// public abstract String cityName();
//
// public static Address create(double[] coordinates, String cityName) {
// return builder().coordinates(coordinates).cityName(cityName).build();
// }
//
// public static Builder builder() {
// return new AutoJson_Address.Builder();
// }
//
// @AutoJson.Builder
// public interface Builder {
// public Builder coordinates(double[] x);
// public Builder cityName(String x);
// public Address build();
// }
//
// @AutoJson.Validate
// public void validate() {
// if (cityName().length() < 2) {
// throw new IllegalStateException("Not a city name");
// }
// }
// }
// Path: auto-json-sample/src/main/java/model3/Person.java
import auto.json.AutoJson;
import android.os.Parcelable;
import android.graphics.Bitmap;
import android.support.annotation.Nullable;
import java.util.List;
import java.util.Map;
import model1.HeightBucket;
import model2.Address;
package model3;
@AutoJson
public abstract class Person implements Parcelable { | public static Person create(String name, long id, HeightBucket heightType, Map<String, Address> addresses, |
yongjhih/AutoJson | auto-json-sample/src/main/java/auto/json/sample/DetailActivity.java | // Path: auto-json-sample/src/main/java/model3/Person.java
// @AutoJson
// public abstract class Person implements Parcelable {
// public static Person create(String name, long id, HeightBucket heightType, Map<String, Address> addresses,
// List<Person> friends, Bitmap bitmap) {
// return new AutoJson_Person(name, id, heightType, addresses, friends, bitmap);
// }
//
// public abstract String name();
// public abstract long id();
// public abstract HeightBucket heightType();
// public abstract Map<String, Address> addresses();
// public abstract List<Person> friends();
// @Nullable
// public abstract Bitmap bitmap();
// }
| import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
import model3.Person; | package auto.json.sample;
public class DetailActivity extends Activity {
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detail); | // Path: auto-json-sample/src/main/java/model3/Person.java
// @AutoJson
// public abstract class Person implements Parcelable {
// public static Person create(String name, long id, HeightBucket heightType, Map<String, Address> addresses,
// List<Person> friends, Bitmap bitmap) {
// return new AutoJson_Person(name, id, heightType, addresses, friends, bitmap);
// }
//
// public abstract String name();
// public abstract long id();
// public abstract HeightBucket heightType();
// public abstract Map<String, Address> addresses();
// public abstract List<Person> friends();
// @Nullable
// public abstract Bitmap bitmap();
// }
// Path: auto-json-sample/src/main/java/auto/json/sample/DetailActivity.java
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
import model3.Person;
package auto.json.sample;
public class DetailActivity extends Activity {
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detail); | Person person = getIntent().getParcelableExtra("Person"); |
yongjhih/AutoJson | auto-json-sample/src/main/java/auto/json/sample/SampleData.java | // Path: auto-json-sample/src/main/java/model2/Address.java
// @AutoJson
// public abstract class Address implements Parcelable {
// @Nullable
// @AutoJson.Field
// public abstract double[] coordinates();
//
// @Nullable
// @AutoJson.Field(name = "is_hidden")
// public abstract String cityName();
//
// public static Address create(double[] coordinates, String cityName) {
// return builder().coordinates(coordinates).cityName(cityName).build();
// }
//
// public static Builder builder() {
// return new AutoJson_Address.Builder();
// }
//
// @AutoJson.Builder
// public interface Builder {
// public Builder coordinates(double[] x);
// public Builder cityName(String x);
// public Address build();
// }
//
// @AutoJson.Validate
// public void validate() {
// if (cityName().length() < 2) {
// throw new IllegalStateException("Not a city name");
// }
// }
// }
//
// Path: auto-json-sample/src/main/java/model3/Person.java
// @AutoJson
// public abstract class Person implements Parcelable {
// public static Person create(String name, long id, HeightBucket heightType, Map<String, Address> addresses,
// List<Person> friends, Bitmap bitmap) {
// return new AutoJson_Person(name, id, heightType, addresses, friends, bitmap);
// }
//
// public abstract String name();
// public abstract long id();
// public abstract HeightBucket heightType();
// public abstract Map<String, Address> addresses();
// public abstract List<Person> friends();
// @Nullable
// public abstract Bitmap bitmap();
// }
| import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import model1.HeightBucket;
import model2.Address;
import model3.Person; | package auto.json.sample;
public interface SampleData {
static final Person ALICE = Person.create("Alice", 1L, HeightBucket.AVERAGE, | // Path: auto-json-sample/src/main/java/model2/Address.java
// @AutoJson
// public abstract class Address implements Parcelable {
// @Nullable
// @AutoJson.Field
// public abstract double[] coordinates();
//
// @Nullable
// @AutoJson.Field(name = "is_hidden")
// public abstract String cityName();
//
// public static Address create(double[] coordinates, String cityName) {
// return builder().coordinates(coordinates).cityName(cityName).build();
// }
//
// public static Builder builder() {
// return new AutoJson_Address.Builder();
// }
//
// @AutoJson.Builder
// public interface Builder {
// public Builder coordinates(double[] x);
// public Builder cityName(String x);
// public Address build();
// }
//
// @AutoJson.Validate
// public void validate() {
// if (cityName().length() < 2) {
// throw new IllegalStateException("Not a city name");
// }
// }
// }
//
// Path: auto-json-sample/src/main/java/model3/Person.java
// @AutoJson
// public abstract class Person implements Parcelable {
// public static Person create(String name, long id, HeightBucket heightType, Map<String, Address> addresses,
// List<Person> friends, Bitmap bitmap) {
// return new AutoJson_Person(name, id, heightType, addresses, friends, bitmap);
// }
//
// public abstract String name();
// public abstract long id();
// public abstract HeightBucket heightType();
// public abstract Map<String, Address> addresses();
// public abstract List<Person> friends();
// @Nullable
// public abstract Bitmap bitmap();
// }
// Path: auto-json-sample/src/main/java/auto/json/sample/SampleData.java
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import model1.HeightBucket;
import model2.Address;
import model3.Person;
package auto.json.sample;
public interface SampleData {
static final Person ALICE = Person.create("Alice", 1L, HeightBucket.AVERAGE, | new HashMap<String, Address>() {{ |
JeffreyFalgout/junit5-extensions | extension-testing/src/test/java/name/falgout/jeffrey/testing/junit/testing/ExtentionTesterTest.java | // Path: extension-testing/src/main/java/name/falgout/jeffrey/testing/junit/testing/TestPlanExecutionReport.java
// @AutoValue
// public static abstract class DisplayName {
// public static DisplayName create(String... names) {
// return create(Arrays.asList(names));
// }
//
// public static DisplayName create(Collection<? extends String> names) {
// return new AutoValue_TestPlanExecutionReport_DisplayName(ImmutableList.copyOf(names));
// }
//
// DisplayName() {}
//
// public abstract ImmutableList<String> getNames();
// }
| import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import static org.junit.jupiter.api.Assertions.assertAll;
import name.falgout.jeffrey.testing.junit.testing.TestPlanExecutionReport.DisplayName;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test; | package name.falgout.jeffrey.testing.junit.testing;
public class ExtentionTesterTest {
static class Tests {
@Test
void successful() {}
@Test
@Disabled("reasons")
void skipped() {}
@Test
void failure() {
throw new IllegalArgumentException();
}
@Nested
class NestedTests {
@Test
void nestedTest() {}
}
}
@Test
void testTheTester() {
TestPlanExecutionReport report = ExtensionTester.runTests(Tests.class);
assertAll(
() -> assertThat(report.getTests()).hasSize(4),
() -> assertThat(report.getSuccessful())
.containsAllOf( | // Path: extension-testing/src/main/java/name/falgout/jeffrey/testing/junit/testing/TestPlanExecutionReport.java
// @AutoValue
// public static abstract class DisplayName {
// public static DisplayName create(String... names) {
// return create(Arrays.asList(names));
// }
//
// public static DisplayName create(Collection<? extends String> names) {
// return new AutoValue_TestPlanExecutionReport_DisplayName(ImmutableList.copyOf(names));
// }
//
// DisplayName() {}
//
// public abstract ImmutableList<String> getNames();
// }
// Path: extension-testing/src/test/java/name/falgout/jeffrey/testing/junit/testing/ExtentionTesterTest.java
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import static org.junit.jupiter.api.Assertions.assertAll;
import name.falgout.jeffrey.testing.junit.testing.TestPlanExecutionReport.DisplayName;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
package name.falgout.jeffrey.testing.junit.testing;
public class ExtentionTesterTest {
static class Tests {
@Test
void successful() {}
@Test
@Disabled("reasons")
void skipped() {}
@Test
void failure() {
throw new IllegalArgumentException();
}
@Nested
class NestedTests {
@Test
void nestedTest() {}
}
}
@Test
void testTheTester() {
TestPlanExecutionReport report = ExtensionTester.runTests(Tests.class);
assertAll(
() -> assertThat(report.getTests()).hasSize(4),
() -> assertThat(report.getSuccessful())
.containsAllOf( | DisplayName.create("successful()"), |
JeffreyFalgout/junit5-extensions | extension-testing/src/test/java/name/falgout/jeffrey/testing/junit/testing/ExpectFailureTest.java | // Path: extension-testing/src/main/java/name/falgout/jeffrey/testing/junit/testing/TestPlanExecutionReport.java
// @AutoValue
// public static abstract class DisplayName {
// public static DisplayName create(String... names) {
// return create(Arrays.asList(names));
// }
//
// public static DisplayName create(Collection<? extends String> names) {
// return new AutoValue_TestPlanExecutionReport_DisplayName(ImmutableList.copyOf(names));
// }
//
// DisplayName() {}
//
// public abstract ImmutableList<String> getNames();
// }
| import static com.google.common.truth.Truth.assertThat;
import static org.junit.jupiter.api.Assertions.assertAll;
import java.io.IOException;
import name.falgout.jeffrey.testing.junit.testing.ExpectFailure.Cause;
import name.falgout.jeffrey.testing.junit.testing.TestPlanExecutionReport.DisplayName;
import org.junit.jupiter.api.Test; | @Cause(type = IllegalArgumentException.class, message = "bar"),
@Cause(type = IOException.class, message = "something else"),
})
@Test
void matchingCauses() {
throw new IllegalArgumentException("Foo bar", new IOException("something else"));
}
@ExpectFailure(@Cause(type = IllegalArgumentException.class))
@Test
void messageIsOptional() {
throw new IllegalArgumentException("Anything you want");
}
@ExpectFailure(@Cause(message = "only message"))
@Test
void typeIsOptional() {
throw new Error("only message");
}
@ExpectFailure
@Test
void causeIsOptional() {
throw new IllegalArgumentException();
}
@Test
void negativeExamples() {
TestPlanExecutionReport report = ExtensionTester.runTests(NegativeExamples.class);
| // Path: extension-testing/src/main/java/name/falgout/jeffrey/testing/junit/testing/TestPlanExecutionReport.java
// @AutoValue
// public static abstract class DisplayName {
// public static DisplayName create(String... names) {
// return create(Arrays.asList(names));
// }
//
// public static DisplayName create(Collection<? extends String> names) {
// return new AutoValue_TestPlanExecutionReport_DisplayName(ImmutableList.copyOf(names));
// }
//
// DisplayName() {}
//
// public abstract ImmutableList<String> getNames();
// }
// Path: extension-testing/src/test/java/name/falgout/jeffrey/testing/junit/testing/ExpectFailureTest.java
import static com.google.common.truth.Truth.assertThat;
import static org.junit.jupiter.api.Assertions.assertAll;
import java.io.IOException;
import name.falgout.jeffrey.testing.junit.testing.ExpectFailure.Cause;
import name.falgout.jeffrey.testing.junit.testing.TestPlanExecutionReport.DisplayName;
import org.junit.jupiter.api.Test;
@Cause(type = IllegalArgumentException.class, message = "bar"),
@Cause(type = IOException.class, message = "something else"),
})
@Test
void matchingCauses() {
throw new IllegalArgumentException("Foo bar", new IOException("something else"));
}
@ExpectFailure(@Cause(type = IllegalArgumentException.class))
@Test
void messageIsOptional() {
throw new IllegalArgumentException("Anything you want");
}
@ExpectFailure(@Cause(message = "only message"))
@Test
void typeIsOptional() {
throw new Error("only message");
}
@ExpectFailure
@Test
void causeIsOptional() {
throw new IllegalArgumentException();
}
@Test
void negativeExamples() {
TestPlanExecutionReport report = ExtensionTester.runTests(NegativeExamples.class);
| DisplayName noExceptionThrown = DisplayName.create("noExceptionThrown()"); |
Turbots/SpringOne2016 | rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/controller/GameController.java | // Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/pubsub/ChatEventPublisher.java
// @Slf4j
// @Service
// public class ChatEventPublisher {
//
// private final RedisTemplate<String, Object> messageRedisTemplate;
// private final Topic topic;
//
// @Autowired
// public ChatEventPublisher(final RedisTemplate<String, Object> messageRedisTemplate, @Qualifier("chatTopic") final Topic topic) {
// this.messageRedisTemplate = messageRedisTemplate;
// this.topic = topic;
// }
//
// public void publish(final ChatMessage chatMessage) {
// log.info("Sending ChatMessage " + chatMessage);
// this.messageRedisTemplate.convertAndSend(topic.getTopic(), chatMessage);
// }
// }
//
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/pubsub/GameEventPublisher.java
// @Slf4j
// @Service
// public class GameEventPublisher {
//
// private final RedisTemplate<String, Object> messageRedisTemplate;
// private final Topic topic;
//
// @Autowired
// public GameEventPublisher(RedisTemplate<String, Object> messageRedisTemplate, @Qualifier("gameTopic") Topic topic) {
// this.messageRedisTemplate = messageRedisTemplate;
// this.topic = topic;
// }
//
// public void publish(final GameMessage gameMessage) {
// log.info("Sending GameMessage " + gameMessage);
// messageRedisTemplate.convertAndSend(topic.getTopic(), gameMessage);
// }
// }
//
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/websocket/ChatMessage.java
// @Getter
// @Builder
// @AllArgsConstructor
// public class ChatMessage implements Serializable {
//
// private String message;
// private String username;
//
// }
//
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/websocket/GameMessage.java
// @Getter
// @Builder
// @NoArgsConstructor
// @AllArgsConstructor
// public class GameMessage implements Serializable {
//
// private Game game;
//
// private GameEvent event;
//
// private String username;
//
// private String image;
//
// public static GameMessageBuilder of(GameMessage gameMessage) {
// return GameMessage.builder()
// .event(gameMessage.getEvent())
// .game(gameMessage.getGame())
// .image(gameMessage.getImage())
// .username(gameMessage.getUsername());
// }
// }
| import be.ordina.jworks.rpsls.game.*;
import be.ordina.jworks.rpsls.game.pubsub.ChatEventPublisher;
import be.ordina.jworks.rpsls.game.pubsub.GameEventPublisher;
import be.ordina.jworks.rpsls.game.websocket.ChatMessage;
import be.ordina.jworks.rpsls.game.websocket.GameMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.security.Principal;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import static org.springframework.util.Assert.notNull; | package be.ordina.jworks.rpsls.controller;
@Slf4j
@RestController
public class GameController {
private final GameRepository gameRepository;
private final GameLogic gameLogic; | // Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/pubsub/ChatEventPublisher.java
// @Slf4j
// @Service
// public class ChatEventPublisher {
//
// private final RedisTemplate<String, Object> messageRedisTemplate;
// private final Topic topic;
//
// @Autowired
// public ChatEventPublisher(final RedisTemplate<String, Object> messageRedisTemplate, @Qualifier("chatTopic") final Topic topic) {
// this.messageRedisTemplate = messageRedisTemplate;
// this.topic = topic;
// }
//
// public void publish(final ChatMessage chatMessage) {
// log.info("Sending ChatMessage " + chatMessage);
// this.messageRedisTemplate.convertAndSend(topic.getTopic(), chatMessage);
// }
// }
//
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/pubsub/GameEventPublisher.java
// @Slf4j
// @Service
// public class GameEventPublisher {
//
// private final RedisTemplate<String, Object> messageRedisTemplate;
// private final Topic topic;
//
// @Autowired
// public GameEventPublisher(RedisTemplate<String, Object> messageRedisTemplate, @Qualifier("gameTopic") Topic topic) {
// this.messageRedisTemplate = messageRedisTemplate;
// this.topic = topic;
// }
//
// public void publish(final GameMessage gameMessage) {
// log.info("Sending GameMessage " + gameMessage);
// messageRedisTemplate.convertAndSend(topic.getTopic(), gameMessage);
// }
// }
//
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/websocket/ChatMessage.java
// @Getter
// @Builder
// @AllArgsConstructor
// public class ChatMessage implements Serializable {
//
// private String message;
// private String username;
//
// }
//
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/websocket/GameMessage.java
// @Getter
// @Builder
// @NoArgsConstructor
// @AllArgsConstructor
// public class GameMessage implements Serializable {
//
// private Game game;
//
// private GameEvent event;
//
// private String username;
//
// private String image;
//
// public static GameMessageBuilder of(GameMessage gameMessage) {
// return GameMessage.builder()
// .event(gameMessage.getEvent())
// .game(gameMessage.getGame())
// .image(gameMessage.getImage())
// .username(gameMessage.getUsername());
// }
// }
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/controller/GameController.java
import be.ordina.jworks.rpsls.game.*;
import be.ordina.jworks.rpsls.game.pubsub.ChatEventPublisher;
import be.ordina.jworks.rpsls.game.pubsub.GameEventPublisher;
import be.ordina.jworks.rpsls.game.websocket.ChatMessage;
import be.ordina.jworks.rpsls.game.websocket.GameMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.security.Principal;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import static org.springframework.util.Assert.notNull;
package be.ordina.jworks.rpsls.controller;
@Slf4j
@RestController
public class GameController {
private final GameRepository gameRepository;
private final GameLogic gameLogic; | private final ChatEventPublisher chatEventPublisher; |
Turbots/SpringOne2016 | rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/controller/GameController.java | // Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/pubsub/ChatEventPublisher.java
// @Slf4j
// @Service
// public class ChatEventPublisher {
//
// private final RedisTemplate<String, Object> messageRedisTemplate;
// private final Topic topic;
//
// @Autowired
// public ChatEventPublisher(final RedisTemplate<String, Object> messageRedisTemplate, @Qualifier("chatTopic") final Topic topic) {
// this.messageRedisTemplate = messageRedisTemplate;
// this.topic = topic;
// }
//
// public void publish(final ChatMessage chatMessage) {
// log.info("Sending ChatMessage " + chatMessage);
// this.messageRedisTemplate.convertAndSend(topic.getTopic(), chatMessage);
// }
// }
//
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/pubsub/GameEventPublisher.java
// @Slf4j
// @Service
// public class GameEventPublisher {
//
// private final RedisTemplate<String, Object> messageRedisTemplate;
// private final Topic topic;
//
// @Autowired
// public GameEventPublisher(RedisTemplate<String, Object> messageRedisTemplate, @Qualifier("gameTopic") Topic topic) {
// this.messageRedisTemplate = messageRedisTemplate;
// this.topic = topic;
// }
//
// public void publish(final GameMessage gameMessage) {
// log.info("Sending GameMessage " + gameMessage);
// messageRedisTemplate.convertAndSend(topic.getTopic(), gameMessage);
// }
// }
//
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/websocket/ChatMessage.java
// @Getter
// @Builder
// @AllArgsConstructor
// public class ChatMessage implements Serializable {
//
// private String message;
// private String username;
//
// }
//
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/websocket/GameMessage.java
// @Getter
// @Builder
// @NoArgsConstructor
// @AllArgsConstructor
// public class GameMessage implements Serializable {
//
// private Game game;
//
// private GameEvent event;
//
// private String username;
//
// private String image;
//
// public static GameMessageBuilder of(GameMessage gameMessage) {
// return GameMessage.builder()
// .event(gameMessage.getEvent())
// .game(gameMessage.getGame())
// .image(gameMessage.getImage())
// .username(gameMessage.getUsername());
// }
// }
| import be.ordina.jworks.rpsls.game.*;
import be.ordina.jworks.rpsls.game.pubsub.ChatEventPublisher;
import be.ordina.jworks.rpsls.game.pubsub.GameEventPublisher;
import be.ordina.jworks.rpsls.game.websocket.ChatMessage;
import be.ordina.jworks.rpsls.game.websocket.GameMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.security.Principal;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import static org.springframework.util.Assert.notNull; | package be.ordina.jworks.rpsls.controller;
@Slf4j
@RestController
public class GameController {
private final GameRepository gameRepository;
private final GameLogic gameLogic;
private final ChatEventPublisher chatEventPublisher; | // Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/pubsub/ChatEventPublisher.java
// @Slf4j
// @Service
// public class ChatEventPublisher {
//
// private final RedisTemplate<String, Object> messageRedisTemplate;
// private final Topic topic;
//
// @Autowired
// public ChatEventPublisher(final RedisTemplate<String, Object> messageRedisTemplate, @Qualifier("chatTopic") final Topic topic) {
// this.messageRedisTemplate = messageRedisTemplate;
// this.topic = topic;
// }
//
// public void publish(final ChatMessage chatMessage) {
// log.info("Sending ChatMessage " + chatMessage);
// this.messageRedisTemplate.convertAndSend(topic.getTopic(), chatMessage);
// }
// }
//
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/pubsub/GameEventPublisher.java
// @Slf4j
// @Service
// public class GameEventPublisher {
//
// private final RedisTemplate<String, Object> messageRedisTemplate;
// private final Topic topic;
//
// @Autowired
// public GameEventPublisher(RedisTemplate<String, Object> messageRedisTemplate, @Qualifier("gameTopic") Topic topic) {
// this.messageRedisTemplate = messageRedisTemplate;
// this.topic = topic;
// }
//
// public void publish(final GameMessage gameMessage) {
// log.info("Sending GameMessage " + gameMessage);
// messageRedisTemplate.convertAndSend(topic.getTopic(), gameMessage);
// }
// }
//
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/websocket/ChatMessage.java
// @Getter
// @Builder
// @AllArgsConstructor
// public class ChatMessage implements Serializable {
//
// private String message;
// private String username;
//
// }
//
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/websocket/GameMessage.java
// @Getter
// @Builder
// @NoArgsConstructor
// @AllArgsConstructor
// public class GameMessage implements Serializable {
//
// private Game game;
//
// private GameEvent event;
//
// private String username;
//
// private String image;
//
// public static GameMessageBuilder of(GameMessage gameMessage) {
// return GameMessage.builder()
// .event(gameMessage.getEvent())
// .game(gameMessage.getGame())
// .image(gameMessage.getImage())
// .username(gameMessage.getUsername());
// }
// }
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/controller/GameController.java
import be.ordina.jworks.rpsls.game.*;
import be.ordina.jworks.rpsls.game.pubsub.ChatEventPublisher;
import be.ordina.jworks.rpsls.game.pubsub.GameEventPublisher;
import be.ordina.jworks.rpsls.game.websocket.ChatMessage;
import be.ordina.jworks.rpsls.game.websocket.GameMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.security.Principal;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import static org.springframework.util.Assert.notNull;
package be.ordina.jworks.rpsls.controller;
@Slf4j
@RestController
public class GameController {
private final GameRepository gameRepository;
private final GameLogic gameLogic;
private final ChatEventPublisher chatEventPublisher; | private final GameEventPublisher gameEventPublisher; |
Turbots/SpringOne2016 | rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/controller/GameController.java | // Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/pubsub/ChatEventPublisher.java
// @Slf4j
// @Service
// public class ChatEventPublisher {
//
// private final RedisTemplate<String, Object> messageRedisTemplate;
// private final Topic topic;
//
// @Autowired
// public ChatEventPublisher(final RedisTemplate<String, Object> messageRedisTemplate, @Qualifier("chatTopic") final Topic topic) {
// this.messageRedisTemplate = messageRedisTemplate;
// this.topic = topic;
// }
//
// public void publish(final ChatMessage chatMessage) {
// log.info("Sending ChatMessage " + chatMessage);
// this.messageRedisTemplate.convertAndSend(topic.getTopic(), chatMessage);
// }
// }
//
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/pubsub/GameEventPublisher.java
// @Slf4j
// @Service
// public class GameEventPublisher {
//
// private final RedisTemplate<String, Object> messageRedisTemplate;
// private final Topic topic;
//
// @Autowired
// public GameEventPublisher(RedisTemplate<String, Object> messageRedisTemplate, @Qualifier("gameTopic") Topic topic) {
// this.messageRedisTemplate = messageRedisTemplate;
// this.topic = topic;
// }
//
// public void publish(final GameMessage gameMessage) {
// log.info("Sending GameMessage " + gameMessage);
// messageRedisTemplate.convertAndSend(topic.getTopic(), gameMessage);
// }
// }
//
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/websocket/ChatMessage.java
// @Getter
// @Builder
// @AllArgsConstructor
// public class ChatMessage implements Serializable {
//
// private String message;
// private String username;
//
// }
//
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/websocket/GameMessage.java
// @Getter
// @Builder
// @NoArgsConstructor
// @AllArgsConstructor
// public class GameMessage implements Serializable {
//
// private Game game;
//
// private GameEvent event;
//
// private String username;
//
// private String image;
//
// public static GameMessageBuilder of(GameMessage gameMessage) {
// return GameMessage.builder()
// .event(gameMessage.getEvent())
// .game(gameMessage.getGame())
// .image(gameMessage.getImage())
// .username(gameMessage.getUsername());
// }
// }
| import be.ordina.jworks.rpsls.game.*;
import be.ordina.jworks.rpsls.game.pubsub.ChatEventPublisher;
import be.ordina.jworks.rpsls.game.pubsub.GameEventPublisher;
import be.ordina.jworks.rpsls.game.websocket.ChatMessage;
import be.ordina.jworks.rpsls.game.websocket.GameMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.security.Principal;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import static org.springframework.util.Assert.notNull; | package be.ordina.jworks.rpsls.controller;
@Slf4j
@RestController
public class GameController {
private final GameRepository gameRepository;
private final GameLogic gameLogic;
private final ChatEventPublisher chatEventPublisher;
private final GameEventPublisher gameEventPublisher;
@Autowired
public GameController(final GameRepository gameRepository, final GameLogic gameLogic, ChatEventPublisher chatEventPublisher, final GameEventPublisher gameEventPublisher) {
this.gameRepository = gameRepository;
this.gameLogic = gameLogic;
this.chatEventPublisher = chatEventPublisher;
this.gameEventPublisher = gameEventPublisher;
}
@RequestMapping("/game/player")
public Player getPlayer() {
return (Player) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
}
@MessageMapping("/chat") | // Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/pubsub/ChatEventPublisher.java
// @Slf4j
// @Service
// public class ChatEventPublisher {
//
// private final RedisTemplate<String, Object> messageRedisTemplate;
// private final Topic topic;
//
// @Autowired
// public ChatEventPublisher(final RedisTemplate<String, Object> messageRedisTemplate, @Qualifier("chatTopic") final Topic topic) {
// this.messageRedisTemplate = messageRedisTemplate;
// this.topic = topic;
// }
//
// public void publish(final ChatMessage chatMessage) {
// log.info("Sending ChatMessage " + chatMessage);
// this.messageRedisTemplate.convertAndSend(topic.getTopic(), chatMessage);
// }
// }
//
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/pubsub/GameEventPublisher.java
// @Slf4j
// @Service
// public class GameEventPublisher {
//
// private final RedisTemplate<String, Object> messageRedisTemplate;
// private final Topic topic;
//
// @Autowired
// public GameEventPublisher(RedisTemplate<String, Object> messageRedisTemplate, @Qualifier("gameTopic") Topic topic) {
// this.messageRedisTemplate = messageRedisTemplate;
// this.topic = topic;
// }
//
// public void publish(final GameMessage gameMessage) {
// log.info("Sending GameMessage " + gameMessage);
// messageRedisTemplate.convertAndSend(topic.getTopic(), gameMessage);
// }
// }
//
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/websocket/ChatMessage.java
// @Getter
// @Builder
// @AllArgsConstructor
// public class ChatMessage implements Serializable {
//
// private String message;
// private String username;
//
// }
//
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/websocket/GameMessage.java
// @Getter
// @Builder
// @NoArgsConstructor
// @AllArgsConstructor
// public class GameMessage implements Serializable {
//
// private Game game;
//
// private GameEvent event;
//
// private String username;
//
// private String image;
//
// public static GameMessageBuilder of(GameMessage gameMessage) {
// return GameMessage.builder()
// .event(gameMessage.getEvent())
// .game(gameMessage.getGame())
// .image(gameMessage.getImage())
// .username(gameMessage.getUsername());
// }
// }
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/controller/GameController.java
import be.ordina.jworks.rpsls.game.*;
import be.ordina.jworks.rpsls.game.pubsub.ChatEventPublisher;
import be.ordina.jworks.rpsls.game.pubsub.GameEventPublisher;
import be.ordina.jworks.rpsls.game.websocket.ChatMessage;
import be.ordina.jworks.rpsls.game.websocket.GameMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.security.Principal;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import static org.springframework.util.Assert.notNull;
package be.ordina.jworks.rpsls.controller;
@Slf4j
@RestController
public class GameController {
private final GameRepository gameRepository;
private final GameLogic gameLogic;
private final ChatEventPublisher chatEventPublisher;
private final GameEventPublisher gameEventPublisher;
@Autowired
public GameController(final GameRepository gameRepository, final GameLogic gameLogic, ChatEventPublisher chatEventPublisher, final GameEventPublisher gameEventPublisher) {
this.gameRepository = gameRepository;
this.gameLogic = gameLogic;
this.chatEventPublisher = chatEventPublisher;
this.gameEventPublisher = gameEventPublisher;
}
@RequestMapping("/game/player")
public Player getPlayer() {
return (Player) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
}
@MessageMapping("/chat") | public void chat(final ChatMessage chatMessage, final Principal principal) throws Exception { |
Turbots/SpringOne2016 | rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/controller/GameController.java | // Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/pubsub/ChatEventPublisher.java
// @Slf4j
// @Service
// public class ChatEventPublisher {
//
// private final RedisTemplate<String, Object> messageRedisTemplate;
// private final Topic topic;
//
// @Autowired
// public ChatEventPublisher(final RedisTemplate<String, Object> messageRedisTemplate, @Qualifier("chatTopic") final Topic topic) {
// this.messageRedisTemplate = messageRedisTemplate;
// this.topic = topic;
// }
//
// public void publish(final ChatMessage chatMessage) {
// log.info("Sending ChatMessage " + chatMessage);
// this.messageRedisTemplate.convertAndSend(topic.getTopic(), chatMessage);
// }
// }
//
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/pubsub/GameEventPublisher.java
// @Slf4j
// @Service
// public class GameEventPublisher {
//
// private final RedisTemplate<String, Object> messageRedisTemplate;
// private final Topic topic;
//
// @Autowired
// public GameEventPublisher(RedisTemplate<String, Object> messageRedisTemplate, @Qualifier("gameTopic") Topic topic) {
// this.messageRedisTemplate = messageRedisTemplate;
// this.topic = topic;
// }
//
// public void publish(final GameMessage gameMessage) {
// log.info("Sending GameMessage " + gameMessage);
// messageRedisTemplate.convertAndSend(topic.getTopic(), gameMessage);
// }
// }
//
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/websocket/ChatMessage.java
// @Getter
// @Builder
// @AllArgsConstructor
// public class ChatMessage implements Serializable {
//
// private String message;
// private String username;
//
// }
//
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/websocket/GameMessage.java
// @Getter
// @Builder
// @NoArgsConstructor
// @AllArgsConstructor
// public class GameMessage implements Serializable {
//
// private Game game;
//
// private GameEvent event;
//
// private String username;
//
// private String image;
//
// public static GameMessageBuilder of(GameMessage gameMessage) {
// return GameMessage.builder()
// .event(gameMessage.getEvent())
// .game(gameMessage.getGame())
// .image(gameMessage.getImage())
// .username(gameMessage.getUsername());
// }
// }
| import be.ordina.jworks.rpsls.game.*;
import be.ordina.jworks.rpsls.game.pubsub.ChatEventPublisher;
import be.ordina.jworks.rpsls.game.pubsub.GameEventPublisher;
import be.ordina.jworks.rpsls.game.websocket.ChatMessage;
import be.ordina.jworks.rpsls.game.websocket.GameMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.security.Principal;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import static org.springframework.util.Assert.notNull; | package be.ordina.jworks.rpsls.controller;
@Slf4j
@RestController
public class GameController {
private final GameRepository gameRepository;
private final GameLogic gameLogic;
private final ChatEventPublisher chatEventPublisher;
private final GameEventPublisher gameEventPublisher;
@Autowired
public GameController(final GameRepository gameRepository, final GameLogic gameLogic, ChatEventPublisher chatEventPublisher, final GameEventPublisher gameEventPublisher) {
this.gameRepository = gameRepository;
this.gameLogic = gameLogic;
this.chatEventPublisher = chatEventPublisher;
this.gameEventPublisher = gameEventPublisher;
}
@RequestMapping("/game/player")
public Player getPlayer() {
return (Player) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
}
@MessageMapping("/chat")
public void chat(final ChatMessage chatMessage, final Principal principal) throws Exception {
log.info("Chat >> [{}] >> [{}]", principal.getName(), chatMessage.getMessage());
ChatMessage message = ChatMessage.builder()
.message(chatMessage.getMessage())
.username(principal.getName())
.build();
this.chatEventPublisher.publish(message);
}
@MessageMapping("/game") | // Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/pubsub/ChatEventPublisher.java
// @Slf4j
// @Service
// public class ChatEventPublisher {
//
// private final RedisTemplate<String, Object> messageRedisTemplate;
// private final Topic topic;
//
// @Autowired
// public ChatEventPublisher(final RedisTemplate<String, Object> messageRedisTemplate, @Qualifier("chatTopic") final Topic topic) {
// this.messageRedisTemplate = messageRedisTemplate;
// this.topic = topic;
// }
//
// public void publish(final ChatMessage chatMessage) {
// log.info("Sending ChatMessage " + chatMessage);
// this.messageRedisTemplate.convertAndSend(topic.getTopic(), chatMessage);
// }
// }
//
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/pubsub/GameEventPublisher.java
// @Slf4j
// @Service
// public class GameEventPublisher {
//
// private final RedisTemplate<String, Object> messageRedisTemplate;
// private final Topic topic;
//
// @Autowired
// public GameEventPublisher(RedisTemplate<String, Object> messageRedisTemplate, @Qualifier("gameTopic") Topic topic) {
// this.messageRedisTemplate = messageRedisTemplate;
// this.topic = topic;
// }
//
// public void publish(final GameMessage gameMessage) {
// log.info("Sending GameMessage " + gameMessage);
// messageRedisTemplate.convertAndSend(topic.getTopic(), gameMessage);
// }
// }
//
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/websocket/ChatMessage.java
// @Getter
// @Builder
// @AllArgsConstructor
// public class ChatMessage implements Serializable {
//
// private String message;
// private String username;
//
// }
//
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/websocket/GameMessage.java
// @Getter
// @Builder
// @NoArgsConstructor
// @AllArgsConstructor
// public class GameMessage implements Serializable {
//
// private Game game;
//
// private GameEvent event;
//
// private String username;
//
// private String image;
//
// public static GameMessageBuilder of(GameMessage gameMessage) {
// return GameMessage.builder()
// .event(gameMessage.getEvent())
// .game(gameMessage.getGame())
// .image(gameMessage.getImage())
// .username(gameMessage.getUsername());
// }
// }
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/controller/GameController.java
import be.ordina.jworks.rpsls.game.*;
import be.ordina.jworks.rpsls.game.pubsub.ChatEventPublisher;
import be.ordina.jworks.rpsls.game.pubsub.GameEventPublisher;
import be.ordina.jworks.rpsls.game.websocket.ChatMessage;
import be.ordina.jworks.rpsls.game.websocket.GameMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.security.Principal;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import static org.springframework.util.Assert.notNull;
package be.ordina.jworks.rpsls.controller;
@Slf4j
@RestController
public class GameController {
private final GameRepository gameRepository;
private final GameLogic gameLogic;
private final ChatEventPublisher chatEventPublisher;
private final GameEventPublisher gameEventPublisher;
@Autowired
public GameController(final GameRepository gameRepository, final GameLogic gameLogic, ChatEventPublisher chatEventPublisher, final GameEventPublisher gameEventPublisher) {
this.gameRepository = gameRepository;
this.gameLogic = gameLogic;
this.chatEventPublisher = chatEventPublisher;
this.gameEventPublisher = gameEventPublisher;
}
@RequestMapping("/game/player")
public Player getPlayer() {
return (Player) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
}
@MessageMapping("/chat")
public void chat(final ChatMessage chatMessage, final Principal principal) throws Exception {
log.info("Chat >> [{}] >> [{}]", principal.getName(), chatMessage.getMessage());
ChatMessage message = ChatMessage.builder()
.message(chatMessage.getMessage())
.username(principal.getName())
.build();
this.chatEventPublisher.publish(message);
}
@MessageMapping("/game") | public void event(final GameMessage gameMessage, final Principal principal) throws Exception { |
Turbots/SpringOne2016 | social-redis-spring-boot-starter/src/main/java/org/springframework/boot/autoconfigure/social/TwitterRedisAutoConfiguration.java | // Path: social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/connection/RedisUsersConnectionRepository.java
// public class RedisUsersConnectionRepository implements UsersConnectionRepository {
//
// private final ConnectionFactoryLocator connectionFactoryLocator;
// private final TextEncryptor textEncryptor;
// private final SocialRedisConnectionRepository socialRedisConnectionRepository;
//
// public RedisUsersConnectionRepository(ConnectionFactoryLocator connectionFactoryLocator, TextEncryptor textEncryptor, SocialRedisConnectionRepository socialRedisConnectionRepository) {
// Assert.notNull(connectionFactoryLocator);
// Assert.notNull(textEncryptor);
// Assert.notNull(socialRedisConnectionRepository);
//
// this.connectionFactoryLocator = connectionFactoryLocator;
// this.textEncryptor = textEncryptor;
// this.socialRedisConnectionRepository = socialRedisConnectionRepository;
// }
//
// public List<String> findUserIdsWithConnection(final Connection<?> connection) {
// String providerId = connection.getKey().getProviderId();
// String providerUserId = connection.getKey().getProviderUserId();
//
// Iterable<SocialRedisConnection> connections = socialRedisConnectionRepository.findByProviderIdAndProviderUserId(providerId, providerUserId);
//
// List<String> userIds = new ArrayList<String>();
// for (SocialRedisConnection socialRedisConnection : connections) {
// userIds.add(socialRedisConnection.getUserId());
// }
//
// return userIds;
// }
//
// public Set<String> findUserIdsConnectedTo(final String providerId, final Set<String> providerUserIds) {
// Set<String> userIds = new HashSet<String>();
//
// for (String providerUserId : providerUserIds) {
// for (SocialRedisConnection socialRedisConnection : socialRedisConnectionRepository.findByProviderIdAndProviderUserId(providerId, providerUserId)) {
// userIds.add(socialRedisConnection.getUserId());
// }
// }
//
// return userIds;
// }
//
// public ConnectionRepository createConnectionRepository(final String userId) {
// return new RedisConnectionRepository(connectionFactoryLocator, textEncryptor, socialRedisConnectionRepository, userId);
// }
// }
//
// Path: social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/connection/data/SocialRedisConnectionRepository.java
// @Repository
// public interface SocialRedisConnectionRepository extends CrudRepository<SocialRedisConnection, String> {
//
// Iterable<SocialRedisConnection> findByProviderId(final String providerId);
//
// Iterable<SocialRedisConnection> findByUserIdAndProviderId(final String userId, final String providerId);
//
// SocialRedisConnection findOneByUserIdAndProviderIdAndProviderUserId(String userId, String providerId, String providerUserId);
//
// // TODO: will be available once DATAKV-135 is finished
// void deleteByUserIdAndProviderIdAndProviderUserId(final String userId, final String providerId, final String providerUserId);
//
// Iterable<SocialRedisConnection> findByUserId(final String userId);
//
// Iterable<SocialRedisConnection> findByProviderIdAndProviderUserId(final String providerId, final String providerUserId);
// }
| import be.ordina.jworks.social.redis.connection.RedisUsersConnectionRepository;
import be.ordina.jworks.social.redis.connection.data.SocialRedisConnectionRepository;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.*;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.*;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.crypto.encrypt.Encryptors;
import org.springframework.social.UserIdSource;
import org.springframework.social.config.annotation.EnableSocial;
import org.springframework.social.config.annotation.SocialConfigurerAdapter;
import org.springframework.social.connect.*;
import org.springframework.social.connect.web.GenericConnectionStatusView;
import org.springframework.social.connect.web.ProviderSignInController;
import org.springframework.social.connect.web.SignInAdapter;
import org.springframework.social.twitter.api.Twitter;
import org.springframework.social.twitter.api.impl.TwitterTemplate;
import org.springframework.social.twitter.connect.TwitterConnectionFactory;
import org.springframework.util.Assert;
import org.springframework.web.context.request.NativeWebRequest; | package org.springframework.boot.autoconfigure.social;
@Configuration
@ConditionalOnClass({SocialConfigurerAdapter.class, TwitterConnectionFactory.class})
@ConditionalOnProperty(prefix = "social.redis.twitter", name = "app-id")
@AutoConfigureAfter(SocialWebAutoConfiguration.class)
public class TwitterRedisAutoConfiguration {
@Configuration
@EnableSocial
@EnableConfigurationProperties(TwitterRedisProperties.class)
@ConditionalOnWebApplication
protected static class TwitterConfigurerAdapter extends SocialAutoConfigurerAdapter {
private final TwitterRedisProperties properties; | // Path: social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/connection/RedisUsersConnectionRepository.java
// public class RedisUsersConnectionRepository implements UsersConnectionRepository {
//
// private final ConnectionFactoryLocator connectionFactoryLocator;
// private final TextEncryptor textEncryptor;
// private final SocialRedisConnectionRepository socialRedisConnectionRepository;
//
// public RedisUsersConnectionRepository(ConnectionFactoryLocator connectionFactoryLocator, TextEncryptor textEncryptor, SocialRedisConnectionRepository socialRedisConnectionRepository) {
// Assert.notNull(connectionFactoryLocator);
// Assert.notNull(textEncryptor);
// Assert.notNull(socialRedisConnectionRepository);
//
// this.connectionFactoryLocator = connectionFactoryLocator;
// this.textEncryptor = textEncryptor;
// this.socialRedisConnectionRepository = socialRedisConnectionRepository;
// }
//
// public List<String> findUserIdsWithConnection(final Connection<?> connection) {
// String providerId = connection.getKey().getProviderId();
// String providerUserId = connection.getKey().getProviderUserId();
//
// Iterable<SocialRedisConnection> connections = socialRedisConnectionRepository.findByProviderIdAndProviderUserId(providerId, providerUserId);
//
// List<String> userIds = new ArrayList<String>();
// for (SocialRedisConnection socialRedisConnection : connections) {
// userIds.add(socialRedisConnection.getUserId());
// }
//
// return userIds;
// }
//
// public Set<String> findUserIdsConnectedTo(final String providerId, final Set<String> providerUserIds) {
// Set<String> userIds = new HashSet<String>();
//
// for (String providerUserId : providerUserIds) {
// for (SocialRedisConnection socialRedisConnection : socialRedisConnectionRepository.findByProviderIdAndProviderUserId(providerId, providerUserId)) {
// userIds.add(socialRedisConnection.getUserId());
// }
// }
//
// return userIds;
// }
//
// public ConnectionRepository createConnectionRepository(final String userId) {
// return new RedisConnectionRepository(connectionFactoryLocator, textEncryptor, socialRedisConnectionRepository, userId);
// }
// }
//
// Path: social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/connection/data/SocialRedisConnectionRepository.java
// @Repository
// public interface SocialRedisConnectionRepository extends CrudRepository<SocialRedisConnection, String> {
//
// Iterable<SocialRedisConnection> findByProviderId(final String providerId);
//
// Iterable<SocialRedisConnection> findByUserIdAndProviderId(final String userId, final String providerId);
//
// SocialRedisConnection findOneByUserIdAndProviderIdAndProviderUserId(String userId, String providerId, String providerUserId);
//
// // TODO: will be available once DATAKV-135 is finished
// void deleteByUserIdAndProviderIdAndProviderUserId(final String userId, final String providerId, final String providerUserId);
//
// Iterable<SocialRedisConnection> findByUserId(final String userId);
//
// Iterable<SocialRedisConnection> findByProviderIdAndProviderUserId(final String providerId, final String providerUserId);
// }
// Path: social-redis-spring-boot-starter/src/main/java/org/springframework/boot/autoconfigure/social/TwitterRedisAutoConfiguration.java
import be.ordina.jworks.social.redis.connection.RedisUsersConnectionRepository;
import be.ordina.jworks.social.redis.connection.data.SocialRedisConnectionRepository;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.*;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.*;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.crypto.encrypt.Encryptors;
import org.springframework.social.UserIdSource;
import org.springframework.social.config.annotation.EnableSocial;
import org.springframework.social.config.annotation.SocialConfigurerAdapter;
import org.springframework.social.connect.*;
import org.springframework.social.connect.web.GenericConnectionStatusView;
import org.springframework.social.connect.web.ProviderSignInController;
import org.springframework.social.connect.web.SignInAdapter;
import org.springframework.social.twitter.api.Twitter;
import org.springframework.social.twitter.api.impl.TwitterTemplate;
import org.springframework.social.twitter.connect.TwitterConnectionFactory;
import org.springframework.util.Assert;
import org.springframework.web.context.request.NativeWebRequest;
package org.springframework.boot.autoconfigure.social;
@Configuration
@ConditionalOnClass({SocialConfigurerAdapter.class, TwitterConnectionFactory.class})
@ConditionalOnProperty(prefix = "social.redis.twitter", name = "app-id")
@AutoConfigureAfter(SocialWebAutoConfiguration.class)
public class TwitterRedisAutoConfiguration {
@Configuration
@EnableSocial
@EnableConfigurationProperties(TwitterRedisProperties.class)
@ConditionalOnWebApplication
protected static class TwitterConfigurerAdapter extends SocialAutoConfigurerAdapter {
private final TwitterRedisProperties properties; | private final SocialRedisConnectionRepository socialRedisConnectionRepository; |
Turbots/SpringOne2016 | social-redis-spring-boot-starter/src/main/java/org/springframework/boot/autoconfigure/social/TwitterRedisAutoConfiguration.java | // Path: social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/connection/RedisUsersConnectionRepository.java
// public class RedisUsersConnectionRepository implements UsersConnectionRepository {
//
// private final ConnectionFactoryLocator connectionFactoryLocator;
// private final TextEncryptor textEncryptor;
// private final SocialRedisConnectionRepository socialRedisConnectionRepository;
//
// public RedisUsersConnectionRepository(ConnectionFactoryLocator connectionFactoryLocator, TextEncryptor textEncryptor, SocialRedisConnectionRepository socialRedisConnectionRepository) {
// Assert.notNull(connectionFactoryLocator);
// Assert.notNull(textEncryptor);
// Assert.notNull(socialRedisConnectionRepository);
//
// this.connectionFactoryLocator = connectionFactoryLocator;
// this.textEncryptor = textEncryptor;
// this.socialRedisConnectionRepository = socialRedisConnectionRepository;
// }
//
// public List<String> findUserIdsWithConnection(final Connection<?> connection) {
// String providerId = connection.getKey().getProviderId();
// String providerUserId = connection.getKey().getProviderUserId();
//
// Iterable<SocialRedisConnection> connections = socialRedisConnectionRepository.findByProviderIdAndProviderUserId(providerId, providerUserId);
//
// List<String> userIds = new ArrayList<String>();
// for (SocialRedisConnection socialRedisConnection : connections) {
// userIds.add(socialRedisConnection.getUserId());
// }
//
// return userIds;
// }
//
// public Set<String> findUserIdsConnectedTo(final String providerId, final Set<String> providerUserIds) {
// Set<String> userIds = new HashSet<String>();
//
// for (String providerUserId : providerUserIds) {
// for (SocialRedisConnection socialRedisConnection : socialRedisConnectionRepository.findByProviderIdAndProviderUserId(providerId, providerUserId)) {
// userIds.add(socialRedisConnection.getUserId());
// }
// }
//
// return userIds;
// }
//
// public ConnectionRepository createConnectionRepository(final String userId) {
// return new RedisConnectionRepository(connectionFactoryLocator, textEncryptor, socialRedisConnectionRepository, userId);
// }
// }
//
// Path: social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/connection/data/SocialRedisConnectionRepository.java
// @Repository
// public interface SocialRedisConnectionRepository extends CrudRepository<SocialRedisConnection, String> {
//
// Iterable<SocialRedisConnection> findByProviderId(final String providerId);
//
// Iterable<SocialRedisConnection> findByUserIdAndProviderId(final String userId, final String providerId);
//
// SocialRedisConnection findOneByUserIdAndProviderIdAndProviderUserId(String userId, String providerId, String providerUserId);
//
// // TODO: will be available once DATAKV-135 is finished
// void deleteByUserIdAndProviderIdAndProviderUserId(final String userId, final String providerId, final String providerUserId);
//
// Iterable<SocialRedisConnection> findByUserId(final String userId);
//
// Iterable<SocialRedisConnection> findByProviderIdAndProviderUserId(final String providerId, final String providerUserId);
// }
| import be.ordina.jworks.social.redis.connection.RedisUsersConnectionRepository;
import be.ordina.jworks.social.redis.connection.data.SocialRedisConnectionRepository;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.*;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.*;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.crypto.encrypt.Encryptors;
import org.springframework.social.UserIdSource;
import org.springframework.social.config.annotation.EnableSocial;
import org.springframework.social.config.annotation.SocialConfigurerAdapter;
import org.springframework.social.connect.*;
import org.springframework.social.connect.web.GenericConnectionStatusView;
import org.springframework.social.connect.web.ProviderSignInController;
import org.springframework.social.connect.web.SignInAdapter;
import org.springframework.social.twitter.api.Twitter;
import org.springframework.social.twitter.api.impl.TwitterTemplate;
import org.springframework.social.twitter.connect.TwitterConnectionFactory;
import org.springframework.util.Assert;
import org.springframework.web.context.request.NativeWebRequest; | return usersConnectionRepository.createConnectionRepository(getUserIdSource().getUserId());
}
@Bean(name = {"connect/twitterConnect", "connect/twitterConnected"})
@ConditionalOnProperty(prefix = "spring.social", name = "auto-connection-views")
public GenericConnectionStatusView twitterConnectView() {
return new GenericConnectionStatusView("twitter", "Twitter");
}
@Bean
@ConditionalOnMissingBean
public ProviderSignInController providerSignInController(ConnectionFactoryLocator connectionFactoryLocator, UsersConnectionRepository usersConnectionRepository) {
return new ProviderSignInController(connectionFactoryLocator, usersConnectionRepository, new SpringSecuritySignInAdapter());
}
private class SpringSecuritySignInAdapter implements SignInAdapter {
public String signIn(String localUserId, Connection<?> connection, NativeWebRequest request) {
SecurityContextHolder.getContext().setAuthentication(new UsernamePasswordAuthenticationToken(localUserId, null, null));
return null;
}
}
@Override
protected ConnectionFactory<?> createConnectionFactory() {
return new TwitterConnectionFactory(this.properties.getAppId(),
this.properties.getAppSecret());
}
@Override
public UsersConnectionRepository getUsersConnectionRepository(ConnectionFactoryLocator connectionFactoryLocator) { | // Path: social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/connection/RedisUsersConnectionRepository.java
// public class RedisUsersConnectionRepository implements UsersConnectionRepository {
//
// private final ConnectionFactoryLocator connectionFactoryLocator;
// private final TextEncryptor textEncryptor;
// private final SocialRedisConnectionRepository socialRedisConnectionRepository;
//
// public RedisUsersConnectionRepository(ConnectionFactoryLocator connectionFactoryLocator, TextEncryptor textEncryptor, SocialRedisConnectionRepository socialRedisConnectionRepository) {
// Assert.notNull(connectionFactoryLocator);
// Assert.notNull(textEncryptor);
// Assert.notNull(socialRedisConnectionRepository);
//
// this.connectionFactoryLocator = connectionFactoryLocator;
// this.textEncryptor = textEncryptor;
// this.socialRedisConnectionRepository = socialRedisConnectionRepository;
// }
//
// public List<String> findUserIdsWithConnection(final Connection<?> connection) {
// String providerId = connection.getKey().getProviderId();
// String providerUserId = connection.getKey().getProviderUserId();
//
// Iterable<SocialRedisConnection> connections = socialRedisConnectionRepository.findByProviderIdAndProviderUserId(providerId, providerUserId);
//
// List<String> userIds = new ArrayList<String>();
// for (SocialRedisConnection socialRedisConnection : connections) {
// userIds.add(socialRedisConnection.getUserId());
// }
//
// return userIds;
// }
//
// public Set<String> findUserIdsConnectedTo(final String providerId, final Set<String> providerUserIds) {
// Set<String> userIds = new HashSet<String>();
//
// for (String providerUserId : providerUserIds) {
// for (SocialRedisConnection socialRedisConnection : socialRedisConnectionRepository.findByProviderIdAndProviderUserId(providerId, providerUserId)) {
// userIds.add(socialRedisConnection.getUserId());
// }
// }
//
// return userIds;
// }
//
// public ConnectionRepository createConnectionRepository(final String userId) {
// return new RedisConnectionRepository(connectionFactoryLocator, textEncryptor, socialRedisConnectionRepository, userId);
// }
// }
//
// Path: social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/connection/data/SocialRedisConnectionRepository.java
// @Repository
// public interface SocialRedisConnectionRepository extends CrudRepository<SocialRedisConnection, String> {
//
// Iterable<SocialRedisConnection> findByProviderId(final String providerId);
//
// Iterable<SocialRedisConnection> findByUserIdAndProviderId(final String userId, final String providerId);
//
// SocialRedisConnection findOneByUserIdAndProviderIdAndProviderUserId(String userId, String providerId, String providerUserId);
//
// // TODO: will be available once DATAKV-135 is finished
// void deleteByUserIdAndProviderIdAndProviderUserId(final String userId, final String providerId, final String providerUserId);
//
// Iterable<SocialRedisConnection> findByUserId(final String userId);
//
// Iterable<SocialRedisConnection> findByProviderIdAndProviderUserId(final String providerId, final String providerUserId);
// }
// Path: social-redis-spring-boot-starter/src/main/java/org/springframework/boot/autoconfigure/social/TwitterRedisAutoConfiguration.java
import be.ordina.jworks.social.redis.connection.RedisUsersConnectionRepository;
import be.ordina.jworks.social.redis.connection.data.SocialRedisConnectionRepository;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.*;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.*;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.crypto.encrypt.Encryptors;
import org.springframework.social.UserIdSource;
import org.springframework.social.config.annotation.EnableSocial;
import org.springframework.social.config.annotation.SocialConfigurerAdapter;
import org.springframework.social.connect.*;
import org.springframework.social.connect.web.GenericConnectionStatusView;
import org.springframework.social.connect.web.ProviderSignInController;
import org.springframework.social.connect.web.SignInAdapter;
import org.springframework.social.twitter.api.Twitter;
import org.springframework.social.twitter.api.impl.TwitterTemplate;
import org.springframework.social.twitter.connect.TwitterConnectionFactory;
import org.springframework.util.Assert;
import org.springframework.web.context.request.NativeWebRequest;
return usersConnectionRepository.createConnectionRepository(getUserIdSource().getUserId());
}
@Bean(name = {"connect/twitterConnect", "connect/twitterConnected"})
@ConditionalOnProperty(prefix = "spring.social", name = "auto-connection-views")
public GenericConnectionStatusView twitterConnectView() {
return new GenericConnectionStatusView("twitter", "Twitter");
}
@Bean
@ConditionalOnMissingBean
public ProviderSignInController providerSignInController(ConnectionFactoryLocator connectionFactoryLocator, UsersConnectionRepository usersConnectionRepository) {
return new ProviderSignInController(connectionFactoryLocator, usersConnectionRepository, new SpringSecuritySignInAdapter());
}
private class SpringSecuritySignInAdapter implements SignInAdapter {
public String signIn(String localUserId, Connection<?> connection, NativeWebRequest request) {
SecurityContextHolder.getContext().setAuthentication(new UsernamePasswordAuthenticationToken(localUserId, null, null));
return null;
}
}
@Override
protected ConnectionFactory<?> createConnectionFactory() {
return new TwitterConnectionFactory(this.properties.getAppId(),
this.properties.getAppSecret());
}
@Override
public UsersConnectionRepository getUsersConnectionRepository(ConnectionFactoryLocator connectionFactoryLocator) { | return new RedisUsersConnectionRepository(connectionFactoryLocator, Encryptors.noOpText(), socialRedisConnectionRepository); |
Turbots/SpringOne2016 | social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/connection/RedisUsersConnectionRepository.java | // Path: social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/connection/data/SocialRedisConnection.java
// @Getter
// @Setter
// @AllArgsConstructor
// @RedisHash("socialRedisConnection")
// public class SocialRedisConnection {
//
// @Id
// @Indexed
// private String providerUserId;
//
// @Indexed
// private String userId;
//
// @Indexed
// private String providerId;
//
// private String displayName;
//
// private String profileUrl;
//
// private String imageUrl;
//
// private String accessToken;
//
// private String secret;
//
// private String refreshToken;
//
// private Long expireTime;
// }
//
// Path: social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/connection/data/SocialRedisConnectionRepository.java
// @Repository
// public interface SocialRedisConnectionRepository extends CrudRepository<SocialRedisConnection, String> {
//
// Iterable<SocialRedisConnection> findByProviderId(final String providerId);
//
// Iterable<SocialRedisConnection> findByUserIdAndProviderId(final String userId, final String providerId);
//
// SocialRedisConnection findOneByUserIdAndProviderIdAndProviderUserId(String userId, String providerId, String providerUserId);
//
// // TODO: will be available once DATAKV-135 is finished
// void deleteByUserIdAndProviderIdAndProviderUserId(final String userId, final String providerId, final String providerUserId);
//
// Iterable<SocialRedisConnection> findByUserId(final String userId);
//
// Iterable<SocialRedisConnection> findByProviderIdAndProviderUserId(final String providerId, final String providerUserId);
// }
| import be.ordina.jworks.social.redis.connection.data.SocialRedisConnection;
import be.ordina.jworks.social.redis.connection.data.SocialRedisConnectionRepository;
import org.springframework.security.crypto.encrypt.TextEncryptor;
import org.springframework.social.connect.Connection;
import org.springframework.social.connect.ConnectionFactoryLocator;
import org.springframework.social.connect.ConnectionRepository;
import org.springframework.social.connect.UsersConnectionRepository;
import org.springframework.util.Assert;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set; | package be.ordina.jworks.social.redis.connection;
public class RedisUsersConnectionRepository implements UsersConnectionRepository {
private final ConnectionFactoryLocator connectionFactoryLocator;
private final TextEncryptor textEncryptor; | // Path: social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/connection/data/SocialRedisConnection.java
// @Getter
// @Setter
// @AllArgsConstructor
// @RedisHash("socialRedisConnection")
// public class SocialRedisConnection {
//
// @Id
// @Indexed
// private String providerUserId;
//
// @Indexed
// private String userId;
//
// @Indexed
// private String providerId;
//
// private String displayName;
//
// private String profileUrl;
//
// private String imageUrl;
//
// private String accessToken;
//
// private String secret;
//
// private String refreshToken;
//
// private Long expireTime;
// }
//
// Path: social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/connection/data/SocialRedisConnectionRepository.java
// @Repository
// public interface SocialRedisConnectionRepository extends CrudRepository<SocialRedisConnection, String> {
//
// Iterable<SocialRedisConnection> findByProviderId(final String providerId);
//
// Iterable<SocialRedisConnection> findByUserIdAndProviderId(final String userId, final String providerId);
//
// SocialRedisConnection findOneByUserIdAndProviderIdAndProviderUserId(String userId, String providerId, String providerUserId);
//
// // TODO: will be available once DATAKV-135 is finished
// void deleteByUserIdAndProviderIdAndProviderUserId(final String userId, final String providerId, final String providerUserId);
//
// Iterable<SocialRedisConnection> findByUserId(final String userId);
//
// Iterable<SocialRedisConnection> findByProviderIdAndProviderUserId(final String providerId, final String providerUserId);
// }
// Path: social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/connection/RedisUsersConnectionRepository.java
import be.ordina.jworks.social.redis.connection.data.SocialRedisConnection;
import be.ordina.jworks.social.redis.connection.data.SocialRedisConnectionRepository;
import org.springframework.security.crypto.encrypt.TextEncryptor;
import org.springframework.social.connect.Connection;
import org.springframework.social.connect.ConnectionFactoryLocator;
import org.springframework.social.connect.ConnectionRepository;
import org.springframework.social.connect.UsersConnectionRepository;
import org.springframework.util.Assert;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
package be.ordina.jworks.social.redis.connection;
public class RedisUsersConnectionRepository implements UsersConnectionRepository {
private final ConnectionFactoryLocator connectionFactoryLocator;
private final TextEncryptor textEncryptor; | private final SocialRedisConnectionRepository socialRedisConnectionRepository; |
Turbots/SpringOne2016 | social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/connection/RedisUsersConnectionRepository.java | // Path: social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/connection/data/SocialRedisConnection.java
// @Getter
// @Setter
// @AllArgsConstructor
// @RedisHash("socialRedisConnection")
// public class SocialRedisConnection {
//
// @Id
// @Indexed
// private String providerUserId;
//
// @Indexed
// private String userId;
//
// @Indexed
// private String providerId;
//
// private String displayName;
//
// private String profileUrl;
//
// private String imageUrl;
//
// private String accessToken;
//
// private String secret;
//
// private String refreshToken;
//
// private Long expireTime;
// }
//
// Path: social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/connection/data/SocialRedisConnectionRepository.java
// @Repository
// public interface SocialRedisConnectionRepository extends CrudRepository<SocialRedisConnection, String> {
//
// Iterable<SocialRedisConnection> findByProviderId(final String providerId);
//
// Iterable<SocialRedisConnection> findByUserIdAndProviderId(final String userId, final String providerId);
//
// SocialRedisConnection findOneByUserIdAndProviderIdAndProviderUserId(String userId, String providerId, String providerUserId);
//
// // TODO: will be available once DATAKV-135 is finished
// void deleteByUserIdAndProviderIdAndProviderUserId(final String userId, final String providerId, final String providerUserId);
//
// Iterable<SocialRedisConnection> findByUserId(final String userId);
//
// Iterable<SocialRedisConnection> findByProviderIdAndProviderUserId(final String providerId, final String providerUserId);
// }
| import be.ordina.jworks.social.redis.connection.data.SocialRedisConnection;
import be.ordina.jworks.social.redis.connection.data.SocialRedisConnectionRepository;
import org.springframework.security.crypto.encrypt.TextEncryptor;
import org.springframework.social.connect.Connection;
import org.springframework.social.connect.ConnectionFactoryLocator;
import org.springframework.social.connect.ConnectionRepository;
import org.springframework.social.connect.UsersConnectionRepository;
import org.springframework.util.Assert;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set; | package be.ordina.jworks.social.redis.connection;
public class RedisUsersConnectionRepository implements UsersConnectionRepository {
private final ConnectionFactoryLocator connectionFactoryLocator;
private final TextEncryptor textEncryptor;
private final SocialRedisConnectionRepository socialRedisConnectionRepository;
public RedisUsersConnectionRepository(ConnectionFactoryLocator connectionFactoryLocator, TextEncryptor textEncryptor, SocialRedisConnectionRepository socialRedisConnectionRepository) {
Assert.notNull(connectionFactoryLocator);
Assert.notNull(textEncryptor);
Assert.notNull(socialRedisConnectionRepository);
this.connectionFactoryLocator = connectionFactoryLocator;
this.textEncryptor = textEncryptor;
this.socialRedisConnectionRepository = socialRedisConnectionRepository;
}
public List<String> findUserIdsWithConnection(final Connection<?> connection) {
String providerId = connection.getKey().getProviderId();
String providerUserId = connection.getKey().getProviderUserId();
| // Path: social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/connection/data/SocialRedisConnection.java
// @Getter
// @Setter
// @AllArgsConstructor
// @RedisHash("socialRedisConnection")
// public class SocialRedisConnection {
//
// @Id
// @Indexed
// private String providerUserId;
//
// @Indexed
// private String userId;
//
// @Indexed
// private String providerId;
//
// private String displayName;
//
// private String profileUrl;
//
// private String imageUrl;
//
// private String accessToken;
//
// private String secret;
//
// private String refreshToken;
//
// private Long expireTime;
// }
//
// Path: social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/connection/data/SocialRedisConnectionRepository.java
// @Repository
// public interface SocialRedisConnectionRepository extends CrudRepository<SocialRedisConnection, String> {
//
// Iterable<SocialRedisConnection> findByProviderId(final String providerId);
//
// Iterable<SocialRedisConnection> findByUserIdAndProviderId(final String userId, final String providerId);
//
// SocialRedisConnection findOneByUserIdAndProviderIdAndProviderUserId(String userId, String providerId, String providerUserId);
//
// // TODO: will be available once DATAKV-135 is finished
// void deleteByUserIdAndProviderIdAndProviderUserId(final String userId, final String providerId, final String providerUserId);
//
// Iterable<SocialRedisConnection> findByUserId(final String userId);
//
// Iterable<SocialRedisConnection> findByProviderIdAndProviderUserId(final String providerId, final String providerUserId);
// }
// Path: social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/connection/RedisUsersConnectionRepository.java
import be.ordina.jworks.social.redis.connection.data.SocialRedisConnection;
import be.ordina.jworks.social.redis.connection.data.SocialRedisConnectionRepository;
import org.springframework.security.crypto.encrypt.TextEncryptor;
import org.springframework.social.connect.Connection;
import org.springframework.social.connect.ConnectionFactoryLocator;
import org.springframework.social.connect.ConnectionRepository;
import org.springframework.social.connect.UsersConnectionRepository;
import org.springframework.util.Assert;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
package be.ordina.jworks.social.redis.connection;
public class RedisUsersConnectionRepository implements UsersConnectionRepository {
private final ConnectionFactoryLocator connectionFactoryLocator;
private final TextEncryptor textEncryptor;
private final SocialRedisConnectionRepository socialRedisConnectionRepository;
public RedisUsersConnectionRepository(ConnectionFactoryLocator connectionFactoryLocator, TextEncryptor textEncryptor, SocialRedisConnectionRepository socialRedisConnectionRepository) {
Assert.notNull(connectionFactoryLocator);
Assert.notNull(textEncryptor);
Assert.notNull(socialRedisConnectionRepository);
this.connectionFactoryLocator = connectionFactoryLocator;
this.textEncryptor = textEncryptor;
this.socialRedisConnectionRepository = socialRedisConnectionRepository;
}
public List<String> findUserIdsWithConnection(final Connection<?> connection) {
String providerId = connection.getKey().getProviderId();
String providerUserId = connection.getKey().getProviderUserId();
| Iterable<SocialRedisConnection> connections = socialRedisConnectionRepository.findByProviderIdAndProviderUserId(providerId, providerUserId); |
Turbots/SpringOne2016 | rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/pubsub/ChatEventPublisher.java | // Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/websocket/ChatMessage.java
// @Getter
// @Builder
// @AllArgsConstructor
// public class ChatMessage implements Serializable {
//
// private String message;
// private String username;
//
// }
| import be.ordina.jworks.rpsls.game.websocket.ChatMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.listener.Topic;
import org.springframework.stereotype.Service; | package be.ordina.jworks.rpsls.game.pubsub;
@Slf4j
@Service
public class ChatEventPublisher {
private final RedisTemplate<String, Object> messageRedisTemplate;
private final Topic topic;
@Autowired
public ChatEventPublisher(final RedisTemplate<String, Object> messageRedisTemplate, @Qualifier("chatTopic") final Topic topic) {
this.messageRedisTemplate = messageRedisTemplate;
this.topic = topic;
}
| // Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/websocket/ChatMessage.java
// @Getter
// @Builder
// @AllArgsConstructor
// public class ChatMessage implements Serializable {
//
// private String message;
// private String username;
//
// }
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/pubsub/ChatEventPublisher.java
import be.ordina.jworks.rpsls.game.websocket.ChatMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.listener.Topic;
import org.springframework.stereotype.Service;
package be.ordina.jworks.rpsls.game.pubsub;
@Slf4j
@Service
public class ChatEventPublisher {
private final RedisTemplate<String, Object> messageRedisTemplate;
private final Topic topic;
@Autowired
public ChatEventPublisher(final RedisTemplate<String, Object> messageRedisTemplate, @Qualifier("chatTopic") final Topic topic) {
this.messageRedisTemplate = messageRedisTemplate;
this.topic = topic;
}
| public void publish(final ChatMessage chatMessage) { |
Turbots/SpringOne2016 | joshlong-emon/src/main/java/com/example/JoshLongEmonAutoConfiguration.java | // Path: joshlong-emon/src/main/java/com/example/logic/OrderedPicProvider.java
// public class OrderedPicProvider implements PictureProvider {
//
// private final List<String> pics;
// private Iterator<String> iterator;
//
// public OrderedPicProvider(List<String> pics) {
// this.pics = sortPics(pics);
// this.iterator = pics.iterator();
// }
//
// private List<String> sortPics(final List<String> pics) {
// List<String> copy = new ArrayList<>(pics);
// Collections.sort(copy);
//
// return copy;
// }
//
// @Override
// public String getNextPicture() {
// if (iterator.hasNext()) {
// return iterator.next();
// } else {
// this.iterator = this.pics.iterator();
// return iterator.next();
// }
// }
// }
//
// Path: joshlong-emon/src/main/java/com/example/logic/PictureProvider.java
// public interface PictureProvider {
//
// String getNextPicture();
// }
//
// Path: joshlong-emon/src/main/java/com/example/logic/RandomPicProvider.java
// public class RandomPicProvider implements PictureProvider {
//
// private final static Random RAND = new Random();
//
// private final List<String> pics;
//
// public RandomPicProvider(final List<String> pics) {
// this.pics = pics;
// }
//
// @Override
// public String getNextPicture() {
// return pics.get(RAND.nextInt(pics.size()));
// }
// }
| import com.example.logic.OrderedPicProvider;
import com.example.logic.PictureProvider;
import com.example.logic.RandomPicProvider;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import java.util.ArrayList;
import java.util.List; | package com.example;
@Configuration
@ComponentScan("com.example.controller")
@ConditionalOnWebApplication
public class JoshLongEmonAutoConfiguration {
private static final List<String> wildPokemon;
static {
wildPokemon = new ArrayList<>();
wildPokemon.add("https://pbs.twimg.com/media/CpAEg2WUkAA46Xk.jpg");
wildPokemon.add("https://pbs.twimg.com/media/CpAFCCgVIAAZbGB.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co_5W8rVYAEcW5g.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co_m3YiUEAAUCXw.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co_EWBgVYAAnPME.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co-tpclUIAI7sFC.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co-j-c2UIAALN-o.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co-YP1ZUsAA0y8q.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co-SqeGUsAEgADj.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co-WR0mVMAAxv4y.jpg");
}
@Bean
@ConditionalOnMissingBean
@ConditionalOnProperty(prefix = "josh.long", name = "pics", havingValue = "random") | // Path: joshlong-emon/src/main/java/com/example/logic/OrderedPicProvider.java
// public class OrderedPicProvider implements PictureProvider {
//
// private final List<String> pics;
// private Iterator<String> iterator;
//
// public OrderedPicProvider(List<String> pics) {
// this.pics = sortPics(pics);
// this.iterator = pics.iterator();
// }
//
// private List<String> sortPics(final List<String> pics) {
// List<String> copy = new ArrayList<>(pics);
// Collections.sort(copy);
//
// return copy;
// }
//
// @Override
// public String getNextPicture() {
// if (iterator.hasNext()) {
// return iterator.next();
// } else {
// this.iterator = this.pics.iterator();
// return iterator.next();
// }
// }
// }
//
// Path: joshlong-emon/src/main/java/com/example/logic/PictureProvider.java
// public interface PictureProvider {
//
// String getNextPicture();
// }
//
// Path: joshlong-emon/src/main/java/com/example/logic/RandomPicProvider.java
// public class RandomPicProvider implements PictureProvider {
//
// private final static Random RAND = new Random();
//
// private final List<String> pics;
//
// public RandomPicProvider(final List<String> pics) {
// this.pics = pics;
// }
//
// @Override
// public String getNextPicture() {
// return pics.get(RAND.nextInt(pics.size()));
// }
// }
// Path: joshlong-emon/src/main/java/com/example/JoshLongEmonAutoConfiguration.java
import com.example.logic.OrderedPicProvider;
import com.example.logic.PictureProvider;
import com.example.logic.RandomPicProvider;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import java.util.ArrayList;
import java.util.List;
package com.example;
@Configuration
@ComponentScan("com.example.controller")
@ConditionalOnWebApplication
public class JoshLongEmonAutoConfiguration {
private static final List<String> wildPokemon;
static {
wildPokemon = new ArrayList<>();
wildPokemon.add("https://pbs.twimg.com/media/CpAEg2WUkAA46Xk.jpg");
wildPokemon.add("https://pbs.twimg.com/media/CpAFCCgVIAAZbGB.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co_5W8rVYAEcW5g.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co_m3YiUEAAUCXw.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co_EWBgVYAAnPME.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co-tpclUIAI7sFC.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co-j-c2UIAALN-o.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co-YP1ZUsAA0y8q.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co-SqeGUsAEgADj.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co-WR0mVMAAxv4y.jpg");
}
@Bean
@ConditionalOnMissingBean
@ConditionalOnProperty(prefix = "josh.long", name = "pics", havingValue = "random") | public PictureProvider randomizedJoshLongPicProvider() { |
Turbots/SpringOne2016 | joshlong-emon/src/main/java/com/example/JoshLongEmonAutoConfiguration.java | // Path: joshlong-emon/src/main/java/com/example/logic/OrderedPicProvider.java
// public class OrderedPicProvider implements PictureProvider {
//
// private final List<String> pics;
// private Iterator<String> iterator;
//
// public OrderedPicProvider(List<String> pics) {
// this.pics = sortPics(pics);
// this.iterator = pics.iterator();
// }
//
// private List<String> sortPics(final List<String> pics) {
// List<String> copy = new ArrayList<>(pics);
// Collections.sort(copy);
//
// return copy;
// }
//
// @Override
// public String getNextPicture() {
// if (iterator.hasNext()) {
// return iterator.next();
// } else {
// this.iterator = this.pics.iterator();
// return iterator.next();
// }
// }
// }
//
// Path: joshlong-emon/src/main/java/com/example/logic/PictureProvider.java
// public interface PictureProvider {
//
// String getNextPicture();
// }
//
// Path: joshlong-emon/src/main/java/com/example/logic/RandomPicProvider.java
// public class RandomPicProvider implements PictureProvider {
//
// private final static Random RAND = new Random();
//
// private final List<String> pics;
//
// public RandomPicProvider(final List<String> pics) {
// this.pics = pics;
// }
//
// @Override
// public String getNextPicture() {
// return pics.get(RAND.nextInt(pics.size()));
// }
// }
| import com.example.logic.OrderedPicProvider;
import com.example.logic.PictureProvider;
import com.example.logic.RandomPicProvider;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import java.util.ArrayList;
import java.util.List; | package com.example;
@Configuration
@ComponentScan("com.example.controller")
@ConditionalOnWebApplication
public class JoshLongEmonAutoConfiguration {
private static final List<String> wildPokemon;
static {
wildPokemon = new ArrayList<>();
wildPokemon.add("https://pbs.twimg.com/media/CpAEg2WUkAA46Xk.jpg");
wildPokemon.add("https://pbs.twimg.com/media/CpAFCCgVIAAZbGB.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co_5W8rVYAEcW5g.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co_m3YiUEAAUCXw.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co_EWBgVYAAnPME.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co-tpclUIAI7sFC.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co-j-c2UIAALN-o.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co-YP1ZUsAA0y8q.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co-SqeGUsAEgADj.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co-WR0mVMAAxv4y.jpg");
}
@Bean
@ConditionalOnMissingBean
@ConditionalOnProperty(prefix = "josh.long", name = "pics", havingValue = "random")
public PictureProvider randomizedJoshLongPicProvider() { | // Path: joshlong-emon/src/main/java/com/example/logic/OrderedPicProvider.java
// public class OrderedPicProvider implements PictureProvider {
//
// private final List<String> pics;
// private Iterator<String> iterator;
//
// public OrderedPicProvider(List<String> pics) {
// this.pics = sortPics(pics);
// this.iterator = pics.iterator();
// }
//
// private List<String> sortPics(final List<String> pics) {
// List<String> copy = new ArrayList<>(pics);
// Collections.sort(copy);
//
// return copy;
// }
//
// @Override
// public String getNextPicture() {
// if (iterator.hasNext()) {
// return iterator.next();
// } else {
// this.iterator = this.pics.iterator();
// return iterator.next();
// }
// }
// }
//
// Path: joshlong-emon/src/main/java/com/example/logic/PictureProvider.java
// public interface PictureProvider {
//
// String getNextPicture();
// }
//
// Path: joshlong-emon/src/main/java/com/example/logic/RandomPicProvider.java
// public class RandomPicProvider implements PictureProvider {
//
// private final static Random RAND = new Random();
//
// private final List<String> pics;
//
// public RandomPicProvider(final List<String> pics) {
// this.pics = pics;
// }
//
// @Override
// public String getNextPicture() {
// return pics.get(RAND.nextInt(pics.size()));
// }
// }
// Path: joshlong-emon/src/main/java/com/example/JoshLongEmonAutoConfiguration.java
import com.example.logic.OrderedPicProvider;
import com.example.logic.PictureProvider;
import com.example.logic.RandomPicProvider;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import java.util.ArrayList;
import java.util.List;
package com.example;
@Configuration
@ComponentScan("com.example.controller")
@ConditionalOnWebApplication
public class JoshLongEmonAutoConfiguration {
private static final List<String> wildPokemon;
static {
wildPokemon = new ArrayList<>();
wildPokemon.add("https://pbs.twimg.com/media/CpAEg2WUkAA46Xk.jpg");
wildPokemon.add("https://pbs.twimg.com/media/CpAFCCgVIAAZbGB.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co_5W8rVYAEcW5g.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co_m3YiUEAAUCXw.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co_EWBgVYAAnPME.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co-tpclUIAI7sFC.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co-j-c2UIAALN-o.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co-YP1ZUsAA0y8q.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co-SqeGUsAEgADj.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co-WR0mVMAAxv4y.jpg");
}
@Bean
@ConditionalOnMissingBean
@ConditionalOnProperty(prefix = "josh.long", name = "pics", havingValue = "random")
public PictureProvider randomizedJoshLongPicProvider() { | return new RandomPicProvider(wildPokemon); |
Turbots/SpringOne2016 | joshlong-emon/src/main/java/com/example/JoshLongEmonAutoConfiguration.java | // Path: joshlong-emon/src/main/java/com/example/logic/OrderedPicProvider.java
// public class OrderedPicProvider implements PictureProvider {
//
// private final List<String> pics;
// private Iterator<String> iterator;
//
// public OrderedPicProvider(List<String> pics) {
// this.pics = sortPics(pics);
// this.iterator = pics.iterator();
// }
//
// private List<String> sortPics(final List<String> pics) {
// List<String> copy = new ArrayList<>(pics);
// Collections.sort(copy);
//
// return copy;
// }
//
// @Override
// public String getNextPicture() {
// if (iterator.hasNext()) {
// return iterator.next();
// } else {
// this.iterator = this.pics.iterator();
// return iterator.next();
// }
// }
// }
//
// Path: joshlong-emon/src/main/java/com/example/logic/PictureProvider.java
// public interface PictureProvider {
//
// String getNextPicture();
// }
//
// Path: joshlong-emon/src/main/java/com/example/logic/RandomPicProvider.java
// public class RandomPicProvider implements PictureProvider {
//
// private final static Random RAND = new Random();
//
// private final List<String> pics;
//
// public RandomPicProvider(final List<String> pics) {
// this.pics = pics;
// }
//
// @Override
// public String getNextPicture() {
// return pics.get(RAND.nextInt(pics.size()));
// }
// }
| import com.example.logic.OrderedPicProvider;
import com.example.logic.PictureProvider;
import com.example.logic.RandomPicProvider;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import java.util.ArrayList;
import java.util.List; | package com.example;
@Configuration
@ComponentScan("com.example.controller")
@ConditionalOnWebApplication
public class JoshLongEmonAutoConfiguration {
private static final List<String> wildPokemon;
static {
wildPokemon = new ArrayList<>();
wildPokemon.add("https://pbs.twimg.com/media/CpAEg2WUkAA46Xk.jpg");
wildPokemon.add("https://pbs.twimg.com/media/CpAFCCgVIAAZbGB.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co_5W8rVYAEcW5g.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co_m3YiUEAAUCXw.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co_EWBgVYAAnPME.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co-tpclUIAI7sFC.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co-j-c2UIAALN-o.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co-YP1ZUsAA0y8q.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co-SqeGUsAEgADj.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co-WR0mVMAAxv4y.jpg");
}
@Bean
@ConditionalOnMissingBean
@ConditionalOnProperty(prefix = "josh.long", name = "pics", havingValue = "random")
public PictureProvider randomizedJoshLongPicProvider() {
return new RandomPicProvider(wildPokemon);
}
@Bean
@ConditionalOnMissingBean
@ConditionalOnProperty(prefix = "josh.long", name = "pics", havingValue = "ordered")
public PictureProvider orderedJoshLongPicProvider() { | // Path: joshlong-emon/src/main/java/com/example/logic/OrderedPicProvider.java
// public class OrderedPicProvider implements PictureProvider {
//
// private final List<String> pics;
// private Iterator<String> iterator;
//
// public OrderedPicProvider(List<String> pics) {
// this.pics = sortPics(pics);
// this.iterator = pics.iterator();
// }
//
// private List<String> sortPics(final List<String> pics) {
// List<String> copy = new ArrayList<>(pics);
// Collections.sort(copy);
//
// return copy;
// }
//
// @Override
// public String getNextPicture() {
// if (iterator.hasNext()) {
// return iterator.next();
// } else {
// this.iterator = this.pics.iterator();
// return iterator.next();
// }
// }
// }
//
// Path: joshlong-emon/src/main/java/com/example/logic/PictureProvider.java
// public interface PictureProvider {
//
// String getNextPicture();
// }
//
// Path: joshlong-emon/src/main/java/com/example/logic/RandomPicProvider.java
// public class RandomPicProvider implements PictureProvider {
//
// private final static Random RAND = new Random();
//
// private final List<String> pics;
//
// public RandomPicProvider(final List<String> pics) {
// this.pics = pics;
// }
//
// @Override
// public String getNextPicture() {
// return pics.get(RAND.nextInt(pics.size()));
// }
// }
// Path: joshlong-emon/src/main/java/com/example/JoshLongEmonAutoConfiguration.java
import com.example.logic.OrderedPicProvider;
import com.example.logic.PictureProvider;
import com.example.logic.RandomPicProvider;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import java.util.ArrayList;
import java.util.List;
package com.example;
@Configuration
@ComponentScan("com.example.controller")
@ConditionalOnWebApplication
public class JoshLongEmonAutoConfiguration {
private static final List<String> wildPokemon;
static {
wildPokemon = new ArrayList<>();
wildPokemon.add("https://pbs.twimg.com/media/CpAEg2WUkAA46Xk.jpg");
wildPokemon.add("https://pbs.twimg.com/media/CpAFCCgVIAAZbGB.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co_5W8rVYAEcW5g.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co_m3YiUEAAUCXw.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co_EWBgVYAAnPME.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co-tpclUIAI7sFC.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co-j-c2UIAALN-o.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co-YP1ZUsAA0y8q.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co-SqeGUsAEgADj.jpg");
wildPokemon.add("https://pbs.twimg.com/media/Co-WR0mVMAAxv4y.jpg");
}
@Bean
@ConditionalOnMissingBean
@ConditionalOnProperty(prefix = "josh.long", name = "pics", havingValue = "random")
public PictureProvider randomizedJoshLongPicProvider() {
return new RandomPicProvider(wildPokemon);
}
@Bean
@ConditionalOnMissingBean
@ConditionalOnProperty(prefix = "josh.long", name = "pics", havingValue = "ordered")
public PictureProvider orderedJoshLongPicProvider() { | return new OrderedPicProvider(wildPokemon); |
Turbots/SpringOne2016 | rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/configuration/AuthenticationUtil.java | // Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/Player.java
// @Getter
// @Builder
// @AllArgsConstructor
// public class Player implements Serializable {
//
// private String username;
// private String image;
// private String url;
// }
| import be.ordina.jworks.rpsls.game.Player;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.social.connect.Connection;
import java.util.Collections; | package be.ordina.jworks.rpsls.configuration;
@Slf4j
public class AuthenticationUtil {
public static void authenticate(Connection<?> connection) { | // Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/Player.java
// @Getter
// @Builder
// @AllArgsConstructor
// public class Player implements Serializable {
//
// private String username;
// private String image;
// private String url;
// }
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/configuration/AuthenticationUtil.java
import be.ordina.jworks.rpsls.game.Player;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.social.connect.Connection;
import java.util.Collections;
package be.ordina.jworks.rpsls.configuration;
@Slf4j
public class AuthenticationUtil {
public static void authenticate(Connection<?> connection) { | Player player = Player.builder() |
Turbots/SpringOne2016 | rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/websocket/GameMessage.java | // Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/Game.java
// @Getter
// @Setter
// @Builder
// @RedisHash(value = "games", timeToLive = 1800)
// @AllArgsConstructor
// public class Game implements Comparable<Game>, Serializable {
//
// @Id
// @Indexed
// private String id;
//
// private LocalDateTime start;
// private LocalDateTime end;
// private String playerOne;
// private String playerOneImage;
// private int playerOneMove;
// private String playerTwo;
// private String playerTwoImage;
// private int playerTwoMove;
//
// @JsonIgnore
// public LocalDateTime getStart() {
// return this.start;
// }
//
// @JsonIgnore
// public LocalDateTime getEnd() {
// return this.end;
// }
//
// @Override
// public int compareTo(Game that) {
// if (this.start.compareTo(that.start) > 0) {
// return -1;
// } else if (this.start.compareTo(that.start) < 0) {
// return 1;
// }
// return 0;
// }
// }
//
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/GameEvent.java
// public enum GameEvent implements Serializable {
//
// SPECTATOR_JOINED(0),
// PLAYER_ONE_JOINED(0),
// PLAYER_TWO_JOINED(0),
// PLAYER_ONE_WINS(0),
// PLAYER_TWO_WINS(0),
// GAME_TIED(0),
// NO_WINNER_YET(0),
// PLAYER_ONE_ROCK(1),
// PLAYER_ONE_PAPER(2),
// PLAYER_ONE_SCISSORS(3),
// PLAYER_ONE_LIZARD(4),
// PLAYER_ONE_SPOCK(5),
// PLAYER_TWO_ROCK(1),
// PLAYER_TWO_PAPER(2),
// PLAYER_TWO_SCISSORS(3),
// PLAYER_TWO_LIZARD(4),
// PLAYER_TWO_SPOCK(5);
//
// private int value;
//
// GameEvent(final int value) {
// this.value = value;
// }
//
// public int value() {
// return this.value;
// }
//
// }
| import be.ordina.jworks.rpsls.game.Game;
import be.ordina.jworks.rpsls.game.GameEvent;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import java.io.Serializable; | package be.ordina.jworks.rpsls.game.websocket;
@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class GameMessage implements Serializable {
| // Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/Game.java
// @Getter
// @Setter
// @Builder
// @RedisHash(value = "games", timeToLive = 1800)
// @AllArgsConstructor
// public class Game implements Comparable<Game>, Serializable {
//
// @Id
// @Indexed
// private String id;
//
// private LocalDateTime start;
// private LocalDateTime end;
// private String playerOne;
// private String playerOneImage;
// private int playerOneMove;
// private String playerTwo;
// private String playerTwoImage;
// private int playerTwoMove;
//
// @JsonIgnore
// public LocalDateTime getStart() {
// return this.start;
// }
//
// @JsonIgnore
// public LocalDateTime getEnd() {
// return this.end;
// }
//
// @Override
// public int compareTo(Game that) {
// if (this.start.compareTo(that.start) > 0) {
// return -1;
// } else if (this.start.compareTo(that.start) < 0) {
// return 1;
// }
// return 0;
// }
// }
//
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/GameEvent.java
// public enum GameEvent implements Serializable {
//
// SPECTATOR_JOINED(0),
// PLAYER_ONE_JOINED(0),
// PLAYER_TWO_JOINED(0),
// PLAYER_ONE_WINS(0),
// PLAYER_TWO_WINS(0),
// GAME_TIED(0),
// NO_WINNER_YET(0),
// PLAYER_ONE_ROCK(1),
// PLAYER_ONE_PAPER(2),
// PLAYER_ONE_SCISSORS(3),
// PLAYER_ONE_LIZARD(4),
// PLAYER_ONE_SPOCK(5),
// PLAYER_TWO_ROCK(1),
// PLAYER_TWO_PAPER(2),
// PLAYER_TWO_SCISSORS(3),
// PLAYER_TWO_LIZARD(4),
// PLAYER_TWO_SPOCK(5);
//
// private int value;
//
// GameEvent(final int value) {
// this.value = value;
// }
//
// public int value() {
// return this.value;
// }
//
// }
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/websocket/GameMessage.java
import be.ordina.jworks.rpsls.game.Game;
import be.ordina.jworks.rpsls.game.GameEvent;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import java.io.Serializable;
package be.ordina.jworks.rpsls.game.websocket;
@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class GameMessage implements Serializable {
| private Game game; |
Turbots/SpringOne2016 | rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/websocket/GameMessage.java | // Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/Game.java
// @Getter
// @Setter
// @Builder
// @RedisHash(value = "games", timeToLive = 1800)
// @AllArgsConstructor
// public class Game implements Comparable<Game>, Serializable {
//
// @Id
// @Indexed
// private String id;
//
// private LocalDateTime start;
// private LocalDateTime end;
// private String playerOne;
// private String playerOneImage;
// private int playerOneMove;
// private String playerTwo;
// private String playerTwoImage;
// private int playerTwoMove;
//
// @JsonIgnore
// public LocalDateTime getStart() {
// return this.start;
// }
//
// @JsonIgnore
// public LocalDateTime getEnd() {
// return this.end;
// }
//
// @Override
// public int compareTo(Game that) {
// if (this.start.compareTo(that.start) > 0) {
// return -1;
// } else if (this.start.compareTo(that.start) < 0) {
// return 1;
// }
// return 0;
// }
// }
//
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/GameEvent.java
// public enum GameEvent implements Serializable {
//
// SPECTATOR_JOINED(0),
// PLAYER_ONE_JOINED(0),
// PLAYER_TWO_JOINED(0),
// PLAYER_ONE_WINS(0),
// PLAYER_TWO_WINS(0),
// GAME_TIED(0),
// NO_WINNER_YET(0),
// PLAYER_ONE_ROCK(1),
// PLAYER_ONE_PAPER(2),
// PLAYER_ONE_SCISSORS(3),
// PLAYER_ONE_LIZARD(4),
// PLAYER_ONE_SPOCK(5),
// PLAYER_TWO_ROCK(1),
// PLAYER_TWO_PAPER(2),
// PLAYER_TWO_SCISSORS(3),
// PLAYER_TWO_LIZARD(4),
// PLAYER_TWO_SPOCK(5);
//
// private int value;
//
// GameEvent(final int value) {
// this.value = value;
// }
//
// public int value() {
// return this.value;
// }
//
// }
| import be.ordina.jworks.rpsls.game.Game;
import be.ordina.jworks.rpsls.game.GameEvent;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import java.io.Serializable; | package be.ordina.jworks.rpsls.game.websocket;
@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class GameMessage implements Serializable {
private Game game;
| // Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/Game.java
// @Getter
// @Setter
// @Builder
// @RedisHash(value = "games", timeToLive = 1800)
// @AllArgsConstructor
// public class Game implements Comparable<Game>, Serializable {
//
// @Id
// @Indexed
// private String id;
//
// private LocalDateTime start;
// private LocalDateTime end;
// private String playerOne;
// private String playerOneImage;
// private int playerOneMove;
// private String playerTwo;
// private String playerTwoImage;
// private int playerTwoMove;
//
// @JsonIgnore
// public LocalDateTime getStart() {
// return this.start;
// }
//
// @JsonIgnore
// public LocalDateTime getEnd() {
// return this.end;
// }
//
// @Override
// public int compareTo(Game that) {
// if (this.start.compareTo(that.start) > 0) {
// return -1;
// } else if (this.start.compareTo(that.start) < 0) {
// return 1;
// }
// return 0;
// }
// }
//
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/GameEvent.java
// public enum GameEvent implements Serializable {
//
// SPECTATOR_JOINED(0),
// PLAYER_ONE_JOINED(0),
// PLAYER_TWO_JOINED(0),
// PLAYER_ONE_WINS(0),
// PLAYER_TWO_WINS(0),
// GAME_TIED(0),
// NO_WINNER_YET(0),
// PLAYER_ONE_ROCK(1),
// PLAYER_ONE_PAPER(2),
// PLAYER_ONE_SCISSORS(3),
// PLAYER_ONE_LIZARD(4),
// PLAYER_ONE_SPOCK(5),
// PLAYER_TWO_ROCK(1),
// PLAYER_TWO_PAPER(2),
// PLAYER_TWO_SCISSORS(3),
// PLAYER_TWO_LIZARD(4),
// PLAYER_TWO_SPOCK(5);
//
// private int value;
//
// GameEvent(final int value) {
// this.value = value;
// }
//
// public int value() {
// return this.value;
// }
//
// }
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/websocket/GameMessage.java
import be.ordina.jworks.rpsls.game.Game;
import be.ordina.jworks.rpsls.game.GameEvent;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import java.io.Serializable;
package be.ordina.jworks.rpsls.game.websocket;
@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class GameMessage implements Serializable {
private Game game;
| private GameEvent event; |
Turbots/SpringOne2016 | rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/pubsub/GameEventPublisher.java | // Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/websocket/GameMessage.java
// @Getter
// @Builder
// @NoArgsConstructor
// @AllArgsConstructor
// public class GameMessage implements Serializable {
//
// private Game game;
//
// private GameEvent event;
//
// private String username;
//
// private String image;
//
// public static GameMessageBuilder of(GameMessage gameMessage) {
// return GameMessage.builder()
// .event(gameMessage.getEvent())
// .game(gameMessage.getGame())
// .image(gameMessage.getImage())
// .username(gameMessage.getUsername());
// }
// }
| import be.ordina.jworks.rpsls.game.websocket.GameMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.listener.Topic;
import org.springframework.stereotype.Service; | package be.ordina.jworks.rpsls.game.pubsub;
@Slf4j
@Service
public class GameEventPublisher {
private final RedisTemplate<String, Object> messageRedisTemplate;
private final Topic topic;
@Autowired
public GameEventPublisher(RedisTemplate<String, Object> messageRedisTemplate, @Qualifier("gameTopic") Topic topic) {
this.messageRedisTemplate = messageRedisTemplate;
this.topic = topic;
}
| // Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/websocket/GameMessage.java
// @Getter
// @Builder
// @NoArgsConstructor
// @AllArgsConstructor
// public class GameMessage implements Serializable {
//
// private Game game;
//
// private GameEvent event;
//
// private String username;
//
// private String image;
//
// public static GameMessageBuilder of(GameMessage gameMessage) {
// return GameMessage.builder()
// .event(gameMessage.getEvent())
// .game(gameMessage.getGame())
// .image(gameMessage.getImage())
// .username(gameMessage.getUsername());
// }
// }
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/pubsub/GameEventPublisher.java
import be.ordina.jworks.rpsls.game.websocket.GameMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.listener.Topic;
import org.springframework.stereotype.Service;
package be.ordina.jworks.rpsls.game.pubsub;
@Slf4j
@Service
public class GameEventPublisher {
private final RedisTemplate<String, Object> messageRedisTemplate;
private final Topic topic;
@Autowired
public GameEventPublisher(RedisTemplate<String, Object> messageRedisTemplate, @Qualifier("gameTopic") Topic topic) {
this.messageRedisTemplate = messageRedisTemplate;
this.topic = topic;
}
| public void publish(final GameMessage gameMessage) { |
Turbots/SpringOne2016 | rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/controller/PlayerController.java | // Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/Player.java
// @Getter
// @Builder
// @AllArgsConstructor
// public class Player implements Serializable {
//
// private String username;
// private String image;
// private String url;
// }
| import be.ordina.jworks.rpsls.game.Player;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.social.connect.Connection;
import org.springframework.social.connect.ConnectionRepository;
import org.springframework.social.connect.NotConnectedException;
import org.springframework.social.twitter.api.Twitter;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpSession; | package be.ordina.jworks.rpsls.controller;
@Slf4j
@RestController
@RequestMapping("/game/player")
public class PlayerController {
private final ConnectionRepository connectionRepository;
@Autowired
public PlayerController(final ConnectionRepository connectionRepository) {
this.connectionRepository = connectionRepository;
}
@RequestMapping(method = RequestMethod.GET) | // Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/Player.java
// @Getter
// @Builder
// @AllArgsConstructor
// public class Player implements Serializable {
//
// private String username;
// private String image;
// private String url;
// }
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/controller/PlayerController.java
import be.ordina.jworks.rpsls.game.Player;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.social.connect.Connection;
import org.springframework.social.connect.ConnectionRepository;
import org.springframework.social.connect.NotConnectedException;
import org.springframework.social.twitter.api.Twitter;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpSession;
package be.ordina.jworks.rpsls.controller;
@Slf4j
@RestController
@RequestMapping("/game/player")
public class PlayerController {
private final ConnectionRepository connectionRepository;
@Autowired
public PlayerController(final ConnectionRepository connectionRepository) {
this.connectionRepository = connectionRepository;
}
@RequestMapping(method = RequestMethod.GET) | public ResponseEntity<Player> userSession(final HttpSession session) { |
Turbots/SpringOne2016 | rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/configuration/RedisConfiguration.java | // Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/pubsub/ChatEventConsumer.java
// @Slf4j
// public class ChatEventConsumer {
//
// private final SimpMessagingTemplate template;
//
// public ChatEventConsumer(SimpMessagingTemplate template) {
// this.template = template;
// }
//
// @SuppressWarnings("unused")
// public void handleMessage(final String message) {
// log.debug("[CHAT] " + message);
//
// log.info("Sending ChatEvent to Websocket: " + message);
// template.convertAndSend("/topic/chat", message);
// }
// }
//
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/pubsub/GameEventConsumer.java
// @Slf4j
// public class GameEventConsumer {
//
// private final SimpMessagingTemplate template;
//
// public GameEventConsumer(SimpMessagingTemplate template) {
// this.template = template;
// }
//
// @SuppressWarnings("unused")
// public void handleMessage(final String message) {
// log.info("[GAME] " + message);
//
// log.info("Sending GameEvent to Websocket: " + message);
// template.convertAndSend("/topic/game", message);
// }
// }
| import be.ordina.jworks.rpsls.game.pubsub.ChatEventConsumer;
import be.ordina.jworks.rpsls.game.pubsub.GameEventConsumer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.listener.ChannelTopic;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.data.redis.listener.Topic;
import org.springframework.data.redis.listener.adapter.MessageListenerAdapter;
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import redis.clients.jedis.JedisShardInfo; | package be.ordina.jworks.rpsls.configuration;
@Slf4j
@Configuration
@EnableRedisRepositories(basePackages = "be.ordina.jworks.rpsls.game")
public class RedisConfiguration {
@Bean
public RedisConnectionFactory redisConnectionFactory() {
return new JedisConnectionFactory(new JedisShardInfo("localhost"));
}
@Bean
public RedisMessageListenerContainer redisContainer(SimpMessagingTemplate simpMessagingTemplate) {
RedisMessageListenerContainer container = new RedisMessageListenerContainer();
container.setConnectionFactory(redisConnectionFactory());
container.addMessageListener(gameMessageListener(simpMessagingTemplate), gameTopic());
container.addMessageListener(chatMessageListener(simpMessagingTemplate), chatTopic());
return container;
}
@Bean
public RedisTemplate<String, Object> messageRedisTemplate() {
RedisTemplate<String, Object> template = new RedisTemplate<>();
template.setConnectionFactory(redisConnectionFactory());
template.setKeySerializer(new StringRedisSerializer());
template.setValueSerializer(new JsonRedisSerializer());
return template;
}
@Bean
public MessageListener gameMessageListener(SimpMessagingTemplate simpMessagingTemplate) { | // Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/pubsub/ChatEventConsumer.java
// @Slf4j
// public class ChatEventConsumer {
//
// private final SimpMessagingTemplate template;
//
// public ChatEventConsumer(SimpMessagingTemplate template) {
// this.template = template;
// }
//
// @SuppressWarnings("unused")
// public void handleMessage(final String message) {
// log.debug("[CHAT] " + message);
//
// log.info("Sending ChatEvent to Websocket: " + message);
// template.convertAndSend("/topic/chat", message);
// }
// }
//
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/pubsub/GameEventConsumer.java
// @Slf4j
// public class GameEventConsumer {
//
// private final SimpMessagingTemplate template;
//
// public GameEventConsumer(SimpMessagingTemplate template) {
// this.template = template;
// }
//
// @SuppressWarnings("unused")
// public void handleMessage(final String message) {
// log.info("[GAME] " + message);
//
// log.info("Sending GameEvent to Websocket: " + message);
// template.convertAndSend("/topic/game", message);
// }
// }
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/configuration/RedisConfiguration.java
import be.ordina.jworks.rpsls.game.pubsub.ChatEventConsumer;
import be.ordina.jworks.rpsls.game.pubsub.GameEventConsumer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.listener.ChannelTopic;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.data.redis.listener.Topic;
import org.springframework.data.redis.listener.adapter.MessageListenerAdapter;
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import redis.clients.jedis.JedisShardInfo;
package be.ordina.jworks.rpsls.configuration;
@Slf4j
@Configuration
@EnableRedisRepositories(basePackages = "be.ordina.jworks.rpsls.game")
public class RedisConfiguration {
@Bean
public RedisConnectionFactory redisConnectionFactory() {
return new JedisConnectionFactory(new JedisShardInfo("localhost"));
}
@Bean
public RedisMessageListenerContainer redisContainer(SimpMessagingTemplate simpMessagingTemplate) {
RedisMessageListenerContainer container = new RedisMessageListenerContainer();
container.setConnectionFactory(redisConnectionFactory());
container.addMessageListener(gameMessageListener(simpMessagingTemplate), gameTopic());
container.addMessageListener(chatMessageListener(simpMessagingTemplate), chatTopic());
return container;
}
@Bean
public RedisTemplate<String, Object> messageRedisTemplate() {
RedisTemplate<String, Object> template = new RedisTemplate<>();
template.setConnectionFactory(redisConnectionFactory());
template.setKeySerializer(new StringRedisSerializer());
template.setValueSerializer(new JsonRedisSerializer());
return template;
}
@Bean
public MessageListener gameMessageListener(SimpMessagingTemplate simpMessagingTemplate) { | return new MessageListenerAdapter(new GameEventConsumer(simpMessagingTemplate)); |
Turbots/SpringOne2016 | rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/configuration/RedisConfiguration.java | // Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/pubsub/ChatEventConsumer.java
// @Slf4j
// public class ChatEventConsumer {
//
// private final SimpMessagingTemplate template;
//
// public ChatEventConsumer(SimpMessagingTemplate template) {
// this.template = template;
// }
//
// @SuppressWarnings("unused")
// public void handleMessage(final String message) {
// log.debug("[CHAT] " + message);
//
// log.info("Sending ChatEvent to Websocket: " + message);
// template.convertAndSend("/topic/chat", message);
// }
// }
//
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/pubsub/GameEventConsumer.java
// @Slf4j
// public class GameEventConsumer {
//
// private final SimpMessagingTemplate template;
//
// public GameEventConsumer(SimpMessagingTemplate template) {
// this.template = template;
// }
//
// @SuppressWarnings("unused")
// public void handleMessage(final String message) {
// log.info("[GAME] " + message);
//
// log.info("Sending GameEvent to Websocket: " + message);
// template.convertAndSend("/topic/game", message);
// }
// }
| import be.ordina.jworks.rpsls.game.pubsub.ChatEventConsumer;
import be.ordina.jworks.rpsls.game.pubsub.GameEventConsumer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.listener.ChannelTopic;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.data.redis.listener.Topic;
import org.springframework.data.redis.listener.adapter.MessageListenerAdapter;
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import redis.clients.jedis.JedisShardInfo; | container.setConnectionFactory(redisConnectionFactory());
container.addMessageListener(gameMessageListener(simpMessagingTemplate), gameTopic());
container.addMessageListener(chatMessageListener(simpMessagingTemplate), chatTopic());
return container;
}
@Bean
public RedisTemplate<String, Object> messageRedisTemplate() {
RedisTemplate<String, Object> template = new RedisTemplate<>();
template.setConnectionFactory(redisConnectionFactory());
template.setKeySerializer(new StringRedisSerializer());
template.setValueSerializer(new JsonRedisSerializer());
return template;
}
@Bean
public MessageListener gameMessageListener(SimpMessagingTemplate simpMessagingTemplate) {
return new MessageListenerAdapter(new GameEventConsumer(simpMessagingTemplate));
}
@Bean
public Topic gameTopic() {
return new ChannelTopic("pubsub:game");
}
@Bean
public MessageListener chatMessageListener(SimpMessagingTemplate simpMessagingTemplate) { | // Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/pubsub/ChatEventConsumer.java
// @Slf4j
// public class ChatEventConsumer {
//
// private final SimpMessagingTemplate template;
//
// public ChatEventConsumer(SimpMessagingTemplate template) {
// this.template = template;
// }
//
// @SuppressWarnings("unused")
// public void handleMessage(final String message) {
// log.debug("[CHAT] " + message);
//
// log.info("Sending ChatEvent to Websocket: " + message);
// template.convertAndSend("/topic/chat", message);
// }
// }
//
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/pubsub/GameEventConsumer.java
// @Slf4j
// public class GameEventConsumer {
//
// private final SimpMessagingTemplate template;
//
// public GameEventConsumer(SimpMessagingTemplate template) {
// this.template = template;
// }
//
// @SuppressWarnings("unused")
// public void handleMessage(final String message) {
// log.info("[GAME] " + message);
//
// log.info("Sending GameEvent to Websocket: " + message);
// template.convertAndSend("/topic/game", message);
// }
// }
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/configuration/RedisConfiguration.java
import be.ordina.jworks.rpsls.game.pubsub.ChatEventConsumer;
import be.ordina.jworks.rpsls.game.pubsub.GameEventConsumer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.listener.ChannelTopic;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.data.redis.listener.Topic;
import org.springframework.data.redis.listener.adapter.MessageListenerAdapter;
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import redis.clients.jedis.JedisShardInfo;
container.setConnectionFactory(redisConnectionFactory());
container.addMessageListener(gameMessageListener(simpMessagingTemplate), gameTopic());
container.addMessageListener(chatMessageListener(simpMessagingTemplate), chatTopic());
return container;
}
@Bean
public RedisTemplate<String, Object> messageRedisTemplate() {
RedisTemplate<String, Object> template = new RedisTemplate<>();
template.setConnectionFactory(redisConnectionFactory());
template.setKeySerializer(new StringRedisSerializer());
template.setValueSerializer(new JsonRedisSerializer());
return template;
}
@Bean
public MessageListener gameMessageListener(SimpMessagingTemplate simpMessagingTemplate) {
return new MessageListenerAdapter(new GameEventConsumer(simpMessagingTemplate));
}
@Bean
public Topic gameTopic() {
return new ChannelTopic("pubsub:game");
}
@Bean
public MessageListener chatMessageListener(SimpMessagingTemplate simpMessagingTemplate) { | return new MessageListenerAdapter(new ChatEventConsumer(simpMessagingTemplate)); |
Turbots/SpringOne2016 | social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/SocialRedisAutoConfiguration.java | // Path: social-redis-spring-boot-starter/src/main/java/org/springframework/boot/autoconfigure/social/TwitterRedisAutoConfiguration.java
// @Configuration
// @ConditionalOnClass({SocialConfigurerAdapter.class, TwitterConnectionFactory.class})
// @ConditionalOnProperty(prefix = "social.redis.twitter", name = "app-id")
// @AutoConfigureAfter(SocialWebAutoConfiguration.class)
// public class TwitterRedisAutoConfiguration {
//
// @Configuration
// @EnableSocial
// @EnableConfigurationProperties(TwitterRedisProperties.class)
// @ConditionalOnWebApplication
// protected static class TwitterConfigurerAdapter extends SocialAutoConfigurerAdapter {
//
// private final TwitterRedisProperties properties;
// private final SocialRedisConnectionRepository socialRedisConnectionRepository;
//
// protected TwitterConfigurerAdapter(TwitterRedisProperties properties, SocialRedisConnectionRepository socialRedisConnectionRepository) {
// this.properties = properties;
// this.socialRedisConnectionRepository = socialRedisConnectionRepository;
// }
//
// @Bean
// @ConditionalOnMissingBean
// @Scope(value = "request", proxyMode = ScopedProxyMode.INTERFACES)
// public Twitter twitter(ConnectionRepository repository) {
// Connection<Twitter> connection = repository
// .findPrimaryConnection(Twitter.class);
// if (connection != null) {
// return connection.getApi();
// }
// return new TwitterTemplate(this.properties.getAppId(),
// this.properties.getAppSecret());
// }
//
// @Bean
// @Primary
// @ConditionalOnBean(RedisConnectionFactory.class)
// @Scope(value = "request", proxyMode = ScopedProxyMode.INTERFACES)
// public ConnectionRepository connectionRepository(UsersConnectionRepository usersConnectionRepository) {
// return usersConnectionRepository.createConnectionRepository(getUserIdSource().getUserId());
// }
//
// @Bean(name = {"connect/twitterConnect", "connect/twitterConnected"})
// @ConditionalOnProperty(prefix = "spring.social", name = "auto-connection-views")
// public GenericConnectionStatusView twitterConnectView() {
// return new GenericConnectionStatusView("twitter", "Twitter");
// }
//
// @Bean
// @ConditionalOnMissingBean
// public ProviderSignInController providerSignInController(ConnectionFactoryLocator connectionFactoryLocator, UsersConnectionRepository usersConnectionRepository) {
// return new ProviderSignInController(connectionFactoryLocator, usersConnectionRepository, new SpringSecuritySignInAdapter());
// }
//
// private class SpringSecuritySignInAdapter implements SignInAdapter {
// public String signIn(String localUserId, Connection<?> connection, NativeWebRequest request) {
// SecurityContextHolder.getContext().setAuthentication(new UsernamePasswordAuthenticationToken(localUserId, null, null));
// return null;
// }
// }
//
// @Override
// protected ConnectionFactory<?> createConnectionFactory() {
// return new TwitterConnectionFactory(this.properties.getAppId(),
// this.properties.getAppSecret());
// }
//
// @Override
// public UsersConnectionRepository getUsersConnectionRepository(ConnectionFactoryLocator connectionFactoryLocator) {
// return new RedisUsersConnectionRepository(connectionFactoryLocator, Encryptors.noOpText(), socialRedisConnectionRepository);
// }
//
// @Override
// public UserIdSource getUserIdSource() {
// return () -> {
// SecurityContext context = SecurityContextHolder.getContext();
// Authentication authentication = context.getAuthentication();
// Assert.state(authentication != null, "Cannot find the authenticated user");
// return authentication.getName();
// };
// }
// }
//
// @ConfigurationProperties("social.redis.twitter")
// public class TwitterRedisProperties {
//
// private String appId;
// private String appSecret;
//
// public String getAppId() {
// return appId;
// }
//
// public void setAppId(String appId) {
// this.appId = appId;
// }
//
// public String getAppSecret() {
// return appSecret;
// }
//
// public void setAppSecret(String appSecret) {
// this.appSecret = appSecret;
// }
// }
// }
| import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.social.TwitterRedisAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories;
import org.springframework.social.security.SocialUserDetailsService; | package be.ordina.jworks.social.redis;
@Configuration
@EnableRedisRepositories
@ConditionalOnClass(RedisConnectionFactory.class) | // Path: social-redis-spring-boot-starter/src/main/java/org/springframework/boot/autoconfigure/social/TwitterRedisAutoConfiguration.java
// @Configuration
// @ConditionalOnClass({SocialConfigurerAdapter.class, TwitterConnectionFactory.class})
// @ConditionalOnProperty(prefix = "social.redis.twitter", name = "app-id")
// @AutoConfigureAfter(SocialWebAutoConfiguration.class)
// public class TwitterRedisAutoConfiguration {
//
// @Configuration
// @EnableSocial
// @EnableConfigurationProperties(TwitterRedisProperties.class)
// @ConditionalOnWebApplication
// protected static class TwitterConfigurerAdapter extends SocialAutoConfigurerAdapter {
//
// private final TwitterRedisProperties properties;
// private final SocialRedisConnectionRepository socialRedisConnectionRepository;
//
// protected TwitterConfigurerAdapter(TwitterRedisProperties properties, SocialRedisConnectionRepository socialRedisConnectionRepository) {
// this.properties = properties;
// this.socialRedisConnectionRepository = socialRedisConnectionRepository;
// }
//
// @Bean
// @ConditionalOnMissingBean
// @Scope(value = "request", proxyMode = ScopedProxyMode.INTERFACES)
// public Twitter twitter(ConnectionRepository repository) {
// Connection<Twitter> connection = repository
// .findPrimaryConnection(Twitter.class);
// if (connection != null) {
// return connection.getApi();
// }
// return new TwitterTemplate(this.properties.getAppId(),
// this.properties.getAppSecret());
// }
//
// @Bean
// @Primary
// @ConditionalOnBean(RedisConnectionFactory.class)
// @Scope(value = "request", proxyMode = ScopedProxyMode.INTERFACES)
// public ConnectionRepository connectionRepository(UsersConnectionRepository usersConnectionRepository) {
// return usersConnectionRepository.createConnectionRepository(getUserIdSource().getUserId());
// }
//
// @Bean(name = {"connect/twitterConnect", "connect/twitterConnected"})
// @ConditionalOnProperty(prefix = "spring.social", name = "auto-connection-views")
// public GenericConnectionStatusView twitterConnectView() {
// return new GenericConnectionStatusView("twitter", "Twitter");
// }
//
// @Bean
// @ConditionalOnMissingBean
// public ProviderSignInController providerSignInController(ConnectionFactoryLocator connectionFactoryLocator, UsersConnectionRepository usersConnectionRepository) {
// return new ProviderSignInController(connectionFactoryLocator, usersConnectionRepository, new SpringSecuritySignInAdapter());
// }
//
// private class SpringSecuritySignInAdapter implements SignInAdapter {
// public String signIn(String localUserId, Connection<?> connection, NativeWebRequest request) {
// SecurityContextHolder.getContext().setAuthentication(new UsernamePasswordAuthenticationToken(localUserId, null, null));
// return null;
// }
// }
//
// @Override
// protected ConnectionFactory<?> createConnectionFactory() {
// return new TwitterConnectionFactory(this.properties.getAppId(),
// this.properties.getAppSecret());
// }
//
// @Override
// public UsersConnectionRepository getUsersConnectionRepository(ConnectionFactoryLocator connectionFactoryLocator) {
// return new RedisUsersConnectionRepository(connectionFactoryLocator, Encryptors.noOpText(), socialRedisConnectionRepository);
// }
//
// @Override
// public UserIdSource getUserIdSource() {
// return () -> {
// SecurityContext context = SecurityContextHolder.getContext();
// Authentication authentication = context.getAuthentication();
// Assert.state(authentication != null, "Cannot find the authenticated user");
// return authentication.getName();
// };
// }
// }
//
// @ConfigurationProperties("social.redis.twitter")
// public class TwitterRedisProperties {
//
// private String appId;
// private String appSecret;
//
// public String getAppId() {
// return appId;
// }
//
// public void setAppId(String appId) {
// this.appId = appId;
// }
//
// public String getAppSecret() {
// return appSecret;
// }
//
// public void setAppSecret(String appSecret) {
// this.appSecret = appSecret;
// }
// }
// }
// Path: social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/SocialRedisAutoConfiguration.java
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.social.TwitterRedisAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories;
import org.springframework.social.security.SocialUserDetailsService;
package be.ordina.jworks.social.redis;
@Configuration
@EnableRedisRepositories
@ConditionalOnClass(RedisConnectionFactory.class) | @AutoConfigureAfter(TwitterRedisAutoConfiguration.class) |
Turbots/SpringOne2016 | social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/connection/RedisConnectionRepository.java | // Path: social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/connection/data/SocialRedisConnection.java
// @Getter
// @Setter
// @AllArgsConstructor
// @RedisHash("socialRedisConnection")
// public class SocialRedisConnection {
//
// @Id
// @Indexed
// private String providerUserId;
//
// @Indexed
// private String userId;
//
// @Indexed
// private String providerId;
//
// private String displayName;
//
// private String profileUrl;
//
// private String imageUrl;
//
// private String accessToken;
//
// private String secret;
//
// private String refreshToken;
//
// private Long expireTime;
// }
//
// Path: social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/connection/data/SocialRedisConnectionRepository.java
// @Repository
// public interface SocialRedisConnectionRepository extends CrudRepository<SocialRedisConnection, String> {
//
// Iterable<SocialRedisConnection> findByProviderId(final String providerId);
//
// Iterable<SocialRedisConnection> findByUserIdAndProviderId(final String userId, final String providerId);
//
// SocialRedisConnection findOneByUserIdAndProviderIdAndProviderUserId(String userId, String providerId, String providerUserId);
//
// // TODO: will be available once DATAKV-135 is finished
// void deleteByUserIdAndProviderIdAndProviderUserId(final String userId, final String providerId, final String providerUserId);
//
// Iterable<SocialRedisConnection> findByUserId(final String userId);
//
// Iterable<SocialRedisConnection> findByProviderIdAndProviderUserId(final String providerId, final String providerUserId);
// }
| import be.ordina.jworks.social.redis.connection.data.SocialRedisConnection;
import be.ordina.jworks.social.redis.connection.data.SocialRedisConnectionRepository;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.security.crypto.encrypt.TextEncryptor;
import org.springframework.social.connect.*;
import org.springframework.util.Assert;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import java.util.ArrayList;
import java.util.List;
import java.util.Set; | package be.ordina.jworks.social.redis.connection;
public class RedisConnectionRepository implements ConnectionRepository {
private final ConnectionFactoryLocator connectionFactoryLocator;
private final TextEncryptor textEncryptor; | // Path: social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/connection/data/SocialRedisConnection.java
// @Getter
// @Setter
// @AllArgsConstructor
// @RedisHash("socialRedisConnection")
// public class SocialRedisConnection {
//
// @Id
// @Indexed
// private String providerUserId;
//
// @Indexed
// private String userId;
//
// @Indexed
// private String providerId;
//
// private String displayName;
//
// private String profileUrl;
//
// private String imageUrl;
//
// private String accessToken;
//
// private String secret;
//
// private String refreshToken;
//
// private Long expireTime;
// }
//
// Path: social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/connection/data/SocialRedisConnectionRepository.java
// @Repository
// public interface SocialRedisConnectionRepository extends CrudRepository<SocialRedisConnection, String> {
//
// Iterable<SocialRedisConnection> findByProviderId(final String providerId);
//
// Iterable<SocialRedisConnection> findByUserIdAndProviderId(final String userId, final String providerId);
//
// SocialRedisConnection findOneByUserIdAndProviderIdAndProviderUserId(String userId, String providerId, String providerUserId);
//
// // TODO: will be available once DATAKV-135 is finished
// void deleteByUserIdAndProviderIdAndProviderUserId(final String userId, final String providerId, final String providerUserId);
//
// Iterable<SocialRedisConnection> findByUserId(final String userId);
//
// Iterable<SocialRedisConnection> findByProviderIdAndProviderUserId(final String providerId, final String providerUserId);
// }
// Path: social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/connection/RedisConnectionRepository.java
import be.ordina.jworks.social.redis.connection.data.SocialRedisConnection;
import be.ordina.jworks.social.redis.connection.data.SocialRedisConnectionRepository;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.security.crypto.encrypt.TextEncryptor;
import org.springframework.social.connect.*;
import org.springframework.util.Assert;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
package be.ordina.jworks.social.redis.connection;
public class RedisConnectionRepository implements ConnectionRepository {
private final ConnectionFactoryLocator connectionFactoryLocator;
private final TextEncryptor textEncryptor; | private final SocialRedisConnectionRepository socialRedisConnectionRepository; |
Turbots/SpringOne2016 | social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/connection/RedisConnectionRepository.java | // Path: social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/connection/data/SocialRedisConnection.java
// @Getter
// @Setter
// @AllArgsConstructor
// @RedisHash("socialRedisConnection")
// public class SocialRedisConnection {
//
// @Id
// @Indexed
// private String providerUserId;
//
// @Indexed
// private String userId;
//
// @Indexed
// private String providerId;
//
// private String displayName;
//
// private String profileUrl;
//
// private String imageUrl;
//
// private String accessToken;
//
// private String secret;
//
// private String refreshToken;
//
// private Long expireTime;
// }
//
// Path: social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/connection/data/SocialRedisConnectionRepository.java
// @Repository
// public interface SocialRedisConnectionRepository extends CrudRepository<SocialRedisConnection, String> {
//
// Iterable<SocialRedisConnection> findByProviderId(final String providerId);
//
// Iterable<SocialRedisConnection> findByUserIdAndProviderId(final String userId, final String providerId);
//
// SocialRedisConnection findOneByUserIdAndProviderIdAndProviderUserId(String userId, String providerId, String providerUserId);
//
// // TODO: will be available once DATAKV-135 is finished
// void deleteByUserIdAndProviderIdAndProviderUserId(final String userId, final String providerId, final String providerUserId);
//
// Iterable<SocialRedisConnection> findByUserId(final String userId);
//
// Iterable<SocialRedisConnection> findByProviderIdAndProviderUserId(final String providerId, final String providerUserId);
// }
| import be.ordina.jworks.social.redis.connection.data.SocialRedisConnection;
import be.ordina.jworks.social.redis.connection.data.SocialRedisConnectionRepository;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.security.crypto.encrypt.TextEncryptor;
import org.springframework.social.connect.*;
import org.springframework.util.Assert;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import java.util.ArrayList;
import java.util.List;
import java.util.Set; | package be.ordina.jworks.social.redis.connection;
public class RedisConnectionRepository implements ConnectionRepository {
private final ConnectionFactoryLocator connectionFactoryLocator;
private final TextEncryptor textEncryptor;
private final SocialRedisConnectionRepository socialRedisConnectionRepository;
private final String userId;
public RedisConnectionRepository(final ConnectionFactoryLocator connectionFactoryLocator, final TextEncryptor textEncryptor, final SocialRedisConnectionRepository socialRedisConnectionRepository, final String userId) {
Assert.notNull(socialRedisConnectionRepository, "socialRedisConnectionRepository is required");
Assert.notNull(userId, "userId is required");
this.userId = userId;
this.socialRedisConnectionRepository = socialRedisConnectionRepository;
this.connectionFactoryLocator = connectionFactoryLocator;
this.textEncryptor = textEncryptor;
}
public MultiValueMap<String, Connection<?>> findAllConnections() { | // Path: social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/connection/data/SocialRedisConnection.java
// @Getter
// @Setter
// @AllArgsConstructor
// @RedisHash("socialRedisConnection")
// public class SocialRedisConnection {
//
// @Id
// @Indexed
// private String providerUserId;
//
// @Indexed
// private String userId;
//
// @Indexed
// private String providerId;
//
// private String displayName;
//
// private String profileUrl;
//
// private String imageUrl;
//
// private String accessToken;
//
// private String secret;
//
// private String refreshToken;
//
// private Long expireTime;
// }
//
// Path: social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/connection/data/SocialRedisConnectionRepository.java
// @Repository
// public interface SocialRedisConnectionRepository extends CrudRepository<SocialRedisConnection, String> {
//
// Iterable<SocialRedisConnection> findByProviderId(final String providerId);
//
// Iterable<SocialRedisConnection> findByUserIdAndProviderId(final String userId, final String providerId);
//
// SocialRedisConnection findOneByUserIdAndProviderIdAndProviderUserId(String userId, String providerId, String providerUserId);
//
// // TODO: will be available once DATAKV-135 is finished
// void deleteByUserIdAndProviderIdAndProviderUserId(final String userId, final String providerId, final String providerUserId);
//
// Iterable<SocialRedisConnection> findByUserId(final String userId);
//
// Iterable<SocialRedisConnection> findByProviderIdAndProviderUserId(final String providerId, final String providerUserId);
// }
// Path: social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/connection/RedisConnectionRepository.java
import be.ordina.jworks.social.redis.connection.data.SocialRedisConnection;
import be.ordina.jworks.social.redis.connection.data.SocialRedisConnectionRepository;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.security.crypto.encrypt.TextEncryptor;
import org.springframework.social.connect.*;
import org.springframework.util.Assert;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
package be.ordina.jworks.social.redis.connection;
public class RedisConnectionRepository implements ConnectionRepository {
private final ConnectionFactoryLocator connectionFactoryLocator;
private final TextEncryptor textEncryptor;
private final SocialRedisConnectionRepository socialRedisConnectionRepository;
private final String userId;
public RedisConnectionRepository(final ConnectionFactoryLocator connectionFactoryLocator, final TextEncryptor textEncryptor, final SocialRedisConnectionRepository socialRedisConnectionRepository, final String userId) {
Assert.notNull(socialRedisConnectionRepository, "socialRedisConnectionRepository is required");
Assert.notNull(userId, "userId is required");
this.userId = userId;
this.socialRedisConnectionRepository = socialRedisConnectionRepository;
this.connectionFactoryLocator = connectionFactoryLocator;
this.textEncryptor = textEncryptor;
}
public MultiValueMap<String, Connection<?>> findAllConnections() { | Iterable<SocialRedisConnection> allConnections = socialRedisConnectionRepository.findByUserId(userId); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.