Skip to content

Commit

Permalink
Issue 11652 saving text areas (#11667)
Browse files Browse the repository at this point in the history
* #11648 language fallback now works better

* #11652 removing field instanciation checks, moving data integrity to factory

* #11652 catching an NPE when user does not select a datatype

* #11652 deprecated old fieldAPI

* #11652
  • Loading branch information
wezell authored and jgambarios committed May 22, 2017
1 parent f15813d commit 3b2ce98
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ public abstract static class Builder implements FieldBuilder {

@Value.Check
public void check() {
super.check();


Preconditions.checkArgument(new FieldUtil().validDate(defaultValue()), this.getClass().getSimpleName() + " invalid defualt Value:" + defaultValue());

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public abstract static class Builder implements FieldBuilder {}

@Value.Check
public void check() {
super.check();

Preconditions.checkArgument(new FieldUtil().validDateTime(defaultValue()), this.getClass().getSimpleName() + " invalid defualt Value:" + defaultValue());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@
@Value.Immutable
public abstract class HostFolderField extends Field implements OnePerContentType {

@Value.Check
public void check() {
super.check();
if(iDate().before(legacyFieldDate))return;
Preconditions.checkArgument(indexed(),"Host Folder Fields must be indexed");
}

@Value.Default
@Override
public boolean indexed() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public List<SelectableValue> selectableValues() {

@Value.Check
public void check() {
super.check();

if(iDate().before(legacyFieldDate))return;
if(values()!=null){
String[] tempVals = StringUtil.split(values().replaceAll("\r\n","|").trim(), "|");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,7 @@ public String typeName(){
return LegacyFieldTypes.getLegacyName(TagField.class);
}

@Value.Check
public void check() {
super.check();
if(iDate().after(legacyFieldDate)){
Preconditions.checkArgument(indexed(),"Tag Fields must be indexed");
}
}

@Value.Default
@Override
public boolean indexed() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public Class type() {
@Value.Derived
@Override
public List<DataTypes> acceptedDataTypes(){
return ImmutableList.of(DataTypes.SYSTEM, DataTypes.LONG_TEXT);
return ImmutableList.of(DataTypes.LONG_TEXT);
}
@Value.Default
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public Class type() {
@Value.Derived
@Override
public List<DataTypes> acceptedDataTypes(){
return ImmutableList.of(DataTypes.LONG_TEXT,DataTypes.TEXT, DataTypes.FLOAT, DataTypes.INTEGER);
return ImmutableList.of(DataTypes.TEXT,DataTypes.LONG_TEXT, DataTypes.FLOAT, DataTypes.INTEGER);
}
@Value.Default
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import com.dotcms.contenttype.util.FieldUtil;
import com.dotcms.repackage.com.google.common.collect.ImmutableList;
import com.dotmarketing.util.UtilMethods;
import com.dotcms.repackage.com.google.common.base.Preconditions;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
Expand Down Expand Up @@ -40,9 +41,9 @@ public abstract static class Builder implements FieldBuilder {}

@Value.Check
public void check() {
super.check();

Preconditions.checkArgument(new FieldUtil().validTime(defaultValue()), this.getClass().getSimpleName() + " invalid defualt Value:" + defaultValue());

if(UtilMethods.isSet(defaultValue())){
Preconditions.checkArgument(new FieldUtil().validTime(defaultValue()), this.getClass().getSimpleName() + " invalid defualt Value:" + defaultValue());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private static String buildLegacyFieldContent(Field field){
return fieldContent;
}

private static Field transformToNew(com.dotmarketing.portlets.structure.model.Field oldField) {
private static Field transformToNew(final com.dotmarketing.portlets.structure.model.Field oldField) {
final String fieldType = oldField.getFieldType();

@SuppressWarnings("serial")
Expand Down Expand Up @@ -164,7 +164,7 @@ public String defaultValue() {

@Override
public DataTypes dataType() {
String dbType = oldField.getFieldContentlet().replaceAll("[0-9]", "");
String dbType = (oldField.getFieldContentlet()!=null) ? oldField.getFieldContentlet().replaceAll("[0-9]", "") : null;
if(!UtilMethods.isSet(dbType)){
return FieldBuilder.instanceOf(LegacyFieldTypes.getImplClass(fieldType)).acceptedDataTypes().get(0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ public static RelationshipAPI getRelationshipAPI(){
* Creates a single instance of the {@link FieldAPI} class.
*
* @return The {@link FieldAPI} class.
* @deprecated
*/
public static com.dotmarketing.portlets.structure.business.FieldAPI getFieldAPI(){
return (com.dotmarketing.portlets.structure.business.FieldAPI)getInstance(APIIndex.FIELD_API);
Expand Down

0 comments on commit 3b2ce98

Please sign in to comment.