Преглед на файлове

Get DAOs from configuraion

pull/61/head
Kristijan Mitrovic преди 4 години
родител
ревизия
2dff57da0a
променени са 1 файла, в които са добавени 9 реда и са изтрити 6 реда
  1. +9
    -6
      bubble-server/src/main/java/bubble/cloud/email/SendgridSmtpEmailDriver.java

+ 9
- 6
bubble-server/src/main/java/bubble/cloud/email/SendgridSmtpEmailDriver.java Целия файл

@@ -10,7 +10,6 @@ import lombok.*;
import org.cobbzilla.util.http.HttpMethods;
import org.cobbzilla.util.http.HttpRequestBean;
import org.cobbzilla.util.http.HttpResponseBean;
import org.springframework.beans.factory.annotation.Autowired;

import javax.annotation.Nullable;
import java.io.IOException;
@@ -31,9 +30,6 @@ public class SendgridSmtpEmailDriver extends SmtpEmailDriver {

private static final String PARAM_PARENT_SERVICE = "parentService";

@Autowired private AccountDAO accountDAO;
@Autowired private CloudServiceDAO serviceDAO;

@Override protected boolean isServiceCompatible(final String serviceHost) {
return SENDGRID_SMTP.equals(serviceHost);
}
@@ -53,7 +49,8 @@ public class SendgridSmtpEmailDriver extends SmtpEmailDriver {
return super.setupDelegatedCloudService(configuration, parentService, delegatedService);
}

final Account accountWithDelegate = accountDAO.findByUuid(delegatedService.getAccount());
final Account accountWithDelegate = configuration.getBean(AccountDAO.class)
.findByUuid(delegatedService.getAccount());
final String user = sgUsername(delegatedService);
String password = generatePassword(MIN_KEY_LENGTH, MIN_DISTINCT_LENGTH);
final CreateSubuserRequest data = new CreateSubuserRequest(user, accountWithDelegate.getEmail(), password,
@@ -70,10 +67,16 @@ public class SendgridSmtpEmailDriver extends SmtpEmailDriver {
}

@Override public void postServiceDelete(@NonNull final CloudService service) {
// TODO: there must be configuration present here. If this happens, try some other way:
if (getConfiguration() == null) {
die("postServiceDelete: Cannot do this action with server configuration set within");
}

final String parentServiceUuid = service.getCredentials().getParam(PARAM_PARENT_SERVICE);
if (parentServiceUuid == null) return;

final CloudService parentService = serviceDAO.findByUuid(parentServiceUuid);
final CloudService parentService = getConfiguration().getBean(CloudServiceDAO.class)
.findByUuid(parentServiceUuid);
if (parentService == null) return;

final String sgUserToDelete = sgUsername(service);


Зареждане…
Отказ
Запис