// Path: src/main/java/se/omegapoint/facepalm/domain/Policy.java
// public class Policy {
//     public final String text;
// 
//     public Policy(final String text) {
//         this.text = notBlank(text);
//     }
// }
// 
// Path: src/main/java/se/omegapoint/facepalm/domain/event/EventService.java
// public interface EventService {
//     void publish(ApplicationEvent event);
// }
// 
// Path: src/main/java/se/omegapoint/facepalm/domain/repository/PolicyRepository.java
// public interface PolicyRepository {
//     Optional<Policy> retrievePolicyWith(String filename);
// }
// 
// Path: src/main/java/se/omegapoint/facepalm/infrastructure/event/GenericEvent.java
// public class GenericEvent implements ApplicationEvent {
//     private final Object data;
// 
//     public GenericEvent(final Object data) {
//         this.data = notNull(data);
//     }
// 
//     @Override
//     public String message() {
//         return data.toString();
//     }
// 
//     @Override
//     public boolean equals(final Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
//         final GenericEvent that = (GenericEvent) o;
//         return Objects.equals(data, that.data);
//     }
// 
//     @Override
//     public int hashCode() {
//         return Objects.hash(data);
//     }
// }


import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import static java.lang.String.format;
import static org.apache.commons.lang3.Validate.notBlank;
import static org.apache.commons.lang3.Validate.notNull;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import se.omegapoint.facepalm.domain.Policy;
import se.omegapoint.facepalm.domain.event.EventService;
import se.omegapoint.facepalm.domain.repository.PolicyRepository;
import se.omegapoint.facepalm.infrastructure.event.GenericEvent;
import java.nio.charset.Charset;
import java.util.Locale;
import java.util.Optional;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/*
 * Copyright 2016 the original author or authors.
 *
 * 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 se.omegapoint.facepalm.infrastructure;




@Repository
public class FilePolicyRepository implements PolicyRepository {

    private static final int TIMEOUT = 5;
    private final EventService eventService;

    @Autowired
    public FilePolicyRepository(final EventService eventService) {
        this.eventService = notNull(eventService);
    }

    @Override
// Path: src/main/java/se/omegapoint/facepalm/domain/Policy.java
// public class Policy {
//     public final String text;
// 
//     public Policy(final String text) {
//         this.text = notBlank(text);
//     }
// }
// 
// Path: src/main/java/se/omegapoint/facepalm/domain/event/EventService.java
// public interface EventService {
//     void publish(ApplicationEvent event);
// }
// 
// Path: src/main/java/se/omegapoint/facepalm/domain/repository/PolicyRepository.java
// public interface PolicyRepository {
//     Optional<Policy> retrievePolicyWith(String filename);
// }
// 
// Path: src/main/java/se/omegapoint/facepalm/infrastructure/event/GenericEvent.java
// public class GenericEvent implements ApplicationEvent {
//     private final Object data;
// 
//     public GenericEvent(final Object data) {
//         this.data = notNull(data);
//     }
// 
//     @Override
//     public String message() {
//         return data.toString();
//     }
// 
//     @Override
//     public boolean equals(final Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
//         final GenericEvent that = (GenericEvent) o;
//         return Objects.equals(data, that.data);
//     }
// 
//     @Override
//     public int hashCode() {
//         return Objects.hash(data);
//     }
// }


// Path: src/main/java/se/omegapoint/facepalm/infrastructure/FilePolicyRepository.java
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import static java.lang.String.format;
import static org.apache.commons.lang3.Validate.notBlank;
import static org.apache.commons.lang3.Validate.notNull;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import se.omegapoint.facepalm.domain.Policy;
import se.omegapoint.facepalm.domain.event.EventService;
import se.omegapoint.facepalm.domain.repository.PolicyRepository;
import se.omegapoint.facepalm.infrastructure.event.GenericEvent;
import java.nio.charset.Charset;
import java.util.Locale;
import java.util.Optional;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/*
 * Copyright 2016 the original author or authors.
 *
 * 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 se.omegapoint.facepalm.infrastructure;




@Repository
public class FilePolicyRepository implements PolicyRepository {

    private static final int TIMEOUT = 5;
    private final EventService eventService;

    @Autowired
    public FilePolicyRepository(final EventService eventService) {
        this.eventService = notNull(eventService);
    }

    @Override
    public Optional<Policy> retrievePolicyWith(final String filename) {