mirror of
				https://github.com/Frooodle/Stirling-PDF.git
				synced 2025-11-01 01:21:18 +01:00 
			
		
		
		
	Merge pull request #1394 from Stirling-Tools/disableConfigUpdater
Disable config updater
This commit is contained in:
		
						commit
						7b08d98232
					
				@ -7,7 +7,6 @@ import java.net.URISyntaxException;
 | 
			
		||||
import java.nio.file.Files;
 | 
			
		||||
import java.nio.file.Path;
 | 
			
		||||
import java.nio.file.Paths;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import org.springframework.context.ApplicationContextInitializer;
 | 
			
		||||
@ -55,7 +54,8 @@ public class ConfigInitializer
 | 
			
		||||
            //
 | 
			
		||||
            //            List<String> templateLines = Files.readAllLines(templatePath);
 | 
			
		||||
            //            List<String> userLines =
 | 
			
		||||
//                    Files.exists(userPath) ? Files.readAllLines(userPath) : new ArrayList<>();
 | 
			
		||||
            //                    Files.exists(userPath) ? Files.readAllLines(userPath) : new
 | 
			
		||||
            // ArrayList<>();
 | 
			
		||||
            //
 | 
			
		||||
            //            List<String> resultLines = new ArrayList<>();
 | 
			
		||||
            //            int position = 0;
 | 
			
		||||
 | 
			
		||||
@ -1,16 +1,18 @@
 | 
			
		||||
package stirling.software.SPDF.config;
 | 
			
		||||
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import java.io.InputStream;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
import org.springframework.core.io.Resource;
 | 
			
		||||
import org.springframework.core.io.ResourceLoader;
 | 
			
		||||
import org.thymeleaf.IEngineConfiguration;
 | 
			
		||||
import org.thymeleaf.templateresolver.AbstractConfigurableTemplateResolver;
 | 
			
		||||
import org.thymeleaf.templateresource.ClassLoaderTemplateResource;
 | 
			
		||||
import org.thymeleaf.templateresource.FileTemplateResource;
 | 
			
		||||
import org.thymeleaf.templateresource.ITemplateResource;
 | 
			
		||||
 | 
			
		||||
import stirling.software.SPDF.model.InputStreamTemplateResource;
 | 
			
		||||
 | 
			
		||||
public class FileFallbackTemplateResolver extends AbstractConfigurableTemplateResolver {
 | 
			
		||||
 | 
			
		||||
    private final ResourceLoader resourceLoader;
 | 
			
		||||
@ -40,9 +42,13 @@ public class FileFallbackTemplateResolver extends AbstractConfigurableTemplateRe
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return new ClassLoaderTemplateResource(
 | 
			
		||||
                Thread.currentThread().getContextClassLoader(),
 | 
			
		||||
                "classpath:/templates/" + resourceName,
 | 
			
		||||
                characterEncoding);
 | 
			
		||||
        InputStream inputStream =
 | 
			
		||||
                Thread.currentThread()
 | 
			
		||||
                        .getContextClassLoader()
 | 
			
		||||
                        .getResourceAsStream("templates/" + resourceName);
 | 
			
		||||
        if (inputStream != null) {
 | 
			
		||||
            return new InputStreamTemplateResource(inputStream, "UTF-8");
 | 
			
		||||
        }
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -231,7 +231,8 @@ public class UserController {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        userService.saveUser(username, password, role, forceChange);
 | 
			
		||||
        return new RedirectView("/addUsers",true); // Redirect to account page after adding the user
 | 
			
		||||
        return new RedirectView(
 | 
			
		||||
                "/addUsers", true); // Redirect to account page after adding the user
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @PreAuthorize("hasRole('ROLE_ADMIN')")
 | 
			
		||||
@ -270,7 +271,8 @@ public class UserController {
 | 
			
		||||
        User user = userOpt.get();
 | 
			
		||||
 | 
			
		||||
        userService.changeRole(user, role);
 | 
			
		||||
        return new RedirectView("/addUsers",true); // Redirect to account page after adding the user
 | 
			
		||||
        return new RedirectView(
 | 
			
		||||
                "/addUsers", true); // Redirect to account page after adding the user
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @PreAuthorize("hasRole('ROLE_ADMIN')")
 | 
			
		||||
 | 
			
		||||
@ -0,0 +1,45 @@
 | 
			
		||||
package stirling.software.SPDF.model;
 | 
			
		||||
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import java.io.InputStream;
 | 
			
		||||
import java.io.InputStreamReader;
 | 
			
		||||
import java.io.Reader;
 | 
			
		||||
 | 
			
		||||
import org.thymeleaf.templateresource.ITemplateResource;
 | 
			
		||||
 | 
			
		||||
public class InputStreamTemplateResource implements ITemplateResource {
 | 
			
		||||
    private InputStream inputStream;
 | 
			
		||||
    private String characterEncoding;
 | 
			
		||||
 | 
			
		||||
    public InputStreamTemplateResource(InputStream inputStream, String characterEncoding) {
 | 
			
		||||
        this.inputStream = inputStream;
 | 
			
		||||
        this.characterEncoding = characterEncoding;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Reader reader() throws IOException {
 | 
			
		||||
        return new InputStreamReader(inputStream, characterEncoding);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ITemplateResource relative(String relativeLocation) {
 | 
			
		||||
        // Implement logic for relative resources, if needed
 | 
			
		||||
        throw new UnsupportedOperationException("Relative resources not supported");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getDescription() {
 | 
			
		||||
        return "InputStream resource [Stream]";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getBaseName() {
 | 
			
		||||
        return "streamResource";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean exists() {
 | 
			
		||||
        // TODO Auto-generated method stub
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user