/*
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see http://www.gnu.org/licenses/
 */
package org.phenotips.data.permissions.rest.internal.utils;

import org.phenotips.data.PatientRepository;
import org.phenotips.data.permissions.AccessLevel;
import org.phenotips.data.permissions.PermissionsManager;

import org.xwiki.component.annotation.Component;
import org.xwiki.users.UserManager;

import javax.inject.Inject;
import javax.ws.rs.WebApplicationException;

import org.slf4j.Logger;

import groovy.lang.Singleton;

/**
 * Default implementation of {@link SecureContextFactory}. The purpose is to reduce the number of common injections
 * between default implementations of the REST resources.
 *
 * @version $Id$
 * @since 1.3M2
 */
@Component
@Singleton
public class DefaultSecureContextFactory implements SecureContextFactory
{
    @Inject
    private Logger logger;

    @Inject
    private PatientRepository repository;

    @Inject
    private UserManager users;

    @Inject
    private PermissionsManager manager;

    @Override
    public PatientAccessContext getContext(String patientId, String minimumAccessLevel) throws WebApplicationException
    {
        AccessLevel level = this.manager.resolveAccessLevel(minimumAccessLevel);
        return new PatientAccessContext(patientId, level, this.repository, this.users, this.manager, this.logger);
    }
}

@@ -1108,16 +1108,47 @@
 Inject;%0A
+import javax.inject.Singleton;%0A
 import j
@@ -1214,39 +1214,8 @@
 r;%0A%0A
-import groovy.lang.Singleton;%0A%0A
 /**%0A

Use the right @Singleton class