// Path: src/main/java/uk/co/caprica/bootlace/data/mongo/profile/ProfileRepository.java
// public interface ProfileRepository extends MongoRepository<Profile, String> {
// 
// }
// 
// Path: src/main/java/uk/co/caprica/bootlace/domain/profile/Profile.java
// @Document
// public class Profile extends AbstractAuditableEntity {
// 
//     @NotNull
//     private String forename;
// 
//     @NotNull
//     private String surname;
// 
//     @NotNull
//     private String email;
// 
//     public Profile() {
//     }
// 
//     public String getForename() {
//         return forename;
//     }
// 
//     public void setForename(String forename) {
//         this.forename = forename;
//     }
// 
//     public String getSurname() {
//         return surname;
//     }
// 
//     public void setSurname(String surname) {
//         this.surname = surname;
//     }
// 
//     public String getEmail() {
//         return email;
//     }
// 
//     public void setEmail(String email) {
//         this.email = email;
//     }
// 
//     @Override
//     public String toString() {
//         return toStringHelper()
//             .add("forename", forename)
//             .add("surname", surname)
//             .add("email", email)
//             .toString();
//     }
// 
// }
// 
// Path: src/main/java/uk/co/caprica/bootlace/security/domain/UserWithId.java
// public final class UserWithId extends User {
// 
//     /**
//      * The database user identifier.
//      */
//     private final String id;
// 
//     /**
//      * Create a user.
//      *
//      * @param id database user identifier
//      */
//     public UserWithId(String username, String password, boolean enabled, boolean accountNonExpired, boolean credentialsNonExpired, boolean accountNonLocked, Collection<? extends GrantedAuthority> authorities, String id) {
//         super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities);
//         this.id = id;
//     }
// 
//     /**
//      * Get the database identifier for the user.
//      *
//      * @return unique user identifier
//      */
//     public String getId() {
//         return id;
//     }
// 
// }


import org.springframework.web.bind.annotation.RestController;
import uk.co.caprica.bootlace.data.mongo.profile.ProfileRepository;
import uk.co.caprica.bootlace.domain.profile.Profile;
import uk.co.caprica.bootlace.security.domain.UserWithId;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.web.bind.annotation.AuthenticationPrincipal;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
/*
 * This file is part of Bootlace.
 *
 * Copyright (C) 2015
 * Caprica Software Limited (capricasoftware.co.uk)
 *
 * 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 uk.co.caprica.bootlace.controller.profile;



/**
 * Web-service controller for Profile resources.
 * <p>
 * A profile is basic personal data associated with an application user.
 * <p>
 * Semantically a user profile (for a valid user) always "exists" even if it has not been created
 * in the repository yet.
 * <p>
 * This is <em>not</em> typical.
 * <p>
 * The security constraints are such that a profile will be returned only for the currently
 * authenticated user, i.e. this service does not allow for a particular profile to be retrieved
 * even if its unique identifier is known.
 * <p>
 * This is <em>not</em> typical either.
 * <p>
 * The profile information could just be kept with the user account information, but they are kept
 * separate so as not to blur responsibilities - i.e. the user account data is deemed "system"
 * data, whereas the profile is more like "application" data.
 * <p>
 * To simplify this a little bit, the profile used the same unique identifier as the user account.
 * <p>
 * {@link RestController} adds {@link Controller} and {@link ResponseBody} by default.
 */
@RestController
@RequestMapping("profile")
public class ProfileController {

    /**
     * Log.
     */
    private final Logger logger = LoggerFactory.getLogger(ProfileController.class);

    /**
     * Repository containing Profile resources.
     */
    @Autowired
// Path: src/main/java/uk/co/caprica/bootlace/data/mongo/profile/ProfileRepository.java
// public interface ProfileRepository extends MongoRepository<Profile, String> {
// 
// }
// 
// Path: src/main/java/uk/co/caprica/bootlace/domain/profile/Profile.java
// @Document
// public class Profile extends AbstractAuditableEntity {
// 
//     @NotNull
//     private String forename;
// 
//     @NotNull
//     private String surname;
// 
//     @NotNull
//     private String email;
// 
//     public Profile() {
//     }
// 
//     public String getForename() {
//         return forename;
//     }
// 
//     public void setForename(String forename) {
//         this.forename = forename;
//     }
// 
//     public String getSurname() {
//         return surname;
//     }
// 
//     public void setSurname(String surname) {
//         this.surname = surname;
//     }
// 
//     public String getEmail() {
//         return email;
//     }
// 
//     public void setEmail(String email) {
//         this.email = email;
//     }
// 
//     @Override
//     public String toString() {
//         return toStringHelper()
//             .add("forename", forename)
//             .add("surname", surname)
//             .add("email", email)
//             .toString();
//     }
// 
// }
// 
// Path: src/main/java/uk/co/caprica/bootlace/security/domain/UserWithId.java
// public final class UserWithId extends User {
// 
//     /**
//      * The database user identifier.
//      */
//     private final String id;
// 
//     /**
//      * Create a user.
//      *
//      * @param id database user identifier
//      */
//     public UserWithId(String username, String password, boolean enabled, boolean accountNonExpired, boolean credentialsNonExpired, boolean accountNonLocked, Collection<? extends GrantedAuthority> authorities, String id) {
//         super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities);
//         this.id = id;
//     }
// 
//     /**
//      * Get the database identifier for the user.
//      *
//      * @return unique user identifier
//      */
//     public String getId() {
//         return id;
//     }
// 
// }


// Path: src/main/java/uk/co/caprica/bootlace/controller/profile/ProfileController.java
import org.springframework.web.bind.annotation.RestController;
import uk.co.caprica.bootlace.data.mongo.profile.ProfileRepository;
import uk.co.caprica.bootlace.domain.profile.Profile;
import uk.co.caprica.bootlace.security.domain.UserWithId;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.web.bind.annotation.AuthenticationPrincipal;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/*
 * This file is part of Bootlace.
 *
 * Copyright (C) 2015
 * Caprica Software Limited (capricasoftware.co.uk)
 *
 * 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 uk.co.caprica.bootlace.controller.profile;



/**
 * Web-service controller for Profile resources.
 * <p>
 * A profile is basic personal data associated with an application user.
 * <p>
 * Semantically a user profile (for a valid user) always "exists" even if it has not been created
 * in the repository yet.
 * <p>
 * This is <em>not</em> typical.
 * <p>
 * The security constraints are such that a profile will be returned only for the currently
 * authenticated user, i.e. this service does not allow for a particular profile to be retrieved
 * even if its unique identifier is known.
 * <p>
 * This is <em>not</em> typical either.
 * <p>
 * The profile information could just be kept with the user account information, but they are kept
 * separate so as not to blur responsibilities - i.e. the user account data is deemed "system"
 * data, whereas the profile is more like "application" data.
 * <p>
 * To simplify this a little bit, the profile used the same unique identifier as the user account.
 * <p>
 * {@link RestController} adds {@link Controller} and {@link ResponseBody} by default.
 */
@RestController
@RequestMapping("profile")
public class ProfileController {

    /**
     * Log.
     */
    private final Logger logger = LoggerFactory.getLogger(ProfileController.class);

    /**
     * Repository containing Profile resources.
     */
    @Autowired
    private ProfileRepository profileRepository;