Last active
December 18, 2015 00:39
-
-
Save vil1/5698157 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.fullsix.edito.protocol.site; | |
import com.fullsix.edito.api.Channel; | |
import com.fullsix.edito.api.PublicationMethod; | |
import com.google.common.collect.ImmutableSet; | |
import javax.annotation.concurrent.Immutable; | |
import java.io.Serializable; | |
import java.net.URL; | |
import java.util.Set; | |
/** | |
* @author Valentin Kasas | |
*/ | |
@Immutable | |
public class CreateSite implements Serializable { | |
public final String name; | |
public final URL url; | |
public final String description; | |
public final String elementsPath; | |
public final String stylesheetsPath; | |
public final boolean absolute; | |
public final Set<PublicationMethod> publicationMethods; | |
public final Set<Channel> channels; | |
public CreateSite(String name, URL url, String description, String elementsPath, String stylesheetsPath, boolean absolute, Set<PublicationMethod> publicationMethods, Set<Channel> channels) { | |
this.name = name; | |
this.url = url; | |
this.description = description; | |
this.elementsPath = elementsPath; | |
this.stylesheetsPath = stylesheetsPath; | |
this.absolute = absolute; | |
this.publicationMethods = ImmutableSet.copyOf(publicationMethods); | |
this.channels = ImmutableSet.copyOf(channels); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.fullsix.edito.protocol.site; | |
import com.fullsix.edito.api.Channel; | |
import com.fullsix.edito.api.PublicationMethod; | |
import com.fullsix.edito.protocol.AbstractProtocolCommandBuilder; | |
import java.net.URL; | |
import java.util.Collections; | |
import java.util.Set; | |
/** | |
* @author Valentin Kasas | |
*/ | |
public class CreateSiteBuilder extends AbstractProtocolCommandBuilder<SiteProtocol> { | |
String name; | |
URL url; | |
String description; | |
String elementsPath; | |
String stylesheetsPath; | |
boolean absolute; | |
Set<PublicationMethod> publicationMethods; | |
Set<Channel> channels; | |
public CreateSiteBuilder name(String name){ | |
this.name = name; | |
return this; | |
} | |
public CreateSiteBuilder url(URL url){ | |
this.url = url; | |
return this; | |
} | |
public CreateSiteBuilder description(String description){ | |
this.description = description; | |
return this; | |
} | |
public CreateSiteBuilder elementsPath(String elementsPath){ | |
this.elementsPath = elementsPath; | |
return this; | |
} | |
public CreateSiteBuilder stylesheetsPath(String stylesheetsPath){ | |
this.stylesheetsPath = stylesheetsPath; | |
return this; | |
} | |
public CreateSiteBuilder absolute(boolean absolute){ | |
this.absolute = absolute; | |
return this; | |
} | |
public CreateSiteBuilder publicationMethods(Set<PublicationMethod> publicationMethods){ | |
this.publicationMethods = publicationMethods; | |
return this; | |
} | |
public CreateSiteBuilder channels(Set<Channel> channels){ | |
this.channels = channels; | |
return this; | |
} | |
public CreateSiteBuilder(SiteProtocol protocol) { | |
super(protocol); | |
this.publicationMethods = Collections.emptySet(); | |
this.channels = Collections.emptySet(); | |
} | |
public void submit(){ | |
protocol.submit(new CreateSite(name, url, description, elementsPath, stylesheetsPath, absolute, publicationMethods, channels)); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.fullsix.edito.protocol.site; | |
import com.fullsix.edito.api.Site; | |
import com.fullsix.edito.api.exceptions.AccessDeniedException; | |
import com.fullsix.edito.api.exceptions.FatalException; | |
import com.fullsix.edito.api.exceptions.ItemExistenceException; | |
/** | |
* @author Valentin Kasas | |
*/ | |
public interface SiteProtocol { | |
public CreateSiteBuilder createSite(); | |
void submit(CreateSite request) throws FatalException, AccessDeniedException, ItemExistenceException; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.fullsix.edito.protocol.site; | |
import com.fullsix.edito.api.Channel; | |
import com.fullsix.edito.api.PublicationMethod; | |
import com.fullsix.edito.api.Site; | |
import com.fullsix.edito.api.exceptions.AccessDeniedException; | |
import com.fullsix.edito.api.exceptions.FatalException; | |
import com.fullsix.edito.api.exceptions.ItemExistenceException; | |
import java.net.URL; | |
import java.util.Set; | |
/** | |
* @author Valentin Kasas | |
*/ | |
public interface SiteProtocolLegacyAdapter { | |
/** | |
* Creates and initializes a new Site instance : | |
* - creates and stores a new Site entity with the given parameters | |
* - creates the site's root node as a folder with root-folder template, named after the given site name | |
* - creates the medialib root node as a folder with root-medialib-folder template, named media | |
* - grants all permissions on these two nodes to the administrator group | |
* - grants READ permission on these two nodes to the everyone group | |
* | |
* @param name the name of the created site | |
* @param url the URL of the created site | |
* @param description the resource key for the description of the created site | |
* @param elementsPath the path where static elements will be located | |
* @param stylesheetsPath the path where the stylesheet will be located | |
* @param absolute if true, elementsPath and stylesheetsPath will be considered as absolute paths, else they will be relative to the webapp context path | |
* @param publicationMethods the (possibly empty) set of publication methods to be attached to the site | |
* @param channels the (possibly empty) set of channels to be attached to the site | |
* @throws com.fullsix.edito.api.exceptions.FatalException | |
* @throws com.fullsix.edito.api.exceptions.ItemExistenceException | |
* @throws com.fullsix.edito.api.exceptions.AccessDeniedException | |
*/ | |
void addSite(String name, URL url, String description, String elementsPath, String stylesheetsPath, boolean absolute, Set<PublicationMethod> publicationMethods, Set<Channel> channels) throws FatalException, ItemExistenceException, AccessDeniedException; | |
Site updateSite(Site site) throws FatalException, ItemExistenceException, AccessDeniedException; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment