How to "delete" a user's photo in Spaces

Hi,
When a user deletes a photo in his/her profile, I want to use a default photo to replace his/her photo. Can I pass in an empty string, null string or a default photo to setJpegPhoto()?
// ADFContext
ADFContext adfCtx = ADFContext.getCurrent();
SecurityContext secCntx = adfCtx.getSecurityContext();
secCntx.getUserProfile().setJpegPhoto("/tmp/LARGE.png");
Thank you.

Hi,
I’ve found another way to call setJPEGPhoto(). But, a problem is that when a user “yes” to delete, the photo is not refreshed and replaced by “LARGE.png” until the page is saved. Looking at the logs on backend, I know it’s replaced.
ProfileFactory.getProfileManager().getProfile(taskFlowUser).setJPEGPhoto("/tmp/LARGE.png");
When a user choose his/her new photo(upload), and “ok” it, the new photo shows up on the page before the page is saved. How is the Delete different from Upload for saving and refreshing a photo on the page?
Thank you.
DELETE PHOTO:
============
<af:commandLink xmlns:af="http://xmlns.oracle.com/adf/faces/rich" text="Delete Photo"
partialSubmit="true" id="commandLink1">
<af:showPopupBehavior xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
popupId="subform3:popup3"/>
<af:subform xmlns:af="http://xmlns.oracle.com/adf/faces/rich" id="subform3">
<af:popup xmlns:af="http://xmlns.oracle.com/adf/faces/rich" id="popup3">
<af:dialog xmlns:af="http://xmlns.oracle.com/adf/faces/rich" id="sd1" type="yesNo"
attributeChangeListener="#{employeeBean.handleDialog}">
<af:outputText xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
value="Do you really want to delete the photo?" id="sot2"/>
</af:dialog>
</af:popup>
</af:subform>
</af:commandLink>
public void deleteUserPhoto() {
// ADFContext
ADFContext adfCtx = ADFContext.getCurrent();
// Security
SecurityContext secCntx = adfCtx.getSecurityContext();
//String userID = secCntx.getUserProfile().getUserID();
byte[] photo = new byte[10000000];
photo = secCntx.getUserProfile().getJpegPhoto();
String taskFlowUser = (String)RequestContext.getCurrentInstance().getPageFlowScope().get("userId");
System.out.printf("deleteUserPhoto() user ID:'%s' photo size: '%d'\n", taskFlowUser, photo.length);
try {
ProfileFactory.getProfileManager().getProfile(taskFlowUser).setJPEGPhoto("/tmp/LARGE.png");
} catch (ProfileException pEx) {
pEx.printStackTrace();
} catch (Exception ex) {
ex.printStackTrace();
photo = secCntx.getUserProfile().getJpegPhoto();
System.out.printf("deleteUserPhoto() photo size: '%d'\n", photo.length);
return;
public void handleDialog(DialogEvent event)
if (event.getOutcome().equals(DialogEvent.Outcome.no))
System.out.printf("handleDialog() DON'T DELETE\n");
} else {
System.out.printf("handleDialog() DELETE\n");
deleteUserPhoto();
UPLODAD A PHOTO:
================
<af:panelGroupLayout id="pgl1" layout="vertical" halign="center">
<af:commandImageLink icon="#{webCenterProfile[pageFlowScope.userId]
.photoURI.LARGE}" id="i2">
<af:showPopupBehavior popupId="phUp:popup"/>
</af:commandImageLink>
<af:commandLink text="#{uib_o_w_pc_p_ProfileMessages.LABEL_CHANGE_PHOTO}"
partialSubmit="true" id="cil1">
<af:showPopupBehavior popupId="phUp:popup"/>
</af:commandLink>
<af:subform id="phUp" defaultCommand="ok">
<af:popup id="popup">
<af:dialog title="#{uib_o_w_pc_p_ProfileMessages.TITLE_UPLOAD_PHOTO}"
titleIconSource="/adf/webcenter/fileupload_ena.png"
type="cancel" id="d1">
<af:inputFile simple="true" id="if1"
shortDesc="#{uib_o_w_pc_p_ProfileMessages.PHOTO_HINT}"
valueChangeListener="#{profileHelper.photoUploaded}"/>
<f:facet name="buttonBar">
<af:commandButton id="ok"
text="#{uib_o_w_pc_p_ProfileMessages.LABEL_OK}"/>
</f:facet>
</af:dialog>
</af:popup>
</af:subform>
</af:panelGroupLayout>
public void photoUploaded(ValueChangeEvent event)
String METHOD_NAME = "photoUploaded";
LOGGER.entering(CLASS_NAME, "photoUploaded");
String taskFlowUser = (String)RequestContext.getCurrentInstance().getPageFlowScope().get("userId");
try
UploadedFile uploadedFile = (UploadedFile)event.getNewValue();
if (!WebCenterFrameworkViewUtils.isValidImage(uploadedFile))
ProfileException validateEx = new ProfileException("UPLOAD_IMAGE_INVALID", new Object[] { uploadedFile.getFilename() }, null);
throw validateEx;
File tempFile = null;
if (taskFlowUser.trim().length() < 3)
String tempFileName = "photo_" + taskFlowUser;
tempFile = File.createTempFile(tempFileName, null);
else
tempFile = File.createTempFile(taskFlowUser, null);
String tempFilePath = tempFile.getCanonicalPath();
if (LOGGER.isFinest()) {
LOGGER.finest(CLASS_NAME, "photoUploaded", "Created temporary file {0}", tempFilePath);
BufferedInputStream in = new BufferedInputStream(uploadedFile.getInputStream());
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(tempFile));
while (true)
int c = in.read();
if (c < 0)
break;
out.write(c);
in.close();
out.close();
ProfileFactory.getProfileManager().getProfile(taskFlowUser).setJPEGPhoto(tempFilePath);
tempFile.delete();
catch (BaseWCServiceException ex)
WCServiceViewUtils.getInstance().logAndDisplayError(ex);
catch (Exception ex)
if ((ex instanceof ProfileException))
WCServiceViewUtils.getInstance().logAndDisplayError((BaseWCServiceException)ex);
else
ProfileException presentableEx = new ProfileException("UNEXP_ERR__SAVE_PHOTO", new Object[] { taskFlowUser }, ex);
WCServiceViewUtils.getInstance().logAndDisplayError(presentableEx);
LOGGER.exiting(CLASS_NAME, "photoUploaded");
Edited by: 891549 on Jun 21, 2012 4:26 PM

Similar Messages

  • How do I delete my user ID photo, taken with the camera in the MacBook Pro.  It keeps appearing randomly when I sign in....even after I make changes.

    How do I delete my user ID photo, taken with the camera in the MacBook Pro (when you first buy and set up the computer...).  The photo keeps appearing randomly, even after I've changed it to a "better picture".  I can't get the change to "stick".  Anyone else having trouble with this?  Thanks!

    what OS are you using?

  • How to delete a user in SAP-CPS Version 7.0

    Hello,
    I created my users via UME ( User Management Engine of Java Application server). Unfortunately I used the wrong name convention, so I had to recreate all the users in UME. Afterwards I delete all wrong users in UME.
    Than I tried to login with my new user in SAP-CPS (users are normally created in SAP-CPS during first login) but I get the error message that I reached the maximum number of 10 users allowed in the basic version. No problem I thougt, I simply delete the wrong ones in SAP-CPS. But I do not know how to delete a user! I could not find any menu item or any describtion in the manualls how to delete an user in SAP-CPS.
    I remove the users from any Isolation group, I disabled all the users but still I could not find any way to delete them.
    Has any body a hint for mor.
    Kind regards
    Frank Morleo

    Hello Anton,
    deactivating the unused users made it possible to login with the new ones. 
    Thanks for your help.
    Now I have to find out how to clear the deactivated users from the list.
    Regards
    Frank

  • How to delete duplicate pictures from Photo Library

    How to delete duplicate pictures from Photo Library in iPhone 3G 16 giga?

    The only way to delete photos from the photo library is by the same way the photos were transferred to your iPhone - via the iTunes sync process.
    Are you saying a photo or all photos transferred to your iPhone via the iTunes sync process are duplicated in your iPhone's Photo Library without being duplicated in the folder on your computer where these photos are stored?

  • How to delete pictures in the photo stream?

    How delete photos in the photo stream?

    It is easy. But please note that when you delete a photo from My Photo Stream on an iOS device, Mac, or PC, that photo will be deleted from the My Photo Stream view on all your devices after you connect each device to Wi-Fi .
    On how to delete them from My Photo Stream, please visit http://support.apple.com/en-us/HT204022, you can find all answers you need.

  • HT201302 how to delete a album or photo transfered through itune?

    how to delete a album or photo transfered through itune?

    This must be done on the computer. The phone holds your pictures/albums hostage until you uncheck/unsync them from iTunes itself. You cannot delete them via the iPhone at all.

  • How to delete a number of photos

    Can someone tell me how to delete a number of photos
    from my 2g iPhone without downloading them?
    I know how to delete them individually but I want to delete a large number
    thanks
    Pete

    you can only delete one at a time

  • How to delete more than one photo at a time

    Apparently there is no longer an iPhoto trash. So you don't drag photos to the trash. Instead you hit the delete key and then a second click on delete when you get the message "Are you sure you want to delete this photo." Has anyone found a way to delete more than one photo at a time, though? This is really a hassle if you have just imported 500 photos and are going to end up deleting 450 of them.

    I didn't say use the command key and delete. I use the command key for selecting random photos. Then I right click and choose delete from the contextual menu.
    I always use right click, but the command-delete does work also in that album.
    Depending on what album you are in, there are different menus. In a user created album, the right click would show "Remove from Album" & "Delete Photo". I noticed that was the same for Last Import Album. But at the same time, under image, you will only have Remove from Album. If it is a system album, you will only get the delete menu from either the right click or from the menu under Image.
    What you have to remember is if it days delete the photo, it will completely delete it from the library and all albums. If the menu says Remove From Album, then it will only be removed from the album you are in.
    In PhotoStream Album, you get only Delete Photo from the right click menu, but under image, you get only remove from album. So if you want to remove an image from PhotoStream, you have to use the top menu so it won't get deleted from the library. If you want to remove a photo completely, you would use delete and it will be removed from the library and photo stream.
    So, there are different processes for the different albums. I don't know if that is intentional or just oversight. That may change in the future.

  • How to delete existing user and create the account

    Hi All,
    How to delete the existing user and does not loose the shopping cart link, confirmations for etc and then create back the account for the user?
    Please tell me the steps.
    Thank you.
    Regards,
    Henry

    How to delete the existing user and does not loose the shopping cart link, confirmations for etc and then create back the account for the user?
    I believe you can not delete the user 100% fully since all documents must be closed before.since it had a relation in crmd_partner table. However it has links with business objects..
    Copied from forum threads.. for your reference..
    Note 1148837 - SRM user cannot be deleted
    in consulting note 550071
    Q8. What happens if I delete the user who has created the shopping cart
    A8. If the user is deleted, and the shoping cart exists in the application, then the shooping cart cannot be displayed. If you want to view/ process those shopping carts, then you have to create a dummy user and retrieve the document. In CRMD_PARTNER table, the old user GUID should be replaced with the new user GUID.
    User deleted from SRM, deletion of SC not possible
    if you have a central recipient cancel them with that role or as advised by akash cancel from r/3.
    discussions are welcome..
    regards
    Muthu

  • How to delete another user?

    Could anyone please tell me how I can delete a user of my shared library? If I locate the itunes folder on my pc, and just delete their folder, music in my itunes ends up with a broken/missing file?
    Regards.

    Hi Chris. I've got 1 pc to share with 2 ipods. I hold shift and click on itunes to select which library I want to use.
    I want to delete the other user because when I add music to my library, it does not go into the other persons library. I didn't notice this until I added over 2000 more songs to my library! I think it would be too much hassle trying to find which songs are missing from the 2nd library. I then created another library for the other user and just dragged all of my itunes songs into their library.
    I then deleted the first folder I made for them, but then the dreaded '!' appeared in my library. I restored the folder from my bin and this fixed the ! problem. I'm just stuck with a folder in my itunes folder, which I don't need any more> Hope that makes sense!!!

  • How to delete the back up photos in my album?

    How to delete back up photos?

    It's not if its small or big. My point is in icloud it says 5 mb, is MY storage.. so i it's my right to know where that storage is.
    So yes, what tooks the 5MB email in place? i can't even see it.

  • How to delete the user text from the web gallery presets

    How can I delete my user text in the label section from the web module. I can't find a way.
    B Mammitzsch

    Hi Sean,
    no I mean the Site title or collecion title box. I hope you know what I mean.
    Greetings from the cornish coast
    B Mammitzsch

  • New user need help!! please! how to delete old user profiles...? a

    Hello Gents and Ladies. i just bought my slightly used macbook pro.Previous owner did not entirely delete his profile, my question is how do i completely delete old user profile? i deleted the old user and set a new profile in but for some reason under "System profiler" it still says old user's computer on it??
    i'm a newbie to macs. so i'm really lost here.. please help thanks!!!

    Open the Sharing pane of System Preferences and change the computer's name.
    (23562)

  • How to delete a user account??

    I made a account to let my guest use it but now I don't want it there anymore. It has the standard user preferences and I don't know how to delete it. Can someone please help me? Thanks

    Open the Users & Groups pane of System Preferences, unlock the pane, and click on it. If it’s not a guest user, press the - button. If it is, uncheck the box to allow guests to log in.
    (110360)

  • How to delete disabled users in SCCM 2012

    Currently we disable user accounts in AD and then move them to a different OU which they stay for 6 - 12 months.
    How can I identify those disabled users accounts and delete them form the SCCM console?
    Thank you

    Thanks for the response but there wasn't a process in place so was tasked with a one time cleanup and we don't have Orchestrator in place.
    I ended up doing the following:
    1.Use a powershell script to output all disabled user ID's
    Get-ADUser
    -Filter 'Enabled -eq $false'
    |Select-Object
    samaccountname
    2. Setup a Query on a collection to gather all these users ID's
    select *  from  SMS_R_User where SMS_R_User.UserName in ("User1", "user2")
    3. Delete the users in the collection

Maybe you are looking for

  • Getting imessages sent to other people

    I'm having repeated issues with my i messaging receiving messages incorrectly. A few weeks ago, I texted (iMessaged) a friend of mine. He received it but the message also popped up on my mom's phone but as if she had sent it. How weird?! When she rep

  • How can I change a decorated JFrame to non-decorated JFrame?

    I want to change a decorated JFrame to a non-decorated JFame. The frame already shown on the screen. How can I do this?

  • Questions in APP

    HI GURU'S 1) why do we give next payment run day in APP can any body explain with examples 2)Suppose if there are 100 open items  for payment if i want to block 25-30 items where we can block in F110 , (one r two we can block it but if its huge what

  • N8 Bettrey heat up very quickly

    Hello, I am having this problem with my nokia N8. Very recently, since I've gotten the AIS internet package. My mobile's battery heat up quickly within 20 to 30 minutes battery getting very warm and also charging goes down quickly. Some can please te

  • How do you change the image in a JPanel?

    Hey! (firstly, i need to use image on a JPanel, label&icon not an option). I've made my JPanel class     public class DrawingPanel extends JPanel {         Image img;         DrawingPanel() {             Image img = Toolkit.getDefaultToolkit().getIma