Kleinere Korrekturen
git-svn-id: https://svn.libreccm.org/ccm/trunk@1069 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
a8e183a761
commit
3dad87a242
|
|
@ -41,20 +41,20 @@ import java.util.Date;
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class PublicPersonalProfileCreate extends PageCreate {
|
public class PublicPersonalProfileCreate extends PageCreate {
|
||||||
|
|
||||||
private static final String SELECTED_PERSON = "selectedPerson";
|
private static final String SELECTED_PERSON = "selectedPerson";
|
||||||
private static final PublicPersonalProfileConfig config =
|
private static final PublicPersonalProfileConfig config =
|
||||||
new PublicPersonalProfileConfig();
|
new PublicPersonalProfileConfig();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
config.load();
|
config.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
public PublicPersonalProfileCreate(final ItemSelectionModel itemModel,
|
public PublicPersonalProfileCreate(final ItemSelectionModel itemModel,
|
||||||
final CreationSelector parent) {
|
final CreationSelector parent) {
|
||||||
super(itemModel, parent);
|
super(itemModel, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addWidgets() {
|
public void addWidgets() {
|
||||||
//super.addWidgets();
|
//super.addWidgets();
|
||||||
|
|
@ -67,19 +67,19 @@ public class PublicPersonalProfileCreate extends PageCreate {
|
||||||
add(new Label(type.getLabel()));
|
add(new Label(type.getLabel()));
|
||||||
add(new Label(GlobalizationUtil.globalize("cms.ui.language.field")));
|
add(new Label(GlobalizationUtil.globalize("cms.ui.language.field")));
|
||||||
add(new LanguageWidget(LANGUAGE));
|
add(new LanguageWidget(LANGUAGE));
|
||||||
|
|
||||||
add(new Label(PublicPersonalProfileGlobalizationUtil.globalize(
|
add(new Label(PublicPersonalProfileGlobalizationUtil.globalize(
|
||||||
"publicpersonalprofile.ui.create.select_person")));
|
"publicpersonalprofile.ui.create.select_person")));
|
||||||
ParameterModel ownerModel =
|
ParameterModel ownerModel =
|
||||||
new StringParameter(PublicPersonalProfile.OWNER);
|
new StringParameter(PublicPersonalProfile.OWNER);
|
||||||
SingleSelect ownerSelect = new SingleSelect(ownerModel);
|
SingleSelect ownerSelect = new SingleSelect(ownerModel);
|
||||||
ownerSelect.addValidationListener(new NotNullValidationListener());
|
ownerSelect.addValidationListener(new NotNullValidationListener());
|
||||||
|
|
||||||
String personType = config.getPersonType();
|
String personType = config.getPersonType();
|
||||||
if ((personType == null) || (personType.isEmpty())) {
|
if ((personType == null) || (personType.isEmpty())) {
|
||||||
personType = "com.arsdigita.cms.contenttypes.GenericPerson";
|
personType = "com.arsdigita.cms.contenttypes.GenericPerson";
|
||||||
}
|
}
|
||||||
|
|
||||||
ContentTypeCollection types = ContentType.getAllContentTypes();
|
ContentTypeCollection types = ContentType.getAllContentTypes();
|
||||||
types.addFilter(String.format("className = '%s'", personType));
|
types.addFilter(String.format("className = '%s'", personType));
|
||||||
if (types.size() == 0) {
|
if (types.size() == 0) {
|
||||||
|
|
@ -98,7 +98,7 @@ public class PublicPersonalProfileCreate extends PageCreate {
|
||||||
getFullName()));
|
getFullName()));
|
||||||
}
|
}
|
||||||
add(ownerSelect);
|
add(ownerSelect);
|
||||||
|
|
||||||
if (!ContentSection.getConfig().getHideLaunchDate()) {
|
if (!ContentSection.getConfig().getHideLaunchDate()) {
|
||||||
add(new Label(GlobalizationUtil.globalize(
|
add(new Label(GlobalizationUtil.globalize(
|
||||||
"cms.ui.authoring.page_launch_date")));
|
"cms.ui.authoring.page_launch_date")));
|
||||||
|
|
@ -115,64 +115,91 @@ public class PublicPersonalProfileCreate extends PageCreate {
|
||||||
add(launchDate);
|
add(launchDate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validate(FormSectionEvent fse) throws FormProcessException {
|
public void validate(FormSectionEvent fse) throws FormProcessException {
|
||||||
Folder folder = m_parent.getFolder(fse.getPageState());
|
Folder folder = m_parent.getFolder(fse.getPageState());
|
||||||
Assert.exists(folder);
|
Assert.exists(folder);
|
||||||
String id = (String) fse.getFormData().get(
|
String id = (String) fse.getFormData().get(
|
||||||
PublicPersonalProfile.OWNER);
|
PublicPersonalProfile.OWNER);
|
||||||
|
|
||||||
if ((id == null) || id.trim().isEmpty()) {
|
if ((id == null) || id.trim().isEmpty()) {
|
||||||
fse.getFormData().addError(PublicPersonalProfileGlobalizationUtil.
|
fse.getFormData().addError(PublicPersonalProfileGlobalizationUtil.
|
||||||
globalize("publicpersonalprofile.ui.person.required"));
|
globalize("publicpersonalprofile.ui.person.required"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GenericPerson owner = new GenericPerson(new BigDecimal(id));
|
GenericPerson owner = new GenericPerson(new BigDecimal(id));
|
||||||
|
|
||||||
validateNameUniqueness(folder,
|
validateNameUniqueness(folder,
|
||||||
fse,
|
fse,
|
||||||
String.format("%s-profile",
|
String.format("%s-profile",
|
||||||
GenericPerson.urlSave(
|
GenericPerson.urlSave(
|
||||||
owner.getFullName())));
|
owner.getFullName())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void process(FormSectionEvent fse) throws FormProcessException {
|
public void process(FormSectionEvent fse) throws FormProcessException {
|
||||||
final FormData data = fse.getFormData();
|
final FormData data = fse.getFormData();
|
||||||
final PageState state = fse.getPageState();
|
final PageState state = fse.getPageState();
|
||||||
final ContentSection section = m_parent.getContentSection(state);
|
final ContentSection section = m_parent.getContentSection(state);
|
||||||
final Folder folder = m_parent.getFolder(state);
|
final Folder folder = m_parent.getFolder(state);
|
||||||
|
|
||||||
Assert.exists(section, ContentSection.class);
|
Assert.exists(section, ContentSection.class);
|
||||||
|
|
||||||
String id = (String) fse.getFormData().get(
|
String id = (String) fse.getFormData().get(
|
||||||
PublicPersonalProfile.OWNER);
|
PublicPersonalProfile.OWNER);
|
||||||
|
|
||||||
GenericPerson owner = new GenericPerson(new BigDecimal(id));
|
GenericPerson owner = new GenericPerson(new BigDecimal(id));
|
||||||
String name = String.format("%s-profile",
|
String name = String.format("%s-profile",
|
||||||
GenericPerson.urlSave(owner.getFullName()));
|
GenericPerson.urlSave(owner.getFullName()));
|
||||||
String title = String.format("%s (Profil)", owner.getFullName());
|
String title = String.format("%s (Profil)", owner.getFullName());
|
||||||
|
|
||||||
final ContentPage item = createContentPage(state);
|
final ContentPage item = createContentPage(state);
|
||||||
item.setLanguage((String) data.get(LANGUAGE));
|
item.setLanguage((String) data.get(LANGUAGE));
|
||||||
item.setName(name);
|
item.setName(name);
|
||||||
item.setTitle(title);
|
item.setTitle(title);
|
||||||
if (!ContentSection.getConfig().getHideLaunchDate()) {
|
if (!ContentSection.getConfig().getHideLaunchDate()) {
|
||||||
item.setLaunchDate((Date) data.get(LAUNCH_DATE));
|
item.setLaunchDate((Date) data.get(LAUNCH_DATE));
|
||||||
}
|
}
|
||||||
|
|
||||||
final ContentBundle bundle = new ContentBundle(item);
|
final ContentBundle bundle = new ContentBundle(item);
|
||||||
bundle.setParent(folder);
|
bundle.setParent(folder);
|
||||||
bundle.setContentSection(m_parent.getContentSection(state));
|
bundle.setContentSection(m_parent.getContentSection(state));
|
||||||
bundle.save();
|
bundle.save();
|
||||||
|
|
||||||
PublicPersonalProfile profile = new PublicPersonalProfile(item.getOID());
|
PublicPersonalProfile profile = new PublicPersonalProfile(item.getOID());
|
||||||
profile.setOwner(owner);
|
profile.setOwner(owner);
|
||||||
profile.setProfileUrl(owner.getSurname().toLowerCase());
|
//profile.setProfileUrl(owner.getSurname().toLowerCase());
|
||||||
|
profile.setProfileUrl(createProfileUrl(owner));
|
||||||
profile.save();
|
profile.save();
|
||||||
|
|
||||||
m_parent.editItem(state, item);
|
m_parent.editItem(state, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String createProfileUrl(final GenericPerson owner) {
|
||||||
|
String profileUrl = owner.getSurname().toLowerCase();
|
||||||
|
int i = 1;
|
||||||
|
|
||||||
|
DataCollection profiles = SessionManager.getSession().retrieve(
|
||||||
|
PublicPersonalProfile.BASE_DATA_OBJECT_TYPE);
|
||||||
|
profiles.addFilter(String.format("profileUrl = '%s'",
|
||||||
|
profileUrl));
|
||||||
|
profiles.addFilter(String.format("version = '%s'", ContentItem.DRAFT));
|
||||||
|
|
||||||
|
while (profiles.size() > 0) {
|
||||||
|
i++;
|
||||||
|
|
||||||
|
profileUrl = String.format("%s%d",
|
||||||
|
owner.getSurname().toLowerCase(),
|
||||||
|
i);
|
||||||
|
profiles.reset();
|
||||||
|
profiles.addFilter(String.format("profileUrl = '%s'",
|
||||||
|
profileUrl));
|
||||||
|
profiles.addFilter(
|
||||||
|
String.format("version = '%s'", ContentItem.DRAFT));
|
||||||
|
}
|
||||||
|
|
||||||
|
return profileUrl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,8 @@ public class PublicPersonalProfilePropertyForm
|
||||||
if ((profile != null)
|
if ((profile != null)
|
||||||
&& getSaveCancelSection().getSaveButton().isSelected(state)) {
|
&& getSaveCancelSection().getSaveButton().isSelected(state)) {
|
||||||
profile.setProfileUrl(((String) data.get(
|
profile.setProfileUrl(((String) data.get(
|
||||||
PublicPersonalProfile.PROFILE_URL)).toLowerCase());
|
PublicPersonalProfile.PROFILE_URL)).
|
||||||
|
toLowerCase());
|
||||||
|
|
||||||
profile.save();
|
profile.save();
|
||||||
}
|
}
|
||||||
|
|
@ -91,24 +92,40 @@ public class PublicPersonalProfilePropertyForm
|
||||||
public void validate(FormSectionEvent fse) throws FormProcessException {
|
public void validate(FormSectionEvent fse) throws FormProcessException {
|
||||||
final PageState state = fse.getPageState();
|
final PageState state = fse.getPageState();
|
||||||
final FormData data = fse.getFormData();
|
final FormData data = fse.getFormData();
|
||||||
|
|
||||||
|
|
||||||
String profilesUrl = (String) data.get(PublicPersonalProfile.PROFILE_URL);
|
String profilesUrl =
|
||||||
|
(String) data.get(PublicPersonalProfile.PROFILE_URL);
|
||||||
if ((profilesUrl == null) || profilesUrl.isEmpty()) {
|
if ((profilesUrl == null) || profilesUrl.isEmpty()) {
|
||||||
data.addError(PublicPersonalProfileGlobalizationUtil.globalize("publicpersonalprofile.ui.profile_url.required"));
|
data.addError(PublicPersonalProfileGlobalizationUtil.globalize(
|
||||||
|
"publicpersonalprofile.ui.profile_url.required"));
|
||||||
}
|
}
|
||||||
|
|
||||||
DataCollection profiles = SessionManager.getSession().retrieve(PublicPersonalProfile.BASE_DATA_OBJECT_TYPE);
|
if ("admin".equalsIgnoreCase(profilesUrl)) {
|
||||||
profiles.addFilter(String.format("profileUrl = '%s'", ((String)data.get(PublicPersonalProfile.PROFILE_URL)).toLowerCase()));
|
data.addError(PublicPersonalProfileGlobalizationUtil.globalize(
|
||||||
|
"publicpersonalprofile.ui.profile_url.reserved"));
|
||||||
|
}
|
||||||
|
|
||||||
|
DataCollection profiles = SessionManager.getSession().retrieve(
|
||||||
|
PublicPersonalProfile.BASE_DATA_OBJECT_TYPE);
|
||||||
|
profiles.addFilter(String.format("profileUrl = '%s'",
|
||||||
|
((String) data.get(
|
||||||
|
PublicPersonalProfile.PROFILE_URL)).
|
||||||
|
toLowerCase()));
|
||||||
profiles.addFilter(String.format("version = '%s'", ContentItem.DRAFT));
|
profiles.addFilter(String.format("version = '%s'", ContentItem.DRAFT));
|
||||||
if (profiles.size() > 1) {
|
if (profiles.size() > 1) {
|
||||||
data.addError(PublicPersonalProfileGlobalizationUtil.globalize("publicpersonalprofile.ui.profile_url.already_in_use"));
|
data.addError(PublicPersonalProfileGlobalizationUtil.globalize(
|
||||||
} else if(profiles.size() == 1) {
|
"publicpersonalprofile.ui.profile_url.already_in_use"));
|
||||||
|
} else if (profiles.size() == 1) {
|
||||||
profiles.next();
|
profiles.next();
|
||||||
PublicPersonalProfile profile = (PublicPersonalProfile) DomainObjectFactory.newInstance(profiles.getDataObject());
|
PublicPersonalProfile profile =
|
||||||
|
(PublicPersonalProfile) DomainObjectFactory.
|
||||||
if (!(profile.getID().equals(itemModel.getSelectedItem(state).getID()))) {
|
newInstance(profiles.getDataObject());
|
||||||
data.addError(PublicPersonalProfileGlobalizationUtil.globalize("publicpersonalprofile.ui.profile_url.already_in_use"));
|
|
||||||
|
if (!(profile.getID().equals(
|
||||||
|
itemModel.getSelectedItem(state).getID()))) {
|
||||||
|
data.addError(PublicPersonalProfileGlobalizationUtil.globalize(
|
||||||
|
"publicpersonalprofile.ui.profile_url.already_in_use"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,3 +31,4 @@ publicpersonalprofile.ui.nav.remove.confirm=Do you really want to remove this na
|
||||||
publicpersonalprofile.ui.navitems.delete.confirm=Do you really want to delete this navigation entry?
|
publicpersonalprofile.ui.navitems.delete.confirm=Do you really want to delete this navigation entry?
|
||||||
publicpersonalprofile.ui.navitems.up=Up
|
publicpersonalprofile.ui.navitems.up=Up
|
||||||
publicpersonalprofile.ui.navitems.down=Down
|
publicpersonalprofile.ui.navitems.down=Down
|
||||||
|
publicpersonalprofile.ui.profile_url.reserved=The provided URL fragment is a reserved name, and can't be used.
|
||||||
|
|
|
||||||
|
|
@ -31,3 +31,4 @@ publicpersonalprofile.ui.nav.remove.confirm=Soll dieser Navigationspunkt wirklic
|
||||||
publicpersonalprofile.ui.navitems.delete.confirm=Soll dieser Navigationspunkt wirklich entfernt werden?
|
publicpersonalprofile.ui.navitems.delete.confirm=Soll dieser Navigationspunkt wirklich entfernt werden?
|
||||||
publicpersonalprofile.ui.navitems.up=Hoch
|
publicpersonalprofile.ui.navitems.up=Hoch
|
||||||
publicpersonalprofile.ui.navitems.down=Runter
|
publicpersonalprofile.ui.navitems.down=Runter
|
||||||
|
publicpersonalprofile.ui.profile_url.reserved=Das angegebene URL-Fragment ist ein reservierter Name und kann nicht verwendet werden.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue