// Path: src/main/java/org/swarmcom/jsynapse/dao/AccessTokenRepository.java
// public interface AccessTokenRepository extends MongoRepository<AccessToken, String> {
//     AccessToken findByToken(String token);
// 
//     AccessToken findByUserId(String userId);
// }
// 
// Path: src/main/java/org/swarmcom/jsynapse/domain/AccessToken.java
// public class AccessToken {
//     @Id
//     String id;
// 
//     String userId;
// 
//     String token;
// 
//     Date lastUsed;
// 
//     public AccessToken(@NotNull String userId, @NotNull String token, @NotNull Date lastUsed) {
//         this.userId = userId;
//         this.token = token;
//         this.lastUsed = lastUsed;
//     }
// 
//     public String getId() {
//         return id;
//     }
// 
//     public void setId(String id) {
//         this.id = id;
//     }
// 
//     public String getUserId() {
//         return userId;
//     }
// 
//     public void setUserId(String userId) {
//         this.userId = userId;
//     }
// 
//     public String getToken() {
//         return token;
//     }
// 
//     public void setToken(String token) {
//         this.token = token;
//     }
// 
//     public Date getLastUsed() {
//         return lastUsed;
//     }
// 
//     public void setLastUsed(Date lastUsed) {
//         this.lastUsed = lastUsed;
//     }
// }


import java.util.concurrent.TimeUnit;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Sort;;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.index.Index;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import org.swarmcom.jsynapse.dao.AccessTokenRepository;
import org.swarmcom.jsynapse.domain.AccessToken;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
/*
 * (C) Copyright 2015 eZuce Inc.
 *
 * 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
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
*/
package org.swarmcom.jsynapse.service.accesstoken;



@Service
@Validated
public class AccessTokenServiceImpl implements AccessTokenService {
    private AccessTokenRepository accessTokenRepository;
    private MongoTemplate mongoTemplate;

    @Value("${token.expire.seconds:300}")
    private long expire;

    @Inject
// Path: src/main/java/org/swarmcom/jsynapse/dao/AccessTokenRepository.java
// public interface AccessTokenRepository extends MongoRepository<AccessToken, String> {
//     AccessToken findByToken(String token);
// 
//     AccessToken findByUserId(String userId);
// }
// 
// Path: src/main/java/org/swarmcom/jsynapse/domain/AccessToken.java
// public class AccessToken {
//     @Id
//     String id;
// 
//     String userId;
// 
//     String token;
// 
//     Date lastUsed;
// 
//     public AccessToken(@NotNull String userId, @NotNull String token, @NotNull Date lastUsed) {
//         this.userId = userId;
//         this.token = token;
//         this.lastUsed = lastUsed;
//     }
// 
//     public String getId() {
//         return id;
//     }
// 
//     public void setId(String id) {
//         this.id = id;
//     }
// 
//     public String getUserId() {
//         return userId;
//     }
// 
//     public void setUserId(String userId) {
//         this.userId = userId;
//     }
// 
//     public String getToken() {
//         return token;
//     }
// 
//     public void setToken(String token) {
//         this.token = token;
//     }
// 
//     public Date getLastUsed() {
//         return lastUsed;
//     }
// 
//     public void setLastUsed(Date lastUsed) {
//         this.lastUsed = lastUsed;
//     }
// }


// Path: src/main/java/org/swarmcom/jsynapse/service/accesstoken/AccessTokenServiceImpl.java
import java.util.concurrent.TimeUnit;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Sort;;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.index.Index;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import org.swarmcom.jsynapse.dao.AccessTokenRepository;
import org.swarmcom.jsynapse.domain.AccessToken;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;

/*
 * (C) Copyright 2015 eZuce Inc.
 *
 * 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
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
*/
package org.swarmcom.jsynapse.service.accesstoken;



@Service
@Validated
public class AccessTokenServiceImpl implements AccessTokenService {
    private AccessTokenRepository accessTokenRepository;
    private MongoTemplate mongoTemplate;

    @Value("${token.expire.seconds:300}")
    private long expire;

    @Inject
    public AccessTokenServiceImpl(AccessTokenRepository accessTokenRepository, MongoTemplate mongoTemplate) {