Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create user #2

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
<id>tmortagne</id>
<name>Thomas Mortagne</name>
</developer>
<developer>
<id>martindelille</id>
<name>Martin Delille</name>
</developer>
</developers>
<modules>
<module>usersync-api</module>
Expand All @@ -60,6 +64,13 @@

<!-- The repository where to get XWiki dependencies -->
<repositories>
<repository>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Il n'y as aucune raison pour que tu ai besoin de ça. Maven central est activé de base dans Maven.

<id>central</id>
<url>http://repo1.maven.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>xwiki-releases</id>
<name>XWiki Nexus Releases Repository Proxy</name>
Expand All @@ -85,4 +96,16 @@
</snapshots>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>com.squareup.retrofit2</groupId>
<artifactId>retrofit</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>com.squareup.retrofit2</groupId>
<artifactId>converter-gson</artifactId>
<version>latest.version</version>
</dependency>
</dependencies>
MartinDelille marked this conversation as resolved.
Show resolved Hide resolved
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.xwiki.contrib.usersync.discourse.internal;

import java.util.List;
//import org.simpleframework.xml.Path;
import retrofit2.Call;
import retrofit2.http.GET;

import org.xwiki.contrib.usersync.discourse.internal.Post;

public interface DiscourseService {
@GET("posts")
Call<List<Post>> getPosts();
}

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
*/
package org.xwiki.contrib.usersync.discourse.internal;

import java.util.List;

import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
Expand All @@ -29,9 +31,16 @@

import com.xpn.xwiki.objects.BaseObject;

import retrofit2.Retrofit;
import retrofit2.Retrofit.Builder;
import retrofit2.Call;
import retrofit2.converter.gson.GsonConverterFactory;

import org.xwiki.contrib.usersync.discourse.internal.DiscourseService;

/**
* {@link UserSyncConnector} implementation for Discourse.
*
*
* @version $Id$
*/
@Component
Expand All @@ -40,8 +49,9 @@
public class DiscourseUserSyncConnector implements UserSyncConnector
{
private static final String PREFIX_CONFIGURATION = "usersync.discourse.";

private static final String CONFIGURATION_URL = PREFIX_CONFIGURATION + "url";
private static final String API_KEY = PREFIX_CONFIGURATION + "api_key";
MartinDelille marked this conversation as resolved.
Show resolved Hide resolved

@Inject
private ConfigurationSource configuration;
Expand All @@ -57,8 +67,20 @@ public void createUser(BaseObject user)

// Get the URL of the discourse server to synchronize with
String discourseURL = this.configuration.getProperty(CONFIGURATION_URL);
String discourseApiKey = this.configuration.getProperty(API_KEY);

// TODO
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://jsonplaceholder.typicode.com/")
.addConvertFactory(GsonConverterFactory.create())
.build();

DiscourseService service = retrofit.create(DiscourseService.class);
Call<List<Post>> posts = service.getPosts();


System.out.println("url");
System.out.println(discourseURL);
System.out.println("end");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.xwiki.contrib.usersync.discourse.internal;

import com.google.json.annotation.SerializedName;

public class Post {
private int userId;

private int id;

private String title;

@SerializedName("body")
private String text;

public int getUserId() {
return d;
}

public int getId() {
return id;
}

public String getTitle() {
return title;
}

public String getText() {
return text;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ public void before()
}

@Test
public void createUser() throws ComponentLookupException
{
// Call the component
this.mocker.getComponentUnderTest().createUser(this.newUser);
}

public void modifyUser() throws ComponentLookupException
{
// Modify the user
Expand Down