com.alogient.cameleon.sdk.content.util.ContentUtils Maven / Gradle / Ivy
The newest version!
package com.alogient.cameleon.sdk.content.util;
import static com.alogient.cameleon.sdk.content.util.InternalCameleonConfig.CAMELEON_MEDIA_URL;
import com.alogient.cameleon.context.CameleonRequestContextHolder;
import com.alogient.cameleon.sdk.content.model.ResourceModel;
import com.alogient.cameleon.sdk.content.util.nav.ModeType;
/**
* Defines utility methods used to deal with the content
*/
public class ContentUtils {
/**
* Builds the Url for any type of files
*
* @param fileName The file name
* @param navId The navId
* @param partId the part id
* @return the url
*/
public static String getRemoteDocumentURL(String fileName, Integer navId, Integer partId) {
StringBuffer sb = new StringBuffer(InternalCameleonConfig.getString(CAMELEON_MEDIA_URL, "/"));
if (!CameleonRequestContextHolder.getModeType().isLiveMode()) {
sb.append("Preview_");
}
sb.append(navId);
sb.append("_");
sb.append(partId);
sb.append("_");
sb.append(CameleonRequestContextHolder.getCultureVo().getCultureCode());
sb.append("_0_");
sb.append(fileName);
return sb.toString();
}
/**
* Builds the Url for any type of files
*
* @param ressourceModel The file
* @return the url
*/
public static String getRemoteDocumentURL(ResourceModel ressourceModel) {
if (ressourceModel == null) {
return null;
}
return getRemoteDocumentURL(ressourceModel.getFileName(), ressourceModel.getNavId(), ressourceModel.getPartId());
}
/**
* Builds the Url for any type of files
*
* @param fileName The file name
* @param navId The navId
* @param partId the part id
* @param cultureCode the culture code
* @param modeType the type
* @return the url
*/
public static String getRemoteDocumentURL(String fileName, Integer navId, Integer partId, String cultureCode, ModeType modeType) {
StringBuffer sb = new StringBuffer(InternalCameleonConfig.getString(CAMELEON_MEDIA_URL, "/"));
if (!modeType.isLiveMode()) {
sb.append("Preview_");
}
sb.append(navId);
sb.append("_");
sb.append(partId);
sb.append("_");
sb.append(cultureCode);
sb.append("_0_");
sb.append(fileName);
return sb.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy