All Downloads are FREE. Search and download functionalities are using the official Maven repository.

base.template.CustomTemplate Maven / Gradle / Ivy

package base.template;

import java.io.IOException;
import java.io.UnsupportedEncodingException;

import base.jee.api.API;
import base.security.User;

public class CustomTemplate extends Template {

	public Template defaultTemplate;
	private API api;

	public CustomTemplate(API api, String name, Template defaultTemplate) throws UnsupportedEncodingException {
		super(name);
		this.api = api;
		this.defaultTemplate = defaultTemplate;

		// Copy all resources from the default template, as the base starting point
		for(Resource r : defaultTemplate.getResources()) {
			this.defineResource(r.getName(), r.getData(), r.isBinary());
		}

		// Load any custom resources from the data store
		//TODO: Complete
	}

	public void updateResource(User user, String name, byte[] data, boolean binary) throws IOException {
		api.upsertTemplateResource(user, getName(), name, data, binary);

		Resource resource = new Resource(name, data, binary);
		resources.put(name, resource);
		resourceList = resources.values();

		if(!binary) {
			definePage(name, data);
		}

	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy