Skip to content
Merged
Show file tree
Hide file tree
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 @@ -93,6 +93,8 @@ public class ReportTemplateEditPane extends TemplateTypeEditPane implements HasE
private TextItem jasperDataSourceAttributeNameField;
/** Jasper PasswordAttributeName */
private TextItem jasperPasswordAttributeNameField;
/** Jasper OwnerPasswordAttributeName */
private TextItem jasperOwnerPasswordAttributeNameField;

/** Poi PasswordAttributeName */
private DynamicForm poiPasswordAttributeNameForm;
Expand Down Expand Up @@ -226,8 +228,10 @@ public void onSubmit(SubmitEvent event) {
jasperDataSourceAttributeNameField.setTitle("DataSource AttributeName");
jasperPasswordAttributeNameField = new MtpTextItem();
jasperPasswordAttributeNameField.setTitle("Password AttributeName");
jasperOwnerPasswordAttributeNameField = new MtpTextItem();
jasperOwnerPasswordAttributeNameField.setTitle("Owner Password AttributeName");

jasperAttributeForm.setItems(jasperDataSourceAttributeNameField, jasperPasswordAttributeNameField);
jasperAttributeForm.setItems(jasperDataSourceAttributeNameField, jasperPasswordAttributeNameField, jasperOwnerPasswordAttributeNameField);

//Jasper ParamMap部分
jasperParamMapPane = new JasperReportParamMapGridPane();
Expand Down Expand Up @@ -329,6 +333,8 @@ public TemplateDefinition getEditDefinition(TemplateDefinition definition) {

//PasswordAttributeName
jasperTemplate.setPasswordAttributeName(SmartGWTUtil.getStringValue(jasperPasswordAttributeNameField, true));
//OwnerPasswordAttributeName
jasperTemplate.setOwnerPasswordAttributeName(SmartGWTUtil.getStringValue(jasperOwnerPasswordAttributeNameField, true));
//パラメータマッピング設定
jasperTemplate.setParamMap(jasperParamMapPane.getParamMap());

Expand Down Expand Up @@ -447,6 +453,9 @@ private void addReportTypeParameter(ReportType type, String prefix) {
if (!SmartGWTUtil.isEmpty(jasRepo.getPasswordAttributeName())) {
addUploadParameter(prefix + ReportTemplateUploadProperty.JASPER_PASSWORD_ATTRIBUTE_NAME, jasRepo.getPasswordAttributeName());
}
if (!SmartGWTUtil.isEmpty(jasRepo.getOwnerPasswordAttributeName())) {
addUploadParameter(prefix + ReportTemplateUploadProperty.JASPER_OWNER_PASSWORD_ATTRIBUTE_NAME, jasRepo.getOwnerPasswordAttributeName());
}

} else if (type instanceof PoiReportType) {
addUploadParameter(prefix + ReportTemplateUploadProperty.REPORT_TYPE, PoiReportType.class.getName());
Expand Down Expand Up @@ -557,6 +566,7 @@ private void setReportType(ReportType type) {
jasperParamMapPane.setParamMap(jasRepo.getParamMap());
jasperDataSourceAttributeNameField.setValue(jasRepo.getDataSourceAttributeName());
jasperPasswordAttributeNameField.setValue(jasRepo.getPasswordAttributeName());
jasperOwnerPasswordAttributeNameField.setValue(jasRepo.getOwnerPasswordAttributeName());
removeMembers(poiPasswordAttributeNameForm, reportOutPane);
removeMembers(jxlsPasswordAttributeNameForm, jxlsContextParamMapPane, jxlsReportOutputLogicPane);
beforeReportType = JasperReportType.class.getName();
Expand Down Expand Up @@ -653,6 +663,8 @@ public LocalizedReportDefinition getEditLocalizedReportDefinition(LocalizedRepor
jasperTemplate.setDataSourceAttributeName(SmartGWTUtil.getStringValue(jasperDataSourceAttributeNameField, true));
//PasswordAttributeName
jasperTemplate.setPasswordAttributeName(SmartGWTUtil.getStringValue(jasperPasswordAttributeNameField, true));
//OwnerPasswordAttributeName
jasperTemplate.setOwnerPasswordAttributeName(SmartGWTUtil.getStringValue(jasperOwnerPasswordAttributeNameField, true));

definition.setReportType(jasperTemplate);
} else if (JxlsReportType.class.getName().equals(reportTypeField.getValueAsString())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,10 @@ private ReportType createReportType(HashMap<String, Object> args) {
if (StringUtil.isNotEmpty(passwordAttributeName)) {
jasperTemplate.setPasswordAttributeName(passwordAttributeName);
}
String ownerPasswordAttributeName = (String) args.get(ReportTemplateUploadProperty.JASPER_OWNER_PASSWORD_ATTRIBUTE_NAME);
if (StringUtil.isNotEmpty(ownerPasswordAttributeName)) {
jasperTemplate.setOwnerPasswordAttributeName(ownerPasswordAttributeName);
}

return jasperTemplate;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,12 @@ public interface ReportTemplateUploadProperty extends UploadProperty {

/** Jasper DataSourceAttributeName */
public static final String JASPER_DATASOURCE_ATTRIBUTE_NAME = "jasperDataSourceAttributeName";

/** Jasper PasswordAttributeName */
public static final String JASPER_PASSWORD_ATTRIBUTE_NAME = "jasperPasswordAttributeName";

/** Jasper OwnerPasswordAttributeName */
public static final String JASPER_OWNER_PASSWORD_ATTRIBUTE_NAME = "jasperOwnerPasswordAttributeName";

/** Poiレポート出力ロジック形式 */
public static final String POI_LOGIC_NAME = "poiLogicName";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ public void exportReport( WebRequestStack context, ReportingOutputModel model )
if (StringUtil.isNotEmpty(jasperModel.getPasswordAttributeName())) {
password = (String)getAttribute(request, jasperModel.getPasswordAttributeName());
}
String ownerPassword = null;
if (StringUtil.isNotEmpty(jasperModel.getOwnerPasswordAttributeName())) {
ownerPassword = (String)getAttribute(request, jasperModel.getOwnerPasswordAttributeName());
}

// JasperPrintインスタンス生成
List<JasperPrint> jrList = new ArrayList<JasperPrint>();
Expand All @@ -180,10 +184,17 @@ public void exportReport( WebRequestStack context, ReportingOutputModel model )
pdfExporter.setExporterOutput(output);

SimplePdfExporterConfiguration config = new SimplePdfExporterConfiguration();
if (StringUtil.isNotEmpty(password)) {
config.setOwnerPassword(password);
config.setUserPassword(password);
if (StringUtil.isNotEmpty(password) || StringUtil.isNotEmpty(ownerPassword)) {
config.setEncrypted(true);
if (StringUtil.isNotEmpty(password)) {
config.setUserPassword(password);
}
if (StringUtil.isNotEmpty(ownerPassword)) {
config.setOwnerPassword(ownerPassword);
} else if (StringUtil.isNotEmpty(password)) {
// ownerパスワードがnullの場合は下位互換性のためuserパスワードをセット
config.setOwnerPassword(password);
}
}
pdfExporter.setConfiguration(config);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class JasperReportingOutputModel implements ReportingOutputModel{
private MetaReportParamMap[] maps;
private String dataSourceAttributeName;
private String passwordAttributeName;
private String ownerPasswordAttributeName;

private final String JASPER_STR = "jasper";
private final String JRXML_STR = "jrxml";
Expand Down Expand Up @@ -107,4 +108,12 @@ public void setPasswordAttributeName(String passwordAttributeName) {
this.passwordAttributeName = passwordAttributeName;
}

public String getOwnerPasswordAttributeName() {
return ownerPasswordAttributeName;
}

public void setOwnerPasswordAttributeName(String ownerPasswordAttributeName) {
this.ownerPasswordAttributeName = ownerPasswordAttributeName;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ public class MetaJasperReportType extends MetaReportType {
/** パスワードAttribute名 */
private String passwordAttributeName;

/** オーナーパスワードAttribute名 */
private String ownerPasswordAttributeName;

public MetaReportParamMap[] getParamMap() {
return paramMap;
}
Expand All @@ -65,6 +68,14 @@ public void setPasswordAttributeName(String passwordAttributeName) {
this.passwordAttributeName = passwordAttributeName;
}

public String getOwnerPasswordAttributeName() {
return ownerPasswordAttributeName;
}

public void setOwnerPasswordAttributeName(String ownerPasswordAttributeName) {
this.ownerPasswordAttributeName = ownerPasswordAttributeName;
}

@Override
public void applyConfig(ReportType reportType) {
JasperReportType def = (JasperReportType)reportType;
Expand All @@ -85,6 +96,7 @@ public void applyConfig(ReportType reportType) {
dataSourceAttributeName = def.getDataSourceAttributeName();

passwordAttributeName = def.getPasswordAttributeName();
ownerPasswordAttributeName = def.getOwnerPasswordAttributeName();
}

@Override
Expand All @@ -104,6 +116,7 @@ public ReportType currentConfig() {

definition.setDataSourceAttributeName(dataSourceAttributeName);
definition.setPasswordAttributeName(passwordAttributeName);
definition.setOwnerPasswordAttributeName(ownerPasswordAttributeName);

return definition;
}
Expand Down Expand Up @@ -136,6 +149,7 @@ public void setParam(ReportingOutputModel createOutputModel) {
model.setMaps(paramMap);
}
model.setPasswordAttributeName(passwordAttributeName);
model.setOwnerPasswordAttributeName(ownerPasswordAttributeName);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public class JasperReportType extends ReportType {
/** パスワードAttribute名 */
private String passwordAttributeName;

/** オーナーパスワードAttribute名 */
private String ownerPasswordAttributeName;

public ReportParamMapDefinition[] getParamMap() {
return paramMap;
}
Expand All @@ -68,4 +71,12 @@ public void setPasswordAttributeName(String passwordAttributeName) {
this.passwordAttributeName = passwordAttributeName;
}

public String getOwnerPasswordAttributeName() {
return ownerPasswordAttributeName;
}

public void setOwnerPasswordAttributeName(String ownerPasswordAttributeName) {
this.ownerPasswordAttributeName = ownerPasswordAttributeName;
}

}
Loading