You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by do...@apache.org on 2012/05/11 20:02:50 UTC
svn commit: r1337319 - in
/ofbiz/trunk/applications/content/src/org/ofbiz/content: ConvertTree.java
layout/LayoutEvents.java
Author: doogie
Date: Fri May 11 18:02:50 2012
New Revision: 1337319
URL: http://svn.apache.org/viewvc?rev=1337319&view=rev
Log:
FORMATTING: Combined split lines, removed a few blank lines, added {}
around single-stmt if, reindented a few things, added spaces after
casts.
Modified:
ofbiz/trunk/applications/content/src/org/ofbiz/content/ConvertTree.java
ofbiz/trunk/applications/content/src/org/ofbiz/content/layout/LayoutEvents.java
Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/ConvertTree.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/ConvertTree.java?rev=1337319&r1=1337318&r2=1337319&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/ConvertTree.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/ConvertTree.java Fri May 11 18:02:50 2012
@@ -70,15 +70,15 @@ In order ta make this service active add
String file = (String) context.get("file");
String errMsg = "", sucMsg= "";
GenericValue Entity = null;
- try {
- BufferedReader input = null;
- try {
- if (!UtilValidate.isEmpty(file)) {
- input = new BufferedReader(new FileReader(file));
- String line = null;
- int size=0;
- if (file != null) {
- int counterLine=0;
+ try {
+ BufferedReader input = null;
+ try {
+ if (!UtilValidate.isEmpty(file)) {
+ input = new BufferedReader(new FileReader(file));
+ String line = null;
+ int size = 0;
+ if (file != null) {
+ int counterLine = 0;
//Home Document
Entity = null;
Entity = delegator.makeValue("Content");
@@ -88,10 +88,10 @@ In order ta make this service active add
Entity.set("createdByUserLogin", userLogin.get("userLoginId"));
Entity.set("lastModifiedByUserLogin", userLogin.get("userLoginId"));
Entity.set("createdDate", UtilDateTime.nowTimestamp());
- Entity.set("lastUpdatedStamp",UtilDateTime.nowTimestamp());
- Entity.set("lastUpdatedTxStamp",UtilDateTime.nowTimestamp());
- Entity.set("createdStamp",UtilDateTime.nowTimestamp());
- Entity.set("createdTxStamp",UtilDateTime.nowTimestamp());
+ Entity.set("lastUpdatedStamp", UtilDateTime.nowTimestamp());
+ Entity.set("lastUpdatedTxStamp", UtilDateTime.nowTimestamp());
+ Entity.set("createdStamp", UtilDateTime.nowTimestamp());
+ Entity.set("createdTxStamp", UtilDateTime.nowTimestamp());
delegator.create(Entity);
Entity = null;
@@ -102,10 +102,10 @@ In order ta make this service active add
Entity.set("createdByUserLogin", userLogin.get("userLoginId"));
Entity.set("lastModifiedByUserLogin", userLogin.get("userLoginId"));
Entity.set("createdDate", UtilDateTime.nowTimestamp());
- Entity.set("lastUpdatedStamp",UtilDateTime.nowTimestamp());
- Entity.set("lastUpdatedTxStamp",UtilDateTime.nowTimestamp());
- Entity.set("createdStamp",UtilDateTime.nowTimestamp());
- Entity.set("createdTxStamp",UtilDateTime.nowTimestamp());
+ Entity.set("lastUpdatedStamp", UtilDateTime.nowTimestamp());
+ Entity.set("lastUpdatedTxStamp", UtilDateTime.nowTimestamp());
+ Entity.set("createdStamp", UtilDateTime.nowTimestamp());
+ Entity.set("createdTxStamp", UtilDateTime.nowTimestamp());
delegator.create(Entity);
Map<String, Object> contentAssoc = FastMap.newInstance();
@@ -116,34 +116,26 @@ In order ta make this service active add
dispatcher.runSync("createContentAssoc", contentAssoc);
int recordCount = 0;
while ((line = input.readLine()) != null) {//start line
- boolean hasFolder=true;
- String
- rootContent=null,
- contentId = null;
- counterLine++;
- if (counterLine>1) {
+ boolean hasFolder = true;
+ String rootContent = null, contentId = null; counterLine++;
+ if (counterLine > 1) {
size = line.length();
- String
- check = "\\",
- checkSubContent = ",",
- contentName = "",
- contentNameInprogress = "",
- data = line.substring(3,size);
+ String check = "\\", checkSubContent = ",", contentName = "", contentNameInprogress = "", data = line.substring(3, size);
//Debug.logInfo("======Data======"+data);
size = data.length();
List<GenericValue> contents = null;
for(int index = 0; index< size; index++) {//start character in line
boolean contentNameMatch = false;
- int contentAssocSize=0;
+ int contentAssocSize = 0;
List<GenericValue> contentAssocs = null;
- if (data.charAt(index) == check.charAt(0)||data.charAt(index)== checkSubContent.charAt(0)) {//store data
+ if (data.charAt(index) == check.charAt(0) || data.charAt(index) == checkSubContent.charAt(0)) {//store data
contentName = contentName + contentNameInprogress;
- if (contentName.length()>100) {
- contentName = contentName.substring(0,100);
+ if (contentName.length() > 100) {
+ contentName = contentName.substring(0, 100);
}
//check duplicate folder
- contents = delegator.findByAnd("Content", UtilMisc.toMap("contentName",contentName));
+ contents = delegator.findByAnd("Content", UtilMisc.toMap("contentName", contentName));
if (contents.size() > 0) {
GenericValue contentResult = contents.get(0);
contentId = contentResult.get("contentId").toString();
@@ -152,28 +144,27 @@ In order ta make this service active add
GenericValue contentResult = contents.get(0);
contentId = contentResult.get("contentId").toString();
if (rootContent != null) {
- contentAssocs= delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentId",contentId, "contentIdTo", rootContent));
- List<GenericValue> contentAssocCheck= delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentIdTo", rootContent));
+ contentAssocs = delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentId", contentId, "contentIdTo", rootContent));
+ List<GenericValue> contentAssocCheck = delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentIdTo", rootContent));
Iterator<GenericValue> contentAssChecks = contentAssocCheck.iterator();
while (contentAssChecks.hasNext() && contentNameMatch == false) {
- GenericValue contentAss = contentAssChecks.next();
- GenericValue contentcheck = delegator.findByPrimaryKey("Content",UtilMisc.toMap("contentId",contentAss.get("contentId")));
- if (contentcheck!=null) {
- if (contentcheck.get("contentName").equals(contentName) && contentNameMatch==false) {
- contentNameMatch = true;
- contentId = contentcheck.get("contentId").toString();
- }
- }
+ GenericValue contentAss = contentAssChecks.next();
+ GenericValue contentcheck = delegator.findByPrimaryKey("Content", UtilMisc.toMap("contentId", contentAss.get("contentId")));
+ if (contentcheck!=null) {
+ if (contentcheck.get("contentName").equals(contentName) && contentNameMatch == false) {
+ contentNameMatch = true;
+ contentId = contentcheck.get("contentId").toString();
+ }
+ }
}
} else {
rootContent = "HOME_DUCUMENT";
- contentAssocs= delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentId",contentId, "contentIdTo", rootContent));
-
+ contentAssocs = delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentId", contentId, "contentIdTo", rootContent));
}
- contentAssocSize=contentAssocs.size();
+ contentAssocSize = contentAssocs.size();
}
- if (contentAssocSize == 0 && contentNameMatch==false) {//New Root Content
+ if (contentAssocSize == 0 && contentNameMatch == false) {//New Root Content
Entity = null;
contentId = delegator.getNextSeqId("Content");
Entity = delegator.makeValue("Content");
@@ -183,93 +174,84 @@ In order ta make this service active add
Entity.set("createdByUserLogin", userLogin.get("userLoginId"));
Entity.set("lastModifiedByUserLogin", userLogin.get("userLoginId"));
Entity.set("createdDate", UtilDateTime.nowTimestamp());
- Entity.set("lastUpdatedStamp",UtilDateTime.nowTimestamp());
- Entity.set("lastUpdatedTxStamp",UtilDateTime.nowTimestamp());
- Entity.set("createdStamp",UtilDateTime.nowTimestamp());
- Entity.set("createdTxStamp",UtilDateTime.nowTimestamp());
+ Entity.set("lastUpdatedStamp", UtilDateTime.nowTimestamp());
+ Entity.set("lastUpdatedTxStamp", UtilDateTime.nowTimestamp());
+ Entity.set("createdStamp", UtilDateTime.nowTimestamp());
+ Entity.set("createdTxStamp", UtilDateTime.nowTimestamp());
delegator.create(Entity);
hasFolder = false;
} else {
- //Debug.logInfo("Content Name = [ "+contentId+"] already exist.");//ShoW log file
+ //Debug.logInfo("Content Name = [ " + contentId + "] already exist.");//ShoW log file
hasFolder = true;
}
//Relation Content
- if (rootContent==null) {
+ if (rootContent == null) {
rootContent = "HOME_DUCUMENT";
}
- contentAssocs = delegator.findByAnd("ContentAssoc",
- UtilMisc.toMap("contentId",contentId,"contentIdTo",rootContent,"contentAssocTypeId","TREE_CHILD"));
- if (contentAssocs.size()==0) {
- contentAssoc = FastMap.newInstance();
- contentAssoc.put("contentId", contentId);
- contentAssoc.put("contentAssocTypeId", "TREE_CHILD");
- contentAssoc.put("contentIdTo", rootContent);
- contentAssoc.put("userLogin", userLogin);
- dispatcher.runSync("createContentAssoc", contentAssoc);
- rootContent=contentId;
- } else {
- //Debug.logInfo("ContentAssoc [contentId= "+contentId+",contentIdTo="+rootContent+"] already exist.");//ShoW log file
- rootContent=contentId;
- }
+ contentAssocs = delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentId", contentId, "contentIdTo", rootContent, "contentAssocTypeId", "TREE_CHILD"));
+ if (contentAssocs.size() == 0) {
+ contentAssoc = FastMap.newInstance();
+ contentAssoc.put("contentId", contentId);
+ contentAssoc.put("contentAssocTypeId", "TREE_CHILD");
+ contentAssoc.put("contentIdTo", rootContent);
+ contentAssoc.put("userLogin", userLogin);
+ dispatcher.runSync("createContentAssoc", contentAssoc);
+ rootContent = contentId;
+ } else {
+ //Debug.logInfo("ContentAssoc [contentId= " + contentId + ", contentIdTo=" + rootContent + "] already exist.");//ShoW log file
+ rootContent=contentId;
+ }
contentName = "";
- contentNameInprogress="";
+ contentNameInprogress ="";
}
if (data.charAt(index)== checkSubContent.charAt(0)) {//Have sub content
createSubContent(index, data, rootContent, context, dctx);
- index=size;
+ index = size;
continue;
}
- if ((data.charAt(index))!= check.charAt(0)) {
- contentNameInprogress = contentNameInprogress.concat(Character.toString(data.charAt(index)));
- if (contentNameInprogress.length()>99) {
- contentName = contentName + contentNameInprogress;
- contentNameInprogress="";
- }
- }
+ if ((data.charAt(index)) != check.charAt(0)) {
+ contentNameInprogress = contentNameInprogress.concat(Character.toString(data.charAt(index)));
+ if (contentNameInprogress.length() > 99) {
+ contentName = contentName + contentNameInprogress;
+ contentNameInprogress ="";
+ }
+ }
}//end character in line
recordCount++;
- }
- }//end line
- sucMsg = "Convert Documents Tree Successful.<br/>Total : "+counterLine+" rows";
- }
- }
+ }
+ }//end line
+ sucMsg = "Convert Documents Tree Successful.<br/>Total : " + counterLine + " rows";
+ }
+ }
}
finally {
input.close();
}
return ServiceUtil.returnSuccess(sucMsg);
- } catch (IOException e) {
- errMsg = "IOException "+ UtilMisc.toMap("errMessage", e.toString());
- Debug.logError(e, errMsg, module);
- return ServiceUtil.returnError(errMsg);
- } catch (GenericServiceException e) {
- errMsg = "GenericServiceException "+ UtilMisc.toMap("errMessage", e.toString());
+ } catch (IOException e) {
+ errMsg = "IOException "+ UtilMisc.toMap("errMessage", e.toString());
Debug.logError(e, errMsg, module);
return ServiceUtil.returnError(errMsg);
- } catch (GenericEntityException e) {
- errMsg = "GenericEntityException "+ UtilMisc.toMap("errMessage", e.toString());
- Debug.logError(e, errMsg, module);
- e.printStackTrace();
- return ServiceUtil.returnError(errMsg);
- }
+ } catch (GenericServiceException e) {
+ errMsg = "GenericServiceException "+ UtilMisc.toMap("errMessage", e.toString());
+ Debug.logError(e, errMsg, module);
+ return ServiceUtil.returnError(errMsg);
+ } catch (GenericEntityException e) {
+ errMsg = "GenericEntityException "+ UtilMisc.toMap("errMessage", e.toString());
+ Debug.logError(e, errMsg, module);
+ e.printStackTrace();
+ return ServiceUtil.returnError(errMsg);
+ }
}
- public static Map<String,Object> createSubContent(int index,String line,String rootContent,
- Map<String, ? extends Object> context, DispatchContext dctx) {
+ public static Map<String,Object> createSubContent(int index, String line, String rootContent, Map<String, ? extends Object> context, DispatchContext dctx) {
Delegator delegator = dctx.getDelegator();
LocalDispatcher dispatcher = dctx.getDispatcher();
GenericValue userLogin = (GenericValue) context.get("userLogin");
- String
- subContents=null,
- check = ",",
- oldChar = "\"",
- newChar = "",
- contentNameInprogress = "",
- contentName = "",
- contentId =null;
+ String subContents = null, check = ",", oldChar = "\"", newChar = "", contentNameInprogress = "", contentName = "", contentId = null;
GenericValue Entity = null;
String errMsg = "", sucMsg= "";
- subContents = line.substring(index+1, line.length());
+ subContents = line.substring(index + 1, line.length());
subContents = subContents.replace(oldChar, newChar);
int size = subContents.length();
try {
@@ -281,13 +263,13 @@ In order ta make this service active add
if (contentName.length()>100) {
contentName = contentName.substring(0,100);
}
- List<GenericValue> contents = delegator.findByAnd("Content", UtilMisc.toMap("contentName",contentName),UtilMisc.toList("-contentId"));
- if (contents!=null) {
+ List<GenericValue> contents = delegator.findByAnd("Content", UtilMisc.toMap("contentName", contentName), UtilMisc.toList("-contentId"));
+ if (contents != null) {
Iterator<GenericValue> contentCheck = contents.iterator();
- while (contentCheck.hasNext() && contentNameMatch==false) {
+ while (contentCheck.hasNext() && contentNameMatch == false) {
GenericValue contentch = contentCheck.next();
- if (contentch!=null) {
- List<GenericValue> contentAssocsChecks = delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentId",contentch.get("contentId"), "contentIdTo", rootContent));
+ if (contentch != null) {
+ List<GenericValue> contentAssocsChecks = delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentId", contentch.get("contentId"), "contentIdTo", rootContent));
if (contentAssocsChecks.size() > 0) {
contentNameMatch = true;
}
@@ -295,12 +277,12 @@ In order ta make this service active add
}
}
contentId = null;
- if (contentNameMatch==false) {
+ if (contentNameMatch == false) {
//create DataResource
Map<String,Object> data = FastMap.newInstance();
data.put("userLogin", userLogin);
- String dataResourceId = (dispatcher.runSync("createDataResource",data)).get("dataResourceId").toString();
- //Debug.logInfo("==dataResourceId"+dataResourceId);
+ String dataResourceId = dispatcher.runSync("createDataResource", data).get("dataResourceId").toString();
+ //Debug.logInfo("==dataResourceId" + dataResourceId);
//create Content
contentId = delegator.getNextSeqId("Content");
@@ -313,10 +295,10 @@ In order ta make this service active add
Entity.set("createdByUserLogin", userLogin.get("userLoginId"));
Entity.set("lastModifiedByUserLogin", userLogin.get("userLoginId"));
Entity.set("createdDate", UtilDateTime.nowTimestamp());
- Entity.set("lastUpdatedStamp",UtilDateTime.nowTimestamp());
- Entity.set("lastUpdatedTxStamp",UtilDateTime.nowTimestamp());
- Entity.set("createdStamp",UtilDateTime.nowTimestamp());
- Entity.set("createdTxStamp",UtilDateTime.nowTimestamp());
+ Entity.set("lastUpdatedStamp", UtilDateTime.nowTimestamp());
+ Entity.set("lastUpdatedTxStamp", UtilDateTime.nowTimestamp());
+ Entity.set("createdStamp", UtilDateTime.nowTimestamp());
+ Entity.set("createdTxStamp", UtilDateTime.nowTimestamp());
delegator.create(Entity);
//Relation Content
@@ -331,23 +313,23 @@ In order ta make this service active add
contentNameInprogress="";
}
- if ((subContents.charAt(index))!= check.charAt(0)) {
- contentNameInprogress = contentNameInprogress.concat(Character.toString(subContents.charAt(index)));
- if (contentNameInprogress.length() > 99) {
- contentName = contentName + contentNameInprogress;
- contentNameInprogress="";
- }
+ if ((subContents.charAt(index) )!= check.charAt(0)) {
+ contentNameInprogress = contentNameInprogress.concat(Character.toString(subContents.charAt(index)));
+ if (contentNameInprogress.length() > 99) {
+ contentName = contentName + contentNameInprogress;
+ contentNameInprogress = "";
}
- //lastItem
- if (index==size-1) {
- contentNameMatch = false;
- List<GenericValue> contents = delegator.findByAnd("Content", UtilMisc.toMap("contentName",contentName));
- if (contents!=null) {
+ }
+ //lastItem
+ if (index == size - 1) {
+ contentNameMatch = false;
+ List<GenericValue> contents = delegator.findByAnd("Content", UtilMisc.toMap("contentName", contentName));
+ if (contents != null) {
Iterator<GenericValue> contentCheck = contents.iterator();
- while (contentCheck.hasNext() && contentNameMatch==false) {
+ while (contentCheck.hasNext() && contentNameMatch == false) {
GenericValue contentch = contentCheck.next();
- if (contentch!=null) {
- List<GenericValue> contentAssocsChecks = delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentId",contentch.get("contentId"), "contentIdTo", rootContent));
+ if (contentch != null) {
+ List<GenericValue> contentAssocsChecks = delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentId", contentch.get("contentId"), "contentIdTo", rootContent));
if (contentAssocsChecks.size() > 0) {
contentNameMatch = true;
}
@@ -359,8 +341,8 @@ In order ta make this service active add
//create DataResource
Map<String,Object> data = FastMap.newInstance();
data.put("userLogin", userLogin);
- String dataResourceId = (dispatcher.runSync("createDataResource",data)).get("dataResourceId").toString();
- //Debug.logInfo("==dataResourceId"+dataResourceId);
+ String dataResourceId = dispatcher.runSync("createDataResource",data).get("dataResourceId").toString();
+ //Debug.logInfo("==dataResourceId" + dataResourceId);
//create Content
contentId = delegator.getNextSeqId("Content");
@@ -373,10 +355,10 @@ In order ta make this service active add
Entity.set("createdByUserLogin", userLogin.get("userLoginId"));
Entity.set("lastModifiedByUserLogin", userLogin.get("userLoginId"));
Entity.set("createdDate", UtilDateTime.nowTimestamp());
- Entity.set("lastUpdatedStamp",UtilDateTime.nowTimestamp());
- Entity.set("lastUpdatedTxStamp",UtilDateTime.nowTimestamp());
- Entity.set("createdStamp",UtilDateTime.nowTimestamp());
- Entity.set("createdTxStamp",UtilDateTime.nowTimestamp());
+ Entity.set("lastUpdatedStamp", UtilDateTime.nowTimestamp());
+ Entity.set("lastUpdatedTxStamp", UtilDateTime.nowTimestamp());
+ Entity.set("createdStamp", UtilDateTime.nowTimestamp());
+ Entity.set("createdTxStamp", UtilDateTime.nowTimestamp());
delegator.create(Entity);
//create ContentAssoc
@@ -387,20 +369,19 @@ In order ta make this service active add
contentAssoc.put("userLogin", userLogin);
dispatcher.runSync("createContentAssoc", contentAssoc);
}
- }
-
+ }
}
- return ServiceUtil.returnSuccess(sucMsg);
+ return ServiceUtil.returnSuccess(sucMsg);
} catch (GenericEntityException e) {
- errMsg = "GenericEntityException "+ UtilMisc.toMap("errMessage", e.toString());
- Debug.logError(e, errMsg, module);
- e.printStackTrace();
- return ServiceUtil.returnError(errMsg);
+ errMsg = "GenericEntityException "+ UtilMisc.toMap("errMessage", e.toString());
+ Debug.logError(e, errMsg, module);
+ e.printStackTrace();
+ return ServiceUtil.returnError(errMsg);
} catch (GenericServiceException e) {
- errMsg = "GenericServiceException"+ UtilMisc.toMap("errMessage", e.toString());
- Debug.logError(e, errMsg, module);
- e.printStackTrace();
- return ServiceUtil.returnError(errMsg);
+ errMsg = "GenericServiceException"+ UtilMisc.toMap("errMessage", e.toString());
+ Debug.logError(e, errMsg, module);
+ e.printStackTrace();
+ return ServiceUtil.returnError(errMsg);
}
}
}
Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/layout/LayoutEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/layout/LayoutEvents.java?rev=1337319&r1=1337318&r2=1337319&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/layout/LayoutEvents.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/layout/LayoutEvents.java Fri May 11 18:02:50 2012
@@ -62,8 +62,8 @@ public class LayoutEvents {
Locale locale = UtilHttp.getLocale(request);
try {
- Delegator delegator = (Delegator)request.getAttribute("delegator");
- LocalDispatcher dispatcher = (LocalDispatcher)request.getAttribute("dispatcher");
+ Delegator delegator = (Delegator) request.getAttribute("delegator");
+ LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
HttpSession session = request.getSession();
Map<String, Object> uploadResults = LayoutWorker.uploadImageAndParameters(request, "imageData");
//Debug.logVerbose("in createLayoutImage(java), uploadResults:" + uploadResults, "");
@@ -76,18 +76,20 @@ public class LayoutEvents {
return "error";
}
//Debug.logVerbose("in createLayoutImage, byteWrap(0):" + byteWrap, module);
- String imageFileName = (String)uploadResults.get("imageFileName");
+ String imageFileName = (String) uploadResults.get("imageFileName");
//Debug.logVerbose("in createLayoutImage(java), context:" + context, "");
String imageFileNameExt = null;
if (UtilValidate.isNotEmpty(imageFileName)) {
int pos = imageFileName.lastIndexOf(".");
- if (pos >= 0)
+ if (pos >= 0) {
imageFileNameExt = imageFileName.substring(pos + 1);
+ }
}
String mimeTypeId = "image/" + imageFileNameExt;
List<Object> errorMessages = FastList.newInstance();
- if (locale == null)
+ if (locale == null) {
locale = Locale.getDefault();
+ }
context.put("locale", locale);
try {
@@ -106,7 +108,7 @@ public class LayoutEvents {
context.put("contentTypeId", "DOCUMENT");
context.put("contentIdTo", formInput.get("contentIdTo"));
context.put("textData", formInput.get("textData"));
- String contentPurposeTypeId = (String)formInput.get("contentPurposeTypeId");
+ String contentPurposeTypeId = (String) formInput.get("contentPurposeTypeId");
if (UtilValidate.isNotEmpty(contentPurposeTypeId)) {
context.put("contentPurposeList", UtilMisc.toList(contentPurposeTypeId));
}
@@ -114,8 +116,8 @@ public class LayoutEvents {
Map<String, Object> result = dispatcher.runSync("persistContentAndAssoc", context);
//Debug.logVerbose("in createLayoutImage, result:" + result, module);
- String dataResourceId = (String)result.get("dataResourceId");
- String activeContentId = (String)result.get("contentId");
+ String dataResourceId = (String) result.get("dataResourceId");
+ String activeContentId = (String) result.get("contentId");
if (UtilValidate.isNotEmpty(activeContentId)) {
Map<String, Object> context2 = FastMap.newInstance();
context2.put("activeContentId", activeContentId);
@@ -168,17 +170,17 @@ public class LayoutEvents {
public static String updateLayoutImage(HttpServletRequest request, HttpServletResponse response) {
Locale locale = UtilHttp.getLocale(request);
try {
- Delegator delegator = (Delegator)request.getAttribute("delegator");
+ Delegator delegator = (Delegator) request.getAttribute("delegator");
HttpSession session = request.getSession();
Map<String, Object> uploadResults = LayoutWorker.uploadImageAndParameters(request, "imageData");
Map<String, Object> context = UtilGenerics.checkMap(uploadResults.get("formInput"));
- ByteBuffer byteWrap = (ByteBuffer)uploadResults.get("imageData");
+ ByteBuffer byteWrap = (ByteBuffer) uploadResults.get("imageData");
if (byteWrap == null) {
String errMsg = UtilProperties.getMessage(LayoutEvents.err_resource, "layoutEvents.image_data_null", locale);
request.setAttribute("_ERROR_MESSAGE_", errMsg);
return "error";
}
- String imageFileName = (String)uploadResults.get("imageFileName");
+ String imageFileName = (String) uploadResults.get("imageFileName");
Debug.logVerbose("in createLayoutImage(java), context:" + context, "");
context.put("userLogin", session.getAttribute("userLogin"));
context.put("dataResourceTypeId", "IMAGE_OBJECT");
@@ -190,7 +192,7 @@ public class LayoutEvents {
context.put("drObjectInfo", null);
context.put("drDataResourceTypeId", null);
- String dataResourceId = (String)context.get("drDataResourceId");
+ String dataResourceId = (String) context.get("drDataResourceId");
Debug.logVerbose("in createLayoutImage(java), dataResourceId:" + dataResourceId, "");
GenericValue dataResource = delegator.findByPrimaryKey("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId));
@@ -222,28 +224,28 @@ public class LayoutEvents {
}
public static String replaceSubContent(HttpServletRequest request, HttpServletResponse response) {
- LocalDispatcher dispatcher = (LocalDispatcher)request.getAttribute("dispatcher");
+ LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
HttpSession session = request.getSession();
Locale locale = UtilHttp.getLocale(request);
Map<String, Object> context = FastMap.newInstance();
Map<String, Object> paramMap = UtilHttp.getParameterMap(request);
Debug.logVerbose("in replaceSubContent, paramMap:" + paramMap, module);
- String dataResourceId = (String)paramMap.get("dataResourceId");
+ String dataResourceId = (String) paramMap.get("dataResourceId");
if (UtilValidate.isEmpty(dataResourceId)) {
String errMsg = UtilProperties.getMessage(LayoutEvents.err_resource, "layoutEvents.data_ressource_id_null", locale);
request.setAttribute("_ERROR_MESSAGE_", errMsg);
return "error";
}
- String contentIdTo = (String)paramMap.get("contentIdTo");
+ String contentIdTo = (String) paramMap.get("contentIdTo");
if (UtilValidate.isEmpty(contentIdTo)) {
String errMsg = UtilProperties.getMessage(LayoutEvents.err_resource, "layoutEvents.content_id_to_null", locale);
request.setAttribute("_ERROR_MESSAGE_", errMsg);
return "error";
}
- String mapKey = (String)paramMap.get("mapKey");
+ String mapKey = (String) paramMap.get("mapKey");
context.put("dataResourceId", dataResourceId);
- String contentId = (String)paramMap.get("contentId");
+ String contentId = (String) paramMap.get("contentId");
context.put("userLogin", session.getAttribute("userLogin"));
/*
@@ -251,12 +253,10 @@ public class LayoutEvents {
if (UtilValidate.isEmpty(contentId)) {
// Look for an existing associated Content
try {
- List lst = delegator.findByAnd(
- "DataResourceContentView ",
- UtilMisc.toMap("dataResourceId", dataResourceId));
+ List lst = delegator.findByAnd("DataResourceContentView ", UtilMisc.toMap("dataResourceId", dataResourceId));
if (lst.size() > 0) {
- GenericValue dataResourceContentView = (GenericValue)lst.get(0);
- contentId = (String)dataResourceContentView.get("coContentId");
+ GenericValue dataResourceContentView = (GenericValue) lst.get(0);
+ contentId = (String) dataResourceContentView.get("coContentId");
}
} catch (GenericEntityException e) {
request.setAttribute("_ERROR_MESSAGE_", e.getMessage());
@@ -299,23 +299,23 @@ public class LayoutEvents {
}
public static String cloneLayout(HttpServletRequest request, HttpServletResponse response) {
- Delegator delegator = (Delegator)request.getAttribute("delegator");
- LocalDispatcher dispatcher = (LocalDispatcher)request.getAttribute("dispatcher");
+ Delegator delegator = (Delegator) request.getAttribute("delegator");
+ LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
HttpSession session = request.getSession();
Locale locale = UtilHttp.getLocale(request);
Map<String, Object> paramMap = UtilHttp.getParameterMap(request);
- String contentId = (String)paramMap.get("contentId");
+ String contentId = (String) paramMap.get("contentId");
Debug.logVerbose("in cloneLayout, contentId:" + contentId, "");
if (UtilValidate.isEmpty(contentId)) {
String errMsg = UtilProperties.getMessage(LayoutEvents.err_resource, "layoutEvents.content_id_empty", locale);
request.setAttribute("_ERROR_MESSAGE_", errMsg);
return "error";
}
- String contentIdTo = (String)paramMap.get("contentIdTo");
+ String contentIdTo = (String) paramMap.get("contentIdTo");
Debug.logVerbose("in cloneLayout, contentIdTo:" + contentIdTo, "");
GenericValue content = null;
GenericValue newContent = null;
- GenericValue userLogin = (GenericValue)request.getSession().getAttribute("userLogin");
+ GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin");
String userLoginId = (String) userLogin.get("userLoginId");
List<GenericValue> entityList = null;
String newId = null;
@@ -330,15 +330,15 @@ public class LayoutEvents {
}
newContent = delegator.makeValue("Content", content);
Debug.logVerbose("in cloneLayout, newContent:" + newContent, "");
- String oldName = (String)content.get("contentName");
+ String oldName = (String) content.get("contentName");
newId = delegator.getNextSeqId("Content");
newContent.set("contentId", newId);
- String dataResourceId = (String)content.get("dataResourceId");
+ String dataResourceId = (String) content.get("dataResourceId");
GenericValue dataResource = delegator.findByPrimaryKey("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId));
if (dataResource != null) {
GenericValue newDataResource = delegator.makeValue("DataResource", dataResource);
Debug.logVerbose("in cloneLayout, newDataResource:" + newDataResource, "");
- String dataResourceName = "Copy:" + (String)dataResource.get("dataResourceName");
+ String dataResourceName = "Copy:" + (String) dataResource.get("dataResourceName");
newDataResource.set("dataResourceName", dataResourceName);
newDataResourceId = delegator.getNextSeqId("DataResource");
newDataResource.set("dataResourceId", newDataResourceId);
@@ -407,10 +407,10 @@ public class LayoutEvents {
request.setAttribute("_ERROR_MESSAGE_", e.getMessage());
return "error";
}
- String contentIdFrom = (String)view.get("contentId");
- String mapKey = (String)view.get("caMapKey");
- Timestamp fromDate = (Timestamp)view.get("caFromDate");
- Timestamp thruDate = (Timestamp)view.get("caThruDate");
+ String contentIdFrom = (String) view.get("contentId");
+ String mapKey = (String) view.get("caMapKey");
+ Timestamp fromDate = (Timestamp) view.get("caFromDate");
+ Timestamp thruDate = (Timestamp) view.get("caThruDate");
Debug.logVerbose("in cloneLayout, contentIdFrom:" + contentIdFrom + " fromDate:" + fromDate + " thruDate:" + thruDate + " mapKey:" + mapKey, "");
if (beenThere.get(contentIdFrom) == null) {
serviceIn.put("contentIdFrom", contentIdFrom);
@@ -439,22 +439,22 @@ public class LayoutEvents {
public static String createLayoutSubContent(HttpServletRequest request, HttpServletResponse response) {
try {
- LocalDispatcher dispatcher = (LocalDispatcher)request.getAttribute("dispatcher");
+ LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
HttpSession session = request.getSession();
Map<String, Object> paramMap = UtilHttp.getParameterMap(request);
- String contentIdTo = (String)paramMap.get("contentIdTo");
- String mapKey = (String)paramMap.get("mapKey");
+ String contentIdTo = (String) paramMap.get("contentIdTo");
+ String mapKey = (String) paramMap.get("mapKey");
if (Debug.verboseOn()) {
Debug.logVerbose("in createSubContent, contentIdTo:" + contentIdTo, module);
Debug.logVerbose("in createSubContent, mapKey:" + mapKey, module);
}
Map<String, Object> context = FastMap.newInstance();
List<Object> errorMessages = null;
- Locale loc = (Locale)request.getSession().getServletContext().getAttribute("locale");
+ Locale loc = (Locale) request.getSession().getServletContext().getAttribute("locale");
if (loc == null) {
loc = Locale.getDefault();
}
- GenericValue userLogin = (GenericValue)session.getAttribute("userLogin");
+ GenericValue userLogin = (GenericValue) session.getAttribute("userLogin");
context.put("userLogin", userLogin);
String rootDir = request.getSession().getServletContext().getRealPath("/");
@@ -469,7 +469,7 @@ public class LayoutEvents {
}
context.put("dataResourceName", context.get("contentName"));
- String contentPurposeTypeId = (String)paramMap.get("contentPurposeTypeId");
+ String contentPurposeTypeId = (String) paramMap.get("contentPurposeTypeId");
if (UtilValidate.isNotEmpty(contentPurposeTypeId)) {
context.put("contentPurposeList", UtilMisc.toList(contentPurposeTypeId));
}
@@ -490,8 +490,8 @@ public class LayoutEvents {
if (Debug.verboseOn()) {
Debug.logVerbose("in createLayoutFile, result:" + result, module);
}
- String contentId = (String)result.get("contentId");
- String dataResourceId = (String)result.get("dataResourceId");
+ String contentId = (String) result.get("contentId");
+ String dataResourceId = (String) result.get("dataResourceId");
request.setAttribute("contentId", contentId);
request.setAttribute("drDataResourceId", dataResourceId);
request.setAttribute("currentEntityName", "SubContentDataResourceId");
@@ -515,19 +515,19 @@ public class LayoutEvents {
public static String updateLayoutSubContent(HttpServletRequest request, HttpServletResponse response) {
try {
- LocalDispatcher dispatcher = (LocalDispatcher)request.getAttribute("dispatcher");
+ LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
HttpSession session = request.getSession();
Map<String, Object> paramMap = UtilHttp.getParameterMap(request);
- // String contentIdTo = (String)paramMap.get("contentIdTo");
- // String mapKey = (String)paramMap.get("mapKey");
+ // String contentIdTo = (String) paramMap.get("contentIdTo");
+ // String mapKey = (String) paramMap.get("mapKey");
Map<String, Object> context = FastMap.newInstance();
List<Object> errorMessages = null;
- Locale loc = (Locale)request.getSession().getServletContext().getAttribute("locale");
+ Locale loc = (Locale) request.getSession().getServletContext().getAttribute("locale");
if (loc == null) {
loc = Locale.getDefault();
- }
+ }
context.put("locale", loc);
- GenericValue userLogin = (GenericValue)session.getAttribute("userLogin");
+ GenericValue userLogin = (GenericValue) session.getAttribute("userLogin");
context.put("userLogin", userLogin);
String rootDir = request.getSession().getServletContext().getRealPath("/");
@@ -542,10 +542,10 @@ public class LayoutEvents {
}
context.put("dataResourceName", context.get("contentName"));
- String contentPurposeTypeId = (String)paramMap.get("contentPurposeTypeId");
+ String contentPurposeTypeId = (String) paramMap.get("contentPurposeTypeId");
if (UtilValidate.isNotEmpty(contentPurposeTypeId)) {
context.put("contentPurposeList", UtilMisc.toList(contentPurposeTypeId));
- }
+ }
context.put("contentIdTo", paramMap.get("contentIdTo"));
context.put("textData", paramMap.get("textData"));
context.put("contentAssocTypeId", null);
@@ -555,8 +555,8 @@ public class LayoutEvents {
request.setAttribute("_ERROR_MESSAGE_", result.get(ModelService.ERROR_MESSAGE));
return "error";
}
- String contentId = (String)result.get("contentId");
- String dataResourceId = (String)result.get("dataResourceId");
+ String contentId = (String) result.get("contentId");
+ String dataResourceId = (String) result.get("dataResourceId");
request.setAttribute("contentId", contentId);
request.setAttribute("drDataResourceId", dataResourceId);
request.setAttribute("currentEntityName", "SubContentDataResourceId");
@@ -580,9 +580,9 @@ public class LayoutEvents {
}
public static String copyToClip(HttpServletRequest request, HttpServletResponse response) {
- Delegator delegator = (Delegator)request.getAttribute("delegator");
+ Delegator delegator = (Delegator) request.getAttribute("delegator");
Map<String, Object> paramMap = UtilHttp.getParameterMap(request);
- String entityName = (String)paramMap.get("entityName");
+ String entityName = (String) paramMap.get("entityName");
Locale locale = UtilHttp.getLocale(request);
if (UtilValidate.isEmpty(entityName)) {
@@ -596,7 +596,7 @@ public class LayoutEvents {
for(String attrName : keyColl) {
String attrVal = (String)request.getAttribute(attrName);
if (attrVal == null) {
- attrVal = (String)paramMap.get(attrName);
+ attrVal = (String) paramMap.get(attrName);
}
Debug.logVerbose("in copyToClip, attrName:" + attrName,"");
Debug.logVerbose("in copyToClip, attrVal:" + attrVal,"");