Skip to content

Commit

Permalink
Merge commit 'b51e20210b849b03843e79c279c229f570a72e5b'
Browse files Browse the repository at this point in the history
Conflicts:
	src/main/resources/local/techlooper.properties
  • Loading branch information
khoa-nd committed Aug 27, 2015
2 parents e29c300 + b51e202 commit e1f907c
Show file tree
Hide file tree
Showing 20 changed files with 268 additions and 181 deletions.
49 changes: 9 additions & 40 deletions src/main/java/com/techlooper/config/CoreConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ public class CoreConfiguration implements ApplicationContextAware {

@Value("classpath:google-auth/techLooper.p12")
private org.springframework.core.io.Resource googleApiAuthResource;
// @Value("classpath:google-auth")
// private org.springframework.core.io.Resource googleApiAuthResource;

private ApplicationContext applicationContext;

Expand Down Expand Up @@ -392,13 +390,18 @@ public JsonNode vietnamworksConfiguration() throws IOException {

@Bean
@DependsOn("jsonConfigRepository")
public SocialConfig googleSocialConfig() {
return applicationContext.getBean(JsonConfigRepository.class).getSocialConfig().stream()
.filter(socialConfig -> socialConfig.getProvider() == SocialProvider.GOOGLE)
.findFirst().get();
}

@Bean
public Calendar googleCalendar() throws GeneralSecurityException, IOException {
JacksonFactory jsonFactory = JacksonFactory.getDefaultInstance();
HttpTransport transport = GoogleNetHttpTransport.newTrustedTransport();

SocialConfig googleConfig = applicationContext.getBean(JsonConfigRepository.class).getSocialConfig().stream()
.filter(socialConfig -> socialConfig.getProvider() == SocialProvider.GOOGLE)
.findFirst().get();
SocialConfig googleConfig = googleSocialConfig();

// GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(transport, jsonFactory,
// googleConfig.getApiKey(), googleConfig.getSecretKey(),
Expand All @@ -417,45 +420,11 @@ public Calendar googleCalendar() throws GeneralSecurityException, IOException {
.setServiceAccountId(googleConfig.getServiceAccountEmail())
.setServiceAccountPrivateKeyFromP12File(googleApiAuthResource.getFile())
.setServiceAccountScopes(Collections.singleton(CalendarScopes.CALENDAR))
.setServiceAccountUser("[email protected]")
.setServiceAccountUser(googleConfig.getCalendarOwner())
.build();

// boolean bool = credential.refreshToken();
// String token = credential.getAccessToken();
// System.out.println(bool);
// System.out.println(token);

return new Calendar.Builder(transport, jsonFactory, credential)
.setApplicationName("Techlooper").build();

// Event event = new Event()
// .setSummary("Google I/O 2015")
// .setLocation("800 Howard St., San Francisco, CA 94103")
// .setDescription("A chance to hear more about Google's developer products.");
//
// DateTime startDateTime = new DateTime("2015-09-28T09:00:00-07:00");
// EventDateTime start = new EventDateTime()
// .setDateTime(startDateTime)
// .setTimeZone("America/Los_Angeles");
// event.setStart(start);
//
// DateTime endDateTime = new DateTime("2015-09-28T17:00:00-07:00");
// EventDateTime end = new EventDateTime()
// .setDateTime(endDateTime)
// .setTimeZone("America/Los_Angeles");
// event.setEnd(end);
//
// EventAttendee[] attendees = new EventAttendee[]{
// new EventAttendee().setEmail("[email protected]"),
// new EventAttendee().setEmail("[email protected]"),
// };
// event.setAttendees(Arrays.asList(attendees));
//
// String calendarId = "[email protected]";
// event = calendar.events().insert(calendarId, event).setSendNotifications(true).execute();
// System.out.printf("Event created: %s\n", event.getHtmlLink());
// event.getHangoutLink()
// return calendar;
}

public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public Authentication authenticate(Authentication authentication) throws Authent
}
}
catch (Exception ex) {
LOGGER.debug(ex.getMessage(), ex);
LOGGER.debug(ex.getMessage());
}

return providers.get(SocialProvider.VIETNAMWORKS).authenticate(authentication);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ public WebinarInfoDto findWebinarById(@PathVariable Long id) {
}

@RequestMapping(value = "user/webinar/join", method = RequestMethod.POST)
public WebinarInfoDto joinWebinar(@RequestBody JoinBySocialDto joinBySocialDto) {
public WebinarInfoDto joinWebinar(@RequestBody JoinBySocialDto joinBySocialDto) throws IOException {
return webinarService.joinWebinar(joinBySocialDto);
}
}
39 changes: 39 additions & 0 deletions src/main/java/com/techlooper/entity/CalendarInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.techlooper.entity;

import java.io.Serializable;

/**
* Created by phuonghqh on 8/27/15.
*/
public class CalendarInfo implements Serializable {

private String id;

private String htmlLink;

private String hangoutLink;

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getHtmlLink() {
return htmlLink;
}

public void setHtmlLink(String htmlLink) {
this.htmlLink = htmlLink;
}

public String getHangoutLink() {
return hangoutLink;
}

public void setHangoutLink(String hangoutLink) {
this.hangoutLink = hangoutLink;
}
}
45 changes: 22 additions & 23 deletions src/main/java/com/techlooper/entity/WebinarEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import java.util.Collection;
import java.util.Date;
import java.util.Set;

/**
* Created by phuonghqh on 8/18/15.
Expand All @@ -29,23 +30,37 @@ public class WebinarEntity {
private String description;

@Field(type = FieldType.Nested)
private Collection<UserProfileDto> attendees;
private Set<UserProfileDto> attendees;

@Field(type = FieldType.Nested)
private UserProfileDto organiser;

@Field(type = FieldType.String, index = FieldIndex.not_analyzed)
private String where = "Google Hangout";

@Field(type = FieldType.String, index = FieldIndex.not_analyzed)
private String calendarUrl;
@Field(type = FieldType.Nested)
private CalendarInfo calendarInfo;

@Field(type = FieldType.String, index = FieldIndex.not_analyzed)
private String hangoutLink;
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private String calendarUrl;
//
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private String hangoutLink;
//
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private String eventId;

@Field(type = FieldType.String)
private String whatEvent;

public CalendarInfo getCalendarInfo() {
return calendarInfo;
}

public void setCalendarInfo(CalendarInfo calendarInfo) {
this.calendarInfo = calendarInfo;
}

public Long getCreatedDateTime() {
return createdDateTime;
}
Expand Down Expand Up @@ -86,11 +101,11 @@ public void setDescription(String description) {
this.description = description;
}

public Collection<UserProfileDto> getAttendees() {
public Set<UserProfileDto> getAttendees() {
return attendees;
}

public void setAttendees(Collection<UserProfileDto> attendees) {
public void setAttendees(Set<UserProfileDto> attendees) {
this.attendees = attendees;
}

Expand All @@ -110,22 +125,6 @@ public void setWhere(String where) {
this.where = where;
}

public String getCalendarUrl() {
return calendarUrl;
}

public void setCalendarUrl(String calendarUrl) {
this.calendarUrl = calendarUrl;
}

public String getHangoutLink() {
return hangoutLink;
}

public void setHangoutLink(String hangoutLink) {
this.hangoutLink = hangoutLink;
}

public String getWhatEvent() {
return whatEvent;
}
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/com/techlooper/model/SocialConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,26 @@ public class SocialConfig {

private String serviceAccountEmail;

private String calendarId;

private String calendarOwner;

public String getCalendarOwner() {
return calendarOwner;
}

public void setCalendarOwner(String calendarOwner) {
this.calendarOwner = calendarOwner;
}

public String getCalendarId() {
return calendarId;
}

public void setCalendarId(String calendarId) {
this.calendarId = calendarId;
}

public String getServiceAccountEmail() {
return serviceAccountEmail;
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/techlooper/model/UserProfileDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

import com.techlooper.entity.vnw.RoleName;

import java.io.Serializable;

/**
* Created by NguyenDangKhoa on 7/30/15.
*/
public class UserProfileDto {
public class UserProfileDto implements Serializable {

private String username;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/techlooper/service/WebinarService.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ public interface WebinarService {

WebinarInfoDto findWebinarById(Long id);

WebinarInfoDto joinWebinar(JoinBySocialDto joinBySocialDto);
WebinarInfoDto joinWebinar(JoinBySocialDto joinBySocialDto) throws IOException;
}
Loading

0 comments on commit e1f907c

Please sign in to comment.