Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #2121 - this was a merge issue. Changes to this file allows this ... #2148

Merged
merged 1 commit into from
Feb 20, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.dotmarketing.portlets.categories.model.Category;
import com.dotmarketing.portlets.contentlet.business.ContentletAPI;
import com.dotmarketing.portlets.contentlet.business.DotContentletStateException;
import com.dotmarketing.portlets.contentlet.business.DotContentletValidationException;
import com.dotmarketing.portlets.contentlet.model.Contentlet;
import com.dotmarketing.portlets.fileassets.business.FileAsset;
import com.dotmarketing.portlets.fileassets.business.FileAssetAPI;
Expand Down Expand Up @@ -102,7 +103,7 @@ public static User getUserFromId(String userId) throws DotDataException{
* @return Map<Relationship,List<Contentlet>>
* @throws DotSecurityException
**/
private static Map<Relationship,List<Contentlet>> getRelationships(Structure structure, Contentlet contentlet, String parametersOptions, User user) throws DotDataException, DotSecurityException{
private static Map<Relationship,List<Contentlet>> getRelationships(Structure structure, Contentlet contentlet, String parametersOptions,List<String> parametersName,List<String[]> values, User user) throws DotDataException, DotSecurityException{
LanguageAPI lAPI = APILocator.getLanguageAPI();
Map<Relationship, List<Contentlet>> contentRelationships = new HashMap<Relationship, List<Contentlet>>();
if(contentlet == null)
Expand All @@ -122,6 +123,19 @@ private static Map<Relationship,List<Contentlet>> getRelationships(Structure str
}
}
}
for(int i=0; i < parametersName.size(); i++){
String fieldname = parametersName.get(i);
String[] fieldValue = values.get(i);
if(fieldname.indexOf(rel.getRelationTypeValue()) != -1){
List<Contentlet> cons = conAPI.findContentletsByIdentifiers(fieldValue, true, lAPI.getDefaultLanguage().getId(), user, true);
if(cons.size()>0){
if(contentRelationships.containsKey(rel)){
cons.addAll(contentRelationships.get(rel));
}
contentRelationships.put(rel, cons);
}
}
}
}
return contentRelationships;
}
Expand Down Expand Up @@ -454,7 +468,7 @@ public static Contentlet createContent(Structure st, ArrayList<Category> cats, S
/**
* Get the required relationships
*/
Map<Relationship,List<Contentlet>> relationships = SubmitContentUtil.getRelationships(st, contentlet, options, user);
Map<Relationship,List<Contentlet>> relationships = SubmitContentUtil.getRelationships(st, contentlet, options,parametersName,values, user);


/**
Expand All @@ -471,14 +485,19 @@ public static Contentlet createContent(Structure st, ArrayList<Category> cats, S
if(fileParameters.size() > 0){
for(Map<String,Object> value : fileParameters){
Field field = (Field)value.get("field");
java.io.File file = (java.io.File)value.get(field.getVelocityVarName());
java.io.File file = (java.io.File)value.get("file");
if(file!=null){
try {
contentlet.setBinary(field.getVelocityVarName(), file);
} catch (IOException e) {

}
}
else if(field.isRequired()) {
DotContentletValidationException cve = new DotContentletValidationException("Contentlet's fields are not valid");
cve.addRequiredField(field);
throw cve;
}
}
}

Expand Down