Subversion Repositories linid-dm

Compare Revisions

Rev 345 → Rev 344

/wui/branches/2.0/src/main/java/org/linid/dm/wui/t5lib/WuiCommonModule.java
38,7 → 38,6
import org.apache.tapestry5.ioc.MappedConfiguration;
import org.apache.tapestry5.ioc.OrderedConfiguration;
import org.apache.tapestry5.ioc.Resource;
import org.apache.tapestry5.ioc.ServiceBinder;
import org.apache.tapestry5.ioc.annotations.InjectService;
import org.apache.tapestry5.ioc.annotations.SubModule;
import org.apache.tapestry5.ioc.annotations.Value;
56,7 → 55,6
import org.linid.dm.wui.t5lib.data.DropDownList;
import org.linid.dm.wui.t5lib.pages.SimplePropertyEditBlocks;
import org.linid.dm.wui.t5lib.services.AttributeValidatorAssignement;
import org.linid.dm.wui.t5lib.services.JpegFileFormatChecker;
import org.linid.dm.wui.t5lib.services.LdapEditorAnalyzer;
import org.linid.dm.wui.t5lib.services.LdapTypeAnalyzer;
import org.linid.dm.wui.t5lib.services.LdapViewerAnalyzer;
69,7 → 67,6
import org.linid.dm.wui.t5lib.services.impl.DefaultLocaleService;
import org.linid.dm.wui.t5lib.services.impl.ESchemaLdapOperatorTranslator;
import org.linid.dm.wui.t5lib.services.impl.IByteStringTranslator;
import org.linid.dm.wui.t5lib.services.impl.JpegFileFormatCheckerImpl;
import org.linid.dm.wui.t5lib.services.impl.PropertiesSymbolProvider;
import org.linid.dm.wui.validator.EqualsValidator;
import org.linid.dm.wui.validator.RequiredAttributeValidator;
323,8 → 320,4
return new DefaultLocaleService(persistentLocale, request);
}
public static void bind(ServiceBinder binder) {
binder.bind(JpegFileFormatChecker.class, JpegFileFormatCheckerImpl.class);
}
}
/wui/branches/2.0/src/main/java/org/linid/dm/wui/t5lib/components/PhotoEditor.java
1,8 → 1,6
package org.linid.dm.wui.t5lib.components;
 
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
 
import org.apache.tapestry5.EventConstants;
import org.apache.tapestry5.annotations.OnEvent;
14,15 → 12,11
import org.apache.tapestry5.ioc.annotations.Value;
import org.apache.tapestry5.services.Request;
import org.apache.tapestry5.upload.services.UploadedFile;
import org.linid.dm.wui.t5lib.services.JpegFileFormatChecker;
 
public class PhotoEditor {
 
@Inject
private Messages messages;
@Inject
private JpegFileFormatChecker jpegChecker;
 
@Property
@Parameter(required=true)
47,16 → 41,12
public void onSuccess()
{
if(userUid!=null){
if (!checkFileFormat()) {
throw new RuntimeException("Invalid format, JPEG expected");
} else {
File copied = new File(photoDirectory,userUid+PHOTO_EXT);
file.write(copied);
}
File copied = new File(photoDirectory,userUid+PHOTO_EXT);
file.write(copied);
}
}
 
/**
/**
* manage action link to delete photo
*/
public void onActionFromDelete(){
89,19 → 79,4
}
}
 
private boolean checkFileFormat() {
InputStream stream = file.getStream();
try {
return jpegChecker.check(stream);
} catch (IOException e) {
return false;
} finally {
try {
stream.close();
} catch (IOException e) {
throw new RuntimeException("Can't close uploaded file input stream");
}
}
}
 
}
/wui/branches/2.0/pom.xml
333,12 → 333,6
<artifactId>tapestry5-jquery</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-parsers</artifactId>
<version>1.3</version>
</dependency>
</dependencies>