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 |
|---|---|---|---|---|---|---|
raulh82vlc/Transactions-Viewer | domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/GetTransactionListInteractorImpl.java | // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java
// public class CustomException extends Exception {
// public CustomException(String detailMessage) {
// super(detailMessage);
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/Interactor.java
// public interface Interactor {
// void run() throws CustomException;
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java
// public interface InteractorExecutor {
// void run(Interactor interactor) throws CustomException;
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java
// public interface MainThread {
// void post(final Runnable runnable);
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java
// public class Rate {
// @SerializedName("from")
// private String fromCurrency;
// @SerializedName("rate")
// private String rate;
// @SerializedName("to")
// private String toCurrency;
//
// public String getFromCurrency() {
// return fromCurrency;
// }
//
// public String getRate() {
// return rate;
// }
//
// public String getToCurrency() {
// return toCurrency;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java
// public class Transaction {
//
// @SerializedName("sku")
// private String skuIdentifier;
//
// @SerializedName("amount")
// private String amountPerTransaction;
//
// @SerializedName("currency")
// private String currency;
//
// public String getSkuIdentifier() {
// return skuIdentifier;
// }
//
// public String getAmountPerTransaction() {
// return amountPerTransaction;
// }
//
// public String getCurrency() {
// return currency;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/DataRepository.java
// public interface DataRepository<R, T> {
//
// /**
// * to get Rates List
// **/
// List<R> getRatesList(String path) throws CustomException;
//
// /**
// * to get Transactions list
// **/
// List<T> getTransactionsList(String path) throws CustomException;
//
// /**
// * to get Transactions per product's SKU
// **/
// List<T> getTransactionsPerSku(String mPathTransactions, String mSku);
//
// /**
// * to save Transactions indexed per product's SKU
// **/
// boolean saveTransactions(Map<String, List<T>> map);
// }
| import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException;
import com.raulh82vlc.TransactionsViewer.domain.executors.Interactor;
import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor;
import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread;
import com.raulh82vlc.TransactionsViewer.domain.models.Rate;
import com.raulh82vlc.TransactionsViewer.domain.models.Transaction;
import com.raulh82vlc.TransactionsViewer.domain.repository.DataRepository;
import java.util.List;
import javax.inject.Inject; | /*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.domain.interactors;
/**
* Implementation of the Get specific details of a movie
*
* @author Raul Hernandez Lopez
*/
public class GetTransactionListInteractorImpl implements GetTransactionListInteractor, Interactor {
private InteractorExecutor executor; | // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java
// public class CustomException extends Exception {
// public CustomException(String detailMessage) {
// super(detailMessage);
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/Interactor.java
// public interface Interactor {
// void run() throws CustomException;
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java
// public interface InteractorExecutor {
// void run(Interactor interactor) throws CustomException;
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java
// public interface MainThread {
// void post(final Runnable runnable);
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java
// public class Rate {
// @SerializedName("from")
// private String fromCurrency;
// @SerializedName("rate")
// private String rate;
// @SerializedName("to")
// private String toCurrency;
//
// public String getFromCurrency() {
// return fromCurrency;
// }
//
// public String getRate() {
// return rate;
// }
//
// public String getToCurrency() {
// return toCurrency;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java
// public class Transaction {
//
// @SerializedName("sku")
// private String skuIdentifier;
//
// @SerializedName("amount")
// private String amountPerTransaction;
//
// @SerializedName("currency")
// private String currency;
//
// public String getSkuIdentifier() {
// return skuIdentifier;
// }
//
// public String getAmountPerTransaction() {
// return amountPerTransaction;
// }
//
// public String getCurrency() {
// return currency;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/DataRepository.java
// public interface DataRepository<R, T> {
//
// /**
// * to get Rates List
// **/
// List<R> getRatesList(String path) throws CustomException;
//
// /**
// * to get Transactions list
// **/
// List<T> getTransactionsList(String path) throws CustomException;
//
// /**
// * to get Transactions per product's SKU
// **/
// List<T> getTransactionsPerSku(String mPathTransactions, String mSku);
//
// /**
// * to save Transactions indexed per product's SKU
// **/
// boolean saveTransactions(Map<String, List<T>> map);
// }
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/GetTransactionListInteractorImpl.java
import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException;
import com.raulh82vlc.TransactionsViewer.domain.executors.Interactor;
import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor;
import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread;
import com.raulh82vlc.TransactionsViewer.domain.models.Rate;
import com.raulh82vlc.TransactionsViewer.domain.models.Transaction;
import com.raulh82vlc.TransactionsViewer.domain.repository.DataRepository;
import java.util.List;
import javax.inject.Inject;
/*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.domain.interactors;
/**
* Implementation of the Get specific details of a movie
*
* @author Raul Hernandez Lopez
*/
public class GetTransactionListInteractorImpl implements GetTransactionListInteractor, Interactor {
private InteractorExecutor executor; | private MainThread mainThread; |
raulh82vlc/Transactions-Viewer | domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/GetTransactionListInteractorImpl.java | // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java
// public class CustomException extends Exception {
// public CustomException(String detailMessage) {
// super(detailMessage);
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/Interactor.java
// public interface Interactor {
// void run() throws CustomException;
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java
// public interface InteractorExecutor {
// void run(Interactor interactor) throws CustomException;
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java
// public interface MainThread {
// void post(final Runnable runnable);
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java
// public class Rate {
// @SerializedName("from")
// private String fromCurrency;
// @SerializedName("rate")
// private String rate;
// @SerializedName("to")
// private String toCurrency;
//
// public String getFromCurrency() {
// return fromCurrency;
// }
//
// public String getRate() {
// return rate;
// }
//
// public String getToCurrency() {
// return toCurrency;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java
// public class Transaction {
//
// @SerializedName("sku")
// private String skuIdentifier;
//
// @SerializedName("amount")
// private String amountPerTransaction;
//
// @SerializedName("currency")
// private String currency;
//
// public String getSkuIdentifier() {
// return skuIdentifier;
// }
//
// public String getAmountPerTransaction() {
// return amountPerTransaction;
// }
//
// public String getCurrency() {
// return currency;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/DataRepository.java
// public interface DataRepository<R, T> {
//
// /**
// * to get Rates List
// **/
// List<R> getRatesList(String path) throws CustomException;
//
// /**
// * to get Transactions list
// **/
// List<T> getTransactionsList(String path) throws CustomException;
//
// /**
// * to get Transactions per product's SKU
// **/
// List<T> getTransactionsPerSku(String mPathTransactions, String mSku);
//
// /**
// * to save Transactions indexed per product's SKU
// **/
// boolean saveTransactions(Map<String, List<T>> map);
// }
| import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException;
import com.raulh82vlc.TransactionsViewer.domain.executors.Interactor;
import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor;
import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread;
import com.raulh82vlc.TransactionsViewer.domain.models.Rate;
import com.raulh82vlc.TransactionsViewer.domain.models.Transaction;
import com.raulh82vlc.TransactionsViewer.domain.repository.DataRepository;
import java.util.List;
import javax.inject.Inject; | /*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.domain.interactors;
/**
* Implementation of the Get specific details of a movie
*
* @author Raul Hernandez Lopez
*/
public class GetTransactionListInteractorImpl implements GetTransactionListInteractor, Interactor {
private InteractorExecutor executor;
private MainThread mainThread; | // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java
// public class CustomException extends Exception {
// public CustomException(String detailMessage) {
// super(detailMessage);
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/Interactor.java
// public interface Interactor {
// void run() throws CustomException;
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java
// public interface InteractorExecutor {
// void run(Interactor interactor) throws CustomException;
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java
// public interface MainThread {
// void post(final Runnable runnable);
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java
// public class Rate {
// @SerializedName("from")
// private String fromCurrency;
// @SerializedName("rate")
// private String rate;
// @SerializedName("to")
// private String toCurrency;
//
// public String getFromCurrency() {
// return fromCurrency;
// }
//
// public String getRate() {
// return rate;
// }
//
// public String getToCurrency() {
// return toCurrency;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java
// public class Transaction {
//
// @SerializedName("sku")
// private String skuIdentifier;
//
// @SerializedName("amount")
// private String amountPerTransaction;
//
// @SerializedName("currency")
// private String currency;
//
// public String getSkuIdentifier() {
// return skuIdentifier;
// }
//
// public String getAmountPerTransaction() {
// return amountPerTransaction;
// }
//
// public String getCurrency() {
// return currency;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/DataRepository.java
// public interface DataRepository<R, T> {
//
// /**
// * to get Rates List
// **/
// List<R> getRatesList(String path) throws CustomException;
//
// /**
// * to get Transactions list
// **/
// List<T> getTransactionsList(String path) throws CustomException;
//
// /**
// * to get Transactions per product's SKU
// **/
// List<T> getTransactionsPerSku(String mPathTransactions, String mSku);
//
// /**
// * to save Transactions indexed per product's SKU
// **/
// boolean saveTransactions(Map<String, List<T>> map);
// }
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/GetTransactionListInteractorImpl.java
import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException;
import com.raulh82vlc.TransactionsViewer.domain.executors.Interactor;
import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor;
import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread;
import com.raulh82vlc.TransactionsViewer.domain.models.Rate;
import com.raulh82vlc.TransactionsViewer.domain.models.Transaction;
import com.raulh82vlc.TransactionsViewer.domain.repository.DataRepository;
import java.util.List;
import javax.inject.Inject;
/*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.domain.interactors;
/**
* Implementation of the Get specific details of a movie
*
* @author Raul Hernandez Lopez
*/
public class GetTransactionListInteractorImpl implements GetTransactionListInteractor, Interactor {
private InteractorExecutor executor;
private MainThread mainThread; | private DataRepository<Rate, Transaction> repository; |
raulh82vlc/Transactions-Viewer | domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/GetTransactionListInteractorImpl.java | // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java
// public class CustomException extends Exception {
// public CustomException(String detailMessage) {
// super(detailMessage);
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/Interactor.java
// public interface Interactor {
// void run() throws CustomException;
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java
// public interface InteractorExecutor {
// void run(Interactor interactor) throws CustomException;
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java
// public interface MainThread {
// void post(final Runnable runnable);
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java
// public class Rate {
// @SerializedName("from")
// private String fromCurrency;
// @SerializedName("rate")
// private String rate;
// @SerializedName("to")
// private String toCurrency;
//
// public String getFromCurrency() {
// return fromCurrency;
// }
//
// public String getRate() {
// return rate;
// }
//
// public String getToCurrency() {
// return toCurrency;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java
// public class Transaction {
//
// @SerializedName("sku")
// private String skuIdentifier;
//
// @SerializedName("amount")
// private String amountPerTransaction;
//
// @SerializedName("currency")
// private String currency;
//
// public String getSkuIdentifier() {
// return skuIdentifier;
// }
//
// public String getAmountPerTransaction() {
// return amountPerTransaction;
// }
//
// public String getCurrency() {
// return currency;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/DataRepository.java
// public interface DataRepository<R, T> {
//
// /**
// * to get Rates List
// **/
// List<R> getRatesList(String path) throws CustomException;
//
// /**
// * to get Transactions list
// **/
// List<T> getTransactionsList(String path) throws CustomException;
//
// /**
// * to get Transactions per product's SKU
// **/
// List<T> getTransactionsPerSku(String mPathTransactions, String mSku);
//
// /**
// * to save Transactions indexed per product's SKU
// **/
// boolean saveTransactions(Map<String, List<T>> map);
// }
| import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException;
import com.raulh82vlc.TransactionsViewer.domain.executors.Interactor;
import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor;
import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread;
import com.raulh82vlc.TransactionsViewer.domain.models.Rate;
import com.raulh82vlc.TransactionsViewer.domain.models.Transaction;
import com.raulh82vlc.TransactionsViewer.domain.repository.DataRepository;
import java.util.List;
import javax.inject.Inject; | /*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.domain.interactors;
/**
* Implementation of the Get specific details of a movie
*
* @author Raul Hernandez Lopez
*/
public class GetTransactionListInteractorImpl implements GetTransactionListInteractor, Interactor {
private InteractorExecutor executor;
private MainThread mainThread; | // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java
// public class CustomException extends Exception {
// public CustomException(String detailMessage) {
// super(detailMessage);
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/Interactor.java
// public interface Interactor {
// void run() throws CustomException;
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java
// public interface InteractorExecutor {
// void run(Interactor interactor) throws CustomException;
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java
// public interface MainThread {
// void post(final Runnable runnable);
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java
// public class Rate {
// @SerializedName("from")
// private String fromCurrency;
// @SerializedName("rate")
// private String rate;
// @SerializedName("to")
// private String toCurrency;
//
// public String getFromCurrency() {
// return fromCurrency;
// }
//
// public String getRate() {
// return rate;
// }
//
// public String getToCurrency() {
// return toCurrency;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java
// public class Transaction {
//
// @SerializedName("sku")
// private String skuIdentifier;
//
// @SerializedName("amount")
// private String amountPerTransaction;
//
// @SerializedName("currency")
// private String currency;
//
// public String getSkuIdentifier() {
// return skuIdentifier;
// }
//
// public String getAmountPerTransaction() {
// return amountPerTransaction;
// }
//
// public String getCurrency() {
// return currency;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/DataRepository.java
// public interface DataRepository<R, T> {
//
// /**
// * to get Rates List
// **/
// List<R> getRatesList(String path) throws CustomException;
//
// /**
// * to get Transactions list
// **/
// List<T> getTransactionsList(String path) throws CustomException;
//
// /**
// * to get Transactions per product's SKU
// **/
// List<T> getTransactionsPerSku(String mPathTransactions, String mSku);
//
// /**
// * to save Transactions indexed per product's SKU
// **/
// boolean saveTransactions(Map<String, List<T>> map);
// }
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/GetTransactionListInteractorImpl.java
import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException;
import com.raulh82vlc.TransactionsViewer.domain.executors.Interactor;
import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor;
import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread;
import com.raulh82vlc.TransactionsViewer.domain.models.Rate;
import com.raulh82vlc.TransactionsViewer.domain.models.Transaction;
import com.raulh82vlc.TransactionsViewer.domain.repository.DataRepository;
import java.util.List;
import javax.inject.Inject;
/*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.domain.interactors;
/**
* Implementation of the Get specific details of a movie
*
* @author Raul Hernandez Lopez
*/
public class GetTransactionListInteractorImpl implements GetTransactionListInteractor, Interactor {
private InteractorExecutor executor;
private MainThread mainThread; | private DataRepository<Rate, Transaction> repository; |
raulh82vlc/Transactions-Viewer | domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/GetTransactionListInteractorImpl.java | // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java
// public class CustomException extends Exception {
// public CustomException(String detailMessage) {
// super(detailMessage);
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/Interactor.java
// public interface Interactor {
// void run() throws CustomException;
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java
// public interface InteractorExecutor {
// void run(Interactor interactor) throws CustomException;
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java
// public interface MainThread {
// void post(final Runnable runnable);
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java
// public class Rate {
// @SerializedName("from")
// private String fromCurrency;
// @SerializedName("rate")
// private String rate;
// @SerializedName("to")
// private String toCurrency;
//
// public String getFromCurrency() {
// return fromCurrency;
// }
//
// public String getRate() {
// return rate;
// }
//
// public String getToCurrency() {
// return toCurrency;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java
// public class Transaction {
//
// @SerializedName("sku")
// private String skuIdentifier;
//
// @SerializedName("amount")
// private String amountPerTransaction;
//
// @SerializedName("currency")
// private String currency;
//
// public String getSkuIdentifier() {
// return skuIdentifier;
// }
//
// public String getAmountPerTransaction() {
// return amountPerTransaction;
// }
//
// public String getCurrency() {
// return currency;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/DataRepository.java
// public interface DataRepository<R, T> {
//
// /**
// * to get Rates List
// **/
// List<R> getRatesList(String path) throws CustomException;
//
// /**
// * to get Transactions list
// **/
// List<T> getTransactionsList(String path) throws CustomException;
//
// /**
// * to get Transactions per product's SKU
// **/
// List<T> getTransactionsPerSku(String mPathTransactions, String mSku);
//
// /**
// * to save Transactions indexed per product's SKU
// **/
// boolean saveTransactions(Map<String, List<T>> map);
// }
| import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException;
import com.raulh82vlc.TransactionsViewer.domain.executors.Interactor;
import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor;
import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread;
import com.raulh82vlc.TransactionsViewer.domain.models.Rate;
import com.raulh82vlc.TransactionsViewer.domain.models.Transaction;
import com.raulh82vlc.TransactionsViewer.domain.repository.DataRepository;
import java.util.List;
import javax.inject.Inject; | /*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.domain.interactors;
/**
* Implementation of the Get specific details of a movie
*
* @author Raul Hernandez Lopez
*/
public class GetTransactionListInteractorImpl implements GetTransactionListInteractor, Interactor {
private InteractorExecutor executor;
private MainThread mainThread; | // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java
// public class CustomException extends Exception {
// public CustomException(String detailMessage) {
// super(detailMessage);
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/Interactor.java
// public interface Interactor {
// void run() throws CustomException;
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java
// public interface InteractorExecutor {
// void run(Interactor interactor) throws CustomException;
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java
// public interface MainThread {
// void post(final Runnable runnable);
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java
// public class Rate {
// @SerializedName("from")
// private String fromCurrency;
// @SerializedName("rate")
// private String rate;
// @SerializedName("to")
// private String toCurrency;
//
// public String getFromCurrency() {
// return fromCurrency;
// }
//
// public String getRate() {
// return rate;
// }
//
// public String getToCurrency() {
// return toCurrency;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java
// public class Transaction {
//
// @SerializedName("sku")
// private String skuIdentifier;
//
// @SerializedName("amount")
// private String amountPerTransaction;
//
// @SerializedName("currency")
// private String currency;
//
// public String getSkuIdentifier() {
// return skuIdentifier;
// }
//
// public String getAmountPerTransaction() {
// return amountPerTransaction;
// }
//
// public String getCurrency() {
// return currency;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/DataRepository.java
// public interface DataRepository<R, T> {
//
// /**
// * to get Rates List
// **/
// List<R> getRatesList(String path) throws CustomException;
//
// /**
// * to get Transactions list
// **/
// List<T> getTransactionsList(String path) throws CustomException;
//
// /**
// * to get Transactions per product's SKU
// **/
// List<T> getTransactionsPerSku(String mPathTransactions, String mSku);
//
// /**
// * to save Transactions indexed per product's SKU
// **/
// boolean saveTransactions(Map<String, List<T>> map);
// }
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/GetTransactionListInteractorImpl.java
import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException;
import com.raulh82vlc.TransactionsViewer.domain.executors.Interactor;
import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor;
import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread;
import com.raulh82vlc.TransactionsViewer.domain.models.Rate;
import com.raulh82vlc.TransactionsViewer.domain.models.Transaction;
import com.raulh82vlc.TransactionsViewer.domain.repository.DataRepository;
import java.util.List;
import javax.inject.Inject;
/*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.domain.interactors;
/**
* Implementation of the Get specific details of a movie
*
* @author Raul Hernandez Lopez
*/
public class GetTransactionListInteractorImpl implements GetTransactionListInteractor, Interactor {
private InteractorExecutor executor;
private MainThread mainThread; | private DataRepository<Rate, Transaction> repository; |
raulh82vlc/Transactions-Viewer | domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/GetTransactionListInteractorImpl.java | // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java
// public class CustomException extends Exception {
// public CustomException(String detailMessage) {
// super(detailMessage);
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/Interactor.java
// public interface Interactor {
// void run() throws CustomException;
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java
// public interface InteractorExecutor {
// void run(Interactor interactor) throws CustomException;
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java
// public interface MainThread {
// void post(final Runnable runnable);
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java
// public class Rate {
// @SerializedName("from")
// private String fromCurrency;
// @SerializedName("rate")
// private String rate;
// @SerializedName("to")
// private String toCurrency;
//
// public String getFromCurrency() {
// return fromCurrency;
// }
//
// public String getRate() {
// return rate;
// }
//
// public String getToCurrency() {
// return toCurrency;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java
// public class Transaction {
//
// @SerializedName("sku")
// private String skuIdentifier;
//
// @SerializedName("amount")
// private String amountPerTransaction;
//
// @SerializedName("currency")
// private String currency;
//
// public String getSkuIdentifier() {
// return skuIdentifier;
// }
//
// public String getAmountPerTransaction() {
// return amountPerTransaction;
// }
//
// public String getCurrency() {
// return currency;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/DataRepository.java
// public interface DataRepository<R, T> {
//
// /**
// * to get Rates List
// **/
// List<R> getRatesList(String path) throws CustomException;
//
// /**
// * to get Transactions list
// **/
// List<T> getTransactionsList(String path) throws CustomException;
//
// /**
// * to get Transactions per product's SKU
// **/
// List<T> getTransactionsPerSku(String mPathTransactions, String mSku);
//
// /**
// * to save Transactions indexed per product's SKU
// **/
// boolean saveTransactions(Map<String, List<T>> map);
// }
| import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException;
import com.raulh82vlc.TransactionsViewer.domain.executors.Interactor;
import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor;
import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread;
import com.raulh82vlc.TransactionsViewer.domain.models.Rate;
import com.raulh82vlc.TransactionsViewer.domain.models.Transaction;
import com.raulh82vlc.TransactionsViewer.domain.repository.DataRepository;
import java.util.List;
import javax.inject.Inject; | /*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.domain.interactors;
/**
* Implementation of the Get specific details of a movie
*
* @author Raul Hernandez Lopez
*/
public class GetTransactionListInteractorImpl implements GetTransactionListInteractor, Interactor {
private InteractorExecutor executor;
private MainThread mainThread;
private DataRepository<Rate, Transaction> repository;
private GetTransactionsListCallback callback;
private String path;
@Inject
GetTransactionListInteractorImpl(InteractorExecutor executor,
MainThread mainThread,
DataRepository repository) {
this.executor = executor;
this.mainThread = mainThread;
this.repository = repository;
}
@Override
public void execute(String path, GetTransactionsListCallback callback) {
this.path = path;
this.callback = callback;
try {
this.executor.run(this); | // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java
// public class CustomException extends Exception {
// public CustomException(String detailMessage) {
// super(detailMessage);
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/Interactor.java
// public interface Interactor {
// void run() throws CustomException;
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java
// public interface InteractorExecutor {
// void run(Interactor interactor) throws CustomException;
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java
// public interface MainThread {
// void post(final Runnable runnable);
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java
// public class Rate {
// @SerializedName("from")
// private String fromCurrency;
// @SerializedName("rate")
// private String rate;
// @SerializedName("to")
// private String toCurrency;
//
// public String getFromCurrency() {
// return fromCurrency;
// }
//
// public String getRate() {
// return rate;
// }
//
// public String getToCurrency() {
// return toCurrency;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java
// public class Transaction {
//
// @SerializedName("sku")
// private String skuIdentifier;
//
// @SerializedName("amount")
// private String amountPerTransaction;
//
// @SerializedName("currency")
// private String currency;
//
// public String getSkuIdentifier() {
// return skuIdentifier;
// }
//
// public String getAmountPerTransaction() {
// return amountPerTransaction;
// }
//
// public String getCurrency() {
// return currency;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/DataRepository.java
// public interface DataRepository<R, T> {
//
// /**
// * to get Rates List
// **/
// List<R> getRatesList(String path) throws CustomException;
//
// /**
// * to get Transactions list
// **/
// List<T> getTransactionsList(String path) throws CustomException;
//
// /**
// * to get Transactions per product's SKU
// **/
// List<T> getTransactionsPerSku(String mPathTransactions, String mSku);
//
// /**
// * to save Transactions indexed per product's SKU
// **/
// boolean saveTransactions(Map<String, List<T>> map);
// }
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/GetTransactionListInteractorImpl.java
import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException;
import com.raulh82vlc.TransactionsViewer.domain.executors.Interactor;
import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor;
import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread;
import com.raulh82vlc.TransactionsViewer.domain.models.Rate;
import com.raulh82vlc.TransactionsViewer.domain.models.Transaction;
import com.raulh82vlc.TransactionsViewer.domain.repository.DataRepository;
import java.util.List;
import javax.inject.Inject;
/*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.domain.interactors;
/**
* Implementation of the Get specific details of a movie
*
* @author Raul Hernandez Lopez
*/
public class GetTransactionListInteractorImpl implements GetTransactionListInteractor, Interactor {
private InteractorExecutor executor;
private MainThread mainThread;
private DataRepository<Rate, Transaction> repository;
private GetTransactionsListCallback callback;
private String path;
@Inject
GetTransactionListInteractorImpl(InteractorExecutor executor,
MainThread mainThread,
DataRepository repository) {
this.executor = executor;
this.mainThread = mainThread;
this.repository = repository;
}
@Override
public void execute(String path, GetTransactionsListCallback callback) {
this.path = path;
this.callback = callback;
try {
this.executor.run(this); | } catch (CustomException e) { |
raulh82vlc/Transactions-Viewer | domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/GetTransactionListInteractor.java | // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java
// public class CustomException extends Exception {
// public CustomException(String detailMessage) {
// super(detailMessage);
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java
// public class Transaction {
//
// @SerializedName("sku")
// private String skuIdentifier;
//
// @SerializedName("amount")
// private String amountPerTransaction;
//
// @SerializedName("currency")
// private String currency;
//
// public String getSkuIdentifier() {
// return skuIdentifier;
// }
//
// public String getAmountPerTransaction() {
// return amountPerTransaction;
// }
//
// public String getCurrency() {
// return currency;
// }
// }
| import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException;
import com.raulh82vlc.TransactionsViewer.domain.models.Transaction;
import java.util.List; | /*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.domain.interactors;
/**
* Get Transactions Use Case
*
* @author Raul Hernandez Lopez
*/
public interface GetTransactionListInteractor {
void execute(String path, GetTransactionsListCallback callback) throws CustomException;
interface GetTransactionsListCallback { | // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java
// public class CustomException extends Exception {
// public CustomException(String detailMessage) {
// super(detailMessage);
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java
// public class Transaction {
//
// @SerializedName("sku")
// private String skuIdentifier;
//
// @SerializedName("amount")
// private String amountPerTransaction;
//
// @SerializedName("currency")
// private String currency;
//
// public String getSkuIdentifier() {
// return skuIdentifier;
// }
//
// public String getAmountPerTransaction() {
// return amountPerTransaction;
// }
//
// public String getCurrency() {
// return currency;
// }
// }
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/GetTransactionListInteractor.java
import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException;
import com.raulh82vlc.TransactionsViewer.domain.models.Transaction;
import java.util.List;
/*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.domain.interactors;
/**
* Get Transactions Use Case
*
* @author Raul Hernandez Lopez
*/
public interface GetTransactionListInteractor {
void execute(String path, GetTransactionsListCallback callback) throws CustomException;
interface GetTransactionsListCallback { | void onGetTransactionsListOK(List<Transaction> transactionList); |
raulh82vlc/Transactions-Viewer | android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/TransactionsPresenter.java | // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java
// public class CustomException extends Exception {
// public CustomException(String detailMessage) {
// super(detailMessage);
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/ProductUI.java
// public class ProductUI implements Parcelable {
//
// private String sku;
// private List<TransactionUI> transactions;
//
// public static final Creator<ProductUI> CREATOR = new Creator<ProductUI>() {
// @Override
// public ProductUI createFromParcel(Parcel in) {
// return new ProductUI(in);
// }
//
// @Override
// public ProductUI[] newArray(int size) {
// return new ProductUI[size];
// }
// };
//
// private ProductUI(Parcel in) {
// sku = in.readString();
// if (transactions == null) {
// transactions = new ArrayList<>();
// }
// in.readList(transactions, Transaction.class.getClassLoader());
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(sku);
// dest.writeList(transactions);
// }
//
// public ProductUI(String key, List<Transaction> values, String toCurrency) {
// sku = key;
// transactions = new ArrayList<>(values.size());
// for (Transaction transaction : values) {
// transactions.add(new TransactionUI(transaction.getCurrency(), toCurrency,
// transaction.getAmountPerTransaction(), "0"));
// }
//
// }
//
// public List<TransactionUI> getTransactions() {
// return transactions;
// }
//
// public String getSku() {
// return sku;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java
// public class Transaction {
//
// @SerializedName("sku")
// private String skuIdentifier;
//
// @SerializedName("amount")
// private String amountPerTransaction;
//
// @SerializedName("currency")
// private String currency;
//
// public String getSkuIdentifier() {
// return skuIdentifier;
// }
//
// public String getAmountPerTransaction() {
// return amountPerTransaction;
// }
//
// public String getCurrency() {
// return currency;
// }
// }
| import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException;
import com.raulh82vlc.TransactionsViewer.domain.models.ProductUI;
import com.raulh82vlc.TransactionsViewer.domain.models.Transaction;
import java.util.List;
import java.util.Map; | /*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.ui.presentation;
/**
* <p>Presenter responsible of asking for Transactions and get them back if any available</p>
*
* @author Raul Hernandez Lopez
*/
public interface TransactionsPresenter {
void startReading(String path) throws CustomException;
void setView(View view);
| // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java
// public class CustomException extends Exception {
// public CustomException(String detailMessage) {
// super(detailMessage);
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/ProductUI.java
// public class ProductUI implements Parcelable {
//
// private String sku;
// private List<TransactionUI> transactions;
//
// public static final Creator<ProductUI> CREATOR = new Creator<ProductUI>() {
// @Override
// public ProductUI createFromParcel(Parcel in) {
// return new ProductUI(in);
// }
//
// @Override
// public ProductUI[] newArray(int size) {
// return new ProductUI[size];
// }
// };
//
// private ProductUI(Parcel in) {
// sku = in.readString();
// if (transactions == null) {
// transactions = new ArrayList<>();
// }
// in.readList(transactions, Transaction.class.getClassLoader());
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(sku);
// dest.writeList(transactions);
// }
//
// public ProductUI(String key, List<Transaction> values, String toCurrency) {
// sku = key;
// transactions = new ArrayList<>(values.size());
// for (Transaction transaction : values) {
// transactions.add(new TransactionUI(transaction.getCurrency(), toCurrency,
// transaction.getAmountPerTransaction(), "0"));
// }
//
// }
//
// public List<TransactionUI> getTransactions() {
// return transactions;
// }
//
// public String getSku() {
// return sku;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java
// public class Transaction {
//
// @SerializedName("sku")
// private String skuIdentifier;
//
// @SerializedName("amount")
// private String amountPerTransaction;
//
// @SerializedName("currency")
// private String currency;
//
// public String getSkuIdentifier() {
// return skuIdentifier;
// }
//
// public String getAmountPerTransaction() {
// return amountPerTransaction;
// }
//
// public String getCurrency() {
// return currency;
// }
// }
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/TransactionsPresenter.java
import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException;
import com.raulh82vlc.TransactionsViewer.domain.models.ProductUI;
import com.raulh82vlc.TransactionsViewer.domain.models.Transaction;
import java.util.List;
import java.util.Map;
/*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.ui.presentation;
/**
* <p>Presenter responsible of asking for Transactions and get them back if any available</p>
*
* @author Raul Hernandez Lopez
*/
public interface TransactionsPresenter {
void startReading(String path) throws CustomException;
void setView(View view);
| void saveProducts(List<Transaction> transactionList, Map<String, List<Transaction>> transactionsMap) |
raulh82vlc/Transactions-Viewer | android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/TransactionsPresenter.java | // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java
// public class CustomException extends Exception {
// public CustomException(String detailMessage) {
// super(detailMessage);
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/ProductUI.java
// public class ProductUI implements Parcelable {
//
// private String sku;
// private List<TransactionUI> transactions;
//
// public static final Creator<ProductUI> CREATOR = new Creator<ProductUI>() {
// @Override
// public ProductUI createFromParcel(Parcel in) {
// return new ProductUI(in);
// }
//
// @Override
// public ProductUI[] newArray(int size) {
// return new ProductUI[size];
// }
// };
//
// private ProductUI(Parcel in) {
// sku = in.readString();
// if (transactions == null) {
// transactions = new ArrayList<>();
// }
// in.readList(transactions, Transaction.class.getClassLoader());
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(sku);
// dest.writeList(transactions);
// }
//
// public ProductUI(String key, List<Transaction> values, String toCurrency) {
// sku = key;
// transactions = new ArrayList<>(values.size());
// for (Transaction transaction : values) {
// transactions.add(new TransactionUI(transaction.getCurrency(), toCurrency,
// transaction.getAmountPerTransaction(), "0"));
// }
//
// }
//
// public List<TransactionUI> getTransactions() {
// return transactions;
// }
//
// public String getSku() {
// return sku;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java
// public class Transaction {
//
// @SerializedName("sku")
// private String skuIdentifier;
//
// @SerializedName("amount")
// private String amountPerTransaction;
//
// @SerializedName("currency")
// private String currency;
//
// public String getSkuIdentifier() {
// return skuIdentifier;
// }
//
// public String getAmountPerTransaction() {
// return amountPerTransaction;
// }
//
// public String getCurrency() {
// return currency;
// }
// }
| import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException;
import com.raulh82vlc.TransactionsViewer.domain.models.ProductUI;
import com.raulh82vlc.TransactionsViewer.domain.models.Transaction;
import java.util.List;
import java.util.Map; | /*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.ui.presentation;
/**
* <p>Presenter responsible of asking for Transactions and get them back if any available</p>
*
* @author Raul Hernandez Lopez
*/
public interface TransactionsPresenter {
void startReading(String path) throws CustomException;
void setView(View view);
void saveProducts(List<Transaction> transactionList, Map<String, List<Transaction>> transactionsMap)
throws CustomException;
void resetView();
interface View {
void saveProducts(Map<String, List<Transaction>> transactionsMap, List<Transaction> transactionList);
void errorSavingProducts(String error);
void productsSavedSuccessfully(String msg);
void errorGettingTransactions(String error);
| // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java
// public class CustomException extends Exception {
// public CustomException(String detailMessage) {
// super(detailMessage);
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/ProductUI.java
// public class ProductUI implements Parcelable {
//
// private String sku;
// private List<TransactionUI> transactions;
//
// public static final Creator<ProductUI> CREATOR = new Creator<ProductUI>() {
// @Override
// public ProductUI createFromParcel(Parcel in) {
// return new ProductUI(in);
// }
//
// @Override
// public ProductUI[] newArray(int size) {
// return new ProductUI[size];
// }
// };
//
// private ProductUI(Parcel in) {
// sku = in.readString();
// if (transactions == null) {
// transactions = new ArrayList<>();
// }
// in.readList(transactions, Transaction.class.getClassLoader());
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(sku);
// dest.writeList(transactions);
// }
//
// public ProductUI(String key, List<Transaction> values, String toCurrency) {
// sku = key;
// transactions = new ArrayList<>(values.size());
// for (Transaction transaction : values) {
// transactions.add(new TransactionUI(transaction.getCurrency(), toCurrency,
// transaction.getAmountPerTransaction(), "0"));
// }
//
// }
//
// public List<TransactionUI> getTransactions() {
// return transactions;
// }
//
// public String getSku() {
// return sku;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java
// public class Transaction {
//
// @SerializedName("sku")
// private String skuIdentifier;
//
// @SerializedName("amount")
// private String amountPerTransaction;
//
// @SerializedName("currency")
// private String currency;
//
// public String getSkuIdentifier() {
// return skuIdentifier;
// }
//
// public String getAmountPerTransaction() {
// return amountPerTransaction;
// }
//
// public String getCurrency() {
// return currency;
// }
// }
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/TransactionsPresenter.java
import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException;
import com.raulh82vlc.TransactionsViewer.domain.models.ProductUI;
import com.raulh82vlc.TransactionsViewer.domain.models.Transaction;
import java.util.List;
import java.util.Map;
/*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.ui.presentation;
/**
* <p>Presenter responsible of asking for Transactions and get them back if any available</p>
*
* @author Raul Hernandez Lopez
*/
public interface TransactionsPresenter {
void startReading(String path) throws CustomException;
void setView(View view);
void saveProducts(List<Transaction> transactionList, Map<String, List<Transaction>> transactionsMap)
throws CustomException;
void resetView();
interface View {
void saveProducts(Map<String, List<Transaction>> transactionsMap, List<Transaction> transactionList);
void errorSavingProducts(String error);
void productsSavedSuccessfully(String msg);
void errorGettingTransactions(String error);
| void showProductsList(List<ProductUI> productUIs); |
raulh82vlc/Transactions-Viewer | android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/TransactionsRatedDataMapper.java | // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/TransactionRatedDomain.java
// public class TransactionRatedDomain {
// private BigDecimal amounPerTransactionPrev;
// private BigDecimal amountPerTransactionCurrent;
// private String currencyPrev;
// private String currencyCurrent;
//
// public TransactionRatedDomain(String currencyPrev, String currencyCurrent,
// BigDecimal amounPerTransactionPrev,
// BigDecimal amountPerTransactionCurrent) {
// this.currencyPrev = currencyPrev;
// this.currencyCurrent = currencyCurrent;
// this.amounPerTransactionPrev = amounPerTransactionPrev;
// this.amountPerTransactionCurrent = amountPerTransactionCurrent;
// }
//
// public BigDecimal getAmounPerTransactionPrev() {
// return amounPerTransactionPrev;
// }
//
// public BigDecimal getAmountPerTransactionCurrent() {
// return amountPerTransactionCurrent;
// }
//
// public String getCurrencyPrev() {
// return currencyPrev;
// }
//
// public String getCurrencyCurrent() {
// return currencyCurrent;
// }
//
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/TransactionUI.java
// public class TransactionUI implements Parcelable {
// private String amounPerTransactionPrev;
// private String amountPerTransactionCurrent;
// private String currencyPrev;
// private String currencyCurrent;
//
// public TransactionUI(String currencyPrev, String currencyCurrent, String amounPerTransactionPrev,
// String amountPerTransactionCurrent) {
// this.currencyPrev = currencyPrev;
// this.currencyCurrent = currencyCurrent;
// this.amounPerTransactionPrev = amounPerTransactionPrev;
// this.amountPerTransactionCurrent = amountPerTransactionCurrent;
// }
//
// private TransactionUI(Parcel in) {
// currencyPrev = in.readString();
// currencyCurrent = in.readString();
// amounPerTransactionPrev = in.readString();
// amountPerTransactionCurrent = in.readString();
// }
//
// public static final Creator<TransactionUI> CREATOR = new Creator<TransactionUI>() {
// @Override
// public TransactionUI createFromParcel(Parcel in) {
// return new TransactionUI(in);
// }
//
// @Override
// public TransactionUI[] newArray(int size) {
// return new TransactionUI[size];
// }
// };
//
// public String getAmounPerTransactionPrev() {
// return amounPerTransactionPrev;
// }
//
// public String getAmountPerTransactionCurrent() {
// return amountPerTransactionCurrent;
// }
//
// public String getCurrencyPrev() {
// return currencyPrev;
// }
//
// public String getCurrencyCurrent() {
// return currencyCurrent;
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(currencyPrev);
// dest.writeString(currencyCurrent);
// dest.writeString(amounPerTransactionPrev);
// dest.writeString(amountPerTransactionCurrent);
// }
// }
| import com.raulh82vlc.TransactionsViewer.di.scopes.ActivityScope;
import com.raulh82vlc.TransactionsViewer.domain.models.TransactionRatedDomain;
import com.raulh82vlc.TransactionsViewer.domain.models.TransactionUI;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject; | /*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.domain.interactors.mappers;
/**
* Transactions Rated Data Mapper to map info from Domain to UI and so on
*
* @author Raul Hernandez Lopez.
*/
@ActivityScope
public class TransactionsRatedDataMapper {
@Inject
TransactionsRatedDataMapper() {
}
| // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/TransactionRatedDomain.java
// public class TransactionRatedDomain {
// private BigDecimal amounPerTransactionPrev;
// private BigDecimal amountPerTransactionCurrent;
// private String currencyPrev;
// private String currencyCurrent;
//
// public TransactionRatedDomain(String currencyPrev, String currencyCurrent,
// BigDecimal amounPerTransactionPrev,
// BigDecimal amountPerTransactionCurrent) {
// this.currencyPrev = currencyPrev;
// this.currencyCurrent = currencyCurrent;
// this.amounPerTransactionPrev = amounPerTransactionPrev;
// this.amountPerTransactionCurrent = amountPerTransactionCurrent;
// }
//
// public BigDecimal getAmounPerTransactionPrev() {
// return amounPerTransactionPrev;
// }
//
// public BigDecimal getAmountPerTransactionCurrent() {
// return amountPerTransactionCurrent;
// }
//
// public String getCurrencyPrev() {
// return currencyPrev;
// }
//
// public String getCurrencyCurrent() {
// return currencyCurrent;
// }
//
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/TransactionUI.java
// public class TransactionUI implements Parcelable {
// private String amounPerTransactionPrev;
// private String amountPerTransactionCurrent;
// private String currencyPrev;
// private String currencyCurrent;
//
// public TransactionUI(String currencyPrev, String currencyCurrent, String amounPerTransactionPrev,
// String amountPerTransactionCurrent) {
// this.currencyPrev = currencyPrev;
// this.currencyCurrent = currencyCurrent;
// this.amounPerTransactionPrev = amounPerTransactionPrev;
// this.amountPerTransactionCurrent = amountPerTransactionCurrent;
// }
//
// private TransactionUI(Parcel in) {
// currencyPrev = in.readString();
// currencyCurrent = in.readString();
// amounPerTransactionPrev = in.readString();
// amountPerTransactionCurrent = in.readString();
// }
//
// public static final Creator<TransactionUI> CREATOR = new Creator<TransactionUI>() {
// @Override
// public TransactionUI createFromParcel(Parcel in) {
// return new TransactionUI(in);
// }
//
// @Override
// public TransactionUI[] newArray(int size) {
// return new TransactionUI[size];
// }
// };
//
// public String getAmounPerTransactionPrev() {
// return amounPerTransactionPrev;
// }
//
// public String getAmountPerTransactionCurrent() {
// return amountPerTransactionCurrent;
// }
//
// public String getCurrencyPrev() {
// return currencyPrev;
// }
//
// public String getCurrencyCurrent() {
// return currencyCurrent;
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(currencyPrev);
// dest.writeString(currencyCurrent);
// dest.writeString(amounPerTransactionPrev);
// dest.writeString(amountPerTransactionCurrent);
// }
// }
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/TransactionsRatedDataMapper.java
import com.raulh82vlc.TransactionsViewer.di.scopes.ActivityScope;
import com.raulh82vlc.TransactionsViewer.domain.models.TransactionRatedDomain;
import com.raulh82vlc.TransactionsViewer.domain.models.TransactionUI;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
/*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.domain.interactors.mappers;
/**
* Transactions Rated Data Mapper to map info from Domain to UI and so on
*
* @author Raul Hernandez Lopez.
*/
@ActivityScope
public class TransactionsRatedDataMapper {
@Inject
TransactionsRatedDataMapper() {
}
| public List<TransactionUI> transformToUI(List<TransactionRatedDomain> transactionList) { |
raulh82vlc/Transactions-Viewer | android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/TransactionsRatedDataMapper.java | // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/TransactionRatedDomain.java
// public class TransactionRatedDomain {
// private BigDecimal amounPerTransactionPrev;
// private BigDecimal amountPerTransactionCurrent;
// private String currencyPrev;
// private String currencyCurrent;
//
// public TransactionRatedDomain(String currencyPrev, String currencyCurrent,
// BigDecimal amounPerTransactionPrev,
// BigDecimal amountPerTransactionCurrent) {
// this.currencyPrev = currencyPrev;
// this.currencyCurrent = currencyCurrent;
// this.amounPerTransactionPrev = amounPerTransactionPrev;
// this.amountPerTransactionCurrent = amountPerTransactionCurrent;
// }
//
// public BigDecimal getAmounPerTransactionPrev() {
// return amounPerTransactionPrev;
// }
//
// public BigDecimal getAmountPerTransactionCurrent() {
// return amountPerTransactionCurrent;
// }
//
// public String getCurrencyPrev() {
// return currencyPrev;
// }
//
// public String getCurrencyCurrent() {
// return currencyCurrent;
// }
//
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/TransactionUI.java
// public class TransactionUI implements Parcelable {
// private String amounPerTransactionPrev;
// private String amountPerTransactionCurrent;
// private String currencyPrev;
// private String currencyCurrent;
//
// public TransactionUI(String currencyPrev, String currencyCurrent, String amounPerTransactionPrev,
// String amountPerTransactionCurrent) {
// this.currencyPrev = currencyPrev;
// this.currencyCurrent = currencyCurrent;
// this.amounPerTransactionPrev = amounPerTransactionPrev;
// this.amountPerTransactionCurrent = amountPerTransactionCurrent;
// }
//
// private TransactionUI(Parcel in) {
// currencyPrev = in.readString();
// currencyCurrent = in.readString();
// amounPerTransactionPrev = in.readString();
// amountPerTransactionCurrent = in.readString();
// }
//
// public static final Creator<TransactionUI> CREATOR = new Creator<TransactionUI>() {
// @Override
// public TransactionUI createFromParcel(Parcel in) {
// return new TransactionUI(in);
// }
//
// @Override
// public TransactionUI[] newArray(int size) {
// return new TransactionUI[size];
// }
// };
//
// public String getAmounPerTransactionPrev() {
// return amounPerTransactionPrev;
// }
//
// public String getAmountPerTransactionCurrent() {
// return amountPerTransactionCurrent;
// }
//
// public String getCurrencyPrev() {
// return currencyPrev;
// }
//
// public String getCurrencyCurrent() {
// return currencyCurrent;
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(currencyPrev);
// dest.writeString(currencyCurrent);
// dest.writeString(amounPerTransactionPrev);
// dest.writeString(amountPerTransactionCurrent);
// }
// }
| import com.raulh82vlc.TransactionsViewer.di.scopes.ActivityScope;
import com.raulh82vlc.TransactionsViewer.domain.models.TransactionRatedDomain;
import com.raulh82vlc.TransactionsViewer.domain.models.TransactionUI;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject; | /*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.domain.interactors.mappers;
/**
* Transactions Rated Data Mapper to map info from Domain to UI and so on
*
* @author Raul Hernandez Lopez.
*/
@ActivityScope
public class TransactionsRatedDataMapper {
@Inject
TransactionsRatedDataMapper() {
}
| // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/TransactionRatedDomain.java
// public class TransactionRatedDomain {
// private BigDecimal amounPerTransactionPrev;
// private BigDecimal amountPerTransactionCurrent;
// private String currencyPrev;
// private String currencyCurrent;
//
// public TransactionRatedDomain(String currencyPrev, String currencyCurrent,
// BigDecimal amounPerTransactionPrev,
// BigDecimal amountPerTransactionCurrent) {
// this.currencyPrev = currencyPrev;
// this.currencyCurrent = currencyCurrent;
// this.amounPerTransactionPrev = amounPerTransactionPrev;
// this.amountPerTransactionCurrent = amountPerTransactionCurrent;
// }
//
// public BigDecimal getAmounPerTransactionPrev() {
// return amounPerTransactionPrev;
// }
//
// public BigDecimal getAmountPerTransactionCurrent() {
// return amountPerTransactionCurrent;
// }
//
// public String getCurrencyPrev() {
// return currencyPrev;
// }
//
// public String getCurrencyCurrent() {
// return currencyCurrent;
// }
//
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/TransactionUI.java
// public class TransactionUI implements Parcelable {
// private String amounPerTransactionPrev;
// private String amountPerTransactionCurrent;
// private String currencyPrev;
// private String currencyCurrent;
//
// public TransactionUI(String currencyPrev, String currencyCurrent, String amounPerTransactionPrev,
// String amountPerTransactionCurrent) {
// this.currencyPrev = currencyPrev;
// this.currencyCurrent = currencyCurrent;
// this.amounPerTransactionPrev = amounPerTransactionPrev;
// this.amountPerTransactionCurrent = amountPerTransactionCurrent;
// }
//
// private TransactionUI(Parcel in) {
// currencyPrev = in.readString();
// currencyCurrent = in.readString();
// amounPerTransactionPrev = in.readString();
// amountPerTransactionCurrent = in.readString();
// }
//
// public static final Creator<TransactionUI> CREATOR = new Creator<TransactionUI>() {
// @Override
// public TransactionUI createFromParcel(Parcel in) {
// return new TransactionUI(in);
// }
//
// @Override
// public TransactionUI[] newArray(int size) {
// return new TransactionUI[size];
// }
// };
//
// public String getAmounPerTransactionPrev() {
// return amounPerTransactionPrev;
// }
//
// public String getAmountPerTransactionCurrent() {
// return amountPerTransactionCurrent;
// }
//
// public String getCurrencyPrev() {
// return currencyPrev;
// }
//
// public String getCurrencyCurrent() {
// return currencyCurrent;
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(currencyPrev);
// dest.writeString(currencyCurrent);
// dest.writeString(amounPerTransactionPrev);
// dest.writeString(amountPerTransactionCurrent);
// }
// }
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/TransactionsRatedDataMapper.java
import com.raulh82vlc.TransactionsViewer.di.scopes.ActivityScope;
import com.raulh82vlc.TransactionsViewer.domain.models.TransactionRatedDomain;
import com.raulh82vlc.TransactionsViewer.domain.models.TransactionUI;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
/*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.domain.interactors.mappers;
/**
* Transactions Rated Data Mapper to map info from Domain to UI and so on
*
* @author Raul Hernandez Lopez.
*/
@ActivityScope
public class TransactionsRatedDataMapper {
@Inject
TransactionsRatedDataMapper() {
}
| public List<TransactionUI> transformToUI(List<TransactionRatedDomain> transactionList) { |
raulh82vlc/Transactions-Viewer | android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors_response/GetTransactionsComputedCallbackImpl.java | // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/ComputeTransactionsInteractor.java
// public interface ComputeTransactionsInteractor {
//
// void execute(String skuFromProduct,
// GetTransactionsComputedCallback getTransactionsComputedCallback,
// String toCurrency,
// String pathTransactions, String pathRates) throws CustomException;
//
//
// interface GetTransactionsComputedCallback {
// void onGetTransactionsListOK(List<TransactionRatedDomain> transactionList, String totalAmount);
//
// void onGetTransactionListKO(String error);
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/TransactionsRatedDataMapper.java
// @ActivityScope
// public class TransactionsRatedDataMapper {
//
// @Inject
// TransactionsRatedDataMapper() {
//
// }
//
// public List<TransactionUI> transformToUI(List<TransactionRatedDomain> transactionList) {
// if (transactionList == null) {
// throw new IllegalArgumentException("Cannot transform a null value");
// }
//
// List<TransactionUI> transactionUIDomList = new ArrayList<>();
// for (TransactionRatedDomain transactionRated : transactionList) {
// transactionUIDomList.add(new TransactionUI(transactionRated.getCurrencyPrev(),
// transactionRated.getCurrencyCurrent(), transactionRated.getAmounPerTransactionPrev().toString(),
// transactionRated.getAmountPerTransactionCurrent().toString()));
// }
// return transactionUIDomList;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/TransactionRatedDomain.java
// public class TransactionRatedDomain {
// private BigDecimal amounPerTransactionPrev;
// private BigDecimal amountPerTransactionCurrent;
// private String currencyPrev;
// private String currencyCurrent;
//
// public TransactionRatedDomain(String currencyPrev, String currencyCurrent,
// BigDecimal amounPerTransactionPrev,
// BigDecimal amountPerTransactionCurrent) {
// this.currencyPrev = currencyPrev;
// this.currencyCurrent = currencyCurrent;
// this.amounPerTransactionPrev = amounPerTransactionPrev;
// this.amountPerTransactionCurrent = amountPerTransactionCurrent;
// }
//
// public BigDecimal getAmounPerTransactionPrev() {
// return amounPerTransactionPrev;
// }
//
// public BigDecimal getAmountPerTransactionCurrent() {
// return amountPerTransactionCurrent;
// }
//
// public String getCurrencyPrev() {
// return currencyPrev;
// }
//
// public String getCurrencyCurrent() {
// return currencyCurrent;
// }
//
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/ComputingTransactionsPresenter.java
// public interface ComputingTransactionsPresenter {
//
// void setView(View view);
//
// void resetView();
//
// void computeRates(String skuFromProduct, String toCurrency, String pathTransactions, String pathRates)
// throws CustomException;
//
// interface View {
// void errorComputingRates(String error);
//
// void computedRatesForTransactions(List<TransactionUI> transactions, String totalAmount);
//
// void visibilityChangesAfterSuccessfulComputedRates();
//
// void visibilityChangesAfterErrorComputedRates();
//
// boolean isReady();
//
// void startLoader();
// }
// }
| import com.raulh82vlc.TransactionsViewer.domain.interactors.ComputeTransactionsInteractor;
import com.raulh82vlc.TransactionsViewer.domain.interactors.mappers.TransactionsRatedDataMapper;
import com.raulh82vlc.TransactionsViewer.domain.models.TransactionRatedDomain;
import com.raulh82vlc.TransactionsViewer.ui.presentation.ComputingTransactionsPresenter;
import java.util.List; | /*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.domain.interactors_response;
/**
* Get Transactions list by means of its callback, communicating towards its view
*
* @author Raul Hernandez Lopez.
*/
public class GetTransactionsComputedCallbackImpl implements
ComputeTransactionsInteractor.GetTransactionsComputedCallback {
| // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/ComputeTransactionsInteractor.java
// public interface ComputeTransactionsInteractor {
//
// void execute(String skuFromProduct,
// GetTransactionsComputedCallback getTransactionsComputedCallback,
// String toCurrency,
// String pathTransactions, String pathRates) throws CustomException;
//
//
// interface GetTransactionsComputedCallback {
// void onGetTransactionsListOK(List<TransactionRatedDomain> transactionList, String totalAmount);
//
// void onGetTransactionListKO(String error);
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/TransactionsRatedDataMapper.java
// @ActivityScope
// public class TransactionsRatedDataMapper {
//
// @Inject
// TransactionsRatedDataMapper() {
//
// }
//
// public List<TransactionUI> transformToUI(List<TransactionRatedDomain> transactionList) {
// if (transactionList == null) {
// throw new IllegalArgumentException("Cannot transform a null value");
// }
//
// List<TransactionUI> transactionUIDomList = new ArrayList<>();
// for (TransactionRatedDomain transactionRated : transactionList) {
// transactionUIDomList.add(new TransactionUI(transactionRated.getCurrencyPrev(),
// transactionRated.getCurrencyCurrent(), transactionRated.getAmounPerTransactionPrev().toString(),
// transactionRated.getAmountPerTransactionCurrent().toString()));
// }
// return transactionUIDomList;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/TransactionRatedDomain.java
// public class TransactionRatedDomain {
// private BigDecimal amounPerTransactionPrev;
// private BigDecimal amountPerTransactionCurrent;
// private String currencyPrev;
// private String currencyCurrent;
//
// public TransactionRatedDomain(String currencyPrev, String currencyCurrent,
// BigDecimal amounPerTransactionPrev,
// BigDecimal amountPerTransactionCurrent) {
// this.currencyPrev = currencyPrev;
// this.currencyCurrent = currencyCurrent;
// this.amounPerTransactionPrev = amounPerTransactionPrev;
// this.amountPerTransactionCurrent = amountPerTransactionCurrent;
// }
//
// public BigDecimal getAmounPerTransactionPrev() {
// return amounPerTransactionPrev;
// }
//
// public BigDecimal getAmountPerTransactionCurrent() {
// return amountPerTransactionCurrent;
// }
//
// public String getCurrencyPrev() {
// return currencyPrev;
// }
//
// public String getCurrencyCurrent() {
// return currencyCurrent;
// }
//
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/ComputingTransactionsPresenter.java
// public interface ComputingTransactionsPresenter {
//
// void setView(View view);
//
// void resetView();
//
// void computeRates(String skuFromProduct, String toCurrency, String pathTransactions, String pathRates)
// throws CustomException;
//
// interface View {
// void errorComputingRates(String error);
//
// void computedRatesForTransactions(List<TransactionUI> transactions, String totalAmount);
//
// void visibilityChangesAfterSuccessfulComputedRates();
//
// void visibilityChangesAfterErrorComputedRates();
//
// boolean isReady();
//
// void startLoader();
// }
// }
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors_response/GetTransactionsComputedCallbackImpl.java
import com.raulh82vlc.TransactionsViewer.domain.interactors.ComputeTransactionsInteractor;
import com.raulh82vlc.TransactionsViewer.domain.interactors.mappers.TransactionsRatedDataMapper;
import com.raulh82vlc.TransactionsViewer.domain.models.TransactionRatedDomain;
import com.raulh82vlc.TransactionsViewer.ui.presentation.ComputingTransactionsPresenter;
import java.util.List;
/*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.domain.interactors_response;
/**
* Get Transactions list by means of its callback, communicating towards its view
*
* @author Raul Hernandez Lopez.
*/
public class GetTransactionsComputedCallbackImpl implements
ComputeTransactionsInteractor.GetTransactionsComputedCallback {
| private final ComputingTransactionsPresenter.View mView; |
raulh82vlc/Transactions-Viewer | android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors_response/GetTransactionsComputedCallbackImpl.java | // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/ComputeTransactionsInteractor.java
// public interface ComputeTransactionsInteractor {
//
// void execute(String skuFromProduct,
// GetTransactionsComputedCallback getTransactionsComputedCallback,
// String toCurrency,
// String pathTransactions, String pathRates) throws CustomException;
//
//
// interface GetTransactionsComputedCallback {
// void onGetTransactionsListOK(List<TransactionRatedDomain> transactionList, String totalAmount);
//
// void onGetTransactionListKO(String error);
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/TransactionsRatedDataMapper.java
// @ActivityScope
// public class TransactionsRatedDataMapper {
//
// @Inject
// TransactionsRatedDataMapper() {
//
// }
//
// public List<TransactionUI> transformToUI(List<TransactionRatedDomain> transactionList) {
// if (transactionList == null) {
// throw new IllegalArgumentException("Cannot transform a null value");
// }
//
// List<TransactionUI> transactionUIDomList = new ArrayList<>();
// for (TransactionRatedDomain transactionRated : transactionList) {
// transactionUIDomList.add(new TransactionUI(transactionRated.getCurrencyPrev(),
// transactionRated.getCurrencyCurrent(), transactionRated.getAmounPerTransactionPrev().toString(),
// transactionRated.getAmountPerTransactionCurrent().toString()));
// }
// return transactionUIDomList;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/TransactionRatedDomain.java
// public class TransactionRatedDomain {
// private BigDecimal amounPerTransactionPrev;
// private BigDecimal amountPerTransactionCurrent;
// private String currencyPrev;
// private String currencyCurrent;
//
// public TransactionRatedDomain(String currencyPrev, String currencyCurrent,
// BigDecimal amounPerTransactionPrev,
// BigDecimal amountPerTransactionCurrent) {
// this.currencyPrev = currencyPrev;
// this.currencyCurrent = currencyCurrent;
// this.amounPerTransactionPrev = amounPerTransactionPrev;
// this.amountPerTransactionCurrent = amountPerTransactionCurrent;
// }
//
// public BigDecimal getAmounPerTransactionPrev() {
// return amounPerTransactionPrev;
// }
//
// public BigDecimal getAmountPerTransactionCurrent() {
// return amountPerTransactionCurrent;
// }
//
// public String getCurrencyPrev() {
// return currencyPrev;
// }
//
// public String getCurrencyCurrent() {
// return currencyCurrent;
// }
//
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/ComputingTransactionsPresenter.java
// public interface ComputingTransactionsPresenter {
//
// void setView(View view);
//
// void resetView();
//
// void computeRates(String skuFromProduct, String toCurrency, String pathTransactions, String pathRates)
// throws CustomException;
//
// interface View {
// void errorComputingRates(String error);
//
// void computedRatesForTransactions(List<TransactionUI> transactions, String totalAmount);
//
// void visibilityChangesAfterSuccessfulComputedRates();
//
// void visibilityChangesAfterErrorComputedRates();
//
// boolean isReady();
//
// void startLoader();
// }
// }
| import com.raulh82vlc.TransactionsViewer.domain.interactors.ComputeTransactionsInteractor;
import com.raulh82vlc.TransactionsViewer.domain.interactors.mappers.TransactionsRatedDataMapper;
import com.raulh82vlc.TransactionsViewer.domain.models.TransactionRatedDomain;
import com.raulh82vlc.TransactionsViewer.ui.presentation.ComputingTransactionsPresenter;
import java.util.List; | /*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.domain.interactors_response;
/**
* Get Transactions list by means of its callback, communicating towards its view
*
* @author Raul Hernandez Lopez.
*/
public class GetTransactionsComputedCallbackImpl implements
ComputeTransactionsInteractor.GetTransactionsComputedCallback {
private final ComputingTransactionsPresenter.View mView; | // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/ComputeTransactionsInteractor.java
// public interface ComputeTransactionsInteractor {
//
// void execute(String skuFromProduct,
// GetTransactionsComputedCallback getTransactionsComputedCallback,
// String toCurrency,
// String pathTransactions, String pathRates) throws CustomException;
//
//
// interface GetTransactionsComputedCallback {
// void onGetTransactionsListOK(List<TransactionRatedDomain> transactionList, String totalAmount);
//
// void onGetTransactionListKO(String error);
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/TransactionsRatedDataMapper.java
// @ActivityScope
// public class TransactionsRatedDataMapper {
//
// @Inject
// TransactionsRatedDataMapper() {
//
// }
//
// public List<TransactionUI> transformToUI(List<TransactionRatedDomain> transactionList) {
// if (transactionList == null) {
// throw new IllegalArgumentException("Cannot transform a null value");
// }
//
// List<TransactionUI> transactionUIDomList = new ArrayList<>();
// for (TransactionRatedDomain transactionRated : transactionList) {
// transactionUIDomList.add(new TransactionUI(transactionRated.getCurrencyPrev(),
// transactionRated.getCurrencyCurrent(), transactionRated.getAmounPerTransactionPrev().toString(),
// transactionRated.getAmountPerTransactionCurrent().toString()));
// }
// return transactionUIDomList;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/TransactionRatedDomain.java
// public class TransactionRatedDomain {
// private BigDecimal amounPerTransactionPrev;
// private BigDecimal amountPerTransactionCurrent;
// private String currencyPrev;
// private String currencyCurrent;
//
// public TransactionRatedDomain(String currencyPrev, String currencyCurrent,
// BigDecimal amounPerTransactionPrev,
// BigDecimal amountPerTransactionCurrent) {
// this.currencyPrev = currencyPrev;
// this.currencyCurrent = currencyCurrent;
// this.amounPerTransactionPrev = amounPerTransactionPrev;
// this.amountPerTransactionCurrent = amountPerTransactionCurrent;
// }
//
// public BigDecimal getAmounPerTransactionPrev() {
// return amounPerTransactionPrev;
// }
//
// public BigDecimal getAmountPerTransactionCurrent() {
// return amountPerTransactionCurrent;
// }
//
// public String getCurrencyPrev() {
// return currencyPrev;
// }
//
// public String getCurrencyCurrent() {
// return currencyCurrent;
// }
//
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/ComputingTransactionsPresenter.java
// public interface ComputingTransactionsPresenter {
//
// void setView(View view);
//
// void resetView();
//
// void computeRates(String skuFromProduct, String toCurrency, String pathTransactions, String pathRates)
// throws CustomException;
//
// interface View {
// void errorComputingRates(String error);
//
// void computedRatesForTransactions(List<TransactionUI> transactions, String totalAmount);
//
// void visibilityChangesAfterSuccessfulComputedRates();
//
// void visibilityChangesAfterErrorComputedRates();
//
// boolean isReady();
//
// void startLoader();
// }
// }
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors_response/GetTransactionsComputedCallbackImpl.java
import com.raulh82vlc.TransactionsViewer.domain.interactors.ComputeTransactionsInteractor;
import com.raulh82vlc.TransactionsViewer.domain.interactors.mappers.TransactionsRatedDataMapper;
import com.raulh82vlc.TransactionsViewer.domain.models.TransactionRatedDomain;
import com.raulh82vlc.TransactionsViewer.ui.presentation.ComputingTransactionsPresenter;
import java.util.List;
/*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.domain.interactors_response;
/**
* Get Transactions list by means of its callback, communicating towards its view
*
* @author Raul Hernandez Lopez.
*/
public class GetTransactionsComputedCallbackImpl implements
ComputeTransactionsInteractor.GetTransactionsComputedCallback {
private final ComputingTransactionsPresenter.View mView; | private final TransactionsRatedDataMapper transactionsRatedDataMapper; |
raulh82vlc/Transactions-Viewer | android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors_response/GetTransactionsComputedCallbackImpl.java | // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/ComputeTransactionsInteractor.java
// public interface ComputeTransactionsInteractor {
//
// void execute(String skuFromProduct,
// GetTransactionsComputedCallback getTransactionsComputedCallback,
// String toCurrency,
// String pathTransactions, String pathRates) throws CustomException;
//
//
// interface GetTransactionsComputedCallback {
// void onGetTransactionsListOK(List<TransactionRatedDomain> transactionList, String totalAmount);
//
// void onGetTransactionListKO(String error);
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/TransactionsRatedDataMapper.java
// @ActivityScope
// public class TransactionsRatedDataMapper {
//
// @Inject
// TransactionsRatedDataMapper() {
//
// }
//
// public List<TransactionUI> transformToUI(List<TransactionRatedDomain> transactionList) {
// if (transactionList == null) {
// throw new IllegalArgumentException("Cannot transform a null value");
// }
//
// List<TransactionUI> transactionUIDomList = new ArrayList<>();
// for (TransactionRatedDomain transactionRated : transactionList) {
// transactionUIDomList.add(new TransactionUI(transactionRated.getCurrencyPrev(),
// transactionRated.getCurrencyCurrent(), transactionRated.getAmounPerTransactionPrev().toString(),
// transactionRated.getAmountPerTransactionCurrent().toString()));
// }
// return transactionUIDomList;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/TransactionRatedDomain.java
// public class TransactionRatedDomain {
// private BigDecimal amounPerTransactionPrev;
// private BigDecimal amountPerTransactionCurrent;
// private String currencyPrev;
// private String currencyCurrent;
//
// public TransactionRatedDomain(String currencyPrev, String currencyCurrent,
// BigDecimal amounPerTransactionPrev,
// BigDecimal amountPerTransactionCurrent) {
// this.currencyPrev = currencyPrev;
// this.currencyCurrent = currencyCurrent;
// this.amounPerTransactionPrev = amounPerTransactionPrev;
// this.amountPerTransactionCurrent = amountPerTransactionCurrent;
// }
//
// public BigDecimal getAmounPerTransactionPrev() {
// return amounPerTransactionPrev;
// }
//
// public BigDecimal getAmountPerTransactionCurrent() {
// return amountPerTransactionCurrent;
// }
//
// public String getCurrencyPrev() {
// return currencyPrev;
// }
//
// public String getCurrencyCurrent() {
// return currencyCurrent;
// }
//
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/ComputingTransactionsPresenter.java
// public interface ComputingTransactionsPresenter {
//
// void setView(View view);
//
// void resetView();
//
// void computeRates(String skuFromProduct, String toCurrency, String pathTransactions, String pathRates)
// throws CustomException;
//
// interface View {
// void errorComputingRates(String error);
//
// void computedRatesForTransactions(List<TransactionUI> transactions, String totalAmount);
//
// void visibilityChangesAfterSuccessfulComputedRates();
//
// void visibilityChangesAfterErrorComputedRates();
//
// boolean isReady();
//
// void startLoader();
// }
// }
| import com.raulh82vlc.TransactionsViewer.domain.interactors.ComputeTransactionsInteractor;
import com.raulh82vlc.TransactionsViewer.domain.interactors.mappers.TransactionsRatedDataMapper;
import com.raulh82vlc.TransactionsViewer.domain.models.TransactionRatedDomain;
import com.raulh82vlc.TransactionsViewer.ui.presentation.ComputingTransactionsPresenter;
import java.util.List; | /*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.domain.interactors_response;
/**
* Get Transactions list by means of its callback, communicating towards its view
*
* @author Raul Hernandez Lopez.
*/
public class GetTransactionsComputedCallbackImpl implements
ComputeTransactionsInteractor.GetTransactionsComputedCallback {
private final ComputingTransactionsPresenter.View mView;
private final TransactionsRatedDataMapper transactionsRatedDataMapper;
public GetTransactionsComputedCallbackImpl(ComputingTransactionsPresenter.View view,
TransactionsRatedDataMapper transactionsRatedDataMapper) {
mView = view;
this.transactionsRatedDataMapper = transactionsRatedDataMapper;
}
@Override | // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/ComputeTransactionsInteractor.java
// public interface ComputeTransactionsInteractor {
//
// void execute(String skuFromProduct,
// GetTransactionsComputedCallback getTransactionsComputedCallback,
// String toCurrency,
// String pathTransactions, String pathRates) throws CustomException;
//
//
// interface GetTransactionsComputedCallback {
// void onGetTransactionsListOK(List<TransactionRatedDomain> transactionList, String totalAmount);
//
// void onGetTransactionListKO(String error);
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/TransactionsRatedDataMapper.java
// @ActivityScope
// public class TransactionsRatedDataMapper {
//
// @Inject
// TransactionsRatedDataMapper() {
//
// }
//
// public List<TransactionUI> transformToUI(List<TransactionRatedDomain> transactionList) {
// if (transactionList == null) {
// throw new IllegalArgumentException("Cannot transform a null value");
// }
//
// List<TransactionUI> transactionUIDomList = new ArrayList<>();
// for (TransactionRatedDomain transactionRated : transactionList) {
// transactionUIDomList.add(new TransactionUI(transactionRated.getCurrencyPrev(),
// transactionRated.getCurrencyCurrent(), transactionRated.getAmounPerTransactionPrev().toString(),
// transactionRated.getAmountPerTransactionCurrent().toString()));
// }
// return transactionUIDomList;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/TransactionRatedDomain.java
// public class TransactionRatedDomain {
// private BigDecimal amounPerTransactionPrev;
// private BigDecimal amountPerTransactionCurrent;
// private String currencyPrev;
// private String currencyCurrent;
//
// public TransactionRatedDomain(String currencyPrev, String currencyCurrent,
// BigDecimal amounPerTransactionPrev,
// BigDecimal amountPerTransactionCurrent) {
// this.currencyPrev = currencyPrev;
// this.currencyCurrent = currencyCurrent;
// this.amounPerTransactionPrev = amounPerTransactionPrev;
// this.amountPerTransactionCurrent = amountPerTransactionCurrent;
// }
//
// public BigDecimal getAmounPerTransactionPrev() {
// return amounPerTransactionPrev;
// }
//
// public BigDecimal getAmountPerTransactionCurrent() {
// return amountPerTransactionCurrent;
// }
//
// public String getCurrencyPrev() {
// return currencyPrev;
// }
//
// public String getCurrencyCurrent() {
// return currencyCurrent;
// }
//
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/ComputingTransactionsPresenter.java
// public interface ComputingTransactionsPresenter {
//
// void setView(View view);
//
// void resetView();
//
// void computeRates(String skuFromProduct, String toCurrency, String pathTransactions, String pathRates)
// throws CustomException;
//
// interface View {
// void errorComputingRates(String error);
//
// void computedRatesForTransactions(List<TransactionUI> transactions, String totalAmount);
//
// void visibilityChangesAfterSuccessfulComputedRates();
//
// void visibilityChangesAfterErrorComputedRates();
//
// boolean isReady();
//
// void startLoader();
// }
// }
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors_response/GetTransactionsComputedCallbackImpl.java
import com.raulh82vlc.TransactionsViewer.domain.interactors.ComputeTransactionsInteractor;
import com.raulh82vlc.TransactionsViewer.domain.interactors.mappers.TransactionsRatedDataMapper;
import com.raulh82vlc.TransactionsViewer.domain.models.TransactionRatedDomain;
import com.raulh82vlc.TransactionsViewer.ui.presentation.ComputingTransactionsPresenter;
import java.util.List;
/*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.domain.interactors_response;
/**
* Get Transactions list by means of its callback, communicating towards its view
*
* @author Raul Hernandez Lopez.
*/
public class GetTransactionsComputedCallbackImpl implements
ComputeTransactionsInteractor.GetTransactionsComputedCallback {
private final ComputingTransactionsPresenter.View mView;
private final TransactionsRatedDataMapper transactionsRatedDataMapper;
public GetTransactionsComputedCallbackImpl(ComputingTransactionsPresenter.View view,
TransactionsRatedDataMapper transactionsRatedDataMapper) {
mView = view;
this.transactionsRatedDataMapper = transactionsRatedDataMapper;
}
@Override | public void onGetTransactionsListOK(List<TransactionRatedDomain> transactionList, String totalAmount) { |
raulh82vlc/Transactions-Viewer | android/src/main/java/com/raulh82vlc/TransactionsViewer/TransactionsViewerApp.java | // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/modules/ApplicationModule.java
// @Module
// public class ApplicationModule {
// private final Application application;
//
// public ApplicationModule(Application application) {
// this.application = application;
// }
//
// @Provides
// @Singleton
// Application provideApplication() {
// return application;
// }
//
// @Provides
// @Singleton
// InteractorExecutor provideThreadsPoolExecutor(ThreadsPoolExecutor executor) {
// return executor;
// }
//
// @Provides
// @Singleton
// MainThread providePostExecutionThread(MainThreadImpl mainThread) {
// return mainThread;
// }
//
// @Provides
// @Singleton
// Context provideApplicationContext() {
// return application.getApplicationContext();
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/components/ApplicationComponent.java
// @Singleton
// @Component(
// modules = {
// ApplicationModule.class,
// RepositoryModule.class
// })
// public interface ApplicationComponent {
//
// /**
// * Injections for the dependencies
// */
// void inject(TransactionsViewerApp app);
//
// void inject(Context context);
//
// /**
// * Used in child components
// */
// Application application();
//
// /**
// * Background processes executor (interactors use this)
// */
// InteractorExecutor threadExecutor();
//
// /**
// * Direct contact to UI thread
// */
// MainThread mainThread();
//
// /**
// * Direct contact to repo
// */
// DataRepository dataRepo();
// }
| import android.app.Application;
import com.raulh82vlc.TransactionsViewer.di.modules.ApplicationModule;
import com.raulh82vlc.TransactionsViewer.di.components.ApplicationComponent;
import com.raulh82vlc.TransactionsViewer.di.components.DaggerApplicationComponent; | /*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer;
/**
* {@link ApplicationComponent} could be used to provide dependencies needed by the whole app
* execution. Application context linked dependencies would be exposed by it too.
*
* @author Raul Hernandez Lopez
*/
public class TransactionsViewerApp extends Application {
private ApplicationComponent applicationComponent;
@Override
public void onCreate() {
super.onCreate();
applicationComponent = DaggerApplicationComponent.builder() | // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/modules/ApplicationModule.java
// @Module
// public class ApplicationModule {
// private final Application application;
//
// public ApplicationModule(Application application) {
// this.application = application;
// }
//
// @Provides
// @Singleton
// Application provideApplication() {
// return application;
// }
//
// @Provides
// @Singleton
// InteractorExecutor provideThreadsPoolExecutor(ThreadsPoolExecutor executor) {
// return executor;
// }
//
// @Provides
// @Singleton
// MainThread providePostExecutionThread(MainThreadImpl mainThread) {
// return mainThread;
// }
//
// @Provides
// @Singleton
// Context provideApplicationContext() {
// return application.getApplicationContext();
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/components/ApplicationComponent.java
// @Singleton
// @Component(
// modules = {
// ApplicationModule.class,
// RepositoryModule.class
// })
// public interface ApplicationComponent {
//
// /**
// * Injections for the dependencies
// */
// void inject(TransactionsViewerApp app);
//
// void inject(Context context);
//
// /**
// * Used in child components
// */
// Application application();
//
// /**
// * Background processes executor (interactors use this)
// */
// InteractorExecutor threadExecutor();
//
// /**
// * Direct contact to UI thread
// */
// MainThread mainThread();
//
// /**
// * Direct contact to repo
// */
// DataRepository dataRepo();
// }
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/TransactionsViewerApp.java
import android.app.Application;
import com.raulh82vlc.TransactionsViewer.di.modules.ApplicationModule;
import com.raulh82vlc.TransactionsViewer.di.components.ApplicationComponent;
import com.raulh82vlc.TransactionsViewer.di.components.DaggerApplicationComponent;
/*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer;
/**
* {@link ApplicationComponent} could be used to provide dependencies needed by the whole app
* execution. Application context linked dependencies would be exposed by it too.
*
* @author Raul Hernandez Lopez
*/
public class TransactionsViewerApp extends Application {
private ApplicationComponent applicationComponent;
@Override
public void onCreate() {
super.onCreate();
applicationComponent = DaggerApplicationComponent.builder() | .applicationModule(new ApplicationModule(this)) |
raulh82vlc/Transactions-Viewer | android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/datasources/json/JSONDataSourceImpl.java | // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java
// public class CustomException extends Exception {
// public CustomException(String detailMessage) {
// super(detailMessage);
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java
// public class Rate {
// @SerializedName("from")
// private String fromCurrency;
// @SerializedName("rate")
// private String rate;
// @SerializedName("to")
// private String toCurrency;
//
// public String getFromCurrency() {
// return fromCurrency;
// }
//
// public String getRate() {
// return rate;
// }
//
// public String getToCurrency() {
// return toCurrency;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java
// public class Transaction {
//
// @SerializedName("sku")
// private String skuIdentifier;
//
// @SerializedName("amount")
// private String amountPerTransaction;
//
// @SerializedName("currency")
// private String currency;
//
// public String getSkuIdentifier() {
// return skuIdentifier;
// }
//
// public String getAmountPerTransaction() {
// return amountPerTransaction;
// }
//
// public String getCurrency() {
// return currency;
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/datasources/JSONDataSource.java
// public interface JSONDataSource<R, T> {
//
// /**
// * Gets a Rates List from a JSON file
// *
// * @param path path of the file
// */
// List<R> getRatesList(String path) throws CustomException;
//
// /**
// * Gets a Transactions List from a JSON file
// *
// * @param path path of the file
// */
// List<T> getTransactionsList(String path) throws CustomException;
// }
| import android.content.Context;
import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException;
import com.raulh82vlc.TransactionsViewer.domain.models.Rate;
import com.raulh82vlc.TransactionsViewer.domain.models.Transaction;
import com.raulh82vlc.TransactionsViewer.domain.repository.datasources.JSONDataSource;
import java.util.List;
import javax.inject.Inject; | /*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.domain.datasources.json;
/**
* {@link JSONDataSource} Implementation
*
* @author Raul Hernandez Lopez
*/
public class JSONDataSourceImpl implements JSONDataSource<Rate, Transaction> {
/**
* Vars declaration
*/
private Context mContext;
private JSONOperations<Rate, Transaction> mJSONOperations;
@Inject
JSONDataSourceImpl(Context context,
JSONOperationsImpl jsonOperations) {
mContext = context;
if (mJSONOperations == null) {
synchronized (this) {
if (mJSONOperations == null) {
mJSONOperations = jsonOperations;
}
}
}
}
@Override | // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java
// public class CustomException extends Exception {
// public CustomException(String detailMessage) {
// super(detailMessage);
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java
// public class Rate {
// @SerializedName("from")
// private String fromCurrency;
// @SerializedName("rate")
// private String rate;
// @SerializedName("to")
// private String toCurrency;
//
// public String getFromCurrency() {
// return fromCurrency;
// }
//
// public String getRate() {
// return rate;
// }
//
// public String getToCurrency() {
// return toCurrency;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java
// public class Transaction {
//
// @SerializedName("sku")
// private String skuIdentifier;
//
// @SerializedName("amount")
// private String amountPerTransaction;
//
// @SerializedName("currency")
// private String currency;
//
// public String getSkuIdentifier() {
// return skuIdentifier;
// }
//
// public String getAmountPerTransaction() {
// return amountPerTransaction;
// }
//
// public String getCurrency() {
// return currency;
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/datasources/JSONDataSource.java
// public interface JSONDataSource<R, T> {
//
// /**
// * Gets a Rates List from a JSON file
// *
// * @param path path of the file
// */
// List<R> getRatesList(String path) throws CustomException;
//
// /**
// * Gets a Transactions List from a JSON file
// *
// * @param path path of the file
// */
// List<T> getTransactionsList(String path) throws CustomException;
// }
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/datasources/json/JSONDataSourceImpl.java
import android.content.Context;
import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException;
import com.raulh82vlc.TransactionsViewer.domain.models.Rate;
import com.raulh82vlc.TransactionsViewer.domain.models.Transaction;
import com.raulh82vlc.TransactionsViewer.domain.repository.datasources.JSONDataSource;
import java.util.List;
import javax.inject.Inject;
/*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.domain.datasources.json;
/**
* {@link JSONDataSource} Implementation
*
* @author Raul Hernandez Lopez
*/
public class JSONDataSourceImpl implements JSONDataSource<Rate, Transaction> {
/**
* Vars declaration
*/
private Context mContext;
private JSONOperations<Rate, Transaction> mJSONOperations;
@Inject
JSONDataSourceImpl(Context context,
JSONOperationsImpl jsonOperations) {
mContext = context;
if (mJSONOperations == null) {
synchronized (this) {
if (mJSONOperations == null) {
mJSONOperations = jsonOperations;
}
}
}
}
@Override | public List<Rate> getRatesList(String path) throws CustomException { |
raulh82vlc/Transactions-Viewer | android/src/main/java/com/raulh82vlc/TransactionsViewer/di/modules/ApplicationModule.java | // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/MainThreadImpl.java
// public class MainThreadImpl implements MainThread {
//
// private Handler handler;
//
// @Inject
// MainThreadImpl() {
// this.handler = new Handler(Looper.getMainLooper());
// }
//
// @Override
// public void post(Runnable runnable) {
// handler.post(runnable);
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java
// public interface InteractorExecutor {
// void run(Interactor interactor) throws CustomException;
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java
// public interface MainThread {
// void post(final Runnable runnable);
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/ThreadsPoolExecutor.java
// public class ThreadsPoolExecutor implements InteractorExecutor {
// /**
// * Constants
// */
// private static final int MAX_SIZE = 6;
// private static final int CORE_DEFAULT_SIZE = 3;
// private static final int TIME_OUT_TIME = 300;
// private static final TimeUnit TIME_UNITS = TimeUnit.SECONDS;
// /**
// * Local variables
// */
// private ThreadPoolExecutor threadsPoolExecutor;
//
//
// @Inject
// ThreadsPoolExecutor() {
// BlockingQueue<Runnable> mWorkersQueue = new LinkedBlockingQueue<>();
// threadsPoolExecutor = new ThreadPoolExecutor(CORE_DEFAULT_SIZE, MAX_SIZE,
// TIME_OUT_TIME, TIME_UNITS, mWorkersQueue);
// }
//
// @Override
// public void run(final Interactor interactor) throws CustomException {
// if (interactor == null) {
// throw new IllegalArgumentException("Interactor must be instantiated");
// }
// threadsPoolExecutor.submit(new Runnable() {
// @Override
// public void run() {
// try {
// interactor.run();
// } catch (CustomException e) {
// e.printStackTrace();
// }
// }
// });
// }
// }
| import android.app.Application;
import android.content.Context;
import com.raulh82vlc.TransactionsViewer.domain.MainThreadImpl;
import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor;
import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread;
import com.raulh82vlc.TransactionsViewer.domain.executors.ThreadsPoolExecutor;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides; | /*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.di.modules;
/**
* Module which provides application context or generic dependencies.
*
* @author Raul Hernandez Lopez
*/
@Module
public class ApplicationModule {
private final Application application;
public ApplicationModule(Application application) {
this.application = application;
}
@Provides
@Singleton
Application provideApplication() {
return application;
}
@Provides
@Singleton | // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/MainThreadImpl.java
// public class MainThreadImpl implements MainThread {
//
// private Handler handler;
//
// @Inject
// MainThreadImpl() {
// this.handler = new Handler(Looper.getMainLooper());
// }
//
// @Override
// public void post(Runnable runnable) {
// handler.post(runnable);
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java
// public interface InteractorExecutor {
// void run(Interactor interactor) throws CustomException;
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java
// public interface MainThread {
// void post(final Runnable runnable);
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/ThreadsPoolExecutor.java
// public class ThreadsPoolExecutor implements InteractorExecutor {
// /**
// * Constants
// */
// private static final int MAX_SIZE = 6;
// private static final int CORE_DEFAULT_SIZE = 3;
// private static final int TIME_OUT_TIME = 300;
// private static final TimeUnit TIME_UNITS = TimeUnit.SECONDS;
// /**
// * Local variables
// */
// private ThreadPoolExecutor threadsPoolExecutor;
//
//
// @Inject
// ThreadsPoolExecutor() {
// BlockingQueue<Runnable> mWorkersQueue = new LinkedBlockingQueue<>();
// threadsPoolExecutor = new ThreadPoolExecutor(CORE_DEFAULT_SIZE, MAX_SIZE,
// TIME_OUT_TIME, TIME_UNITS, mWorkersQueue);
// }
//
// @Override
// public void run(final Interactor interactor) throws CustomException {
// if (interactor == null) {
// throw new IllegalArgumentException("Interactor must be instantiated");
// }
// threadsPoolExecutor.submit(new Runnable() {
// @Override
// public void run() {
// try {
// interactor.run();
// } catch (CustomException e) {
// e.printStackTrace();
// }
// }
// });
// }
// }
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/modules/ApplicationModule.java
import android.app.Application;
import android.content.Context;
import com.raulh82vlc.TransactionsViewer.domain.MainThreadImpl;
import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor;
import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread;
import com.raulh82vlc.TransactionsViewer.domain.executors.ThreadsPoolExecutor;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
/*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.di.modules;
/**
* Module which provides application context or generic dependencies.
*
* @author Raul Hernandez Lopez
*/
@Module
public class ApplicationModule {
private final Application application;
public ApplicationModule(Application application) {
this.application = application;
}
@Provides
@Singleton
Application provideApplication() {
return application;
}
@Provides
@Singleton | InteractorExecutor provideThreadsPoolExecutor(ThreadsPoolExecutor executor) { |
raulh82vlc/Transactions-Viewer | android/src/main/java/com/raulh82vlc/TransactionsViewer/di/modules/ApplicationModule.java | // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/MainThreadImpl.java
// public class MainThreadImpl implements MainThread {
//
// private Handler handler;
//
// @Inject
// MainThreadImpl() {
// this.handler = new Handler(Looper.getMainLooper());
// }
//
// @Override
// public void post(Runnable runnable) {
// handler.post(runnable);
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java
// public interface InteractorExecutor {
// void run(Interactor interactor) throws CustomException;
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java
// public interface MainThread {
// void post(final Runnable runnable);
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/ThreadsPoolExecutor.java
// public class ThreadsPoolExecutor implements InteractorExecutor {
// /**
// * Constants
// */
// private static final int MAX_SIZE = 6;
// private static final int CORE_DEFAULT_SIZE = 3;
// private static final int TIME_OUT_TIME = 300;
// private static final TimeUnit TIME_UNITS = TimeUnit.SECONDS;
// /**
// * Local variables
// */
// private ThreadPoolExecutor threadsPoolExecutor;
//
//
// @Inject
// ThreadsPoolExecutor() {
// BlockingQueue<Runnable> mWorkersQueue = new LinkedBlockingQueue<>();
// threadsPoolExecutor = new ThreadPoolExecutor(CORE_DEFAULT_SIZE, MAX_SIZE,
// TIME_OUT_TIME, TIME_UNITS, mWorkersQueue);
// }
//
// @Override
// public void run(final Interactor interactor) throws CustomException {
// if (interactor == null) {
// throw new IllegalArgumentException("Interactor must be instantiated");
// }
// threadsPoolExecutor.submit(new Runnable() {
// @Override
// public void run() {
// try {
// interactor.run();
// } catch (CustomException e) {
// e.printStackTrace();
// }
// }
// });
// }
// }
| import android.app.Application;
import android.content.Context;
import com.raulh82vlc.TransactionsViewer.domain.MainThreadImpl;
import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor;
import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread;
import com.raulh82vlc.TransactionsViewer.domain.executors.ThreadsPoolExecutor;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides; | /*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.di.modules;
/**
* Module which provides application context or generic dependencies.
*
* @author Raul Hernandez Lopez
*/
@Module
public class ApplicationModule {
private final Application application;
public ApplicationModule(Application application) {
this.application = application;
}
@Provides
@Singleton
Application provideApplication() {
return application;
}
@Provides
@Singleton | // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/MainThreadImpl.java
// public class MainThreadImpl implements MainThread {
//
// private Handler handler;
//
// @Inject
// MainThreadImpl() {
// this.handler = new Handler(Looper.getMainLooper());
// }
//
// @Override
// public void post(Runnable runnable) {
// handler.post(runnable);
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java
// public interface InteractorExecutor {
// void run(Interactor interactor) throws CustomException;
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java
// public interface MainThread {
// void post(final Runnable runnable);
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/ThreadsPoolExecutor.java
// public class ThreadsPoolExecutor implements InteractorExecutor {
// /**
// * Constants
// */
// private static final int MAX_SIZE = 6;
// private static final int CORE_DEFAULT_SIZE = 3;
// private static final int TIME_OUT_TIME = 300;
// private static final TimeUnit TIME_UNITS = TimeUnit.SECONDS;
// /**
// * Local variables
// */
// private ThreadPoolExecutor threadsPoolExecutor;
//
//
// @Inject
// ThreadsPoolExecutor() {
// BlockingQueue<Runnable> mWorkersQueue = new LinkedBlockingQueue<>();
// threadsPoolExecutor = new ThreadPoolExecutor(CORE_DEFAULT_SIZE, MAX_SIZE,
// TIME_OUT_TIME, TIME_UNITS, mWorkersQueue);
// }
//
// @Override
// public void run(final Interactor interactor) throws CustomException {
// if (interactor == null) {
// throw new IllegalArgumentException("Interactor must be instantiated");
// }
// threadsPoolExecutor.submit(new Runnable() {
// @Override
// public void run() {
// try {
// interactor.run();
// } catch (CustomException e) {
// e.printStackTrace();
// }
// }
// });
// }
// }
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/modules/ApplicationModule.java
import android.app.Application;
import android.content.Context;
import com.raulh82vlc.TransactionsViewer.domain.MainThreadImpl;
import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor;
import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread;
import com.raulh82vlc.TransactionsViewer.domain.executors.ThreadsPoolExecutor;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
/*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.di.modules;
/**
* Module which provides application context or generic dependencies.
*
* @author Raul Hernandez Lopez
*/
@Module
public class ApplicationModule {
private final Application application;
public ApplicationModule(Application application) {
this.application = application;
}
@Provides
@Singleton
Application provideApplication() {
return application;
}
@Provides
@Singleton | InteractorExecutor provideThreadsPoolExecutor(ThreadsPoolExecutor executor) { |
raulh82vlc/Transactions-Viewer | android/src/main/java/com/raulh82vlc/TransactionsViewer/di/modules/ApplicationModule.java | // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/MainThreadImpl.java
// public class MainThreadImpl implements MainThread {
//
// private Handler handler;
//
// @Inject
// MainThreadImpl() {
// this.handler = new Handler(Looper.getMainLooper());
// }
//
// @Override
// public void post(Runnable runnable) {
// handler.post(runnable);
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java
// public interface InteractorExecutor {
// void run(Interactor interactor) throws CustomException;
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java
// public interface MainThread {
// void post(final Runnable runnable);
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/ThreadsPoolExecutor.java
// public class ThreadsPoolExecutor implements InteractorExecutor {
// /**
// * Constants
// */
// private static final int MAX_SIZE = 6;
// private static final int CORE_DEFAULT_SIZE = 3;
// private static final int TIME_OUT_TIME = 300;
// private static final TimeUnit TIME_UNITS = TimeUnit.SECONDS;
// /**
// * Local variables
// */
// private ThreadPoolExecutor threadsPoolExecutor;
//
//
// @Inject
// ThreadsPoolExecutor() {
// BlockingQueue<Runnable> mWorkersQueue = new LinkedBlockingQueue<>();
// threadsPoolExecutor = new ThreadPoolExecutor(CORE_DEFAULT_SIZE, MAX_SIZE,
// TIME_OUT_TIME, TIME_UNITS, mWorkersQueue);
// }
//
// @Override
// public void run(final Interactor interactor) throws CustomException {
// if (interactor == null) {
// throw new IllegalArgumentException("Interactor must be instantiated");
// }
// threadsPoolExecutor.submit(new Runnable() {
// @Override
// public void run() {
// try {
// interactor.run();
// } catch (CustomException e) {
// e.printStackTrace();
// }
// }
// });
// }
// }
| import android.app.Application;
import android.content.Context;
import com.raulh82vlc.TransactionsViewer.domain.MainThreadImpl;
import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor;
import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread;
import com.raulh82vlc.TransactionsViewer.domain.executors.ThreadsPoolExecutor;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides; | /*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.di.modules;
/**
* Module which provides application context or generic dependencies.
*
* @author Raul Hernandez Lopez
*/
@Module
public class ApplicationModule {
private final Application application;
public ApplicationModule(Application application) {
this.application = application;
}
@Provides
@Singleton
Application provideApplication() {
return application;
}
@Provides
@Singleton
InteractorExecutor provideThreadsPoolExecutor(ThreadsPoolExecutor executor) {
return executor;
}
@Provides
@Singleton | // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/MainThreadImpl.java
// public class MainThreadImpl implements MainThread {
//
// private Handler handler;
//
// @Inject
// MainThreadImpl() {
// this.handler = new Handler(Looper.getMainLooper());
// }
//
// @Override
// public void post(Runnable runnable) {
// handler.post(runnable);
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java
// public interface InteractorExecutor {
// void run(Interactor interactor) throws CustomException;
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java
// public interface MainThread {
// void post(final Runnable runnable);
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/ThreadsPoolExecutor.java
// public class ThreadsPoolExecutor implements InteractorExecutor {
// /**
// * Constants
// */
// private static final int MAX_SIZE = 6;
// private static final int CORE_DEFAULT_SIZE = 3;
// private static final int TIME_OUT_TIME = 300;
// private static final TimeUnit TIME_UNITS = TimeUnit.SECONDS;
// /**
// * Local variables
// */
// private ThreadPoolExecutor threadsPoolExecutor;
//
//
// @Inject
// ThreadsPoolExecutor() {
// BlockingQueue<Runnable> mWorkersQueue = new LinkedBlockingQueue<>();
// threadsPoolExecutor = new ThreadPoolExecutor(CORE_DEFAULT_SIZE, MAX_SIZE,
// TIME_OUT_TIME, TIME_UNITS, mWorkersQueue);
// }
//
// @Override
// public void run(final Interactor interactor) throws CustomException {
// if (interactor == null) {
// throw new IllegalArgumentException("Interactor must be instantiated");
// }
// threadsPoolExecutor.submit(new Runnable() {
// @Override
// public void run() {
// try {
// interactor.run();
// } catch (CustomException e) {
// e.printStackTrace();
// }
// }
// });
// }
// }
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/modules/ApplicationModule.java
import android.app.Application;
import android.content.Context;
import com.raulh82vlc.TransactionsViewer.domain.MainThreadImpl;
import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor;
import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread;
import com.raulh82vlc.TransactionsViewer.domain.executors.ThreadsPoolExecutor;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
/*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.di.modules;
/**
* Module which provides application context or generic dependencies.
*
* @author Raul Hernandez Lopez
*/
@Module
public class ApplicationModule {
private final Application application;
public ApplicationModule(Application application) {
this.application = application;
}
@Provides
@Singleton
Application provideApplication() {
return application;
}
@Provides
@Singleton
InteractorExecutor provideThreadsPoolExecutor(ThreadsPoolExecutor executor) {
return executor;
}
@Provides
@Singleton | MainThread providePostExecutionThread(MainThreadImpl mainThread) { |
raulh82vlc/Transactions-Viewer | android/src/main/java/com/raulh82vlc/TransactionsViewer/di/modules/ApplicationModule.java | // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/MainThreadImpl.java
// public class MainThreadImpl implements MainThread {
//
// private Handler handler;
//
// @Inject
// MainThreadImpl() {
// this.handler = new Handler(Looper.getMainLooper());
// }
//
// @Override
// public void post(Runnable runnable) {
// handler.post(runnable);
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java
// public interface InteractorExecutor {
// void run(Interactor interactor) throws CustomException;
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java
// public interface MainThread {
// void post(final Runnable runnable);
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/ThreadsPoolExecutor.java
// public class ThreadsPoolExecutor implements InteractorExecutor {
// /**
// * Constants
// */
// private static final int MAX_SIZE = 6;
// private static final int CORE_DEFAULT_SIZE = 3;
// private static final int TIME_OUT_TIME = 300;
// private static final TimeUnit TIME_UNITS = TimeUnit.SECONDS;
// /**
// * Local variables
// */
// private ThreadPoolExecutor threadsPoolExecutor;
//
//
// @Inject
// ThreadsPoolExecutor() {
// BlockingQueue<Runnable> mWorkersQueue = new LinkedBlockingQueue<>();
// threadsPoolExecutor = new ThreadPoolExecutor(CORE_DEFAULT_SIZE, MAX_SIZE,
// TIME_OUT_TIME, TIME_UNITS, mWorkersQueue);
// }
//
// @Override
// public void run(final Interactor interactor) throws CustomException {
// if (interactor == null) {
// throw new IllegalArgumentException("Interactor must be instantiated");
// }
// threadsPoolExecutor.submit(new Runnable() {
// @Override
// public void run() {
// try {
// interactor.run();
// } catch (CustomException e) {
// e.printStackTrace();
// }
// }
// });
// }
// }
| import android.app.Application;
import android.content.Context;
import com.raulh82vlc.TransactionsViewer.domain.MainThreadImpl;
import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor;
import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread;
import com.raulh82vlc.TransactionsViewer.domain.executors.ThreadsPoolExecutor;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides; | /*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.di.modules;
/**
* Module which provides application context or generic dependencies.
*
* @author Raul Hernandez Lopez
*/
@Module
public class ApplicationModule {
private final Application application;
public ApplicationModule(Application application) {
this.application = application;
}
@Provides
@Singleton
Application provideApplication() {
return application;
}
@Provides
@Singleton
InteractorExecutor provideThreadsPoolExecutor(ThreadsPoolExecutor executor) {
return executor;
}
@Provides
@Singleton | // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/MainThreadImpl.java
// public class MainThreadImpl implements MainThread {
//
// private Handler handler;
//
// @Inject
// MainThreadImpl() {
// this.handler = new Handler(Looper.getMainLooper());
// }
//
// @Override
// public void post(Runnable runnable) {
// handler.post(runnable);
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java
// public interface InteractorExecutor {
// void run(Interactor interactor) throws CustomException;
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java
// public interface MainThread {
// void post(final Runnable runnable);
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/ThreadsPoolExecutor.java
// public class ThreadsPoolExecutor implements InteractorExecutor {
// /**
// * Constants
// */
// private static final int MAX_SIZE = 6;
// private static final int CORE_DEFAULT_SIZE = 3;
// private static final int TIME_OUT_TIME = 300;
// private static final TimeUnit TIME_UNITS = TimeUnit.SECONDS;
// /**
// * Local variables
// */
// private ThreadPoolExecutor threadsPoolExecutor;
//
//
// @Inject
// ThreadsPoolExecutor() {
// BlockingQueue<Runnable> mWorkersQueue = new LinkedBlockingQueue<>();
// threadsPoolExecutor = new ThreadPoolExecutor(CORE_DEFAULT_SIZE, MAX_SIZE,
// TIME_OUT_TIME, TIME_UNITS, mWorkersQueue);
// }
//
// @Override
// public void run(final Interactor interactor) throws CustomException {
// if (interactor == null) {
// throw new IllegalArgumentException("Interactor must be instantiated");
// }
// threadsPoolExecutor.submit(new Runnable() {
// @Override
// public void run() {
// try {
// interactor.run();
// } catch (CustomException e) {
// e.printStackTrace();
// }
// }
// });
// }
// }
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/modules/ApplicationModule.java
import android.app.Application;
import android.content.Context;
import com.raulh82vlc.TransactionsViewer.domain.MainThreadImpl;
import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor;
import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread;
import com.raulh82vlc.TransactionsViewer.domain.executors.ThreadsPoolExecutor;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
/*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.di.modules;
/**
* Module which provides application context or generic dependencies.
*
* @author Raul Hernandez Lopez
*/
@Module
public class ApplicationModule {
private final Application application;
public ApplicationModule(Application application) {
this.application = application;
}
@Provides
@Singleton
Application provideApplication() {
return application;
}
@Provides
@Singleton
InteractorExecutor provideThreadsPoolExecutor(ThreadsPoolExecutor executor) {
return executor;
}
@Provides
@Singleton | MainThread providePostExecutionThread(MainThreadImpl mainThread) { |
raulh82vlc/Transactions-Viewer | android/src/test/java/com/raulh82vlc/TransactionsViewer/domain/interactors_response/GetTransactionsComputedCallbackImplTest.java | // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/ComputeTransactionsInteractor.java
// public interface ComputeTransactionsInteractor {
//
// void execute(String skuFromProduct,
// GetTransactionsComputedCallback getTransactionsComputedCallback,
// String toCurrency,
// String pathTransactions, String pathRates) throws CustomException;
//
//
// interface GetTransactionsComputedCallback {
// void onGetTransactionsListOK(List<TransactionRatedDomain> transactionList, String totalAmount);
//
// void onGetTransactionListKO(String error);
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/TransactionsRatedDataMapper.java
// @ActivityScope
// public class TransactionsRatedDataMapper {
//
// @Inject
// TransactionsRatedDataMapper() {
//
// }
//
// public List<TransactionUI> transformToUI(List<TransactionRatedDomain> transactionList) {
// if (transactionList == null) {
// throw new IllegalArgumentException("Cannot transform a null value");
// }
//
// List<TransactionUI> transactionUIDomList = new ArrayList<>();
// for (TransactionRatedDomain transactionRated : transactionList) {
// transactionUIDomList.add(new TransactionUI(transactionRated.getCurrencyPrev(),
// transactionRated.getCurrencyCurrent(), transactionRated.getAmounPerTransactionPrev().toString(),
// transactionRated.getAmountPerTransactionCurrent().toString()));
// }
// return transactionUIDomList;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/TransactionRatedDomain.java
// public class TransactionRatedDomain {
// private BigDecimal amounPerTransactionPrev;
// private BigDecimal amountPerTransactionCurrent;
// private String currencyPrev;
// private String currencyCurrent;
//
// public TransactionRatedDomain(String currencyPrev, String currencyCurrent,
// BigDecimal amounPerTransactionPrev,
// BigDecimal amountPerTransactionCurrent) {
// this.currencyPrev = currencyPrev;
// this.currencyCurrent = currencyCurrent;
// this.amounPerTransactionPrev = amounPerTransactionPrev;
// this.amountPerTransactionCurrent = amountPerTransactionCurrent;
// }
//
// public BigDecimal getAmounPerTransactionPrev() {
// return amounPerTransactionPrev;
// }
//
// public BigDecimal getAmountPerTransactionCurrent() {
// return amountPerTransactionCurrent;
// }
//
// public String getCurrencyPrev() {
// return currencyPrev;
// }
//
// public String getCurrencyCurrent() {
// return currencyCurrent;
// }
//
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/ComputingTransactionsPresenter.java
// public interface ComputingTransactionsPresenter {
//
// void setView(View view);
//
// void resetView();
//
// void computeRates(String skuFromProduct, String toCurrency, String pathTransactions, String pathRates)
// throws CustomException;
//
// interface View {
// void errorComputingRates(String error);
//
// void computedRatesForTransactions(List<TransactionUI> transactions, String totalAmount);
//
// void visibilityChangesAfterSuccessfulComputedRates();
//
// void visibilityChangesAfterErrorComputedRates();
//
// boolean isReady();
//
// void startLoader();
// }
// }
| import static org.mockito.Matchers.anyList;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import android.support.annotation.NonNull;
import com.raulh82vlc.TransactionsViewer.domain.interactors.ComputeTransactionsInteractor;
import com.raulh82vlc.TransactionsViewer.domain.interactors.mappers.TransactionsRatedDataMapper;
import com.raulh82vlc.TransactionsViewer.domain.models.TransactionRatedDomain;
import com.raulh82vlc.TransactionsViewer.ui.presentation.ComputingTransactionsPresenter;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.verification.VerificationMode;
import java.util.List; | /*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.domain.interactors_response;
/**
* <p>Get Transactions Computed CallbackImpl interaction with its view or mapper</p>
*
* @author Raul Hernandez Lopez.
*/
public class GetTransactionsComputedCallbackImplTest {
private final static String AMOUNT = "2222";
private final static String ERROR = "ERROR";
@Mock | // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/ComputeTransactionsInteractor.java
// public interface ComputeTransactionsInteractor {
//
// void execute(String skuFromProduct,
// GetTransactionsComputedCallback getTransactionsComputedCallback,
// String toCurrency,
// String pathTransactions, String pathRates) throws CustomException;
//
//
// interface GetTransactionsComputedCallback {
// void onGetTransactionsListOK(List<TransactionRatedDomain> transactionList, String totalAmount);
//
// void onGetTransactionListKO(String error);
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/TransactionsRatedDataMapper.java
// @ActivityScope
// public class TransactionsRatedDataMapper {
//
// @Inject
// TransactionsRatedDataMapper() {
//
// }
//
// public List<TransactionUI> transformToUI(List<TransactionRatedDomain> transactionList) {
// if (transactionList == null) {
// throw new IllegalArgumentException("Cannot transform a null value");
// }
//
// List<TransactionUI> transactionUIDomList = new ArrayList<>();
// for (TransactionRatedDomain transactionRated : transactionList) {
// transactionUIDomList.add(new TransactionUI(transactionRated.getCurrencyPrev(),
// transactionRated.getCurrencyCurrent(), transactionRated.getAmounPerTransactionPrev().toString(),
// transactionRated.getAmountPerTransactionCurrent().toString()));
// }
// return transactionUIDomList;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/TransactionRatedDomain.java
// public class TransactionRatedDomain {
// private BigDecimal amounPerTransactionPrev;
// private BigDecimal amountPerTransactionCurrent;
// private String currencyPrev;
// private String currencyCurrent;
//
// public TransactionRatedDomain(String currencyPrev, String currencyCurrent,
// BigDecimal amounPerTransactionPrev,
// BigDecimal amountPerTransactionCurrent) {
// this.currencyPrev = currencyPrev;
// this.currencyCurrent = currencyCurrent;
// this.amounPerTransactionPrev = amounPerTransactionPrev;
// this.amountPerTransactionCurrent = amountPerTransactionCurrent;
// }
//
// public BigDecimal getAmounPerTransactionPrev() {
// return amounPerTransactionPrev;
// }
//
// public BigDecimal getAmountPerTransactionCurrent() {
// return amountPerTransactionCurrent;
// }
//
// public String getCurrencyPrev() {
// return currencyPrev;
// }
//
// public String getCurrencyCurrent() {
// return currencyCurrent;
// }
//
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/ComputingTransactionsPresenter.java
// public interface ComputingTransactionsPresenter {
//
// void setView(View view);
//
// void resetView();
//
// void computeRates(String skuFromProduct, String toCurrency, String pathTransactions, String pathRates)
// throws CustomException;
//
// interface View {
// void errorComputingRates(String error);
//
// void computedRatesForTransactions(List<TransactionUI> transactions, String totalAmount);
//
// void visibilityChangesAfterSuccessfulComputedRates();
//
// void visibilityChangesAfterErrorComputedRates();
//
// boolean isReady();
//
// void startLoader();
// }
// }
// Path: android/src/test/java/com/raulh82vlc/TransactionsViewer/domain/interactors_response/GetTransactionsComputedCallbackImplTest.java
import static org.mockito.Matchers.anyList;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import android.support.annotation.NonNull;
import com.raulh82vlc.TransactionsViewer.domain.interactors.ComputeTransactionsInteractor;
import com.raulh82vlc.TransactionsViewer.domain.interactors.mappers.TransactionsRatedDataMapper;
import com.raulh82vlc.TransactionsViewer.domain.models.TransactionRatedDomain;
import com.raulh82vlc.TransactionsViewer.ui.presentation.ComputingTransactionsPresenter;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.verification.VerificationMode;
import java.util.List;
/*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.domain.interactors_response;
/**
* <p>Get Transactions Computed CallbackImpl interaction with its view or mapper</p>
*
* @author Raul Hernandez Lopez.
*/
public class GetTransactionsComputedCallbackImplTest {
private final static String AMOUNT = "2222";
private final static String ERROR = "ERROR";
@Mock | private ComputingTransactionsPresenter.View view; |
raulh82vlc/Transactions-Viewer | android/src/test/java/com/raulh82vlc/TransactionsViewer/domain/interactors_response/GetTransactionsComputedCallbackImplTest.java | // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/ComputeTransactionsInteractor.java
// public interface ComputeTransactionsInteractor {
//
// void execute(String skuFromProduct,
// GetTransactionsComputedCallback getTransactionsComputedCallback,
// String toCurrency,
// String pathTransactions, String pathRates) throws CustomException;
//
//
// interface GetTransactionsComputedCallback {
// void onGetTransactionsListOK(List<TransactionRatedDomain> transactionList, String totalAmount);
//
// void onGetTransactionListKO(String error);
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/TransactionsRatedDataMapper.java
// @ActivityScope
// public class TransactionsRatedDataMapper {
//
// @Inject
// TransactionsRatedDataMapper() {
//
// }
//
// public List<TransactionUI> transformToUI(List<TransactionRatedDomain> transactionList) {
// if (transactionList == null) {
// throw new IllegalArgumentException("Cannot transform a null value");
// }
//
// List<TransactionUI> transactionUIDomList = new ArrayList<>();
// for (TransactionRatedDomain transactionRated : transactionList) {
// transactionUIDomList.add(new TransactionUI(transactionRated.getCurrencyPrev(),
// transactionRated.getCurrencyCurrent(), transactionRated.getAmounPerTransactionPrev().toString(),
// transactionRated.getAmountPerTransactionCurrent().toString()));
// }
// return transactionUIDomList;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/TransactionRatedDomain.java
// public class TransactionRatedDomain {
// private BigDecimal amounPerTransactionPrev;
// private BigDecimal amountPerTransactionCurrent;
// private String currencyPrev;
// private String currencyCurrent;
//
// public TransactionRatedDomain(String currencyPrev, String currencyCurrent,
// BigDecimal amounPerTransactionPrev,
// BigDecimal amountPerTransactionCurrent) {
// this.currencyPrev = currencyPrev;
// this.currencyCurrent = currencyCurrent;
// this.amounPerTransactionPrev = amounPerTransactionPrev;
// this.amountPerTransactionCurrent = amountPerTransactionCurrent;
// }
//
// public BigDecimal getAmounPerTransactionPrev() {
// return amounPerTransactionPrev;
// }
//
// public BigDecimal getAmountPerTransactionCurrent() {
// return amountPerTransactionCurrent;
// }
//
// public String getCurrencyPrev() {
// return currencyPrev;
// }
//
// public String getCurrencyCurrent() {
// return currencyCurrent;
// }
//
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/ComputingTransactionsPresenter.java
// public interface ComputingTransactionsPresenter {
//
// void setView(View view);
//
// void resetView();
//
// void computeRates(String skuFromProduct, String toCurrency, String pathTransactions, String pathRates)
// throws CustomException;
//
// interface View {
// void errorComputingRates(String error);
//
// void computedRatesForTransactions(List<TransactionUI> transactions, String totalAmount);
//
// void visibilityChangesAfterSuccessfulComputedRates();
//
// void visibilityChangesAfterErrorComputedRates();
//
// boolean isReady();
//
// void startLoader();
// }
// }
| import static org.mockito.Matchers.anyList;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import android.support.annotation.NonNull;
import com.raulh82vlc.TransactionsViewer.domain.interactors.ComputeTransactionsInteractor;
import com.raulh82vlc.TransactionsViewer.domain.interactors.mappers.TransactionsRatedDataMapper;
import com.raulh82vlc.TransactionsViewer.domain.models.TransactionRatedDomain;
import com.raulh82vlc.TransactionsViewer.ui.presentation.ComputingTransactionsPresenter;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.verification.VerificationMode;
import java.util.List; | /*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.domain.interactors_response;
/**
* <p>Get Transactions Computed CallbackImpl interaction with its view or mapper</p>
*
* @author Raul Hernandez Lopez.
*/
public class GetTransactionsComputedCallbackImplTest {
private final static String AMOUNT = "2222";
private final static String ERROR = "ERROR";
@Mock
private ComputingTransactionsPresenter.View view;
@Mock | // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/ComputeTransactionsInteractor.java
// public interface ComputeTransactionsInteractor {
//
// void execute(String skuFromProduct,
// GetTransactionsComputedCallback getTransactionsComputedCallback,
// String toCurrency,
// String pathTransactions, String pathRates) throws CustomException;
//
//
// interface GetTransactionsComputedCallback {
// void onGetTransactionsListOK(List<TransactionRatedDomain> transactionList, String totalAmount);
//
// void onGetTransactionListKO(String error);
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/TransactionsRatedDataMapper.java
// @ActivityScope
// public class TransactionsRatedDataMapper {
//
// @Inject
// TransactionsRatedDataMapper() {
//
// }
//
// public List<TransactionUI> transformToUI(List<TransactionRatedDomain> transactionList) {
// if (transactionList == null) {
// throw new IllegalArgumentException("Cannot transform a null value");
// }
//
// List<TransactionUI> transactionUIDomList = new ArrayList<>();
// for (TransactionRatedDomain transactionRated : transactionList) {
// transactionUIDomList.add(new TransactionUI(transactionRated.getCurrencyPrev(),
// transactionRated.getCurrencyCurrent(), transactionRated.getAmounPerTransactionPrev().toString(),
// transactionRated.getAmountPerTransactionCurrent().toString()));
// }
// return transactionUIDomList;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/TransactionRatedDomain.java
// public class TransactionRatedDomain {
// private BigDecimal amounPerTransactionPrev;
// private BigDecimal amountPerTransactionCurrent;
// private String currencyPrev;
// private String currencyCurrent;
//
// public TransactionRatedDomain(String currencyPrev, String currencyCurrent,
// BigDecimal amounPerTransactionPrev,
// BigDecimal amountPerTransactionCurrent) {
// this.currencyPrev = currencyPrev;
// this.currencyCurrent = currencyCurrent;
// this.amounPerTransactionPrev = amounPerTransactionPrev;
// this.amountPerTransactionCurrent = amountPerTransactionCurrent;
// }
//
// public BigDecimal getAmounPerTransactionPrev() {
// return amounPerTransactionPrev;
// }
//
// public BigDecimal getAmountPerTransactionCurrent() {
// return amountPerTransactionCurrent;
// }
//
// public String getCurrencyPrev() {
// return currencyPrev;
// }
//
// public String getCurrencyCurrent() {
// return currencyCurrent;
// }
//
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/ComputingTransactionsPresenter.java
// public interface ComputingTransactionsPresenter {
//
// void setView(View view);
//
// void resetView();
//
// void computeRates(String skuFromProduct, String toCurrency, String pathTransactions, String pathRates)
// throws CustomException;
//
// interface View {
// void errorComputingRates(String error);
//
// void computedRatesForTransactions(List<TransactionUI> transactions, String totalAmount);
//
// void visibilityChangesAfterSuccessfulComputedRates();
//
// void visibilityChangesAfterErrorComputedRates();
//
// boolean isReady();
//
// void startLoader();
// }
// }
// Path: android/src/test/java/com/raulh82vlc/TransactionsViewer/domain/interactors_response/GetTransactionsComputedCallbackImplTest.java
import static org.mockito.Matchers.anyList;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import android.support.annotation.NonNull;
import com.raulh82vlc.TransactionsViewer.domain.interactors.ComputeTransactionsInteractor;
import com.raulh82vlc.TransactionsViewer.domain.interactors.mappers.TransactionsRatedDataMapper;
import com.raulh82vlc.TransactionsViewer.domain.models.TransactionRatedDomain;
import com.raulh82vlc.TransactionsViewer.ui.presentation.ComputingTransactionsPresenter;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.verification.VerificationMode;
import java.util.List;
/*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.domain.interactors_response;
/**
* <p>Get Transactions Computed CallbackImpl interaction with its view or mapper</p>
*
* @author Raul Hernandez Lopez.
*/
public class GetTransactionsComputedCallbackImplTest {
private final static String AMOUNT = "2222";
private final static String ERROR = "ERROR";
@Mock
private ComputingTransactionsPresenter.View view;
@Mock | private TransactionsRatedDataMapper mapper; |
raulh82vlc/Transactions-Viewer | android/src/test/java/com/raulh82vlc/TransactionsViewer/domain/interactors_response/GetTransactionsComputedCallbackImplTest.java | // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/ComputeTransactionsInteractor.java
// public interface ComputeTransactionsInteractor {
//
// void execute(String skuFromProduct,
// GetTransactionsComputedCallback getTransactionsComputedCallback,
// String toCurrency,
// String pathTransactions, String pathRates) throws CustomException;
//
//
// interface GetTransactionsComputedCallback {
// void onGetTransactionsListOK(List<TransactionRatedDomain> transactionList, String totalAmount);
//
// void onGetTransactionListKO(String error);
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/TransactionsRatedDataMapper.java
// @ActivityScope
// public class TransactionsRatedDataMapper {
//
// @Inject
// TransactionsRatedDataMapper() {
//
// }
//
// public List<TransactionUI> transformToUI(List<TransactionRatedDomain> transactionList) {
// if (transactionList == null) {
// throw new IllegalArgumentException("Cannot transform a null value");
// }
//
// List<TransactionUI> transactionUIDomList = new ArrayList<>();
// for (TransactionRatedDomain transactionRated : transactionList) {
// transactionUIDomList.add(new TransactionUI(transactionRated.getCurrencyPrev(),
// transactionRated.getCurrencyCurrent(), transactionRated.getAmounPerTransactionPrev().toString(),
// transactionRated.getAmountPerTransactionCurrent().toString()));
// }
// return transactionUIDomList;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/TransactionRatedDomain.java
// public class TransactionRatedDomain {
// private BigDecimal amounPerTransactionPrev;
// private BigDecimal amountPerTransactionCurrent;
// private String currencyPrev;
// private String currencyCurrent;
//
// public TransactionRatedDomain(String currencyPrev, String currencyCurrent,
// BigDecimal amounPerTransactionPrev,
// BigDecimal amountPerTransactionCurrent) {
// this.currencyPrev = currencyPrev;
// this.currencyCurrent = currencyCurrent;
// this.amounPerTransactionPrev = amounPerTransactionPrev;
// this.amountPerTransactionCurrent = amountPerTransactionCurrent;
// }
//
// public BigDecimal getAmounPerTransactionPrev() {
// return amounPerTransactionPrev;
// }
//
// public BigDecimal getAmountPerTransactionCurrent() {
// return amountPerTransactionCurrent;
// }
//
// public String getCurrencyPrev() {
// return currencyPrev;
// }
//
// public String getCurrencyCurrent() {
// return currencyCurrent;
// }
//
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/ComputingTransactionsPresenter.java
// public interface ComputingTransactionsPresenter {
//
// void setView(View view);
//
// void resetView();
//
// void computeRates(String skuFromProduct, String toCurrency, String pathTransactions, String pathRates)
// throws CustomException;
//
// interface View {
// void errorComputingRates(String error);
//
// void computedRatesForTransactions(List<TransactionUI> transactions, String totalAmount);
//
// void visibilityChangesAfterSuccessfulComputedRates();
//
// void visibilityChangesAfterErrorComputedRates();
//
// boolean isReady();
//
// void startLoader();
// }
// }
| import static org.mockito.Matchers.anyList;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import android.support.annotation.NonNull;
import com.raulh82vlc.TransactionsViewer.domain.interactors.ComputeTransactionsInteractor;
import com.raulh82vlc.TransactionsViewer.domain.interactors.mappers.TransactionsRatedDataMapper;
import com.raulh82vlc.TransactionsViewer.domain.models.TransactionRatedDomain;
import com.raulh82vlc.TransactionsViewer.ui.presentation.ComputingTransactionsPresenter;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.verification.VerificationMode;
import java.util.List; | /*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.domain.interactors_response;
/**
* <p>Get Transactions Computed CallbackImpl interaction with its view or mapper</p>
*
* @author Raul Hernandez Lopez.
*/
public class GetTransactionsComputedCallbackImplTest {
private final static String AMOUNT = "2222";
private final static String ERROR = "ERROR";
@Mock
private ComputingTransactionsPresenter.View view;
@Mock
private TransactionsRatedDataMapper mapper;
@Mock | // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/ComputeTransactionsInteractor.java
// public interface ComputeTransactionsInteractor {
//
// void execute(String skuFromProduct,
// GetTransactionsComputedCallback getTransactionsComputedCallback,
// String toCurrency,
// String pathTransactions, String pathRates) throws CustomException;
//
//
// interface GetTransactionsComputedCallback {
// void onGetTransactionsListOK(List<TransactionRatedDomain> transactionList, String totalAmount);
//
// void onGetTransactionListKO(String error);
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/TransactionsRatedDataMapper.java
// @ActivityScope
// public class TransactionsRatedDataMapper {
//
// @Inject
// TransactionsRatedDataMapper() {
//
// }
//
// public List<TransactionUI> transformToUI(List<TransactionRatedDomain> transactionList) {
// if (transactionList == null) {
// throw new IllegalArgumentException("Cannot transform a null value");
// }
//
// List<TransactionUI> transactionUIDomList = new ArrayList<>();
// for (TransactionRatedDomain transactionRated : transactionList) {
// transactionUIDomList.add(new TransactionUI(transactionRated.getCurrencyPrev(),
// transactionRated.getCurrencyCurrent(), transactionRated.getAmounPerTransactionPrev().toString(),
// transactionRated.getAmountPerTransactionCurrent().toString()));
// }
// return transactionUIDomList;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/TransactionRatedDomain.java
// public class TransactionRatedDomain {
// private BigDecimal amounPerTransactionPrev;
// private BigDecimal amountPerTransactionCurrent;
// private String currencyPrev;
// private String currencyCurrent;
//
// public TransactionRatedDomain(String currencyPrev, String currencyCurrent,
// BigDecimal amounPerTransactionPrev,
// BigDecimal amountPerTransactionCurrent) {
// this.currencyPrev = currencyPrev;
// this.currencyCurrent = currencyCurrent;
// this.amounPerTransactionPrev = amounPerTransactionPrev;
// this.amountPerTransactionCurrent = amountPerTransactionCurrent;
// }
//
// public BigDecimal getAmounPerTransactionPrev() {
// return amounPerTransactionPrev;
// }
//
// public BigDecimal getAmountPerTransactionCurrent() {
// return amountPerTransactionCurrent;
// }
//
// public String getCurrencyPrev() {
// return currencyPrev;
// }
//
// public String getCurrencyCurrent() {
// return currencyCurrent;
// }
//
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/ComputingTransactionsPresenter.java
// public interface ComputingTransactionsPresenter {
//
// void setView(View view);
//
// void resetView();
//
// void computeRates(String skuFromProduct, String toCurrency, String pathTransactions, String pathRates)
// throws CustomException;
//
// interface View {
// void errorComputingRates(String error);
//
// void computedRatesForTransactions(List<TransactionUI> transactions, String totalAmount);
//
// void visibilityChangesAfterSuccessfulComputedRates();
//
// void visibilityChangesAfterErrorComputedRates();
//
// boolean isReady();
//
// void startLoader();
// }
// }
// Path: android/src/test/java/com/raulh82vlc/TransactionsViewer/domain/interactors_response/GetTransactionsComputedCallbackImplTest.java
import static org.mockito.Matchers.anyList;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import android.support.annotation.NonNull;
import com.raulh82vlc.TransactionsViewer.domain.interactors.ComputeTransactionsInteractor;
import com.raulh82vlc.TransactionsViewer.domain.interactors.mappers.TransactionsRatedDataMapper;
import com.raulh82vlc.TransactionsViewer.domain.models.TransactionRatedDomain;
import com.raulh82vlc.TransactionsViewer.ui.presentation.ComputingTransactionsPresenter;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.verification.VerificationMode;
import java.util.List;
/*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.domain.interactors_response;
/**
* <p>Get Transactions Computed CallbackImpl interaction with its view or mapper</p>
*
* @author Raul Hernandez Lopez.
*/
public class GetTransactionsComputedCallbackImplTest {
private final static String AMOUNT = "2222";
private final static String ERROR = "ERROR";
@Mock
private ComputingTransactionsPresenter.View view;
@Mock
private TransactionsRatedDataMapper mapper;
@Mock | private List<TransactionRatedDomain> list; |
raulh82vlc/Transactions-Viewer | android/src/test/java/com/raulh82vlc/TransactionsViewer/domain/interactors_response/GetTransactionsComputedCallbackImplTest.java | // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/ComputeTransactionsInteractor.java
// public interface ComputeTransactionsInteractor {
//
// void execute(String skuFromProduct,
// GetTransactionsComputedCallback getTransactionsComputedCallback,
// String toCurrency,
// String pathTransactions, String pathRates) throws CustomException;
//
//
// interface GetTransactionsComputedCallback {
// void onGetTransactionsListOK(List<TransactionRatedDomain> transactionList, String totalAmount);
//
// void onGetTransactionListKO(String error);
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/TransactionsRatedDataMapper.java
// @ActivityScope
// public class TransactionsRatedDataMapper {
//
// @Inject
// TransactionsRatedDataMapper() {
//
// }
//
// public List<TransactionUI> transformToUI(List<TransactionRatedDomain> transactionList) {
// if (transactionList == null) {
// throw new IllegalArgumentException("Cannot transform a null value");
// }
//
// List<TransactionUI> transactionUIDomList = new ArrayList<>();
// for (TransactionRatedDomain transactionRated : transactionList) {
// transactionUIDomList.add(new TransactionUI(transactionRated.getCurrencyPrev(),
// transactionRated.getCurrencyCurrent(), transactionRated.getAmounPerTransactionPrev().toString(),
// transactionRated.getAmountPerTransactionCurrent().toString()));
// }
// return transactionUIDomList;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/TransactionRatedDomain.java
// public class TransactionRatedDomain {
// private BigDecimal amounPerTransactionPrev;
// private BigDecimal amountPerTransactionCurrent;
// private String currencyPrev;
// private String currencyCurrent;
//
// public TransactionRatedDomain(String currencyPrev, String currencyCurrent,
// BigDecimal amounPerTransactionPrev,
// BigDecimal amountPerTransactionCurrent) {
// this.currencyPrev = currencyPrev;
// this.currencyCurrent = currencyCurrent;
// this.amounPerTransactionPrev = amounPerTransactionPrev;
// this.amountPerTransactionCurrent = amountPerTransactionCurrent;
// }
//
// public BigDecimal getAmounPerTransactionPrev() {
// return amounPerTransactionPrev;
// }
//
// public BigDecimal getAmountPerTransactionCurrent() {
// return amountPerTransactionCurrent;
// }
//
// public String getCurrencyPrev() {
// return currencyPrev;
// }
//
// public String getCurrencyCurrent() {
// return currencyCurrent;
// }
//
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/ComputingTransactionsPresenter.java
// public interface ComputingTransactionsPresenter {
//
// void setView(View view);
//
// void resetView();
//
// void computeRates(String skuFromProduct, String toCurrency, String pathTransactions, String pathRates)
// throws CustomException;
//
// interface View {
// void errorComputingRates(String error);
//
// void computedRatesForTransactions(List<TransactionUI> transactions, String totalAmount);
//
// void visibilityChangesAfterSuccessfulComputedRates();
//
// void visibilityChangesAfterErrorComputedRates();
//
// boolean isReady();
//
// void startLoader();
// }
// }
| import static org.mockito.Matchers.anyList;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import android.support.annotation.NonNull;
import com.raulh82vlc.TransactionsViewer.domain.interactors.ComputeTransactionsInteractor;
import com.raulh82vlc.TransactionsViewer.domain.interactors.mappers.TransactionsRatedDataMapper;
import com.raulh82vlc.TransactionsViewer.domain.models.TransactionRatedDomain;
import com.raulh82vlc.TransactionsViewer.ui.presentation.ComputingTransactionsPresenter;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.verification.VerificationMode;
import java.util.List; | /*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.domain.interactors_response;
/**
* <p>Get Transactions Computed CallbackImpl interaction with its view or mapper</p>
*
* @author Raul Hernandez Lopez.
*/
public class GetTransactionsComputedCallbackImplTest {
private final static String AMOUNT = "2222";
private final static String ERROR = "ERROR";
@Mock
private ComputingTransactionsPresenter.View view;
@Mock
private TransactionsRatedDataMapper mapper;
@Mock
private List<TransactionRatedDomain> list;
| // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/ComputeTransactionsInteractor.java
// public interface ComputeTransactionsInteractor {
//
// void execute(String skuFromProduct,
// GetTransactionsComputedCallback getTransactionsComputedCallback,
// String toCurrency,
// String pathTransactions, String pathRates) throws CustomException;
//
//
// interface GetTransactionsComputedCallback {
// void onGetTransactionsListOK(List<TransactionRatedDomain> transactionList, String totalAmount);
//
// void onGetTransactionListKO(String error);
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/TransactionsRatedDataMapper.java
// @ActivityScope
// public class TransactionsRatedDataMapper {
//
// @Inject
// TransactionsRatedDataMapper() {
//
// }
//
// public List<TransactionUI> transformToUI(List<TransactionRatedDomain> transactionList) {
// if (transactionList == null) {
// throw new IllegalArgumentException("Cannot transform a null value");
// }
//
// List<TransactionUI> transactionUIDomList = new ArrayList<>();
// for (TransactionRatedDomain transactionRated : transactionList) {
// transactionUIDomList.add(new TransactionUI(transactionRated.getCurrencyPrev(),
// transactionRated.getCurrencyCurrent(), transactionRated.getAmounPerTransactionPrev().toString(),
// transactionRated.getAmountPerTransactionCurrent().toString()));
// }
// return transactionUIDomList;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/TransactionRatedDomain.java
// public class TransactionRatedDomain {
// private BigDecimal amounPerTransactionPrev;
// private BigDecimal amountPerTransactionCurrent;
// private String currencyPrev;
// private String currencyCurrent;
//
// public TransactionRatedDomain(String currencyPrev, String currencyCurrent,
// BigDecimal amounPerTransactionPrev,
// BigDecimal amountPerTransactionCurrent) {
// this.currencyPrev = currencyPrev;
// this.currencyCurrent = currencyCurrent;
// this.amounPerTransactionPrev = amounPerTransactionPrev;
// this.amountPerTransactionCurrent = amountPerTransactionCurrent;
// }
//
// public BigDecimal getAmounPerTransactionPrev() {
// return amounPerTransactionPrev;
// }
//
// public BigDecimal getAmountPerTransactionCurrent() {
// return amountPerTransactionCurrent;
// }
//
// public String getCurrencyPrev() {
// return currencyPrev;
// }
//
// public String getCurrencyCurrent() {
// return currencyCurrent;
// }
//
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/ComputingTransactionsPresenter.java
// public interface ComputingTransactionsPresenter {
//
// void setView(View view);
//
// void resetView();
//
// void computeRates(String skuFromProduct, String toCurrency, String pathTransactions, String pathRates)
// throws CustomException;
//
// interface View {
// void errorComputingRates(String error);
//
// void computedRatesForTransactions(List<TransactionUI> transactions, String totalAmount);
//
// void visibilityChangesAfterSuccessfulComputedRates();
//
// void visibilityChangesAfterErrorComputedRates();
//
// boolean isReady();
//
// void startLoader();
// }
// }
// Path: android/src/test/java/com/raulh82vlc/TransactionsViewer/domain/interactors_response/GetTransactionsComputedCallbackImplTest.java
import static org.mockito.Matchers.anyList;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import android.support.annotation.NonNull;
import com.raulh82vlc.TransactionsViewer.domain.interactors.ComputeTransactionsInteractor;
import com.raulh82vlc.TransactionsViewer.domain.interactors.mappers.TransactionsRatedDataMapper;
import com.raulh82vlc.TransactionsViewer.domain.models.TransactionRatedDomain;
import com.raulh82vlc.TransactionsViewer.ui.presentation.ComputingTransactionsPresenter;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.verification.VerificationMode;
import java.util.List;
/*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.domain.interactors_response;
/**
* <p>Get Transactions Computed CallbackImpl interaction with its view or mapper</p>
*
* @author Raul Hernandez Lopez.
*/
public class GetTransactionsComputedCallbackImplTest {
private final static String AMOUNT = "2222";
private final static String ERROR = "ERROR";
@Mock
private ComputingTransactionsPresenter.View view;
@Mock
private TransactionsRatedDataMapper mapper;
@Mock
private List<TransactionRatedDomain> list;
| private ComputeTransactionsInteractor.GetTransactionsComputedCallback callbackToTest; |
raulh82vlc/Transactions-Viewer | android/src/main/java/com/raulh82vlc/TransactionsViewer/di/components/ApplicationComponent.java | // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/TransactionsViewerApp.java
// public class TransactionsViewerApp extends Application {
//
// private ApplicationComponent applicationComponent;
//
// @Override
// public void onCreate() {
// super.onCreate();
// applicationComponent = DaggerApplicationComponent.builder()
// .applicationModule(new ApplicationModule(this))
// .build();
// }
//
// public ApplicationComponent component() {
// return applicationComponent;
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/modules/ApplicationModule.java
// @Module
// public class ApplicationModule {
// private final Application application;
//
// public ApplicationModule(Application application) {
// this.application = application;
// }
//
// @Provides
// @Singleton
// Application provideApplication() {
// return application;
// }
//
// @Provides
// @Singleton
// InteractorExecutor provideThreadsPoolExecutor(ThreadsPoolExecutor executor) {
// return executor;
// }
//
// @Provides
// @Singleton
// MainThread providePostExecutionThread(MainThreadImpl mainThread) {
// return mainThread;
// }
//
// @Provides
// @Singleton
// Context provideApplicationContext() {
// return application.getApplicationContext();
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/modules/RepositoryModule.java
// @Module
// public class RepositoryModule {
// @Provides
// @Singleton
// DataRepository provideRepository(JSONRepositoryImpl repository) {
// return repository;
// }
//
// @Provides
// @Singleton
// JSONDataSource provideJSONDataSource(JSONDataSourceImpl dataSource) {
// return dataSource;
// }
//
// @Provides
// @Singleton
// JSONOperations provideJSONOperations(JSONOperationsImpl jsonOperations) {
// return jsonOperations;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java
// public interface InteractorExecutor {
// void run(Interactor interactor) throws CustomException;
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java
// public interface MainThread {
// void post(final Runnable runnable);
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/DataRepository.java
// public interface DataRepository<R, T> {
//
// /**
// * to get Rates List
// **/
// List<R> getRatesList(String path) throws CustomException;
//
// /**
// * to get Transactions list
// **/
// List<T> getTransactionsList(String path) throws CustomException;
//
// /**
// * to get Transactions per product's SKU
// **/
// List<T> getTransactionsPerSku(String mPathTransactions, String mSku);
//
// /**
// * to save Transactions indexed per product's SKU
// **/
// boolean saveTransactions(Map<String, List<T>> map);
// }
| import android.app.Application;
import android.content.Context;
import com.raulh82vlc.TransactionsViewer.TransactionsViewerApp;
import com.raulh82vlc.TransactionsViewer.di.modules.ApplicationModule;
import com.raulh82vlc.TransactionsViewer.di.modules.RepositoryModule;
import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor;
import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread;
import com.raulh82vlc.TransactionsViewer.domain.repository.DataRepository;
import javax.inject.Singleton;
import dagger.Component; | /*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.di.components;
/**
* ApplicationComponent is the top level component for this architecture.
* It provides generic dependencies such as
* {@link MainThread} or {@link InteractorExecutor}
* and makes them available to sub-components and other external dependant classes.
* <p/>
* Scope {@link Singleton} is used to limit dependency instances across whole execution.
*
* @author Raul Hernandez Lopez
*/
@Singleton
@Component(
modules = { | // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/TransactionsViewerApp.java
// public class TransactionsViewerApp extends Application {
//
// private ApplicationComponent applicationComponent;
//
// @Override
// public void onCreate() {
// super.onCreate();
// applicationComponent = DaggerApplicationComponent.builder()
// .applicationModule(new ApplicationModule(this))
// .build();
// }
//
// public ApplicationComponent component() {
// return applicationComponent;
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/modules/ApplicationModule.java
// @Module
// public class ApplicationModule {
// private final Application application;
//
// public ApplicationModule(Application application) {
// this.application = application;
// }
//
// @Provides
// @Singleton
// Application provideApplication() {
// return application;
// }
//
// @Provides
// @Singleton
// InteractorExecutor provideThreadsPoolExecutor(ThreadsPoolExecutor executor) {
// return executor;
// }
//
// @Provides
// @Singleton
// MainThread providePostExecutionThread(MainThreadImpl mainThread) {
// return mainThread;
// }
//
// @Provides
// @Singleton
// Context provideApplicationContext() {
// return application.getApplicationContext();
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/modules/RepositoryModule.java
// @Module
// public class RepositoryModule {
// @Provides
// @Singleton
// DataRepository provideRepository(JSONRepositoryImpl repository) {
// return repository;
// }
//
// @Provides
// @Singleton
// JSONDataSource provideJSONDataSource(JSONDataSourceImpl dataSource) {
// return dataSource;
// }
//
// @Provides
// @Singleton
// JSONOperations provideJSONOperations(JSONOperationsImpl jsonOperations) {
// return jsonOperations;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java
// public interface InteractorExecutor {
// void run(Interactor interactor) throws CustomException;
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java
// public interface MainThread {
// void post(final Runnable runnable);
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/DataRepository.java
// public interface DataRepository<R, T> {
//
// /**
// * to get Rates List
// **/
// List<R> getRatesList(String path) throws CustomException;
//
// /**
// * to get Transactions list
// **/
// List<T> getTransactionsList(String path) throws CustomException;
//
// /**
// * to get Transactions per product's SKU
// **/
// List<T> getTransactionsPerSku(String mPathTransactions, String mSku);
//
// /**
// * to save Transactions indexed per product's SKU
// **/
// boolean saveTransactions(Map<String, List<T>> map);
// }
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/components/ApplicationComponent.java
import android.app.Application;
import android.content.Context;
import com.raulh82vlc.TransactionsViewer.TransactionsViewerApp;
import com.raulh82vlc.TransactionsViewer.di.modules.ApplicationModule;
import com.raulh82vlc.TransactionsViewer.di.modules.RepositoryModule;
import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor;
import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread;
import com.raulh82vlc.TransactionsViewer.domain.repository.DataRepository;
import javax.inject.Singleton;
import dagger.Component;
/*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.di.components;
/**
* ApplicationComponent is the top level component for this architecture.
* It provides generic dependencies such as
* {@link MainThread} or {@link InteractorExecutor}
* and makes them available to sub-components and other external dependant classes.
* <p/>
* Scope {@link Singleton} is used to limit dependency instances across whole execution.
*
* @author Raul Hernandez Lopez
*/
@Singleton
@Component(
modules = { | ApplicationModule.class, |
raulh82vlc/Transactions-Viewer | android/src/main/java/com/raulh82vlc/TransactionsViewer/di/components/ApplicationComponent.java | // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/TransactionsViewerApp.java
// public class TransactionsViewerApp extends Application {
//
// private ApplicationComponent applicationComponent;
//
// @Override
// public void onCreate() {
// super.onCreate();
// applicationComponent = DaggerApplicationComponent.builder()
// .applicationModule(new ApplicationModule(this))
// .build();
// }
//
// public ApplicationComponent component() {
// return applicationComponent;
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/modules/ApplicationModule.java
// @Module
// public class ApplicationModule {
// private final Application application;
//
// public ApplicationModule(Application application) {
// this.application = application;
// }
//
// @Provides
// @Singleton
// Application provideApplication() {
// return application;
// }
//
// @Provides
// @Singleton
// InteractorExecutor provideThreadsPoolExecutor(ThreadsPoolExecutor executor) {
// return executor;
// }
//
// @Provides
// @Singleton
// MainThread providePostExecutionThread(MainThreadImpl mainThread) {
// return mainThread;
// }
//
// @Provides
// @Singleton
// Context provideApplicationContext() {
// return application.getApplicationContext();
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/modules/RepositoryModule.java
// @Module
// public class RepositoryModule {
// @Provides
// @Singleton
// DataRepository provideRepository(JSONRepositoryImpl repository) {
// return repository;
// }
//
// @Provides
// @Singleton
// JSONDataSource provideJSONDataSource(JSONDataSourceImpl dataSource) {
// return dataSource;
// }
//
// @Provides
// @Singleton
// JSONOperations provideJSONOperations(JSONOperationsImpl jsonOperations) {
// return jsonOperations;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java
// public interface InteractorExecutor {
// void run(Interactor interactor) throws CustomException;
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java
// public interface MainThread {
// void post(final Runnable runnable);
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/DataRepository.java
// public interface DataRepository<R, T> {
//
// /**
// * to get Rates List
// **/
// List<R> getRatesList(String path) throws CustomException;
//
// /**
// * to get Transactions list
// **/
// List<T> getTransactionsList(String path) throws CustomException;
//
// /**
// * to get Transactions per product's SKU
// **/
// List<T> getTransactionsPerSku(String mPathTransactions, String mSku);
//
// /**
// * to save Transactions indexed per product's SKU
// **/
// boolean saveTransactions(Map<String, List<T>> map);
// }
| import android.app.Application;
import android.content.Context;
import com.raulh82vlc.TransactionsViewer.TransactionsViewerApp;
import com.raulh82vlc.TransactionsViewer.di.modules.ApplicationModule;
import com.raulh82vlc.TransactionsViewer.di.modules.RepositoryModule;
import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor;
import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread;
import com.raulh82vlc.TransactionsViewer.domain.repository.DataRepository;
import javax.inject.Singleton;
import dagger.Component; | /*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.di.components;
/**
* ApplicationComponent is the top level component for this architecture.
* It provides generic dependencies such as
* {@link MainThread} or {@link InteractorExecutor}
* and makes them available to sub-components and other external dependant classes.
* <p/>
* Scope {@link Singleton} is used to limit dependency instances across whole execution.
*
* @author Raul Hernandez Lopez
*/
@Singleton
@Component(
modules = {
ApplicationModule.class, | // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/TransactionsViewerApp.java
// public class TransactionsViewerApp extends Application {
//
// private ApplicationComponent applicationComponent;
//
// @Override
// public void onCreate() {
// super.onCreate();
// applicationComponent = DaggerApplicationComponent.builder()
// .applicationModule(new ApplicationModule(this))
// .build();
// }
//
// public ApplicationComponent component() {
// return applicationComponent;
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/modules/ApplicationModule.java
// @Module
// public class ApplicationModule {
// private final Application application;
//
// public ApplicationModule(Application application) {
// this.application = application;
// }
//
// @Provides
// @Singleton
// Application provideApplication() {
// return application;
// }
//
// @Provides
// @Singleton
// InteractorExecutor provideThreadsPoolExecutor(ThreadsPoolExecutor executor) {
// return executor;
// }
//
// @Provides
// @Singleton
// MainThread providePostExecutionThread(MainThreadImpl mainThread) {
// return mainThread;
// }
//
// @Provides
// @Singleton
// Context provideApplicationContext() {
// return application.getApplicationContext();
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/modules/RepositoryModule.java
// @Module
// public class RepositoryModule {
// @Provides
// @Singleton
// DataRepository provideRepository(JSONRepositoryImpl repository) {
// return repository;
// }
//
// @Provides
// @Singleton
// JSONDataSource provideJSONDataSource(JSONDataSourceImpl dataSource) {
// return dataSource;
// }
//
// @Provides
// @Singleton
// JSONOperations provideJSONOperations(JSONOperationsImpl jsonOperations) {
// return jsonOperations;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java
// public interface InteractorExecutor {
// void run(Interactor interactor) throws CustomException;
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java
// public interface MainThread {
// void post(final Runnable runnable);
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/DataRepository.java
// public interface DataRepository<R, T> {
//
// /**
// * to get Rates List
// **/
// List<R> getRatesList(String path) throws CustomException;
//
// /**
// * to get Transactions list
// **/
// List<T> getTransactionsList(String path) throws CustomException;
//
// /**
// * to get Transactions per product's SKU
// **/
// List<T> getTransactionsPerSku(String mPathTransactions, String mSku);
//
// /**
// * to save Transactions indexed per product's SKU
// **/
// boolean saveTransactions(Map<String, List<T>> map);
// }
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/components/ApplicationComponent.java
import android.app.Application;
import android.content.Context;
import com.raulh82vlc.TransactionsViewer.TransactionsViewerApp;
import com.raulh82vlc.TransactionsViewer.di.modules.ApplicationModule;
import com.raulh82vlc.TransactionsViewer.di.modules.RepositoryModule;
import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor;
import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread;
import com.raulh82vlc.TransactionsViewer.domain.repository.DataRepository;
import javax.inject.Singleton;
import dagger.Component;
/*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.di.components;
/**
* ApplicationComponent is the top level component for this architecture.
* It provides generic dependencies such as
* {@link MainThread} or {@link InteractorExecutor}
* and makes them available to sub-components and other external dependant classes.
* <p/>
* Scope {@link Singleton} is used to limit dependency instances across whole execution.
*
* @author Raul Hernandez Lopez
*/
@Singleton
@Component(
modules = {
ApplicationModule.class, | RepositoryModule.class |
raulh82vlc/Transactions-Viewer | android/src/main/java/com/raulh82vlc/TransactionsViewer/di/components/ApplicationComponent.java | // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/TransactionsViewerApp.java
// public class TransactionsViewerApp extends Application {
//
// private ApplicationComponent applicationComponent;
//
// @Override
// public void onCreate() {
// super.onCreate();
// applicationComponent = DaggerApplicationComponent.builder()
// .applicationModule(new ApplicationModule(this))
// .build();
// }
//
// public ApplicationComponent component() {
// return applicationComponent;
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/modules/ApplicationModule.java
// @Module
// public class ApplicationModule {
// private final Application application;
//
// public ApplicationModule(Application application) {
// this.application = application;
// }
//
// @Provides
// @Singleton
// Application provideApplication() {
// return application;
// }
//
// @Provides
// @Singleton
// InteractorExecutor provideThreadsPoolExecutor(ThreadsPoolExecutor executor) {
// return executor;
// }
//
// @Provides
// @Singleton
// MainThread providePostExecutionThread(MainThreadImpl mainThread) {
// return mainThread;
// }
//
// @Provides
// @Singleton
// Context provideApplicationContext() {
// return application.getApplicationContext();
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/modules/RepositoryModule.java
// @Module
// public class RepositoryModule {
// @Provides
// @Singleton
// DataRepository provideRepository(JSONRepositoryImpl repository) {
// return repository;
// }
//
// @Provides
// @Singleton
// JSONDataSource provideJSONDataSource(JSONDataSourceImpl dataSource) {
// return dataSource;
// }
//
// @Provides
// @Singleton
// JSONOperations provideJSONOperations(JSONOperationsImpl jsonOperations) {
// return jsonOperations;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java
// public interface InteractorExecutor {
// void run(Interactor interactor) throws CustomException;
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java
// public interface MainThread {
// void post(final Runnable runnable);
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/DataRepository.java
// public interface DataRepository<R, T> {
//
// /**
// * to get Rates List
// **/
// List<R> getRatesList(String path) throws CustomException;
//
// /**
// * to get Transactions list
// **/
// List<T> getTransactionsList(String path) throws CustomException;
//
// /**
// * to get Transactions per product's SKU
// **/
// List<T> getTransactionsPerSku(String mPathTransactions, String mSku);
//
// /**
// * to save Transactions indexed per product's SKU
// **/
// boolean saveTransactions(Map<String, List<T>> map);
// }
| import android.app.Application;
import android.content.Context;
import com.raulh82vlc.TransactionsViewer.TransactionsViewerApp;
import com.raulh82vlc.TransactionsViewer.di.modules.ApplicationModule;
import com.raulh82vlc.TransactionsViewer.di.modules.RepositoryModule;
import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor;
import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread;
import com.raulh82vlc.TransactionsViewer.domain.repository.DataRepository;
import javax.inject.Singleton;
import dagger.Component; | /*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.di.components;
/**
* ApplicationComponent is the top level component for this architecture.
* It provides generic dependencies such as
* {@link MainThread} or {@link InteractorExecutor}
* and makes them available to sub-components and other external dependant classes.
* <p/>
* Scope {@link Singleton} is used to limit dependency instances across whole execution.
*
* @author Raul Hernandez Lopez
*/
@Singleton
@Component(
modules = {
ApplicationModule.class,
RepositoryModule.class
})
public interface ApplicationComponent {
/**
* Injections for the dependencies
*/ | // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/TransactionsViewerApp.java
// public class TransactionsViewerApp extends Application {
//
// private ApplicationComponent applicationComponent;
//
// @Override
// public void onCreate() {
// super.onCreate();
// applicationComponent = DaggerApplicationComponent.builder()
// .applicationModule(new ApplicationModule(this))
// .build();
// }
//
// public ApplicationComponent component() {
// return applicationComponent;
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/modules/ApplicationModule.java
// @Module
// public class ApplicationModule {
// private final Application application;
//
// public ApplicationModule(Application application) {
// this.application = application;
// }
//
// @Provides
// @Singleton
// Application provideApplication() {
// return application;
// }
//
// @Provides
// @Singleton
// InteractorExecutor provideThreadsPoolExecutor(ThreadsPoolExecutor executor) {
// return executor;
// }
//
// @Provides
// @Singleton
// MainThread providePostExecutionThread(MainThreadImpl mainThread) {
// return mainThread;
// }
//
// @Provides
// @Singleton
// Context provideApplicationContext() {
// return application.getApplicationContext();
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/modules/RepositoryModule.java
// @Module
// public class RepositoryModule {
// @Provides
// @Singleton
// DataRepository provideRepository(JSONRepositoryImpl repository) {
// return repository;
// }
//
// @Provides
// @Singleton
// JSONDataSource provideJSONDataSource(JSONDataSourceImpl dataSource) {
// return dataSource;
// }
//
// @Provides
// @Singleton
// JSONOperations provideJSONOperations(JSONOperationsImpl jsonOperations) {
// return jsonOperations;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java
// public interface InteractorExecutor {
// void run(Interactor interactor) throws CustomException;
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java
// public interface MainThread {
// void post(final Runnable runnable);
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/DataRepository.java
// public interface DataRepository<R, T> {
//
// /**
// * to get Rates List
// **/
// List<R> getRatesList(String path) throws CustomException;
//
// /**
// * to get Transactions list
// **/
// List<T> getTransactionsList(String path) throws CustomException;
//
// /**
// * to get Transactions per product's SKU
// **/
// List<T> getTransactionsPerSku(String mPathTransactions, String mSku);
//
// /**
// * to save Transactions indexed per product's SKU
// **/
// boolean saveTransactions(Map<String, List<T>> map);
// }
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/components/ApplicationComponent.java
import android.app.Application;
import android.content.Context;
import com.raulh82vlc.TransactionsViewer.TransactionsViewerApp;
import com.raulh82vlc.TransactionsViewer.di.modules.ApplicationModule;
import com.raulh82vlc.TransactionsViewer.di.modules.RepositoryModule;
import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor;
import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread;
import com.raulh82vlc.TransactionsViewer.domain.repository.DataRepository;
import javax.inject.Singleton;
import dagger.Component;
/*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.di.components;
/**
* ApplicationComponent is the top level component for this architecture.
* It provides generic dependencies such as
* {@link MainThread} or {@link InteractorExecutor}
* and makes them available to sub-components and other external dependant classes.
* <p/>
* Scope {@link Singleton} is used to limit dependency instances across whole execution.
*
* @author Raul Hernandez Lopez
*/
@Singleton
@Component(
modules = {
ApplicationModule.class,
RepositoryModule.class
})
public interface ApplicationComponent {
/**
* Injections for the dependencies
*/ | void inject(TransactionsViewerApp app); |
raulh82vlc/Transactions-Viewer | android/src/main/java/com/raulh82vlc/TransactionsViewer/di/components/ApplicationComponent.java | // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/TransactionsViewerApp.java
// public class TransactionsViewerApp extends Application {
//
// private ApplicationComponent applicationComponent;
//
// @Override
// public void onCreate() {
// super.onCreate();
// applicationComponent = DaggerApplicationComponent.builder()
// .applicationModule(new ApplicationModule(this))
// .build();
// }
//
// public ApplicationComponent component() {
// return applicationComponent;
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/modules/ApplicationModule.java
// @Module
// public class ApplicationModule {
// private final Application application;
//
// public ApplicationModule(Application application) {
// this.application = application;
// }
//
// @Provides
// @Singleton
// Application provideApplication() {
// return application;
// }
//
// @Provides
// @Singleton
// InteractorExecutor provideThreadsPoolExecutor(ThreadsPoolExecutor executor) {
// return executor;
// }
//
// @Provides
// @Singleton
// MainThread providePostExecutionThread(MainThreadImpl mainThread) {
// return mainThread;
// }
//
// @Provides
// @Singleton
// Context provideApplicationContext() {
// return application.getApplicationContext();
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/modules/RepositoryModule.java
// @Module
// public class RepositoryModule {
// @Provides
// @Singleton
// DataRepository provideRepository(JSONRepositoryImpl repository) {
// return repository;
// }
//
// @Provides
// @Singleton
// JSONDataSource provideJSONDataSource(JSONDataSourceImpl dataSource) {
// return dataSource;
// }
//
// @Provides
// @Singleton
// JSONOperations provideJSONOperations(JSONOperationsImpl jsonOperations) {
// return jsonOperations;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java
// public interface InteractorExecutor {
// void run(Interactor interactor) throws CustomException;
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java
// public interface MainThread {
// void post(final Runnable runnable);
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/DataRepository.java
// public interface DataRepository<R, T> {
//
// /**
// * to get Rates List
// **/
// List<R> getRatesList(String path) throws CustomException;
//
// /**
// * to get Transactions list
// **/
// List<T> getTransactionsList(String path) throws CustomException;
//
// /**
// * to get Transactions per product's SKU
// **/
// List<T> getTransactionsPerSku(String mPathTransactions, String mSku);
//
// /**
// * to save Transactions indexed per product's SKU
// **/
// boolean saveTransactions(Map<String, List<T>> map);
// }
| import android.app.Application;
import android.content.Context;
import com.raulh82vlc.TransactionsViewer.TransactionsViewerApp;
import com.raulh82vlc.TransactionsViewer.di.modules.ApplicationModule;
import com.raulh82vlc.TransactionsViewer.di.modules.RepositoryModule;
import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor;
import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread;
import com.raulh82vlc.TransactionsViewer.domain.repository.DataRepository;
import javax.inject.Singleton;
import dagger.Component; | /*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.di.components;
/**
* ApplicationComponent is the top level component for this architecture.
* It provides generic dependencies such as
* {@link MainThread} or {@link InteractorExecutor}
* and makes them available to sub-components and other external dependant classes.
* <p/>
* Scope {@link Singleton} is used to limit dependency instances across whole execution.
*
* @author Raul Hernandez Lopez
*/
@Singleton
@Component(
modules = {
ApplicationModule.class,
RepositoryModule.class
})
public interface ApplicationComponent {
/**
* Injections for the dependencies
*/
void inject(TransactionsViewerApp app);
void inject(Context context);
/**
* Used in child components
*/
Application application();
/**
* Background processes executor (interactors use this)
*/ | // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/TransactionsViewerApp.java
// public class TransactionsViewerApp extends Application {
//
// private ApplicationComponent applicationComponent;
//
// @Override
// public void onCreate() {
// super.onCreate();
// applicationComponent = DaggerApplicationComponent.builder()
// .applicationModule(new ApplicationModule(this))
// .build();
// }
//
// public ApplicationComponent component() {
// return applicationComponent;
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/modules/ApplicationModule.java
// @Module
// public class ApplicationModule {
// private final Application application;
//
// public ApplicationModule(Application application) {
// this.application = application;
// }
//
// @Provides
// @Singleton
// Application provideApplication() {
// return application;
// }
//
// @Provides
// @Singleton
// InteractorExecutor provideThreadsPoolExecutor(ThreadsPoolExecutor executor) {
// return executor;
// }
//
// @Provides
// @Singleton
// MainThread providePostExecutionThread(MainThreadImpl mainThread) {
// return mainThread;
// }
//
// @Provides
// @Singleton
// Context provideApplicationContext() {
// return application.getApplicationContext();
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/modules/RepositoryModule.java
// @Module
// public class RepositoryModule {
// @Provides
// @Singleton
// DataRepository provideRepository(JSONRepositoryImpl repository) {
// return repository;
// }
//
// @Provides
// @Singleton
// JSONDataSource provideJSONDataSource(JSONDataSourceImpl dataSource) {
// return dataSource;
// }
//
// @Provides
// @Singleton
// JSONOperations provideJSONOperations(JSONOperationsImpl jsonOperations) {
// return jsonOperations;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java
// public interface InteractorExecutor {
// void run(Interactor interactor) throws CustomException;
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java
// public interface MainThread {
// void post(final Runnable runnable);
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/DataRepository.java
// public interface DataRepository<R, T> {
//
// /**
// * to get Rates List
// **/
// List<R> getRatesList(String path) throws CustomException;
//
// /**
// * to get Transactions list
// **/
// List<T> getTransactionsList(String path) throws CustomException;
//
// /**
// * to get Transactions per product's SKU
// **/
// List<T> getTransactionsPerSku(String mPathTransactions, String mSku);
//
// /**
// * to save Transactions indexed per product's SKU
// **/
// boolean saveTransactions(Map<String, List<T>> map);
// }
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/components/ApplicationComponent.java
import android.app.Application;
import android.content.Context;
import com.raulh82vlc.TransactionsViewer.TransactionsViewerApp;
import com.raulh82vlc.TransactionsViewer.di.modules.ApplicationModule;
import com.raulh82vlc.TransactionsViewer.di.modules.RepositoryModule;
import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor;
import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread;
import com.raulh82vlc.TransactionsViewer.domain.repository.DataRepository;
import javax.inject.Singleton;
import dagger.Component;
/*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.di.components;
/**
* ApplicationComponent is the top level component for this architecture.
* It provides generic dependencies such as
* {@link MainThread} or {@link InteractorExecutor}
* and makes them available to sub-components and other external dependant classes.
* <p/>
* Scope {@link Singleton} is used to limit dependency instances across whole execution.
*
* @author Raul Hernandez Lopez
*/
@Singleton
@Component(
modules = {
ApplicationModule.class,
RepositoryModule.class
})
public interface ApplicationComponent {
/**
* Injections for the dependencies
*/
void inject(TransactionsViewerApp app);
void inject(Context context);
/**
* Used in child components
*/
Application application();
/**
* Background processes executor (interactors use this)
*/ | InteractorExecutor threadExecutor(); |
raulh82vlc/Transactions-Viewer | android/src/main/java/com/raulh82vlc/TransactionsViewer/di/components/ApplicationComponent.java | // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/TransactionsViewerApp.java
// public class TransactionsViewerApp extends Application {
//
// private ApplicationComponent applicationComponent;
//
// @Override
// public void onCreate() {
// super.onCreate();
// applicationComponent = DaggerApplicationComponent.builder()
// .applicationModule(new ApplicationModule(this))
// .build();
// }
//
// public ApplicationComponent component() {
// return applicationComponent;
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/modules/ApplicationModule.java
// @Module
// public class ApplicationModule {
// private final Application application;
//
// public ApplicationModule(Application application) {
// this.application = application;
// }
//
// @Provides
// @Singleton
// Application provideApplication() {
// return application;
// }
//
// @Provides
// @Singleton
// InteractorExecutor provideThreadsPoolExecutor(ThreadsPoolExecutor executor) {
// return executor;
// }
//
// @Provides
// @Singleton
// MainThread providePostExecutionThread(MainThreadImpl mainThread) {
// return mainThread;
// }
//
// @Provides
// @Singleton
// Context provideApplicationContext() {
// return application.getApplicationContext();
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/modules/RepositoryModule.java
// @Module
// public class RepositoryModule {
// @Provides
// @Singleton
// DataRepository provideRepository(JSONRepositoryImpl repository) {
// return repository;
// }
//
// @Provides
// @Singleton
// JSONDataSource provideJSONDataSource(JSONDataSourceImpl dataSource) {
// return dataSource;
// }
//
// @Provides
// @Singleton
// JSONOperations provideJSONOperations(JSONOperationsImpl jsonOperations) {
// return jsonOperations;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java
// public interface InteractorExecutor {
// void run(Interactor interactor) throws CustomException;
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java
// public interface MainThread {
// void post(final Runnable runnable);
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/DataRepository.java
// public interface DataRepository<R, T> {
//
// /**
// * to get Rates List
// **/
// List<R> getRatesList(String path) throws CustomException;
//
// /**
// * to get Transactions list
// **/
// List<T> getTransactionsList(String path) throws CustomException;
//
// /**
// * to get Transactions per product's SKU
// **/
// List<T> getTransactionsPerSku(String mPathTransactions, String mSku);
//
// /**
// * to save Transactions indexed per product's SKU
// **/
// boolean saveTransactions(Map<String, List<T>> map);
// }
| import android.app.Application;
import android.content.Context;
import com.raulh82vlc.TransactionsViewer.TransactionsViewerApp;
import com.raulh82vlc.TransactionsViewer.di.modules.ApplicationModule;
import com.raulh82vlc.TransactionsViewer.di.modules.RepositoryModule;
import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor;
import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread;
import com.raulh82vlc.TransactionsViewer.domain.repository.DataRepository;
import javax.inject.Singleton;
import dagger.Component; | /*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.di.components;
/**
* ApplicationComponent is the top level component for this architecture.
* It provides generic dependencies such as
* {@link MainThread} or {@link InteractorExecutor}
* and makes them available to sub-components and other external dependant classes.
* <p/>
* Scope {@link Singleton} is used to limit dependency instances across whole execution.
*
* @author Raul Hernandez Lopez
*/
@Singleton
@Component(
modules = {
ApplicationModule.class,
RepositoryModule.class
})
public interface ApplicationComponent {
/**
* Injections for the dependencies
*/
void inject(TransactionsViewerApp app);
void inject(Context context);
/**
* Used in child components
*/
Application application();
/**
* Background processes executor (interactors use this)
*/
InteractorExecutor threadExecutor();
/**
* Direct contact to UI thread
*/ | // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/TransactionsViewerApp.java
// public class TransactionsViewerApp extends Application {
//
// private ApplicationComponent applicationComponent;
//
// @Override
// public void onCreate() {
// super.onCreate();
// applicationComponent = DaggerApplicationComponent.builder()
// .applicationModule(new ApplicationModule(this))
// .build();
// }
//
// public ApplicationComponent component() {
// return applicationComponent;
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/modules/ApplicationModule.java
// @Module
// public class ApplicationModule {
// private final Application application;
//
// public ApplicationModule(Application application) {
// this.application = application;
// }
//
// @Provides
// @Singleton
// Application provideApplication() {
// return application;
// }
//
// @Provides
// @Singleton
// InteractorExecutor provideThreadsPoolExecutor(ThreadsPoolExecutor executor) {
// return executor;
// }
//
// @Provides
// @Singleton
// MainThread providePostExecutionThread(MainThreadImpl mainThread) {
// return mainThread;
// }
//
// @Provides
// @Singleton
// Context provideApplicationContext() {
// return application.getApplicationContext();
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/modules/RepositoryModule.java
// @Module
// public class RepositoryModule {
// @Provides
// @Singleton
// DataRepository provideRepository(JSONRepositoryImpl repository) {
// return repository;
// }
//
// @Provides
// @Singleton
// JSONDataSource provideJSONDataSource(JSONDataSourceImpl dataSource) {
// return dataSource;
// }
//
// @Provides
// @Singleton
// JSONOperations provideJSONOperations(JSONOperationsImpl jsonOperations) {
// return jsonOperations;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java
// public interface InteractorExecutor {
// void run(Interactor interactor) throws CustomException;
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java
// public interface MainThread {
// void post(final Runnable runnable);
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/DataRepository.java
// public interface DataRepository<R, T> {
//
// /**
// * to get Rates List
// **/
// List<R> getRatesList(String path) throws CustomException;
//
// /**
// * to get Transactions list
// **/
// List<T> getTransactionsList(String path) throws CustomException;
//
// /**
// * to get Transactions per product's SKU
// **/
// List<T> getTransactionsPerSku(String mPathTransactions, String mSku);
//
// /**
// * to save Transactions indexed per product's SKU
// **/
// boolean saveTransactions(Map<String, List<T>> map);
// }
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/components/ApplicationComponent.java
import android.app.Application;
import android.content.Context;
import com.raulh82vlc.TransactionsViewer.TransactionsViewerApp;
import com.raulh82vlc.TransactionsViewer.di.modules.ApplicationModule;
import com.raulh82vlc.TransactionsViewer.di.modules.RepositoryModule;
import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor;
import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread;
import com.raulh82vlc.TransactionsViewer.domain.repository.DataRepository;
import javax.inject.Singleton;
import dagger.Component;
/*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.di.components;
/**
* ApplicationComponent is the top level component for this architecture.
* It provides generic dependencies such as
* {@link MainThread} or {@link InteractorExecutor}
* and makes them available to sub-components and other external dependant classes.
* <p/>
* Scope {@link Singleton} is used to limit dependency instances across whole execution.
*
* @author Raul Hernandez Lopez
*/
@Singleton
@Component(
modules = {
ApplicationModule.class,
RepositoryModule.class
})
public interface ApplicationComponent {
/**
* Injections for the dependencies
*/
void inject(TransactionsViewerApp app);
void inject(Context context);
/**
* Used in child components
*/
Application application();
/**
* Background processes executor (interactors use this)
*/
InteractorExecutor threadExecutor();
/**
* Direct contact to UI thread
*/ | MainThread mainThread(); |
raulh82vlc/Transactions-Viewer | android/src/main/java/com/raulh82vlc/TransactionsViewer/di/components/ApplicationComponent.java | // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/TransactionsViewerApp.java
// public class TransactionsViewerApp extends Application {
//
// private ApplicationComponent applicationComponent;
//
// @Override
// public void onCreate() {
// super.onCreate();
// applicationComponent = DaggerApplicationComponent.builder()
// .applicationModule(new ApplicationModule(this))
// .build();
// }
//
// public ApplicationComponent component() {
// return applicationComponent;
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/modules/ApplicationModule.java
// @Module
// public class ApplicationModule {
// private final Application application;
//
// public ApplicationModule(Application application) {
// this.application = application;
// }
//
// @Provides
// @Singleton
// Application provideApplication() {
// return application;
// }
//
// @Provides
// @Singleton
// InteractorExecutor provideThreadsPoolExecutor(ThreadsPoolExecutor executor) {
// return executor;
// }
//
// @Provides
// @Singleton
// MainThread providePostExecutionThread(MainThreadImpl mainThread) {
// return mainThread;
// }
//
// @Provides
// @Singleton
// Context provideApplicationContext() {
// return application.getApplicationContext();
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/modules/RepositoryModule.java
// @Module
// public class RepositoryModule {
// @Provides
// @Singleton
// DataRepository provideRepository(JSONRepositoryImpl repository) {
// return repository;
// }
//
// @Provides
// @Singleton
// JSONDataSource provideJSONDataSource(JSONDataSourceImpl dataSource) {
// return dataSource;
// }
//
// @Provides
// @Singleton
// JSONOperations provideJSONOperations(JSONOperationsImpl jsonOperations) {
// return jsonOperations;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java
// public interface InteractorExecutor {
// void run(Interactor interactor) throws CustomException;
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java
// public interface MainThread {
// void post(final Runnable runnable);
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/DataRepository.java
// public interface DataRepository<R, T> {
//
// /**
// * to get Rates List
// **/
// List<R> getRatesList(String path) throws CustomException;
//
// /**
// * to get Transactions list
// **/
// List<T> getTransactionsList(String path) throws CustomException;
//
// /**
// * to get Transactions per product's SKU
// **/
// List<T> getTransactionsPerSku(String mPathTransactions, String mSku);
//
// /**
// * to save Transactions indexed per product's SKU
// **/
// boolean saveTransactions(Map<String, List<T>> map);
// }
| import android.app.Application;
import android.content.Context;
import com.raulh82vlc.TransactionsViewer.TransactionsViewerApp;
import com.raulh82vlc.TransactionsViewer.di.modules.ApplicationModule;
import com.raulh82vlc.TransactionsViewer.di.modules.RepositoryModule;
import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor;
import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread;
import com.raulh82vlc.TransactionsViewer.domain.repository.DataRepository;
import javax.inject.Singleton;
import dagger.Component; | /*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.di.components;
/**
* ApplicationComponent is the top level component for this architecture.
* It provides generic dependencies such as
* {@link MainThread} or {@link InteractorExecutor}
* and makes them available to sub-components and other external dependant classes.
* <p/>
* Scope {@link Singleton} is used to limit dependency instances across whole execution.
*
* @author Raul Hernandez Lopez
*/
@Singleton
@Component(
modules = {
ApplicationModule.class,
RepositoryModule.class
})
public interface ApplicationComponent {
/**
* Injections for the dependencies
*/
void inject(TransactionsViewerApp app);
void inject(Context context);
/**
* Used in child components
*/
Application application();
/**
* Background processes executor (interactors use this)
*/
InteractorExecutor threadExecutor();
/**
* Direct contact to UI thread
*/
MainThread mainThread();
/**
* Direct contact to repo
*/ | // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/TransactionsViewerApp.java
// public class TransactionsViewerApp extends Application {
//
// private ApplicationComponent applicationComponent;
//
// @Override
// public void onCreate() {
// super.onCreate();
// applicationComponent = DaggerApplicationComponent.builder()
// .applicationModule(new ApplicationModule(this))
// .build();
// }
//
// public ApplicationComponent component() {
// return applicationComponent;
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/modules/ApplicationModule.java
// @Module
// public class ApplicationModule {
// private final Application application;
//
// public ApplicationModule(Application application) {
// this.application = application;
// }
//
// @Provides
// @Singleton
// Application provideApplication() {
// return application;
// }
//
// @Provides
// @Singleton
// InteractorExecutor provideThreadsPoolExecutor(ThreadsPoolExecutor executor) {
// return executor;
// }
//
// @Provides
// @Singleton
// MainThread providePostExecutionThread(MainThreadImpl mainThread) {
// return mainThread;
// }
//
// @Provides
// @Singleton
// Context provideApplicationContext() {
// return application.getApplicationContext();
// }
// }
//
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/modules/RepositoryModule.java
// @Module
// public class RepositoryModule {
// @Provides
// @Singleton
// DataRepository provideRepository(JSONRepositoryImpl repository) {
// return repository;
// }
//
// @Provides
// @Singleton
// JSONDataSource provideJSONDataSource(JSONDataSourceImpl dataSource) {
// return dataSource;
// }
//
// @Provides
// @Singleton
// JSONOperations provideJSONOperations(JSONOperationsImpl jsonOperations) {
// return jsonOperations;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java
// public interface InteractorExecutor {
// void run(Interactor interactor) throws CustomException;
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java
// public interface MainThread {
// void post(final Runnable runnable);
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/DataRepository.java
// public interface DataRepository<R, T> {
//
// /**
// * to get Rates List
// **/
// List<R> getRatesList(String path) throws CustomException;
//
// /**
// * to get Transactions list
// **/
// List<T> getTransactionsList(String path) throws CustomException;
//
// /**
// * to get Transactions per product's SKU
// **/
// List<T> getTransactionsPerSku(String mPathTransactions, String mSku);
//
// /**
// * to save Transactions indexed per product's SKU
// **/
// boolean saveTransactions(Map<String, List<T>> map);
// }
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/components/ApplicationComponent.java
import android.app.Application;
import android.content.Context;
import com.raulh82vlc.TransactionsViewer.TransactionsViewerApp;
import com.raulh82vlc.TransactionsViewer.di.modules.ApplicationModule;
import com.raulh82vlc.TransactionsViewer.di.modules.RepositoryModule;
import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor;
import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread;
import com.raulh82vlc.TransactionsViewer.domain.repository.DataRepository;
import javax.inject.Singleton;
import dagger.Component;
/*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.di.components;
/**
* ApplicationComponent is the top level component for this architecture.
* It provides generic dependencies such as
* {@link MainThread} or {@link InteractorExecutor}
* and makes them available to sub-components and other external dependant classes.
* <p/>
* Scope {@link Singleton} is used to limit dependency instances across whole execution.
*
* @author Raul Hernandez Lopez
*/
@Singleton
@Component(
modules = {
ApplicationModule.class,
RepositoryModule.class
})
public interface ApplicationComponent {
/**
* Injections for the dependencies
*/
void inject(TransactionsViewerApp app);
void inject(Context context);
/**
* Used in child components
*/
Application application();
/**
* Background processes executor (interactors use this)
*/
InteractorExecutor threadExecutor();
/**
* Direct contact to UI thread
*/
MainThread mainThread();
/**
* Direct contact to repo
*/ | DataRepository dataRepo(); |
raulh82vlc/Transactions-Viewer | android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/TransactionsListModelDataMapper.java | // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/ProductUI.java
// public class ProductUI implements Parcelable {
//
// private String sku;
// private List<TransactionUI> transactions;
//
// public static final Creator<ProductUI> CREATOR = new Creator<ProductUI>() {
// @Override
// public ProductUI createFromParcel(Parcel in) {
// return new ProductUI(in);
// }
//
// @Override
// public ProductUI[] newArray(int size) {
// return new ProductUI[size];
// }
// };
//
// private ProductUI(Parcel in) {
// sku = in.readString();
// if (transactions == null) {
// transactions = new ArrayList<>();
// }
// in.readList(transactions, Transaction.class.getClassLoader());
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(sku);
// dest.writeList(transactions);
// }
//
// public ProductUI(String key, List<Transaction> values, String toCurrency) {
// sku = key;
// transactions = new ArrayList<>(values.size());
// for (Transaction transaction : values) {
// transactions.add(new TransactionUI(transaction.getCurrency(), toCurrency,
// transaction.getAmountPerTransaction(), "0"));
// }
//
// }
//
// public List<TransactionUI> getTransactions() {
// return transactions;
// }
//
// public String getSku() {
// return sku;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java
// public class Transaction {
//
// @SerializedName("sku")
// private String skuIdentifier;
//
// @SerializedName("amount")
// private String amountPerTransaction;
//
// @SerializedName("currency")
// private String currency;
//
// public String getSkuIdentifier() {
// return skuIdentifier;
// }
//
// public String getAmountPerTransaction() {
// return amountPerTransaction;
// }
//
// public String getCurrency() {
// return currency;
// }
// }
| import com.raulh82vlc.TransactionsViewer.di.scopes.ActivityScope;
import com.raulh82vlc.TransactionsViewer.domain.models.ProductUI;
import com.raulh82vlc.TransactionsViewer.domain.models.Transaction;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import javax.inject.Inject; | /*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.domain.interactors.mappers;
/**
* Mapper conversion from Movie model of the API to Movie model of the UI
*
* @author Raul Hernandez Lopez
*/
@ActivityScope
public class TransactionsListModelDataMapper {
private static final String GBP = "GBP";
@Inject
TransactionsListModelDataMapper() {
}
/**
* Transforms a List {@link Transaction} into an TreeMap of {@link Transaction}
* to maintain the order from A to Z sorted.
*/ | // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/ProductUI.java
// public class ProductUI implements Parcelable {
//
// private String sku;
// private List<TransactionUI> transactions;
//
// public static final Creator<ProductUI> CREATOR = new Creator<ProductUI>() {
// @Override
// public ProductUI createFromParcel(Parcel in) {
// return new ProductUI(in);
// }
//
// @Override
// public ProductUI[] newArray(int size) {
// return new ProductUI[size];
// }
// };
//
// private ProductUI(Parcel in) {
// sku = in.readString();
// if (transactions == null) {
// transactions = new ArrayList<>();
// }
// in.readList(transactions, Transaction.class.getClassLoader());
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(sku);
// dest.writeList(transactions);
// }
//
// public ProductUI(String key, List<Transaction> values, String toCurrency) {
// sku = key;
// transactions = new ArrayList<>(values.size());
// for (Transaction transaction : values) {
// transactions.add(new TransactionUI(transaction.getCurrency(), toCurrency,
// transaction.getAmountPerTransaction(), "0"));
// }
//
// }
//
// public List<TransactionUI> getTransactions() {
// return transactions;
// }
//
// public String getSku() {
// return sku;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java
// public class Transaction {
//
// @SerializedName("sku")
// private String skuIdentifier;
//
// @SerializedName("amount")
// private String amountPerTransaction;
//
// @SerializedName("currency")
// private String currency;
//
// public String getSkuIdentifier() {
// return skuIdentifier;
// }
//
// public String getAmountPerTransaction() {
// return amountPerTransaction;
// }
//
// public String getCurrency() {
// return currency;
// }
// }
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/TransactionsListModelDataMapper.java
import com.raulh82vlc.TransactionsViewer.di.scopes.ActivityScope;
import com.raulh82vlc.TransactionsViewer.domain.models.ProductUI;
import com.raulh82vlc.TransactionsViewer.domain.models.Transaction;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import javax.inject.Inject;
/*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.domain.interactors.mappers;
/**
* Mapper conversion from Movie model of the API to Movie model of the UI
*
* @author Raul Hernandez Lopez
*/
@ActivityScope
public class TransactionsListModelDataMapper {
private static final String GBP = "GBP";
@Inject
TransactionsListModelDataMapper() {
}
/**
* Transforms a List {@link Transaction} into an TreeMap of {@link Transaction}
* to maintain the order from A to Z sorted.
*/ | public TreeMap<String, List<Transaction>> transform(List<Transaction> transactionList) { |
raulh82vlc/Transactions-Viewer | android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/TransactionsListModelDataMapper.java | // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/ProductUI.java
// public class ProductUI implements Parcelable {
//
// private String sku;
// private List<TransactionUI> transactions;
//
// public static final Creator<ProductUI> CREATOR = new Creator<ProductUI>() {
// @Override
// public ProductUI createFromParcel(Parcel in) {
// return new ProductUI(in);
// }
//
// @Override
// public ProductUI[] newArray(int size) {
// return new ProductUI[size];
// }
// };
//
// private ProductUI(Parcel in) {
// sku = in.readString();
// if (transactions == null) {
// transactions = new ArrayList<>();
// }
// in.readList(transactions, Transaction.class.getClassLoader());
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(sku);
// dest.writeList(transactions);
// }
//
// public ProductUI(String key, List<Transaction> values, String toCurrency) {
// sku = key;
// transactions = new ArrayList<>(values.size());
// for (Transaction transaction : values) {
// transactions.add(new TransactionUI(transaction.getCurrency(), toCurrency,
// transaction.getAmountPerTransaction(), "0"));
// }
//
// }
//
// public List<TransactionUI> getTransactions() {
// return transactions;
// }
//
// public String getSku() {
// return sku;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java
// public class Transaction {
//
// @SerializedName("sku")
// private String skuIdentifier;
//
// @SerializedName("amount")
// private String amountPerTransaction;
//
// @SerializedName("currency")
// private String currency;
//
// public String getSkuIdentifier() {
// return skuIdentifier;
// }
//
// public String getAmountPerTransaction() {
// return amountPerTransaction;
// }
//
// public String getCurrency() {
// return currency;
// }
// }
| import com.raulh82vlc.TransactionsViewer.di.scopes.ActivityScope;
import com.raulh82vlc.TransactionsViewer.domain.models.ProductUI;
import com.raulh82vlc.TransactionsViewer.domain.models.Transaction;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import javax.inject.Inject; | /*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.domain.interactors.mappers;
/**
* Mapper conversion from Movie model of the API to Movie model of the UI
*
* @author Raul Hernandez Lopez
*/
@ActivityScope
public class TransactionsListModelDataMapper {
private static final String GBP = "GBP";
@Inject
TransactionsListModelDataMapper() {
}
/**
* Transforms a List {@link Transaction} into an TreeMap of {@link Transaction}
* to maintain the order from A to Z sorted.
*/
public TreeMap<String, List<Transaction>> transform(List<Transaction> transactionList) {
if (transactionList == null) {
throw new IllegalArgumentException("Cannot transform a null value");
}
TreeMap<String, List<Transaction>> map = new TreeMap<>();
for (Transaction transaction : transactionList) {
String key = transaction.getSkuIdentifier();
if (map.containsKey(key)) {
map.get(key).add(transaction);
} else {
List<Transaction> transactions = new ArrayList<>();
transactions.add(transaction);
map.put(key, transactions);
}
}
return map;
}
| // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/ProductUI.java
// public class ProductUI implements Parcelable {
//
// private String sku;
// private List<TransactionUI> transactions;
//
// public static final Creator<ProductUI> CREATOR = new Creator<ProductUI>() {
// @Override
// public ProductUI createFromParcel(Parcel in) {
// return new ProductUI(in);
// }
//
// @Override
// public ProductUI[] newArray(int size) {
// return new ProductUI[size];
// }
// };
//
// private ProductUI(Parcel in) {
// sku = in.readString();
// if (transactions == null) {
// transactions = new ArrayList<>();
// }
// in.readList(transactions, Transaction.class.getClassLoader());
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(sku);
// dest.writeList(transactions);
// }
//
// public ProductUI(String key, List<Transaction> values, String toCurrency) {
// sku = key;
// transactions = new ArrayList<>(values.size());
// for (Transaction transaction : values) {
// transactions.add(new TransactionUI(transaction.getCurrency(), toCurrency,
// transaction.getAmountPerTransaction(), "0"));
// }
//
// }
//
// public List<TransactionUI> getTransactions() {
// return transactions;
// }
//
// public String getSku() {
// return sku;
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java
// public class Transaction {
//
// @SerializedName("sku")
// private String skuIdentifier;
//
// @SerializedName("amount")
// private String amountPerTransaction;
//
// @SerializedName("currency")
// private String currency;
//
// public String getSkuIdentifier() {
// return skuIdentifier;
// }
//
// public String getAmountPerTransaction() {
// return amountPerTransaction;
// }
//
// public String getCurrency() {
// return currency;
// }
// }
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/TransactionsListModelDataMapper.java
import com.raulh82vlc.TransactionsViewer.di.scopes.ActivityScope;
import com.raulh82vlc.TransactionsViewer.domain.models.ProductUI;
import com.raulh82vlc.TransactionsViewer.domain.models.Transaction;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import javax.inject.Inject;
/*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.domain.interactors.mappers;
/**
* Mapper conversion from Movie model of the API to Movie model of the UI
*
* @author Raul Hernandez Lopez
*/
@ActivityScope
public class TransactionsListModelDataMapper {
private static final String GBP = "GBP";
@Inject
TransactionsListModelDataMapper() {
}
/**
* Transforms a List {@link Transaction} into an TreeMap of {@link Transaction}
* to maintain the order from A to Z sorted.
*/
public TreeMap<String, List<Transaction>> transform(List<Transaction> transactionList) {
if (transactionList == null) {
throw new IllegalArgumentException("Cannot transform a null value");
}
TreeMap<String, List<Transaction>> map = new TreeMap<>();
for (Transaction transaction : transactionList) {
String key = transaction.getSkuIdentifier();
if (map.containsKey(key)) {
map.get(key).add(transaction);
} else {
List<Transaction> transactions = new ArrayList<>();
transactions.add(transaction);
map.put(key, transactions);
}
}
return map;
}
| public List<ProductUI> transform(Map<String, List<Transaction>> transactionsDictionary) { |
raulh82vlc/Transactions-Viewer | domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/ComputeTransactionsInteractor.java | // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java
// public class CustomException extends Exception {
// public CustomException(String detailMessage) {
// super(detailMessage);
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/TransactionRatedDomain.java
// public class TransactionRatedDomain {
// private BigDecimal amounPerTransactionPrev;
// private BigDecimal amountPerTransactionCurrent;
// private String currencyPrev;
// private String currencyCurrent;
//
// public TransactionRatedDomain(String currencyPrev, String currencyCurrent,
// BigDecimal amounPerTransactionPrev,
// BigDecimal amountPerTransactionCurrent) {
// this.currencyPrev = currencyPrev;
// this.currencyCurrent = currencyCurrent;
// this.amounPerTransactionPrev = amounPerTransactionPrev;
// this.amountPerTransactionCurrent = amountPerTransactionCurrent;
// }
//
// public BigDecimal getAmounPerTransactionPrev() {
// return amounPerTransactionPrev;
// }
//
// public BigDecimal getAmountPerTransactionCurrent() {
// return amountPerTransactionCurrent;
// }
//
// public String getCurrencyPrev() {
// return currencyPrev;
// }
//
// public String getCurrencyCurrent() {
// return currencyCurrent;
// }
//
// }
| import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException;
import com.raulh82vlc.TransactionsViewer.domain.models.TransactionRatedDomain;
import java.util.List; | /*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.domain.interactors;
/**
* Interactor which Computes Transactions to its different currency
*
* @author Raul Hernandez Lopez.
*/
public interface ComputeTransactionsInteractor {
void execute(String skuFromProduct,
GetTransactionsComputedCallback getTransactionsComputedCallback,
String toCurrency, | // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java
// public class CustomException extends Exception {
// public CustomException(String detailMessage) {
// super(detailMessage);
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/TransactionRatedDomain.java
// public class TransactionRatedDomain {
// private BigDecimal amounPerTransactionPrev;
// private BigDecimal amountPerTransactionCurrent;
// private String currencyPrev;
// private String currencyCurrent;
//
// public TransactionRatedDomain(String currencyPrev, String currencyCurrent,
// BigDecimal amounPerTransactionPrev,
// BigDecimal amountPerTransactionCurrent) {
// this.currencyPrev = currencyPrev;
// this.currencyCurrent = currencyCurrent;
// this.amounPerTransactionPrev = amounPerTransactionPrev;
// this.amountPerTransactionCurrent = amountPerTransactionCurrent;
// }
//
// public BigDecimal getAmounPerTransactionPrev() {
// return amounPerTransactionPrev;
// }
//
// public BigDecimal getAmountPerTransactionCurrent() {
// return amountPerTransactionCurrent;
// }
//
// public String getCurrencyPrev() {
// return currencyPrev;
// }
//
// public String getCurrencyCurrent() {
// return currencyCurrent;
// }
//
// }
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/ComputeTransactionsInteractor.java
import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException;
import com.raulh82vlc.TransactionsViewer.domain.models.TransactionRatedDomain;
import java.util.List;
/*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.domain.interactors;
/**
* Interactor which Computes Transactions to its different currency
*
* @author Raul Hernandez Lopez.
*/
public interface ComputeTransactionsInteractor {
void execute(String skuFromProduct,
GetTransactionsComputedCallback getTransactionsComputedCallback,
String toCurrency, | String pathTransactions, String pathRates) throws CustomException; |
raulh82vlc/Transactions-Viewer | domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/ComputeTransactionsInteractor.java | // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java
// public class CustomException extends Exception {
// public CustomException(String detailMessage) {
// super(detailMessage);
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/TransactionRatedDomain.java
// public class TransactionRatedDomain {
// private BigDecimal amounPerTransactionPrev;
// private BigDecimal amountPerTransactionCurrent;
// private String currencyPrev;
// private String currencyCurrent;
//
// public TransactionRatedDomain(String currencyPrev, String currencyCurrent,
// BigDecimal amounPerTransactionPrev,
// BigDecimal amountPerTransactionCurrent) {
// this.currencyPrev = currencyPrev;
// this.currencyCurrent = currencyCurrent;
// this.amounPerTransactionPrev = amounPerTransactionPrev;
// this.amountPerTransactionCurrent = amountPerTransactionCurrent;
// }
//
// public BigDecimal getAmounPerTransactionPrev() {
// return amounPerTransactionPrev;
// }
//
// public BigDecimal getAmountPerTransactionCurrent() {
// return amountPerTransactionCurrent;
// }
//
// public String getCurrencyPrev() {
// return currencyPrev;
// }
//
// public String getCurrencyCurrent() {
// return currencyCurrent;
// }
//
// }
| import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException;
import com.raulh82vlc.TransactionsViewer.domain.models.TransactionRatedDomain;
import java.util.List; | /*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.domain.interactors;
/**
* Interactor which Computes Transactions to its different currency
*
* @author Raul Hernandez Lopez.
*/
public interface ComputeTransactionsInteractor {
void execute(String skuFromProduct,
GetTransactionsComputedCallback getTransactionsComputedCallback,
String toCurrency,
String pathTransactions, String pathRates) throws CustomException;
interface GetTransactionsComputedCallback { | // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java
// public class CustomException extends Exception {
// public CustomException(String detailMessage) {
// super(detailMessage);
// }
// }
//
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/TransactionRatedDomain.java
// public class TransactionRatedDomain {
// private BigDecimal amounPerTransactionPrev;
// private BigDecimal amountPerTransactionCurrent;
// private String currencyPrev;
// private String currencyCurrent;
//
// public TransactionRatedDomain(String currencyPrev, String currencyCurrent,
// BigDecimal amounPerTransactionPrev,
// BigDecimal amountPerTransactionCurrent) {
// this.currencyPrev = currencyPrev;
// this.currencyCurrent = currencyCurrent;
// this.amounPerTransactionPrev = amounPerTransactionPrev;
// this.amountPerTransactionCurrent = amountPerTransactionCurrent;
// }
//
// public BigDecimal getAmounPerTransactionPrev() {
// return amounPerTransactionPrev;
// }
//
// public BigDecimal getAmountPerTransactionCurrent() {
// return amountPerTransactionCurrent;
// }
//
// public String getCurrencyPrev() {
// return currencyPrev;
// }
//
// public String getCurrencyCurrent() {
// return currencyCurrent;
// }
//
// }
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/ComputeTransactionsInteractor.java
import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException;
import com.raulh82vlc.TransactionsViewer.domain.models.TransactionRatedDomain;
import java.util.List;
/*
* Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc
*
* 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 com.raulh82vlc.TransactionsViewer.domain.interactors;
/**
* Interactor which Computes Transactions to its different currency
*
* @author Raul Hernandez Lopez.
*/
public interface ComputeTransactionsInteractor {
void execute(String skuFromProduct,
GetTransactionsComputedCallback getTransactionsComputedCallback,
String toCurrency,
String pathTransactions, String pathRates) throws CustomException;
interface GetTransactionsComputedCallback { | void onGetTransactionsListOK(List<TransactionRatedDomain> transactionList, String totalAmount); |
jexenberger/yadi | src/test/java/org/yadi/core/SamplesTest.java | // Path: src/main/java/org/yadi/core/DefaultContainer.java
// public static Container create(Consumer<Container> builder) {
// DefaultContainer defaultContainer = new DefaultContainer(builder);
// defaultContainer.init();
// return defaultContainer;
// }
| import org.junit.Test;
import static org.yadi.core.DefaultContainer.create; | package org.yadi.core;
/**
* Created by w1428134 on 2014/06/25.
*/
public class SamplesTest {
@Test
public void testSimpleString() throws Exception {
| // Path: src/main/java/org/yadi/core/DefaultContainer.java
// public static Container create(Consumer<Container> builder) {
// DefaultContainer defaultContainer = new DefaultContainer(builder);
// defaultContainer.init();
// return defaultContainer;
// }
// Path: src/test/java/org/yadi/core/SamplesTest.java
import org.junit.Test;
import static org.yadi.core.DefaultContainer.create;
package org.yadi.core;
/**
* Created by w1428134 on 2014/06/25.
*/
public class SamplesTest {
@Test
public void testSimpleString() throws Exception {
| Container container = create((builder) -> { |
jexenberger/yadi | src/test/java/org/yadi/core/DefaultContainerTest.java | // Path: src/main/java/org/yadi/core/DefaultContainer.java
// public static Container create(Consumer<Container> builder) {
// DefaultContainer defaultContainer = new DefaultContainer(builder);
// defaultContainer.init();
// return defaultContainer;
// }
| import org.junit.Test;
import java.util.function.Supplier;
import static org.junit.Assert.assertNotNull;
import static org.yadi.core.DefaultContainer.create; | package org.yadi.core;
/**
* Created by julian3 on 2014/05/03.
*/
public class DefaultContainerTest {
@Test
public void testCreate() throws Exception {
| // Path: src/main/java/org/yadi/core/DefaultContainer.java
// public static Container create(Consumer<Container> builder) {
// DefaultContainer defaultContainer = new DefaultContainer(builder);
// defaultContainer.init();
// return defaultContainer;
// }
// Path: src/test/java/org/yadi/core/DefaultContainerTest.java
import org.junit.Test;
import java.util.function.Supplier;
import static org.junit.Assert.assertNotNull;
import static org.yadi.core.DefaultContainer.create;
package org.yadi.core;
/**
* Created by julian3 on 2014/05/03.
*/
public class DefaultContainerTest {
@Test
public void testCreate() throws Exception {
| Container container = create((builder) -> { |
jexenberger/yadi | src/main/java/org/yadi/core/Construction.java | // Path: src/main/java/org/yadi/core/ReflectionUtils.java
// public static Constructor resolveConstructor(Class source, Class[] types) throws NoSuchMethodException {
// Constructor<?>[] constructors = source.getConstructors();
// for (Constructor<?> constructor : constructors) {
// Class<?>[] parameterTypes = constructor.getParameterTypes();
// boolean found = true;
// found &= parameterTypes.length == types.length;
// if (!found) {
// continue;
// }
// int cnt = 0;
// for (Class<?> parameterType : parameterTypes) {
//
// found &= (wrap(parameterType).isAssignableFrom(types[cnt++]));
// }
//
// if (found) {
// return constructor;
// }
// }
// throw new ContainerException("unable to resolve constructor");
// }
| import java.lang.reflect.Constructor;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import static org.yadi.core.ReflectionUtils.resolveConstructor; | package org.yadi.core;
/*
Copyright 2014 Julian Exenberger
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.
*/
/**
* Created by julian3 on 2014/05/03.
*/
public interface Construction<T> extends Consumer<Arguments> {
default T createWithConstructor(Arguments arguments, Class<T> implementation, Function<Reference, Object> typeResolver, Function<Reference, Object> objectResolver) {
accept(arguments);
try {
if (arguments.size() == 0) {
return implementation.newInstance();
}
Object[] args = arguments.stream().map((pair) -> {
if (pair.getCdr() instanceof Reference && objectResolver != null) {
Reference ref = (Reference) pair.getCdr();
return objectResolver.apply(ref);
} else {
return pair.getCdr();
}
}).toArray();
Class[] types = arguments.stream()
.map((pair) -> {
if (pair.getCdr() instanceof Reference && typeResolver != null && pair.getCar() == null) {
Reference ref = (Reference) pair.getCdr();
return typeResolver.apply(ref);
} else {
return pair.getCar();
}
})
.collect(Collectors.toList())
.toArray(new Class[]{});
| // Path: src/main/java/org/yadi/core/ReflectionUtils.java
// public static Constructor resolveConstructor(Class source, Class[] types) throws NoSuchMethodException {
// Constructor<?>[] constructors = source.getConstructors();
// for (Constructor<?> constructor : constructors) {
// Class<?>[] parameterTypes = constructor.getParameterTypes();
// boolean found = true;
// found &= parameterTypes.length == types.length;
// if (!found) {
// continue;
// }
// int cnt = 0;
// for (Class<?> parameterType : parameterTypes) {
//
// found &= (wrap(parameterType).isAssignableFrom(types[cnt++]));
// }
//
// if (found) {
// return constructor;
// }
// }
// throw new ContainerException("unable to resolve constructor");
// }
// Path: src/main/java/org/yadi/core/Construction.java
import java.lang.reflect.Constructor;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import static org.yadi.core.ReflectionUtils.resolveConstructor;
package org.yadi.core;
/*
Copyright 2014 Julian Exenberger
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.
*/
/**
* Created by julian3 on 2014/05/03.
*/
public interface Construction<T> extends Consumer<Arguments> {
default T createWithConstructor(Arguments arguments, Class<T> implementation, Function<Reference, Object> typeResolver, Function<Reference, Object> objectResolver) {
accept(arguments);
try {
if (arguments.size() == 0) {
return implementation.newInstance();
}
Object[] args = arguments.stream().map((pair) -> {
if (pair.getCdr() instanceof Reference && objectResolver != null) {
Reference ref = (Reference) pair.getCdr();
return objectResolver.apply(ref);
} else {
return pair.getCdr();
}
}).toArray();
Class[] types = arguments.stream()
.map((pair) -> {
if (pair.getCdr() instanceof Reference && typeResolver != null && pair.getCar() == null) {
Reference ref = (Reference) pair.getCdr();
return typeResolver.apply(ref);
} else {
return pair.getCar();
}
})
.collect(Collectors.toList())
.toArray(new Class[]{});
| Constructor<T> theConstructor = resolveConstructor(implementation, types); |
InfinityStudio/FoodCraft | src/main/java/com/foodcraft/block/BlockFc.java | // Path: src/main/java/com/foodcraft/FoodCraft.java
// @Mod(modid="foodcraft", name="FoodCraft", version="1.2.0")
//
// public class FoodCraft implements NetworkMod {
// public static boolean JEIIsLoad = false;
// public static final CreativeTabs FcTabMachine = new CreativeTabs("Jiqi") {//机器&工具
// public Item getTabIconItem() {
// return Item.getItemFromBlock(FoodcraftGuiBlocks.Nmj);
// }
// };
// public static final CreativeTabs FcTabPlant = new CreativeTabs("Zhiwu") {//植物
// public Item getTabIconItem() {
// return FoodcraftItems.ItemLajiao;
// }
// };
// public static final CreativeTabs FcTabDrink = new CreativeTabs("Yingliao") {//饮料
// public Item getTabIconItem() {
// return FoodcraftItems.ItemPutaozhi;
// }
// };
// public static final CreativeTabs FcTabStaple = new CreativeTabs("Zhushi") {//主食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemChaotudousifan;
// }
// };
// public static final CreativeTabs FcTabIngredient = new CreativeTabs("Shicai") {//食材
// public Item getTabIconItem() {
// return FoodcraftItems.ItemMianfen;
// }
// };
// public static final CreativeTabs FcTabSnack = new CreativeTabs("Xiaodian") {//零食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemJianjiao;
// }
// };
//
// @SidedProxy(clientSide = "com.foodcraft.proxy.ClientProxy", serverSide = "com.foodcraft.proxy.CommonProxy")
// private static CommonProxy proxy;
//
// @Instance("foodcraft")
// public static FoodCraft instance;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// PacketDispatcher.initInstance("foodcraft", this);
// NERLogManager.log("Loading foodcraft, Version: 1.2.3");
// JEIIsLoad = Loader.isModLoaded("JustEnoughItems");
// NERConfigHandler.initConfig(event);
// NERConfigHandler.getConfig();
// proxy.preInit(event);
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// proxy.init(event);
// MinecraftForge.EVENT_BUS.register(new FcSubscribeEvent());
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @Override
// public Proxy getProxy() {
// return proxy;
// }
// }
| import com.foodcraft.FoodCraft;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material; | package com.foodcraft.block;
public class BlockFc extends Block {
public BlockFc(Material material, String name) {
super(material);
this.setUnlocalizedName(name); | // Path: src/main/java/com/foodcraft/FoodCraft.java
// @Mod(modid="foodcraft", name="FoodCraft", version="1.2.0")
//
// public class FoodCraft implements NetworkMod {
// public static boolean JEIIsLoad = false;
// public static final CreativeTabs FcTabMachine = new CreativeTabs("Jiqi") {//机器&工具
// public Item getTabIconItem() {
// return Item.getItemFromBlock(FoodcraftGuiBlocks.Nmj);
// }
// };
// public static final CreativeTabs FcTabPlant = new CreativeTabs("Zhiwu") {//植物
// public Item getTabIconItem() {
// return FoodcraftItems.ItemLajiao;
// }
// };
// public static final CreativeTabs FcTabDrink = new CreativeTabs("Yingliao") {//饮料
// public Item getTabIconItem() {
// return FoodcraftItems.ItemPutaozhi;
// }
// };
// public static final CreativeTabs FcTabStaple = new CreativeTabs("Zhushi") {//主食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemChaotudousifan;
// }
// };
// public static final CreativeTabs FcTabIngredient = new CreativeTabs("Shicai") {//食材
// public Item getTabIconItem() {
// return FoodcraftItems.ItemMianfen;
// }
// };
// public static final CreativeTabs FcTabSnack = new CreativeTabs("Xiaodian") {//零食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemJianjiao;
// }
// };
//
// @SidedProxy(clientSide = "com.foodcraft.proxy.ClientProxy", serverSide = "com.foodcraft.proxy.CommonProxy")
// private static CommonProxy proxy;
//
// @Instance("foodcraft")
// public static FoodCraft instance;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// PacketDispatcher.initInstance("foodcraft", this);
// NERLogManager.log("Loading foodcraft, Version: 1.2.3");
// JEIIsLoad = Loader.isModLoaded("JustEnoughItems");
// NERConfigHandler.initConfig(event);
// NERConfigHandler.getConfig();
// proxy.preInit(event);
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// proxy.init(event);
// MinecraftForge.EVENT_BUS.register(new FcSubscribeEvent());
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @Override
// public Proxy getProxy() {
// return proxy;
// }
// }
// Path: src/main/java/com/foodcraft/block/BlockFc.java
import com.foodcraft.FoodCraft;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
package com.foodcraft.block;
public class BlockFc extends Block {
public BlockFc(Material material, String name) {
super(material);
this.setUnlocalizedName(name); | this.setCreativeTab(FoodCraft.FcTabMachine); |
InfinityStudio/FoodCraft | src/main/java/com/foodcraft/item/ItemFoodChili.java | // Path: src/main/java/com/foodcraft/FoodCraft.java
// @Mod(modid="foodcraft", name="FoodCraft", version="1.2.0")
//
// public class FoodCraft implements NetworkMod {
// public static boolean JEIIsLoad = false;
// public static final CreativeTabs FcTabMachine = new CreativeTabs("Jiqi") {//机器&工具
// public Item getTabIconItem() {
// return Item.getItemFromBlock(FoodcraftGuiBlocks.Nmj);
// }
// };
// public static final CreativeTabs FcTabPlant = new CreativeTabs("Zhiwu") {//植物
// public Item getTabIconItem() {
// return FoodcraftItems.ItemLajiao;
// }
// };
// public static final CreativeTabs FcTabDrink = new CreativeTabs("Yingliao") {//饮料
// public Item getTabIconItem() {
// return FoodcraftItems.ItemPutaozhi;
// }
// };
// public static final CreativeTabs FcTabStaple = new CreativeTabs("Zhushi") {//主食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemChaotudousifan;
// }
// };
// public static final CreativeTabs FcTabIngredient = new CreativeTabs("Shicai") {//食材
// public Item getTabIconItem() {
// return FoodcraftItems.ItemMianfen;
// }
// };
// public static final CreativeTabs FcTabSnack = new CreativeTabs("Xiaodian") {//零食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemJianjiao;
// }
// };
//
// @SidedProxy(clientSide = "com.foodcraft.proxy.ClientProxy", serverSide = "com.foodcraft.proxy.CommonProxy")
// private static CommonProxy proxy;
//
// @Instance("foodcraft")
// public static FoodCraft instance;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// PacketDispatcher.initInstance("foodcraft", this);
// NERLogManager.log("Loading foodcraft, Version: 1.2.3");
// JEIIsLoad = Loader.isModLoaded("JustEnoughItems");
// NERConfigHandler.initConfig(event);
// NERConfigHandler.getConfig();
// proxy.preInit(event);
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// proxy.init(event);
// MinecraftForge.EVENT_BUS.register(new FcSubscribeEvent());
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @Override
// public Proxy getProxy() {
// return proxy;
// }
// }
| import com.foodcraft.FoodCraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World; | package com.foodcraft.item;
public class ItemFoodChili extends FcFood {
public ItemFoodChili() {
super(3, 1F, "ItemLajiao"); | // Path: src/main/java/com/foodcraft/FoodCraft.java
// @Mod(modid="foodcraft", name="FoodCraft", version="1.2.0")
//
// public class FoodCraft implements NetworkMod {
// public static boolean JEIIsLoad = false;
// public static final CreativeTabs FcTabMachine = new CreativeTabs("Jiqi") {//机器&工具
// public Item getTabIconItem() {
// return Item.getItemFromBlock(FoodcraftGuiBlocks.Nmj);
// }
// };
// public static final CreativeTabs FcTabPlant = new CreativeTabs("Zhiwu") {//植物
// public Item getTabIconItem() {
// return FoodcraftItems.ItemLajiao;
// }
// };
// public static final CreativeTabs FcTabDrink = new CreativeTabs("Yingliao") {//饮料
// public Item getTabIconItem() {
// return FoodcraftItems.ItemPutaozhi;
// }
// };
// public static final CreativeTabs FcTabStaple = new CreativeTabs("Zhushi") {//主食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemChaotudousifan;
// }
// };
// public static final CreativeTabs FcTabIngredient = new CreativeTabs("Shicai") {//食材
// public Item getTabIconItem() {
// return FoodcraftItems.ItemMianfen;
// }
// };
// public static final CreativeTabs FcTabSnack = new CreativeTabs("Xiaodian") {//零食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemJianjiao;
// }
// };
//
// @SidedProxy(clientSide = "com.foodcraft.proxy.ClientProxy", serverSide = "com.foodcraft.proxy.CommonProxy")
// private static CommonProxy proxy;
//
// @Instance("foodcraft")
// public static FoodCraft instance;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// PacketDispatcher.initInstance("foodcraft", this);
// NERLogManager.log("Loading foodcraft, Version: 1.2.3");
// JEIIsLoad = Loader.isModLoaded("JustEnoughItems");
// NERConfigHandler.initConfig(event);
// NERConfigHandler.getConfig();
// proxy.preInit(event);
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// proxy.init(event);
// MinecraftForge.EVENT_BUS.register(new FcSubscribeEvent());
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @Override
// public Proxy getProxy() {
// return proxy;
// }
// }
// Path: src/main/java/com/foodcraft/item/ItemFoodChili.java
import com.foodcraft.FoodCraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
package com.foodcraft.item;
public class ItemFoodChili extends FcFood {
public ItemFoodChili() {
super(3, 1F, "ItemLajiao"); | this.setCreativeTab(FoodCraft.FcTabPlant); |
InfinityStudio/FoodCraft | src/main/java/com/foodcraft/item/ItemGoldenGrapeWine.java | // Path: src/main/java/com/foodcraft/FoodCraft.java
// @Mod(modid="foodcraft", name="FoodCraft", version="1.2.0")
//
// public class FoodCraft implements NetworkMod {
// public static boolean JEIIsLoad = false;
// public static final CreativeTabs FcTabMachine = new CreativeTabs("Jiqi") {//机器&工具
// public Item getTabIconItem() {
// return Item.getItemFromBlock(FoodcraftGuiBlocks.Nmj);
// }
// };
// public static final CreativeTabs FcTabPlant = new CreativeTabs("Zhiwu") {//植物
// public Item getTabIconItem() {
// return FoodcraftItems.ItemLajiao;
// }
// };
// public static final CreativeTabs FcTabDrink = new CreativeTabs("Yingliao") {//饮料
// public Item getTabIconItem() {
// return FoodcraftItems.ItemPutaozhi;
// }
// };
// public static final CreativeTabs FcTabStaple = new CreativeTabs("Zhushi") {//主食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemChaotudousifan;
// }
// };
// public static final CreativeTabs FcTabIngredient = new CreativeTabs("Shicai") {//食材
// public Item getTabIconItem() {
// return FoodcraftItems.ItemMianfen;
// }
// };
// public static final CreativeTabs FcTabSnack = new CreativeTabs("Xiaodian") {//零食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemJianjiao;
// }
// };
//
// @SidedProxy(clientSide = "com.foodcraft.proxy.ClientProxy", serverSide = "com.foodcraft.proxy.CommonProxy")
// private static CommonProxy proxy;
//
// @Instance("foodcraft")
// public static FoodCraft instance;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// PacketDispatcher.initInstance("foodcraft", this);
// NERLogManager.log("Loading foodcraft, Version: 1.2.3");
// JEIIsLoad = Loader.isModLoaded("JustEnoughItems");
// NERConfigHandler.initConfig(event);
// NERConfigHandler.getConfig();
// proxy.preInit(event);
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// proxy.init(event);
// MinecraftForge.EVENT_BUS.register(new FcSubscribeEvent());
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @Override
// public Proxy getProxy() {
// return proxy;
// }
// }
| import java.util.Random;
import com.foodcraft.FoodCraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World; | package com.foodcraft.item;
public class ItemGoldenGrapeWine extends ItemFood {
public ItemGoldenGrapeWine(int amount, float saturation, String name) {
super((int)saturation, saturation, false);
this.setUnlocalizedName(name); | // Path: src/main/java/com/foodcraft/FoodCraft.java
// @Mod(modid="foodcraft", name="FoodCraft", version="1.2.0")
//
// public class FoodCraft implements NetworkMod {
// public static boolean JEIIsLoad = false;
// public static final CreativeTabs FcTabMachine = new CreativeTabs("Jiqi") {//机器&工具
// public Item getTabIconItem() {
// return Item.getItemFromBlock(FoodcraftGuiBlocks.Nmj);
// }
// };
// public static final CreativeTabs FcTabPlant = new CreativeTabs("Zhiwu") {//植物
// public Item getTabIconItem() {
// return FoodcraftItems.ItemLajiao;
// }
// };
// public static final CreativeTabs FcTabDrink = new CreativeTabs("Yingliao") {//饮料
// public Item getTabIconItem() {
// return FoodcraftItems.ItemPutaozhi;
// }
// };
// public static final CreativeTabs FcTabStaple = new CreativeTabs("Zhushi") {//主食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemChaotudousifan;
// }
// };
// public static final CreativeTabs FcTabIngredient = new CreativeTabs("Shicai") {//食材
// public Item getTabIconItem() {
// return FoodcraftItems.ItemMianfen;
// }
// };
// public static final CreativeTabs FcTabSnack = new CreativeTabs("Xiaodian") {//零食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemJianjiao;
// }
// };
//
// @SidedProxy(clientSide = "com.foodcraft.proxy.ClientProxy", serverSide = "com.foodcraft.proxy.CommonProxy")
// private static CommonProxy proxy;
//
// @Instance("foodcraft")
// public static FoodCraft instance;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// PacketDispatcher.initInstance("foodcraft", this);
// NERLogManager.log("Loading foodcraft, Version: 1.2.3");
// JEIIsLoad = Loader.isModLoaded("JustEnoughItems");
// NERConfigHandler.initConfig(event);
// NERConfigHandler.getConfig();
// proxy.preInit(event);
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// proxy.init(event);
// MinecraftForge.EVENT_BUS.register(new FcSubscribeEvent());
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @Override
// public Proxy getProxy() {
// return proxy;
// }
// }
// Path: src/main/java/com/foodcraft/item/ItemGoldenGrapeWine.java
import java.util.Random;
import com.foodcraft.FoodCraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
package com.foodcraft.item;
public class ItemGoldenGrapeWine extends ItemFood {
public ItemGoldenGrapeWine(int amount, float saturation, String name) {
super((int)saturation, saturation, false);
this.setUnlocalizedName(name); | this.setCreativeTab(FoodCraft.FcTabDrink); |
InfinityStudio/FoodCraft | src/main/java/com/foodcraft/item/ItemStapleFood.java | // Path: src/main/java/com/foodcraft/FoodCraft.java
// @Mod(modid="foodcraft", name="FoodCraft", version="1.2.0")
//
// public class FoodCraft implements NetworkMod {
// public static boolean JEIIsLoad = false;
// public static final CreativeTabs FcTabMachine = new CreativeTabs("Jiqi") {//机器&工具
// public Item getTabIconItem() {
// return Item.getItemFromBlock(FoodcraftGuiBlocks.Nmj);
// }
// };
// public static final CreativeTabs FcTabPlant = new CreativeTabs("Zhiwu") {//植物
// public Item getTabIconItem() {
// return FoodcraftItems.ItemLajiao;
// }
// };
// public static final CreativeTabs FcTabDrink = new CreativeTabs("Yingliao") {//饮料
// public Item getTabIconItem() {
// return FoodcraftItems.ItemPutaozhi;
// }
// };
// public static final CreativeTabs FcTabStaple = new CreativeTabs("Zhushi") {//主食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemChaotudousifan;
// }
// };
// public static final CreativeTabs FcTabIngredient = new CreativeTabs("Shicai") {//食材
// public Item getTabIconItem() {
// return FoodcraftItems.ItemMianfen;
// }
// };
// public static final CreativeTabs FcTabSnack = new CreativeTabs("Xiaodian") {//零食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemJianjiao;
// }
// };
//
// @SidedProxy(clientSide = "com.foodcraft.proxy.ClientProxy", serverSide = "com.foodcraft.proxy.CommonProxy")
// private static CommonProxy proxy;
//
// @Instance("foodcraft")
// public static FoodCraft instance;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// PacketDispatcher.initInstance("foodcraft", this);
// NERLogManager.log("Loading foodcraft, Version: 1.2.3");
// JEIIsLoad = Loader.isModLoaded("JustEnoughItems");
// NERConfigHandler.initConfig(event);
// NERConfigHandler.getConfig();
// proxy.preInit(event);
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// proxy.init(event);
// MinecraftForge.EVENT_BUS.register(new FcSubscribeEvent());
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @Override
// public Proxy getProxy() {
// return proxy;
// }
// }
| import com.foodcraft.FoodCraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World; | package com.foodcraft.item;
public class ItemStapleFood extends ItemFood {
private boolean hasEffect;
public ItemStapleFood(int amount, float saturation, String name) {
super((int)saturation, saturation/3F, false);
this.setUnlocalizedName(name); | // Path: src/main/java/com/foodcraft/FoodCraft.java
// @Mod(modid="foodcraft", name="FoodCraft", version="1.2.0")
//
// public class FoodCraft implements NetworkMod {
// public static boolean JEIIsLoad = false;
// public static final CreativeTabs FcTabMachine = new CreativeTabs("Jiqi") {//机器&工具
// public Item getTabIconItem() {
// return Item.getItemFromBlock(FoodcraftGuiBlocks.Nmj);
// }
// };
// public static final CreativeTabs FcTabPlant = new CreativeTabs("Zhiwu") {//植物
// public Item getTabIconItem() {
// return FoodcraftItems.ItemLajiao;
// }
// };
// public static final CreativeTabs FcTabDrink = new CreativeTabs("Yingliao") {//饮料
// public Item getTabIconItem() {
// return FoodcraftItems.ItemPutaozhi;
// }
// };
// public static final CreativeTabs FcTabStaple = new CreativeTabs("Zhushi") {//主食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemChaotudousifan;
// }
// };
// public static final CreativeTabs FcTabIngredient = new CreativeTabs("Shicai") {//食材
// public Item getTabIconItem() {
// return FoodcraftItems.ItemMianfen;
// }
// };
// public static final CreativeTabs FcTabSnack = new CreativeTabs("Xiaodian") {//零食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemJianjiao;
// }
// };
//
// @SidedProxy(clientSide = "com.foodcraft.proxy.ClientProxy", serverSide = "com.foodcraft.proxy.CommonProxy")
// private static CommonProxy proxy;
//
// @Instance("foodcraft")
// public static FoodCraft instance;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// PacketDispatcher.initInstance("foodcraft", this);
// NERLogManager.log("Loading foodcraft, Version: 1.2.3");
// JEIIsLoad = Loader.isModLoaded("JustEnoughItems");
// NERConfigHandler.initConfig(event);
// NERConfigHandler.getConfig();
// proxy.preInit(event);
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// proxy.init(event);
// MinecraftForge.EVENT_BUS.register(new FcSubscribeEvent());
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @Override
// public Proxy getProxy() {
// return proxy;
// }
// }
// Path: src/main/java/com/foodcraft/item/ItemStapleFood.java
import com.foodcraft.FoodCraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
package com.foodcraft.item;
public class ItemStapleFood extends ItemFood {
private boolean hasEffect;
public ItemStapleFood(int amount, float saturation, String name) {
super((int)saturation, saturation/3F, false);
this.setUnlocalizedName(name); | this.setCreativeTab(FoodCraft.FcTabStaple); |
InfinityStudio/FoodCraft | src/main/java/com/foodcraft/support/jei/milling/MillingRecipeHandler.java | // Path: src/main/java/com/foodcraft/support/jei/FcRecipeHandler.java
// public abstract class FcRecipeHandler<T> implements IRecipeHandler<T> {
// @Override
// public boolean isRecipeValid(@Nonnull T t) {
// return true;
// }
// }
//
// Path: src/main/java/com/foodcraft/support/jei/FcRecipeUids.java
// public interface FcRecipeUids {
// String MILLING = "foodcraft.milling";
// String CHOPPING = "foodcraft.chopping";
// String PRESSURE_COOKER = "foodcraft.pressure_cooker";
// String PAN = "foodcraft.pan";
// String BREW_BARREL = "foodcraft.brew_barrel";
// String FRYING = "foodcraft.frying";
// String BEVERAGE_MAKING = "foodcraft.beverage_making";
// String POT = "foodcraft.pot";
// String STOVE = "foodcraft.stove";
// }
| import com.foodcraft.support.jei.FcRecipeHandler;
import com.foodcraft.support.jei.FcRecipeUids;
import mezz.jei.api.recipe.IRecipeWrapper;
import javax.annotation.Nonnull; | package com.foodcraft.support.jei.milling;
public class MillingRecipeHandler extends FcRecipeHandler<MillingRecipeWrapper> {
@Override
public boolean isRecipeValid(@Nonnull MillingRecipeWrapper millingRecipeWrapper) {
return millingRecipeWrapper.getInputs().size() > 0 && millingRecipeWrapper.getOutputs().size() == 1;
}
@Nonnull
@Override
public Class<MillingRecipeWrapper> getRecipeClass() {
return MillingRecipeWrapper.class;
}
@Nonnull
@Override
public String getRecipeCategoryUid() { | // Path: src/main/java/com/foodcraft/support/jei/FcRecipeHandler.java
// public abstract class FcRecipeHandler<T> implements IRecipeHandler<T> {
// @Override
// public boolean isRecipeValid(@Nonnull T t) {
// return true;
// }
// }
//
// Path: src/main/java/com/foodcraft/support/jei/FcRecipeUids.java
// public interface FcRecipeUids {
// String MILLING = "foodcraft.milling";
// String CHOPPING = "foodcraft.chopping";
// String PRESSURE_COOKER = "foodcraft.pressure_cooker";
// String PAN = "foodcraft.pan";
// String BREW_BARREL = "foodcraft.brew_barrel";
// String FRYING = "foodcraft.frying";
// String BEVERAGE_MAKING = "foodcraft.beverage_making";
// String POT = "foodcraft.pot";
// String STOVE = "foodcraft.stove";
// }
// Path: src/main/java/com/foodcraft/support/jei/milling/MillingRecipeHandler.java
import com.foodcraft.support.jei.FcRecipeHandler;
import com.foodcraft.support.jei.FcRecipeUids;
import mezz.jei.api.recipe.IRecipeWrapper;
import javax.annotation.Nonnull;
package com.foodcraft.support.jei.milling;
public class MillingRecipeHandler extends FcRecipeHandler<MillingRecipeWrapper> {
@Override
public boolean isRecipeValid(@Nonnull MillingRecipeWrapper millingRecipeWrapper) {
return millingRecipeWrapper.getInputs().size() > 0 && millingRecipeWrapper.getOutputs().size() == 1;
}
@Nonnull
@Override
public Class<MillingRecipeWrapper> getRecipeClass() {
return MillingRecipeWrapper.class;
}
@Nonnull
@Override
public String getRecipeCategoryUid() { | return FcRecipeUids.MILLING; |
InfinityStudio/FoodCraft | src/main/java/com/foodcraft/item/ItemWine.java | // Path: src/main/java/com/foodcraft/FoodCraft.java
// @Mod(modid="foodcraft", name="FoodCraft", version="1.2.0")
//
// public class FoodCraft implements NetworkMod {
// public static boolean JEIIsLoad = false;
// public static final CreativeTabs FcTabMachine = new CreativeTabs("Jiqi") {//机器&工具
// public Item getTabIconItem() {
// return Item.getItemFromBlock(FoodcraftGuiBlocks.Nmj);
// }
// };
// public static final CreativeTabs FcTabPlant = new CreativeTabs("Zhiwu") {//植物
// public Item getTabIconItem() {
// return FoodcraftItems.ItemLajiao;
// }
// };
// public static final CreativeTabs FcTabDrink = new CreativeTabs("Yingliao") {//饮料
// public Item getTabIconItem() {
// return FoodcraftItems.ItemPutaozhi;
// }
// };
// public static final CreativeTabs FcTabStaple = new CreativeTabs("Zhushi") {//主食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemChaotudousifan;
// }
// };
// public static final CreativeTabs FcTabIngredient = new CreativeTabs("Shicai") {//食材
// public Item getTabIconItem() {
// return FoodcraftItems.ItemMianfen;
// }
// };
// public static final CreativeTabs FcTabSnack = new CreativeTabs("Xiaodian") {//零食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemJianjiao;
// }
// };
//
// @SidedProxy(clientSide = "com.foodcraft.proxy.ClientProxy", serverSide = "com.foodcraft.proxy.CommonProxy")
// private static CommonProxy proxy;
//
// @Instance("foodcraft")
// public static FoodCraft instance;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// PacketDispatcher.initInstance("foodcraft", this);
// NERLogManager.log("Loading foodcraft, Version: 1.2.3");
// JEIIsLoad = Loader.isModLoaded("JustEnoughItems");
// NERConfigHandler.initConfig(event);
// NERConfigHandler.getConfig();
// proxy.preInit(event);
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// proxy.init(event);
// MinecraftForge.EVENT_BUS.register(new FcSubscribeEvent());
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @Override
// public Proxy getProxy() {
// return proxy;
// }
// }
| import java.util.Random;
import com.foodcraft.FoodCraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World; | package com.foodcraft.item;
public class ItemWine extends ItemFood {
public ItemWine(int amount, float saturation, String name) {
super((int)saturation, saturation, false);
this.setUnlocalizedName(name); | // Path: src/main/java/com/foodcraft/FoodCraft.java
// @Mod(modid="foodcraft", name="FoodCraft", version="1.2.0")
//
// public class FoodCraft implements NetworkMod {
// public static boolean JEIIsLoad = false;
// public static final CreativeTabs FcTabMachine = new CreativeTabs("Jiqi") {//机器&工具
// public Item getTabIconItem() {
// return Item.getItemFromBlock(FoodcraftGuiBlocks.Nmj);
// }
// };
// public static final CreativeTabs FcTabPlant = new CreativeTabs("Zhiwu") {//植物
// public Item getTabIconItem() {
// return FoodcraftItems.ItemLajiao;
// }
// };
// public static final CreativeTabs FcTabDrink = new CreativeTabs("Yingliao") {//饮料
// public Item getTabIconItem() {
// return FoodcraftItems.ItemPutaozhi;
// }
// };
// public static final CreativeTabs FcTabStaple = new CreativeTabs("Zhushi") {//主食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemChaotudousifan;
// }
// };
// public static final CreativeTabs FcTabIngredient = new CreativeTabs("Shicai") {//食材
// public Item getTabIconItem() {
// return FoodcraftItems.ItemMianfen;
// }
// };
// public static final CreativeTabs FcTabSnack = new CreativeTabs("Xiaodian") {//零食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemJianjiao;
// }
// };
//
// @SidedProxy(clientSide = "com.foodcraft.proxy.ClientProxy", serverSide = "com.foodcraft.proxy.CommonProxy")
// private static CommonProxy proxy;
//
// @Instance("foodcraft")
// public static FoodCraft instance;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// PacketDispatcher.initInstance("foodcraft", this);
// NERLogManager.log("Loading foodcraft, Version: 1.2.3");
// JEIIsLoad = Loader.isModLoaded("JustEnoughItems");
// NERConfigHandler.initConfig(event);
// NERConfigHandler.getConfig();
// proxy.preInit(event);
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// proxy.init(event);
// MinecraftForge.EVENT_BUS.register(new FcSubscribeEvent());
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @Override
// public Proxy getProxy() {
// return proxy;
// }
// }
// Path: src/main/java/com/foodcraft/item/ItemWine.java
import java.util.Random;
import com.foodcraft.FoodCraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
package com.foodcraft.item;
public class ItemWine extends ItemFood {
public ItemWine(int amount, float saturation, String name) {
super((int)saturation, saturation, false);
this.setUnlocalizedName(name); | this.setCreativeTab(FoodCraft.FcTabDrink); |
InfinityStudio/FoodCraft | src/main/java/com/foodcraft/item/ItemCookie.java | // Path: src/main/java/com/foodcraft/FoodCraft.java
// @Mod(modid="foodcraft", name="FoodCraft", version="1.2.0")
//
// public class FoodCraft implements NetworkMod {
// public static boolean JEIIsLoad = false;
// public static final CreativeTabs FcTabMachine = new CreativeTabs("Jiqi") {//机器&工具
// public Item getTabIconItem() {
// return Item.getItemFromBlock(FoodcraftGuiBlocks.Nmj);
// }
// };
// public static final CreativeTabs FcTabPlant = new CreativeTabs("Zhiwu") {//植物
// public Item getTabIconItem() {
// return FoodcraftItems.ItemLajiao;
// }
// };
// public static final CreativeTabs FcTabDrink = new CreativeTabs("Yingliao") {//饮料
// public Item getTabIconItem() {
// return FoodcraftItems.ItemPutaozhi;
// }
// };
// public static final CreativeTabs FcTabStaple = new CreativeTabs("Zhushi") {//主食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemChaotudousifan;
// }
// };
// public static final CreativeTabs FcTabIngredient = new CreativeTabs("Shicai") {//食材
// public Item getTabIconItem() {
// return FoodcraftItems.ItemMianfen;
// }
// };
// public static final CreativeTabs FcTabSnack = new CreativeTabs("Xiaodian") {//零食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemJianjiao;
// }
// };
//
// @SidedProxy(clientSide = "com.foodcraft.proxy.ClientProxy", serverSide = "com.foodcraft.proxy.CommonProxy")
// private static CommonProxy proxy;
//
// @Instance("foodcraft")
// public static FoodCraft instance;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// PacketDispatcher.initInstance("foodcraft", this);
// NERLogManager.log("Loading foodcraft, Version: 1.2.3");
// JEIIsLoad = Loader.isModLoaded("JustEnoughItems");
// NERConfigHandler.initConfig(event);
// NERConfigHandler.getConfig();
// proxy.preInit(event);
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// proxy.init(event);
// MinecraftForge.EVENT_BUS.register(new FcSubscribeEvent());
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @Override
// public Proxy getProxy() {
// return proxy;
// }
// }
| import java.util.List;
import com.foodcraft.FoodCraft;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; | package com.foodcraft.item;
public class ItemCookie extends FcFood {
private String[] names = new String[] {"ItemPutaoBG","ItemJinputaoBG","ItemLiBG","ItemTaoziBG","ItemJuziBG","ItemNingmengBG","ItemCaomeiBG","ItemYeziBG"};
public ItemCookie(int amount, float saturation, String name) {
super((int)saturation, saturation, name);
this.setHasSubtypes(true);
this.setUnlocalizedName("ItemBinggan"); | // Path: src/main/java/com/foodcraft/FoodCraft.java
// @Mod(modid="foodcraft", name="FoodCraft", version="1.2.0")
//
// public class FoodCraft implements NetworkMod {
// public static boolean JEIIsLoad = false;
// public static final CreativeTabs FcTabMachine = new CreativeTabs("Jiqi") {//机器&工具
// public Item getTabIconItem() {
// return Item.getItemFromBlock(FoodcraftGuiBlocks.Nmj);
// }
// };
// public static final CreativeTabs FcTabPlant = new CreativeTabs("Zhiwu") {//植物
// public Item getTabIconItem() {
// return FoodcraftItems.ItemLajiao;
// }
// };
// public static final CreativeTabs FcTabDrink = new CreativeTabs("Yingliao") {//饮料
// public Item getTabIconItem() {
// return FoodcraftItems.ItemPutaozhi;
// }
// };
// public static final CreativeTabs FcTabStaple = new CreativeTabs("Zhushi") {//主食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemChaotudousifan;
// }
// };
// public static final CreativeTabs FcTabIngredient = new CreativeTabs("Shicai") {//食材
// public Item getTabIconItem() {
// return FoodcraftItems.ItemMianfen;
// }
// };
// public static final CreativeTabs FcTabSnack = new CreativeTabs("Xiaodian") {//零食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemJianjiao;
// }
// };
//
// @SidedProxy(clientSide = "com.foodcraft.proxy.ClientProxy", serverSide = "com.foodcraft.proxy.CommonProxy")
// private static CommonProxy proxy;
//
// @Instance("foodcraft")
// public static FoodCraft instance;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// PacketDispatcher.initInstance("foodcraft", this);
// NERLogManager.log("Loading foodcraft, Version: 1.2.3");
// JEIIsLoad = Loader.isModLoaded("JustEnoughItems");
// NERConfigHandler.initConfig(event);
// NERConfigHandler.getConfig();
// proxy.preInit(event);
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// proxy.init(event);
// MinecraftForge.EVENT_BUS.register(new FcSubscribeEvent());
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @Override
// public Proxy getProxy() {
// return proxy;
// }
// }
// Path: src/main/java/com/foodcraft/item/ItemCookie.java
import java.util.List;
import com.foodcraft.FoodCraft;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
package com.foodcraft.item;
public class ItemCookie extends FcFood {
private String[] names = new String[] {"ItemPutaoBG","ItemJinputaoBG","ItemLiBG","ItemTaoziBG","ItemJuziBG","ItemNingmengBG","ItemCaomeiBG","ItemYeziBG"};
public ItemCookie(int amount, float saturation, String name) {
super((int)saturation, saturation, name);
this.setHasSubtypes(true);
this.setUnlocalizedName("ItemBinggan"); | this.setCreativeTab(FoodCraft.FcTabSnack); |
InfinityStudio/FoodCraft | src/main/java/com/foodcraft/support/jei/choppingboard/ChoppingBoardRecipeHandler.java | // Path: src/main/java/com/foodcraft/support/jei/FcRecipeHandler.java
// public abstract class FcRecipeHandler<T> implements IRecipeHandler<T> {
// @Override
// public boolean isRecipeValid(@Nonnull T t) {
// return true;
// }
// }
//
// Path: src/main/java/com/foodcraft/support/jei/FcRecipeUids.java
// public interface FcRecipeUids {
// String MILLING = "foodcraft.milling";
// String CHOPPING = "foodcraft.chopping";
// String PRESSURE_COOKER = "foodcraft.pressure_cooker";
// String PAN = "foodcraft.pan";
// String BREW_BARREL = "foodcraft.brew_barrel";
// String FRYING = "foodcraft.frying";
// String BEVERAGE_MAKING = "foodcraft.beverage_making";
// String POT = "foodcraft.pot";
// String STOVE = "foodcraft.stove";
// }
| import com.foodcraft.support.jei.FcRecipeHandler;
import com.foodcraft.support.jei.FcRecipeUids;
import mezz.jei.api.recipe.IRecipeWrapper;
import javax.annotation.Nonnull; | package com.foodcraft.support.jei.choppingboard;
public class ChoppingBoardRecipeHandler extends FcRecipeHandler<ChoppingBoardRecipeWrapper> {
@Override
public boolean isRecipeValid(@Nonnull ChoppingBoardRecipeWrapper choppingBoardRecipeWrapper) {
return choppingBoardRecipeWrapper.getInputs().size() > 0 && choppingBoardRecipeWrapper.getOutputs().size() == 1;
}
@Nonnull
@Override
public Class<ChoppingBoardRecipeWrapper> getRecipeClass() {
return ChoppingBoardRecipeWrapper.class;
}
@Nonnull
@Override
public String getRecipeCategoryUid() { | // Path: src/main/java/com/foodcraft/support/jei/FcRecipeHandler.java
// public abstract class FcRecipeHandler<T> implements IRecipeHandler<T> {
// @Override
// public boolean isRecipeValid(@Nonnull T t) {
// return true;
// }
// }
//
// Path: src/main/java/com/foodcraft/support/jei/FcRecipeUids.java
// public interface FcRecipeUids {
// String MILLING = "foodcraft.milling";
// String CHOPPING = "foodcraft.chopping";
// String PRESSURE_COOKER = "foodcraft.pressure_cooker";
// String PAN = "foodcraft.pan";
// String BREW_BARREL = "foodcraft.brew_barrel";
// String FRYING = "foodcraft.frying";
// String BEVERAGE_MAKING = "foodcraft.beverage_making";
// String POT = "foodcraft.pot";
// String STOVE = "foodcraft.stove";
// }
// Path: src/main/java/com/foodcraft/support/jei/choppingboard/ChoppingBoardRecipeHandler.java
import com.foodcraft.support.jei.FcRecipeHandler;
import com.foodcraft.support.jei.FcRecipeUids;
import mezz.jei.api.recipe.IRecipeWrapper;
import javax.annotation.Nonnull;
package com.foodcraft.support.jei.choppingboard;
public class ChoppingBoardRecipeHandler extends FcRecipeHandler<ChoppingBoardRecipeWrapper> {
@Override
public boolean isRecipeValid(@Nonnull ChoppingBoardRecipeWrapper choppingBoardRecipeWrapper) {
return choppingBoardRecipeWrapper.getInputs().size() > 0 && choppingBoardRecipeWrapper.getOutputs().size() == 1;
}
@Nonnull
@Override
public Class<ChoppingBoardRecipeWrapper> getRecipeClass() {
return ChoppingBoardRecipeWrapper.class;
}
@Nonnull
@Override
public String getRecipeCategoryUid() { | return FcRecipeUids.CHOPPING; |
InfinityStudio/FoodCraft | src/main/java/com/foodcraft/support/jei/pressurecooker/PressureCookerRecipeWrapper.java | // Path: src/main/java/com/foodcraft/itemstack/FoodcraftItemStack.java
// public class FoodcraftItemStack {
//
// private Item[] Stack;
//
// public FoodcraftItemStack(Item[] Item1) {
// this.Stack = Item1;
// }
//
// public Item[] getItems() {
// return Stack;
// }
// }
//
// Path: src/main/java/com/foodcraft/support/jei/FcRecipeWrapper.java
// public abstract class FcRecipeWrapper extends BlankRecipeWrapper {
// }
| import com.foodcraft.itemstack.FoodcraftItemStack;
import com.foodcraft.support.jei.FcRecipeWrapper;
import com.google.common.collect.Lists;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import javax.annotation.Nonnull;
import java.util.Collections;
import java.util.List;
import java.util.Map; | package com.foodcraft.support.jei.pressurecooker;
public class PressureCookerRecipeWrapper extends FcRecipeWrapper {
private final List inputs;
private final List outputs;
| // Path: src/main/java/com/foodcraft/itemstack/FoodcraftItemStack.java
// public class FoodcraftItemStack {
//
// private Item[] Stack;
//
// public FoodcraftItemStack(Item[] Item1) {
// this.Stack = Item1;
// }
//
// public Item[] getItems() {
// return Stack;
// }
// }
//
// Path: src/main/java/com/foodcraft/support/jei/FcRecipeWrapper.java
// public abstract class FcRecipeWrapper extends BlankRecipeWrapper {
// }
// Path: src/main/java/com/foodcraft/support/jei/pressurecooker/PressureCookerRecipeWrapper.java
import com.foodcraft.itemstack.FoodcraftItemStack;
import com.foodcraft.support.jei.FcRecipeWrapper;
import com.google.common.collect.Lists;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import javax.annotation.Nonnull;
import java.util.Collections;
import java.util.List;
import java.util.Map;
package com.foodcraft.support.jei.pressurecooker;
public class PressureCookerRecipeWrapper extends FcRecipeWrapper {
private final List inputs;
private final List outputs;
| public PressureCookerRecipeWrapper(Map.Entry<FoodcraftItemStack, ItemStack> entry) { |
InfinityStudio/FoodCraft | src/main/java/com/foodcraft/support/jei/pressurecooker/PressureCookerRecipeCategory.java | // Path: src/main/java/com/foodcraft/support/jei/FcRecipeUids.java
// public interface FcRecipeUids {
// String MILLING = "foodcraft.milling";
// String CHOPPING = "foodcraft.chopping";
// String PRESSURE_COOKER = "foodcraft.pressure_cooker";
// String PAN = "foodcraft.pan";
// String BREW_BARREL = "foodcraft.brew_barrel";
// String FRYING = "foodcraft.frying";
// String BEVERAGE_MAKING = "foodcraft.beverage_making";
// String POT = "foodcraft.pot";
// String STOVE = "foodcraft.stove";
// }
| import com.foodcraft.support.jei.FcRecipeUids;
import mezz.jei.api.IGuiHelper;
import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.gui.IGuiItemStackGroup;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.recipe.BlankRecipeCategory;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import javax.annotation.Nonnull; | package com.foodcraft.support.jei.pressurecooker;
public class PressureCookerRecipeCategory extends BlankRecipeCategory {
@Nonnull
private final IDrawable background;
@Nonnull
private final String localizedName;
public PressureCookerRecipeCategory(IGuiHelper guiHelper) {
ResourceLocation location = new ResourceLocation("foodcraft:textures/gui/nei/gyg.png");
background = guiHelper.createDrawable(location, 13, 10, 158 - 13 + 1, 71 - 10 + 1);
localizedName = StatCollector.translateToLocal("tile.Gyg.name");
}
@Nonnull
@Override
public String getUid() { | // Path: src/main/java/com/foodcraft/support/jei/FcRecipeUids.java
// public interface FcRecipeUids {
// String MILLING = "foodcraft.milling";
// String CHOPPING = "foodcraft.chopping";
// String PRESSURE_COOKER = "foodcraft.pressure_cooker";
// String PAN = "foodcraft.pan";
// String BREW_BARREL = "foodcraft.brew_barrel";
// String FRYING = "foodcraft.frying";
// String BEVERAGE_MAKING = "foodcraft.beverage_making";
// String POT = "foodcraft.pot";
// String STOVE = "foodcraft.stove";
// }
// Path: src/main/java/com/foodcraft/support/jei/pressurecooker/PressureCookerRecipeCategory.java
import com.foodcraft.support.jei.FcRecipeUids;
import mezz.jei.api.IGuiHelper;
import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.gui.IGuiItemStackGroup;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.recipe.BlankRecipeCategory;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import javax.annotation.Nonnull;
package com.foodcraft.support.jei.pressurecooker;
public class PressureCookerRecipeCategory extends BlankRecipeCategory {
@Nonnull
private final IDrawable background;
@Nonnull
private final String localizedName;
public PressureCookerRecipeCategory(IGuiHelper guiHelper) {
ResourceLocation location = new ResourceLocation("foodcraft:textures/gui/nei/gyg.png");
background = guiHelper.createDrawable(location, 13, 10, 158 - 13 + 1, 71 - 10 + 1);
localizedName = StatCollector.translateToLocal("tile.Gyg.name");
}
@Nonnull
@Override
public String getUid() { | return FcRecipeUids.PRESSURE_COOKER; |
InfinityStudio/FoodCraft | src/main/java/com/foodcraft/support/jei/choppingboard/ChoppingBoardRecipeWrapper.java | // Path: src/main/java/com/foodcraft/itemstack/FoodcraftItemStack.java
// public class FoodcraftItemStack {
//
// private Item[] Stack;
//
// public FoodcraftItemStack(Item[] Item1) {
// this.Stack = Item1;
// }
//
// public Item[] getItems() {
// return Stack;
// }
// }
//
// Path: src/main/java/com/foodcraft/support/jei/FcRecipeWrapper.java
// public abstract class FcRecipeWrapper extends BlankRecipeWrapper {
// }
| import com.foodcraft.itemstack.FoodcraftItemStack;
import com.foodcraft.support.jei.FcRecipeWrapper;
import com.google.common.collect.Lists;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import javax.annotation.Nonnull;
import java.util.Collections;
import java.util.List;
import java.util.Map; | package com.foodcraft.support.jei.choppingboard;
public class ChoppingBoardRecipeWrapper extends FcRecipeWrapper {
private final List inputs;
private final List outputs;
| // Path: src/main/java/com/foodcraft/itemstack/FoodcraftItemStack.java
// public class FoodcraftItemStack {
//
// private Item[] Stack;
//
// public FoodcraftItemStack(Item[] Item1) {
// this.Stack = Item1;
// }
//
// public Item[] getItems() {
// return Stack;
// }
// }
//
// Path: src/main/java/com/foodcraft/support/jei/FcRecipeWrapper.java
// public abstract class FcRecipeWrapper extends BlankRecipeWrapper {
// }
// Path: src/main/java/com/foodcraft/support/jei/choppingboard/ChoppingBoardRecipeWrapper.java
import com.foodcraft.itemstack.FoodcraftItemStack;
import com.foodcraft.support.jei.FcRecipeWrapper;
import com.google.common.collect.Lists;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import javax.annotation.Nonnull;
import java.util.Collections;
import java.util.List;
import java.util.Map;
package com.foodcraft.support.jei.choppingboard;
public class ChoppingBoardRecipeWrapper extends FcRecipeWrapper {
private final List inputs;
private final List outputs;
| public ChoppingBoardRecipeWrapper(Map.Entry<FoodcraftItemStack, ItemStack> entry) { |
InfinityStudio/FoodCraft | src/main/java/com/foodcraft/item/ItemDrink.java | // Path: src/main/java/com/foodcraft/FoodCraft.java
// @Mod(modid="foodcraft", name="FoodCraft", version="1.2.0")
//
// public class FoodCraft implements NetworkMod {
// public static boolean JEIIsLoad = false;
// public static final CreativeTabs FcTabMachine = new CreativeTabs("Jiqi") {//机器&工具
// public Item getTabIconItem() {
// return Item.getItemFromBlock(FoodcraftGuiBlocks.Nmj);
// }
// };
// public static final CreativeTabs FcTabPlant = new CreativeTabs("Zhiwu") {//植物
// public Item getTabIconItem() {
// return FoodcraftItems.ItemLajiao;
// }
// };
// public static final CreativeTabs FcTabDrink = new CreativeTabs("Yingliao") {//饮料
// public Item getTabIconItem() {
// return FoodcraftItems.ItemPutaozhi;
// }
// };
// public static final CreativeTabs FcTabStaple = new CreativeTabs("Zhushi") {//主食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemChaotudousifan;
// }
// };
// public static final CreativeTabs FcTabIngredient = new CreativeTabs("Shicai") {//食材
// public Item getTabIconItem() {
// return FoodcraftItems.ItemMianfen;
// }
// };
// public static final CreativeTabs FcTabSnack = new CreativeTabs("Xiaodian") {//零食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemJianjiao;
// }
// };
//
// @SidedProxy(clientSide = "com.foodcraft.proxy.ClientProxy", serverSide = "com.foodcraft.proxy.CommonProxy")
// private static CommonProxy proxy;
//
// @Instance("foodcraft")
// public static FoodCraft instance;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// PacketDispatcher.initInstance("foodcraft", this);
// NERLogManager.log("Loading foodcraft, Version: 1.2.3");
// JEIIsLoad = Loader.isModLoaded("JustEnoughItems");
// NERConfigHandler.initConfig(event);
// NERConfigHandler.getConfig();
// proxy.preInit(event);
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// proxy.init(event);
// MinecraftForge.EVENT_BUS.register(new FcSubscribeEvent());
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @Override
// public Proxy getProxy() {
// return proxy;
// }
// }
| import com.foodcraft.FoodCraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; | package com.foodcraft.item;
public class ItemDrink extends ItemFood {
private boolean hasEffect;
private int type = 10;
private int color;
public ItemDrink(int amount, float saturation, String name,int color) {
super((int)saturation, saturation, false);
this.setUnlocalizedName(name); | // Path: src/main/java/com/foodcraft/FoodCraft.java
// @Mod(modid="foodcraft", name="FoodCraft", version="1.2.0")
//
// public class FoodCraft implements NetworkMod {
// public static boolean JEIIsLoad = false;
// public static final CreativeTabs FcTabMachine = new CreativeTabs("Jiqi") {//机器&工具
// public Item getTabIconItem() {
// return Item.getItemFromBlock(FoodcraftGuiBlocks.Nmj);
// }
// };
// public static final CreativeTabs FcTabPlant = new CreativeTabs("Zhiwu") {//植物
// public Item getTabIconItem() {
// return FoodcraftItems.ItemLajiao;
// }
// };
// public static final CreativeTabs FcTabDrink = new CreativeTabs("Yingliao") {//饮料
// public Item getTabIconItem() {
// return FoodcraftItems.ItemPutaozhi;
// }
// };
// public static final CreativeTabs FcTabStaple = new CreativeTabs("Zhushi") {//主食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemChaotudousifan;
// }
// };
// public static final CreativeTabs FcTabIngredient = new CreativeTabs("Shicai") {//食材
// public Item getTabIconItem() {
// return FoodcraftItems.ItemMianfen;
// }
// };
// public static final CreativeTabs FcTabSnack = new CreativeTabs("Xiaodian") {//零食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemJianjiao;
// }
// };
//
// @SidedProxy(clientSide = "com.foodcraft.proxy.ClientProxy", serverSide = "com.foodcraft.proxy.CommonProxy")
// private static CommonProxy proxy;
//
// @Instance("foodcraft")
// public static FoodCraft instance;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// PacketDispatcher.initInstance("foodcraft", this);
// NERLogManager.log("Loading foodcraft, Version: 1.2.3");
// JEIIsLoad = Loader.isModLoaded("JustEnoughItems");
// NERConfigHandler.initConfig(event);
// NERConfigHandler.getConfig();
// proxy.preInit(event);
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// proxy.init(event);
// MinecraftForge.EVENT_BUS.register(new FcSubscribeEvent());
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @Override
// public Proxy getProxy() {
// return proxy;
// }
// }
// Path: src/main/java/com/foodcraft/item/ItemDrink.java
import com.foodcraft.FoodCraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
package com.foodcraft.item;
public class ItemDrink extends ItemFood {
private boolean hasEffect;
private int type = 10;
private int color;
public ItemDrink(int amount, float saturation, String name,int color) {
super((int)saturation, saturation, false);
this.setUnlocalizedName(name); | this.setCreativeTab(FoodCraft.FcTabDrink); |
InfinityStudio/FoodCraft | src/main/java/com/foodcraft/item/ItemGoldenAppleWine.java | // Path: src/main/java/com/foodcraft/FoodCraft.java
// @Mod(modid="foodcraft", name="FoodCraft", version="1.2.0")
//
// public class FoodCraft implements NetworkMod {
// public static boolean JEIIsLoad = false;
// public static final CreativeTabs FcTabMachine = new CreativeTabs("Jiqi") {//机器&工具
// public Item getTabIconItem() {
// return Item.getItemFromBlock(FoodcraftGuiBlocks.Nmj);
// }
// };
// public static final CreativeTabs FcTabPlant = new CreativeTabs("Zhiwu") {//植物
// public Item getTabIconItem() {
// return FoodcraftItems.ItemLajiao;
// }
// };
// public static final CreativeTabs FcTabDrink = new CreativeTabs("Yingliao") {//饮料
// public Item getTabIconItem() {
// return FoodcraftItems.ItemPutaozhi;
// }
// };
// public static final CreativeTabs FcTabStaple = new CreativeTabs("Zhushi") {//主食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemChaotudousifan;
// }
// };
// public static final CreativeTabs FcTabIngredient = new CreativeTabs("Shicai") {//食材
// public Item getTabIconItem() {
// return FoodcraftItems.ItemMianfen;
// }
// };
// public static final CreativeTabs FcTabSnack = new CreativeTabs("Xiaodian") {//零食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemJianjiao;
// }
// };
//
// @SidedProxy(clientSide = "com.foodcraft.proxy.ClientProxy", serverSide = "com.foodcraft.proxy.CommonProxy")
// private static CommonProxy proxy;
//
// @Instance("foodcraft")
// public static FoodCraft instance;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// PacketDispatcher.initInstance("foodcraft", this);
// NERLogManager.log("Loading foodcraft, Version: 1.2.3");
// JEIIsLoad = Loader.isModLoaded("JustEnoughItems");
// NERConfigHandler.initConfig(event);
// NERConfigHandler.getConfig();
// proxy.preInit(event);
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// proxy.init(event);
// MinecraftForge.EVENT_BUS.register(new FcSubscribeEvent());
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @Override
// public Proxy getProxy() {
// return proxy;
// }
// }
| import java.util.Random;
import com.foodcraft.FoodCraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World; | package com.foodcraft.item;
public class ItemGoldenAppleWine extends ItemFood {
public ItemGoldenAppleWine(int amount, float saturation, String name) {
super((int)saturation, saturation, false);
this.setUnlocalizedName(name); | // Path: src/main/java/com/foodcraft/FoodCraft.java
// @Mod(modid="foodcraft", name="FoodCraft", version="1.2.0")
//
// public class FoodCraft implements NetworkMod {
// public static boolean JEIIsLoad = false;
// public static final CreativeTabs FcTabMachine = new CreativeTabs("Jiqi") {//机器&工具
// public Item getTabIconItem() {
// return Item.getItemFromBlock(FoodcraftGuiBlocks.Nmj);
// }
// };
// public static final CreativeTabs FcTabPlant = new CreativeTabs("Zhiwu") {//植物
// public Item getTabIconItem() {
// return FoodcraftItems.ItemLajiao;
// }
// };
// public static final CreativeTabs FcTabDrink = new CreativeTabs("Yingliao") {//饮料
// public Item getTabIconItem() {
// return FoodcraftItems.ItemPutaozhi;
// }
// };
// public static final CreativeTabs FcTabStaple = new CreativeTabs("Zhushi") {//主食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemChaotudousifan;
// }
// };
// public static final CreativeTabs FcTabIngredient = new CreativeTabs("Shicai") {//食材
// public Item getTabIconItem() {
// return FoodcraftItems.ItemMianfen;
// }
// };
// public static final CreativeTabs FcTabSnack = new CreativeTabs("Xiaodian") {//零食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemJianjiao;
// }
// };
//
// @SidedProxy(clientSide = "com.foodcraft.proxy.ClientProxy", serverSide = "com.foodcraft.proxy.CommonProxy")
// private static CommonProxy proxy;
//
// @Instance("foodcraft")
// public static FoodCraft instance;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// PacketDispatcher.initInstance("foodcraft", this);
// NERLogManager.log("Loading foodcraft, Version: 1.2.3");
// JEIIsLoad = Loader.isModLoaded("JustEnoughItems");
// NERConfigHandler.initConfig(event);
// NERConfigHandler.getConfig();
// proxy.preInit(event);
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// proxy.init(event);
// MinecraftForge.EVENT_BUS.register(new FcSubscribeEvent());
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @Override
// public Proxy getProxy() {
// return proxy;
// }
// }
// Path: src/main/java/com/foodcraft/item/ItemGoldenAppleWine.java
import java.util.Random;
import com.foodcraft.FoodCraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
package com.foodcraft.item;
public class ItemGoldenAppleWine extends ItemFood {
public ItemGoldenAppleWine(int amount, float saturation, String name) {
super((int)saturation, saturation, false);
this.setUnlocalizedName(name); | this.setCreativeTab(FoodCraft.FcTabDrink); |
InfinityStudio/FoodCraft | src/main/java/com/foodcraft/item/ItemJam.java | // Path: src/main/java/com/foodcraft/FoodCraft.java
// @Mod(modid="foodcraft", name="FoodCraft", version="1.2.0")
//
// public class FoodCraft implements NetworkMod {
// public static boolean JEIIsLoad = false;
// public static final CreativeTabs FcTabMachine = new CreativeTabs("Jiqi") {//机器&工具
// public Item getTabIconItem() {
// return Item.getItemFromBlock(FoodcraftGuiBlocks.Nmj);
// }
// };
// public static final CreativeTabs FcTabPlant = new CreativeTabs("Zhiwu") {//植物
// public Item getTabIconItem() {
// return FoodcraftItems.ItemLajiao;
// }
// };
// public static final CreativeTabs FcTabDrink = new CreativeTabs("Yingliao") {//饮料
// public Item getTabIconItem() {
// return FoodcraftItems.ItemPutaozhi;
// }
// };
// public static final CreativeTabs FcTabStaple = new CreativeTabs("Zhushi") {//主食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemChaotudousifan;
// }
// };
// public static final CreativeTabs FcTabIngredient = new CreativeTabs("Shicai") {//食材
// public Item getTabIconItem() {
// return FoodcraftItems.ItemMianfen;
// }
// };
// public static final CreativeTabs FcTabSnack = new CreativeTabs("Xiaodian") {//零食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemJianjiao;
// }
// };
//
// @SidedProxy(clientSide = "com.foodcraft.proxy.ClientProxy", serverSide = "com.foodcraft.proxy.CommonProxy")
// private static CommonProxy proxy;
//
// @Instance("foodcraft")
// public static FoodCraft instance;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// PacketDispatcher.initInstance("foodcraft", this);
// NERLogManager.log("Loading foodcraft, Version: 1.2.3");
// JEIIsLoad = Loader.isModLoaded("JustEnoughItems");
// NERConfigHandler.initConfig(event);
// NERConfigHandler.getConfig();
// proxy.preInit(event);
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// proxy.init(event);
// MinecraftForge.EVENT_BUS.register(new FcSubscribeEvent());
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @Override
// public Proxy getProxy() {
// return proxy;
// }
// }
| import java.util.List;
import com.foodcraft.FoodCraft;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; | package com.foodcraft.item;
public class ItemJam extends Item {
private String[] s = new String[] {"ItemPutaoGJ","ItemJinputaoGJ","ItemLiGJ","ItemTaoziGJ","ItemJuziGJ","ItemNingmengGJ","ItemCaomeiGJ","ItemYeziGJ"};
public ItemJam() {
this.setHasSubtypes(true); | // Path: src/main/java/com/foodcraft/FoodCraft.java
// @Mod(modid="foodcraft", name="FoodCraft", version="1.2.0")
//
// public class FoodCraft implements NetworkMod {
// public static boolean JEIIsLoad = false;
// public static final CreativeTabs FcTabMachine = new CreativeTabs("Jiqi") {//机器&工具
// public Item getTabIconItem() {
// return Item.getItemFromBlock(FoodcraftGuiBlocks.Nmj);
// }
// };
// public static final CreativeTabs FcTabPlant = new CreativeTabs("Zhiwu") {//植物
// public Item getTabIconItem() {
// return FoodcraftItems.ItemLajiao;
// }
// };
// public static final CreativeTabs FcTabDrink = new CreativeTabs("Yingliao") {//饮料
// public Item getTabIconItem() {
// return FoodcraftItems.ItemPutaozhi;
// }
// };
// public static final CreativeTabs FcTabStaple = new CreativeTabs("Zhushi") {//主食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemChaotudousifan;
// }
// };
// public static final CreativeTabs FcTabIngredient = new CreativeTabs("Shicai") {//食材
// public Item getTabIconItem() {
// return FoodcraftItems.ItemMianfen;
// }
// };
// public static final CreativeTabs FcTabSnack = new CreativeTabs("Xiaodian") {//零食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemJianjiao;
// }
// };
//
// @SidedProxy(clientSide = "com.foodcraft.proxy.ClientProxy", serverSide = "com.foodcraft.proxy.CommonProxy")
// private static CommonProxy proxy;
//
// @Instance("foodcraft")
// public static FoodCraft instance;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// PacketDispatcher.initInstance("foodcraft", this);
// NERLogManager.log("Loading foodcraft, Version: 1.2.3");
// JEIIsLoad = Loader.isModLoaded("JustEnoughItems");
// NERConfigHandler.initConfig(event);
// NERConfigHandler.getConfig();
// proxy.preInit(event);
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// proxy.init(event);
// MinecraftForge.EVENT_BUS.register(new FcSubscribeEvent());
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @Override
// public Proxy getProxy() {
// return proxy;
// }
// }
// Path: src/main/java/com/foodcraft/item/ItemJam.java
import java.util.List;
import com.foodcraft.FoodCraft;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
package com.foodcraft.item;
public class ItemJam extends Item {
private String[] s = new String[] {"ItemPutaoGJ","ItemJinputaoGJ","ItemLiGJ","ItemTaoziGJ","ItemJuziGJ","ItemNingmengGJ","ItemCaomeiGJ","ItemYeziGJ"};
public ItemJam() {
this.setHasSubtypes(true); | this.setCreativeTab(FoodCraft.FcTabIngredient); |
InfinityStudio/FoodCraft | src/main/java/com/foodcraft/item/ItemKitchenKnifeDiamond.java | // Path: src/main/java/com/foodcraft/FoodCraft.java
// @Mod(modid="foodcraft", name="FoodCraft", version="1.2.0")
//
// public class FoodCraft implements NetworkMod {
// public static boolean JEIIsLoad = false;
// public static final CreativeTabs FcTabMachine = new CreativeTabs("Jiqi") {//机器&工具
// public Item getTabIconItem() {
// return Item.getItemFromBlock(FoodcraftGuiBlocks.Nmj);
// }
// };
// public static final CreativeTabs FcTabPlant = new CreativeTabs("Zhiwu") {//植物
// public Item getTabIconItem() {
// return FoodcraftItems.ItemLajiao;
// }
// };
// public static final CreativeTabs FcTabDrink = new CreativeTabs("Yingliao") {//饮料
// public Item getTabIconItem() {
// return FoodcraftItems.ItemPutaozhi;
// }
// };
// public static final CreativeTabs FcTabStaple = new CreativeTabs("Zhushi") {//主食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemChaotudousifan;
// }
// };
// public static final CreativeTabs FcTabIngredient = new CreativeTabs("Shicai") {//食材
// public Item getTabIconItem() {
// return FoodcraftItems.ItemMianfen;
// }
// };
// public static final CreativeTabs FcTabSnack = new CreativeTabs("Xiaodian") {//零食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemJianjiao;
// }
// };
//
// @SidedProxy(clientSide = "com.foodcraft.proxy.ClientProxy", serverSide = "com.foodcraft.proxy.CommonProxy")
// private static CommonProxy proxy;
//
// @Instance("foodcraft")
// public static FoodCraft instance;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// PacketDispatcher.initInstance("foodcraft", this);
// NERLogManager.log("Loading foodcraft, Version: 1.2.3");
// JEIIsLoad = Loader.isModLoaded("JustEnoughItems");
// NERConfigHandler.initConfig(event);
// NERConfigHandler.getConfig();
// proxy.preInit(event);
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// proxy.init(event);
// MinecraftForge.EVENT_BUS.register(new FcSubscribeEvent());
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @Override
// public Proxy getProxy() {
// return proxy;
// }
// }
//
// Path: src/main/java/com/foodcraft/api/IItemKitchenKnife.java
// public interface IItemKitchenKnife {
// /**
// * Get the Kitchen Knife MaxUses.
// * @return The Kitchen Knife MaxUses.
// */
// public int getMaxUses();
// /**
// *
// * When the chopping board chopping.
// * @param world world
// * @param x PosX
// * @param y PosY
// * @param z PosZ
// * @param Result result
// * @param Quantity Result Quantity
// * @return Add quantity
// */
// public int event(World world, BlockPos pos, ItemStack Result, int Quantity);
// }
| import com.foodcraft.FoodCraft;
import com.foodcraft.api.IItemKitchenKnife;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World; | package com.foodcraft.item;
public class ItemKitchenKnifeDiamond extends Item implements IItemKitchenKnife {
public ItemKitchenKnifeDiamond() {
this.setMaxDamage(480);
this.setMaxStackSize(1);
this.setUnlocalizedName("ItemCaidaoZS"); | // Path: src/main/java/com/foodcraft/FoodCraft.java
// @Mod(modid="foodcraft", name="FoodCraft", version="1.2.0")
//
// public class FoodCraft implements NetworkMod {
// public static boolean JEIIsLoad = false;
// public static final CreativeTabs FcTabMachine = new CreativeTabs("Jiqi") {//机器&工具
// public Item getTabIconItem() {
// return Item.getItemFromBlock(FoodcraftGuiBlocks.Nmj);
// }
// };
// public static final CreativeTabs FcTabPlant = new CreativeTabs("Zhiwu") {//植物
// public Item getTabIconItem() {
// return FoodcraftItems.ItemLajiao;
// }
// };
// public static final CreativeTabs FcTabDrink = new CreativeTabs("Yingliao") {//饮料
// public Item getTabIconItem() {
// return FoodcraftItems.ItemPutaozhi;
// }
// };
// public static final CreativeTabs FcTabStaple = new CreativeTabs("Zhushi") {//主食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemChaotudousifan;
// }
// };
// public static final CreativeTabs FcTabIngredient = new CreativeTabs("Shicai") {//食材
// public Item getTabIconItem() {
// return FoodcraftItems.ItemMianfen;
// }
// };
// public static final CreativeTabs FcTabSnack = new CreativeTabs("Xiaodian") {//零食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemJianjiao;
// }
// };
//
// @SidedProxy(clientSide = "com.foodcraft.proxy.ClientProxy", serverSide = "com.foodcraft.proxy.CommonProxy")
// private static CommonProxy proxy;
//
// @Instance("foodcraft")
// public static FoodCraft instance;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// PacketDispatcher.initInstance("foodcraft", this);
// NERLogManager.log("Loading foodcraft, Version: 1.2.3");
// JEIIsLoad = Loader.isModLoaded("JustEnoughItems");
// NERConfigHandler.initConfig(event);
// NERConfigHandler.getConfig();
// proxy.preInit(event);
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// proxy.init(event);
// MinecraftForge.EVENT_BUS.register(new FcSubscribeEvent());
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @Override
// public Proxy getProxy() {
// return proxy;
// }
// }
//
// Path: src/main/java/com/foodcraft/api/IItemKitchenKnife.java
// public interface IItemKitchenKnife {
// /**
// * Get the Kitchen Knife MaxUses.
// * @return The Kitchen Knife MaxUses.
// */
// public int getMaxUses();
// /**
// *
// * When the chopping board chopping.
// * @param world world
// * @param x PosX
// * @param y PosY
// * @param z PosZ
// * @param Result result
// * @param Quantity Result Quantity
// * @return Add quantity
// */
// public int event(World world, BlockPos pos, ItemStack Result, int Quantity);
// }
// Path: src/main/java/com/foodcraft/item/ItemKitchenKnifeDiamond.java
import com.foodcraft.FoodCraft;
import com.foodcraft.api.IItemKitchenKnife;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
package com.foodcraft.item;
public class ItemKitchenKnifeDiamond extends Item implements IItemKitchenKnife {
public ItemKitchenKnifeDiamond() {
this.setMaxDamage(480);
this.setMaxStackSize(1);
this.setUnlocalizedName("ItemCaidaoZS"); | this.setCreativeTab(FoodCraft.FcTabMachine); |
InfinityStudio/FoodCraft | src/main/java/com/foodcraft/support/jei/milling/MillingRecipeCategory.java | // Path: src/main/java/com/foodcraft/support/jei/FcRecipeUids.java
// public interface FcRecipeUids {
// String MILLING = "foodcraft.milling";
// String CHOPPING = "foodcraft.chopping";
// String PRESSURE_COOKER = "foodcraft.pressure_cooker";
// String PAN = "foodcraft.pan";
// String BREW_BARREL = "foodcraft.brew_barrel";
// String FRYING = "foodcraft.frying";
// String BEVERAGE_MAKING = "foodcraft.beverage_making";
// String POT = "foodcraft.pot";
// String STOVE = "foodcraft.stove";
// }
| import com.foodcraft.support.jei.FcRecipeUids;
import mezz.jei.api.IGuiHelper;
import mezz.jei.api.gui.*;
import mezz.jei.api.recipe.BlankRecipeCategory;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.client.Minecraft;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import javax.annotation.Nonnull; | package com.foodcraft.support.jei.milling;
public class MillingRecipeCategory extends BlankRecipeCategory {
@Nonnull
private final IDrawable background;
@Nonnull
private final IDrawable arrow;
@Nonnull
private final IDrawable flame;
@Nonnull
private final String localizedName;
public MillingRecipeCategory(IGuiHelper guiHelper) {
ResourceLocation location = new ResourceLocation("foodcraft:textures/gui/nei/nmj.png");
background = guiHelper.createDrawable(location, 48, 18, 81, 53);
localizedName = StatCollector.translateToLocal("tile.Nmj.name");
IDrawableStatic flameDrawable = guiHelper.createDrawable(location, 176, 0, 14, 14);
flame = guiHelper.createAnimatedDrawable(flameDrawable, 300, IDrawableAnimated.StartDirection.TOP, true);
IDrawableStatic arrowDrawable = guiHelper.createDrawable(location, 176, 14, 22, 12);
this.arrow = guiHelper.createAnimatedDrawable(arrowDrawable, 200, IDrawableAnimated.StartDirection.LEFT, false);
}
@Nonnull
@Override
public String getUid() { | // Path: src/main/java/com/foodcraft/support/jei/FcRecipeUids.java
// public interface FcRecipeUids {
// String MILLING = "foodcraft.milling";
// String CHOPPING = "foodcraft.chopping";
// String PRESSURE_COOKER = "foodcraft.pressure_cooker";
// String PAN = "foodcraft.pan";
// String BREW_BARREL = "foodcraft.brew_barrel";
// String FRYING = "foodcraft.frying";
// String BEVERAGE_MAKING = "foodcraft.beverage_making";
// String POT = "foodcraft.pot";
// String STOVE = "foodcraft.stove";
// }
// Path: src/main/java/com/foodcraft/support/jei/milling/MillingRecipeCategory.java
import com.foodcraft.support.jei.FcRecipeUids;
import mezz.jei.api.IGuiHelper;
import mezz.jei.api.gui.*;
import mezz.jei.api.recipe.BlankRecipeCategory;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.client.Minecraft;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import javax.annotation.Nonnull;
package com.foodcraft.support.jei.milling;
public class MillingRecipeCategory extends BlankRecipeCategory {
@Nonnull
private final IDrawable background;
@Nonnull
private final IDrawable arrow;
@Nonnull
private final IDrawable flame;
@Nonnull
private final String localizedName;
public MillingRecipeCategory(IGuiHelper guiHelper) {
ResourceLocation location = new ResourceLocation("foodcraft:textures/gui/nei/nmj.png");
background = guiHelper.createDrawable(location, 48, 18, 81, 53);
localizedName = StatCollector.translateToLocal("tile.Nmj.name");
IDrawableStatic flameDrawable = guiHelper.createDrawable(location, 176, 0, 14, 14);
flame = guiHelper.createAnimatedDrawable(flameDrawable, 300, IDrawableAnimated.StartDirection.TOP, true);
IDrawableStatic arrowDrawable = guiHelper.createDrawable(location, 176, 14, 22, 12);
this.arrow = guiHelper.createAnimatedDrawable(arrowDrawable, 200, IDrawableAnimated.StartDirection.LEFT, false);
}
@Nonnull
@Override
public String getUid() { | return FcRecipeUids.MILLING; |
InfinityStudio/FoodCraft | src/main/java/com/foodcraft/item/ItemKitchenKnifeGold.java | // Path: src/main/java/com/foodcraft/FoodCraft.java
// @Mod(modid="foodcraft", name="FoodCraft", version="1.2.0")
//
// public class FoodCraft implements NetworkMod {
// public static boolean JEIIsLoad = false;
// public static final CreativeTabs FcTabMachine = new CreativeTabs("Jiqi") {//机器&工具
// public Item getTabIconItem() {
// return Item.getItemFromBlock(FoodcraftGuiBlocks.Nmj);
// }
// };
// public static final CreativeTabs FcTabPlant = new CreativeTabs("Zhiwu") {//植物
// public Item getTabIconItem() {
// return FoodcraftItems.ItemLajiao;
// }
// };
// public static final CreativeTabs FcTabDrink = new CreativeTabs("Yingliao") {//饮料
// public Item getTabIconItem() {
// return FoodcraftItems.ItemPutaozhi;
// }
// };
// public static final CreativeTabs FcTabStaple = new CreativeTabs("Zhushi") {//主食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemChaotudousifan;
// }
// };
// public static final CreativeTabs FcTabIngredient = new CreativeTabs("Shicai") {//食材
// public Item getTabIconItem() {
// return FoodcraftItems.ItemMianfen;
// }
// };
// public static final CreativeTabs FcTabSnack = new CreativeTabs("Xiaodian") {//零食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemJianjiao;
// }
// };
//
// @SidedProxy(clientSide = "com.foodcraft.proxy.ClientProxy", serverSide = "com.foodcraft.proxy.CommonProxy")
// private static CommonProxy proxy;
//
// @Instance("foodcraft")
// public static FoodCraft instance;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// PacketDispatcher.initInstance("foodcraft", this);
// NERLogManager.log("Loading foodcraft, Version: 1.2.3");
// JEIIsLoad = Loader.isModLoaded("JustEnoughItems");
// NERConfigHandler.initConfig(event);
// NERConfigHandler.getConfig();
// proxy.preInit(event);
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// proxy.init(event);
// MinecraftForge.EVENT_BUS.register(new FcSubscribeEvent());
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @Override
// public Proxy getProxy() {
// return proxy;
// }
// }
//
// Path: src/main/java/com/foodcraft/api/IItemKitchenKnife.java
// public interface IItemKitchenKnife {
// /**
// * Get the Kitchen Knife MaxUses.
// * @return The Kitchen Knife MaxUses.
// */
// public int getMaxUses();
// /**
// *
// * When the chopping board chopping.
// * @param world world
// * @param x PosX
// * @param y PosY
// * @param z PosZ
// * @param Result result
// * @param Quantity Result Quantity
// * @return Add quantity
// */
// public int event(World world, BlockPos pos, ItemStack Result, int Quantity);
// }
| import com.foodcraft.FoodCraft;
import com.foodcraft.api.IItemKitchenKnife;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World; | package com.foodcraft.item;
public class ItemKitchenKnifeGold extends Item implements IItemKitchenKnife {
public ItemKitchenKnifeGold() {
this.setMaxDamage(32);
this.setMaxStackSize(1);
this.setUnlocalizedName("ItemCaidaoHJ"); | // Path: src/main/java/com/foodcraft/FoodCraft.java
// @Mod(modid="foodcraft", name="FoodCraft", version="1.2.0")
//
// public class FoodCraft implements NetworkMod {
// public static boolean JEIIsLoad = false;
// public static final CreativeTabs FcTabMachine = new CreativeTabs("Jiqi") {//机器&工具
// public Item getTabIconItem() {
// return Item.getItemFromBlock(FoodcraftGuiBlocks.Nmj);
// }
// };
// public static final CreativeTabs FcTabPlant = new CreativeTabs("Zhiwu") {//植物
// public Item getTabIconItem() {
// return FoodcraftItems.ItemLajiao;
// }
// };
// public static final CreativeTabs FcTabDrink = new CreativeTabs("Yingliao") {//饮料
// public Item getTabIconItem() {
// return FoodcraftItems.ItemPutaozhi;
// }
// };
// public static final CreativeTabs FcTabStaple = new CreativeTabs("Zhushi") {//主食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemChaotudousifan;
// }
// };
// public static final CreativeTabs FcTabIngredient = new CreativeTabs("Shicai") {//食材
// public Item getTabIconItem() {
// return FoodcraftItems.ItemMianfen;
// }
// };
// public static final CreativeTabs FcTabSnack = new CreativeTabs("Xiaodian") {//零食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemJianjiao;
// }
// };
//
// @SidedProxy(clientSide = "com.foodcraft.proxy.ClientProxy", serverSide = "com.foodcraft.proxy.CommonProxy")
// private static CommonProxy proxy;
//
// @Instance("foodcraft")
// public static FoodCraft instance;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// PacketDispatcher.initInstance("foodcraft", this);
// NERLogManager.log("Loading foodcraft, Version: 1.2.3");
// JEIIsLoad = Loader.isModLoaded("JustEnoughItems");
// NERConfigHandler.initConfig(event);
// NERConfigHandler.getConfig();
// proxy.preInit(event);
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// proxy.init(event);
// MinecraftForge.EVENT_BUS.register(new FcSubscribeEvent());
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @Override
// public Proxy getProxy() {
// return proxy;
// }
// }
//
// Path: src/main/java/com/foodcraft/api/IItemKitchenKnife.java
// public interface IItemKitchenKnife {
// /**
// * Get the Kitchen Knife MaxUses.
// * @return The Kitchen Knife MaxUses.
// */
// public int getMaxUses();
// /**
// *
// * When the chopping board chopping.
// * @param world world
// * @param x PosX
// * @param y PosY
// * @param z PosZ
// * @param Result result
// * @param Quantity Result Quantity
// * @return Add quantity
// */
// public int event(World world, BlockPos pos, ItemStack Result, int Quantity);
// }
// Path: src/main/java/com/foodcraft/item/ItemKitchenKnifeGold.java
import com.foodcraft.FoodCraft;
import com.foodcraft.api.IItemKitchenKnife;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
package com.foodcraft.item;
public class ItemKitchenKnifeGold extends Item implements IItemKitchenKnife {
public ItemKitchenKnifeGold() {
this.setMaxDamage(32);
this.setMaxStackSize(1);
this.setUnlocalizedName("ItemCaidaoHJ"); | this.setCreativeTab(FoodCraft.FcTabMachine); |
InfinityStudio/FoodCraft | src/main/java/com/foodcraft/support/jei/pressurecooker/PressureCookerRecipeHandler.java | // Path: src/main/java/com/foodcraft/support/jei/FcRecipeHandler.java
// public abstract class FcRecipeHandler<T> implements IRecipeHandler<T> {
// @Override
// public boolean isRecipeValid(@Nonnull T t) {
// return true;
// }
// }
//
// Path: src/main/java/com/foodcraft/support/jei/FcRecipeUids.java
// public interface FcRecipeUids {
// String MILLING = "foodcraft.milling";
// String CHOPPING = "foodcraft.chopping";
// String PRESSURE_COOKER = "foodcraft.pressure_cooker";
// String PAN = "foodcraft.pan";
// String BREW_BARREL = "foodcraft.brew_barrel";
// String FRYING = "foodcraft.frying";
// String BEVERAGE_MAKING = "foodcraft.beverage_making";
// String POT = "foodcraft.pot";
// String STOVE = "foodcraft.stove";
// }
| import com.foodcraft.support.jei.FcRecipeHandler;
import com.foodcraft.support.jei.FcRecipeUids;
import mezz.jei.api.recipe.IRecipeWrapper;
import javax.annotation.Nonnull; | package com.foodcraft.support.jei.pressurecooker;
public class PressureCookerRecipeHandler extends FcRecipeHandler<PressureCookerRecipeWrapper> {
@Override
public boolean isRecipeValid(@Nonnull PressureCookerRecipeWrapper pressureCookerRecipeWrapper) {
return pressureCookerRecipeWrapper.getInputs().size() > 0 && pressureCookerRecipeWrapper.getOutputs().size() == 1;
}
@Nonnull
@Override
public Class<PressureCookerRecipeWrapper> getRecipeClass() {
return PressureCookerRecipeWrapper.class;
}
@Nonnull
@Override
public String getRecipeCategoryUid() { | // Path: src/main/java/com/foodcraft/support/jei/FcRecipeHandler.java
// public abstract class FcRecipeHandler<T> implements IRecipeHandler<T> {
// @Override
// public boolean isRecipeValid(@Nonnull T t) {
// return true;
// }
// }
//
// Path: src/main/java/com/foodcraft/support/jei/FcRecipeUids.java
// public interface FcRecipeUids {
// String MILLING = "foodcraft.milling";
// String CHOPPING = "foodcraft.chopping";
// String PRESSURE_COOKER = "foodcraft.pressure_cooker";
// String PAN = "foodcraft.pan";
// String BREW_BARREL = "foodcraft.brew_barrel";
// String FRYING = "foodcraft.frying";
// String BEVERAGE_MAKING = "foodcraft.beverage_making";
// String POT = "foodcraft.pot";
// String STOVE = "foodcraft.stove";
// }
// Path: src/main/java/com/foodcraft/support/jei/pressurecooker/PressureCookerRecipeHandler.java
import com.foodcraft.support.jei.FcRecipeHandler;
import com.foodcraft.support.jei.FcRecipeUids;
import mezz.jei.api.recipe.IRecipeWrapper;
import javax.annotation.Nonnull;
package com.foodcraft.support.jei.pressurecooker;
public class PressureCookerRecipeHandler extends FcRecipeHandler<PressureCookerRecipeWrapper> {
@Override
public boolean isRecipeValid(@Nonnull PressureCookerRecipeWrapper pressureCookerRecipeWrapper) {
return pressureCookerRecipeWrapper.getInputs().size() > 0 && pressureCookerRecipeWrapper.getOutputs().size() == 1;
}
@Nonnull
@Override
public Class<PressureCookerRecipeWrapper> getRecipeClass() {
return PressureCookerRecipeWrapper.class;
}
@Nonnull
@Override
public String getRecipeCategoryUid() { | return FcRecipeUids.PRESSURE_COOKER; |
InfinityStudio/FoodCraft | src/main/java/com/foodcraft/init/FoodcraftRecipe.java | // Path: src/main/java/com/foodcraft/util/FcUtil.java
// public class FcUtil {
//
// public static void dropItemAsEntity(World world, double posX, double posY, double posZ, ItemStack itemStack) {
//
// if (itemStack == null) {
// return;
// }
// double f = 0.7D;
// double dx = world.rand.nextFloat() * f + (1.0D - f) * 0.5D;
// double dy = world.rand.nextFloat() * f + (1.0D - f) * 0.5D;
// double dz = world.rand.nextFloat() * f + (1.0D - f) * 0.5D;
//
// EntityItem entityItem = new EntityItem(world, posX + dx, posY + dy, posZ + dz, itemStack.copy());
// entityItem.setDefaultPickupDelay();
// world.spawnEntityInWorld(entityItem);
// }
//
// public static void removeRecipe(ItemStack ItemStack) {
// List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
// for (int i = 0; i < recipes.size(); i++) {
// IRecipe tmpRecipe = recipes.get(i);
// ItemStack recipeResult = tmpRecipe.getRecipeOutput();
// if (ItemStack.areItemStacksEqual(ItemStack, recipeResult)) recipes.remove(i--);
// }
// }
// }
| import com.foodcraft.util.FcUtil;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.util.WeightedRandomChestContent;
import net.minecraftforge.common.ChestGenHooks;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe; | package com.foodcraft.init;
public class FoodcraftRecipe {
public static class FcGameRegistry extends GameRegistry {
public static void addRecipe(ItemStack output, Object... params)
{
addShapedRecipe(output, params);
}
public static IRecipe addShapedRecipe(ItemStack output, Object... params)
{
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(output, params));
return new ShapedOreRecipe(output, params);
}
public static void addShapelessRecipe(ItemStack output, Object... params)
{
CraftingManager.getInstance().getRecipeList().add(new ShapelessOreRecipe(output, params));
}
}
public static void init() {
Items.egg.setMaxStackSize(64);
Items.snowball.setMaxStackSize(64);
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(FoodcraftItems.ItemTiepian, 16), "###", "#X#","###", '#',"ingotIron",'X',"stone"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(FoodcraftItems.ItemCaidao, 1), "## ", "## ","X ", '#',FoodcraftItems.ItemTiepian,'X',"stickWood"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(FoodcraftItems.ItemCaidaoHJ, 1), "## ", "## ","X ", '#',"ingotGold",'X',"stickWood"));
FcGameRegistry.addRecipe(new ItemStack(FoodcraftItems.ItemCaidaoZS, 1), "## ", "## ","X ", '#',Items.diamond,'X',Items.stick);
FcGameRegistry.addRecipe(new ItemStack(FoodcraftItems.ItemCaidaoLBS, 1), "## ", "## ","X ", '#',Items.emerald,'X',Items.stick);
| // Path: src/main/java/com/foodcraft/util/FcUtil.java
// public class FcUtil {
//
// public static void dropItemAsEntity(World world, double posX, double posY, double posZ, ItemStack itemStack) {
//
// if (itemStack == null) {
// return;
// }
// double f = 0.7D;
// double dx = world.rand.nextFloat() * f + (1.0D - f) * 0.5D;
// double dy = world.rand.nextFloat() * f + (1.0D - f) * 0.5D;
// double dz = world.rand.nextFloat() * f + (1.0D - f) * 0.5D;
//
// EntityItem entityItem = new EntityItem(world, posX + dx, posY + dy, posZ + dz, itemStack.copy());
// entityItem.setDefaultPickupDelay();
// world.spawnEntityInWorld(entityItem);
// }
//
// public static void removeRecipe(ItemStack ItemStack) {
// List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
// for (int i = 0; i < recipes.size(); i++) {
// IRecipe tmpRecipe = recipes.get(i);
// ItemStack recipeResult = tmpRecipe.getRecipeOutput();
// if (ItemStack.areItemStacksEqual(ItemStack, recipeResult)) recipes.remove(i--);
// }
// }
// }
// Path: src/main/java/com/foodcraft/init/FoodcraftRecipe.java
import com.foodcraft.util.FcUtil;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.util.WeightedRandomChestContent;
import net.minecraftforge.common.ChestGenHooks;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
package com.foodcraft.init;
public class FoodcraftRecipe {
public static class FcGameRegistry extends GameRegistry {
public static void addRecipe(ItemStack output, Object... params)
{
addShapedRecipe(output, params);
}
public static IRecipe addShapedRecipe(ItemStack output, Object... params)
{
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(output, params));
return new ShapedOreRecipe(output, params);
}
public static void addShapelessRecipe(ItemStack output, Object... params)
{
CraftingManager.getInstance().getRecipeList().add(new ShapelessOreRecipe(output, params));
}
}
public static void init() {
Items.egg.setMaxStackSize(64);
Items.snowball.setMaxStackSize(64);
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(FoodcraftItems.ItemTiepian, 16), "###", "#X#","###", '#',"ingotIron",'X',"stone"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(FoodcraftItems.ItemCaidao, 1), "## ", "## ","X ", '#',FoodcraftItems.ItemTiepian,'X',"stickWood"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(FoodcraftItems.ItemCaidaoHJ, 1), "## ", "## ","X ", '#',"ingotGold",'X',"stickWood"));
FcGameRegistry.addRecipe(new ItemStack(FoodcraftItems.ItemCaidaoZS, 1), "## ", "## ","X ", '#',Items.diamond,'X',Items.stick);
FcGameRegistry.addRecipe(new ItemStack(FoodcraftItems.ItemCaidaoLBS, 1), "## ", "## ","X ", '#',Items.emerald,'X',Items.stick);
| FcUtil.removeRecipe(new ItemStack(Items.cake)); |
InfinityStudio/FoodCraft | src/main/java/com/foodcraft/init/FoodcraftBlocks.java | // Path: src/main/java/com/foodcraft/FoodCraft.java
// @Mod(modid="foodcraft", name="FoodCraft", version="1.2.0")
//
// public class FoodCraft implements NetworkMod {
// public static boolean JEIIsLoad = false;
// public static final CreativeTabs FcTabMachine = new CreativeTabs("Jiqi") {//机器&工具
// public Item getTabIconItem() {
// return Item.getItemFromBlock(FoodcraftGuiBlocks.Nmj);
// }
// };
// public static final CreativeTabs FcTabPlant = new CreativeTabs("Zhiwu") {//植物
// public Item getTabIconItem() {
// return FoodcraftItems.ItemLajiao;
// }
// };
// public static final CreativeTabs FcTabDrink = new CreativeTabs("Yingliao") {//饮料
// public Item getTabIconItem() {
// return FoodcraftItems.ItemPutaozhi;
// }
// };
// public static final CreativeTabs FcTabStaple = new CreativeTabs("Zhushi") {//主食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemChaotudousifan;
// }
// };
// public static final CreativeTabs FcTabIngredient = new CreativeTabs("Shicai") {//食材
// public Item getTabIconItem() {
// return FoodcraftItems.ItemMianfen;
// }
// };
// public static final CreativeTabs FcTabSnack = new CreativeTabs("Xiaodian") {//零食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemJianjiao;
// }
// };
//
// @SidedProxy(clientSide = "com.foodcraft.proxy.ClientProxy", serverSide = "com.foodcraft.proxy.CommonProxy")
// private static CommonProxy proxy;
//
// @Instance("foodcraft")
// public static FoodCraft instance;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// PacketDispatcher.initInstance("foodcraft", this);
// NERLogManager.log("Loading foodcraft, Version: 1.2.3");
// JEIIsLoad = Loader.isModLoaded("JustEnoughItems");
// NERConfigHandler.initConfig(event);
// NERConfigHandler.getConfig();
// proxy.preInit(event);
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// proxy.init(event);
// MinecraftForge.EVENT_BUS.register(new FcSubscribeEvent());
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @Override
// public Proxy getProxy() {
// return proxy;
// }
// }
//
// Path: src/main/java/com/foodcraft/block/BlockCakeFoodcraft.java
// public class BlockCakeFoodcraft extends BlockCake {
//
// private String[] names = new String[] {"BlockPutaoDG","BlockJinputaoDG","BlockLiDG","BlockTaoziDG","BlockJuziDG","BlockNingmengDG","BlockCaomeiDG","BlockYeziDG"};
//
// public BlockCakeFoodcraft() {
// this.disableStats();
// this.setHardness(0.5F).setStepSound(Block.soundTypeCloth);
// }
// @Override
// @SideOnly(Side.CLIENT)
// public Item getItem(World worldIn, BlockPos pos) {
// return Item.getItemFromBlock(this);
// }
// }
//
// Path: src/main/java/com/foodcraft/block/BlockFc.java
// public class BlockFc extends Block {
// public BlockFc(Material material, String name) {
// super(material);
// this.setUnlocalizedName(name);
// this.setCreativeTab(FoodCraft.FcTabMachine);
// }
// }
//
// Path: src/main/java/com/foodcraft/block/BlockGoldenGrapeCake.java
// public class BlockGoldenGrapeCake extends BlockCake {
//
// public BlockGoldenGrapeCake() {
// this.disableStats();
// this.setHardness(0.5F).setStepSound(Block.soundTypeCloth);
// }
//
// @Override
// @SideOnly(Side.CLIENT)
// public Item getItem(World worldIn, BlockPos pos) {
// return Item.getItemFromBlock(this);
// }
//
//
// @Override
// @SideOnly(Side.CLIENT)
// public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
// if (!worldIn.isRemote) {
// int j = ((Integer)state.getValue(BITES)).intValue();
// if(j > 0) {
// worldIn.setBlockState(pos, state.withProperty(BITES, Integer.valueOf(j - 1)), 3);
// }
// }
// }
// }
| import com.foodcraft.FoodCraft;
import com.foodcraft.block.BlockCakeFoodcraft;
import com.foodcraft.block.BlockFc;
import com.foodcraft.block.BlockGoldenGrapeCake;
import com.foodcraft.gui.blocks.*;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.item.Item;
import net.minecraftforge.fml.common.registry.GameRegistry; | package com.foodcraft.init;
public class FoodcraftBlocks {
static public Block BlockWaike,Blocksugar,BlockDami,BlockHuashenk,BlockLuobo,BlockTudou,BlockYan,BlockDouzik,BlockRuomi,BlockDouban,
BlockQiaokeli,BlockPutaoDG,BlockJinputaoDG,BlockLiDG,BlockTaoziDG,BlockJuziDG,BlockNingmengDG,BlockCaomeiDG,BlockYeziDG;
public static void init() { | // Path: src/main/java/com/foodcraft/FoodCraft.java
// @Mod(modid="foodcraft", name="FoodCraft", version="1.2.0")
//
// public class FoodCraft implements NetworkMod {
// public static boolean JEIIsLoad = false;
// public static final CreativeTabs FcTabMachine = new CreativeTabs("Jiqi") {//机器&工具
// public Item getTabIconItem() {
// return Item.getItemFromBlock(FoodcraftGuiBlocks.Nmj);
// }
// };
// public static final CreativeTabs FcTabPlant = new CreativeTabs("Zhiwu") {//植物
// public Item getTabIconItem() {
// return FoodcraftItems.ItemLajiao;
// }
// };
// public static final CreativeTabs FcTabDrink = new CreativeTabs("Yingliao") {//饮料
// public Item getTabIconItem() {
// return FoodcraftItems.ItemPutaozhi;
// }
// };
// public static final CreativeTabs FcTabStaple = new CreativeTabs("Zhushi") {//主食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemChaotudousifan;
// }
// };
// public static final CreativeTabs FcTabIngredient = new CreativeTabs("Shicai") {//食材
// public Item getTabIconItem() {
// return FoodcraftItems.ItemMianfen;
// }
// };
// public static final CreativeTabs FcTabSnack = new CreativeTabs("Xiaodian") {//零食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemJianjiao;
// }
// };
//
// @SidedProxy(clientSide = "com.foodcraft.proxy.ClientProxy", serverSide = "com.foodcraft.proxy.CommonProxy")
// private static CommonProxy proxy;
//
// @Instance("foodcraft")
// public static FoodCraft instance;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// PacketDispatcher.initInstance("foodcraft", this);
// NERLogManager.log("Loading foodcraft, Version: 1.2.3");
// JEIIsLoad = Loader.isModLoaded("JustEnoughItems");
// NERConfigHandler.initConfig(event);
// NERConfigHandler.getConfig();
// proxy.preInit(event);
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// proxy.init(event);
// MinecraftForge.EVENT_BUS.register(new FcSubscribeEvent());
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @Override
// public Proxy getProxy() {
// return proxy;
// }
// }
//
// Path: src/main/java/com/foodcraft/block/BlockCakeFoodcraft.java
// public class BlockCakeFoodcraft extends BlockCake {
//
// private String[] names = new String[] {"BlockPutaoDG","BlockJinputaoDG","BlockLiDG","BlockTaoziDG","BlockJuziDG","BlockNingmengDG","BlockCaomeiDG","BlockYeziDG"};
//
// public BlockCakeFoodcraft() {
// this.disableStats();
// this.setHardness(0.5F).setStepSound(Block.soundTypeCloth);
// }
// @Override
// @SideOnly(Side.CLIENT)
// public Item getItem(World worldIn, BlockPos pos) {
// return Item.getItemFromBlock(this);
// }
// }
//
// Path: src/main/java/com/foodcraft/block/BlockFc.java
// public class BlockFc extends Block {
// public BlockFc(Material material, String name) {
// super(material);
// this.setUnlocalizedName(name);
// this.setCreativeTab(FoodCraft.FcTabMachine);
// }
// }
//
// Path: src/main/java/com/foodcraft/block/BlockGoldenGrapeCake.java
// public class BlockGoldenGrapeCake extends BlockCake {
//
// public BlockGoldenGrapeCake() {
// this.disableStats();
// this.setHardness(0.5F).setStepSound(Block.soundTypeCloth);
// }
//
// @Override
// @SideOnly(Side.CLIENT)
// public Item getItem(World worldIn, BlockPos pos) {
// return Item.getItemFromBlock(this);
// }
//
//
// @Override
// @SideOnly(Side.CLIENT)
// public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
// if (!worldIn.isRemote) {
// int j = ((Integer)state.getValue(BITES)).intValue();
// if(j > 0) {
// worldIn.setBlockState(pos, state.withProperty(BITES, Integer.valueOf(j - 1)), 3);
// }
// }
// }
// }
// Path: src/main/java/com/foodcraft/init/FoodcraftBlocks.java
import com.foodcraft.FoodCraft;
import com.foodcraft.block.BlockCakeFoodcraft;
import com.foodcraft.block.BlockFc;
import com.foodcraft.block.BlockGoldenGrapeCake;
import com.foodcraft.gui.blocks.*;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.item.Item;
import net.minecraftforge.fml.common.registry.GameRegistry;
package com.foodcraft.init;
public class FoodcraftBlocks {
static public Block BlockWaike,Blocksugar,BlockDami,BlockHuashenk,BlockLuobo,BlockTudou,BlockYan,BlockDouzik,BlockRuomi,BlockDouban,
BlockQiaokeli,BlockPutaoDG,BlockJinputaoDG,BlockLiDG,BlockTaoziDG,BlockJuziDG,BlockNingmengDG,BlockCaomeiDG,BlockYeziDG;
public static void init() { | BlockWaike = new BlockFc(Material.rock, "BlockWaike").setStepSound(Block.soundTypeStone); |
InfinityStudio/FoodCraft | src/main/java/com/foodcraft/gui/items/ItemBlockPan.java | // Path: src/main/java/com/foodcraft/gui/blocks/BlockPan.java
// public class BlockPan extends BlockGuiFc {
//
// public BlockPan() {
// this.setHardness(3.0f);
// this.setBlockBounds(0F, 0F, 0F, 1F, 0.3F, 1F);
// this.setUnlocalizedName("PDG");
// this.setHarvestLevel("pickaxe", 2);
// this.setStepSound(Block.soundTypeStone);
// this.setCreativeTab(FoodCraft.FcTabMachine);
// this.setLightOpacity(0);
// this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
// GameRegistry.registerBlock(this,ItemBlockPan.class, "PDG");
// }
//
// @Override
// public TileEntity createNewTileEntity(World var1, int var2) {
// return new TileEntityPan();
// }
//
// public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) {
// return Item.getItemFromBlock(FoodcraftGuiBlocks.PDG);
// }
//
// @SideOnly(Side.CLIENT)
// public Item getItem(World w, int x, int y, int z) {
// return Item.getItemFromBlock(FoodcraftGuiBlocks.PDG);
// }
//
// public int getRenderType() {
// return 3;
// }
//
// public boolean isOpaqueCube() {
// return false;
// }
//
// public boolean isFullCube() {
// return false;
// }
//
// @Override
// public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ) {
// ItemStack stack = playerIn.inventory.mainInventory[playerIn.inventory.currentItem];
// playerIn.openGui(FoodCraft.instance, GuiIDs.GUI_PDG, worldIn,pos.getX(), pos.getY(), pos.getZ());
// return true;
// }
// public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
// TileEntity tileentity = worldIn.getTileEntity(pos);
// if (tileentity instanceof TileEntityPan) {
// InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityPan)tileentity);
// worldIn.updateComparatorOutputLevel(pos, this);
// }
// super.breakBlock(worldIn, pos, state);
// }
//
//
//
// public static int getFrequencyOfUse(ItemStack item) {
// if (item.getTagCompound() == null) item.setTagCompound(new NBTTagCompound());
// return item.getTagCompound().getInteger("frequencyOfUse");
// }
//
// @Override
// public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
// if (stack.getTagCompound() != null) {
// int xh = getFrequencyOfUse(stack);
// TileEntityPan tep = (TileEntityPan)worldIn.getTileEntity(pos);
// tep.frequencyOfUse = xh;
// }
// }
// }
//
// Path: src/main/java/com/foodcraft/init/FoodcraftGuiBlocks.java
// public class FoodcraftGuiBlocks {
//
// public static Block Nmj,lit_Nmj,PDG,Guo,Gyg,Caiban,YZJ,lit_YZJ,Nt,lit_Nt,Zl,lit_Zl,Tpj,lit_Tpj;
//
// public static void init() {
// Nmj = new BlockMill(false);
// lit_Nmj = new BlockMill(true);
// YZJ = new BlockFrying(false);
// lit_YZJ = new BlockFrying(true);
// Zl = new BlockStove(false);
// lit_Zl = new BlockStove(true);
// Tpj = new BlockBeverageMaking(false);
// lit_Tpj = new BlockBeverageMaking(true);
// Nt = new BlockBrewBarrel(false);
// PDG = new BlockPan();
// Guo = new BlockPot();
// Gyg = new BlockPressureCooker();
// Caiban = new BlockChoppingBoard();
// }
// }
| import java.util.List;
import com.foodcraft.gui.blocks.BlockPan;
import com.foodcraft.init.FoodcraftGuiBlocks;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector; | package com.foodcraft.gui.items;
public class ItemBlockPan extends ItemBlock {
public ItemBlockPan(Block block) {
super(block);
}
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack item, EntityPlayer player, List list, boolean par4) { | // Path: src/main/java/com/foodcraft/gui/blocks/BlockPan.java
// public class BlockPan extends BlockGuiFc {
//
// public BlockPan() {
// this.setHardness(3.0f);
// this.setBlockBounds(0F, 0F, 0F, 1F, 0.3F, 1F);
// this.setUnlocalizedName("PDG");
// this.setHarvestLevel("pickaxe", 2);
// this.setStepSound(Block.soundTypeStone);
// this.setCreativeTab(FoodCraft.FcTabMachine);
// this.setLightOpacity(0);
// this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
// GameRegistry.registerBlock(this,ItemBlockPan.class, "PDG");
// }
//
// @Override
// public TileEntity createNewTileEntity(World var1, int var2) {
// return new TileEntityPan();
// }
//
// public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) {
// return Item.getItemFromBlock(FoodcraftGuiBlocks.PDG);
// }
//
// @SideOnly(Side.CLIENT)
// public Item getItem(World w, int x, int y, int z) {
// return Item.getItemFromBlock(FoodcraftGuiBlocks.PDG);
// }
//
// public int getRenderType() {
// return 3;
// }
//
// public boolean isOpaqueCube() {
// return false;
// }
//
// public boolean isFullCube() {
// return false;
// }
//
// @Override
// public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ) {
// ItemStack stack = playerIn.inventory.mainInventory[playerIn.inventory.currentItem];
// playerIn.openGui(FoodCraft.instance, GuiIDs.GUI_PDG, worldIn,pos.getX(), pos.getY(), pos.getZ());
// return true;
// }
// public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
// TileEntity tileentity = worldIn.getTileEntity(pos);
// if (tileentity instanceof TileEntityPan) {
// InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityPan)tileentity);
// worldIn.updateComparatorOutputLevel(pos, this);
// }
// super.breakBlock(worldIn, pos, state);
// }
//
//
//
// public static int getFrequencyOfUse(ItemStack item) {
// if (item.getTagCompound() == null) item.setTagCompound(new NBTTagCompound());
// return item.getTagCompound().getInteger("frequencyOfUse");
// }
//
// @Override
// public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
// if (stack.getTagCompound() != null) {
// int xh = getFrequencyOfUse(stack);
// TileEntityPan tep = (TileEntityPan)worldIn.getTileEntity(pos);
// tep.frequencyOfUse = xh;
// }
// }
// }
//
// Path: src/main/java/com/foodcraft/init/FoodcraftGuiBlocks.java
// public class FoodcraftGuiBlocks {
//
// public static Block Nmj,lit_Nmj,PDG,Guo,Gyg,Caiban,YZJ,lit_YZJ,Nt,lit_Nt,Zl,lit_Zl,Tpj,lit_Tpj;
//
// public static void init() {
// Nmj = new BlockMill(false);
// lit_Nmj = new BlockMill(true);
// YZJ = new BlockFrying(false);
// lit_YZJ = new BlockFrying(true);
// Zl = new BlockStove(false);
// lit_Zl = new BlockStove(true);
// Tpj = new BlockBeverageMaking(false);
// lit_Tpj = new BlockBeverageMaking(true);
// Nt = new BlockBrewBarrel(false);
// PDG = new BlockPan();
// Guo = new BlockPot();
// Gyg = new BlockPressureCooker();
// Caiban = new BlockChoppingBoard();
// }
// }
// Path: src/main/java/com/foodcraft/gui/items/ItemBlockPan.java
import java.util.List;
import com.foodcraft.gui.blocks.BlockPan;
import com.foodcraft.init.FoodcraftGuiBlocks;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
package com.foodcraft.gui.items;
public class ItemBlockPan extends ItemBlock {
public ItemBlockPan(Block block) {
super(block);
}
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack item, EntityPlayer player, List list, boolean par4) { | list.add(StatCollector.translateToLocal("gui.UseF.name") + BlockPan.getFrequencyOfUse(item)); |
InfinityStudio/FoodCraft | src/main/java/com/foodcraft/gui/items/ItemBlockPot.java | // Path: src/main/java/com/foodcraft/gui/blocks/BlockPot.java
// public class BlockPot extends BlockGuiFc {
// private final Random Random = new Random();
// public BlockPot() {
// this.setHardness(3.0f);
// this.setBlockBounds(0F, 0F, 0F, 1F, 0.4F, 1F);
// this.setUnlocalizedName("Guo");
// this.setHarvestLevel("pickaxe", 2);
// this.setStepSound(Block.soundTypeStone);
// this.setCreativeTab(FoodCraft.FcTabMachine);
// this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
// GameRegistry.registerBlock(this,ItemBlockPot.class,"Guo");
// }
//
// @Override
// public TileEntity createNewTileEntity(World var1, int var2) {
// return new TileEntityPot();
// }
//
// public int getRenderType() {
// return 3;
// }
//
// public boolean isOpaqueCube() {
// return false;
// }
//
// public boolean isFullCube() {
// return false;
// }
//
// public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) {
// return Item.getItemFromBlock(FoodcraftGuiBlocks.Guo);
// }
//
// @SideOnly(Side.CLIENT)
// public Item getItem(World w, int x, int y, int z) {
// return Item.getItemFromBlock(FoodcraftGuiBlocks.Guo);
// }
//
// @Override
// public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ) {
// ItemStack stack = playerIn.inventory.mainInventory[playerIn.inventory.currentItem];
// playerIn.openGui(FoodCraft.instance, GuiIDs.GUI_Guo, worldIn,pos.getX(), pos.getY(), pos.getZ());
// return true;
// }
//
// public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
// TileEntity tileentity = worldIn.getTileEntity(pos);
// if (tileentity instanceof TileEntityPot) {
// InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityPot)tileentity);
// worldIn.updateComparatorOutputLevel(pos, this);
// }
// super.breakBlock(worldIn, pos, state);
// }
//
// public static boolean update(World world,int x,int y,int z) {
// return world.getBlockState(new BlockPos(x, y - 1, z)).getBlock() == Blocks.fire;
// }
//
// public static int getFrequencyOfUse(ItemStack item) {
// if (item.getTagCompound() == null) item.setTagCompound(new NBTTagCompound());
// return item.getTagCompound().getInteger("frequencyOfUse");
// }
//
// @Override
// public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
// if (stack.getTagCompound() != null) {
// int xh = getFrequencyOfUse(stack);
// TileEntityPot tep = (TileEntityPot)worldIn.getTileEntity(pos);
// tep.frequencyOfUse = xh;
// }
// }
// }
| import java.util.List;
import com.foodcraft.gui.blocks.BlockPot;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; | package com.foodcraft.gui.items;
public class ItemBlockPot extends ItemBlock {
public ItemBlockPot(Block block) {
super(block);
}
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack item, EntityPlayer player, List list, boolean par4) { | // Path: src/main/java/com/foodcraft/gui/blocks/BlockPot.java
// public class BlockPot extends BlockGuiFc {
// private final Random Random = new Random();
// public BlockPot() {
// this.setHardness(3.0f);
// this.setBlockBounds(0F, 0F, 0F, 1F, 0.4F, 1F);
// this.setUnlocalizedName("Guo");
// this.setHarvestLevel("pickaxe", 2);
// this.setStepSound(Block.soundTypeStone);
// this.setCreativeTab(FoodCraft.FcTabMachine);
// this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
// GameRegistry.registerBlock(this,ItemBlockPot.class,"Guo");
// }
//
// @Override
// public TileEntity createNewTileEntity(World var1, int var2) {
// return new TileEntityPot();
// }
//
// public int getRenderType() {
// return 3;
// }
//
// public boolean isOpaqueCube() {
// return false;
// }
//
// public boolean isFullCube() {
// return false;
// }
//
// public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) {
// return Item.getItemFromBlock(FoodcraftGuiBlocks.Guo);
// }
//
// @SideOnly(Side.CLIENT)
// public Item getItem(World w, int x, int y, int z) {
// return Item.getItemFromBlock(FoodcraftGuiBlocks.Guo);
// }
//
// @Override
// public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ) {
// ItemStack stack = playerIn.inventory.mainInventory[playerIn.inventory.currentItem];
// playerIn.openGui(FoodCraft.instance, GuiIDs.GUI_Guo, worldIn,pos.getX(), pos.getY(), pos.getZ());
// return true;
// }
//
// public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
// TileEntity tileentity = worldIn.getTileEntity(pos);
// if (tileentity instanceof TileEntityPot) {
// InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityPot)tileentity);
// worldIn.updateComparatorOutputLevel(pos, this);
// }
// super.breakBlock(worldIn, pos, state);
// }
//
// public static boolean update(World world,int x,int y,int z) {
// return world.getBlockState(new BlockPos(x, y - 1, z)).getBlock() == Blocks.fire;
// }
//
// public static int getFrequencyOfUse(ItemStack item) {
// if (item.getTagCompound() == null) item.setTagCompound(new NBTTagCompound());
// return item.getTagCompound().getInteger("frequencyOfUse");
// }
//
// @Override
// public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
// if (stack.getTagCompound() != null) {
// int xh = getFrequencyOfUse(stack);
// TileEntityPot tep = (TileEntityPot)worldIn.getTileEntity(pos);
// tep.frequencyOfUse = xh;
// }
// }
// }
// Path: src/main/java/com/foodcraft/gui/items/ItemBlockPot.java
import java.util.List;
import com.foodcraft.gui.blocks.BlockPot;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
package com.foodcraft.gui.items;
public class ItemBlockPot extends ItemBlock {
public ItemBlockPot(Block block) {
super(block);
}
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack item, EntityPlayer player, List list, boolean par4) { | list.add(StatCollector.translateToLocal("gui.UseF.name") + BlockPot.getFrequencyOfUse(item)); |
InfinityStudio/FoodCraft | src/main/java/com/foodcraft/item/ItemKitchenKnifeEmerald.java | // Path: src/main/java/com/foodcraft/FoodCraft.java
// @Mod(modid="foodcraft", name="FoodCraft", version="1.2.0")
//
// public class FoodCraft implements NetworkMod {
// public static boolean JEIIsLoad = false;
// public static final CreativeTabs FcTabMachine = new CreativeTabs("Jiqi") {//机器&工具
// public Item getTabIconItem() {
// return Item.getItemFromBlock(FoodcraftGuiBlocks.Nmj);
// }
// };
// public static final CreativeTabs FcTabPlant = new CreativeTabs("Zhiwu") {//植物
// public Item getTabIconItem() {
// return FoodcraftItems.ItemLajiao;
// }
// };
// public static final CreativeTabs FcTabDrink = new CreativeTabs("Yingliao") {//饮料
// public Item getTabIconItem() {
// return FoodcraftItems.ItemPutaozhi;
// }
// };
// public static final CreativeTabs FcTabStaple = new CreativeTabs("Zhushi") {//主食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemChaotudousifan;
// }
// };
// public static final CreativeTabs FcTabIngredient = new CreativeTabs("Shicai") {//食材
// public Item getTabIconItem() {
// return FoodcraftItems.ItemMianfen;
// }
// };
// public static final CreativeTabs FcTabSnack = new CreativeTabs("Xiaodian") {//零食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemJianjiao;
// }
// };
//
// @SidedProxy(clientSide = "com.foodcraft.proxy.ClientProxy", serverSide = "com.foodcraft.proxy.CommonProxy")
// private static CommonProxy proxy;
//
// @Instance("foodcraft")
// public static FoodCraft instance;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// PacketDispatcher.initInstance("foodcraft", this);
// NERLogManager.log("Loading foodcraft, Version: 1.2.3");
// JEIIsLoad = Loader.isModLoaded("JustEnoughItems");
// NERConfigHandler.initConfig(event);
// NERConfigHandler.getConfig();
// proxy.preInit(event);
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// proxy.init(event);
// MinecraftForge.EVENT_BUS.register(new FcSubscribeEvent());
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @Override
// public Proxy getProxy() {
// return proxy;
// }
// }
//
// Path: src/main/java/com/foodcraft/api/IItemKitchenKnife.java
// public interface IItemKitchenKnife {
// /**
// * Get the Kitchen Knife MaxUses.
// * @return The Kitchen Knife MaxUses.
// */
// public int getMaxUses();
// /**
// *
// * When the chopping board chopping.
// * @param world world
// * @param x PosX
// * @param y PosY
// * @param z PosZ
// * @param Result result
// * @param Quantity Result Quantity
// * @return Add quantity
// */
// public int event(World world, BlockPos pos, ItemStack Result, int Quantity);
// }
| import com.foodcraft.FoodCraft;
import com.foodcraft.api.IItemKitchenKnife;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World; | package com.foodcraft.item;
public class ItemKitchenKnifeEmerald extends Item implements IItemKitchenKnife {
public ItemKitchenKnifeEmerald() {
this.setMaxDamage(960);
this.setMaxStackSize(1);
this.setUnlocalizedName("ItemCaidaoLBS"); | // Path: src/main/java/com/foodcraft/FoodCraft.java
// @Mod(modid="foodcraft", name="FoodCraft", version="1.2.0")
//
// public class FoodCraft implements NetworkMod {
// public static boolean JEIIsLoad = false;
// public static final CreativeTabs FcTabMachine = new CreativeTabs("Jiqi") {//机器&工具
// public Item getTabIconItem() {
// return Item.getItemFromBlock(FoodcraftGuiBlocks.Nmj);
// }
// };
// public static final CreativeTabs FcTabPlant = new CreativeTabs("Zhiwu") {//植物
// public Item getTabIconItem() {
// return FoodcraftItems.ItemLajiao;
// }
// };
// public static final CreativeTabs FcTabDrink = new CreativeTabs("Yingliao") {//饮料
// public Item getTabIconItem() {
// return FoodcraftItems.ItemPutaozhi;
// }
// };
// public static final CreativeTabs FcTabStaple = new CreativeTabs("Zhushi") {//主食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemChaotudousifan;
// }
// };
// public static final CreativeTabs FcTabIngredient = new CreativeTabs("Shicai") {//食材
// public Item getTabIconItem() {
// return FoodcraftItems.ItemMianfen;
// }
// };
// public static final CreativeTabs FcTabSnack = new CreativeTabs("Xiaodian") {//零食
// public Item getTabIconItem() {
// return FoodcraftItems.ItemJianjiao;
// }
// };
//
// @SidedProxy(clientSide = "com.foodcraft.proxy.ClientProxy", serverSide = "com.foodcraft.proxy.CommonProxy")
// private static CommonProxy proxy;
//
// @Instance("foodcraft")
// public static FoodCraft instance;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// PacketDispatcher.initInstance("foodcraft", this);
// NERLogManager.log("Loading foodcraft, Version: 1.2.3");
// JEIIsLoad = Loader.isModLoaded("JustEnoughItems");
// NERConfigHandler.initConfig(event);
// NERConfigHandler.getConfig();
// proxy.preInit(event);
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// proxy.init(event);
// MinecraftForge.EVENT_BUS.register(new FcSubscribeEvent());
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @Override
// public Proxy getProxy() {
// return proxy;
// }
// }
//
// Path: src/main/java/com/foodcraft/api/IItemKitchenKnife.java
// public interface IItemKitchenKnife {
// /**
// * Get the Kitchen Knife MaxUses.
// * @return The Kitchen Knife MaxUses.
// */
// public int getMaxUses();
// /**
// *
// * When the chopping board chopping.
// * @param world world
// * @param x PosX
// * @param y PosY
// * @param z PosZ
// * @param Result result
// * @param Quantity Result Quantity
// * @return Add quantity
// */
// public int event(World world, BlockPos pos, ItemStack Result, int Quantity);
// }
// Path: src/main/java/com/foodcraft/item/ItemKitchenKnifeEmerald.java
import com.foodcraft.FoodCraft;
import com.foodcraft.api.IItemKitchenKnife;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
package com.foodcraft.item;
public class ItemKitchenKnifeEmerald extends Item implements IItemKitchenKnife {
public ItemKitchenKnifeEmerald() {
this.setMaxDamage(960);
this.setMaxStackSize(1);
this.setUnlocalizedName("ItemCaidaoLBS"); | this.setCreativeTab(FoodCraft.FcTabMachine); |
InfinityStudio/FoodCraft | src/main/java/com/foodcraft/support/jei/choppingboard/ChoppingBoardRecipeCategory.java | // Path: src/main/java/com/foodcraft/support/jei/FcRecipeUids.java
// public interface FcRecipeUids {
// String MILLING = "foodcraft.milling";
// String CHOPPING = "foodcraft.chopping";
// String PRESSURE_COOKER = "foodcraft.pressure_cooker";
// String PAN = "foodcraft.pan";
// String BREW_BARREL = "foodcraft.brew_barrel";
// String FRYING = "foodcraft.frying";
// String BEVERAGE_MAKING = "foodcraft.beverage_making";
// String POT = "foodcraft.pot";
// String STOVE = "foodcraft.stove";
// }
| import com.foodcraft.support.jei.FcRecipeUids;
import mezz.jei.api.IGuiHelper;
import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.gui.IGuiItemStackGroup;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.recipe.BlankRecipeCategory;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import javax.annotation.Nonnull; | package com.foodcraft.support.jei.choppingboard;
public class ChoppingBoardRecipeCategory extends BlankRecipeCategory {
@Nonnull
private final IDrawable background;
@Nonnull
private final String localizedName;
public ChoppingBoardRecipeCategory(IGuiHelper guiHelper) {
ResourceLocation location = new ResourceLocation("foodcraft:textures/gui/nei/caiban.png");
background = guiHelper.createDrawable(location, 69, 20, 140 - 69 + 1, 69 - 20 + 1);
localizedName = StatCollector.translateToLocal("tile.Caiban.name");
}
@Nonnull
@Override
public String getUid() { | // Path: src/main/java/com/foodcraft/support/jei/FcRecipeUids.java
// public interface FcRecipeUids {
// String MILLING = "foodcraft.milling";
// String CHOPPING = "foodcraft.chopping";
// String PRESSURE_COOKER = "foodcraft.pressure_cooker";
// String PAN = "foodcraft.pan";
// String BREW_BARREL = "foodcraft.brew_barrel";
// String FRYING = "foodcraft.frying";
// String BEVERAGE_MAKING = "foodcraft.beverage_making";
// String POT = "foodcraft.pot";
// String STOVE = "foodcraft.stove";
// }
// Path: src/main/java/com/foodcraft/support/jei/choppingboard/ChoppingBoardRecipeCategory.java
import com.foodcraft.support.jei.FcRecipeUids;
import mezz.jei.api.IGuiHelper;
import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.gui.IGuiItemStackGroup;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.recipe.BlankRecipeCategory;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import javax.annotation.Nonnull;
package com.foodcraft.support.jei.choppingboard;
public class ChoppingBoardRecipeCategory extends BlankRecipeCategory {
@Nonnull
private final IDrawable background;
@Nonnull
private final String localizedName;
public ChoppingBoardRecipeCategory(IGuiHelper guiHelper) {
ResourceLocation location = new ResourceLocation("foodcraft:textures/gui/nei/caiban.png");
background = guiHelper.createDrawable(location, 69, 20, 140 - 69 + 1, 69 - 20 + 1);
localizedName = StatCollector.translateToLocal("tile.Caiban.name");
}
@Nonnull
@Override
public String getUid() { | return FcRecipeUids.CHOPPING; |
cameronbraid/wordpress-java | src/net/bican/wordpress/Main.java | // Path: src/net/bican/wordpress/configuration/WpCliConfiguration.java
// public class WpCliConfiguration {
//
// private CompositeConfiguration config = null;
//
// /**
// * @param args Command line arguments
// * @param options Command line options
// * @param cl Calling class
// * @throws ParseException When the configuration cannot be parsed
// */
// public WpCliConfiguration(String[] args, Options options, Class<?> cl)
// throws ParseException {
// Collection<Configuration> confs = new ArrayList<Configuration>();
// confs.add(new CliConfiguration(args, options));
// confs.add(new PreferencesConfiguration(cl));
// this.config = new CompositeConfiguration(confs);
// }
//
// /**
// * @param key Option key to check
// * @return <code>true</code> if the configuration contains the key
// */
// public boolean hasOption(String key) {
// return this.config.containsKey(key);
// }
//
// /**
// * @param key Option key to retrieve
// * @return Value of the option key
// */
// public String getOptionValue(String key) {
// return this.config.getString(key);
// }
//
// }
| import redstone.xmlrpc.XmlRpcFault;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.List;
import javax.activation.MimetypesFileTypeMap;
import net.bican.wordpress.configuration.WpCliConfiguration;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException; | options.addOption("oe", "editpost", true,
"Edit post (needs --postid and --publish");
options.addOption("od", "deletepost", true,
"Delete post (needs --publish)");
options.addOption("sm", "supportedmethods", false,
"List supported methods");
options.addOption("st", "supportedfilters", false,
"List supported text filters");
options.addOption("mn", "newmedia", true,
"New media file (uses --overwrite)");
options.addOption("ov", "overwrite", false,
"Allow overwrite in uploading new media");
options.addOption("so", "supportedstatus", false,
"Print supported page and post status values");
options.addOption("cs", "commentstatus", false,
"Print comment status names for the blog");
options.addOption("cc", "commentcount", true,
"Get comment count for a post (-1 for all posts)");
options.addOption("ca", "newcomment", true, "New comment from file");
options.addOption("cd", "deletecomment", true, "Delete comment");
options.addOption("ce", "editcomment", true, "Edit comment from file");
options.addOption("cg", "getcomment", true, "Get comment");
options.addOption("ct", "getcomments", true, "Get comments for the post");
options.addOption("cs", "commentstatus", true,
"Comment status (for --getcomments)");
options.addOption("co", "commentoffset", true,
"Comment offset # (for --getcomments)");
options.addOption("cm", "commentnumber", true,
"Comment # (for --getcomments)");
try { | // Path: src/net/bican/wordpress/configuration/WpCliConfiguration.java
// public class WpCliConfiguration {
//
// private CompositeConfiguration config = null;
//
// /**
// * @param args Command line arguments
// * @param options Command line options
// * @param cl Calling class
// * @throws ParseException When the configuration cannot be parsed
// */
// public WpCliConfiguration(String[] args, Options options, Class<?> cl)
// throws ParseException {
// Collection<Configuration> confs = new ArrayList<Configuration>();
// confs.add(new CliConfiguration(args, options));
// confs.add(new PreferencesConfiguration(cl));
// this.config = new CompositeConfiguration(confs);
// }
//
// /**
// * @param key Option key to check
// * @return <code>true</code> if the configuration contains the key
// */
// public boolean hasOption(String key) {
// return this.config.containsKey(key);
// }
//
// /**
// * @param key Option key to retrieve
// * @return Value of the option key
// */
// public String getOptionValue(String key) {
// return this.config.getString(key);
// }
//
// }
// Path: src/net/bican/wordpress/Main.java
import redstone.xmlrpc.XmlRpcFault;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.List;
import javax.activation.MimetypesFileTypeMap;
import net.bican.wordpress.configuration.WpCliConfiguration;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
options.addOption("oe", "editpost", true,
"Edit post (needs --postid and --publish");
options.addOption("od", "deletepost", true,
"Delete post (needs --publish)");
options.addOption("sm", "supportedmethods", false,
"List supported methods");
options.addOption("st", "supportedfilters", false,
"List supported text filters");
options.addOption("mn", "newmedia", true,
"New media file (uses --overwrite)");
options.addOption("ov", "overwrite", false,
"Allow overwrite in uploading new media");
options.addOption("so", "supportedstatus", false,
"Print supported page and post status values");
options.addOption("cs", "commentstatus", false,
"Print comment status names for the blog");
options.addOption("cc", "commentcount", true,
"Get comment count for a post (-1 for all posts)");
options.addOption("ca", "newcomment", true, "New comment from file");
options.addOption("cd", "deletecomment", true, "Delete comment");
options.addOption("ce", "editcomment", true, "Edit comment from file");
options.addOption("cg", "getcomment", true, "Get comment");
options.addOption("ct", "getcomments", true, "Get comments for the post");
options.addOption("cs", "commentstatus", true,
"Comment status (for --getcomments)");
options.addOption("co", "commentoffset", true,
"Comment offset # (for --getcomments)");
options.addOption("cm", "commentnumber", true,
"Comment # (for --getcomments)");
try { | WpCliConfiguration config = new WpCliConfiguration(args, options, |
reportportal/service-authorization | src/main/java/com/epam/reportportal/auth/integration/github/GitHubTokenServices.java | // Path: src/main/java/com/epam/reportportal/auth/integration/github/ExternalOauth2TokenConverter.java
// static final String UPSTREAM_TOKEN = "upstream_token";
| import java.util.function.Supplier;
import static com.epam.reportportal.auth.integration.github.ExternalOauth2TokenConverter.UPSTREAM_TOKEN;
import static java.util.Collections.emptyList;
import static java.util.Optional.ofNullable;
import com.epam.ta.reportportal.commons.ReportPortalUser;
import com.epam.ta.reportportal.ws.model.settings.OAuthRegistrationResource;
import com.google.common.base.Splitter;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.common.exceptions.InvalidTokenException;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.security.oauth2.provider.OAuth2Request;
import org.springframework.security.oauth2.provider.token.ResourceServerTokenServices;
import java.io.Serializable;
import java.util.Collections;
import java.util.List;
import java.util.Map; | /*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.integration.github;
/**
* Token services for GitHub account info with internal ReportPortal's database
*
* @author <a href="mailto:andrei_varabyeu@epam.com">Andrei Varabyeu</a>
*/
public class GitHubTokenServices implements ResourceServerTokenServices {
private final GitHubUserReplicator replicator;
private final Supplier<OAuthRegistrationResource> oAuthRegistrationSupplier;
public GitHubTokenServices(GitHubUserReplicator replicatingPrincipalExtractor,
Supplier<OAuthRegistrationResource> oAuthRegistrationSupplier) {
this.replicator = replicatingPrincipalExtractor;
this.oAuthRegistrationSupplier = oAuthRegistrationSupplier;
}
@Override
public OAuth2Authentication loadAuthentication(String accessToken) throws AuthenticationException, InvalidTokenException {
GitHubClient gitHubClient = GitHubClient.withAccessToken(accessToken);
UserResource gitHubUser = gitHubClient.getUser();
OAuthRegistrationResource oAuthRegistrationResource = oAuthRegistrationSupplier.get();
List<String> allowedOrganizations = ofNullable(oAuthRegistrationResource.getRestrictions()).flatMap(restrictions -> ofNullable(
restrictions.get("organizations"))).map(it -> Splitter.on(",").omitEmptyStrings().splitToList(it)).orElse(emptyList());
if (!allowedOrganizations.isEmpty()) {
boolean assignedToOrganization = gitHubClient.getUserOrganizations(gitHubUser.getLogin())
.stream()
.map(OrganizationResource::getLogin)
.anyMatch(allowedOrganizations::contains);
if (!assignedToOrganization) {
throw new InsufficientOrganizationException(
"User '" + gitHubUser.getLogin() + "' does not belong to allowed GitHUB organization");
}
}
ReportPortalUser user = replicator.replicateUser(gitHubUser, gitHubClient);
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(user, "N/A", user.getAuthorities());
| // Path: src/main/java/com/epam/reportportal/auth/integration/github/ExternalOauth2TokenConverter.java
// static final String UPSTREAM_TOKEN = "upstream_token";
// Path: src/main/java/com/epam/reportportal/auth/integration/github/GitHubTokenServices.java
import java.util.function.Supplier;
import static com.epam.reportportal.auth.integration.github.ExternalOauth2TokenConverter.UPSTREAM_TOKEN;
import static java.util.Collections.emptyList;
import static java.util.Optional.ofNullable;
import com.epam.ta.reportportal.commons.ReportPortalUser;
import com.epam.ta.reportportal.ws.model.settings.OAuthRegistrationResource;
import com.google.common.base.Splitter;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.common.exceptions.InvalidTokenException;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.security.oauth2.provider.OAuth2Request;
import org.springframework.security.oauth2.provider.token.ResourceServerTokenServices;
import java.io.Serializable;
import java.util.Collections;
import java.util.List;
import java.util.Map;
/*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.integration.github;
/**
* Token services for GitHub account info with internal ReportPortal's database
*
* @author <a href="mailto:andrei_varabyeu@epam.com">Andrei Varabyeu</a>
*/
public class GitHubTokenServices implements ResourceServerTokenServices {
private final GitHubUserReplicator replicator;
private final Supplier<OAuthRegistrationResource> oAuthRegistrationSupplier;
public GitHubTokenServices(GitHubUserReplicator replicatingPrincipalExtractor,
Supplier<OAuthRegistrationResource> oAuthRegistrationSupplier) {
this.replicator = replicatingPrincipalExtractor;
this.oAuthRegistrationSupplier = oAuthRegistrationSupplier;
}
@Override
public OAuth2Authentication loadAuthentication(String accessToken) throws AuthenticationException, InvalidTokenException {
GitHubClient gitHubClient = GitHubClient.withAccessToken(accessToken);
UserResource gitHubUser = gitHubClient.getUser();
OAuthRegistrationResource oAuthRegistrationResource = oAuthRegistrationSupplier.get();
List<String> allowedOrganizations = ofNullable(oAuthRegistrationResource.getRestrictions()).flatMap(restrictions -> ofNullable(
restrictions.get("organizations"))).map(it -> Splitter.on(",").omitEmptyStrings().splitToList(it)).orElse(emptyList());
if (!allowedOrganizations.isEmpty()) {
boolean assignedToOrganization = gitHubClient.getUserOrganizations(gitHubUser.getLogin())
.stream()
.map(OrganizationResource::getLogin)
.anyMatch(allowedOrganizations::contains);
if (!assignedToOrganization) {
throw new InsufficientOrganizationException(
"User '" + gitHubUser.getLogin() + "' does not belong to allowed GitHUB organization");
}
}
ReportPortalUser user = replicator.replicateUser(gitHubUser, gitHubClient);
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(user, "N/A", user.getAuthorities());
| Map<String, Serializable> extensionProperties = Collections.singletonMap(UPSTREAM_TOKEN, accessToken); |
reportportal/service-authorization | src/main/java/com/epam/reportportal/auth/integration/saml/ReportPortalSamlAuthentication.java | // Path: src/main/java/com/epam/reportportal/auth/util/AuthUtils.java
// public static final Function<String, String> CROP_DOMAIN = it -> normalizeId(StringUtils.substringBefore(it, "@"));
| import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.saml.SamlAuthentication;
import org.springframework.security.saml.saml2.authentication.Assertion;
import org.springframework.security.saml.saml2.authentication.SubjectPrincipal;
import org.springframework.security.saml.spi.DefaultSamlAuthentication;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;
import static com.epam.reportportal.auth.util.AuthUtils.CROP_DOMAIN; | issuer = assertion.getIssuer().getValue();
}
public ReportPortalSamlAuthentication(DefaultSamlAuthentication defaultSamlAuthentication) {
this(
defaultSamlAuthentication.isAuthenticated(),
defaultSamlAuthentication.getAssertion(),
defaultSamlAuthentication.getAssertingEntityId(),
defaultSamlAuthentication.getHoldingEntityId(),
defaultSamlAuthentication.getRelayState()
);
}
private void fillAttributes(Assertion assertion) {
List<Attribute> mappedAttributes = assertion.getAttributes()
.stream()
.map(attr -> new Attribute().setName(attr.getName())
.setFriendlyName(attr.getFriendlyName())
.setNameFormat(attr.getNameFormat().toString())
.setRequired(attr.isRequired())
.setValues(attr.getValues()))
.collect(Collectors.toList());
attributes.addAll(mappedAttributes);
}
private void fillSubject(Assertion assertion) {
subject = new Subject().setSamlPrincipal(new SamlPrincipal().setFormat(assertion.getSubject()
.getPrincipal()
.getFormat()
.getFormat() | // Path: src/main/java/com/epam/reportportal/auth/util/AuthUtils.java
// public static final Function<String, String> CROP_DOMAIN = it -> normalizeId(StringUtils.substringBefore(it, "@"));
// Path: src/main/java/com/epam/reportportal/auth/integration/saml/ReportPortalSamlAuthentication.java
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.saml.SamlAuthentication;
import org.springframework.security.saml.saml2.authentication.Assertion;
import org.springframework.security.saml.saml2.authentication.SubjectPrincipal;
import org.springframework.security.saml.spi.DefaultSamlAuthentication;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;
import static com.epam.reportportal.auth.util.AuthUtils.CROP_DOMAIN;
issuer = assertion.getIssuer().getValue();
}
public ReportPortalSamlAuthentication(DefaultSamlAuthentication defaultSamlAuthentication) {
this(
defaultSamlAuthentication.isAuthenticated(),
defaultSamlAuthentication.getAssertion(),
defaultSamlAuthentication.getAssertingEntityId(),
defaultSamlAuthentication.getHoldingEntityId(),
defaultSamlAuthentication.getRelayState()
);
}
private void fillAttributes(Assertion assertion) {
List<Attribute> mappedAttributes = assertion.getAttributes()
.stream()
.map(attr -> new Attribute().setName(attr.getName())
.setFriendlyName(attr.getFriendlyName())
.setNameFormat(attr.getNameFormat().toString())
.setRequired(attr.isRequired())
.setValues(attr.getValues()))
.collect(Collectors.toList());
attributes.addAll(mappedAttributes);
}
private void fillSubject(Assertion assertion) {
subject = new Subject().setSamlPrincipal(new SamlPrincipal().setFormat(assertion.getSubject()
.getPrincipal()
.getFormat()
.getFormat() | .toString()).setValue(CROP_DOMAIN.apply(assertion.getSubject().getPrincipal().getValue()))); |
reportportal/service-authorization | src/main/java/com/epam/reportportal/auth/integration/validator/request/param/provider/LdapRequiredParamNamesProvider.java | // Path: src/main/java/com/epam/reportportal/auth/integration/parameter/LdapParameter.java
// public enum LdapParameter {
// NAME("name", false, false),
// URL("url", true, false),
// BASE_DN("baseDn", true, false),
// EMAIL_ATTRIBUTE("email", true, true),
// FULL_NAME_ATTRIBUTE("fullName", false, true),
// PHOTO_ATTRIBUTE("photo", false, true),
// SEARCH_FILTER_REMOVE_NOT_PRESENT("searchFilter", false, false) {
// @Override
// public void setParameter(UpdateAuthRQ request, Integration integration) {
// getParameter(request).ifPresentOrElse(it -> setParameter(integration, it), () -> removeParameter(integration));
// }
// },
// USER_DN_PATTERN("userDnPattern", false, false),
// USER_SEARCH_FILTER("userSearchFilter", false, false),
// GROUP_SEARCH_BASE("groupSearchBase", false, false),
// GROUP_SEARCH_FILTER("groupSearchFilter", false, false),
// PASSWORD_ENCODER_TYPE("passwordEncoderType", false, false),
// PASSWORD_ATTRIBUTE("passwordAttribute", false, false),
// MANAGER_DN("managerDn", false, false),
// MANAGER_PASSWORD("managerPassword", false, false),
// DOMAIN("domain", false, false);
//
// private String parameterName;
//
// private boolean required;
//
// private boolean syncAttribute;
//
// LdapParameter(String parameterName, boolean required, boolean syncAttribute) {
// this.parameterName = parameterName;
// this.required = required;
// this.syncAttribute = syncAttribute;
// }
//
// public String getParameterName() {
// return parameterName;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public boolean isSyncAttribute() {
// return syncAttribute;
// }
//
// public Optional<String> getParameter(Integration integration) {
// return ofNullable(integration.getParams()).map(it -> it.getParams().get(parameterName)).map(String::valueOf);
// }
//
// public void setParameter(Integration integration, String value) {
// if (Objects.isNull(integration.getParams())) {
// integration.setParams(new IntegrationParams(new HashMap<>()));
// }
// if (Objects.isNull(integration.getParams().getParams())) {
// integration.getParams().setParams(new HashMap<>());
// }
// integration.getParams().getParams().put(parameterName, value);
// }
//
// public void removeParameter(Integration integration) {
// ofNullable(integration.getParams()).map(IntegrationParams::getParams).ifPresent(params -> params.remove(parameterName));
// }
//
// public boolean exists(Integration integration) {
// return getParameter(integration).isPresent();
// }
//
// public String getRequiredParameter(Integration integration) {
// Optional<String> property = getParameter(integration);
// if (required) {
// if (property.isPresent()) {
// return property.get();
// } else {
// throw new ReportPortalException(ErrorType.INCORRECT_REQUEST, formattedSupplier("'{}' should be present.", parameterName));
// }
// } else {
// throw new ReportPortalException(ErrorType.INCORRECT_REQUEST, formattedSupplier("'{}' is not required."));
// }
// }
//
// public Optional<String> getParameter(Map<String, Object> parametersMap) {
// return ofNullable(parametersMap.get(parameterName)).map(String::valueOf).filter(StringUtils::isNotBlank);
// }
//
// public Optional<String> getParameter(UpdateAuthRQ request) {
// return ofNullable(request.getIntegrationParams()).flatMap(this::getParameter);
// }
//
// public void setParameter(UpdateAuthRQ request, Integration integration) {
// getParameter(request).ifPresent(it -> setParameter(integration, it));
// }
//
// }
| import com.epam.reportportal.auth.integration.parameter.LdapParameter;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors; | package com.epam.reportportal.auth.integration.validator.request.param.provider;
@Service
public class LdapRequiredParamNamesProvider implements ParamNamesProvider {
@Override
public List<String> provide() { | // Path: src/main/java/com/epam/reportportal/auth/integration/parameter/LdapParameter.java
// public enum LdapParameter {
// NAME("name", false, false),
// URL("url", true, false),
// BASE_DN("baseDn", true, false),
// EMAIL_ATTRIBUTE("email", true, true),
// FULL_NAME_ATTRIBUTE("fullName", false, true),
// PHOTO_ATTRIBUTE("photo", false, true),
// SEARCH_FILTER_REMOVE_NOT_PRESENT("searchFilter", false, false) {
// @Override
// public void setParameter(UpdateAuthRQ request, Integration integration) {
// getParameter(request).ifPresentOrElse(it -> setParameter(integration, it), () -> removeParameter(integration));
// }
// },
// USER_DN_PATTERN("userDnPattern", false, false),
// USER_SEARCH_FILTER("userSearchFilter", false, false),
// GROUP_SEARCH_BASE("groupSearchBase", false, false),
// GROUP_SEARCH_FILTER("groupSearchFilter", false, false),
// PASSWORD_ENCODER_TYPE("passwordEncoderType", false, false),
// PASSWORD_ATTRIBUTE("passwordAttribute", false, false),
// MANAGER_DN("managerDn", false, false),
// MANAGER_PASSWORD("managerPassword", false, false),
// DOMAIN("domain", false, false);
//
// private String parameterName;
//
// private boolean required;
//
// private boolean syncAttribute;
//
// LdapParameter(String parameterName, boolean required, boolean syncAttribute) {
// this.parameterName = parameterName;
// this.required = required;
// this.syncAttribute = syncAttribute;
// }
//
// public String getParameterName() {
// return parameterName;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public boolean isSyncAttribute() {
// return syncAttribute;
// }
//
// public Optional<String> getParameter(Integration integration) {
// return ofNullable(integration.getParams()).map(it -> it.getParams().get(parameterName)).map(String::valueOf);
// }
//
// public void setParameter(Integration integration, String value) {
// if (Objects.isNull(integration.getParams())) {
// integration.setParams(new IntegrationParams(new HashMap<>()));
// }
// if (Objects.isNull(integration.getParams().getParams())) {
// integration.getParams().setParams(new HashMap<>());
// }
// integration.getParams().getParams().put(parameterName, value);
// }
//
// public void removeParameter(Integration integration) {
// ofNullable(integration.getParams()).map(IntegrationParams::getParams).ifPresent(params -> params.remove(parameterName));
// }
//
// public boolean exists(Integration integration) {
// return getParameter(integration).isPresent();
// }
//
// public String getRequiredParameter(Integration integration) {
// Optional<String> property = getParameter(integration);
// if (required) {
// if (property.isPresent()) {
// return property.get();
// } else {
// throw new ReportPortalException(ErrorType.INCORRECT_REQUEST, formattedSupplier("'{}' should be present.", parameterName));
// }
// } else {
// throw new ReportPortalException(ErrorType.INCORRECT_REQUEST, formattedSupplier("'{}' is not required."));
// }
// }
//
// public Optional<String> getParameter(Map<String, Object> parametersMap) {
// return ofNullable(parametersMap.get(parameterName)).map(String::valueOf).filter(StringUtils::isNotBlank);
// }
//
// public Optional<String> getParameter(UpdateAuthRQ request) {
// return ofNullable(request.getIntegrationParams()).flatMap(this::getParameter);
// }
//
// public void setParameter(UpdateAuthRQ request, Integration integration) {
// getParameter(request).ifPresent(it -> setParameter(integration, it));
// }
//
// }
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/param/provider/LdapRequiredParamNamesProvider.java
import com.epam.reportportal.auth.integration.parameter.LdapParameter;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
package com.epam.reportportal.auth.integration.validator.request.param.provider;
@Service
public class LdapRequiredParamNamesProvider implements ParamNamesProvider {
@Override
public List<String> provide() { | return Arrays.stream(LdapParameter.values()) |
reportportal/service-authorization | src/main/java/com/epam/reportportal/auth/integration/handler/impl/GetSamlIntegrationsStrategy.java | // Path: src/main/java/com/epam/reportportal/auth/integration/AuthIntegrationType.java
// public enum AuthIntegrationType {
//
// ACTIVE_DIRECTORY("ad") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, ActiveDirectoryResource> getToResourceMapper() {
// return ActiveDirectoryConverter.TO_RESOURCE;
// }
// },
// LDAP("ldap") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, LdapResource> getToResourceMapper() {
// return LdapConverter.TO_RESOURCE;
// }
// },
// SAML("saml") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, SamlResource> getToResourceMapper() {
// return SamlConverter.TO_RESOURCE;
// }
// };
//
// private String name;
//
// AuthIntegrationType(String name) {
// this.name = name;
// }
//
// public abstract Optional<Integration> get(Integration entity);
//
// public abstract Function<Integration, ? extends AbstractAuthResource> getToResourceMapper();
//
// public String getName() {
// return name;
// }
//
// public static Optional<AuthIntegrationType> fromId(String id) {
// return Arrays.stream(values()).filter(it -> it.name.equalsIgnoreCase(id)).findAny();
// }
//
// @Override
// public String toString() {
// return this.name;
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/GetAuthIntegrationStrategy.java
// public interface GetAuthIntegrationStrategy {
//
// AbstractAuthResource getIntegration();
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/converter/SamlConverter.java
// public final static Function<List<Integration>, SamlProvidersResource> TO_PROVIDERS_RESOURCE = integrations -> {
// if (CollectionUtils.isEmpty(integrations)) {
// SamlProvidersResource emptyResource = new SamlProvidersResource();
// emptyResource.setProviders(Collections.emptyList());
// return emptyResource;
// }
// SamlProvidersResource resource = new SamlProvidersResource();
// resource.setProviders(integrations.stream().map(TO_RESOURCE).collect(Collectors.toList()));
// return resource;
// };
| import com.epam.reportportal.auth.integration.AuthIntegrationType;
import com.epam.reportportal.auth.integration.handler.GetAuthIntegrationStrategy;
import com.epam.ta.reportportal.dao.IntegrationRepository;
import com.epam.ta.reportportal.dao.IntegrationTypeRepository;
import com.epam.ta.reportportal.entity.integration.Integration;
import com.epam.ta.reportportal.entity.integration.IntegrationType;
import com.epam.ta.reportportal.exception.ReportPortalException;
import com.epam.ta.reportportal.ws.model.ErrorType;
import com.epam.ta.reportportal.ws.model.integration.auth.AbstractAuthResource;
import com.epam.ta.reportportal.ws.model.integration.auth.SamlProvidersResource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import static com.epam.reportportal.auth.integration.converter.SamlConverter.TO_PROVIDERS_RESOURCE; | package com.epam.reportportal.auth.integration.handler.impl;
/**
* @author <a href="mailto:ihar_kahadouski@epam.com">Ihar Kahadouski</a>
*/
@Service
public class GetSamlIntegrationsStrategy implements GetAuthIntegrationStrategy {
private IntegrationTypeRepository integrationTypeRepository;
private IntegrationRepository integrationRepository;
@Autowired
public GetSamlIntegrationsStrategy(IntegrationTypeRepository integrationTypeRepository, IntegrationRepository integrationRepository) {
this.integrationTypeRepository = integrationTypeRepository;
this.integrationRepository = integrationRepository;
}
@Override
public AbstractAuthResource getIntegration() { | // Path: src/main/java/com/epam/reportportal/auth/integration/AuthIntegrationType.java
// public enum AuthIntegrationType {
//
// ACTIVE_DIRECTORY("ad") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, ActiveDirectoryResource> getToResourceMapper() {
// return ActiveDirectoryConverter.TO_RESOURCE;
// }
// },
// LDAP("ldap") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, LdapResource> getToResourceMapper() {
// return LdapConverter.TO_RESOURCE;
// }
// },
// SAML("saml") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, SamlResource> getToResourceMapper() {
// return SamlConverter.TO_RESOURCE;
// }
// };
//
// private String name;
//
// AuthIntegrationType(String name) {
// this.name = name;
// }
//
// public abstract Optional<Integration> get(Integration entity);
//
// public abstract Function<Integration, ? extends AbstractAuthResource> getToResourceMapper();
//
// public String getName() {
// return name;
// }
//
// public static Optional<AuthIntegrationType> fromId(String id) {
// return Arrays.stream(values()).filter(it -> it.name.equalsIgnoreCase(id)).findAny();
// }
//
// @Override
// public String toString() {
// return this.name;
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/GetAuthIntegrationStrategy.java
// public interface GetAuthIntegrationStrategy {
//
// AbstractAuthResource getIntegration();
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/converter/SamlConverter.java
// public final static Function<List<Integration>, SamlProvidersResource> TO_PROVIDERS_RESOURCE = integrations -> {
// if (CollectionUtils.isEmpty(integrations)) {
// SamlProvidersResource emptyResource = new SamlProvidersResource();
// emptyResource.setProviders(Collections.emptyList());
// return emptyResource;
// }
// SamlProvidersResource resource = new SamlProvidersResource();
// resource.setProviders(integrations.stream().map(TO_RESOURCE).collect(Collectors.toList()));
// return resource;
// };
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/impl/GetSamlIntegrationsStrategy.java
import com.epam.reportportal.auth.integration.AuthIntegrationType;
import com.epam.reportportal.auth.integration.handler.GetAuthIntegrationStrategy;
import com.epam.ta.reportportal.dao.IntegrationRepository;
import com.epam.ta.reportportal.dao.IntegrationTypeRepository;
import com.epam.ta.reportportal.entity.integration.Integration;
import com.epam.ta.reportportal.entity.integration.IntegrationType;
import com.epam.ta.reportportal.exception.ReportPortalException;
import com.epam.ta.reportportal.ws.model.ErrorType;
import com.epam.ta.reportportal.ws.model.integration.auth.AbstractAuthResource;
import com.epam.ta.reportportal.ws.model.integration.auth.SamlProvidersResource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import static com.epam.reportportal.auth.integration.converter.SamlConverter.TO_PROVIDERS_RESOURCE;
package com.epam.reportportal.auth.integration.handler.impl;
/**
* @author <a href="mailto:ihar_kahadouski@epam.com">Ihar Kahadouski</a>
*/
@Service
public class GetSamlIntegrationsStrategy implements GetAuthIntegrationStrategy {
private IntegrationTypeRepository integrationTypeRepository;
private IntegrationRepository integrationRepository;
@Autowired
public GetSamlIntegrationsStrategy(IntegrationTypeRepository integrationTypeRepository, IntegrationRepository integrationRepository) {
this.integrationTypeRepository = integrationTypeRepository;
this.integrationRepository = integrationRepository;
}
@Override
public AbstractAuthResource getIntegration() { | IntegrationType samlIntegrationType = integrationTypeRepository.findByName(AuthIntegrationType.SAML.getName()) |
reportportal/service-authorization | src/main/java/com/epam/reportportal/auth/integration/handler/impl/GetSamlIntegrationsStrategy.java | // Path: src/main/java/com/epam/reportportal/auth/integration/AuthIntegrationType.java
// public enum AuthIntegrationType {
//
// ACTIVE_DIRECTORY("ad") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, ActiveDirectoryResource> getToResourceMapper() {
// return ActiveDirectoryConverter.TO_RESOURCE;
// }
// },
// LDAP("ldap") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, LdapResource> getToResourceMapper() {
// return LdapConverter.TO_RESOURCE;
// }
// },
// SAML("saml") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, SamlResource> getToResourceMapper() {
// return SamlConverter.TO_RESOURCE;
// }
// };
//
// private String name;
//
// AuthIntegrationType(String name) {
// this.name = name;
// }
//
// public abstract Optional<Integration> get(Integration entity);
//
// public abstract Function<Integration, ? extends AbstractAuthResource> getToResourceMapper();
//
// public String getName() {
// return name;
// }
//
// public static Optional<AuthIntegrationType> fromId(String id) {
// return Arrays.stream(values()).filter(it -> it.name.equalsIgnoreCase(id)).findAny();
// }
//
// @Override
// public String toString() {
// return this.name;
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/GetAuthIntegrationStrategy.java
// public interface GetAuthIntegrationStrategy {
//
// AbstractAuthResource getIntegration();
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/converter/SamlConverter.java
// public final static Function<List<Integration>, SamlProvidersResource> TO_PROVIDERS_RESOURCE = integrations -> {
// if (CollectionUtils.isEmpty(integrations)) {
// SamlProvidersResource emptyResource = new SamlProvidersResource();
// emptyResource.setProviders(Collections.emptyList());
// return emptyResource;
// }
// SamlProvidersResource resource = new SamlProvidersResource();
// resource.setProviders(integrations.stream().map(TO_RESOURCE).collect(Collectors.toList()));
// return resource;
// };
| import com.epam.reportportal.auth.integration.AuthIntegrationType;
import com.epam.reportportal.auth.integration.handler.GetAuthIntegrationStrategy;
import com.epam.ta.reportportal.dao.IntegrationRepository;
import com.epam.ta.reportportal.dao.IntegrationTypeRepository;
import com.epam.ta.reportportal.entity.integration.Integration;
import com.epam.ta.reportportal.entity.integration.IntegrationType;
import com.epam.ta.reportportal.exception.ReportPortalException;
import com.epam.ta.reportportal.ws.model.ErrorType;
import com.epam.ta.reportportal.ws.model.integration.auth.AbstractAuthResource;
import com.epam.ta.reportportal.ws.model.integration.auth.SamlProvidersResource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import static com.epam.reportportal.auth.integration.converter.SamlConverter.TO_PROVIDERS_RESOURCE; | package com.epam.reportportal.auth.integration.handler.impl;
/**
* @author <a href="mailto:ihar_kahadouski@epam.com">Ihar Kahadouski</a>
*/
@Service
public class GetSamlIntegrationsStrategy implements GetAuthIntegrationStrategy {
private IntegrationTypeRepository integrationTypeRepository;
private IntegrationRepository integrationRepository;
@Autowired
public GetSamlIntegrationsStrategy(IntegrationTypeRepository integrationTypeRepository, IntegrationRepository integrationRepository) {
this.integrationTypeRepository = integrationTypeRepository;
this.integrationRepository = integrationRepository;
}
@Override
public AbstractAuthResource getIntegration() {
IntegrationType samlIntegrationType = integrationTypeRepository.findByName(AuthIntegrationType.SAML.getName())
.orElseThrow(() -> new ReportPortalException(ErrorType.AUTH_INTEGRATION_NOT_FOUND, AuthIntegrationType.SAML.getName()));
List<Integration> providers = integrationRepository.findAllGlobalByType(samlIntegrationType); | // Path: src/main/java/com/epam/reportportal/auth/integration/AuthIntegrationType.java
// public enum AuthIntegrationType {
//
// ACTIVE_DIRECTORY("ad") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, ActiveDirectoryResource> getToResourceMapper() {
// return ActiveDirectoryConverter.TO_RESOURCE;
// }
// },
// LDAP("ldap") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, LdapResource> getToResourceMapper() {
// return LdapConverter.TO_RESOURCE;
// }
// },
// SAML("saml") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, SamlResource> getToResourceMapper() {
// return SamlConverter.TO_RESOURCE;
// }
// };
//
// private String name;
//
// AuthIntegrationType(String name) {
// this.name = name;
// }
//
// public abstract Optional<Integration> get(Integration entity);
//
// public abstract Function<Integration, ? extends AbstractAuthResource> getToResourceMapper();
//
// public String getName() {
// return name;
// }
//
// public static Optional<AuthIntegrationType> fromId(String id) {
// return Arrays.stream(values()).filter(it -> it.name.equalsIgnoreCase(id)).findAny();
// }
//
// @Override
// public String toString() {
// return this.name;
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/GetAuthIntegrationStrategy.java
// public interface GetAuthIntegrationStrategy {
//
// AbstractAuthResource getIntegration();
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/converter/SamlConverter.java
// public final static Function<List<Integration>, SamlProvidersResource> TO_PROVIDERS_RESOURCE = integrations -> {
// if (CollectionUtils.isEmpty(integrations)) {
// SamlProvidersResource emptyResource = new SamlProvidersResource();
// emptyResource.setProviders(Collections.emptyList());
// return emptyResource;
// }
// SamlProvidersResource resource = new SamlProvidersResource();
// resource.setProviders(integrations.stream().map(TO_RESOURCE).collect(Collectors.toList()));
// return resource;
// };
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/impl/GetSamlIntegrationsStrategy.java
import com.epam.reportportal.auth.integration.AuthIntegrationType;
import com.epam.reportportal.auth.integration.handler.GetAuthIntegrationStrategy;
import com.epam.ta.reportportal.dao.IntegrationRepository;
import com.epam.ta.reportportal.dao.IntegrationTypeRepository;
import com.epam.ta.reportportal.entity.integration.Integration;
import com.epam.ta.reportportal.entity.integration.IntegrationType;
import com.epam.ta.reportportal.exception.ReportPortalException;
import com.epam.ta.reportportal.ws.model.ErrorType;
import com.epam.ta.reportportal.ws.model.integration.auth.AbstractAuthResource;
import com.epam.ta.reportportal.ws.model.integration.auth.SamlProvidersResource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import static com.epam.reportportal.auth.integration.converter.SamlConverter.TO_PROVIDERS_RESOURCE;
package com.epam.reportportal.auth.integration.handler.impl;
/**
* @author <a href="mailto:ihar_kahadouski@epam.com">Ihar Kahadouski</a>
*/
@Service
public class GetSamlIntegrationsStrategy implements GetAuthIntegrationStrategy {
private IntegrationTypeRepository integrationTypeRepository;
private IntegrationRepository integrationRepository;
@Autowired
public GetSamlIntegrationsStrategy(IntegrationTypeRepository integrationTypeRepository, IntegrationRepository integrationRepository) {
this.integrationTypeRepository = integrationTypeRepository;
this.integrationRepository = integrationRepository;
}
@Override
public AbstractAuthResource getIntegration() {
IntegrationType samlIntegrationType = integrationTypeRepository.findByName(AuthIntegrationType.SAML.getName())
.orElseThrow(() -> new ReportPortalException(ErrorType.AUTH_INTEGRATION_NOT_FOUND, AuthIntegrationType.SAML.getName()));
List<Integration> providers = integrationRepository.findAllGlobalByType(samlIntegrationType); | SamlProvidersResource resource = TO_PROVIDERS_RESOURCE.apply(providers); |
reportportal/service-authorization | src/main/java/com/epam/reportportal/auth/config/AuthIntegrationValidatorConfig.java | // Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/SamlUpdateAuthRequestValidator.java
// public class SamlUpdateAuthRequestValidator extends UpdateAuthRequestValidator {
//
// private static final Predicate<UpdateAuthRQ> FULL_NAME_IS_EMPTY = request -> FULL_NAME_ATTRIBUTE.getParameter(request).isEmpty();
// private static final Predicate<UpdateAuthRQ> FIRST_AND_LAST_NAME_IS_EMPTY = request ->
// LAST_NAME_ATTRIBUTE.getParameter(request).isEmpty() && FIRST_NAME_ATTRIBUTE.getParameter(request).isEmpty();
//
// public SamlUpdateAuthRequestValidator(ParamNamesProvider paramNamesProvider) {
// super(paramNamesProvider);
// }
//
// @Override
// public void validate(UpdateAuthRQ updateRequest) {
// super.validate(updateRequest);
// BusinessRule.expect(FULL_NAME_IS_EMPTY.test(updateRequest) && FIRST_AND_LAST_NAME_IS_EMPTY.test(updateRequest),
// equalTo(Boolean.FALSE)
// ).verify(ErrorType.BAD_REQUEST_ERROR, "Fields Full name or combination of Last name and First name are empty");
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/UpdateAuthRequestValidator.java
// public class UpdateAuthRequestValidator implements AuthRequestValidator<UpdateAuthRQ> {
//
// private final ParamNamesProvider paramNamesProvider;
//
// public UpdateAuthRequestValidator(ParamNamesProvider paramNamesProvider) {
// this.paramNamesProvider = paramNamesProvider;
// }
//
// @Override
// public void validate(UpdateAuthRQ updateRequest) {
// final List<String> paramNames = paramNamesProvider.provide();
// paramNames.stream()
// .map(it -> retrieveParam(updateRequest, it))
// .forEach(it -> expect(it, Optional::isPresent).verify(ErrorType.BAD_REQUEST_ERROR,
// formattedSupplier("parameter '{}' is required.", it)
// ));
// }
//
// private Optional<String> retrieveParam(UpdateAuthRQ updateRequest, String name) {
// return ofNullable(updateRequest.getIntegrationParams().get(name)).map(String::valueOf).filter(StringUtils::isNotBlank);
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/param/provider/LdapRequiredParamNamesProvider.java
// @Service
// public class LdapRequiredParamNamesProvider implements ParamNamesProvider {
//
// @Override
// public List<String> provide() {
// return Arrays.stream(LdapParameter.values())
// .filter(LdapParameter::isRequired)
// .map(LdapParameter::getParameterName)
// .collect(Collectors.toList());
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/param/provider/ParamNamesProvider.java
// public interface ParamNamesProvider {
//
// List<String> provide();
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/param/provider/SamlRequiredParamNamesProvider.java
// @Service
// public class SamlRequiredParamNamesProvider implements ParamNamesProvider {
//
// @Override
// public List<String> provide() {
// return Arrays.stream(SamlParameter.values())
// .filter(SamlParameter::isRequired)
// .map(SamlParameter::getParameterName)
// .collect(Collectors.toList());
// }
// }
| import com.epam.reportportal.auth.integration.validator.request.SamlUpdateAuthRequestValidator;
import com.epam.reportportal.auth.integration.validator.request.UpdateAuthRequestValidator;
import com.epam.reportportal.auth.integration.validator.request.param.provider.LdapRequiredParamNamesProvider;
import com.epam.reportportal.auth.integration.validator.request.param.provider.ParamNamesProvider;
import com.epam.reportportal.auth.integration.validator.request.param.provider.SamlRequiredParamNamesProvider;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; | package com.epam.reportportal.auth.config;
@Configuration
public class AuthIntegrationValidatorConfig {
@Bean | // Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/SamlUpdateAuthRequestValidator.java
// public class SamlUpdateAuthRequestValidator extends UpdateAuthRequestValidator {
//
// private static final Predicate<UpdateAuthRQ> FULL_NAME_IS_EMPTY = request -> FULL_NAME_ATTRIBUTE.getParameter(request).isEmpty();
// private static final Predicate<UpdateAuthRQ> FIRST_AND_LAST_NAME_IS_EMPTY = request ->
// LAST_NAME_ATTRIBUTE.getParameter(request).isEmpty() && FIRST_NAME_ATTRIBUTE.getParameter(request).isEmpty();
//
// public SamlUpdateAuthRequestValidator(ParamNamesProvider paramNamesProvider) {
// super(paramNamesProvider);
// }
//
// @Override
// public void validate(UpdateAuthRQ updateRequest) {
// super.validate(updateRequest);
// BusinessRule.expect(FULL_NAME_IS_EMPTY.test(updateRequest) && FIRST_AND_LAST_NAME_IS_EMPTY.test(updateRequest),
// equalTo(Boolean.FALSE)
// ).verify(ErrorType.BAD_REQUEST_ERROR, "Fields Full name or combination of Last name and First name are empty");
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/UpdateAuthRequestValidator.java
// public class UpdateAuthRequestValidator implements AuthRequestValidator<UpdateAuthRQ> {
//
// private final ParamNamesProvider paramNamesProvider;
//
// public UpdateAuthRequestValidator(ParamNamesProvider paramNamesProvider) {
// this.paramNamesProvider = paramNamesProvider;
// }
//
// @Override
// public void validate(UpdateAuthRQ updateRequest) {
// final List<String> paramNames = paramNamesProvider.provide();
// paramNames.stream()
// .map(it -> retrieveParam(updateRequest, it))
// .forEach(it -> expect(it, Optional::isPresent).verify(ErrorType.BAD_REQUEST_ERROR,
// formattedSupplier("parameter '{}' is required.", it)
// ));
// }
//
// private Optional<String> retrieveParam(UpdateAuthRQ updateRequest, String name) {
// return ofNullable(updateRequest.getIntegrationParams().get(name)).map(String::valueOf).filter(StringUtils::isNotBlank);
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/param/provider/LdapRequiredParamNamesProvider.java
// @Service
// public class LdapRequiredParamNamesProvider implements ParamNamesProvider {
//
// @Override
// public List<String> provide() {
// return Arrays.stream(LdapParameter.values())
// .filter(LdapParameter::isRequired)
// .map(LdapParameter::getParameterName)
// .collect(Collectors.toList());
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/param/provider/ParamNamesProvider.java
// public interface ParamNamesProvider {
//
// List<String> provide();
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/param/provider/SamlRequiredParamNamesProvider.java
// @Service
// public class SamlRequiredParamNamesProvider implements ParamNamesProvider {
//
// @Override
// public List<String> provide() {
// return Arrays.stream(SamlParameter.values())
// .filter(SamlParameter::isRequired)
// .map(SamlParameter::getParameterName)
// .collect(Collectors.toList());
// }
// }
// Path: src/main/java/com/epam/reportportal/auth/config/AuthIntegrationValidatorConfig.java
import com.epam.reportportal.auth.integration.validator.request.SamlUpdateAuthRequestValidator;
import com.epam.reportportal.auth.integration.validator.request.UpdateAuthRequestValidator;
import com.epam.reportportal.auth.integration.validator.request.param.provider.LdapRequiredParamNamesProvider;
import com.epam.reportportal.auth.integration.validator.request.param.provider.ParamNamesProvider;
import com.epam.reportportal.auth.integration.validator.request.param.provider.SamlRequiredParamNamesProvider;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
package com.epam.reportportal.auth.config;
@Configuration
public class AuthIntegrationValidatorConfig {
@Bean | public ParamNamesProvider ldapParamNamesProvider() { |
reportportal/service-authorization | src/main/java/com/epam/reportportal/auth/config/AuthIntegrationValidatorConfig.java | // Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/SamlUpdateAuthRequestValidator.java
// public class SamlUpdateAuthRequestValidator extends UpdateAuthRequestValidator {
//
// private static final Predicate<UpdateAuthRQ> FULL_NAME_IS_EMPTY = request -> FULL_NAME_ATTRIBUTE.getParameter(request).isEmpty();
// private static final Predicate<UpdateAuthRQ> FIRST_AND_LAST_NAME_IS_EMPTY = request ->
// LAST_NAME_ATTRIBUTE.getParameter(request).isEmpty() && FIRST_NAME_ATTRIBUTE.getParameter(request).isEmpty();
//
// public SamlUpdateAuthRequestValidator(ParamNamesProvider paramNamesProvider) {
// super(paramNamesProvider);
// }
//
// @Override
// public void validate(UpdateAuthRQ updateRequest) {
// super.validate(updateRequest);
// BusinessRule.expect(FULL_NAME_IS_EMPTY.test(updateRequest) && FIRST_AND_LAST_NAME_IS_EMPTY.test(updateRequest),
// equalTo(Boolean.FALSE)
// ).verify(ErrorType.BAD_REQUEST_ERROR, "Fields Full name or combination of Last name and First name are empty");
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/UpdateAuthRequestValidator.java
// public class UpdateAuthRequestValidator implements AuthRequestValidator<UpdateAuthRQ> {
//
// private final ParamNamesProvider paramNamesProvider;
//
// public UpdateAuthRequestValidator(ParamNamesProvider paramNamesProvider) {
// this.paramNamesProvider = paramNamesProvider;
// }
//
// @Override
// public void validate(UpdateAuthRQ updateRequest) {
// final List<String> paramNames = paramNamesProvider.provide();
// paramNames.stream()
// .map(it -> retrieveParam(updateRequest, it))
// .forEach(it -> expect(it, Optional::isPresent).verify(ErrorType.BAD_REQUEST_ERROR,
// formattedSupplier("parameter '{}' is required.", it)
// ));
// }
//
// private Optional<String> retrieveParam(UpdateAuthRQ updateRequest, String name) {
// return ofNullable(updateRequest.getIntegrationParams().get(name)).map(String::valueOf).filter(StringUtils::isNotBlank);
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/param/provider/LdapRequiredParamNamesProvider.java
// @Service
// public class LdapRequiredParamNamesProvider implements ParamNamesProvider {
//
// @Override
// public List<String> provide() {
// return Arrays.stream(LdapParameter.values())
// .filter(LdapParameter::isRequired)
// .map(LdapParameter::getParameterName)
// .collect(Collectors.toList());
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/param/provider/ParamNamesProvider.java
// public interface ParamNamesProvider {
//
// List<String> provide();
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/param/provider/SamlRequiredParamNamesProvider.java
// @Service
// public class SamlRequiredParamNamesProvider implements ParamNamesProvider {
//
// @Override
// public List<String> provide() {
// return Arrays.stream(SamlParameter.values())
// .filter(SamlParameter::isRequired)
// .map(SamlParameter::getParameterName)
// .collect(Collectors.toList());
// }
// }
| import com.epam.reportportal.auth.integration.validator.request.SamlUpdateAuthRequestValidator;
import com.epam.reportportal.auth.integration.validator.request.UpdateAuthRequestValidator;
import com.epam.reportportal.auth.integration.validator.request.param.provider.LdapRequiredParamNamesProvider;
import com.epam.reportportal.auth.integration.validator.request.param.provider.ParamNamesProvider;
import com.epam.reportportal.auth.integration.validator.request.param.provider.SamlRequiredParamNamesProvider;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; | package com.epam.reportportal.auth.config;
@Configuration
public class AuthIntegrationValidatorConfig {
@Bean
public ParamNamesProvider ldapParamNamesProvider() { | // Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/SamlUpdateAuthRequestValidator.java
// public class SamlUpdateAuthRequestValidator extends UpdateAuthRequestValidator {
//
// private static final Predicate<UpdateAuthRQ> FULL_NAME_IS_EMPTY = request -> FULL_NAME_ATTRIBUTE.getParameter(request).isEmpty();
// private static final Predicate<UpdateAuthRQ> FIRST_AND_LAST_NAME_IS_EMPTY = request ->
// LAST_NAME_ATTRIBUTE.getParameter(request).isEmpty() && FIRST_NAME_ATTRIBUTE.getParameter(request).isEmpty();
//
// public SamlUpdateAuthRequestValidator(ParamNamesProvider paramNamesProvider) {
// super(paramNamesProvider);
// }
//
// @Override
// public void validate(UpdateAuthRQ updateRequest) {
// super.validate(updateRequest);
// BusinessRule.expect(FULL_NAME_IS_EMPTY.test(updateRequest) && FIRST_AND_LAST_NAME_IS_EMPTY.test(updateRequest),
// equalTo(Boolean.FALSE)
// ).verify(ErrorType.BAD_REQUEST_ERROR, "Fields Full name or combination of Last name and First name are empty");
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/UpdateAuthRequestValidator.java
// public class UpdateAuthRequestValidator implements AuthRequestValidator<UpdateAuthRQ> {
//
// private final ParamNamesProvider paramNamesProvider;
//
// public UpdateAuthRequestValidator(ParamNamesProvider paramNamesProvider) {
// this.paramNamesProvider = paramNamesProvider;
// }
//
// @Override
// public void validate(UpdateAuthRQ updateRequest) {
// final List<String> paramNames = paramNamesProvider.provide();
// paramNames.stream()
// .map(it -> retrieveParam(updateRequest, it))
// .forEach(it -> expect(it, Optional::isPresent).verify(ErrorType.BAD_REQUEST_ERROR,
// formattedSupplier("parameter '{}' is required.", it)
// ));
// }
//
// private Optional<String> retrieveParam(UpdateAuthRQ updateRequest, String name) {
// return ofNullable(updateRequest.getIntegrationParams().get(name)).map(String::valueOf).filter(StringUtils::isNotBlank);
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/param/provider/LdapRequiredParamNamesProvider.java
// @Service
// public class LdapRequiredParamNamesProvider implements ParamNamesProvider {
//
// @Override
// public List<String> provide() {
// return Arrays.stream(LdapParameter.values())
// .filter(LdapParameter::isRequired)
// .map(LdapParameter::getParameterName)
// .collect(Collectors.toList());
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/param/provider/ParamNamesProvider.java
// public interface ParamNamesProvider {
//
// List<String> provide();
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/param/provider/SamlRequiredParamNamesProvider.java
// @Service
// public class SamlRequiredParamNamesProvider implements ParamNamesProvider {
//
// @Override
// public List<String> provide() {
// return Arrays.stream(SamlParameter.values())
// .filter(SamlParameter::isRequired)
// .map(SamlParameter::getParameterName)
// .collect(Collectors.toList());
// }
// }
// Path: src/main/java/com/epam/reportportal/auth/config/AuthIntegrationValidatorConfig.java
import com.epam.reportportal.auth.integration.validator.request.SamlUpdateAuthRequestValidator;
import com.epam.reportportal.auth.integration.validator.request.UpdateAuthRequestValidator;
import com.epam.reportportal.auth.integration.validator.request.param.provider.LdapRequiredParamNamesProvider;
import com.epam.reportportal.auth.integration.validator.request.param.provider.ParamNamesProvider;
import com.epam.reportportal.auth.integration.validator.request.param.provider.SamlRequiredParamNamesProvider;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
package com.epam.reportportal.auth.config;
@Configuration
public class AuthIntegrationValidatorConfig {
@Bean
public ParamNamesProvider ldapParamNamesProvider() { | return new LdapRequiredParamNamesProvider(); |
reportportal/service-authorization | src/main/java/com/epam/reportportal/auth/config/AuthIntegrationValidatorConfig.java | // Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/SamlUpdateAuthRequestValidator.java
// public class SamlUpdateAuthRequestValidator extends UpdateAuthRequestValidator {
//
// private static final Predicate<UpdateAuthRQ> FULL_NAME_IS_EMPTY = request -> FULL_NAME_ATTRIBUTE.getParameter(request).isEmpty();
// private static final Predicate<UpdateAuthRQ> FIRST_AND_LAST_NAME_IS_EMPTY = request ->
// LAST_NAME_ATTRIBUTE.getParameter(request).isEmpty() && FIRST_NAME_ATTRIBUTE.getParameter(request).isEmpty();
//
// public SamlUpdateAuthRequestValidator(ParamNamesProvider paramNamesProvider) {
// super(paramNamesProvider);
// }
//
// @Override
// public void validate(UpdateAuthRQ updateRequest) {
// super.validate(updateRequest);
// BusinessRule.expect(FULL_NAME_IS_EMPTY.test(updateRequest) && FIRST_AND_LAST_NAME_IS_EMPTY.test(updateRequest),
// equalTo(Boolean.FALSE)
// ).verify(ErrorType.BAD_REQUEST_ERROR, "Fields Full name or combination of Last name and First name are empty");
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/UpdateAuthRequestValidator.java
// public class UpdateAuthRequestValidator implements AuthRequestValidator<UpdateAuthRQ> {
//
// private final ParamNamesProvider paramNamesProvider;
//
// public UpdateAuthRequestValidator(ParamNamesProvider paramNamesProvider) {
// this.paramNamesProvider = paramNamesProvider;
// }
//
// @Override
// public void validate(UpdateAuthRQ updateRequest) {
// final List<String> paramNames = paramNamesProvider.provide();
// paramNames.stream()
// .map(it -> retrieveParam(updateRequest, it))
// .forEach(it -> expect(it, Optional::isPresent).verify(ErrorType.BAD_REQUEST_ERROR,
// formattedSupplier("parameter '{}' is required.", it)
// ));
// }
//
// private Optional<String> retrieveParam(UpdateAuthRQ updateRequest, String name) {
// return ofNullable(updateRequest.getIntegrationParams().get(name)).map(String::valueOf).filter(StringUtils::isNotBlank);
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/param/provider/LdapRequiredParamNamesProvider.java
// @Service
// public class LdapRequiredParamNamesProvider implements ParamNamesProvider {
//
// @Override
// public List<String> provide() {
// return Arrays.stream(LdapParameter.values())
// .filter(LdapParameter::isRequired)
// .map(LdapParameter::getParameterName)
// .collect(Collectors.toList());
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/param/provider/ParamNamesProvider.java
// public interface ParamNamesProvider {
//
// List<String> provide();
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/param/provider/SamlRequiredParamNamesProvider.java
// @Service
// public class SamlRequiredParamNamesProvider implements ParamNamesProvider {
//
// @Override
// public List<String> provide() {
// return Arrays.stream(SamlParameter.values())
// .filter(SamlParameter::isRequired)
// .map(SamlParameter::getParameterName)
// .collect(Collectors.toList());
// }
// }
| import com.epam.reportportal.auth.integration.validator.request.SamlUpdateAuthRequestValidator;
import com.epam.reportportal.auth.integration.validator.request.UpdateAuthRequestValidator;
import com.epam.reportportal.auth.integration.validator.request.param.provider.LdapRequiredParamNamesProvider;
import com.epam.reportportal.auth.integration.validator.request.param.provider.ParamNamesProvider;
import com.epam.reportportal.auth.integration.validator.request.param.provider.SamlRequiredParamNamesProvider;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; | package com.epam.reportportal.auth.config;
@Configuration
public class AuthIntegrationValidatorConfig {
@Bean
public ParamNamesProvider ldapParamNamesProvider() {
return new LdapRequiredParamNamesProvider();
}
@Bean
public ParamNamesProvider samlParamNamesProvider() { | // Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/SamlUpdateAuthRequestValidator.java
// public class SamlUpdateAuthRequestValidator extends UpdateAuthRequestValidator {
//
// private static final Predicate<UpdateAuthRQ> FULL_NAME_IS_EMPTY = request -> FULL_NAME_ATTRIBUTE.getParameter(request).isEmpty();
// private static final Predicate<UpdateAuthRQ> FIRST_AND_LAST_NAME_IS_EMPTY = request ->
// LAST_NAME_ATTRIBUTE.getParameter(request).isEmpty() && FIRST_NAME_ATTRIBUTE.getParameter(request).isEmpty();
//
// public SamlUpdateAuthRequestValidator(ParamNamesProvider paramNamesProvider) {
// super(paramNamesProvider);
// }
//
// @Override
// public void validate(UpdateAuthRQ updateRequest) {
// super.validate(updateRequest);
// BusinessRule.expect(FULL_NAME_IS_EMPTY.test(updateRequest) && FIRST_AND_LAST_NAME_IS_EMPTY.test(updateRequest),
// equalTo(Boolean.FALSE)
// ).verify(ErrorType.BAD_REQUEST_ERROR, "Fields Full name or combination of Last name and First name are empty");
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/UpdateAuthRequestValidator.java
// public class UpdateAuthRequestValidator implements AuthRequestValidator<UpdateAuthRQ> {
//
// private final ParamNamesProvider paramNamesProvider;
//
// public UpdateAuthRequestValidator(ParamNamesProvider paramNamesProvider) {
// this.paramNamesProvider = paramNamesProvider;
// }
//
// @Override
// public void validate(UpdateAuthRQ updateRequest) {
// final List<String> paramNames = paramNamesProvider.provide();
// paramNames.stream()
// .map(it -> retrieveParam(updateRequest, it))
// .forEach(it -> expect(it, Optional::isPresent).verify(ErrorType.BAD_REQUEST_ERROR,
// formattedSupplier("parameter '{}' is required.", it)
// ));
// }
//
// private Optional<String> retrieveParam(UpdateAuthRQ updateRequest, String name) {
// return ofNullable(updateRequest.getIntegrationParams().get(name)).map(String::valueOf).filter(StringUtils::isNotBlank);
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/param/provider/LdapRequiredParamNamesProvider.java
// @Service
// public class LdapRequiredParamNamesProvider implements ParamNamesProvider {
//
// @Override
// public List<String> provide() {
// return Arrays.stream(LdapParameter.values())
// .filter(LdapParameter::isRequired)
// .map(LdapParameter::getParameterName)
// .collect(Collectors.toList());
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/param/provider/ParamNamesProvider.java
// public interface ParamNamesProvider {
//
// List<String> provide();
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/param/provider/SamlRequiredParamNamesProvider.java
// @Service
// public class SamlRequiredParamNamesProvider implements ParamNamesProvider {
//
// @Override
// public List<String> provide() {
// return Arrays.stream(SamlParameter.values())
// .filter(SamlParameter::isRequired)
// .map(SamlParameter::getParameterName)
// .collect(Collectors.toList());
// }
// }
// Path: src/main/java/com/epam/reportportal/auth/config/AuthIntegrationValidatorConfig.java
import com.epam.reportportal.auth.integration.validator.request.SamlUpdateAuthRequestValidator;
import com.epam.reportportal.auth.integration.validator.request.UpdateAuthRequestValidator;
import com.epam.reportportal.auth.integration.validator.request.param.provider.LdapRequiredParamNamesProvider;
import com.epam.reportportal.auth.integration.validator.request.param.provider.ParamNamesProvider;
import com.epam.reportportal.auth.integration.validator.request.param.provider.SamlRequiredParamNamesProvider;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
package com.epam.reportportal.auth.config;
@Configuration
public class AuthIntegrationValidatorConfig {
@Bean
public ParamNamesProvider ldapParamNamesProvider() {
return new LdapRequiredParamNamesProvider();
}
@Bean
public ParamNamesProvider samlParamNamesProvider() { | return new SamlRequiredParamNamesProvider(); |
reportportal/service-authorization | src/main/java/com/epam/reportportal/auth/config/AuthIntegrationValidatorConfig.java | // Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/SamlUpdateAuthRequestValidator.java
// public class SamlUpdateAuthRequestValidator extends UpdateAuthRequestValidator {
//
// private static final Predicate<UpdateAuthRQ> FULL_NAME_IS_EMPTY = request -> FULL_NAME_ATTRIBUTE.getParameter(request).isEmpty();
// private static final Predicate<UpdateAuthRQ> FIRST_AND_LAST_NAME_IS_EMPTY = request ->
// LAST_NAME_ATTRIBUTE.getParameter(request).isEmpty() && FIRST_NAME_ATTRIBUTE.getParameter(request).isEmpty();
//
// public SamlUpdateAuthRequestValidator(ParamNamesProvider paramNamesProvider) {
// super(paramNamesProvider);
// }
//
// @Override
// public void validate(UpdateAuthRQ updateRequest) {
// super.validate(updateRequest);
// BusinessRule.expect(FULL_NAME_IS_EMPTY.test(updateRequest) && FIRST_AND_LAST_NAME_IS_EMPTY.test(updateRequest),
// equalTo(Boolean.FALSE)
// ).verify(ErrorType.BAD_REQUEST_ERROR, "Fields Full name or combination of Last name and First name are empty");
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/UpdateAuthRequestValidator.java
// public class UpdateAuthRequestValidator implements AuthRequestValidator<UpdateAuthRQ> {
//
// private final ParamNamesProvider paramNamesProvider;
//
// public UpdateAuthRequestValidator(ParamNamesProvider paramNamesProvider) {
// this.paramNamesProvider = paramNamesProvider;
// }
//
// @Override
// public void validate(UpdateAuthRQ updateRequest) {
// final List<String> paramNames = paramNamesProvider.provide();
// paramNames.stream()
// .map(it -> retrieveParam(updateRequest, it))
// .forEach(it -> expect(it, Optional::isPresent).verify(ErrorType.BAD_REQUEST_ERROR,
// formattedSupplier("parameter '{}' is required.", it)
// ));
// }
//
// private Optional<String> retrieveParam(UpdateAuthRQ updateRequest, String name) {
// return ofNullable(updateRequest.getIntegrationParams().get(name)).map(String::valueOf).filter(StringUtils::isNotBlank);
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/param/provider/LdapRequiredParamNamesProvider.java
// @Service
// public class LdapRequiredParamNamesProvider implements ParamNamesProvider {
//
// @Override
// public List<String> provide() {
// return Arrays.stream(LdapParameter.values())
// .filter(LdapParameter::isRequired)
// .map(LdapParameter::getParameterName)
// .collect(Collectors.toList());
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/param/provider/ParamNamesProvider.java
// public interface ParamNamesProvider {
//
// List<String> provide();
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/param/provider/SamlRequiredParamNamesProvider.java
// @Service
// public class SamlRequiredParamNamesProvider implements ParamNamesProvider {
//
// @Override
// public List<String> provide() {
// return Arrays.stream(SamlParameter.values())
// .filter(SamlParameter::isRequired)
// .map(SamlParameter::getParameterName)
// .collect(Collectors.toList());
// }
// }
| import com.epam.reportportal.auth.integration.validator.request.SamlUpdateAuthRequestValidator;
import com.epam.reportportal.auth.integration.validator.request.UpdateAuthRequestValidator;
import com.epam.reportportal.auth.integration.validator.request.param.provider.LdapRequiredParamNamesProvider;
import com.epam.reportportal.auth.integration.validator.request.param.provider.ParamNamesProvider;
import com.epam.reportportal.auth.integration.validator.request.param.provider.SamlRequiredParamNamesProvider;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; | package com.epam.reportportal.auth.config;
@Configuration
public class AuthIntegrationValidatorConfig {
@Bean
public ParamNamesProvider ldapParamNamesProvider() {
return new LdapRequiredParamNamesProvider();
}
@Bean
public ParamNamesProvider samlParamNamesProvider() {
return new SamlRequiredParamNamesProvider();
}
@Bean | // Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/SamlUpdateAuthRequestValidator.java
// public class SamlUpdateAuthRequestValidator extends UpdateAuthRequestValidator {
//
// private static final Predicate<UpdateAuthRQ> FULL_NAME_IS_EMPTY = request -> FULL_NAME_ATTRIBUTE.getParameter(request).isEmpty();
// private static final Predicate<UpdateAuthRQ> FIRST_AND_LAST_NAME_IS_EMPTY = request ->
// LAST_NAME_ATTRIBUTE.getParameter(request).isEmpty() && FIRST_NAME_ATTRIBUTE.getParameter(request).isEmpty();
//
// public SamlUpdateAuthRequestValidator(ParamNamesProvider paramNamesProvider) {
// super(paramNamesProvider);
// }
//
// @Override
// public void validate(UpdateAuthRQ updateRequest) {
// super.validate(updateRequest);
// BusinessRule.expect(FULL_NAME_IS_EMPTY.test(updateRequest) && FIRST_AND_LAST_NAME_IS_EMPTY.test(updateRequest),
// equalTo(Boolean.FALSE)
// ).verify(ErrorType.BAD_REQUEST_ERROR, "Fields Full name or combination of Last name and First name are empty");
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/UpdateAuthRequestValidator.java
// public class UpdateAuthRequestValidator implements AuthRequestValidator<UpdateAuthRQ> {
//
// private final ParamNamesProvider paramNamesProvider;
//
// public UpdateAuthRequestValidator(ParamNamesProvider paramNamesProvider) {
// this.paramNamesProvider = paramNamesProvider;
// }
//
// @Override
// public void validate(UpdateAuthRQ updateRequest) {
// final List<String> paramNames = paramNamesProvider.provide();
// paramNames.stream()
// .map(it -> retrieveParam(updateRequest, it))
// .forEach(it -> expect(it, Optional::isPresent).verify(ErrorType.BAD_REQUEST_ERROR,
// formattedSupplier("parameter '{}' is required.", it)
// ));
// }
//
// private Optional<String> retrieveParam(UpdateAuthRQ updateRequest, String name) {
// return ofNullable(updateRequest.getIntegrationParams().get(name)).map(String::valueOf).filter(StringUtils::isNotBlank);
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/param/provider/LdapRequiredParamNamesProvider.java
// @Service
// public class LdapRequiredParamNamesProvider implements ParamNamesProvider {
//
// @Override
// public List<String> provide() {
// return Arrays.stream(LdapParameter.values())
// .filter(LdapParameter::isRequired)
// .map(LdapParameter::getParameterName)
// .collect(Collectors.toList());
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/param/provider/ParamNamesProvider.java
// public interface ParamNamesProvider {
//
// List<String> provide();
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/param/provider/SamlRequiredParamNamesProvider.java
// @Service
// public class SamlRequiredParamNamesProvider implements ParamNamesProvider {
//
// @Override
// public List<String> provide() {
// return Arrays.stream(SamlParameter.values())
// .filter(SamlParameter::isRequired)
// .map(SamlParameter::getParameterName)
// .collect(Collectors.toList());
// }
// }
// Path: src/main/java/com/epam/reportportal/auth/config/AuthIntegrationValidatorConfig.java
import com.epam.reportportal.auth.integration.validator.request.SamlUpdateAuthRequestValidator;
import com.epam.reportportal.auth.integration.validator.request.UpdateAuthRequestValidator;
import com.epam.reportportal.auth.integration.validator.request.param.provider.LdapRequiredParamNamesProvider;
import com.epam.reportportal.auth.integration.validator.request.param.provider.ParamNamesProvider;
import com.epam.reportportal.auth.integration.validator.request.param.provider.SamlRequiredParamNamesProvider;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
package com.epam.reportportal.auth.config;
@Configuration
public class AuthIntegrationValidatorConfig {
@Bean
public ParamNamesProvider ldapParamNamesProvider() {
return new LdapRequiredParamNamesProvider();
}
@Bean
public ParamNamesProvider samlParamNamesProvider() {
return new SamlRequiredParamNamesProvider();
}
@Bean | public UpdateAuthRequestValidator ldapUpdateAuthRequestValidator() { |
reportportal/service-authorization | src/main/java/com/epam/reportportal/auth/config/AuthIntegrationValidatorConfig.java | // Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/SamlUpdateAuthRequestValidator.java
// public class SamlUpdateAuthRequestValidator extends UpdateAuthRequestValidator {
//
// private static final Predicate<UpdateAuthRQ> FULL_NAME_IS_EMPTY = request -> FULL_NAME_ATTRIBUTE.getParameter(request).isEmpty();
// private static final Predicate<UpdateAuthRQ> FIRST_AND_LAST_NAME_IS_EMPTY = request ->
// LAST_NAME_ATTRIBUTE.getParameter(request).isEmpty() && FIRST_NAME_ATTRIBUTE.getParameter(request).isEmpty();
//
// public SamlUpdateAuthRequestValidator(ParamNamesProvider paramNamesProvider) {
// super(paramNamesProvider);
// }
//
// @Override
// public void validate(UpdateAuthRQ updateRequest) {
// super.validate(updateRequest);
// BusinessRule.expect(FULL_NAME_IS_EMPTY.test(updateRequest) && FIRST_AND_LAST_NAME_IS_EMPTY.test(updateRequest),
// equalTo(Boolean.FALSE)
// ).verify(ErrorType.BAD_REQUEST_ERROR, "Fields Full name or combination of Last name and First name are empty");
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/UpdateAuthRequestValidator.java
// public class UpdateAuthRequestValidator implements AuthRequestValidator<UpdateAuthRQ> {
//
// private final ParamNamesProvider paramNamesProvider;
//
// public UpdateAuthRequestValidator(ParamNamesProvider paramNamesProvider) {
// this.paramNamesProvider = paramNamesProvider;
// }
//
// @Override
// public void validate(UpdateAuthRQ updateRequest) {
// final List<String> paramNames = paramNamesProvider.provide();
// paramNames.stream()
// .map(it -> retrieveParam(updateRequest, it))
// .forEach(it -> expect(it, Optional::isPresent).verify(ErrorType.BAD_REQUEST_ERROR,
// formattedSupplier("parameter '{}' is required.", it)
// ));
// }
//
// private Optional<String> retrieveParam(UpdateAuthRQ updateRequest, String name) {
// return ofNullable(updateRequest.getIntegrationParams().get(name)).map(String::valueOf).filter(StringUtils::isNotBlank);
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/param/provider/LdapRequiredParamNamesProvider.java
// @Service
// public class LdapRequiredParamNamesProvider implements ParamNamesProvider {
//
// @Override
// public List<String> provide() {
// return Arrays.stream(LdapParameter.values())
// .filter(LdapParameter::isRequired)
// .map(LdapParameter::getParameterName)
// .collect(Collectors.toList());
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/param/provider/ParamNamesProvider.java
// public interface ParamNamesProvider {
//
// List<String> provide();
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/param/provider/SamlRequiredParamNamesProvider.java
// @Service
// public class SamlRequiredParamNamesProvider implements ParamNamesProvider {
//
// @Override
// public List<String> provide() {
// return Arrays.stream(SamlParameter.values())
// .filter(SamlParameter::isRequired)
// .map(SamlParameter::getParameterName)
// .collect(Collectors.toList());
// }
// }
| import com.epam.reportportal.auth.integration.validator.request.SamlUpdateAuthRequestValidator;
import com.epam.reportportal.auth.integration.validator.request.UpdateAuthRequestValidator;
import com.epam.reportportal.auth.integration.validator.request.param.provider.LdapRequiredParamNamesProvider;
import com.epam.reportportal.auth.integration.validator.request.param.provider.ParamNamesProvider;
import com.epam.reportportal.auth.integration.validator.request.param.provider.SamlRequiredParamNamesProvider;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; | package com.epam.reportportal.auth.config;
@Configuration
public class AuthIntegrationValidatorConfig {
@Bean
public ParamNamesProvider ldapParamNamesProvider() {
return new LdapRequiredParamNamesProvider();
}
@Bean
public ParamNamesProvider samlParamNamesProvider() {
return new SamlRequiredParamNamesProvider();
}
@Bean
public UpdateAuthRequestValidator ldapUpdateAuthRequestValidator() {
return new UpdateAuthRequestValidator(ldapParamNamesProvider());
}
@Bean | // Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/SamlUpdateAuthRequestValidator.java
// public class SamlUpdateAuthRequestValidator extends UpdateAuthRequestValidator {
//
// private static final Predicate<UpdateAuthRQ> FULL_NAME_IS_EMPTY = request -> FULL_NAME_ATTRIBUTE.getParameter(request).isEmpty();
// private static final Predicate<UpdateAuthRQ> FIRST_AND_LAST_NAME_IS_EMPTY = request ->
// LAST_NAME_ATTRIBUTE.getParameter(request).isEmpty() && FIRST_NAME_ATTRIBUTE.getParameter(request).isEmpty();
//
// public SamlUpdateAuthRequestValidator(ParamNamesProvider paramNamesProvider) {
// super(paramNamesProvider);
// }
//
// @Override
// public void validate(UpdateAuthRQ updateRequest) {
// super.validate(updateRequest);
// BusinessRule.expect(FULL_NAME_IS_EMPTY.test(updateRequest) && FIRST_AND_LAST_NAME_IS_EMPTY.test(updateRequest),
// equalTo(Boolean.FALSE)
// ).verify(ErrorType.BAD_REQUEST_ERROR, "Fields Full name or combination of Last name and First name are empty");
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/UpdateAuthRequestValidator.java
// public class UpdateAuthRequestValidator implements AuthRequestValidator<UpdateAuthRQ> {
//
// private final ParamNamesProvider paramNamesProvider;
//
// public UpdateAuthRequestValidator(ParamNamesProvider paramNamesProvider) {
// this.paramNamesProvider = paramNamesProvider;
// }
//
// @Override
// public void validate(UpdateAuthRQ updateRequest) {
// final List<String> paramNames = paramNamesProvider.provide();
// paramNames.stream()
// .map(it -> retrieveParam(updateRequest, it))
// .forEach(it -> expect(it, Optional::isPresent).verify(ErrorType.BAD_REQUEST_ERROR,
// formattedSupplier("parameter '{}' is required.", it)
// ));
// }
//
// private Optional<String> retrieveParam(UpdateAuthRQ updateRequest, String name) {
// return ofNullable(updateRequest.getIntegrationParams().get(name)).map(String::valueOf).filter(StringUtils::isNotBlank);
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/param/provider/LdapRequiredParamNamesProvider.java
// @Service
// public class LdapRequiredParamNamesProvider implements ParamNamesProvider {
//
// @Override
// public List<String> provide() {
// return Arrays.stream(LdapParameter.values())
// .filter(LdapParameter::isRequired)
// .map(LdapParameter::getParameterName)
// .collect(Collectors.toList());
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/param/provider/ParamNamesProvider.java
// public interface ParamNamesProvider {
//
// List<String> provide();
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/param/provider/SamlRequiredParamNamesProvider.java
// @Service
// public class SamlRequiredParamNamesProvider implements ParamNamesProvider {
//
// @Override
// public List<String> provide() {
// return Arrays.stream(SamlParameter.values())
// .filter(SamlParameter::isRequired)
// .map(SamlParameter::getParameterName)
// .collect(Collectors.toList());
// }
// }
// Path: src/main/java/com/epam/reportportal/auth/config/AuthIntegrationValidatorConfig.java
import com.epam.reportportal.auth.integration.validator.request.SamlUpdateAuthRequestValidator;
import com.epam.reportportal.auth.integration.validator.request.UpdateAuthRequestValidator;
import com.epam.reportportal.auth.integration.validator.request.param.provider.LdapRequiredParamNamesProvider;
import com.epam.reportportal.auth.integration.validator.request.param.provider.ParamNamesProvider;
import com.epam.reportportal.auth.integration.validator.request.param.provider.SamlRequiredParamNamesProvider;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
package com.epam.reportportal.auth.config;
@Configuration
public class AuthIntegrationValidatorConfig {
@Bean
public ParamNamesProvider ldapParamNamesProvider() {
return new LdapRequiredParamNamesProvider();
}
@Bean
public ParamNamesProvider samlParamNamesProvider() {
return new SamlRequiredParamNamesProvider();
}
@Bean
public UpdateAuthRequestValidator ldapUpdateAuthRequestValidator() {
return new UpdateAuthRequestValidator(ldapParamNamesProvider());
}
@Bean | public SamlUpdateAuthRequestValidator samlUpdateAuthRequestValidator() { |
reportportal/service-authorization | src/main/java/com/epam/reportportal/auth/integration/AbstractUserReplicator.java | // Path: src/main/java/com/epam/reportportal/auth/oauth/UserSynchronizationException.java
// public class UserSynchronizationException extends AuthenticationException {
//
// public UserSynchronizationException(String msg) {
// super(msg);
// }
//
// public UserSynchronizationException(String msg, Throwable e) {
// super(msg, e);
// }
// }
| import java.time.ZoneOffset;
import java.util.HashMap;
import java.util.Map;
import static java.util.Optional.ofNullable;
import com.epam.reportportal.auth.oauth.UserSynchronizationException;
import com.epam.reportportal.commons.ContentTypeResolver;
import com.epam.ta.reportportal.binary.UserBinaryDataService;
import com.epam.ta.reportportal.dao.ProjectRepository;
import com.epam.ta.reportportal.dao.UserRepository;
import com.epam.ta.reportportal.entity.attachment.BinaryData;
import com.epam.ta.reportportal.entity.project.Project;
import com.epam.ta.reportportal.entity.user.User;
import com.epam.ta.reportportal.util.PersonalProjectService;
import com.google.common.collect.Maps;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.ByteArrayInputStream;
import java.time.LocalDateTime; | *
* @return Default meta info
*/
protected com.epam.ta.reportportal.entity.Metadata defaultMetaData() {
Map<String, Object> metaDataMap = new HashMap<>();
long nowInMillis = LocalDateTime.now().toInstant(ZoneOffset.UTC).toEpochMilli();
metaDataMap.put("last_login", nowInMillis);
metaDataMap.put("synchronizationDate", nowInMillis);
return new com.epam.ta.reportportal.entity.Metadata(metaDataMap);
}
/**
* Updates last syncronization data for specified user
*
* @param user User to be synchronized
*/
protected void updateSynchronizationDate(User user) {
com.epam.ta.reportportal.entity.Metadata metadata = ofNullable(user.getMetadata()).orElse(new com.epam.ta.reportportal.entity.Metadata(
Maps.newHashMap()));
metadata.getMetadata().put("synchronizationDate", LocalDateTime.now().toInstant(ZoneOffset.UTC).toEpochMilli());
user.setMetadata(metadata);
}
/**
* Checks email is available
*
* @param email email to check
*/
protected void checkEmail(String email) {
if (userRepository.findByEmail(email).isPresent()) { | // Path: src/main/java/com/epam/reportportal/auth/oauth/UserSynchronizationException.java
// public class UserSynchronizationException extends AuthenticationException {
//
// public UserSynchronizationException(String msg) {
// super(msg);
// }
//
// public UserSynchronizationException(String msg, Throwable e) {
// super(msg, e);
// }
// }
// Path: src/main/java/com/epam/reportportal/auth/integration/AbstractUserReplicator.java
import java.time.ZoneOffset;
import java.util.HashMap;
import java.util.Map;
import static java.util.Optional.ofNullable;
import com.epam.reportportal.auth.oauth.UserSynchronizationException;
import com.epam.reportportal.commons.ContentTypeResolver;
import com.epam.ta.reportportal.binary.UserBinaryDataService;
import com.epam.ta.reportportal.dao.ProjectRepository;
import com.epam.ta.reportportal.dao.UserRepository;
import com.epam.ta.reportportal.entity.attachment.BinaryData;
import com.epam.ta.reportportal.entity.project.Project;
import com.epam.ta.reportportal.entity.user.User;
import com.epam.ta.reportportal.util.PersonalProjectService;
import com.google.common.collect.Maps;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.ByteArrayInputStream;
import java.time.LocalDateTime;
*
* @return Default meta info
*/
protected com.epam.ta.reportportal.entity.Metadata defaultMetaData() {
Map<String, Object> metaDataMap = new HashMap<>();
long nowInMillis = LocalDateTime.now().toInstant(ZoneOffset.UTC).toEpochMilli();
metaDataMap.put("last_login", nowInMillis);
metaDataMap.put("synchronizationDate", nowInMillis);
return new com.epam.ta.reportportal.entity.Metadata(metaDataMap);
}
/**
* Updates last syncronization data for specified user
*
* @param user User to be synchronized
*/
protected void updateSynchronizationDate(User user) {
com.epam.ta.reportportal.entity.Metadata metadata = ofNullable(user.getMetadata()).orElse(new com.epam.ta.reportportal.entity.Metadata(
Maps.newHashMap()));
metadata.getMetadata().put("synchronizationDate", LocalDateTime.now().toInstant(ZoneOffset.UTC).toEpochMilli());
user.setMetadata(metadata);
}
/**
* Checks email is available
*
* @param email email to check
*/
protected void checkEmail(String email) {
if (userRepository.findByEmail(email).isPresent()) { | throw new UserSynchronizationException("User with email '" + email + "' already exists"); |
reportportal/service-authorization | src/main/java/com/epam/reportportal/auth/integration/validator/request/SamlUpdateAuthRequestValidator.java | // Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/param/provider/ParamNamesProvider.java
// public interface ParamNamesProvider {
//
// List<String> provide();
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/parameter/SamlParameter.java
// public enum SamlParameter {
//
// BASE_PATH("callbackUrl", false),
// IDP_NAME("identityProviderName", true),
// IDP_METADATA_URL("identityProviderMetadataUrl", true),
// EMAIL_ATTRIBUTE("emailAttribute", true),
// IDP_NAME_ID("identityProviderNameId", false),
// IDP_ALIAS("identityProviderAlias", false),
// IDP_URL("identityProviderUrl", false),
// FULL_NAME_ATTRIBUTE("fullNameAttribute", false),
// FIRST_NAME_ATTRIBUTE("firstNameAttribute", false),
// LAST_NAME_ATTRIBUTE("lastNameAttribute", false);
//
// private String parameterName;
//
// private boolean required;
//
// SamlParameter(String parameterName, boolean required) {
// this.parameterName = parameterName;
// this.required = required;
// }
//
// public String getParameterName() {
// return parameterName;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public Optional<String> getParameter(Integration integration) {
// return ofNullable((String) integration.getParams().getParams().get(parameterName));
// }
//
// public void setParameter(Integration integration, String value) {
// if (Objects.isNull(integration.getParams())) {
// integration.setParams(new IntegrationParams(new HashMap<>()));
// }
// if (Objects.isNull(integration.getParams().getParams())) {
// integration.getParams().setParams(new HashMap<>());
// }
// integration.getParams().getParams().put(parameterName, value);
// }
//
// public void removeParameter(Integration integration) {
// ofNullable(integration.getParams()).map(IntegrationParams::getParams).ifPresent(params -> params.remove(parameterName));
// }
//
// public String getRequiredParameter(Integration integration) {
// Optional<String> parameter = getParameter(integration);
// if (required) {
// if (parameter.isPresent()) {
// return parameter.get();
// } else {
// throw new ReportPortalException(ErrorType.INCORRECT_REQUEST, formattedSupplier("'{}' should be present.", parameterName));
// }
// } else {
// throw new ReportPortalException(ErrorType.INCORRECT_REQUEST, formattedSupplier("'{}' is not required."));
// }
// }
//
// public boolean exist(Integration integration) {
// return getParameter(integration).isPresent();
// }
//
// public Optional<String> getParameter(Map<String, Object> parameterMap) {
// return ofNullable(parameterMap.get(parameterName)).map(it -> (String) it).filter(StringUtils::isNotBlank);
// }
//
// public Optional<String> getParameter(UpdateAuthRQ request) {
// return ofNullable(request.getIntegrationParams()).flatMap(this::getParameter);
// }
//
// public String getRequiredParameter(UpdateAuthRQ request) {
// Optional<String> parameter = getParameter(request);
// if (required) {
// if (parameter.isPresent()) {
// return parameter.get();
// } else {
// throw new ReportPortalException(ErrorType.INCORRECT_REQUEST, formattedSupplier("'{}' should be present.", parameterName));
// }
// } else {
// throw new ReportPortalException(ErrorType.INCORRECT_REQUEST, formattedSupplier("'{}' is not required."));
// }
// }
//
// public void setParameter(UpdateAuthRQ request, Integration integration) {
// getParameter(request).ifPresent(it -> setParameter(integration, it));
// }
//
// }
| import com.epam.reportportal.auth.integration.validator.request.param.provider.ParamNamesProvider;
import com.epam.ta.reportportal.commons.validation.BusinessRule;
import com.epam.ta.reportportal.ws.model.ErrorType;
import com.epam.ta.reportportal.ws.model.integration.auth.UpdateAuthRQ;
import java.util.function.Predicate;
import static com.epam.reportportal.auth.integration.parameter.SamlParameter.*;
import static com.epam.ta.reportportal.commons.Predicates.equalTo; | package com.epam.reportportal.auth.integration.validator.request;
public class SamlUpdateAuthRequestValidator extends UpdateAuthRequestValidator {
private static final Predicate<UpdateAuthRQ> FULL_NAME_IS_EMPTY = request -> FULL_NAME_ATTRIBUTE.getParameter(request).isEmpty();
private static final Predicate<UpdateAuthRQ> FIRST_AND_LAST_NAME_IS_EMPTY = request ->
LAST_NAME_ATTRIBUTE.getParameter(request).isEmpty() && FIRST_NAME_ATTRIBUTE.getParameter(request).isEmpty();
| // Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/param/provider/ParamNamesProvider.java
// public interface ParamNamesProvider {
//
// List<String> provide();
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/parameter/SamlParameter.java
// public enum SamlParameter {
//
// BASE_PATH("callbackUrl", false),
// IDP_NAME("identityProviderName", true),
// IDP_METADATA_URL("identityProviderMetadataUrl", true),
// EMAIL_ATTRIBUTE("emailAttribute", true),
// IDP_NAME_ID("identityProviderNameId", false),
// IDP_ALIAS("identityProviderAlias", false),
// IDP_URL("identityProviderUrl", false),
// FULL_NAME_ATTRIBUTE("fullNameAttribute", false),
// FIRST_NAME_ATTRIBUTE("firstNameAttribute", false),
// LAST_NAME_ATTRIBUTE("lastNameAttribute", false);
//
// private String parameterName;
//
// private boolean required;
//
// SamlParameter(String parameterName, boolean required) {
// this.parameterName = parameterName;
// this.required = required;
// }
//
// public String getParameterName() {
// return parameterName;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public Optional<String> getParameter(Integration integration) {
// return ofNullable((String) integration.getParams().getParams().get(parameterName));
// }
//
// public void setParameter(Integration integration, String value) {
// if (Objects.isNull(integration.getParams())) {
// integration.setParams(new IntegrationParams(new HashMap<>()));
// }
// if (Objects.isNull(integration.getParams().getParams())) {
// integration.getParams().setParams(new HashMap<>());
// }
// integration.getParams().getParams().put(parameterName, value);
// }
//
// public void removeParameter(Integration integration) {
// ofNullable(integration.getParams()).map(IntegrationParams::getParams).ifPresent(params -> params.remove(parameterName));
// }
//
// public String getRequiredParameter(Integration integration) {
// Optional<String> parameter = getParameter(integration);
// if (required) {
// if (parameter.isPresent()) {
// return parameter.get();
// } else {
// throw new ReportPortalException(ErrorType.INCORRECT_REQUEST, formattedSupplier("'{}' should be present.", parameterName));
// }
// } else {
// throw new ReportPortalException(ErrorType.INCORRECT_REQUEST, formattedSupplier("'{}' is not required."));
// }
// }
//
// public boolean exist(Integration integration) {
// return getParameter(integration).isPresent();
// }
//
// public Optional<String> getParameter(Map<String, Object> parameterMap) {
// return ofNullable(parameterMap.get(parameterName)).map(it -> (String) it).filter(StringUtils::isNotBlank);
// }
//
// public Optional<String> getParameter(UpdateAuthRQ request) {
// return ofNullable(request.getIntegrationParams()).flatMap(this::getParameter);
// }
//
// public String getRequiredParameter(UpdateAuthRQ request) {
// Optional<String> parameter = getParameter(request);
// if (required) {
// if (parameter.isPresent()) {
// return parameter.get();
// } else {
// throw new ReportPortalException(ErrorType.INCORRECT_REQUEST, formattedSupplier("'{}' should be present.", parameterName));
// }
// } else {
// throw new ReportPortalException(ErrorType.INCORRECT_REQUEST, formattedSupplier("'{}' is not required."));
// }
// }
//
// public void setParameter(UpdateAuthRQ request, Integration integration) {
// getParameter(request).ifPresent(it -> setParameter(integration, it));
// }
//
// }
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/SamlUpdateAuthRequestValidator.java
import com.epam.reportportal.auth.integration.validator.request.param.provider.ParamNamesProvider;
import com.epam.ta.reportportal.commons.validation.BusinessRule;
import com.epam.ta.reportportal.ws.model.ErrorType;
import com.epam.ta.reportportal.ws.model.integration.auth.UpdateAuthRQ;
import java.util.function.Predicate;
import static com.epam.reportportal.auth.integration.parameter.SamlParameter.*;
import static com.epam.ta.reportportal.commons.Predicates.equalTo;
package com.epam.reportportal.auth.integration.validator.request;
public class SamlUpdateAuthRequestValidator extends UpdateAuthRequestValidator {
private static final Predicate<UpdateAuthRQ> FULL_NAME_IS_EMPTY = request -> FULL_NAME_ATTRIBUTE.getParameter(request).isEmpty();
private static final Predicate<UpdateAuthRQ> FIRST_AND_LAST_NAME_IS_EMPTY = request ->
LAST_NAME_ATTRIBUTE.getParameter(request).isEmpty() && FIRST_NAME_ATTRIBUTE.getParameter(request).isEmpty();
| public SamlUpdateAuthRequestValidator(ParamNamesProvider paramNamesProvider) { |
reportportal/service-authorization | src/main/java/com/epam/reportportal/auth/integration/converter/ActiveDirectoryConverter.java | // Path: src/main/java/com/epam/reportportal/auth/integration/parameter/LdapParameter.java
// public enum LdapParameter {
// NAME("name", false, false),
// URL("url", true, false),
// BASE_DN("baseDn", true, false),
// EMAIL_ATTRIBUTE("email", true, true),
// FULL_NAME_ATTRIBUTE("fullName", false, true),
// PHOTO_ATTRIBUTE("photo", false, true),
// SEARCH_FILTER_REMOVE_NOT_PRESENT("searchFilter", false, false) {
// @Override
// public void setParameter(UpdateAuthRQ request, Integration integration) {
// getParameter(request).ifPresentOrElse(it -> setParameter(integration, it), () -> removeParameter(integration));
// }
// },
// USER_DN_PATTERN("userDnPattern", false, false),
// USER_SEARCH_FILTER("userSearchFilter", false, false),
// GROUP_SEARCH_BASE("groupSearchBase", false, false),
// GROUP_SEARCH_FILTER("groupSearchFilter", false, false),
// PASSWORD_ENCODER_TYPE("passwordEncoderType", false, false),
// PASSWORD_ATTRIBUTE("passwordAttribute", false, false),
// MANAGER_DN("managerDn", false, false),
// MANAGER_PASSWORD("managerPassword", false, false),
// DOMAIN("domain", false, false);
//
// private String parameterName;
//
// private boolean required;
//
// private boolean syncAttribute;
//
// LdapParameter(String parameterName, boolean required, boolean syncAttribute) {
// this.parameterName = parameterName;
// this.required = required;
// this.syncAttribute = syncAttribute;
// }
//
// public String getParameterName() {
// return parameterName;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public boolean isSyncAttribute() {
// return syncAttribute;
// }
//
// public Optional<String> getParameter(Integration integration) {
// return ofNullable(integration.getParams()).map(it -> it.getParams().get(parameterName)).map(String::valueOf);
// }
//
// public void setParameter(Integration integration, String value) {
// if (Objects.isNull(integration.getParams())) {
// integration.setParams(new IntegrationParams(new HashMap<>()));
// }
// if (Objects.isNull(integration.getParams().getParams())) {
// integration.getParams().setParams(new HashMap<>());
// }
// integration.getParams().getParams().put(parameterName, value);
// }
//
// public void removeParameter(Integration integration) {
// ofNullable(integration.getParams()).map(IntegrationParams::getParams).ifPresent(params -> params.remove(parameterName));
// }
//
// public boolean exists(Integration integration) {
// return getParameter(integration).isPresent();
// }
//
// public String getRequiredParameter(Integration integration) {
// Optional<String> property = getParameter(integration);
// if (required) {
// if (property.isPresent()) {
// return property.get();
// } else {
// throw new ReportPortalException(ErrorType.INCORRECT_REQUEST, formattedSupplier("'{}' should be present.", parameterName));
// }
// } else {
// throw new ReportPortalException(ErrorType.INCORRECT_REQUEST, formattedSupplier("'{}' is not required."));
// }
// }
//
// public Optional<String> getParameter(Map<String, Object> parametersMap) {
// return ofNullable(parametersMap.get(parameterName)).map(String::valueOf).filter(StringUtils::isNotBlank);
// }
//
// public Optional<String> getParameter(UpdateAuthRQ request) {
// return ofNullable(request.getIntegrationParams()).flatMap(this::getParameter);
// }
//
// public void setParameter(UpdateAuthRQ request, Integration integration) {
// getParameter(request).ifPresent(it -> setParameter(integration, it));
// }
//
// }
| import com.epam.reportportal.auth.integration.parameter.LdapParameter;
import com.epam.ta.reportportal.entity.integration.Integration;
import com.epam.ta.reportportal.ws.model.integration.auth.ActiveDirectoryResource;
import java.util.function.Function; | /*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.integration.converter;
/**
* @author <a href="mailto:ivan_budayeu@epam.com">Ivan Budayeu</a>
*/
public final class ActiveDirectoryConverter {
private ActiveDirectoryConverter() {
//static only
}
public static final Function<Integration, ActiveDirectoryResource> TO_RESOURCE = adIntegration -> {
ActiveDirectoryResource resource = new ActiveDirectoryResource();
resource.setId(adIntegration.getId()); | // Path: src/main/java/com/epam/reportportal/auth/integration/parameter/LdapParameter.java
// public enum LdapParameter {
// NAME("name", false, false),
// URL("url", true, false),
// BASE_DN("baseDn", true, false),
// EMAIL_ATTRIBUTE("email", true, true),
// FULL_NAME_ATTRIBUTE("fullName", false, true),
// PHOTO_ATTRIBUTE("photo", false, true),
// SEARCH_FILTER_REMOVE_NOT_PRESENT("searchFilter", false, false) {
// @Override
// public void setParameter(UpdateAuthRQ request, Integration integration) {
// getParameter(request).ifPresentOrElse(it -> setParameter(integration, it), () -> removeParameter(integration));
// }
// },
// USER_DN_PATTERN("userDnPattern", false, false),
// USER_SEARCH_FILTER("userSearchFilter", false, false),
// GROUP_SEARCH_BASE("groupSearchBase", false, false),
// GROUP_SEARCH_FILTER("groupSearchFilter", false, false),
// PASSWORD_ENCODER_TYPE("passwordEncoderType", false, false),
// PASSWORD_ATTRIBUTE("passwordAttribute", false, false),
// MANAGER_DN("managerDn", false, false),
// MANAGER_PASSWORD("managerPassword", false, false),
// DOMAIN("domain", false, false);
//
// private String parameterName;
//
// private boolean required;
//
// private boolean syncAttribute;
//
// LdapParameter(String parameterName, boolean required, boolean syncAttribute) {
// this.parameterName = parameterName;
// this.required = required;
// this.syncAttribute = syncAttribute;
// }
//
// public String getParameterName() {
// return parameterName;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public boolean isSyncAttribute() {
// return syncAttribute;
// }
//
// public Optional<String> getParameter(Integration integration) {
// return ofNullable(integration.getParams()).map(it -> it.getParams().get(parameterName)).map(String::valueOf);
// }
//
// public void setParameter(Integration integration, String value) {
// if (Objects.isNull(integration.getParams())) {
// integration.setParams(new IntegrationParams(new HashMap<>()));
// }
// if (Objects.isNull(integration.getParams().getParams())) {
// integration.getParams().setParams(new HashMap<>());
// }
// integration.getParams().getParams().put(parameterName, value);
// }
//
// public void removeParameter(Integration integration) {
// ofNullable(integration.getParams()).map(IntegrationParams::getParams).ifPresent(params -> params.remove(parameterName));
// }
//
// public boolean exists(Integration integration) {
// return getParameter(integration).isPresent();
// }
//
// public String getRequiredParameter(Integration integration) {
// Optional<String> property = getParameter(integration);
// if (required) {
// if (property.isPresent()) {
// return property.get();
// } else {
// throw new ReportPortalException(ErrorType.INCORRECT_REQUEST, formattedSupplier("'{}' should be present.", parameterName));
// }
// } else {
// throw new ReportPortalException(ErrorType.INCORRECT_REQUEST, formattedSupplier("'{}' is not required."));
// }
// }
//
// public Optional<String> getParameter(Map<String, Object> parametersMap) {
// return ofNullable(parametersMap.get(parameterName)).map(String::valueOf).filter(StringUtils::isNotBlank);
// }
//
// public Optional<String> getParameter(UpdateAuthRQ request) {
// return ofNullable(request.getIntegrationParams()).flatMap(this::getParameter);
// }
//
// public void setParameter(UpdateAuthRQ request, Integration integration) {
// getParameter(request).ifPresent(it -> setParameter(integration, it));
// }
//
// }
// Path: src/main/java/com/epam/reportportal/auth/integration/converter/ActiveDirectoryConverter.java
import com.epam.reportportal.auth.integration.parameter.LdapParameter;
import com.epam.ta.reportportal.entity.integration.Integration;
import com.epam.ta.reportportal.ws.model.integration.auth.ActiveDirectoryResource;
import java.util.function.Function;
/*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.integration.converter;
/**
* @author <a href="mailto:ivan_budayeu@epam.com">Ivan Budayeu</a>
*/
public final class ActiveDirectoryConverter {
private ActiveDirectoryConverter() {
//static only
}
public static final Function<Integration, ActiveDirectoryResource> TO_RESOURCE = adIntegration -> {
ActiveDirectoryResource resource = new ActiveDirectoryResource();
resource.setId(adIntegration.getId()); | LdapParameter.DOMAIN.getParameter(adIntegration).ifPresent(resource::setDomain); |
reportportal/service-authorization | src/main/java/com/epam/reportportal/auth/AuthSuccessHandler.java | // Path: src/main/java/com/epam/reportportal/auth/event/UiUserSignedInEvent.java
// public class UiUserSignedInEvent extends AuthenticationSuccessEvent {
//
// private static final long serialVersionUID = -6746135168882975399L;
//
// public UiUserSignedInEvent(Authentication authentication) {
// super(authentication);
// }
//
// }
| import com.epam.reportportal.auth.event.UiUserSignedInEvent;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.http.server.ServletServerHttpRequest;
import org.springframework.security.core.Authentication;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.util.UriComponentsBuilder;
import javax.inject.Provider;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URI; | /*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth;
/**
* Base class for handling of success authentication and redirection to UI page.
*
* @author Yevgeniy Svalukhin
*/
public abstract class AuthSuccessHandler extends SimpleUrlAuthenticationSuccessHandler {
protected Provider<TokenServicesFacade> tokenServicesFacade;
private ApplicationEventPublisher eventPublisher;
public AuthSuccessHandler(Provider<TokenServicesFacade> tokenServicesFacade, ApplicationEventPublisher eventPublisher) {
super("/");
this.tokenServicesFacade = tokenServicesFacade;
this.eventPublisher = eventPublisher;
}
@Override
protected void handle(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException {
OAuth2AccessToken token = getToken(authentication);
MultiValueMap<String, String> query = new LinkedMultiValueMap<>();
query.add("token", token.getValue());
query.add("token_type", token.getTokenType());
URI rqUrl = UriComponentsBuilder.fromHttpRequest(new ServletServerHttpRequest(request))
.replacePath("/ui/authSuccess")
.replaceQueryParams(query)
.build()
.toUri();
| // Path: src/main/java/com/epam/reportportal/auth/event/UiUserSignedInEvent.java
// public class UiUserSignedInEvent extends AuthenticationSuccessEvent {
//
// private static final long serialVersionUID = -6746135168882975399L;
//
// public UiUserSignedInEvent(Authentication authentication) {
// super(authentication);
// }
//
// }
// Path: src/main/java/com/epam/reportportal/auth/AuthSuccessHandler.java
import com.epam.reportportal.auth.event.UiUserSignedInEvent;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.http.server.ServletServerHttpRequest;
import org.springframework.security.core.Authentication;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.util.UriComponentsBuilder;
import javax.inject.Provider;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URI;
/*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth;
/**
* Base class for handling of success authentication and redirection to UI page.
*
* @author Yevgeniy Svalukhin
*/
public abstract class AuthSuccessHandler extends SimpleUrlAuthenticationSuccessHandler {
protected Provider<TokenServicesFacade> tokenServicesFacade;
private ApplicationEventPublisher eventPublisher;
public AuthSuccessHandler(Provider<TokenServicesFacade> tokenServicesFacade, ApplicationEventPublisher eventPublisher) {
super("/");
this.tokenServicesFacade = tokenServicesFacade;
this.eventPublisher = eventPublisher;
}
@Override
protected void handle(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException {
OAuth2AccessToken token = getToken(authentication);
MultiValueMap<String, String> query = new LinkedMultiValueMap<>();
query.add("token", token.getValue());
query.add("token_type", token.getTokenType());
URI rqUrl = UriComponentsBuilder.fromHttpRequest(new ServletServerHttpRequest(request))
.replacePath("/ui/authSuccess")
.replaceQueryParams(query)
.build()
.toUri();
| eventPublisher.publishEvent(new UiUserSignedInEvent(authentication)); |
reportportal/service-authorization | src/main/java/com/epam/reportportal/auth/EnableableAuthProvider.java | // Path: src/main/java/com/epam/reportportal/auth/event/UiUserSignedInEvent.java
// public class UiUserSignedInEvent extends AuthenticationSuccessEvent {
//
// private static final long serialVersionUID = -6746135168882975399L;
//
// public UiUserSignedInEvent(Authentication authentication) {
// super(authentication);
// }
//
// }
| import com.epam.reportportal.auth.event.UiUserSignedInEvent;
import com.epam.ta.reportportal.dao.IntegrationRepository;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.stereotype.Component; | /*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth;
/**
* Dynamic (enableable) auth provider
*
* @author Andrei Varabyeu
*/
@Component
public abstract class EnableableAuthProvider implements AuthenticationProvider {
protected final IntegrationRepository integrationRepository;
protected final ApplicationEventPublisher eventPublisher;
public EnableableAuthProvider(IntegrationRepository integrationRepository, ApplicationEventPublisher eventPublisher) {
this.integrationRepository = integrationRepository;
this.eventPublisher = eventPublisher;
}
protected abstract boolean isEnabled();
protected abstract AuthenticationProvider getDelegate();
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
if (isEnabled()) {
Authentication auth = getDelegate().authenticate(authentication); | // Path: src/main/java/com/epam/reportportal/auth/event/UiUserSignedInEvent.java
// public class UiUserSignedInEvent extends AuthenticationSuccessEvent {
//
// private static final long serialVersionUID = -6746135168882975399L;
//
// public UiUserSignedInEvent(Authentication authentication) {
// super(authentication);
// }
//
// }
// Path: src/main/java/com/epam/reportportal/auth/EnableableAuthProvider.java
import com.epam.reportportal.auth.event.UiUserSignedInEvent;
import com.epam.ta.reportportal.dao.IntegrationRepository;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.stereotype.Component;
/*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth;
/**
* Dynamic (enableable) auth provider
*
* @author Andrei Varabyeu
*/
@Component
public abstract class EnableableAuthProvider implements AuthenticationProvider {
protected final IntegrationRepository integrationRepository;
protected final ApplicationEventPublisher eventPublisher;
public EnableableAuthProvider(IntegrationRepository integrationRepository, ApplicationEventPublisher eventPublisher) {
this.integrationRepository = integrationRepository;
this.eventPublisher = eventPublisher;
}
protected abstract boolean isEnabled();
protected abstract AuthenticationProvider getDelegate();
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
if (isEnabled()) {
Authentication auth = getDelegate().authenticate(authentication); | eventPublisher.publishEvent(new UiUserSignedInEvent(auth)); |
reportportal/service-authorization | src/main/java/com/epam/reportportal/auth/integration/github/GithubEndpoint.java | // Path: src/main/java/com/epam/reportportal/auth/integration/github/ExternalOauth2TokenConverter.java
// static final String UPSTREAM_TOKEN = "upstream_token";
| import com.epam.ta.reportportal.commons.validation.BusinessRule;
import com.epam.ta.reportportal.ws.model.ErrorType;
import com.epam.ta.reportportal.ws.model.OperationCompletionRS;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.io.Serializable;
import java.util.Objects;
import static com.epam.reportportal.auth.integration.github.ExternalOauth2TokenConverter.UPSTREAM_TOKEN; | /*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.integration.github;
/**
* GitHUB synchronization endpoint
*
* @author <a href="mailto:andrei_varabyeu@epam.com">Andrei Varabyeu</a>
*/
@RestController
public class GithubEndpoint {
private final GitHubUserReplicator replicator;
@Autowired
public GithubEndpoint(GitHubUserReplicator replicator) {
this.replicator = replicator;
}
@ApiOperation(value = "Synchronizes logged-in GitHub user")
@RequestMapping(value = { "/sso/me/github/synchronize" }, method = RequestMethod.POST)
public OperationCompletionRS synchronize(OAuth2Authentication user) { | // Path: src/main/java/com/epam/reportportal/auth/integration/github/ExternalOauth2TokenConverter.java
// static final String UPSTREAM_TOKEN = "upstream_token";
// Path: src/main/java/com/epam/reportportal/auth/integration/github/GithubEndpoint.java
import com.epam.ta.reportportal.commons.validation.BusinessRule;
import com.epam.ta.reportportal.ws.model.ErrorType;
import com.epam.ta.reportportal.ws.model.OperationCompletionRS;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.io.Serializable;
import java.util.Objects;
import static com.epam.reportportal.auth.integration.github.ExternalOauth2TokenConverter.UPSTREAM_TOKEN;
/*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.integration.github;
/**
* GitHUB synchronization endpoint
*
* @author <a href="mailto:andrei_varabyeu@epam.com">Andrei Varabyeu</a>
*/
@RestController
public class GithubEndpoint {
private final GitHubUserReplicator replicator;
@Autowired
public GithubEndpoint(GitHubUserReplicator replicator) {
this.replicator = replicator;
}
@ApiOperation(value = "Synchronizes logged-in GitHub user")
@RequestMapping(value = { "/sso/me/github/synchronize" }, method = RequestMethod.POST)
public OperationCompletionRS synchronize(OAuth2Authentication user) { | Serializable upstreamToken = user.getOAuth2Request().getExtensions().get(UPSTREAM_TOKEN); |
reportportal/service-authorization | src/main/java/com/epam/reportportal/auth/endpoint/OAuthConfigurationEndpoint.java | // Path: src/main/java/com/epam/reportportal/auth/integration/handler/CreateAuthIntegrationHandler.java
// public interface CreateAuthIntegrationHandler {
//
// AbstractAuthResource createAuthIntegration(AuthIntegrationType type, UpdateAuthRQ request, ReportPortalUser user);
//
// AbstractAuthResource updateAuthIntegration(AuthIntegrationType type, Long integrationId, UpdateAuthRQ request, ReportPortalUser user);
//
// OAuthRegistrationResource createOrUpdateOauthSettings(String oauthProviderId, OAuthRegistrationResource clientRegistrationResource);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/DeleteAuthIntegrationHandler.java
// public interface DeleteAuthIntegrationHandler {
//
// OperationCompletionRS deleteAuthIntegrationById(Long integrationId);
//
// OperationCompletionRS deleteOauthSettingsById(String oauthProviderId);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/GetAuthIntegrationHandler.java
// public interface GetAuthIntegrationHandler {
//
// AbstractAuthResource getIntegrationByType(AuthIntegrationType integrationType);
//
// Map<String, OAuthRegistrationResource> getAllOauthIntegrations();
//
// OAuthRegistrationResource getOauthIntegrationById(String oauthProviderId);
// }
| import static org.springframework.web.bind.annotation.RequestMethod.*;
import com.epam.reportportal.auth.integration.handler.CreateAuthIntegrationHandler;
import com.epam.reportportal.auth.integration.handler.DeleteAuthIntegrationHandler;
import com.epam.reportportal.auth.integration.handler.GetAuthIntegrationHandler;
import com.epam.ta.reportportal.ws.model.OperationCompletionRS;
import com.epam.ta.reportportal.ws.model.settings.OAuthRegistrationResource;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.Map; | /*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.endpoint;
/**
* Endpoint for oauth configs
*
* @author <a href="mailto:andrei_varabyeu@epam.com">Andrei Varabyeu</a>
*/
@Controller
@RequestMapping("/settings/oauth")
public class OAuthConfigurationEndpoint {
| // Path: src/main/java/com/epam/reportportal/auth/integration/handler/CreateAuthIntegrationHandler.java
// public interface CreateAuthIntegrationHandler {
//
// AbstractAuthResource createAuthIntegration(AuthIntegrationType type, UpdateAuthRQ request, ReportPortalUser user);
//
// AbstractAuthResource updateAuthIntegration(AuthIntegrationType type, Long integrationId, UpdateAuthRQ request, ReportPortalUser user);
//
// OAuthRegistrationResource createOrUpdateOauthSettings(String oauthProviderId, OAuthRegistrationResource clientRegistrationResource);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/DeleteAuthIntegrationHandler.java
// public interface DeleteAuthIntegrationHandler {
//
// OperationCompletionRS deleteAuthIntegrationById(Long integrationId);
//
// OperationCompletionRS deleteOauthSettingsById(String oauthProviderId);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/GetAuthIntegrationHandler.java
// public interface GetAuthIntegrationHandler {
//
// AbstractAuthResource getIntegrationByType(AuthIntegrationType integrationType);
//
// Map<String, OAuthRegistrationResource> getAllOauthIntegrations();
//
// OAuthRegistrationResource getOauthIntegrationById(String oauthProviderId);
// }
// Path: src/main/java/com/epam/reportportal/auth/endpoint/OAuthConfigurationEndpoint.java
import static org.springframework.web.bind.annotation.RequestMethod.*;
import com.epam.reportportal.auth.integration.handler.CreateAuthIntegrationHandler;
import com.epam.reportportal.auth.integration.handler.DeleteAuthIntegrationHandler;
import com.epam.reportportal.auth.integration.handler.GetAuthIntegrationHandler;
import com.epam.ta.reportportal.ws.model.OperationCompletionRS;
import com.epam.ta.reportportal.ws.model.settings.OAuthRegistrationResource;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.endpoint;
/**
* Endpoint for oauth configs
*
* @author <a href="mailto:andrei_varabyeu@epam.com">Andrei Varabyeu</a>
*/
@Controller
@RequestMapping("/settings/oauth")
public class OAuthConfigurationEndpoint {
| private final CreateAuthIntegrationHandler createAuthIntegrationHandler; |
reportportal/service-authorization | src/main/java/com/epam/reportportal/auth/endpoint/OAuthConfigurationEndpoint.java | // Path: src/main/java/com/epam/reportportal/auth/integration/handler/CreateAuthIntegrationHandler.java
// public interface CreateAuthIntegrationHandler {
//
// AbstractAuthResource createAuthIntegration(AuthIntegrationType type, UpdateAuthRQ request, ReportPortalUser user);
//
// AbstractAuthResource updateAuthIntegration(AuthIntegrationType type, Long integrationId, UpdateAuthRQ request, ReportPortalUser user);
//
// OAuthRegistrationResource createOrUpdateOauthSettings(String oauthProviderId, OAuthRegistrationResource clientRegistrationResource);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/DeleteAuthIntegrationHandler.java
// public interface DeleteAuthIntegrationHandler {
//
// OperationCompletionRS deleteAuthIntegrationById(Long integrationId);
//
// OperationCompletionRS deleteOauthSettingsById(String oauthProviderId);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/GetAuthIntegrationHandler.java
// public interface GetAuthIntegrationHandler {
//
// AbstractAuthResource getIntegrationByType(AuthIntegrationType integrationType);
//
// Map<String, OAuthRegistrationResource> getAllOauthIntegrations();
//
// OAuthRegistrationResource getOauthIntegrationById(String oauthProviderId);
// }
| import static org.springframework.web.bind.annotation.RequestMethod.*;
import com.epam.reportportal.auth.integration.handler.CreateAuthIntegrationHandler;
import com.epam.reportportal.auth.integration.handler.DeleteAuthIntegrationHandler;
import com.epam.reportportal.auth.integration.handler.GetAuthIntegrationHandler;
import com.epam.ta.reportportal.ws.model.OperationCompletionRS;
import com.epam.ta.reportportal.ws.model.settings.OAuthRegistrationResource;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.Map; | /*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.endpoint;
/**
* Endpoint for oauth configs
*
* @author <a href="mailto:andrei_varabyeu@epam.com">Andrei Varabyeu</a>
*/
@Controller
@RequestMapping("/settings/oauth")
public class OAuthConfigurationEndpoint {
private final CreateAuthIntegrationHandler createAuthIntegrationHandler;
| // Path: src/main/java/com/epam/reportportal/auth/integration/handler/CreateAuthIntegrationHandler.java
// public interface CreateAuthIntegrationHandler {
//
// AbstractAuthResource createAuthIntegration(AuthIntegrationType type, UpdateAuthRQ request, ReportPortalUser user);
//
// AbstractAuthResource updateAuthIntegration(AuthIntegrationType type, Long integrationId, UpdateAuthRQ request, ReportPortalUser user);
//
// OAuthRegistrationResource createOrUpdateOauthSettings(String oauthProviderId, OAuthRegistrationResource clientRegistrationResource);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/DeleteAuthIntegrationHandler.java
// public interface DeleteAuthIntegrationHandler {
//
// OperationCompletionRS deleteAuthIntegrationById(Long integrationId);
//
// OperationCompletionRS deleteOauthSettingsById(String oauthProviderId);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/GetAuthIntegrationHandler.java
// public interface GetAuthIntegrationHandler {
//
// AbstractAuthResource getIntegrationByType(AuthIntegrationType integrationType);
//
// Map<String, OAuthRegistrationResource> getAllOauthIntegrations();
//
// OAuthRegistrationResource getOauthIntegrationById(String oauthProviderId);
// }
// Path: src/main/java/com/epam/reportportal/auth/endpoint/OAuthConfigurationEndpoint.java
import static org.springframework.web.bind.annotation.RequestMethod.*;
import com.epam.reportportal.auth.integration.handler.CreateAuthIntegrationHandler;
import com.epam.reportportal.auth.integration.handler.DeleteAuthIntegrationHandler;
import com.epam.reportportal.auth.integration.handler.GetAuthIntegrationHandler;
import com.epam.ta.reportportal.ws.model.OperationCompletionRS;
import com.epam.ta.reportportal.ws.model.settings.OAuthRegistrationResource;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.endpoint;
/**
* Endpoint for oauth configs
*
* @author <a href="mailto:andrei_varabyeu@epam.com">Andrei Varabyeu</a>
*/
@Controller
@RequestMapping("/settings/oauth")
public class OAuthConfigurationEndpoint {
private final CreateAuthIntegrationHandler createAuthIntegrationHandler;
| private final DeleteAuthIntegrationHandler deleteAuthIntegrationHandler; |
reportportal/service-authorization | src/main/java/com/epam/reportportal/auth/endpoint/OAuthConfigurationEndpoint.java | // Path: src/main/java/com/epam/reportportal/auth/integration/handler/CreateAuthIntegrationHandler.java
// public interface CreateAuthIntegrationHandler {
//
// AbstractAuthResource createAuthIntegration(AuthIntegrationType type, UpdateAuthRQ request, ReportPortalUser user);
//
// AbstractAuthResource updateAuthIntegration(AuthIntegrationType type, Long integrationId, UpdateAuthRQ request, ReportPortalUser user);
//
// OAuthRegistrationResource createOrUpdateOauthSettings(String oauthProviderId, OAuthRegistrationResource clientRegistrationResource);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/DeleteAuthIntegrationHandler.java
// public interface DeleteAuthIntegrationHandler {
//
// OperationCompletionRS deleteAuthIntegrationById(Long integrationId);
//
// OperationCompletionRS deleteOauthSettingsById(String oauthProviderId);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/GetAuthIntegrationHandler.java
// public interface GetAuthIntegrationHandler {
//
// AbstractAuthResource getIntegrationByType(AuthIntegrationType integrationType);
//
// Map<String, OAuthRegistrationResource> getAllOauthIntegrations();
//
// OAuthRegistrationResource getOauthIntegrationById(String oauthProviderId);
// }
| import static org.springframework.web.bind.annotation.RequestMethod.*;
import com.epam.reportportal.auth.integration.handler.CreateAuthIntegrationHandler;
import com.epam.reportportal.auth.integration.handler.DeleteAuthIntegrationHandler;
import com.epam.reportportal.auth.integration.handler.GetAuthIntegrationHandler;
import com.epam.ta.reportportal.ws.model.OperationCompletionRS;
import com.epam.ta.reportportal.ws.model.settings.OAuthRegistrationResource;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.Map; | /*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.endpoint;
/**
* Endpoint for oauth configs
*
* @author <a href="mailto:andrei_varabyeu@epam.com">Andrei Varabyeu</a>
*/
@Controller
@RequestMapping("/settings/oauth")
public class OAuthConfigurationEndpoint {
private final CreateAuthIntegrationHandler createAuthIntegrationHandler;
private final DeleteAuthIntegrationHandler deleteAuthIntegrationHandler;
| // Path: src/main/java/com/epam/reportportal/auth/integration/handler/CreateAuthIntegrationHandler.java
// public interface CreateAuthIntegrationHandler {
//
// AbstractAuthResource createAuthIntegration(AuthIntegrationType type, UpdateAuthRQ request, ReportPortalUser user);
//
// AbstractAuthResource updateAuthIntegration(AuthIntegrationType type, Long integrationId, UpdateAuthRQ request, ReportPortalUser user);
//
// OAuthRegistrationResource createOrUpdateOauthSettings(String oauthProviderId, OAuthRegistrationResource clientRegistrationResource);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/DeleteAuthIntegrationHandler.java
// public interface DeleteAuthIntegrationHandler {
//
// OperationCompletionRS deleteAuthIntegrationById(Long integrationId);
//
// OperationCompletionRS deleteOauthSettingsById(String oauthProviderId);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/GetAuthIntegrationHandler.java
// public interface GetAuthIntegrationHandler {
//
// AbstractAuthResource getIntegrationByType(AuthIntegrationType integrationType);
//
// Map<String, OAuthRegistrationResource> getAllOauthIntegrations();
//
// OAuthRegistrationResource getOauthIntegrationById(String oauthProviderId);
// }
// Path: src/main/java/com/epam/reportportal/auth/endpoint/OAuthConfigurationEndpoint.java
import static org.springframework.web.bind.annotation.RequestMethod.*;
import com.epam.reportportal.auth.integration.handler.CreateAuthIntegrationHandler;
import com.epam.reportportal.auth.integration.handler.DeleteAuthIntegrationHandler;
import com.epam.reportportal.auth.integration.handler.GetAuthIntegrationHandler;
import com.epam.ta.reportportal.ws.model.OperationCompletionRS;
import com.epam.ta.reportportal.ws.model.settings.OAuthRegistrationResource;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.endpoint;
/**
* Endpoint for oauth configs
*
* @author <a href="mailto:andrei_varabyeu@epam.com">Andrei Varabyeu</a>
*/
@Controller
@RequestMapping("/settings/oauth")
public class OAuthConfigurationEndpoint {
private final CreateAuthIntegrationHandler createAuthIntegrationHandler;
private final DeleteAuthIntegrationHandler deleteAuthIntegrationHandler;
| private final GetAuthIntegrationHandler getAuthIntegrationHandler; |
reportportal/service-authorization | src/main/java/com/epam/reportportal/auth/oauth/OAuthProviderFactory.java | // Path: src/main/java/com/epam/reportportal/auth/integration/converter/OAuthRegistrationConverters.java
// public static final BiFunction<OAuthRegistrationResource, ClientRegistration, OAuthRegistration> FROM_SPRING_MERGE = (registrationResource, clientResource) -> {
// OAuthRegistration registration = new OAuthRegistration();
// registration.setId(clientResource.getRegistrationId());
// registration.setClientId(registrationResource.getClientId());
// registration.setClientSecret(registrationResource.getClientSecret());
// registration.setClientAuthMethod(ofNullable(registrationResource.getClientAuthMethod()).orElseGet(() -> clientResource.getClientAuthenticationMethod()
// .getValue()));
// registration.setClientName(ofNullable(registrationResource.getClientName()).orElseGet(clientResource::getClientName));
// registration.setAuthGrantType(ofNullable(registrationResource.getAuthGrantType()).orElseGet(() -> clientResource.getAuthorizationGrantType()
// .getValue()));
// registration.setRedirectUrlTemplate(ofNullable(registrationResource.getRedirectUrlTemplate()).orElseGet(clientResource::getRedirectUriTemplate));
// registration.setScopes(ofNullable(registrationResource.getScopes()).map(scopes -> scopes.stream()
// .map(SCOPE_FROM_RESOURCE)
// .peek(registrationScope -> registrationScope.setRegistration(registration))
// .collect(Collectors.toSet()))
// .orElse(clientResource.getScopes()
// .stream()
// .map(SCOPE_FROM_RESOURCE)
// .peek(registrationScope -> registrationScope.setRegistration(registration))
// .collect(Collectors.toSet())));
//
// List<OAuthRegistrationRestriction> registrationRestrictions = OAuthRestrictionConverter.FROM_RESOURCE.apply(registrationResource);
// registration.setRestrictions(registrationRestrictions.stream()
// .peek(restriction -> restriction.setRegistration(registration))
// .collect(Collectors.toSet()));
//
// ClientRegistration.ProviderDetails details = clientResource.getProviderDetails();
// registration.setAuthorizationUri(ofNullable(registrationResource.getAuthorizationUri()).orElseGet(details::getAuthorizationUri));
// registration.setTokenUri(ofNullable(registrationResource.getTokenUri()).orElseGet(details::getTokenUri));
// registration.setUserInfoEndpointUri(ofNullable(registrationResource.getUserInfoEndpointUri()).orElseGet(() -> details.getUserInfoEndpoint()
// .getUri()));
// registration.setUserInfoEndpointNameAttribute(ofNullable(registrationResource.getUserInfoEndpointNameAttribute()).orElseGet(() -> details
// .getUserInfoEndpoint()
// .getUserNameAttributeName()));
// registration.setJwkSetUri(ofNullable(registrationResource.getJwkSetUri()).orElseGet(details::getJwkSetUri));
//
// return registration;
// };
| import com.epam.ta.reportportal.entity.oauth.OAuthRegistration;
import com.epam.ta.reportportal.exception.ReportPortalException;
import com.epam.ta.reportportal.ws.model.ErrorType;
import com.epam.ta.reportportal.ws.model.settings.OAuthRegistrationResource;
import org.springframework.security.config.oauth2.client.CommonOAuth2Provider;
import org.springframework.security.oauth2.client.registration.ClientRegistration;
import static com.epam.reportportal.auth.integration.converter.OAuthRegistrationConverters.FROM_SPRING_MERGE; | /*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.oauth;
public class OAuthProviderFactory {
public static OAuthRegistration fillOAuthRegistration(String oauthProviderId, OAuthRegistrationResource registrationResource) {
switch (oauthProviderId) {
case "github":
ClientRegistration springRegistration = createGitHubProvider(oauthProviderId, registrationResource); | // Path: src/main/java/com/epam/reportportal/auth/integration/converter/OAuthRegistrationConverters.java
// public static final BiFunction<OAuthRegistrationResource, ClientRegistration, OAuthRegistration> FROM_SPRING_MERGE = (registrationResource, clientResource) -> {
// OAuthRegistration registration = new OAuthRegistration();
// registration.setId(clientResource.getRegistrationId());
// registration.setClientId(registrationResource.getClientId());
// registration.setClientSecret(registrationResource.getClientSecret());
// registration.setClientAuthMethod(ofNullable(registrationResource.getClientAuthMethod()).orElseGet(() -> clientResource.getClientAuthenticationMethod()
// .getValue()));
// registration.setClientName(ofNullable(registrationResource.getClientName()).orElseGet(clientResource::getClientName));
// registration.setAuthGrantType(ofNullable(registrationResource.getAuthGrantType()).orElseGet(() -> clientResource.getAuthorizationGrantType()
// .getValue()));
// registration.setRedirectUrlTemplate(ofNullable(registrationResource.getRedirectUrlTemplate()).orElseGet(clientResource::getRedirectUriTemplate));
// registration.setScopes(ofNullable(registrationResource.getScopes()).map(scopes -> scopes.stream()
// .map(SCOPE_FROM_RESOURCE)
// .peek(registrationScope -> registrationScope.setRegistration(registration))
// .collect(Collectors.toSet()))
// .orElse(clientResource.getScopes()
// .stream()
// .map(SCOPE_FROM_RESOURCE)
// .peek(registrationScope -> registrationScope.setRegistration(registration))
// .collect(Collectors.toSet())));
//
// List<OAuthRegistrationRestriction> registrationRestrictions = OAuthRestrictionConverter.FROM_RESOURCE.apply(registrationResource);
// registration.setRestrictions(registrationRestrictions.stream()
// .peek(restriction -> restriction.setRegistration(registration))
// .collect(Collectors.toSet()));
//
// ClientRegistration.ProviderDetails details = clientResource.getProviderDetails();
// registration.setAuthorizationUri(ofNullable(registrationResource.getAuthorizationUri()).orElseGet(details::getAuthorizationUri));
// registration.setTokenUri(ofNullable(registrationResource.getTokenUri()).orElseGet(details::getTokenUri));
// registration.setUserInfoEndpointUri(ofNullable(registrationResource.getUserInfoEndpointUri()).orElseGet(() -> details.getUserInfoEndpoint()
// .getUri()));
// registration.setUserInfoEndpointNameAttribute(ofNullable(registrationResource.getUserInfoEndpointNameAttribute()).orElseGet(() -> details
// .getUserInfoEndpoint()
// .getUserNameAttributeName()));
// registration.setJwkSetUri(ofNullable(registrationResource.getJwkSetUri()).orElseGet(details::getJwkSetUri));
//
// return registration;
// };
// Path: src/main/java/com/epam/reportportal/auth/oauth/OAuthProviderFactory.java
import com.epam.ta.reportportal.entity.oauth.OAuthRegistration;
import com.epam.ta.reportportal.exception.ReportPortalException;
import com.epam.ta.reportportal.ws.model.ErrorType;
import com.epam.ta.reportportal.ws.model.settings.OAuthRegistrationResource;
import org.springframework.security.config.oauth2.client.CommonOAuth2Provider;
import org.springframework.security.oauth2.client.registration.ClientRegistration;
import static com.epam.reportportal.auth.integration.converter.OAuthRegistrationConverters.FROM_SPRING_MERGE;
/*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.oauth;
public class OAuthProviderFactory {
public static OAuthRegistration fillOAuthRegistration(String oauthProviderId, OAuthRegistrationResource registrationResource) {
switch (oauthProviderId) {
case "github":
ClientRegistration springRegistration = createGitHubProvider(oauthProviderId, registrationResource); | return FROM_SPRING_MERGE.apply(registrationResource, springRegistration); |
reportportal/service-authorization | src/main/java/com/epam/reportportal/auth/endpoint/SsoEndpoint.java | // Path: src/main/java/com/epam/reportportal/auth/ReportPortalClient.java
// public enum ReportPortalClient {
// ui,
// api,
// internal
// }
//
// Path: src/main/java/com/epam/reportportal/auth/TokenServicesFacade.java
// @Service
// public class TokenServicesFacade {
//
// private final DefaultTokenServices databaseTokenServices;
// private final DefaultTokenServices jwtTokenServices;
// private final OAuth2RequestFactory oAuth2RequestFactory;
// private final ClientDetailsService clientDetailsService;
// private final OAuth2AccessTokenRepository tokenRepository;
//
// @Autowired
// public TokenServicesFacade(@Qualifier(value = "databaseTokenServices") DefaultTokenServices databaseTokenServices,
// DefaultTokenServices jwtTokenServices, ClientDetailsService clientDetailsService, OAuth2AccessTokenRepository tokenRepository) {
// this.databaseTokenServices = databaseTokenServices;
// this.jwtTokenServices = jwtTokenServices;
// this.clientDetailsService = clientDetailsService;
// this.oAuth2RequestFactory = new DefaultOAuth2RequestFactory(clientDetailsService);
// this.tokenRepository = tokenRepository;
// }
//
// public Stream<OAuth2AccessToken> getTokens(String username, ReportPortalClient client) {
// return tokenRepository.findByClientIdAndUserName(client.name(), username)
// .map(token -> SerializationUtils.deserialize(token.getToken()));
// }
//
// public OAuth2AccessToken createToken(ReportPortalClient client, String username, Authentication userAuthentication,
// Map<String, Serializable> extensionParams) {
// if (client == ReportPortalClient.api) {
// return createApiToken(client, username, userAuthentication, extensionParams);
// } else {
// return createNonApiToken(client, username, userAuthentication, extensionParams);
// }
//
// }
//
// public OAuth2AccessToken createApiToken(ReportPortalClient client, String username, Authentication userAuthentication,
// Map<String, Serializable> extensionParams) {
// OAuth2Request oAuth2Request = createOAuth2Request(client, username, extensionParams);
// return databaseTokenServices.createAccessToken(new OAuth2Authentication(oAuth2Request, userAuthentication));
// }
//
// public OAuth2AccessToken createNonApiToken(ReportPortalClient client, String username, Authentication userAuthentication,
// Map<String, Serializable> extensionParams) {
// OAuth2Request oAuth2Request = createOAuth2Request(client, username, extensionParams);
// return jwtTokenServices.createAccessToken(new OAuth2Authentication(oAuth2Request, userAuthentication));
// }
//
// public OAuth2AccessToken getAccessToken(Authentication userAuthentication) {
// return databaseTokenServices.getAccessToken((OAuth2Authentication) userAuthentication);
// }
//
// public void revokeUserTokens(String user, ReportPortalClient client) {
// this.tokenRepository.findByClientIdAndUserName(client.name(), user)
// .forEach(token -> databaseTokenServices.revokeToken(token.getTokenId()));
// }
//
// private OAuth2Request createOAuth2Request(ReportPortalClient client, String username, Map<String, Serializable> extensionParams) {
// //@formatter:off
// ClientDetails clientDetails = clientDetailsService.loadClientByClientId(client.name());
// OAuth2Request oAuth2Request = oAuth2RequestFactory.createOAuth2Request(clientDetails, oAuth2RequestFactory.createTokenRequest(
// ImmutableMap.<String, String>builder()
// .put("client_id", client.name())
// .put("username", username)
// .put("grant", "password")
// .build(), clientDetails));
// oAuth2Request.getExtensions().putAll(extensionParams);
// //@formatter:on
// return oAuth2Request;
// }
// }
| import com.epam.reportportal.auth.ReportPortalClient;
import com.epam.reportportal.auth.TokenServicesFacade;
import com.epam.ta.reportportal.commons.ReportPortalUser;
import com.epam.ta.reportportal.commons.validation.BusinessRule;
import com.epam.ta.reportportal.ws.model.ErrorType;
import com.google.common.collect.ImmutableMap;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.security.Principal;
import java.util.Collections;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST; | /*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.endpoint;
/**
* Base SSO controller
*
* @author <a href="mailto:andrei_varabyeu@epam.com">Andrei Varabyeu</a>
*/
@RestController
@Transactional
public class SsoEndpoint {
| // Path: src/main/java/com/epam/reportportal/auth/ReportPortalClient.java
// public enum ReportPortalClient {
// ui,
// api,
// internal
// }
//
// Path: src/main/java/com/epam/reportportal/auth/TokenServicesFacade.java
// @Service
// public class TokenServicesFacade {
//
// private final DefaultTokenServices databaseTokenServices;
// private final DefaultTokenServices jwtTokenServices;
// private final OAuth2RequestFactory oAuth2RequestFactory;
// private final ClientDetailsService clientDetailsService;
// private final OAuth2AccessTokenRepository tokenRepository;
//
// @Autowired
// public TokenServicesFacade(@Qualifier(value = "databaseTokenServices") DefaultTokenServices databaseTokenServices,
// DefaultTokenServices jwtTokenServices, ClientDetailsService clientDetailsService, OAuth2AccessTokenRepository tokenRepository) {
// this.databaseTokenServices = databaseTokenServices;
// this.jwtTokenServices = jwtTokenServices;
// this.clientDetailsService = clientDetailsService;
// this.oAuth2RequestFactory = new DefaultOAuth2RequestFactory(clientDetailsService);
// this.tokenRepository = tokenRepository;
// }
//
// public Stream<OAuth2AccessToken> getTokens(String username, ReportPortalClient client) {
// return tokenRepository.findByClientIdAndUserName(client.name(), username)
// .map(token -> SerializationUtils.deserialize(token.getToken()));
// }
//
// public OAuth2AccessToken createToken(ReportPortalClient client, String username, Authentication userAuthentication,
// Map<String, Serializable> extensionParams) {
// if (client == ReportPortalClient.api) {
// return createApiToken(client, username, userAuthentication, extensionParams);
// } else {
// return createNonApiToken(client, username, userAuthentication, extensionParams);
// }
//
// }
//
// public OAuth2AccessToken createApiToken(ReportPortalClient client, String username, Authentication userAuthentication,
// Map<String, Serializable> extensionParams) {
// OAuth2Request oAuth2Request = createOAuth2Request(client, username, extensionParams);
// return databaseTokenServices.createAccessToken(new OAuth2Authentication(oAuth2Request, userAuthentication));
// }
//
// public OAuth2AccessToken createNonApiToken(ReportPortalClient client, String username, Authentication userAuthentication,
// Map<String, Serializable> extensionParams) {
// OAuth2Request oAuth2Request = createOAuth2Request(client, username, extensionParams);
// return jwtTokenServices.createAccessToken(new OAuth2Authentication(oAuth2Request, userAuthentication));
// }
//
// public OAuth2AccessToken getAccessToken(Authentication userAuthentication) {
// return databaseTokenServices.getAccessToken((OAuth2Authentication) userAuthentication);
// }
//
// public void revokeUserTokens(String user, ReportPortalClient client) {
// this.tokenRepository.findByClientIdAndUserName(client.name(), user)
// .forEach(token -> databaseTokenServices.revokeToken(token.getTokenId()));
// }
//
// private OAuth2Request createOAuth2Request(ReportPortalClient client, String username, Map<String, Serializable> extensionParams) {
// //@formatter:off
// ClientDetails clientDetails = clientDetailsService.loadClientByClientId(client.name());
// OAuth2Request oAuth2Request = oAuth2RequestFactory.createOAuth2Request(clientDetails, oAuth2RequestFactory.createTokenRequest(
// ImmutableMap.<String, String>builder()
// .put("client_id", client.name())
// .put("username", username)
// .put("grant", "password")
// .build(), clientDetails));
// oAuth2Request.getExtensions().putAll(extensionParams);
// //@formatter:on
// return oAuth2Request;
// }
// }
// Path: src/main/java/com/epam/reportportal/auth/endpoint/SsoEndpoint.java
import com.epam.reportportal.auth.ReportPortalClient;
import com.epam.reportportal.auth.TokenServicesFacade;
import com.epam.ta.reportportal.commons.ReportPortalUser;
import com.epam.ta.reportportal.commons.validation.BusinessRule;
import com.epam.ta.reportportal.ws.model.ErrorType;
import com.google.common.collect.ImmutableMap;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.security.Principal;
import java.util.Collections;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
/*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.endpoint;
/**
* Base SSO controller
*
* @author <a href="mailto:andrei_varabyeu@epam.com">Andrei Varabyeu</a>
*/
@RestController
@Transactional
public class SsoEndpoint {
| private final TokenServicesFacade tokenServicesFacade; |
reportportal/service-authorization | src/main/java/com/epam/reportportal/auth/integration/validator/request/param/provider/SamlRequiredParamNamesProvider.java | // Path: src/main/java/com/epam/reportportal/auth/integration/parameter/SamlParameter.java
// public enum SamlParameter {
//
// BASE_PATH("callbackUrl", false),
// IDP_NAME("identityProviderName", true),
// IDP_METADATA_URL("identityProviderMetadataUrl", true),
// EMAIL_ATTRIBUTE("emailAttribute", true),
// IDP_NAME_ID("identityProviderNameId", false),
// IDP_ALIAS("identityProviderAlias", false),
// IDP_URL("identityProviderUrl", false),
// FULL_NAME_ATTRIBUTE("fullNameAttribute", false),
// FIRST_NAME_ATTRIBUTE("firstNameAttribute", false),
// LAST_NAME_ATTRIBUTE("lastNameAttribute", false);
//
// private String parameterName;
//
// private boolean required;
//
// SamlParameter(String parameterName, boolean required) {
// this.parameterName = parameterName;
// this.required = required;
// }
//
// public String getParameterName() {
// return parameterName;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public Optional<String> getParameter(Integration integration) {
// return ofNullable((String) integration.getParams().getParams().get(parameterName));
// }
//
// public void setParameter(Integration integration, String value) {
// if (Objects.isNull(integration.getParams())) {
// integration.setParams(new IntegrationParams(new HashMap<>()));
// }
// if (Objects.isNull(integration.getParams().getParams())) {
// integration.getParams().setParams(new HashMap<>());
// }
// integration.getParams().getParams().put(parameterName, value);
// }
//
// public void removeParameter(Integration integration) {
// ofNullable(integration.getParams()).map(IntegrationParams::getParams).ifPresent(params -> params.remove(parameterName));
// }
//
// public String getRequiredParameter(Integration integration) {
// Optional<String> parameter = getParameter(integration);
// if (required) {
// if (parameter.isPresent()) {
// return parameter.get();
// } else {
// throw new ReportPortalException(ErrorType.INCORRECT_REQUEST, formattedSupplier("'{}' should be present.", parameterName));
// }
// } else {
// throw new ReportPortalException(ErrorType.INCORRECT_REQUEST, formattedSupplier("'{}' is not required."));
// }
// }
//
// public boolean exist(Integration integration) {
// return getParameter(integration).isPresent();
// }
//
// public Optional<String> getParameter(Map<String, Object> parameterMap) {
// return ofNullable(parameterMap.get(parameterName)).map(it -> (String) it).filter(StringUtils::isNotBlank);
// }
//
// public Optional<String> getParameter(UpdateAuthRQ request) {
// return ofNullable(request.getIntegrationParams()).flatMap(this::getParameter);
// }
//
// public String getRequiredParameter(UpdateAuthRQ request) {
// Optional<String> parameter = getParameter(request);
// if (required) {
// if (parameter.isPresent()) {
// return parameter.get();
// } else {
// throw new ReportPortalException(ErrorType.INCORRECT_REQUEST, formattedSupplier("'{}' should be present.", parameterName));
// }
// } else {
// throw new ReportPortalException(ErrorType.INCORRECT_REQUEST, formattedSupplier("'{}' is not required."));
// }
// }
//
// public void setParameter(UpdateAuthRQ request, Integration integration) {
// getParameter(request).ifPresent(it -> setParameter(integration, it));
// }
//
// }
| import com.epam.reportportal.auth.integration.parameter.SamlParameter;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors; | package com.epam.reportportal.auth.integration.validator.request.param.provider;
@Service
public class SamlRequiredParamNamesProvider implements ParamNamesProvider {
@Override
public List<String> provide() { | // Path: src/main/java/com/epam/reportportal/auth/integration/parameter/SamlParameter.java
// public enum SamlParameter {
//
// BASE_PATH("callbackUrl", false),
// IDP_NAME("identityProviderName", true),
// IDP_METADATA_URL("identityProviderMetadataUrl", true),
// EMAIL_ATTRIBUTE("emailAttribute", true),
// IDP_NAME_ID("identityProviderNameId", false),
// IDP_ALIAS("identityProviderAlias", false),
// IDP_URL("identityProviderUrl", false),
// FULL_NAME_ATTRIBUTE("fullNameAttribute", false),
// FIRST_NAME_ATTRIBUTE("firstNameAttribute", false),
// LAST_NAME_ATTRIBUTE("lastNameAttribute", false);
//
// private String parameterName;
//
// private boolean required;
//
// SamlParameter(String parameterName, boolean required) {
// this.parameterName = parameterName;
// this.required = required;
// }
//
// public String getParameterName() {
// return parameterName;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public Optional<String> getParameter(Integration integration) {
// return ofNullable((String) integration.getParams().getParams().get(parameterName));
// }
//
// public void setParameter(Integration integration, String value) {
// if (Objects.isNull(integration.getParams())) {
// integration.setParams(new IntegrationParams(new HashMap<>()));
// }
// if (Objects.isNull(integration.getParams().getParams())) {
// integration.getParams().setParams(new HashMap<>());
// }
// integration.getParams().getParams().put(parameterName, value);
// }
//
// public void removeParameter(Integration integration) {
// ofNullable(integration.getParams()).map(IntegrationParams::getParams).ifPresent(params -> params.remove(parameterName));
// }
//
// public String getRequiredParameter(Integration integration) {
// Optional<String> parameter = getParameter(integration);
// if (required) {
// if (parameter.isPresent()) {
// return parameter.get();
// } else {
// throw new ReportPortalException(ErrorType.INCORRECT_REQUEST, formattedSupplier("'{}' should be present.", parameterName));
// }
// } else {
// throw new ReportPortalException(ErrorType.INCORRECT_REQUEST, formattedSupplier("'{}' is not required."));
// }
// }
//
// public boolean exist(Integration integration) {
// return getParameter(integration).isPresent();
// }
//
// public Optional<String> getParameter(Map<String, Object> parameterMap) {
// return ofNullable(parameterMap.get(parameterName)).map(it -> (String) it).filter(StringUtils::isNotBlank);
// }
//
// public Optional<String> getParameter(UpdateAuthRQ request) {
// return ofNullable(request.getIntegrationParams()).flatMap(this::getParameter);
// }
//
// public String getRequiredParameter(UpdateAuthRQ request) {
// Optional<String> parameter = getParameter(request);
// if (required) {
// if (parameter.isPresent()) {
// return parameter.get();
// } else {
// throw new ReportPortalException(ErrorType.INCORRECT_REQUEST, formattedSupplier("'{}' should be present.", parameterName));
// }
// } else {
// throw new ReportPortalException(ErrorType.INCORRECT_REQUEST, formattedSupplier("'{}' is not required."));
// }
// }
//
// public void setParameter(UpdateAuthRQ request, Integration integration) {
// getParameter(request).ifPresent(it -> setParameter(integration, it));
// }
//
// }
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/param/provider/SamlRequiredParamNamesProvider.java
import com.epam.reportportal.auth.integration.parameter.SamlParameter;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
package com.epam.reportportal.auth.integration.validator.request.param.provider;
@Service
public class SamlRequiredParamNamesProvider implements ParamNamesProvider {
@Override
public List<String> provide() { | return Arrays.stream(SamlParameter.values()) |
reportportal/service-authorization | src/main/java/com/epam/reportportal/auth/integration/handler/impl/GetActiveDirectoryStrategy.java | // Path: src/main/java/com/epam/reportportal/auth/integration/AuthIntegrationType.java
// public enum AuthIntegrationType {
//
// ACTIVE_DIRECTORY("ad") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, ActiveDirectoryResource> getToResourceMapper() {
// return ActiveDirectoryConverter.TO_RESOURCE;
// }
// },
// LDAP("ldap") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, LdapResource> getToResourceMapper() {
// return LdapConverter.TO_RESOURCE;
// }
// },
// SAML("saml") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, SamlResource> getToResourceMapper() {
// return SamlConverter.TO_RESOURCE;
// }
// };
//
// private String name;
//
// AuthIntegrationType(String name) {
// this.name = name;
// }
//
// public abstract Optional<Integration> get(Integration entity);
//
// public abstract Function<Integration, ? extends AbstractAuthResource> getToResourceMapper();
//
// public String getName() {
// return name;
// }
//
// public static Optional<AuthIntegrationType> fromId(String id) {
// return Arrays.stream(values()).filter(it -> it.name.equalsIgnoreCase(id)).findAny();
// }
//
// @Override
// public String toString() {
// return this.name;
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/converter/ActiveDirectoryConverter.java
// public final class ActiveDirectoryConverter {
//
// private ActiveDirectoryConverter() {
// //static only
// }
//
// public static final Function<Integration, ActiveDirectoryResource> TO_RESOURCE = adIntegration -> {
// ActiveDirectoryResource resource = new ActiveDirectoryResource();
// resource.setId(adIntegration.getId());
// LdapParameter.DOMAIN.getParameter(adIntegration).ifPresent(resource::setDomain);
// LdapParameter.SEARCH_FILTER_REMOVE_NOT_PRESENT.getParameter(adIntegration).ifPresent(resource::setSearchFilter);
// resource.setLdapAttributes(LdapConverter.LDAP_ATTRIBUTES_TO_RESOURCE.apply(adIntegration));
// return resource;
// };
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/GetAuthIntegrationStrategy.java
// public interface GetAuthIntegrationStrategy {
//
// AbstractAuthResource getIntegration();
// }
| import com.epam.reportportal.auth.integration.AuthIntegrationType;
import com.epam.reportportal.auth.integration.converter.ActiveDirectoryConverter;
import com.epam.reportportal.auth.integration.handler.GetAuthIntegrationStrategy;
import com.epam.ta.reportportal.dao.IntegrationRepository;
import com.epam.ta.reportportal.dao.IntegrationTypeRepository;
import com.epam.ta.reportportal.entity.integration.Integration;
import com.epam.ta.reportportal.entity.integration.IntegrationType;
import com.epam.ta.reportportal.exception.ReportPortalException;
import com.epam.ta.reportportal.ws.model.ErrorType;
import com.epam.ta.reportportal.ws.model.integration.auth.ActiveDirectoryResource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; | /*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.integration.handler.impl;
/**
* @author <a href="mailto:ivan_budayeu@epam.com">Ivan Budayeu</a>
*/
@Service
public class GetActiveDirectoryStrategy implements GetAuthIntegrationStrategy {
private final IntegrationTypeRepository integrationTypeRepository;
private final IntegrationRepository integrationRepository;
@Autowired
public GetActiveDirectoryStrategy(IntegrationTypeRepository integrationTypeRepository, IntegrationRepository integrationRepository) {
this.integrationTypeRepository = integrationTypeRepository;
this.integrationRepository = integrationRepository;
}
@Override
public ActiveDirectoryResource getIntegration() { | // Path: src/main/java/com/epam/reportportal/auth/integration/AuthIntegrationType.java
// public enum AuthIntegrationType {
//
// ACTIVE_DIRECTORY("ad") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, ActiveDirectoryResource> getToResourceMapper() {
// return ActiveDirectoryConverter.TO_RESOURCE;
// }
// },
// LDAP("ldap") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, LdapResource> getToResourceMapper() {
// return LdapConverter.TO_RESOURCE;
// }
// },
// SAML("saml") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, SamlResource> getToResourceMapper() {
// return SamlConverter.TO_RESOURCE;
// }
// };
//
// private String name;
//
// AuthIntegrationType(String name) {
// this.name = name;
// }
//
// public abstract Optional<Integration> get(Integration entity);
//
// public abstract Function<Integration, ? extends AbstractAuthResource> getToResourceMapper();
//
// public String getName() {
// return name;
// }
//
// public static Optional<AuthIntegrationType> fromId(String id) {
// return Arrays.stream(values()).filter(it -> it.name.equalsIgnoreCase(id)).findAny();
// }
//
// @Override
// public String toString() {
// return this.name;
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/converter/ActiveDirectoryConverter.java
// public final class ActiveDirectoryConverter {
//
// private ActiveDirectoryConverter() {
// //static only
// }
//
// public static final Function<Integration, ActiveDirectoryResource> TO_RESOURCE = adIntegration -> {
// ActiveDirectoryResource resource = new ActiveDirectoryResource();
// resource.setId(adIntegration.getId());
// LdapParameter.DOMAIN.getParameter(adIntegration).ifPresent(resource::setDomain);
// LdapParameter.SEARCH_FILTER_REMOVE_NOT_PRESENT.getParameter(adIntegration).ifPresent(resource::setSearchFilter);
// resource.setLdapAttributes(LdapConverter.LDAP_ATTRIBUTES_TO_RESOURCE.apply(adIntegration));
// return resource;
// };
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/GetAuthIntegrationStrategy.java
// public interface GetAuthIntegrationStrategy {
//
// AbstractAuthResource getIntegration();
// }
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/impl/GetActiveDirectoryStrategy.java
import com.epam.reportportal.auth.integration.AuthIntegrationType;
import com.epam.reportportal.auth.integration.converter.ActiveDirectoryConverter;
import com.epam.reportportal.auth.integration.handler.GetAuthIntegrationStrategy;
import com.epam.ta.reportportal.dao.IntegrationRepository;
import com.epam.ta.reportportal.dao.IntegrationTypeRepository;
import com.epam.ta.reportportal.entity.integration.Integration;
import com.epam.ta.reportportal.entity.integration.IntegrationType;
import com.epam.ta.reportportal.exception.ReportPortalException;
import com.epam.ta.reportportal.ws.model.ErrorType;
import com.epam.ta.reportportal.ws.model.integration.auth.ActiveDirectoryResource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.integration.handler.impl;
/**
* @author <a href="mailto:ivan_budayeu@epam.com">Ivan Budayeu</a>
*/
@Service
public class GetActiveDirectoryStrategy implements GetAuthIntegrationStrategy {
private final IntegrationTypeRepository integrationTypeRepository;
private final IntegrationRepository integrationRepository;
@Autowired
public GetActiveDirectoryStrategy(IntegrationTypeRepository integrationTypeRepository, IntegrationRepository integrationRepository) {
this.integrationTypeRepository = integrationTypeRepository;
this.integrationRepository = integrationRepository;
}
@Override
public ActiveDirectoryResource getIntegration() { | IntegrationType adIntegrationType = integrationTypeRepository.findByName(AuthIntegrationType.ACTIVE_DIRECTORY.getName()) |
reportportal/service-authorization | src/main/java/com/epam/reportportal/auth/integration/handler/impl/GetActiveDirectoryStrategy.java | // Path: src/main/java/com/epam/reportportal/auth/integration/AuthIntegrationType.java
// public enum AuthIntegrationType {
//
// ACTIVE_DIRECTORY("ad") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, ActiveDirectoryResource> getToResourceMapper() {
// return ActiveDirectoryConverter.TO_RESOURCE;
// }
// },
// LDAP("ldap") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, LdapResource> getToResourceMapper() {
// return LdapConverter.TO_RESOURCE;
// }
// },
// SAML("saml") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, SamlResource> getToResourceMapper() {
// return SamlConverter.TO_RESOURCE;
// }
// };
//
// private String name;
//
// AuthIntegrationType(String name) {
// this.name = name;
// }
//
// public abstract Optional<Integration> get(Integration entity);
//
// public abstract Function<Integration, ? extends AbstractAuthResource> getToResourceMapper();
//
// public String getName() {
// return name;
// }
//
// public static Optional<AuthIntegrationType> fromId(String id) {
// return Arrays.stream(values()).filter(it -> it.name.equalsIgnoreCase(id)).findAny();
// }
//
// @Override
// public String toString() {
// return this.name;
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/converter/ActiveDirectoryConverter.java
// public final class ActiveDirectoryConverter {
//
// private ActiveDirectoryConverter() {
// //static only
// }
//
// public static final Function<Integration, ActiveDirectoryResource> TO_RESOURCE = adIntegration -> {
// ActiveDirectoryResource resource = new ActiveDirectoryResource();
// resource.setId(adIntegration.getId());
// LdapParameter.DOMAIN.getParameter(adIntegration).ifPresent(resource::setDomain);
// LdapParameter.SEARCH_FILTER_REMOVE_NOT_PRESENT.getParameter(adIntegration).ifPresent(resource::setSearchFilter);
// resource.setLdapAttributes(LdapConverter.LDAP_ATTRIBUTES_TO_RESOURCE.apply(adIntegration));
// return resource;
// };
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/GetAuthIntegrationStrategy.java
// public interface GetAuthIntegrationStrategy {
//
// AbstractAuthResource getIntegration();
// }
| import com.epam.reportportal.auth.integration.AuthIntegrationType;
import com.epam.reportportal.auth.integration.converter.ActiveDirectoryConverter;
import com.epam.reportportal.auth.integration.handler.GetAuthIntegrationStrategy;
import com.epam.ta.reportportal.dao.IntegrationRepository;
import com.epam.ta.reportportal.dao.IntegrationTypeRepository;
import com.epam.ta.reportportal.entity.integration.Integration;
import com.epam.ta.reportportal.entity.integration.IntegrationType;
import com.epam.ta.reportportal.exception.ReportPortalException;
import com.epam.ta.reportportal.ws.model.ErrorType;
import com.epam.ta.reportportal.ws.model.integration.auth.ActiveDirectoryResource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; | /*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.integration.handler.impl;
/**
* @author <a href="mailto:ivan_budayeu@epam.com">Ivan Budayeu</a>
*/
@Service
public class GetActiveDirectoryStrategy implements GetAuthIntegrationStrategy {
private final IntegrationTypeRepository integrationTypeRepository;
private final IntegrationRepository integrationRepository;
@Autowired
public GetActiveDirectoryStrategy(IntegrationTypeRepository integrationTypeRepository, IntegrationRepository integrationRepository) {
this.integrationTypeRepository = integrationTypeRepository;
this.integrationRepository = integrationRepository;
}
@Override
public ActiveDirectoryResource getIntegration() {
IntegrationType adIntegrationType = integrationTypeRepository.findByName(AuthIntegrationType.ACTIVE_DIRECTORY.getName())
.orElseThrow(() -> new ReportPortalException(ErrorType.AUTH_INTEGRATION_NOT_FOUND,
AuthIntegrationType.ACTIVE_DIRECTORY.getName()
));
//or else empty integration with default 'enabled = false' flag | // Path: src/main/java/com/epam/reportportal/auth/integration/AuthIntegrationType.java
// public enum AuthIntegrationType {
//
// ACTIVE_DIRECTORY("ad") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, ActiveDirectoryResource> getToResourceMapper() {
// return ActiveDirectoryConverter.TO_RESOURCE;
// }
// },
// LDAP("ldap") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, LdapResource> getToResourceMapper() {
// return LdapConverter.TO_RESOURCE;
// }
// },
// SAML("saml") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, SamlResource> getToResourceMapper() {
// return SamlConverter.TO_RESOURCE;
// }
// };
//
// private String name;
//
// AuthIntegrationType(String name) {
// this.name = name;
// }
//
// public abstract Optional<Integration> get(Integration entity);
//
// public abstract Function<Integration, ? extends AbstractAuthResource> getToResourceMapper();
//
// public String getName() {
// return name;
// }
//
// public static Optional<AuthIntegrationType> fromId(String id) {
// return Arrays.stream(values()).filter(it -> it.name.equalsIgnoreCase(id)).findAny();
// }
//
// @Override
// public String toString() {
// return this.name;
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/converter/ActiveDirectoryConverter.java
// public final class ActiveDirectoryConverter {
//
// private ActiveDirectoryConverter() {
// //static only
// }
//
// public static final Function<Integration, ActiveDirectoryResource> TO_RESOURCE = adIntegration -> {
// ActiveDirectoryResource resource = new ActiveDirectoryResource();
// resource.setId(adIntegration.getId());
// LdapParameter.DOMAIN.getParameter(adIntegration).ifPresent(resource::setDomain);
// LdapParameter.SEARCH_FILTER_REMOVE_NOT_PRESENT.getParameter(adIntegration).ifPresent(resource::setSearchFilter);
// resource.setLdapAttributes(LdapConverter.LDAP_ATTRIBUTES_TO_RESOURCE.apply(adIntegration));
// return resource;
// };
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/GetAuthIntegrationStrategy.java
// public interface GetAuthIntegrationStrategy {
//
// AbstractAuthResource getIntegration();
// }
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/impl/GetActiveDirectoryStrategy.java
import com.epam.reportportal.auth.integration.AuthIntegrationType;
import com.epam.reportportal.auth.integration.converter.ActiveDirectoryConverter;
import com.epam.reportportal.auth.integration.handler.GetAuthIntegrationStrategy;
import com.epam.ta.reportportal.dao.IntegrationRepository;
import com.epam.ta.reportportal.dao.IntegrationTypeRepository;
import com.epam.ta.reportportal.entity.integration.Integration;
import com.epam.ta.reportportal.entity.integration.IntegrationType;
import com.epam.ta.reportportal.exception.ReportPortalException;
import com.epam.ta.reportportal.ws.model.ErrorType;
import com.epam.ta.reportportal.ws.model.integration.auth.ActiveDirectoryResource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.integration.handler.impl;
/**
* @author <a href="mailto:ivan_budayeu@epam.com">Ivan Budayeu</a>
*/
@Service
public class GetActiveDirectoryStrategy implements GetAuthIntegrationStrategy {
private final IntegrationTypeRepository integrationTypeRepository;
private final IntegrationRepository integrationRepository;
@Autowired
public GetActiveDirectoryStrategy(IntegrationTypeRepository integrationTypeRepository, IntegrationRepository integrationRepository) {
this.integrationTypeRepository = integrationTypeRepository;
this.integrationRepository = integrationRepository;
}
@Override
public ActiveDirectoryResource getIntegration() {
IntegrationType adIntegrationType = integrationTypeRepository.findByName(AuthIntegrationType.ACTIVE_DIRECTORY.getName())
.orElseThrow(() -> new ReportPortalException(ErrorType.AUTH_INTEGRATION_NOT_FOUND,
AuthIntegrationType.ACTIVE_DIRECTORY.getName()
));
//or else empty integration with default 'enabled = false' flag | ActiveDirectoryResource adResource = ActiveDirectoryConverter.TO_RESOURCE.apply(integrationRepository.findByNameAndTypeIdAndProjectIdIsNull( |
reportportal/service-authorization | src/main/java/com/epam/reportportal/auth/basic/BasicPasswordAuthenticationProvider.java | // Path: src/main/java/com/epam/reportportal/auth/event/UiAuthenticationFailureEventHandler.java
// @Component
// public class UiAuthenticationFailureEventHandler implements ApplicationListener<AuthenticationFailureBadCredentialsEvent> {
//
// private static final long MAXIMUM_SIZE = 5000;
// private static final long EXPIRATION_SECONDS = 30;
// private static final int MAX_ATTEMPTS = 3;
// private static final RequestHeaderRequestMatcher AJAX_REQUEST_MATCHER = new RequestHeaderRequestMatcher(HttpHeaders.X_REQUESTED_WITH,
// "XMLHttpRequest");
//
// @Inject
// private Provider<HttpServletRequest> request;
//
// private LoadingCache<String, AtomicInteger> failures;
//
// public UiAuthenticationFailureEventHandler() {
// super();
// failures = CacheBuilder.newBuilder().maximumSize(MAXIMUM_SIZE).expireAfterWrite(EXPIRATION_SECONDS, TimeUnit.SECONDS)
// .build(new CacheLoader<String, AtomicInteger>() {
// @Override
// public AtomicInteger load(String key) {
// return new AtomicInteger(0);
// }
// });
// }
//
// public boolean isBlocked(HttpServletRequest request) {
// AtomicInteger attempts = failures.getIfPresent(getClientIP(request));
// return null != attempts && attempts.get() > MAX_ATTEMPTS;
// }
//
// private void onAjaxFailure(HttpServletRequest request) {
// String clientIP = getClientIP(request);
// failures.getUnchecked(clientIP).incrementAndGet();
//
// }
//
// private String getClientIP(HttpServletRequest request) {
// String xfHeader = request.getHeader(HttpHeaders.X_FORWARDED_FOR);
// if (xfHeader == null) {
// return request.getRemoteAddr();
// }
// return xfHeader.split(",")[0];
// }
//
// @Override
// public void onApplicationEvent(AuthenticationFailureBadCredentialsEvent event) {
// onAjaxFailure(request.get());
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/event/UiUserSignedInEvent.java
// public class UiUserSignedInEvent extends AuthenticationSuccessEvent {
//
// private static final long serialVersionUID = -6746135168882975399L;
//
// public UiUserSignedInEvent(Authentication authentication) {
// super(authentication);
// }
//
// }
| import com.epam.reportportal.auth.event.UiAuthenticationFailureEventHandler;
import com.epam.reportportal.auth.event.UiUserSignedInEvent;
import com.epam.ta.reportportal.exception.ReportPortalException;
import com.epam.ta.reportportal.ws.model.ErrorType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import javax.inject.Provider;
import javax.servlet.http.HttpServletRequest; | /*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.basic;
/**
* Checks whether client have more auth errors than defined and throws exception if so
*
* @author <a href="mailto:andrei_varabyeu@epam.com">Andrei Varabyeu</a>
*/
public class BasicPasswordAuthenticationProvider extends DaoAuthenticationProvider {
@Autowired
private ApplicationEventPublisher eventPublisher;
@Autowired | // Path: src/main/java/com/epam/reportportal/auth/event/UiAuthenticationFailureEventHandler.java
// @Component
// public class UiAuthenticationFailureEventHandler implements ApplicationListener<AuthenticationFailureBadCredentialsEvent> {
//
// private static final long MAXIMUM_SIZE = 5000;
// private static final long EXPIRATION_SECONDS = 30;
// private static final int MAX_ATTEMPTS = 3;
// private static final RequestHeaderRequestMatcher AJAX_REQUEST_MATCHER = new RequestHeaderRequestMatcher(HttpHeaders.X_REQUESTED_WITH,
// "XMLHttpRequest");
//
// @Inject
// private Provider<HttpServletRequest> request;
//
// private LoadingCache<String, AtomicInteger> failures;
//
// public UiAuthenticationFailureEventHandler() {
// super();
// failures = CacheBuilder.newBuilder().maximumSize(MAXIMUM_SIZE).expireAfterWrite(EXPIRATION_SECONDS, TimeUnit.SECONDS)
// .build(new CacheLoader<String, AtomicInteger>() {
// @Override
// public AtomicInteger load(String key) {
// return new AtomicInteger(0);
// }
// });
// }
//
// public boolean isBlocked(HttpServletRequest request) {
// AtomicInteger attempts = failures.getIfPresent(getClientIP(request));
// return null != attempts && attempts.get() > MAX_ATTEMPTS;
// }
//
// private void onAjaxFailure(HttpServletRequest request) {
// String clientIP = getClientIP(request);
// failures.getUnchecked(clientIP).incrementAndGet();
//
// }
//
// private String getClientIP(HttpServletRequest request) {
// String xfHeader = request.getHeader(HttpHeaders.X_FORWARDED_FOR);
// if (xfHeader == null) {
// return request.getRemoteAddr();
// }
// return xfHeader.split(",")[0];
// }
//
// @Override
// public void onApplicationEvent(AuthenticationFailureBadCredentialsEvent event) {
// onAjaxFailure(request.get());
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/event/UiUserSignedInEvent.java
// public class UiUserSignedInEvent extends AuthenticationSuccessEvent {
//
// private static final long serialVersionUID = -6746135168882975399L;
//
// public UiUserSignedInEvent(Authentication authentication) {
// super(authentication);
// }
//
// }
// Path: src/main/java/com/epam/reportportal/auth/basic/BasicPasswordAuthenticationProvider.java
import com.epam.reportportal.auth.event.UiAuthenticationFailureEventHandler;
import com.epam.reportportal.auth.event.UiUserSignedInEvent;
import com.epam.ta.reportportal.exception.ReportPortalException;
import com.epam.ta.reportportal.ws.model.ErrorType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import javax.inject.Provider;
import javax.servlet.http.HttpServletRequest;
/*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.basic;
/**
* Checks whether client have more auth errors than defined and throws exception if so
*
* @author <a href="mailto:andrei_varabyeu@epam.com">Andrei Varabyeu</a>
*/
public class BasicPasswordAuthenticationProvider extends DaoAuthenticationProvider {
@Autowired
private ApplicationEventPublisher eventPublisher;
@Autowired | private UiAuthenticationFailureEventHandler failureEventHandler; |
reportportal/service-authorization | src/main/java/com/epam/reportportal/auth/basic/BasicPasswordAuthenticationProvider.java | // Path: src/main/java/com/epam/reportportal/auth/event/UiAuthenticationFailureEventHandler.java
// @Component
// public class UiAuthenticationFailureEventHandler implements ApplicationListener<AuthenticationFailureBadCredentialsEvent> {
//
// private static final long MAXIMUM_SIZE = 5000;
// private static final long EXPIRATION_SECONDS = 30;
// private static final int MAX_ATTEMPTS = 3;
// private static final RequestHeaderRequestMatcher AJAX_REQUEST_MATCHER = new RequestHeaderRequestMatcher(HttpHeaders.X_REQUESTED_WITH,
// "XMLHttpRequest");
//
// @Inject
// private Provider<HttpServletRequest> request;
//
// private LoadingCache<String, AtomicInteger> failures;
//
// public UiAuthenticationFailureEventHandler() {
// super();
// failures = CacheBuilder.newBuilder().maximumSize(MAXIMUM_SIZE).expireAfterWrite(EXPIRATION_SECONDS, TimeUnit.SECONDS)
// .build(new CacheLoader<String, AtomicInteger>() {
// @Override
// public AtomicInteger load(String key) {
// return new AtomicInteger(0);
// }
// });
// }
//
// public boolean isBlocked(HttpServletRequest request) {
// AtomicInteger attempts = failures.getIfPresent(getClientIP(request));
// return null != attempts && attempts.get() > MAX_ATTEMPTS;
// }
//
// private void onAjaxFailure(HttpServletRequest request) {
// String clientIP = getClientIP(request);
// failures.getUnchecked(clientIP).incrementAndGet();
//
// }
//
// private String getClientIP(HttpServletRequest request) {
// String xfHeader = request.getHeader(HttpHeaders.X_FORWARDED_FOR);
// if (xfHeader == null) {
// return request.getRemoteAddr();
// }
// return xfHeader.split(",")[0];
// }
//
// @Override
// public void onApplicationEvent(AuthenticationFailureBadCredentialsEvent event) {
// onAjaxFailure(request.get());
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/event/UiUserSignedInEvent.java
// public class UiUserSignedInEvent extends AuthenticationSuccessEvent {
//
// private static final long serialVersionUID = -6746135168882975399L;
//
// public UiUserSignedInEvent(Authentication authentication) {
// super(authentication);
// }
//
// }
| import com.epam.reportportal.auth.event.UiAuthenticationFailureEventHandler;
import com.epam.reportportal.auth.event.UiUserSignedInEvent;
import com.epam.ta.reportportal.exception.ReportPortalException;
import com.epam.ta.reportportal.ws.model.ErrorType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import javax.inject.Provider;
import javax.servlet.http.HttpServletRequest; | /*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.basic;
/**
* Checks whether client have more auth errors than defined and throws exception if so
*
* @author <a href="mailto:andrei_varabyeu@epam.com">Andrei Varabyeu</a>
*/
public class BasicPasswordAuthenticationProvider extends DaoAuthenticationProvider {
@Autowired
private ApplicationEventPublisher eventPublisher;
@Autowired
private UiAuthenticationFailureEventHandler failureEventHandler;
@Autowired
private Provider<HttpServletRequest> request;
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
boolean accountNonLocked = !failureEventHandler.isBlocked(request.get());
if (!accountNonLocked) {
throw new ReportPortalException(ErrorType.ADDRESS_LOCKED);
}
Authentication auth = super.authenticate(authentication); | // Path: src/main/java/com/epam/reportportal/auth/event/UiAuthenticationFailureEventHandler.java
// @Component
// public class UiAuthenticationFailureEventHandler implements ApplicationListener<AuthenticationFailureBadCredentialsEvent> {
//
// private static final long MAXIMUM_SIZE = 5000;
// private static final long EXPIRATION_SECONDS = 30;
// private static final int MAX_ATTEMPTS = 3;
// private static final RequestHeaderRequestMatcher AJAX_REQUEST_MATCHER = new RequestHeaderRequestMatcher(HttpHeaders.X_REQUESTED_WITH,
// "XMLHttpRequest");
//
// @Inject
// private Provider<HttpServletRequest> request;
//
// private LoadingCache<String, AtomicInteger> failures;
//
// public UiAuthenticationFailureEventHandler() {
// super();
// failures = CacheBuilder.newBuilder().maximumSize(MAXIMUM_SIZE).expireAfterWrite(EXPIRATION_SECONDS, TimeUnit.SECONDS)
// .build(new CacheLoader<String, AtomicInteger>() {
// @Override
// public AtomicInteger load(String key) {
// return new AtomicInteger(0);
// }
// });
// }
//
// public boolean isBlocked(HttpServletRequest request) {
// AtomicInteger attempts = failures.getIfPresent(getClientIP(request));
// return null != attempts && attempts.get() > MAX_ATTEMPTS;
// }
//
// private void onAjaxFailure(HttpServletRequest request) {
// String clientIP = getClientIP(request);
// failures.getUnchecked(clientIP).incrementAndGet();
//
// }
//
// private String getClientIP(HttpServletRequest request) {
// String xfHeader = request.getHeader(HttpHeaders.X_FORWARDED_FOR);
// if (xfHeader == null) {
// return request.getRemoteAddr();
// }
// return xfHeader.split(",")[0];
// }
//
// @Override
// public void onApplicationEvent(AuthenticationFailureBadCredentialsEvent event) {
// onAjaxFailure(request.get());
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/event/UiUserSignedInEvent.java
// public class UiUserSignedInEvent extends AuthenticationSuccessEvent {
//
// private static final long serialVersionUID = -6746135168882975399L;
//
// public UiUserSignedInEvent(Authentication authentication) {
// super(authentication);
// }
//
// }
// Path: src/main/java/com/epam/reportportal/auth/basic/BasicPasswordAuthenticationProvider.java
import com.epam.reportportal.auth.event.UiAuthenticationFailureEventHandler;
import com.epam.reportportal.auth.event.UiUserSignedInEvent;
import com.epam.ta.reportportal.exception.ReportPortalException;
import com.epam.ta.reportportal.ws.model.ErrorType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import javax.inject.Provider;
import javax.servlet.http.HttpServletRequest;
/*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.basic;
/**
* Checks whether client have more auth errors than defined and throws exception if so
*
* @author <a href="mailto:andrei_varabyeu@epam.com">Andrei Varabyeu</a>
*/
public class BasicPasswordAuthenticationProvider extends DaoAuthenticationProvider {
@Autowired
private ApplicationEventPublisher eventPublisher;
@Autowired
private UiAuthenticationFailureEventHandler failureEventHandler;
@Autowired
private Provider<HttpServletRequest> request;
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
boolean accountNonLocked = !failureEventHandler.isBlocked(request.get());
if (!accountNonLocked) {
throw new ReportPortalException(ErrorType.ADDRESS_LOCKED);
}
Authentication auth = super.authenticate(authentication); | eventPublisher.publishEvent(new UiUserSignedInEvent(auth)); |
reportportal/service-authorization | src/main/java/com/epam/reportportal/auth/integration/saml/ReportPortalSamlAuthenticationManager.java | // Path: src/main/java/com/epam/reportportal/auth/util/AuthUtils.java
// public final class AuthUtils {
//
// private AuthUtils() {
// //statics only
// }
//
// public static final Function<UserRole, List<GrantedAuthority>> AS_AUTHORITIES = userRole -> Collections.singletonList(new SimpleGrantedAuthority(
// userRole.getAuthority()));
//
// public static final Function<String, String> CROP_DOMAIN = it -> normalizeId(StringUtils.substringBefore(it, "@"));
//
// }
| import com.epam.reportportal.auth.util.AuthUtils;
import com.epam.ta.reportportal.entity.user.User;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.saml.spi.DefaultSamlAuthentication;
import org.springframework.stereotype.Component; | /*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.integration.saml;
/**
* Implementation of authentication manager for SAML integration
*
* @author Yevgeniy Svalukhin
*/
@Component
public class ReportPortalSamlAuthenticationManager implements AuthenticationManager {
private SamlUserReplicator samlUserReplicator;
public ReportPortalSamlAuthenticationManager(SamlUserReplicator samlUserReplicator) {
this.samlUserReplicator = samlUserReplicator;
}
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
if (authentication instanceof DefaultSamlAuthentication) {
ReportPortalSamlAuthentication reportPortalSamlAuthentication = new ReportPortalSamlAuthentication((DefaultSamlAuthentication) authentication);
if (reportPortalSamlAuthentication.isAuthenticated()) {
User user = samlUserReplicator.replicateUser(reportPortalSamlAuthentication);
| // Path: src/main/java/com/epam/reportportal/auth/util/AuthUtils.java
// public final class AuthUtils {
//
// private AuthUtils() {
// //statics only
// }
//
// public static final Function<UserRole, List<GrantedAuthority>> AS_AUTHORITIES = userRole -> Collections.singletonList(new SimpleGrantedAuthority(
// userRole.getAuthority()));
//
// public static final Function<String, String> CROP_DOMAIN = it -> normalizeId(StringUtils.substringBefore(it, "@"));
//
// }
// Path: src/main/java/com/epam/reportportal/auth/integration/saml/ReportPortalSamlAuthenticationManager.java
import com.epam.reportportal.auth.util.AuthUtils;
import com.epam.ta.reportportal.entity.user.User;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.saml.spi.DefaultSamlAuthentication;
import org.springframework.stereotype.Component;
/*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.integration.saml;
/**
* Implementation of authentication manager for SAML integration
*
* @author Yevgeniy Svalukhin
*/
@Component
public class ReportPortalSamlAuthenticationManager implements AuthenticationManager {
private SamlUserReplicator samlUserReplicator;
public ReportPortalSamlAuthenticationManager(SamlUserReplicator samlUserReplicator) {
this.samlUserReplicator = samlUserReplicator;
}
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
if (authentication instanceof DefaultSamlAuthentication) {
ReportPortalSamlAuthentication reportPortalSamlAuthentication = new ReportPortalSamlAuthentication((DefaultSamlAuthentication) authentication);
if (reportPortalSamlAuthentication.isAuthenticated()) {
User user = samlUserReplicator.replicateUser(reportPortalSamlAuthentication);
| reportPortalSamlAuthentication.setAuthorities(AuthUtils.AS_AUTHORITIES.apply(user.getRole())); |
reportportal/service-authorization | src/main/java/com/epam/reportportal/auth/endpoint/AuthConfigurationEndpoint.java | // Path: src/main/java/com/epam/reportportal/auth/integration/AuthIntegrationType.java
// public enum AuthIntegrationType {
//
// ACTIVE_DIRECTORY("ad") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, ActiveDirectoryResource> getToResourceMapper() {
// return ActiveDirectoryConverter.TO_RESOURCE;
// }
// },
// LDAP("ldap") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, LdapResource> getToResourceMapper() {
// return LdapConverter.TO_RESOURCE;
// }
// },
// SAML("saml") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, SamlResource> getToResourceMapper() {
// return SamlConverter.TO_RESOURCE;
// }
// };
//
// private String name;
//
// AuthIntegrationType(String name) {
// this.name = name;
// }
//
// public abstract Optional<Integration> get(Integration entity);
//
// public abstract Function<Integration, ? extends AbstractAuthResource> getToResourceMapper();
//
// public String getName() {
// return name;
// }
//
// public static Optional<AuthIntegrationType> fromId(String id) {
// return Arrays.stream(values()).filter(it -> it.name.equalsIgnoreCase(id)).findAny();
// }
//
// @Override
// public String toString() {
// return this.name;
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/CreateAuthIntegrationHandler.java
// public interface CreateAuthIntegrationHandler {
//
// AbstractAuthResource createAuthIntegration(AuthIntegrationType type, UpdateAuthRQ request, ReportPortalUser user);
//
// AbstractAuthResource updateAuthIntegration(AuthIntegrationType type, Long integrationId, UpdateAuthRQ request, ReportPortalUser user);
//
// OAuthRegistrationResource createOrUpdateOauthSettings(String oauthProviderId, OAuthRegistrationResource clientRegistrationResource);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/DeleteAuthIntegrationHandler.java
// public interface DeleteAuthIntegrationHandler {
//
// OperationCompletionRS deleteAuthIntegrationById(Long integrationId);
//
// OperationCompletionRS deleteOauthSettingsById(String oauthProviderId);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/GetAuthIntegrationHandler.java
// public interface GetAuthIntegrationHandler {
//
// AbstractAuthResource getIntegrationByType(AuthIntegrationType integrationType);
//
// Map<String, OAuthRegistrationResource> getAllOauthIntegrations();
//
// OAuthRegistrationResource getOauthIntegrationById(String oauthProviderId);
// }
| import com.epam.reportportal.auth.integration.AuthIntegrationType;
import com.epam.reportportal.auth.integration.handler.CreateAuthIntegrationHandler;
import com.epam.reportportal.auth.integration.handler.DeleteAuthIntegrationHandler;
import com.epam.reportportal.auth.integration.handler.GetAuthIntegrationHandler;
import com.epam.ta.reportportal.commons.ReportPortalUser;
import com.epam.ta.reportportal.exception.ReportPortalException;
import com.epam.ta.reportportal.ws.model.ErrorType;
import com.epam.ta.reportportal.ws.model.OperationCompletionRS;
import com.epam.ta.reportportal.ws.model.integration.auth.AbstractAuthResource;
import com.epam.ta.reportportal.ws.model.integration.auth.UpdateAuthRQ;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.beans.PropertyEditorSupport; | /*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.endpoint;
@RestController
@RequestMapping("/settings/auth")
public class AuthConfigurationEndpoint {
| // Path: src/main/java/com/epam/reportportal/auth/integration/AuthIntegrationType.java
// public enum AuthIntegrationType {
//
// ACTIVE_DIRECTORY("ad") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, ActiveDirectoryResource> getToResourceMapper() {
// return ActiveDirectoryConverter.TO_RESOURCE;
// }
// },
// LDAP("ldap") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, LdapResource> getToResourceMapper() {
// return LdapConverter.TO_RESOURCE;
// }
// },
// SAML("saml") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, SamlResource> getToResourceMapper() {
// return SamlConverter.TO_RESOURCE;
// }
// };
//
// private String name;
//
// AuthIntegrationType(String name) {
// this.name = name;
// }
//
// public abstract Optional<Integration> get(Integration entity);
//
// public abstract Function<Integration, ? extends AbstractAuthResource> getToResourceMapper();
//
// public String getName() {
// return name;
// }
//
// public static Optional<AuthIntegrationType> fromId(String id) {
// return Arrays.stream(values()).filter(it -> it.name.equalsIgnoreCase(id)).findAny();
// }
//
// @Override
// public String toString() {
// return this.name;
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/CreateAuthIntegrationHandler.java
// public interface CreateAuthIntegrationHandler {
//
// AbstractAuthResource createAuthIntegration(AuthIntegrationType type, UpdateAuthRQ request, ReportPortalUser user);
//
// AbstractAuthResource updateAuthIntegration(AuthIntegrationType type, Long integrationId, UpdateAuthRQ request, ReportPortalUser user);
//
// OAuthRegistrationResource createOrUpdateOauthSettings(String oauthProviderId, OAuthRegistrationResource clientRegistrationResource);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/DeleteAuthIntegrationHandler.java
// public interface DeleteAuthIntegrationHandler {
//
// OperationCompletionRS deleteAuthIntegrationById(Long integrationId);
//
// OperationCompletionRS deleteOauthSettingsById(String oauthProviderId);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/GetAuthIntegrationHandler.java
// public interface GetAuthIntegrationHandler {
//
// AbstractAuthResource getIntegrationByType(AuthIntegrationType integrationType);
//
// Map<String, OAuthRegistrationResource> getAllOauthIntegrations();
//
// OAuthRegistrationResource getOauthIntegrationById(String oauthProviderId);
// }
// Path: src/main/java/com/epam/reportportal/auth/endpoint/AuthConfigurationEndpoint.java
import com.epam.reportportal.auth.integration.AuthIntegrationType;
import com.epam.reportportal.auth.integration.handler.CreateAuthIntegrationHandler;
import com.epam.reportportal.auth.integration.handler.DeleteAuthIntegrationHandler;
import com.epam.reportportal.auth.integration.handler.GetAuthIntegrationHandler;
import com.epam.ta.reportportal.commons.ReportPortalUser;
import com.epam.ta.reportportal.exception.ReportPortalException;
import com.epam.ta.reportportal.ws.model.ErrorType;
import com.epam.ta.reportportal.ws.model.OperationCompletionRS;
import com.epam.ta.reportportal.ws.model.integration.auth.AbstractAuthResource;
import com.epam.ta.reportportal.ws.model.integration.auth.UpdateAuthRQ;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.beans.PropertyEditorSupport;
/*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.endpoint;
@RestController
@RequestMapping("/settings/auth")
public class AuthConfigurationEndpoint {
| private final CreateAuthIntegrationHandler createAuthIntegrationHandler; |
reportportal/service-authorization | src/main/java/com/epam/reportportal/auth/endpoint/AuthConfigurationEndpoint.java | // Path: src/main/java/com/epam/reportportal/auth/integration/AuthIntegrationType.java
// public enum AuthIntegrationType {
//
// ACTIVE_DIRECTORY("ad") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, ActiveDirectoryResource> getToResourceMapper() {
// return ActiveDirectoryConverter.TO_RESOURCE;
// }
// },
// LDAP("ldap") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, LdapResource> getToResourceMapper() {
// return LdapConverter.TO_RESOURCE;
// }
// },
// SAML("saml") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, SamlResource> getToResourceMapper() {
// return SamlConverter.TO_RESOURCE;
// }
// };
//
// private String name;
//
// AuthIntegrationType(String name) {
// this.name = name;
// }
//
// public abstract Optional<Integration> get(Integration entity);
//
// public abstract Function<Integration, ? extends AbstractAuthResource> getToResourceMapper();
//
// public String getName() {
// return name;
// }
//
// public static Optional<AuthIntegrationType> fromId(String id) {
// return Arrays.stream(values()).filter(it -> it.name.equalsIgnoreCase(id)).findAny();
// }
//
// @Override
// public String toString() {
// return this.name;
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/CreateAuthIntegrationHandler.java
// public interface CreateAuthIntegrationHandler {
//
// AbstractAuthResource createAuthIntegration(AuthIntegrationType type, UpdateAuthRQ request, ReportPortalUser user);
//
// AbstractAuthResource updateAuthIntegration(AuthIntegrationType type, Long integrationId, UpdateAuthRQ request, ReportPortalUser user);
//
// OAuthRegistrationResource createOrUpdateOauthSettings(String oauthProviderId, OAuthRegistrationResource clientRegistrationResource);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/DeleteAuthIntegrationHandler.java
// public interface DeleteAuthIntegrationHandler {
//
// OperationCompletionRS deleteAuthIntegrationById(Long integrationId);
//
// OperationCompletionRS deleteOauthSettingsById(String oauthProviderId);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/GetAuthIntegrationHandler.java
// public interface GetAuthIntegrationHandler {
//
// AbstractAuthResource getIntegrationByType(AuthIntegrationType integrationType);
//
// Map<String, OAuthRegistrationResource> getAllOauthIntegrations();
//
// OAuthRegistrationResource getOauthIntegrationById(String oauthProviderId);
// }
| import com.epam.reportportal.auth.integration.AuthIntegrationType;
import com.epam.reportportal.auth.integration.handler.CreateAuthIntegrationHandler;
import com.epam.reportportal.auth.integration.handler.DeleteAuthIntegrationHandler;
import com.epam.reportportal.auth.integration.handler.GetAuthIntegrationHandler;
import com.epam.ta.reportportal.commons.ReportPortalUser;
import com.epam.ta.reportportal.exception.ReportPortalException;
import com.epam.ta.reportportal.ws.model.ErrorType;
import com.epam.ta.reportportal.ws.model.OperationCompletionRS;
import com.epam.ta.reportportal.ws.model.integration.auth.AbstractAuthResource;
import com.epam.ta.reportportal.ws.model.integration.auth.UpdateAuthRQ;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.beans.PropertyEditorSupport; | /*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.endpoint;
@RestController
@RequestMapping("/settings/auth")
public class AuthConfigurationEndpoint {
private final CreateAuthIntegrationHandler createAuthIntegrationHandler;
| // Path: src/main/java/com/epam/reportportal/auth/integration/AuthIntegrationType.java
// public enum AuthIntegrationType {
//
// ACTIVE_DIRECTORY("ad") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, ActiveDirectoryResource> getToResourceMapper() {
// return ActiveDirectoryConverter.TO_RESOURCE;
// }
// },
// LDAP("ldap") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, LdapResource> getToResourceMapper() {
// return LdapConverter.TO_RESOURCE;
// }
// },
// SAML("saml") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, SamlResource> getToResourceMapper() {
// return SamlConverter.TO_RESOURCE;
// }
// };
//
// private String name;
//
// AuthIntegrationType(String name) {
// this.name = name;
// }
//
// public abstract Optional<Integration> get(Integration entity);
//
// public abstract Function<Integration, ? extends AbstractAuthResource> getToResourceMapper();
//
// public String getName() {
// return name;
// }
//
// public static Optional<AuthIntegrationType> fromId(String id) {
// return Arrays.stream(values()).filter(it -> it.name.equalsIgnoreCase(id)).findAny();
// }
//
// @Override
// public String toString() {
// return this.name;
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/CreateAuthIntegrationHandler.java
// public interface CreateAuthIntegrationHandler {
//
// AbstractAuthResource createAuthIntegration(AuthIntegrationType type, UpdateAuthRQ request, ReportPortalUser user);
//
// AbstractAuthResource updateAuthIntegration(AuthIntegrationType type, Long integrationId, UpdateAuthRQ request, ReportPortalUser user);
//
// OAuthRegistrationResource createOrUpdateOauthSettings(String oauthProviderId, OAuthRegistrationResource clientRegistrationResource);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/DeleteAuthIntegrationHandler.java
// public interface DeleteAuthIntegrationHandler {
//
// OperationCompletionRS deleteAuthIntegrationById(Long integrationId);
//
// OperationCompletionRS deleteOauthSettingsById(String oauthProviderId);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/GetAuthIntegrationHandler.java
// public interface GetAuthIntegrationHandler {
//
// AbstractAuthResource getIntegrationByType(AuthIntegrationType integrationType);
//
// Map<String, OAuthRegistrationResource> getAllOauthIntegrations();
//
// OAuthRegistrationResource getOauthIntegrationById(String oauthProviderId);
// }
// Path: src/main/java/com/epam/reportportal/auth/endpoint/AuthConfigurationEndpoint.java
import com.epam.reportportal.auth.integration.AuthIntegrationType;
import com.epam.reportportal.auth.integration.handler.CreateAuthIntegrationHandler;
import com.epam.reportportal.auth.integration.handler.DeleteAuthIntegrationHandler;
import com.epam.reportportal.auth.integration.handler.GetAuthIntegrationHandler;
import com.epam.ta.reportportal.commons.ReportPortalUser;
import com.epam.ta.reportportal.exception.ReportPortalException;
import com.epam.ta.reportportal.ws.model.ErrorType;
import com.epam.ta.reportportal.ws.model.OperationCompletionRS;
import com.epam.ta.reportportal.ws.model.integration.auth.AbstractAuthResource;
import com.epam.ta.reportportal.ws.model.integration.auth.UpdateAuthRQ;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.beans.PropertyEditorSupport;
/*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.endpoint;
@RestController
@RequestMapping("/settings/auth")
public class AuthConfigurationEndpoint {
private final CreateAuthIntegrationHandler createAuthIntegrationHandler;
| private final DeleteAuthIntegrationHandler deleteAuthIntegrationHandler; |
reportportal/service-authorization | src/main/java/com/epam/reportportal/auth/endpoint/AuthConfigurationEndpoint.java | // Path: src/main/java/com/epam/reportportal/auth/integration/AuthIntegrationType.java
// public enum AuthIntegrationType {
//
// ACTIVE_DIRECTORY("ad") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, ActiveDirectoryResource> getToResourceMapper() {
// return ActiveDirectoryConverter.TO_RESOURCE;
// }
// },
// LDAP("ldap") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, LdapResource> getToResourceMapper() {
// return LdapConverter.TO_RESOURCE;
// }
// },
// SAML("saml") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, SamlResource> getToResourceMapper() {
// return SamlConverter.TO_RESOURCE;
// }
// };
//
// private String name;
//
// AuthIntegrationType(String name) {
// this.name = name;
// }
//
// public abstract Optional<Integration> get(Integration entity);
//
// public abstract Function<Integration, ? extends AbstractAuthResource> getToResourceMapper();
//
// public String getName() {
// return name;
// }
//
// public static Optional<AuthIntegrationType> fromId(String id) {
// return Arrays.stream(values()).filter(it -> it.name.equalsIgnoreCase(id)).findAny();
// }
//
// @Override
// public String toString() {
// return this.name;
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/CreateAuthIntegrationHandler.java
// public interface CreateAuthIntegrationHandler {
//
// AbstractAuthResource createAuthIntegration(AuthIntegrationType type, UpdateAuthRQ request, ReportPortalUser user);
//
// AbstractAuthResource updateAuthIntegration(AuthIntegrationType type, Long integrationId, UpdateAuthRQ request, ReportPortalUser user);
//
// OAuthRegistrationResource createOrUpdateOauthSettings(String oauthProviderId, OAuthRegistrationResource clientRegistrationResource);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/DeleteAuthIntegrationHandler.java
// public interface DeleteAuthIntegrationHandler {
//
// OperationCompletionRS deleteAuthIntegrationById(Long integrationId);
//
// OperationCompletionRS deleteOauthSettingsById(String oauthProviderId);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/GetAuthIntegrationHandler.java
// public interface GetAuthIntegrationHandler {
//
// AbstractAuthResource getIntegrationByType(AuthIntegrationType integrationType);
//
// Map<String, OAuthRegistrationResource> getAllOauthIntegrations();
//
// OAuthRegistrationResource getOauthIntegrationById(String oauthProviderId);
// }
| import com.epam.reportportal.auth.integration.AuthIntegrationType;
import com.epam.reportportal.auth.integration.handler.CreateAuthIntegrationHandler;
import com.epam.reportportal.auth.integration.handler.DeleteAuthIntegrationHandler;
import com.epam.reportportal.auth.integration.handler.GetAuthIntegrationHandler;
import com.epam.ta.reportportal.commons.ReportPortalUser;
import com.epam.ta.reportportal.exception.ReportPortalException;
import com.epam.ta.reportportal.ws.model.ErrorType;
import com.epam.ta.reportportal.ws.model.OperationCompletionRS;
import com.epam.ta.reportportal.ws.model.integration.auth.AbstractAuthResource;
import com.epam.ta.reportportal.ws.model.integration.auth.UpdateAuthRQ;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.beans.PropertyEditorSupport; | /*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.endpoint;
@RestController
@RequestMapping("/settings/auth")
public class AuthConfigurationEndpoint {
private final CreateAuthIntegrationHandler createAuthIntegrationHandler;
private final DeleteAuthIntegrationHandler deleteAuthIntegrationHandler;
| // Path: src/main/java/com/epam/reportportal/auth/integration/AuthIntegrationType.java
// public enum AuthIntegrationType {
//
// ACTIVE_DIRECTORY("ad") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, ActiveDirectoryResource> getToResourceMapper() {
// return ActiveDirectoryConverter.TO_RESOURCE;
// }
// },
// LDAP("ldap") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, LdapResource> getToResourceMapper() {
// return LdapConverter.TO_RESOURCE;
// }
// },
// SAML("saml") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, SamlResource> getToResourceMapper() {
// return SamlConverter.TO_RESOURCE;
// }
// };
//
// private String name;
//
// AuthIntegrationType(String name) {
// this.name = name;
// }
//
// public abstract Optional<Integration> get(Integration entity);
//
// public abstract Function<Integration, ? extends AbstractAuthResource> getToResourceMapper();
//
// public String getName() {
// return name;
// }
//
// public static Optional<AuthIntegrationType> fromId(String id) {
// return Arrays.stream(values()).filter(it -> it.name.equalsIgnoreCase(id)).findAny();
// }
//
// @Override
// public String toString() {
// return this.name;
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/CreateAuthIntegrationHandler.java
// public interface CreateAuthIntegrationHandler {
//
// AbstractAuthResource createAuthIntegration(AuthIntegrationType type, UpdateAuthRQ request, ReportPortalUser user);
//
// AbstractAuthResource updateAuthIntegration(AuthIntegrationType type, Long integrationId, UpdateAuthRQ request, ReportPortalUser user);
//
// OAuthRegistrationResource createOrUpdateOauthSettings(String oauthProviderId, OAuthRegistrationResource clientRegistrationResource);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/DeleteAuthIntegrationHandler.java
// public interface DeleteAuthIntegrationHandler {
//
// OperationCompletionRS deleteAuthIntegrationById(Long integrationId);
//
// OperationCompletionRS deleteOauthSettingsById(String oauthProviderId);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/GetAuthIntegrationHandler.java
// public interface GetAuthIntegrationHandler {
//
// AbstractAuthResource getIntegrationByType(AuthIntegrationType integrationType);
//
// Map<String, OAuthRegistrationResource> getAllOauthIntegrations();
//
// OAuthRegistrationResource getOauthIntegrationById(String oauthProviderId);
// }
// Path: src/main/java/com/epam/reportportal/auth/endpoint/AuthConfigurationEndpoint.java
import com.epam.reportportal.auth.integration.AuthIntegrationType;
import com.epam.reportportal.auth.integration.handler.CreateAuthIntegrationHandler;
import com.epam.reportportal.auth.integration.handler.DeleteAuthIntegrationHandler;
import com.epam.reportportal.auth.integration.handler.GetAuthIntegrationHandler;
import com.epam.ta.reportportal.commons.ReportPortalUser;
import com.epam.ta.reportportal.exception.ReportPortalException;
import com.epam.ta.reportportal.ws.model.ErrorType;
import com.epam.ta.reportportal.ws.model.OperationCompletionRS;
import com.epam.ta.reportportal.ws.model.integration.auth.AbstractAuthResource;
import com.epam.ta.reportportal.ws.model.integration.auth.UpdateAuthRQ;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.beans.PropertyEditorSupport;
/*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.endpoint;
@RestController
@RequestMapping("/settings/auth")
public class AuthConfigurationEndpoint {
private final CreateAuthIntegrationHandler createAuthIntegrationHandler;
private final DeleteAuthIntegrationHandler deleteAuthIntegrationHandler;
| private final GetAuthIntegrationHandler getAuthIntegrationHandler; |
reportportal/service-authorization | src/main/java/com/epam/reportportal/auth/endpoint/AuthConfigurationEndpoint.java | // Path: src/main/java/com/epam/reportportal/auth/integration/AuthIntegrationType.java
// public enum AuthIntegrationType {
//
// ACTIVE_DIRECTORY("ad") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, ActiveDirectoryResource> getToResourceMapper() {
// return ActiveDirectoryConverter.TO_RESOURCE;
// }
// },
// LDAP("ldap") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, LdapResource> getToResourceMapper() {
// return LdapConverter.TO_RESOURCE;
// }
// },
// SAML("saml") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, SamlResource> getToResourceMapper() {
// return SamlConverter.TO_RESOURCE;
// }
// };
//
// private String name;
//
// AuthIntegrationType(String name) {
// this.name = name;
// }
//
// public abstract Optional<Integration> get(Integration entity);
//
// public abstract Function<Integration, ? extends AbstractAuthResource> getToResourceMapper();
//
// public String getName() {
// return name;
// }
//
// public static Optional<AuthIntegrationType> fromId(String id) {
// return Arrays.stream(values()).filter(it -> it.name.equalsIgnoreCase(id)).findAny();
// }
//
// @Override
// public String toString() {
// return this.name;
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/CreateAuthIntegrationHandler.java
// public interface CreateAuthIntegrationHandler {
//
// AbstractAuthResource createAuthIntegration(AuthIntegrationType type, UpdateAuthRQ request, ReportPortalUser user);
//
// AbstractAuthResource updateAuthIntegration(AuthIntegrationType type, Long integrationId, UpdateAuthRQ request, ReportPortalUser user);
//
// OAuthRegistrationResource createOrUpdateOauthSettings(String oauthProviderId, OAuthRegistrationResource clientRegistrationResource);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/DeleteAuthIntegrationHandler.java
// public interface DeleteAuthIntegrationHandler {
//
// OperationCompletionRS deleteAuthIntegrationById(Long integrationId);
//
// OperationCompletionRS deleteOauthSettingsById(String oauthProviderId);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/GetAuthIntegrationHandler.java
// public interface GetAuthIntegrationHandler {
//
// AbstractAuthResource getIntegrationByType(AuthIntegrationType integrationType);
//
// Map<String, OAuthRegistrationResource> getAllOauthIntegrations();
//
// OAuthRegistrationResource getOauthIntegrationById(String oauthProviderId);
// }
| import com.epam.reportportal.auth.integration.AuthIntegrationType;
import com.epam.reportportal.auth.integration.handler.CreateAuthIntegrationHandler;
import com.epam.reportportal.auth.integration.handler.DeleteAuthIntegrationHandler;
import com.epam.reportportal.auth.integration.handler.GetAuthIntegrationHandler;
import com.epam.ta.reportportal.commons.ReportPortalUser;
import com.epam.ta.reportportal.exception.ReportPortalException;
import com.epam.ta.reportportal.ws.model.ErrorType;
import com.epam.ta.reportportal.ws.model.OperationCompletionRS;
import com.epam.ta.reportportal.ws.model.integration.auth.AbstractAuthResource;
import com.epam.ta.reportportal.ws.model.integration.auth.UpdateAuthRQ;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.beans.PropertyEditorSupport; | /*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.endpoint;
@RestController
@RequestMapping("/settings/auth")
public class AuthConfigurationEndpoint {
private final CreateAuthIntegrationHandler createAuthIntegrationHandler;
private final DeleteAuthIntegrationHandler deleteAuthIntegrationHandler;
private final GetAuthIntegrationHandler getAuthIntegrationHandler;
@Autowired
public AuthConfigurationEndpoint(CreateAuthIntegrationHandler createAuthIntegrationHandler,
DeleteAuthIntegrationHandler deleteAuthIntegrationHandler, GetAuthIntegrationHandler getAuthIntegrationHandler) {
this.createAuthIntegrationHandler = createAuthIntegrationHandler;
this.deleteAuthIntegrationHandler = deleteAuthIntegrationHandler;
this.getAuthIntegrationHandler = getAuthIntegrationHandler;
}
/**
* Creates or updates auth integration settings
*
* @param request Update request
* @return Successful message or an error
*/
@Transactional
@PostMapping(value = "/{authType}")
@ResponseStatus(HttpStatus.OK)
@ApiOperation(value = "Create new auth integration")
public AbstractAuthResource createAuthIntegration(@RequestBody @Valid UpdateAuthRQ request, @AuthenticationPrincipal ReportPortalUser user, | // Path: src/main/java/com/epam/reportportal/auth/integration/AuthIntegrationType.java
// public enum AuthIntegrationType {
//
// ACTIVE_DIRECTORY("ad") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, ActiveDirectoryResource> getToResourceMapper() {
// return ActiveDirectoryConverter.TO_RESOURCE;
// }
// },
// LDAP("ldap") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, LdapResource> getToResourceMapper() {
// return LdapConverter.TO_RESOURCE;
// }
// },
// SAML("saml") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, SamlResource> getToResourceMapper() {
// return SamlConverter.TO_RESOURCE;
// }
// };
//
// private String name;
//
// AuthIntegrationType(String name) {
// this.name = name;
// }
//
// public abstract Optional<Integration> get(Integration entity);
//
// public abstract Function<Integration, ? extends AbstractAuthResource> getToResourceMapper();
//
// public String getName() {
// return name;
// }
//
// public static Optional<AuthIntegrationType> fromId(String id) {
// return Arrays.stream(values()).filter(it -> it.name.equalsIgnoreCase(id)).findAny();
// }
//
// @Override
// public String toString() {
// return this.name;
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/CreateAuthIntegrationHandler.java
// public interface CreateAuthIntegrationHandler {
//
// AbstractAuthResource createAuthIntegration(AuthIntegrationType type, UpdateAuthRQ request, ReportPortalUser user);
//
// AbstractAuthResource updateAuthIntegration(AuthIntegrationType type, Long integrationId, UpdateAuthRQ request, ReportPortalUser user);
//
// OAuthRegistrationResource createOrUpdateOauthSettings(String oauthProviderId, OAuthRegistrationResource clientRegistrationResource);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/DeleteAuthIntegrationHandler.java
// public interface DeleteAuthIntegrationHandler {
//
// OperationCompletionRS deleteAuthIntegrationById(Long integrationId);
//
// OperationCompletionRS deleteOauthSettingsById(String oauthProviderId);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/GetAuthIntegrationHandler.java
// public interface GetAuthIntegrationHandler {
//
// AbstractAuthResource getIntegrationByType(AuthIntegrationType integrationType);
//
// Map<String, OAuthRegistrationResource> getAllOauthIntegrations();
//
// OAuthRegistrationResource getOauthIntegrationById(String oauthProviderId);
// }
// Path: src/main/java/com/epam/reportportal/auth/endpoint/AuthConfigurationEndpoint.java
import com.epam.reportportal.auth.integration.AuthIntegrationType;
import com.epam.reportportal.auth.integration.handler.CreateAuthIntegrationHandler;
import com.epam.reportportal.auth.integration.handler.DeleteAuthIntegrationHandler;
import com.epam.reportportal.auth.integration.handler.GetAuthIntegrationHandler;
import com.epam.ta.reportportal.commons.ReportPortalUser;
import com.epam.ta.reportportal.exception.ReportPortalException;
import com.epam.ta.reportportal.ws.model.ErrorType;
import com.epam.ta.reportportal.ws.model.OperationCompletionRS;
import com.epam.ta.reportportal.ws.model.integration.auth.AbstractAuthResource;
import com.epam.ta.reportportal.ws.model.integration.auth.UpdateAuthRQ;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.beans.PropertyEditorSupport;
/*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.endpoint;
@RestController
@RequestMapping("/settings/auth")
public class AuthConfigurationEndpoint {
private final CreateAuthIntegrationHandler createAuthIntegrationHandler;
private final DeleteAuthIntegrationHandler deleteAuthIntegrationHandler;
private final GetAuthIntegrationHandler getAuthIntegrationHandler;
@Autowired
public AuthConfigurationEndpoint(CreateAuthIntegrationHandler createAuthIntegrationHandler,
DeleteAuthIntegrationHandler deleteAuthIntegrationHandler, GetAuthIntegrationHandler getAuthIntegrationHandler) {
this.createAuthIntegrationHandler = createAuthIntegrationHandler;
this.deleteAuthIntegrationHandler = deleteAuthIntegrationHandler;
this.getAuthIntegrationHandler = getAuthIntegrationHandler;
}
/**
* Creates or updates auth integration settings
*
* @param request Update request
* @return Successful message or an error
*/
@Transactional
@PostMapping(value = "/{authType}")
@ResponseStatus(HttpStatus.OK)
@ApiOperation(value = "Create new auth integration")
public AbstractAuthResource createAuthIntegration(@RequestBody @Valid UpdateAuthRQ request, @AuthenticationPrincipal ReportPortalUser user, | @PathVariable AuthIntegrationType authType) { |
reportportal/service-authorization | src/main/java/com/epam/reportportal/auth/basic/DatabaseUserDetailsService.java | // Path: src/main/java/com/epam/reportportal/auth/util/AuthUtils.java
// public final class AuthUtils {
//
// private AuthUtils() {
// //statics only
// }
//
// public static final Function<UserRole, List<GrantedAuthority>> AS_AUTHORITIES = userRole -> Collections.singletonList(new SimpleGrantedAuthority(
// userRole.getAuthority()));
//
// public static final Function<String, String> CROP_DOMAIN = it -> normalizeId(StringUtils.substringBefore(it, "@"));
//
// }
| import com.epam.reportportal.auth.util.AuthUtils;
import com.epam.ta.reportportal.commons.ReportPortalUser;
import com.epam.ta.reportportal.dao.UserRepository;
import com.epam.ta.reportportal.entity.user.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.transaction.annotation.Transactional;
import static com.epam.ta.reportportal.commons.EntityUtils.normalizeId; | /*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.basic;
/**
* Spring's {@link UserDetailsService} implementation. Uses {@link User} entity
* from ReportPortal database
*
* @author <a href="mailto:andrei_varabyeu@epam.com">Andrei Varabyeu</a>
*/
public class DatabaseUserDetailsService implements UserDetailsService {
private UserRepository userRepository;
@Autowired
public void setUserRepository(UserRepository userRepository) {
this.userRepository = userRepository;
}
@Override
@Transactional(readOnly = true)
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
ReportPortalUser user = userRepository.findUserDetails(normalizeId(username))
.orElseThrow(() -> new UsernameNotFoundException("User not found"));
UserDetails userDetails = org.springframework.security.core.userdetails.User.builder()
.username(user.getUsername())
.password(user.getPassword() == null ? "" : user.getPassword()) | // Path: src/main/java/com/epam/reportportal/auth/util/AuthUtils.java
// public final class AuthUtils {
//
// private AuthUtils() {
// //statics only
// }
//
// public static final Function<UserRole, List<GrantedAuthority>> AS_AUTHORITIES = userRole -> Collections.singletonList(new SimpleGrantedAuthority(
// userRole.getAuthority()));
//
// public static final Function<String, String> CROP_DOMAIN = it -> normalizeId(StringUtils.substringBefore(it, "@"));
//
// }
// Path: src/main/java/com/epam/reportportal/auth/basic/DatabaseUserDetailsService.java
import com.epam.reportportal.auth.util.AuthUtils;
import com.epam.ta.reportportal.commons.ReportPortalUser;
import com.epam.ta.reportportal.dao.UserRepository;
import com.epam.ta.reportportal.entity.user.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.transaction.annotation.Transactional;
import static com.epam.ta.reportportal.commons.EntityUtils.normalizeId;
/*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.basic;
/**
* Spring's {@link UserDetailsService} implementation. Uses {@link User} entity
* from ReportPortal database
*
* @author <a href="mailto:andrei_varabyeu@epam.com">Andrei Varabyeu</a>
*/
public class DatabaseUserDetailsService implements UserDetailsService {
private UserRepository userRepository;
@Autowired
public void setUserRepository(UserRepository userRepository) {
this.userRepository = userRepository;
}
@Override
@Transactional(readOnly = true)
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
ReportPortalUser user = userRepository.findUserDetails(normalizeId(username))
.orElseThrow(() -> new UsernameNotFoundException("User not found"));
UserDetails userDetails = org.springframework.security.core.userdetails.User.builder()
.username(user.getUsername())
.password(user.getPassword() == null ? "" : user.getPassword()) | .authorities(AuthUtils.AS_AUTHORITIES.apply(user.getUserRole())) |
reportportal/service-authorization | src/main/java/com/epam/reportportal/auth/event/SamlProvidersReloadEventHandler.java | // Path: src/main/java/com/epam/reportportal/auth/integration/converter/SamlConverter.java
// public class SamlConverter {
//
// public static final BiConsumer<UpdateAuthRQ, Integration> UPDATE_FROM_REQUEST = (request, integration) -> {
// integration.setEnabled(request.getEnabled());
// integration.setName(IDP_NAME.getRequiredParameter(request));
// ParameterUtils.setSamlParameters(request, integration);
// };
//
// public final static Function<Integration, SamlResource> TO_RESOURCE = integration -> {
// SamlResource resource = new SamlResource();
// resource.setId(integration.getId());
// resource.setIdentityProviderName(integration.getName());
// resource.setEnabled(integration.isEnabled());
//
// EMAIL_ATTRIBUTE.getParameter(integration).ifPresent(resource::setEmailAttribute);
// FIRST_NAME_ATTRIBUTE.getParameter(integration).ifPresent(resource::setFirstNameAttribute);
// LAST_NAME_ATTRIBUTE.getParameter(integration).ifPresent(resource::setLastNameAttribute);
// FULL_NAME_ATTRIBUTE.getParameter(integration).ifPresent(resource::setFullNameAttribute);
// IDP_ALIAS.getParameter(integration).ifPresent(resource::setIdentityProviderAlias);
// IDP_METADATA_URL.getParameter(integration).ifPresent(resource::setIdentityProviderMetadataUrl);
// IDP_URL.getParameter(integration).ifPresent(resource::setIdentityProviderUrl);
// IDP_NAME_ID.getParameter(integration).ifPresent(resource::setIdentityProviderNameId);
// final IntegrationType integrationType = integration.getType();
// ofNullable(integrationType.getDetails()).flatMap(typeDetails -> Optional.ofNullable(typeDetails.getDetails()))
// .flatMap(BASE_PATH::getParameter)
// .ifPresent(resource::setCallbackUrl);
// return resource;
// };
//
// public final static Function<List<Integration>, List<ExternalIdentityProviderConfiguration>> TO_EXTERNAL_PROVIDER_CONFIG = integrations -> {
// List<ExternalIdentityProviderConfiguration> externalProviders = integrations.stream()
// .map(integration -> new ExternalIdentityProviderConfiguration().setAlias(IDP_ALIAS.getParameter(integration).get())
// .setMetadata(IDP_METADATA_URL.getRequiredParameter(integration))
// .setLinktext(integration.getName())
// .setNameId(NameId.fromUrn(IDP_NAME_ID.getParameter(integration).get())))
// .collect(Collectors.toList());
// IntStream.range(0, externalProviders.size()).forEach(value -> externalProviders.get(value).setAssertionConsumerServiceIndex(value));
// return externalProviders;
// };
//
// public final static Function<List<Integration>, SamlProvidersResource> TO_PROVIDERS_RESOURCE = integrations -> {
// if (CollectionUtils.isEmpty(integrations)) {
// SamlProvidersResource emptyResource = new SamlProvidersResource();
// emptyResource.setProviders(Collections.emptyList());
// return emptyResource;
// }
// SamlProvidersResource resource = new SamlProvidersResource();
// resource.setProviders(integrations.stream().map(TO_RESOURCE).collect(Collectors.toList()));
// return resource;
// };
//
// }
| import com.epam.reportportal.auth.integration.converter.SamlConverter;
import com.epam.ta.reportportal.dao.IntegrationRepository;
import com.epam.ta.reportportal.entity.integration.Integration;
import com.epam.ta.reportportal.entity.integration.IntegrationType;
import org.springframework.context.ApplicationListener;
import org.springframework.security.saml.provider.SamlServerConfiguration;
import org.springframework.security.saml.provider.service.config.LocalServiceProviderConfiguration;
import org.springframework.stereotype.Component;
import java.util.List; | /*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.event;
/**
* Handles SAML settings changes event and reload configuration of IDP in service provider configuration
*
* @author Yevgeniy Svalukhin
*/
@Component
public class SamlProvidersReloadEventHandler implements ApplicationListener<SamlProvidersReloadEvent> {
private final IntegrationRepository integrationRepository;
private final SamlServerConfiguration samlConfiguration;
public SamlProvidersReloadEventHandler(IntegrationRepository integrationRepository, SamlServerConfiguration spConfiguration) {
this.integrationRepository = integrationRepository;
this.samlConfiguration = spConfiguration;
}
@Override
public void onApplicationEvent(SamlProvidersReloadEvent event) {
final IntegrationType integrationType = event.getIntegrationType();
final List<Integration> integrations = integrationRepository.findAllGlobalByType(integrationType);
LocalServiceProviderConfiguration serviceProvider = samlConfiguration.getServiceProvider();
serviceProvider.getProviders().clear(); | // Path: src/main/java/com/epam/reportportal/auth/integration/converter/SamlConverter.java
// public class SamlConverter {
//
// public static final BiConsumer<UpdateAuthRQ, Integration> UPDATE_FROM_REQUEST = (request, integration) -> {
// integration.setEnabled(request.getEnabled());
// integration.setName(IDP_NAME.getRequiredParameter(request));
// ParameterUtils.setSamlParameters(request, integration);
// };
//
// public final static Function<Integration, SamlResource> TO_RESOURCE = integration -> {
// SamlResource resource = new SamlResource();
// resource.setId(integration.getId());
// resource.setIdentityProviderName(integration.getName());
// resource.setEnabled(integration.isEnabled());
//
// EMAIL_ATTRIBUTE.getParameter(integration).ifPresent(resource::setEmailAttribute);
// FIRST_NAME_ATTRIBUTE.getParameter(integration).ifPresent(resource::setFirstNameAttribute);
// LAST_NAME_ATTRIBUTE.getParameter(integration).ifPresent(resource::setLastNameAttribute);
// FULL_NAME_ATTRIBUTE.getParameter(integration).ifPresent(resource::setFullNameAttribute);
// IDP_ALIAS.getParameter(integration).ifPresent(resource::setIdentityProviderAlias);
// IDP_METADATA_URL.getParameter(integration).ifPresent(resource::setIdentityProviderMetadataUrl);
// IDP_URL.getParameter(integration).ifPresent(resource::setIdentityProviderUrl);
// IDP_NAME_ID.getParameter(integration).ifPresent(resource::setIdentityProviderNameId);
// final IntegrationType integrationType = integration.getType();
// ofNullable(integrationType.getDetails()).flatMap(typeDetails -> Optional.ofNullable(typeDetails.getDetails()))
// .flatMap(BASE_PATH::getParameter)
// .ifPresent(resource::setCallbackUrl);
// return resource;
// };
//
// public final static Function<List<Integration>, List<ExternalIdentityProviderConfiguration>> TO_EXTERNAL_PROVIDER_CONFIG = integrations -> {
// List<ExternalIdentityProviderConfiguration> externalProviders = integrations.stream()
// .map(integration -> new ExternalIdentityProviderConfiguration().setAlias(IDP_ALIAS.getParameter(integration).get())
// .setMetadata(IDP_METADATA_URL.getRequiredParameter(integration))
// .setLinktext(integration.getName())
// .setNameId(NameId.fromUrn(IDP_NAME_ID.getParameter(integration).get())))
// .collect(Collectors.toList());
// IntStream.range(0, externalProviders.size()).forEach(value -> externalProviders.get(value).setAssertionConsumerServiceIndex(value));
// return externalProviders;
// };
//
// public final static Function<List<Integration>, SamlProvidersResource> TO_PROVIDERS_RESOURCE = integrations -> {
// if (CollectionUtils.isEmpty(integrations)) {
// SamlProvidersResource emptyResource = new SamlProvidersResource();
// emptyResource.setProviders(Collections.emptyList());
// return emptyResource;
// }
// SamlProvidersResource resource = new SamlProvidersResource();
// resource.setProviders(integrations.stream().map(TO_RESOURCE).collect(Collectors.toList()));
// return resource;
// };
//
// }
// Path: src/main/java/com/epam/reportportal/auth/event/SamlProvidersReloadEventHandler.java
import com.epam.reportportal.auth.integration.converter.SamlConverter;
import com.epam.ta.reportportal.dao.IntegrationRepository;
import com.epam.ta.reportportal.entity.integration.Integration;
import com.epam.ta.reportportal.entity.integration.IntegrationType;
import org.springframework.context.ApplicationListener;
import org.springframework.security.saml.provider.SamlServerConfiguration;
import org.springframework.security.saml.provider.service.config.LocalServiceProviderConfiguration;
import org.springframework.stereotype.Component;
import java.util.List;
/*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.event;
/**
* Handles SAML settings changes event and reload configuration of IDP in service provider configuration
*
* @author Yevgeniy Svalukhin
*/
@Component
public class SamlProvidersReloadEventHandler implements ApplicationListener<SamlProvidersReloadEvent> {
private final IntegrationRepository integrationRepository;
private final SamlServerConfiguration samlConfiguration;
public SamlProvidersReloadEventHandler(IntegrationRepository integrationRepository, SamlServerConfiguration spConfiguration) {
this.integrationRepository = integrationRepository;
this.samlConfiguration = spConfiguration;
}
@Override
public void onApplicationEvent(SamlProvidersReloadEvent event) {
final IntegrationType integrationType = event.getIntegrationType();
final List<Integration> integrations = integrationRepository.findAllGlobalByType(integrationType);
LocalServiceProviderConfiguration serviceProvider = samlConfiguration.getServiceProvider();
serviceProvider.getProviders().clear(); | serviceProvider.getProviders().addAll(SamlConverter.TO_EXTERNAL_PROVIDER_CONFIG.apply(integrations)); |
reportportal/service-authorization | src/main/java/com/epam/reportportal/auth/integration/handler/impl/strategy/ActiveDirectoryIntegrationStrategy.java | // Path: src/main/java/com/epam/reportportal/auth/integration/AuthIntegrationType.java
// public enum AuthIntegrationType {
//
// ACTIVE_DIRECTORY("ad") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, ActiveDirectoryResource> getToResourceMapper() {
// return ActiveDirectoryConverter.TO_RESOURCE;
// }
// },
// LDAP("ldap") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, LdapResource> getToResourceMapper() {
// return LdapConverter.TO_RESOURCE;
// }
// },
// SAML("saml") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, SamlResource> getToResourceMapper() {
// return SamlConverter.TO_RESOURCE;
// }
// };
//
// private String name;
//
// AuthIntegrationType(String name) {
// this.name = name;
// }
//
// public abstract Optional<Integration> get(Integration entity);
//
// public abstract Function<Integration, ? extends AbstractAuthResource> getToResourceMapper();
//
// public String getName() {
// return name;
// }
//
// public static Optional<AuthIntegrationType> fromId(String id) {
// return Arrays.stream(values()).filter(it -> it.name.equalsIgnoreCase(id)).findAny();
// }
//
// @Override
// public String toString() {
// return this.name;
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/duplicate/IntegrationDuplicateValidator.java
// public interface IntegrationDuplicateValidator {
//
// void validate(Integration integration);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/AuthRequestValidator.java
// public interface AuthRequestValidator<T> {
//
// void validate(T authRequest);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/converter/LdapConverter.java
// public static final BiConsumer<UpdateAuthRQ, Integration> UPDATE_FROM_REQUEST = (request, integration) -> {
// ParameterUtils.setLdapParameters(request, integration);
// integration.setEnabled(ofNullable(request.getEnabled()).orElse(false));
// };
| import com.epam.reportportal.auth.integration.AuthIntegrationType;
import com.epam.reportportal.auth.integration.validator.duplicate.IntegrationDuplicateValidator;
import com.epam.reportportal.auth.integration.validator.request.AuthRequestValidator;
import com.epam.ta.reportportal.dao.IntegrationRepository;
import com.epam.ta.reportportal.entity.integration.Integration;
import com.epam.ta.reportportal.ws.model.integration.auth.UpdateAuthRQ;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import static com.epam.reportportal.auth.integration.converter.LdapConverter.UPDATE_FROM_REQUEST; | /*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.integration.handler.impl.strategy;
/**
* @author <a href="mailto:ihar_kahadouski@epam.com">Ihar Kahadouski</a>
*/
@Service
public class ActiveDirectoryIntegrationStrategy extends AuthIntegrationStrategy {
@Autowired
public ActiveDirectoryIntegrationStrategy(IntegrationRepository integrationRepository, | // Path: src/main/java/com/epam/reportportal/auth/integration/AuthIntegrationType.java
// public enum AuthIntegrationType {
//
// ACTIVE_DIRECTORY("ad") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, ActiveDirectoryResource> getToResourceMapper() {
// return ActiveDirectoryConverter.TO_RESOURCE;
// }
// },
// LDAP("ldap") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, LdapResource> getToResourceMapper() {
// return LdapConverter.TO_RESOURCE;
// }
// },
// SAML("saml") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, SamlResource> getToResourceMapper() {
// return SamlConverter.TO_RESOURCE;
// }
// };
//
// private String name;
//
// AuthIntegrationType(String name) {
// this.name = name;
// }
//
// public abstract Optional<Integration> get(Integration entity);
//
// public abstract Function<Integration, ? extends AbstractAuthResource> getToResourceMapper();
//
// public String getName() {
// return name;
// }
//
// public static Optional<AuthIntegrationType> fromId(String id) {
// return Arrays.stream(values()).filter(it -> it.name.equalsIgnoreCase(id)).findAny();
// }
//
// @Override
// public String toString() {
// return this.name;
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/duplicate/IntegrationDuplicateValidator.java
// public interface IntegrationDuplicateValidator {
//
// void validate(Integration integration);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/AuthRequestValidator.java
// public interface AuthRequestValidator<T> {
//
// void validate(T authRequest);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/converter/LdapConverter.java
// public static final BiConsumer<UpdateAuthRQ, Integration> UPDATE_FROM_REQUEST = (request, integration) -> {
// ParameterUtils.setLdapParameters(request, integration);
// integration.setEnabled(ofNullable(request.getEnabled()).orElse(false));
// };
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/impl/strategy/ActiveDirectoryIntegrationStrategy.java
import com.epam.reportportal.auth.integration.AuthIntegrationType;
import com.epam.reportportal.auth.integration.validator.duplicate.IntegrationDuplicateValidator;
import com.epam.reportportal.auth.integration.validator.request.AuthRequestValidator;
import com.epam.ta.reportportal.dao.IntegrationRepository;
import com.epam.ta.reportportal.entity.integration.Integration;
import com.epam.ta.reportportal.ws.model.integration.auth.UpdateAuthRQ;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import static com.epam.reportportal.auth.integration.converter.LdapConverter.UPDATE_FROM_REQUEST;
/*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.integration.handler.impl.strategy;
/**
* @author <a href="mailto:ihar_kahadouski@epam.com">Ihar Kahadouski</a>
*/
@Service
public class ActiveDirectoryIntegrationStrategy extends AuthIntegrationStrategy {
@Autowired
public ActiveDirectoryIntegrationStrategy(IntegrationRepository integrationRepository, | @Qualifier("ldapUpdateAuthRequestValidator") AuthRequestValidator<UpdateAuthRQ> updateAuthRequestValidator, IntegrationDuplicateValidator integrationDuplicateValidator) { |
reportportal/service-authorization | src/main/java/com/epam/reportportal/auth/integration/handler/impl/strategy/ActiveDirectoryIntegrationStrategy.java | // Path: src/main/java/com/epam/reportportal/auth/integration/AuthIntegrationType.java
// public enum AuthIntegrationType {
//
// ACTIVE_DIRECTORY("ad") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, ActiveDirectoryResource> getToResourceMapper() {
// return ActiveDirectoryConverter.TO_RESOURCE;
// }
// },
// LDAP("ldap") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, LdapResource> getToResourceMapper() {
// return LdapConverter.TO_RESOURCE;
// }
// },
// SAML("saml") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, SamlResource> getToResourceMapper() {
// return SamlConverter.TO_RESOURCE;
// }
// };
//
// private String name;
//
// AuthIntegrationType(String name) {
// this.name = name;
// }
//
// public abstract Optional<Integration> get(Integration entity);
//
// public abstract Function<Integration, ? extends AbstractAuthResource> getToResourceMapper();
//
// public String getName() {
// return name;
// }
//
// public static Optional<AuthIntegrationType> fromId(String id) {
// return Arrays.stream(values()).filter(it -> it.name.equalsIgnoreCase(id)).findAny();
// }
//
// @Override
// public String toString() {
// return this.name;
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/duplicate/IntegrationDuplicateValidator.java
// public interface IntegrationDuplicateValidator {
//
// void validate(Integration integration);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/AuthRequestValidator.java
// public interface AuthRequestValidator<T> {
//
// void validate(T authRequest);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/converter/LdapConverter.java
// public static final BiConsumer<UpdateAuthRQ, Integration> UPDATE_FROM_REQUEST = (request, integration) -> {
// ParameterUtils.setLdapParameters(request, integration);
// integration.setEnabled(ofNullable(request.getEnabled()).orElse(false));
// };
| import com.epam.reportportal.auth.integration.AuthIntegrationType;
import com.epam.reportportal.auth.integration.validator.duplicate.IntegrationDuplicateValidator;
import com.epam.reportportal.auth.integration.validator.request.AuthRequestValidator;
import com.epam.ta.reportportal.dao.IntegrationRepository;
import com.epam.ta.reportportal.entity.integration.Integration;
import com.epam.ta.reportportal.ws.model.integration.auth.UpdateAuthRQ;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import static com.epam.reportportal.auth.integration.converter.LdapConverter.UPDATE_FROM_REQUEST; | /*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.integration.handler.impl.strategy;
/**
* @author <a href="mailto:ihar_kahadouski@epam.com">Ihar Kahadouski</a>
*/
@Service
public class ActiveDirectoryIntegrationStrategy extends AuthIntegrationStrategy {
@Autowired
public ActiveDirectoryIntegrationStrategy(IntegrationRepository integrationRepository, | // Path: src/main/java/com/epam/reportportal/auth/integration/AuthIntegrationType.java
// public enum AuthIntegrationType {
//
// ACTIVE_DIRECTORY("ad") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, ActiveDirectoryResource> getToResourceMapper() {
// return ActiveDirectoryConverter.TO_RESOURCE;
// }
// },
// LDAP("ldap") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, LdapResource> getToResourceMapper() {
// return LdapConverter.TO_RESOURCE;
// }
// },
// SAML("saml") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, SamlResource> getToResourceMapper() {
// return SamlConverter.TO_RESOURCE;
// }
// };
//
// private String name;
//
// AuthIntegrationType(String name) {
// this.name = name;
// }
//
// public abstract Optional<Integration> get(Integration entity);
//
// public abstract Function<Integration, ? extends AbstractAuthResource> getToResourceMapper();
//
// public String getName() {
// return name;
// }
//
// public static Optional<AuthIntegrationType> fromId(String id) {
// return Arrays.stream(values()).filter(it -> it.name.equalsIgnoreCase(id)).findAny();
// }
//
// @Override
// public String toString() {
// return this.name;
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/duplicate/IntegrationDuplicateValidator.java
// public interface IntegrationDuplicateValidator {
//
// void validate(Integration integration);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/AuthRequestValidator.java
// public interface AuthRequestValidator<T> {
//
// void validate(T authRequest);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/converter/LdapConverter.java
// public static final BiConsumer<UpdateAuthRQ, Integration> UPDATE_FROM_REQUEST = (request, integration) -> {
// ParameterUtils.setLdapParameters(request, integration);
// integration.setEnabled(ofNullable(request.getEnabled()).orElse(false));
// };
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/impl/strategy/ActiveDirectoryIntegrationStrategy.java
import com.epam.reportportal.auth.integration.AuthIntegrationType;
import com.epam.reportportal.auth.integration.validator.duplicate.IntegrationDuplicateValidator;
import com.epam.reportportal.auth.integration.validator.request.AuthRequestValidator;
import com.epam.ta.reportportal.dao.IntegrationRepository;
import com.epam.ta.reportportal.entity.integration.Integration;
import com.epam.ta.reportportal.ws.model.integration.auth.UpdateAuthRQ;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import static com.epam.reportportal.auth.integration.converter.LdapConverter.UPDATE_FROM_REQUEST;
/*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.integration.handler.impl.strategy;
/**
* @author <a href="mailto:ihar_kahadouski@epam.com">Ihar Kahadouski</a>
*/
@Service
public class ActiveDirectoryIntegrationStrategy extends AuthIntegrationStrategy {
@Autowired
public ActiveDirectoryIntegrationStrategy(IntegrationRepository integrationRepository, | @Qualifier("ldapUpdateAuthRequestValidator") AuthRequestValidator<UpdateAuthRQ> updateAuthRequestValidator, IntegrationDuplicateValidator integrationDuplicateValidator) { |
reportportal/service-authorization | src/main/java/com/epam/reportportal/auth/integration/handler/impl/strategy/ActiveDirectoryIntegrationStrategy.java | // Path: src/main/java/com/epam/reportportal/auth/integration/AuthIntegrationType.java
// public enum AuthIntegrationType {
//
// ACTIVE_DIRECTORY("ad") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, ActiveDirectoryResource> getToResourceMapper() {
// return ActiveDirectoryConverter.TO_RESOURCE;
// }
// },
// LDAP("ldap") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, LdapResource> getToResourceMapper() {
// return LdapConverter.TO_RESOURCE;
// }
// },
// SAML("saml") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, SamlResource> getToResourceMapper() {
// return SamlConverter.TO_RESOURCE;
// }
// };
//
// private String name;
//
// AuthIntegrationType(String name) {
// this.name = name;
// }
//
// public abstract Optional<Integration> get(Integration entity);
//
// public abstract Function<Integration, ? extends AbstractAuthResource> getToResourceMapper();
//
// public String getName() {
// return name;
// }
//
// public static Optional<AuthIntegrationType> fromId(String id) {
// return Arrays.stream(values()).filter(it -> it.name.equalsIgnoreCase(id)).findAny();
// }
//
// @Override
// public String toString() {
// return this.name;
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/duplicate/IntegrationDuplicateValidator.java
// public interface IntegrationDuplicateValidator {
//
// void validate(Integration integration);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/AuthRequestValidator.java
// public interface AuthRequestValidator<T> {
//
// void validate(T authRequest);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/converter/LdapConverter.java
// public static final BiConsumer<UpdateAuthRQ, Integration> UPDATE_FROM_REQUEST = (request, integration) -> {
// ParameterUtils.setLdapParameters(request, integration);
// integration.setEnabled(ofNullable(request.getEnabled()).orElse(false));
// };
| import com.epam.reportportal.auth.integration.AuthIntegrationType;
import com.epam.reportportal.auth.integration.validator.duplicate.IntegrationDuplicateValidator;
import com.epam.reportportal.auth.integration.validator.request.AuthRequestValidator;
import com.epam.ta.reportportal.dao.IntegrationRepository;
import com.epam.ta.reportportal.entity.integration.Integration;
import com.epam.ta.reportportal.ws.model.integration.auth.UpdateAuthRQ;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import static com.epam.reportportal.auth.integration.converter.LdapConverter.UPDATE_FROM_REQUEST; | /*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.integration.handler.impl.strategy;
/**
* @author <a href="mailto:ihar_kahadouski@epam.com">Ihar Kahadouski</a>
*/
@Service
public class ActiveDirectoryIntegrationStrategy extends AuthIntegrationStrategy {
@Autowired
public ActiveDirectoryIntegrationStrategy(IntegrationRepository integrationRepository,
@Qualifier("ldapUpdateAuthRequestValidator") AuthRequestValidator<UpdateAuthRQ> updateAuthRequestValidator, IntegrationDuplicateValidator integrationDuplicateValidator) {
super(integrationRepository, updateAuthRequestValidator, integrationDuplicateValidator);
}
@Override
protected void fill(Integration integration, UpdateAuthRQ updateRequest) { | // Path: src/main/java/com/epam/reportportal/auth/integration/AuthIntegrationType.java
// public enum AuthIntegrationType {
//
// ACTIVE_DIRECTORY("ad") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, ActiveDirectoryResource> getToResourceMapper() {
// return ActiveDirectoryConverter.TO_RESOURCE;
// }
// },
// LDAP("ldap") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, LdapResource> getToResourceMapper() {
// return LdapConverter.TO_RESOURCE;
// }
// },
// SAML("saml") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, SamlResource> getToResourceMapper() {
// return SamlConverter.TO_RESOURCE;
// }
// };
//
// private String name;
//
// AuthIntegrationType(String name) {
// this.name = name;
// }
//
// public abstract Optional<Integration> get(Integration entity);
//
// public abstract Function<Integration, ? extends AbstractAuthResource> getToResourceMapper();
//
// public String getName() {
// return name;
// }
//
// public static Optional<AuthIntegrationType> fromId(String id) {
// return Arrays.stream(values()).filter(it -> it.name.equalsIgnoreCase(id)).findAny();
// }
//
// @Override
// public String toString() {
// return this.name;
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/duplicate/IntegrationDuplicateValidator.java
// public interface IntegrationDuplicateValidator {
//
// void validate(Integration integration);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/AuthRequestValidator.java
// public interface AuthRequestValidator<T> {
//
// void validate(T authRequest);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/converter/LdapConverter.java
// public static final BiConsumer<UpdateAuthRQ, Integration> UPDATE_FROM_REQUEST = (request, integration) -> {
// ParameterUtils.setLdapParameters(request, integration);
// integration.setEnabled(ofNullable(request.getEnabled()).orElse(false));
// };
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/impl/strategy/ActiveDirectoryIntegrationStrategy.java
import com.epam.reportportal.auth.integration.AuthIntegrationType;
import com.epam.reportportal.auth.integration.validator.duplicate.IntegrationDuplicateValidator;
import com.epam.reportportal.auth.integration.validator.request.AuthRequestValidator;
import com.epam.ta.reportportal.dao.IntegrationRepository;
import com.epam.ta.reportportal.entity.integration.Integration;
import com.epam.ta.reportportal.ws.model.integration.auth.UpdateAuthRQ;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import static com.epam.reportportal.auth.integration.converter.LdapConverter.UPDATE_FROM_REQUEST;
/*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.integration.handler.impl.strategy;
/**
* @author <a href="mailto:ihar_kahadouski@epam.com">Ihar Kahadouski</a>
*/
@Service
public class ActiveDirectoryIntegrationStrategy extends AuthIntegrationStrategy {
@Autowired
public ActiveDirectoryIntegrationStrategy(IntegrationRepository integrationRepository,
@Qualifier("ldapUpdateAuthRequestValidator") AuthRequestValidator<UpdateAuthRQ> updateAuthRequestValidator, IntegrationDuplicateValidator integrationDuplicateValidator) {
super(integrationRepository, updateAuthRequestValidator, integrationDuplicateValidator);
}
@Override
protected void fill(Integration integration, UpdateAuthRQ updateRequest) { | integration.setName(AuthIntegrationType.ACTIVE_DIRECTORY.getName()); |
reportportal/service-authorization | src/main/java/com/epam/reportportal/auth/integration/handler/impl/strategy/ActiveDirectoryIntegrationStrategy.java | // Path: src/main/java/com/epam/reportportal/auth/integration/AuthIntegrationType.java
// public enum AuthIntegrationType {
//
// ACTIVE_DIRECTORY("ad") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, ActiveDirectoryResource> getToResourceMapper() {
// return ActiveDirectoryConverter.TO_RESOURCE;
// }
// },
// LDAP("ldap") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, LdapResource> getToResourceMapper() {
// return LdapConverter.TO_RESOURCE;
// }
// },
// SAML("saml") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, SamlResource> getToResourceMapper() {
// return SamlConverter.TO_RESOURCE;
// }
// };
//
// private String name;
//
// AuthIntegrationType(String name) {
// this.name = name;
// }
//
// public abstract Optional<Integration> get(Integration entity);
//
// public abstract Function<Integration, ? extends AbstractAuthResource> getToResourceMapper();
//
// public String getName() {
// return name;
// }
//
// public static Optional<AuthIntegrationType> fromId(String id) {
// return Arrays.stream(values()).filter(it -> it.name.equalsIgnoreCase(id)).findAny();
// }
//
// @Override
// public String toString() {
// return this.name;
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/duplicate/IntegrationDuplicateValidator.java
// public interface IntegrationDuplicateValidator {
//
// void validate(Integration integration);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/AuthRequestValidator.java
// public interface AuthRequestValidator<T> {
//
// void validate(T authRequest);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/converter/LdapConverter.java
// public static final BiConsumer<UpdateAuthRQ, Integration> UPDATE_FROM_REQUEST = (request, integration) -> {
// ParameterUtils.setLdapParameters(request, integration);
// integration.setEnabled(ofNullable(request.getEnabled()).orElse(false));
// };
| import com.epam.reportportal.auth.integration.AuthIntegrationType;
import com.epam.reportportal.auth.integration.validator.duplicate.IntegrationDuplicateValidator;
import com.epam.reportportal.auth.integration.validator.request.AuthRequestValidator;
import com.epam.ta.reportportal.dao.IntegrationRepository;
import com.epam.ta.reportportal.entity.integration.Integration;
import com.epam.ta.reportportal.ws.model.integration.auth.UpdateAuthRQ;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import static com.epam.reportportal.auth.integration.converter.LdapConverter.UPDATE_FROM_REQUEST; | /*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.integration.handler.impl.strategy;
/**
* @author <a href="mailto:ihar_kahadouski@epam.com">Ihar Kahadouski</a>
*/
@Service
public class ActiveDirectoryIntegrationStrategy extends AuthIntegrationStrategy {
@Autowired
public ActiveDirectoryIntegrationStrategy(IntegrationRepository integrationRepository,
@Qualifier("ldapUpdateAuthRequestValidator") AuthRequestValidator<UpdateAuthRQ> updateAuthRequestValidator, IntegrationDuplicateValidator integrationDuplicateValidator) {
super(integrationRepository, updateAuthRequestValidator, integrationDuplicateValidator);
}
@Override
protected void fill(Integration integration, UpdateAuthRQ updateRequest) {
integration.setName(AuthIntegrationType.ACTIVE_DIRECTORY.getName()); | // Path: src/main/java/com/epam/reportportal/auth/integration/AuthIntegrationType.java
// public enum AuthIntegrationType {
//
// ACTIVE_DIRECTORY("ad") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, ActiveDirectoryResource> getToResourceMapper() {
// return ActiveDirectoryConverter.TO_RESOURCE;
// }
// },
// LDAP("ldap") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, LdapResource> getToResourceMapper() {
// return LdapConverter.TO_RESOURCE;
// }
// },
// SAML("saml") {
// @Override
// public Optional<Integration> get(Integration entity) {
// return ofNullable(entity);
// }
//
// @Override
// public Function<Integration, SamlResource> getToResourceMapper() {
// return SamlConverter.TO_RESOURCE;
// }
// };
//
// private String name;
//
// AuthIntegrationType(String name) {
// this.name = name;
// }
//
// public abstract Optional<Integration> get(Integration entity);
//
// public abstract Function<Integration, ? extends AbstractAuthResource> getToResourceMapper();
//
// public String getName() {
// return name;
// }
//
// public static Optional<AuthIntegrationType> fromId(String id) {
// return Arrays.stream(values()).filter(it -> it.name.equalsIgnoreCase(id)).findAny();
// }
//
// @Override
// public String toString() {
// return this.name;
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/duplicate/IntegrationDuplicateValidator.java
// public interface IntegrationDuplicateValidator {
//
// void validate(Integration integration);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/AuthRequestValidator.java
// public interface AuthRequestValidator<T> {
//
// void validate(T authRequest);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/converter/LdapConverter.java
// public static final BiConsumer<UpdateAuthRQ, Integration> UPDATE_FROM_REQUEST = (request, integration) -> {
// ParameterUtils.setLdapParameters(request, integration);
// integration.setEnabled(ofNullable(request.getEnabled()).orElse(false));
// };
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/impl/strategy/ActiveDirectoryIntegrationStrategy.java
import com.epam.reportportal.auth.integration.AuthIntegrationType;
import com.epam.reportportal.auth.integration.validator.duplicate.IntegrationDuplicateValidator;
import com.epam.reportportal.auth.integration.validator.request.AuthRequestValidator;
import com.epam.ta.reportportal.dao.IntegrationRepository;
import com.epam.ta.reportportal.entity.integration.Integration;
import com.epam.ta.reportportal.ws.model.integration.auth.UpdateAuthRQ;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import static com.epam.reportportal.auth.integration.converter.LdapConverter.UPDATE_FROM_REQUEST;
/*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.integration.handler.impl.strategy;
/**
* @author <a href="mailto:ihar_kahadouski@epam.com">Ihar Kahadouski</a>
*/
@Service
public class ActiveDirectoryIntegrationStrategy extends AuthIntegrationStrategy {
@Autowired
public ActiveDirectoryIntegrationStrategy(IntegrationRepository integrationRepository,
@Qualifier("ldapUpdateAuthRequestValidator") AuthRequestValidator<UpdateAuthRQ> updateAuthRequestValidator, IntegrationDuplicateValidator integrationDuplicateValidator) {
super(integrationRepository, updateAuthRequestValidator, integrationDuplicateValidator);
}
@Override
protected void fill(Integration integration, UpdateAuthRQ updateRequest) {
integration.setName(AuthIntegrationType.ACTIVE_DIRECTORY.getName()); | UPDATE_FROM_REQUEST.accept(updateRequest, integration); |
reportportal/service-authorization | src/main/java/com/epam/reportportal/auth/integration/handler/impl/strategy/AuthIntegrationStrategy.java | // Path: src/main/java/com/epam/reportportal/auth/integration/builder/AuthIntegrationBuilder.java
// public class AuthIntegrationBuilder {
//
// private final Integration integration;
//
// public AuthIntegrationBuilder() {
// integration = new Integration();
// }
//
// public AuthIntegrationBuilder(Integration integration) {
// this.integration = integration;
// }
//
// public AuthIntegrationBuilder addCreator(String username) {
// integration.setCreator(username);
// return this;
// }
//
// public AuthIntegrationBuilder addIntegrationType(IntegrationType type) {
// integration.setType(type);
// return this;
// }
//
// public AuthIntegrationBuilder addCreationDate(LocalDateTime creationDate) {
// integration.setCreationDate(creationDate);
// return this;
// }
//
// public @NotNull Integration build() {
// return integration;
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/duplicate/IntegrationDuplicateValidator.java
// public interface IntegrationDuplicateValidator {
//
// void validate(Integration integration);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/AuthRequestValidator.java
// public interface AuthRequestValidator<T> {
//
// void validate(T authRequest);
// }
| import com.epam.reportportal.auth.integration.builder.AuthIntegrationBuilder;
import com.epam.reportportal.auth.integration.validator.duplicate.IntegrationDuplicateValidator;
import com.epam.reportportal.auth.integration.validator.request.AuthRequestValidator;
import com.epam.ta.reportportal.dao.IntegrationRepository;
import com.epam.ta.reportportal.entity.integration.Integration;
import com.epam.ta.reportportal.entity.integration.IntegrationType;
import com.epam.ta.reportportal.exception.ReportPortalException;
import com.epam.ta.reportportal.ws.model.ErrorType;
import com.epam.ta.reportportal.ws.model.integration.auth.UpdateAuthRQ;
import java.time.LocalDateTime;
import java.time.ZoneOffset; | /*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.integration.handler.impl.strategy;
/**
* @author <a href="mailto:ihar_kahadouski@epam.com">Ihar Kahadouski</a>
*/
public abstract class AuthIntegrationStrategy {
private final IntegrationRepository integrationRepository; | // Path: src/main/java/com/epam/reportportal/auth/integration/builder/AuthIntegrationBuilder.java
// public class AuthIntegrationBuilder {
//
// private final Integration integration;
//
// public AuthIntegrationBuilder() {
// integration = new Integration();
// }
//
// public AuthIntegrationBuilder(Integration integration) {
// this.integration = integration;
// }
//
// public AuthIntegrationBuilder addCreator(String username) {
// integration.setCreator(username);
// return this;
// }
//
// public AuthIntegrationBuilder addIntegrationType(IntegrationType type) {
// integration.setType(type);
// return this;
// }
//
// public AuthIntegrationBuilder addCreationDate(LocalDateTime creationDate) {
// integration.setCreationDate(creationDate);
// return this;
// }
//
// public @NotNull Integration build() {
// return integration;
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/duplicate/IntegrationDuplicateValidator.java
// public interface IntegrationDuplicateValidator {
//
// void validate(Integration integration);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/AuthRequestValidator.java
// public interface AuthRequestValidator<T> {
//
// void validate(T authRequest);
// }
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/impl/strategy/AuthIntegrationStrategy.java
import com.epam.reportportal.auth.integration.builder.AuthIntegrationBuilder;
import com.epam.reportportal.auth.integration.validator.duplicate.IntegrationDuplicateValidator;
import com.epam.reportportal.auth.integration.validator.request.AuthRequestValidator;
import com.epam.ta.reportportal.dao.IntegrationRepository;
import com.epam.ta.reportportal.entity.integration.Integration;
import com.epam.ta.reportportal.entity.integration.IntegrationType;
import com.epam.ta.reportportal.exception.ReportPortalException;
import com.epam.ta.reportportal.ws.model.ErrorType;
import com.epam.ta.reportportal.ws.model.integration.auth.UpdateAuthRQ;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
/*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.integration.handler.impl.strategy;
/**
* @author <a href="mailto:ihar_kahadouski@epam.com">Ihar Kahadouski</a>
*/
public abstract class AuthIntegrationStrategy {
private final IntegrationRepository integrationRepository; | private final AuthRequestValidator<UpdateAuthRQ> updateAuthRequestValidator; |
reportportal/service-authorization | src/main/java/com/epam/reportportal/auth/integration/handler/impl/strategy/AuthIntegrationStrategy.java | // Path: src/main/java/com/epam/reportportal/auth/integration/builder/AuthIntegrationBuilder.java
// public class AuthIntegrationBuilder {
//
// private final Integration integration;
//
// public AuthIntegrationBuilder() {
// integration = new Integration();
// }
//
// public AuthIntegrationBuilder(Integration integration) {
// this.integration = integration;
// }
//
// public AuthIntegrationBuilder addCreator(String username) {
// integration.setCreator(username);
// return this;
// }
//
// public AuthIntegrationBuilder addIntegrationType(IntegrationType type) {
// integration.setType(type);
// return this;
// }
//
// public AuthIntegrationBuilder addCreationDate(LocalDateTime creationDate) {
// integration.setCreationDate(creationDate);
// return this;
// }
//
// public @NotNull Integration build() {
// return integration;
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/duplicate/IntegrationDuplicateValidator.java
// public interface IntegrationDuplicateValidator {
//
// void validate(Integration integration);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/AuthRequestValidator.java
// public interface AuthRequestValidator<T> {
//
// void validate(T authRequest);
// }
| import com.epam.reportportal.auth.integration.builder.AuthIntegrationBuilder;
import com.epam.reportportal.auth.integration.validator.duplicate.IntegrationDuplicateValidator;
import com.epam.reportportal.auth.integration.validator.request.AuthRequestValidator;
import com.epam.ta.reportportal.dao.IntegrationRepository;
import com.epam.ta.reportportal.entity.integration.Integration;
import com.epam.ta.reportportal.entity.integration.IntegrationType;
import com.epam.ta.reportportal.exception.ReportPortalException;
import com.epam.ta.reportportal.ws.model.ErrorType;
import com.epam.ta.reportportal.ws.model.integration.auth.UpdateAuthRQ;
import java.time.LocalDateTime;
import java.time.ZoneOffset; | /*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.integration.handler.impl.strategy;
/**
* @author <a href="mailto:ihar_kahadouski@epam.com">Ihar Kahadouski</a>
*/
public abstract class AuthIntegrationStrategy {
private final IntegrationRepository integrationRepository;
private final AuthRequestValidator<UpdateAuthRQ> updateAuthRequestValidator; | // Path: src/main/java/com/epam/reportportal/auth/integration/builder/AuthIntegrationBuilder.java
// public class AuthIntegrationBuilder {
//
// private final Integration integration;
//
// public AuthIntegrationBuilder() {
// integration = new Integration();
// }
//
// public AuthIntegrationBuilder(Integration integration) {
// this.integration = integration;
// }
//
// public AuthIntegrationBuilder addCreator(String username) {
// integration.setCreator(username);
// return this;
// }
//
// public AuthIntegrationBuilder addIntegrationType(IntegrationType type) {
// integration.setType(type);
// return this;
// }
//
// public AuthIntegrationBuilder addCreationDate(LocalDateTime creationDate) {
// integration.setCreationDate(creationDate);
// return this;
// }
//
// public @NotNull Integration build() {
// return integration;
// }
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/duplicate/IntegrationDuplicateValidator.java
// public interface IntegrationDuplicateValidator {
//
// void validate(Integration integration);
// }
//
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/AuthRequestValidator.java
// public interface AuthRequestValidator<T> {
//
// void validate(T authRequest);
// }
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/impl/strategy/AuthIntegrationStrategy.java
import com.epam.reportportal.auth.integration.builder.AuthIntegrationBuilder;
import com.epam.reportportal.auth.integration.validator.duplicate.IntegrationDuplicateValidator;
import com.epam.reportportal.auth.integration.validator.request.AuthRequestValidator;
import com.epam.ta.reportportal.dao.IntegrationRepository;
import com.epam.ta.reportportal.entity.integration.Integration;
import com.epam.ta.reportportal.entity.integration.IntegrationType;
import com.epam.ta.reportportal.exception.ReportPortalException;
import com.epam.ta.reportportal.ws.model.ErrorType;
import com.epam.ta.reportportal.ws.model.integration.auth.UpdateAuthRQ;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
/*
* Copyright 2019 EPAM Systems
*
* 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 com.epam.reportportal.auth.integration.handler.impl.strategy;
/**
* @author <a href="mailto:ihar_kahadouski@epam.com">Ihar Kahadouski</a>
*/
public abstract class AuthIntegrationStrategy {
private final IntegrationRepository integrationRepository;
private final AuthRequestValidator<UpdateAuthRQ> updateAuthRequestValidator; | private final IntegrationDuplicateValidator integrationDuplicateValidator; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.